Skip to content

Commit 7cea069

Browse files
authored
Merge pull request #3850 from bikallem/patch-2
Fixes #3843
2 parents 9f45e70 + d919834 commit 7cea069

File tree

1 file changed

+37
-27
lines changed

1 file changed

+37
-27
lines changed

scripts/install.js

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -201,39 +201,49 @@ function install(stdlib) {
201201
* @param {string} sys_extension
202202
*
203203
*/
204-
function createCopyNinja(sys_extension) {
205-
var output = "";
206-
switch (sys_extension) {
207-
case ".win32":
208-
output += `
209-
rule cp
210-
command = cmd /q /c copy $in $out 1>nul
211-
`;
212-
break;
213-
default:
214-
output += `
204+
function copyPrebuiltCompilersForUnix(sys_extension) {
205+
var output = `
215206
rule cp
216207
command = cp $in $out
217208
`;
218-
break;
219-
}
220-
output += ["bsc", "bsb", "bsb_helper", "bsppx", "refmt"]
221-
.map(function(x) {
222-
return `build ${x}.exe: cp ${x}${sys_extension}`;
223-
})
224-
.join("\n");
225-
output += "\n";
226-
return output;
209+
output += preBuiltCompilerArtifacts
210+
.map(function (x) {
211+
return `build ${x}.exe: cp ${x}${sys_extension}`;
212+
})
213+
.join("\n");
214+
output += "\n";
215+
216+
var filePath = path.join(lib_dir, "copy.ninja");
217+
fs.writeFileSync(filePath, output, "ascii");
218+
cp.execFileSync(ninja_bin_output, ["-f", "copy.ninja"], {
219+
cwd: lib_dir,
220+
stdio: [0, 1, 2]
221+
});
222+
fs.unlinkSync(filePath);
223+
}
224+
225+
/**
226+
*
227+
* @param {string} sys_extension
228+
*
229+
*/
230+
function copyPrebuiltCompilersForWindows(sys_extension) {
231+
preBuiltCompilerArtifacts
232+
.forEach(function (x) {
233+
fs.copyFileSync(path.join(lib_dir, `${x}${sys_extension}`), path.join((lib_dir), `${x}.exe`));
234+
});
227235
}
228236

229237
function copyPrebuiltCompilers() {
230-
var filePath = path.join(lib_dir, "copy.ninja");
231-
fs.writeFileSync(filePath, createCopyNinja(sys_extension), "ascii");
232-
cp.execFileSync(ninja_bin_output, ["-f", "copy.ninja"], {
233-
cwd: lib_dir,
234-
stdio: [0, 1, 2]
235-
});
236-
fs.unlinkSync(filePath);
238+
switch (sys_extension) {
239+
case ".win32":
240+
copyPrebuiltCompilersForWindows(sys_extension);
241+
break;
242+
243+
default:
244+
copyPrebuiltCompilersForUnix(sys_extension);
245+
break;
246+
}
237247
}
238248

239249
/**

0 commit comments

Comments
 (0)