Files
orca/config/scripts/desktop-distribution/runtime-verification/electron-builder-native-rebuild.cjs
Neil 9bd6272fdf refactor(tooling): organize build, CI, and test owners (#38130)
* refactor(tooling): organize test runtime and maintenance owners

* test(tooling): preserve relocated runtime fixture dependency edges

* refactor(tooling): preserve xterm routing owner checks

* ci(tooling): include routing owner in sparse checkout

* test(tooling): preserve copied workflow dependency closures

* fix(tooling): normalize hashed JSON assets in release parity

* fix(tooling): distinguish asset aliases from literal references

* fix(tooling): frame normalized asset reference payloads

* fix(tooling): normalize decoded JSON asset references

* refactor(tooling): organize build, CI and release owners

* fix(tooling): align moved generator and workflow path contracts

* fix(tooling): update generated plugin bundle owner banners

* test(tooling): create relocated mobile verifier fixture directories

* test(tooling): copy headless detector dependency closure

* test(tooling): align native batch policy fixtures with owner path

* fix(tooling): link moved reliability command to historical evidence

* fix(tooling): preserve nested sandbox owners and canonical guide source

* fix(tooling): target release version owners in checkout fixture
2026-11-04 21:08:19 -08:00

79 lines
2.4 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const { execFileSync } = require('node:child_process')
const { resolve } = require('node:path')
const projectDir = resolve(__dirname, '../../../..')
function electronBuilderNativeRebuild(context) {
return runElectronBuilderNativeRebuild(context)
}
function runElectronBuilderNativeRebuild(context, runner = execFileSync, runtime = {}) {
const args = buildNativeRebuildArgs(context, runtime)
if (readPlatformName(context?.platform) === 'win32') {
runner(
process.execPath,
['config/scripts/native-build/windows/build-windows-cli-launcher.mjs'],
{
cwd: projectDir,
stdio: 'inherit'
}
)
// Packaging rejects a hook built for another machine, so build the one this package targets.
runner(
process.execPath,
[
'config/scripts/native-build/windows/build-windows-agent-hook.mjs',
'--arch',
readArchName(context?.arch)
],
{ cwd: projectDir, stdio: 'inherit' }
)
}
runner(process.execPath, args, {
cwd: projectDir,
stdio: 'inherit'
})
// Return false to skip electron-builder’s all-module rebuild of optional cpu-features.
return false
}
function buildNativeRebuildArgs(
context,
{ environment = process.env, hostPlatform = process.platform, hostArch = process.arch } = {}
) {
const platform = readPlatformName(context?.platform)
const arch = readArchName(context?.arch)
const canReusePreparedRuntime =
environment.ORCA_REUSE_PREPARED_NATIVE_RUNTIME === '1' &&
platform === hostPlatform &&
arch === hostArch
return [
'config/scripts/native-build/node-addons/rebuild-native-deps.mjs',
`--platform=${platform}`,
`--arch=${arch}`,
...(canReusePreparedRuntime ? [] : ['--force'])
]
}
function readPlatformName(platform) {
const name = typeof platform === 'string' ? platform : platform?.nodeName
if (!name) {
throw new Error('electron-builder native rebuild context is missing platform.nodeName')
}
return name
}
function readArchName(arch) {
if (!arch || typeof arch !== 'string') {
throw new Error('electron-builder native rebuild context is missing arch')
}
return arch
}
module.exports = electronBuilderNativeRebuild
module.exports.default = electronBuilderNativeRebuild
module.exports.buildNativeRebuildArgs = buildNativeRebuildArgs
module.exports.runElectronBuilderNativeRebuild = runElectronBuilderNativeRebuild