Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from multiple builddir to required builddir #233

Open
zenshosan opened this issue May 15, 2024 · 2 comments
Open

Switch from multiple builddir to required builddir #233

zenshosan opened this issue May 15, 2024 · 2 comments

Comments

@zenshosan
Copy link

zenshosan commented May 15, 2024

Hi I have recently started using meson.
I'd like to add the following feature to vscode-meson.

What

When developing software using compiled languages such as c++ or rust, it often happens to switch between multiple build configurations such as so-called 'release' and 'debug'.

In meson, this is supposed to be done by creating multiple builddirs and switching between them. (see Using multiple build directories)

In vscode-meson, switching between builddirs requires rewriting mesonbuild.buildFolder in settings.json, which is not very convenient.

I would like to be able to switch this easily.

How to work

I will explain how these can be realized given the knowledge gained from reading the threads and source code below. (because I'm new)

#201
#195
#188
#179
#101
#22
#103

Currently vscode-meson reactivates itself by calling reloadWindow when sourceDir is selected or mesonbuild.buildFolder is changed.

Although reloading is generally an undesirable behavior, I'd like to follow this behavior for the time being to minimize source code changes by reloading when switching buildDirs.
(Avoiding reloads should be a separate issue.)

Specification overview

  1. Automatic launch of selection UI at first startup
    Basically, add a buildDir selection flow after the user selects sourceDir.
    This also includes leaving sourceDir as is and selecting only buildDir.

    • buildDir selection UI
      Unlike sourceDir selection, it does not search the file system to collect existing buildDir. User enters the path manually or selects from previous entries.

    • Saving sourceDir selection
      This buildDir selection is permanently remembered in memento, just like sourceDir.
      On the next time startup, these values ​​will be applied and the user does not need to make a selection.

  2. Explicit selection UI launch from command or builddir selection via MesonProjectExplorer
    Users can also launch the selection UI from the command palette or select a builddir directly from the MesonProjectExplorer in the side panel.

  3. Save format of buildDir
    I expect that "mesonbuild.buildFolder" is probably unnecessary or a less important setting.
    The buildDir selected by the UI is permanently saved in the format below.
    Please note that multiple buildDirs are stored per sourceDir, and the most recently used one is placed at 0th.

type BuildConfig = {
    buildDir: string;     // path to builddir
    friendlyName: string; // for displaying of MesonProjectExplorer
  };
type BuildConfigMap = {
    [sourceDir: string]: BuildConfig[] // multiple builddirs per sourceDir
};

// example
let buildDirsMap: BuildConfigMap = {
    "path/to/sourceDir1": [
        {
            buildDir: "path/to/sourceDir1/build_dbg",
            friendlyName: "x64_dbg",
        },
        {
            buildDir: "path/to/sourceDir1/build_rel",
            friendlyName: "x64_rel",
        },
    ],
    "path/to/sourceDir2": [
        {
            // It can also happen if buildDir is outside of sourceDir.
            buildDir: "path/to/out/of/sourceDir2/build_dbg",
            friendlyName: "x64_dbg",
        },
        {
            buildDir: "path/to/out/of/sourceDir2/build_rel",
            friendlyName: "x64_rel",
        },
    ],
};

workspaceState.update("mesonbuild.buildDirsMap", buildDirsMap);

We need to discuss the details further, but for now I would like to hear everyone's opinions.

Thank you.

@tristan957
Copy link
Contributor

I think what you are proposing sounds reasonable. It would be good to make the automatic popup optional via a setting

@zenshosan
Copy link
Author

I think what you are proposing sounds reasonable. It would be good to make the automatic popup optional via a setting

Thank you. I have considered about it.
It is better to integrate buildDir selection into the sourceDir selection UI.
Therefore, in this case, the popup settings should just follow the existing mesonbuild.selectRootDir.
(No need to introduce mesonbuild.selectBuildDir)

However, if you have sourceDir and only select buildDir, we will need to switch the popup wording.

So, is it like this?

if (!hasSourceDir) {}
    showInformationMessage("Multiple Meson projects detected, select one?");
} else {
    showInformationMessage("Build directory is not set. Do you want to set it?");
}

This might be somewhat confusing for users.
This is because if you reply "Never" to the former message, the latter message will also no longer be displayed.
Personally, this is acceptable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants