microsoft / vscode-makefile-tools

MAKE integration in Visual Studio Code
Other
194 stars 58 forks source link

Environment variables #123

Open andreeis opened 3 years ago

andreeis commented 3 years ago

Requested by users to have, as CMake Tools does, a setting for environment variables. This would be an alternative to preconfigure script. Maybe also per configuration or only global...

avrahamshukron commented 3 years ago

It will be most useful as a per-config option

IoriBranford commented 3 years ago

Great for specifying a temporary PATH, instead of messing with the system PATH which is now required if you want to use MSYS2/MinGW make with this extension.

gunterkoenigsmann commented 1 year ago

On mingw that would also be practical for setting the following variables:

                CHERE_INVOKING=1,
                MSYS2_PATH_TYPE="inherit",
                MINGW_CHOST="x86_64-w64-mingw32",
                MINGW_PACKAGE_PREFIX="mingw-w64-x86_64",
                MSYSTEM="MINGW64",
                MSYSTEM_CARCH="x64_64",

Without them for example compiling wxWidgets and finding a compiled wxWidgets or your gettext installation from ./configure fails.

For compiling wxWidgets, applications that use it or applications that use gettext and similar stuff in the Visual Studio Code's console the following seems to work:

{
    "terminal.integrated.profiles.windows": {
        "msys64 - bash": {
            "path": "C:\\msys64\\usr\\bin\\bash.exe",
            "env": {
                "MINGW_PREFIX": "C:/msys64/mingw64",
                "CHERE_INVOKING": "1",
                "MSYS2_PATH_TYPE": "inherit",
                "MINGW_CHOST ": "x86_64-w64-mingw32",
                "MINGW_PACKAGE_PREFIX": "mingw-w64-x86_64",
                "MSYSTEM": "MINGW64",
                "MSYSTEM_CARCH": "x64_64",
                "MSYSTEM_PREFIX": "${env.MINGW_PREFIX}",
                "SHELL": "${env.MINGW_PREFIX}/../usr/bin/bash",
                "TEMP": "${env.MINGW_PREFIX}/../tmp",
                "TMP": "${env.TEMP}",
                "PATH": "${env.MINGW_PREFIX}/bin;${env.MINGW_PREFIX}/../usr/local/bin;${env.MINGW_PREFIX}/../usr/bin;${env.PATH}",
                "INCLUDE": "project/lib/include;${env.MINGW_PREFIX}/mingw/include"                
            },
            "args": ["--login"]
     }
    },
    "terminal.integrated.defaultProfile.windows": "msys64 - bash",

...but that works only on the console, not in a build using the makefile extension.

gunterkoenigsmann commented 1 year ago

As a 2nd thought additionally for debug builds one might want different LDFLAGS, CFLAGS - and perhaps might want to set things like WXTRACE before launching the program.

bobbrow commented 1 year ago

@gunterkoenigsmann Are you able to set the environment using the makefile.preConfigureScript setting? You should be able to make environment variable changes with a pre-configure script and we will apply those to the build environment. When this feature is implemented you would not need the pre-configure script any longer.