Skip to content
This repository was archived by the owner on Sep 19, 2025. It is now read-only.

Commit c2bd263

Browse files
Switch build target name based off compiler version number
1 parent 07bac27 commit c2bd263

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed

build-scripts/build_compiler.js

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,38 @@ const path = require("path");
3737
const runCommand = require("./run-command");
3838
const childProcess = require("child_process");
3939

40-
const compilerTargetName = "compiler_uberjar_deploy.jar";
40+
/**
41+
* The compiler version that will be built.
42+
*
43+
* For release builds, this is of the form: "vYYYYMMDD"
44+
* For nightly builds, this is "1.0-SNAPSHOT"
45+
*
46+
* @type {string}
47+
*/
48+
const compilerVersion = process.env.COMPILER_NIGHTLY == 'true'
49+
? 'SNAPSHOT-1.0'
50+
: String(
51+
childProcess.execSync('git tag --points-at HEAD', {
52+
cwd: './compiler',
53+
})
54+
).trim();
55+
56+
const compilerTargetName = compilerVersion === 'SNAPSHOT-1.0' || parseInt(compilerVersion.slice(1), 10) > 20221004 ?
57+
'compiler_uber_deploy.jar' : 'compiler_unshaded_deploy.jar';
4158
const compilerJavaBinaryPath = `./compiler/bazel-bin/${compilerTargetName}`;
4259

4360
async function main() {
4461
console.log(process.platform, process.arch, compilerVersion);
4562

4663
const { exitCode } = await runCommand(
47-
"bazelisk",
64+
'bazelisk',
4865
[
49-
"build",
50-
"--color=yes",
66+
'build',
67+
'--color=yes',
5168
`//:${compilerTargetName}`,
5269
`--define=COMPILER_VERSION=${compilerVersion}`,
5370
],
54-
{ cwd: "./compiler" }
71+
{ cwd: './compiler' }
5572
);
5673
if (exitCode !== 0) {
5774
throw new Error(exitCode);
@@ -60,40 +77,24 @@ async function main() {
6077
return Promise.all([
6178
copy(
6279
compilerJavaBinaryPath,
63-
"./packages/google-closure-compiler-java/compiler.jar"
80+
'./packages/google-closure-compiler-java/compiler.jar'
6481
),
6582
copy(
6683
compilerJavaBinaryPath,
67-
"./packages/google-closure-compiler-linux/compiler.jar"
84+
'./packages/google-closure-compiler-linux/compiler.jar'
6885
),
6986
copy(
7087
compilerJavaBinaryPath,
71-
"./packages/google-closure-compiler-osx/compiler.jar"
88+
'./packages/google-closure-compiler-osx/compiler.jar'
7289
),
7390
copy(
7491
compilerJavaBinaryPath,
75-
"./packages/google-closure-compiler-windows/compiler.jar"
92+
'./packages/google-closure-compiler-windows/compiler.jar'
7693
),
77-
copy("./compiler/contrib", "./packages/google-closure-compiler/contrib"),
94+
copy('./compiler/contrib', './packages/google-closure-compiler/contrib'),
7895
]);
7996
}
8097

81-
/**
82-
* The compiler version that will be built.
83-
*
84-
* For release builds, this is of the form: "vYYYYMMDD"
85-
* For nightly builds, this is "1.0-SNAPSHOT"
86-
*
87-
* @type {string}
88-
*/
89-
const compilerVersion = process.env.COMPILER_NIGHTLY == 'true'
90-
? "SNAPSHOT-1.0"
91-
: String(
92-
childProcess.execSync("git tag --points-at HEAD", {
93-
cwd: "./compiler",
94-
})
95-
).trim();
96-
9798
/**
9899
* @param {string} src path to source file or folder
99100
* @param {string} dest path to destination file or folder

0 commit comments

Comments
 (0)