DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: "Burakov, Anatoly" <anatoly.burakov@intel.com>
Cc: <dev@dpdk.org>, <john.mcnamara@intel.com>
Subject: Re: [RFC PATCH v2 1/1] devtools: add vscode configuration generator
Date: Mon, 29 Jul 2024 17:41:04 +0100	[thread overview]
Message-ID: <ZqfGIJQOlB6di69-@bricha3-mobl1.ger.corp.intel.com> (raw)
In-Reply-To: <3edc6421-0923-4371-a7dd-62d3857259ab@intel.com>

On Mon, Jul 29, 2024 at 06:16:48PM +0200, Burakov, Anatoly wrote:
> On 7/29/2024 4:30 PM, Bruce Richardson wrote:
> > On Mon, Jul 29, 2024 at 02:05:52PM +0100, Anatoly Burakov wrote:
> > > A lot of developers use Visual Studio Code as their primary IDE. This
> > > script generates a configuration file for VSCode that sets up basic build
> > > tasks, launch tasks, as well as C/C++ code analysis settings that will
> > > take into account compile_commands.json that is automatically generated
> > > by meson.
> > > 
> > > Files generated by script:
> > >   - .vscode/settings.json: stores variables needed by other files
> > >   - .vscode/tasks.json: defines build tasks
> > >   - .vscode/launch.json: defines launch tasks
> > >   - .vscode/c_cpp_properties.json: defines code analysis settings
> > > 
> > > The script uses a combination of globbing and meson file parsing to
> > > discover available apps, examples, and drivers, and generates a
> > > project-wide settings file, so that the user can later switch between
> > > debug/release/etc. configurations while keeping their desired apps,
> > > examples, and drivers, built by meson, and ensuring launch configurations
> > > still work correctly whatever the configuration selected.
> > > 
> > > This script uses whiptail as TUI, which is expected to be universally
> > > available as it is shipped by default on most major distributions.
> > > However, the script is also designed to be scriptable and can be run
> > > without user interaction, and have its configuration supplied from
> > > command-line arguments.
> > > 
> > > Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> > > ---
> > > 
> > Just was trying this out, nice script, thanks.
> 
> Thanks for the feedback! Comments below.
> 
> > 
> > Initial thoughts concerning the build directory:
> > - the script doesn't actually create the build directory, so there is no
> >    guarantee that the build directory created will have the same parameters
> >    as that specified in the script run. I'd suggest in the case where the
> >    user runs the script and specifies build settings, that the build
> >    directory is then configured using those settings.
> 
> I'm not sure I follow.
> 
> The script creates a command for VSCode to create a build directory using
> configuration the user has supplied at script's run time. The directory is
> not created by the script, that is the job of meson build system. This
> script is merely codifying commands for meson to do that, with the
> expectation that the user is familiar with VSCode workflow and will go
> straight to build commands anyway, and will pick one of them. Are you
> suggesting running `meson setup` right after?
> 

Yes, that is what I was thinking, based on the assumption that running
"meson setup" should be a once-only task. I suppose overall it's a
different workflow to what you have - where you run meson setup repeatedly
each time you change a build type. My thinking for the approach to take
here is that your script firstly asks for a build directory, and then:
* if build-dir exists, pull settings you need from there, such as build
  type and the apps being built.
* if not existing, ask for config settings as you do now, and then run
  meson setup to create the build dir.

Thereafter, the source for all build settings is not in vscode, but in
meson, and you just use "meson configure" from vscode to tweak whatever
needs tweaking, without affecting any other settings. Since you don't
affect any other settings there is no need to record what they should be.


> Assuming we do that, it would actually then be possible to adjust launch
> tasks to only include *actual* built apps/examples (as well as infer things
> like platform, compiler etc.), as that's one weakness of my current "flying
> blind" approach, so I wouldn't be opposed to adding an extra step here, just
> want to make sure I understand what you're saying correctly.
> 
> > 
> > - On the other hand, when the build directory already exists - I think the
> >    script should pull all settings from there, rather than prompting the
> >    user.
> > 
> 
> That can be done, however, my own workflow has been that I do not ever keep
> build directories inside my source directory, so it would not be possible to
> pick up directories anywhere but the source directory.
> 

Why is that, and how does it work now, for e.g. getting the
compile_commands.json file from your build folder?

> I also think from the point of view of the script it would be easier to
> start from known quantities rather than guess what user was trying to do
> from current configuration, but I guess a few common-sense heuristics should
> suffice for most use cases, such as e.g. inferring debug builds.
> 

What you need depends on whether you want to keep running "meson setup" -
which means you need to track all settings - or want to use "meson
configure" where you don't really need to track much at all.

> > - I'm not sure I like the idea for reconfiguring of just removing the build
> >    directory and doing a whole meson setup command all over again. This
> >    seems excessive and also removes the possibility of the user having made
> >    changes in config to the build dir without re-running the whole config
> >    script. For example, having tweaked the LTO setting, or the
> >    instruction_set_isa_setting. Rather than deleting it and running meson
> >    setup, it would be better to use "meson configure" to adjust the one
> >    required setting and let ninja figure out how to propagate that change.
> >    That saves the script from having to track all meson parameters itself.
> 
> Last I checked, meson doesn't have a command that would "setup or configure
> existing" a directory, it's either "set up new one" or "configure existing
> one". I guess we could set up a fallback of "configure || setup".
> 

This goes back to the whole "create build directory after running the
script" option. If the script creates the build dir, the vscode commands
never need to use meson setup, only ever meson configure.

