Build-system cleanup

This commit is contained in:
James Babcock committed 2026-10-23 17:29:05 -07:00
1 parent bce2307fdb
commit da44ade803
3 files changed
+34 -31

No files matched your search

+12 -11
View File
@@ -30,19 +30,20 @@ async function buildKotlin(platform, configuration = 'debug') {
if (!['debug', 'release'].includes(configuration)) throw new Error(`Unsupported Kotlin configuration: ${configuration}`);
const variant = configuration === 'release' ? 'Release' : 'Debug';
const task = platform === 'android' ? ':shared:assembleAndroidMain' : `:shared:assembleFaceclawKit${variant}XCFramework`;
const wrapper = path.join(root, 'wear', process.platform === 'win32' ? 'gradlew.bat' : 'gradlew');
const windows = process.platform === 'win32';
const wrapper = path.join(root, 'wear', windows ? 'gradlew.bat' : 'gradlew');
// Through cmd.exe a missing wrapper is only "not recognized" and exit 1.
if (!existsSync(wrapper)) throw new Error(`Gradle wrapper not found: ${wrapper}`);
const args = [task, '--console=plain'];
console.log(`[kotlin] Building ${platform} (${configuration})`);
await new Promise((resolve, reject) => {
// A .bat cannot be exec'd directly: Node passes it to CreateProcess, which
// rejects it with EINVAL. cmd.exe has to run it, so the Windows path goes
// through a shell, quoted because the checkout may sit under a path with
// spaces in it.
const windows = process.platform === 'win32';
const child = spawn(windows ? `"${wrapper}"` : wrapper, [task, '--console=plain'], {
cwd: kotlin,
stdio: 'inherit',
shell: windows,
});
// Node refuses to spawn a .bat directly (EINVAL, since the CVE-2024-27980
// fix), so cmd.exe runs it. It gets one command string because args
// alongside shell: true are deprecated (DEP0190); the wrapper is quoted for
// checkouts under paths with spaces.
const child = windows
? spawn(`"${wrapper}" ${args.join(' ')}`, { cwd: kotlin, stdio: 'inherit', shell: true })
: spawn(wrapper, args, { cwd: kotlin, stdio: 'inherit' });
child.on('error', reject);
child.on('exit', (code, signal) => {
if (code === 0) resolve();