Skip to content

Commit a7e1f70

Browse files
committed
fix: precompute full_version string to avoid stage2 checkmissingreturns false positive
1 parent 343a9ce commit a7e1f70

4 files changed

Lines changed: 9 additions & 7 deletions

File tree

scripts/gen-version.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ try {
1414

1515
const buildDate = new Date().toISOString().slice(0, 10);
1616

17+
const fullVersion = `${pkg.version}-${gitCommit}-${buildDate}`;
18+
1719
writeFileSync(
1820
"src/version.ts",
19-
`export const VERSION = "${pkg.version}";\nexport const GIT_COMMIT = "${gitCommit}";\nexport const BUILD_DATE = "${buildDate}";\n`,
21+
`export const VERSION = "${pkg.version}";\nexport const GIT_COMMIT = "${gitCommit}";\nexport const BUILD_DATE = "${buildDate}";\nexport const FULL_VERSION = "${fullVersion}";\n`,
2022
);

src/chad-native.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ declare function cs_watch_loop(
6060
output_binary: string,
6161
): void;
6262

63-
import { VERSION, GIT_COMMIT, BUILD_DATE } from "./version.js";
63+
import { FULL_VERSION } from "./version.js";
6464

6565
const parser = new ArgumentParser("chad", "compile TypeScript to native binaries via LLVM");
6666
// Color enabled unless NO_COLOR is set (https://no-color.org/) or TERM=dumb
@@ -119,7 +119,7 @@ parser.addPositional("input", "Input .ts or .js file");
119119
parser.parse(process.argv);
120120

121121
if (parser.getFlag("version")) {
122-
console.log("chad " + VERSION + "-" + GIT_COMMIT + "-" + BUILD_DATE);
122+
console.log("chad " + FULL_VERSION);
123123
process.exit(0);
124124
}
125125

src/chad-node.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import * as path from "path";
3131
import * as fs from "fs";
3232
import { execSync, spawn as spawnProc, ChildProcess } from "child_process";
3333
import { installTargetSDK, listInstalledSDKs, getSDKBaseDir } from "./cross-compile.js";
34-
import { VERSION, GIT_COMMIT, BUILD_DATE } from "./version.js";
34+
import { FULL_VERSION } from "./version.js";
3535

3636
const parser = new ArgumentParser("chad", "compile TypeScript to native binaries via LLVM");
3737
parser.setColorEnabled(process.stdout.isTTY === true);
@@ -104,7 +104,7 @@ parser.addPositional("input", "Input .ts or .js file");
104104
parser.parse(process.argv.slice(2));
105105

106106
if (parser.getFlag("version")) {
107-
console.log(`chad ${VERSION}-${GIT_COMMIT}-${BUILD_DATE}`);
107+
console.log(`chad ${FULL_VERSION}`);
108108
process.exit(0);
109109
}
110110

src/compiler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { AST, ImportDeclaration, ClassNode, FunctionNode } from "./ast/types.js"
1111
import { type LogLevel, LogLevel_Normal, LogLevel_Verbose, logger } from "./utils/logger.js";
1212
import { TargetInfo, resolveTarget, getHostTarget, isCrossCompiling } from "./target.js";
1313
import { loadTargetSDK, ensureTargetSDK, TargetSDK } from "./cross-compile.js";
14-
import { VERSION, GIT_COMMIT, BUILD_DATE } from "./version.js";
14+
import { FULL_VERSION } from "./version.js";
1515
import { setGlobalDiagnosticColor } from "./diagnostics/engine.js";
1616

1717
function findLLVMTool(name: string): string {
@@ -192,7 +192,7 @@ export function compile(
192192
const target = targetOverride || getHostTarget();
193193
const crossCompiling = isCrossCompiling(target);
194194

195-
logger.info(`ChadScript compiler version ${VERSION}-${GIT_COMMIT}-${BUILD_DATE}`);
195+
logger.info(`ChadScript compiler version ${FULL_VERSION}`);
196196
logger.info(`Target: ${target.archString}-${target.platformString}`);
197197
if (crossCompiling) {
198198
logger.info(`Cross-compiling for ${target.triple}`);

0 commit comments

Comments
 (0)