> > 
> > - Finally, and semi-related, this script assumes that the user does
> >    everything in a single build directory. Just something to consider, but
> >    my own workflow till now has tended to keep multiple build directories
> >    around, generally a "build" directory, which is either release or
> >    debugoptimized type, and a separate "build-debug" directory + occasionally
> >    others for build testing. When doing incremental builds, the time taken to
> >    do two builds following a change is a lot less noticable than the time taken
> >    for periodic switches of a single build directory between debug and release
> >    mode.
> 
> The problem with that approach is the launch tasks, because a launch task
> can only ever point to one executable, so if you have multiple build
> directories, you'll have to have multiple launch tasks per app/example. I
> guess we can either tag them (e.g. "Launch dpdk-testpmd [debug]", "Launch
> dpdk-testpmd [asan]" etc.), or use some kind of indirection to "select
> active build configuration" (e.g. have one launch task but overwrite
> ${config:BUILDDIR} after request for configuration, so that launch tasks
> would pick up actual executable path at run time from settings). I would
> prefer the latter to be honest, as it's much easier to drop a script into
> ./vscode and run it together with "configure" command to switch between
> different build/launch configurations. What do you think?
> 

I think I'd prefer the former actually - to have explicit tasks always
listed for debug and release builds.
Not a big deal for me either way, I'll just hack in the extra tasks as I
need them, so it's a low-priority support item for me.

> > 
> > Final thoughts on usability:
> > 
> > - Please don't write gdbsudo to /usr/local/bin without asking the user
> >    first. Instead I think it should default to $HOME/.local/bin, but with a
> >    prompt for the user to specify a path.
> 
> It's not creating anything, it's just printing out a snippet, which, if run
> by user, would do that - the implication is obviously that the user may
> correct it if necessary. The script actually picks up path to `gdbsudo` from
> `which` command, so if the user puts their command to $HOME/.local/bin or
> something, it would get picked up if it's in PATH. I see your point about
> maybe suggesting using a home directory path instead of a system wide path,
> I can change that.

Yep, thanks, and thanks for the explanation.
BTW: even if the user is running as non-root user, they don't always need
to use sudo (I set up my system to not need it for running DPDK). I see
there is a cmdline option for "no-gdbsudo" but I think you should make that
accessible via TUI also if non-root.

And for the cmdline parameters, how about shortening them to "--sudo" and
"--nosudo". For debug vs release builds you may want to have the latter run
without gdb at all, just with or without sudo.]

> 
> > 
> > - While I realise your primary concern here is an interactive script, I'd
> >    tend towards requiring a cmdline arg to run in interactive mode and
> >    instead printing the help usage when run without parameters. Just a
> >    personal preference on my part though.
> 
> I found it to be much faster to pick my targets, apps etc. using a couple of
> interactive windows than to type out parameters I probably don't even
> remember ahead of time (especially build configurations!), and I believe
> it's more newbie-friendly that way, as I imagine very few people will want
> to learn arguments for yet-another-script just to start using VSCode. It
> would be my personal preference to leave it as default-to-TUI, but maybe
> recognizing a widely used `-i` parameter would be a good compromise for
> instant familiarity.
> 

Ok. There's always a -h option for me to get the cmdline parameters.

I also think if the script is ok with working off an existing build
directory (or directories!), and only prompting for that, it would remove
for me the real necessity of asking for a more cmdline-fieldly version.


  reply	other threads:[~2024-07-29 16:41 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-26 12:42 [RFC PATCH v1 0/1] Add Visual Studio Code configuration script Anatoly Burakov
2024-07-26 12:42 ` [RFC PATCH v1 1/1] devtools: add vscode configuration generator Anatoly Burakov
2024-07-26 15:36   ` Stephen Hemminger
2024-07-26 16:05     ` Burakov, Anatoly
2024-07-29 13:05 ` [RFC PATCH v2 0/1] Add Visual Studio Code configuration script Anatoly Burakov
2024-07-29 13:05   ` [RFC PATCH v2 1/1] devtools: add vscode configuration generator Anatoly Burakov
2024-07-29 13:14     ` Bruce Richardson
2024-07-29 13:17       ` Burakov, Anatoly
2024-07-29 14:30     ` Bruce Richardson
2024-07-29 16:16       ` Burakov, Anatoly
2024-07-29 16:41         ` Bruce Richardson [this message]
2024-07-30  9:21           ` Burakov, Anatoly
2024-07-30 10:31             ` Bruce Richardson
2024-07-30 10:50               ` Burakov, Anatoly
2024-07-30 15:01   ` [RFC PATCH v2 0/1] Add Visual Studio Code configuration script Bruce Richardson
2024-07-30 15:14     ` Burakov, Anatoly
2024-07-30 15:19       ` Bruce Richardson
2024-07-31 13:33 ` [RFC PATCH v3 " Anatoly Burakov
2024-07-31 13:33   ` [RFC PATCH v3 1/1] buildtools: add vscode configuration generator Anatoly Burakov
2024-09-02 12:17 ` [PATCH v1 0/1] Add Visual Studio Code configuration script Anatoly Burakov
2024-09-02 12:17   ` [PATCH v1 1/1] buildtools: add VSCode configuration generator Anatoly Burakov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZqfGIJQOlB6di69-@bricha3-mobl1.ger.corp.intel.com \
    --to=bruce.richardson@intel.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=john.mcnamara@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).