diff --git a/src/kit.ts b/src/kit.ts index ae75af6fa0..6bb7ab0822 100644 --- a/src/kit.ts +++ b/src/kit.ts @@ -1172,6 +1172,8 @@ export async function effectiveKitEnvironment(kit: Kit, opts?: expand.ExpansionO } } if (kit.environmentSetupScript) { + /* TODO: Question, do we need override kit.environmentVariables with kit.environmentSetupScript or + override kit.environmentSetupScript with kit.environmentVariables, who has the higher priority */ const shell_vars = await getShellScriptEnvironment(kit, opts); if (shell_vars) { host_env = shell_vars; @@ -1181,30 +1183,29 @@ export async function effectiveKitEnvironment(kit: Kit, opts?: expand.ExpansionO // get host_env from process if it was not set by shell script before host_env = process.env; } - if (kit.visualStudio && kit.visualStudioArchitecture) { - const vs_vars = await getVSKitEnvironment(kit); - if (vs_vars) { - return vs_vars; - } - } - const env = EnvironmentUtils.merge([host_env, kit_env]); - const isWin32 = process.platform === 'win32'; - if (isWin32) { - const path_list: string[] = []; - const cCompiler = kit.compilers?.C; - /* Force add the compiler executable dir to the PATH env */ - if (cCompiler) { - path_list.push(path.dirname(cCompiler)); - } - const cmt_mingw_path = env['CMT_MINGW_PATH']; - if (cmt_mingw_path) { - path_list.push(cmt_mingw_path); - } - if (env.hasOwnProperty('PATH')) { - path_list.unshift(env['PATH'] ?? ''); - env['PATH'] = path_list.join(';'); + let env = EnvironmentUtils.merge([host_env, kit_env]); + if (process.platform === 'win32') { + if (kit.visualStudio && kit.visualStudioArchitecture) { + const vs_vars = await getVSKitEnvironment(kit); + env = EnvironmentUtils.merge([env, vs_vars]); + } else { + const path_list: string[] = []; + const cCompiler = kit.compilers?.C; + /* Force add the compiler executable dir to the PATH env */ + if (cCompiler) { + path_list.push(path.dirname(cCompiler)); + } + const cmt_mingw_path = env['CMT_MINGW_PATH']; + if (cmt_mingw_path) { + path_list.push(cmt_mingw_path); + } + if (env.hasOwnProperty('PATH')) { + path_list.unshift(env['PATH'] ?? ''); + env['PATH'] = path_list.join(';'); + } } } + log.debug(localize('kit.env', 'The environment variables for kit {0} is: {1}', `'${kit.name}'`, JSON.stringify(env))); return env; }