Skip to content

Commit

Permalink
Revise effectiveKitEnvironment to fixes #2354
Browse files Browse the repository at this point in the history
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
  • Loading branch information
lygstate committed Feb 6, 2022
1 parent d31f5b3 commit da5747a
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions src/kit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down

0 comments on commit da5747a

Please sign in to comment.