electron/script/nan-spec-runner.js
electron-roller[bot] c3036d4557
chore: bump chromium to 117.0.5938.0 (main) (#39375)
* chore: bump chromium in DEPS to 117.0.5929.0

* chore: bump chromium in DEPS to 117.0.5931.0

* chore: bump chromium in DEPS to 117.0.5932.0

* chore: update patches

* 4728317: Prevent PrintRenderFrameHelper from printing when already printing
 | https://chromium-review.googlesource.com/c/chromium/src/+/4728317

* 4739501: Use base::SequenceBound to manage SerialPortManagerImpl |
 https://chromium-review.googlesource.com/c/chromium/src/+/4739501

* 4702051: Allow overriding source in install-sysroot.py | https://chromium-review.googlesource.com/c/chromium/src/+/4702051

* chore: update filenames.libcxx.gni

* 4727002: Rename "enable_arc2" to "enable_arc" |
https://chromium-review.googlesource.com/c/chromium/src/+/4727002

* chore: bump chromium in DEPS to 117.0.5934.0

* 4736873: Rename ColorSpaces methods on display::Display | https://chromium-review.googlesource.com/c/chromium/src/+/4736873

* 4727203: Replace bool with an enum in as suggested in DevtoolsManagerDelegate. | https://chromium-review.googlesource.com/c/chromium/src/+/4727203

* 4744479: [DevTools] Add 'generateTaggedPDF' option to DevTools Page.printToPDF | https://chromium-review.googlesource.com/c/chromium/src/+/4744479

* 4735893: Don't share WebUSB permissions with webviews | https://chromium-review.googlesource.com/c/chromium/src/+/4735893

* revert: update filenames.libcxx.gni

* chore: bump chromium in DEPS to 117.0.5936.0

* chore: update patches

* 4746465: SAA: Query for embargoed StorageAccess permissions | https://chromium-review.googlesource.com/c/chromium/src/+/4746465

* 4666325: Move buildtools/third_party/lib*/trunk source paths to third_party/lib*/src. | https://chromium-review.googlesource.com/c/chromium/src/+/4666325

* chore: bump chromium in DEPS to 117.0.5938.0

* chore: bump chromium in DEPS to 118.0.5939.0

* chore: update patches

* Send line bounds through CursorAnchorInfo on requestCursorUpdate

https://chromium-review.googlesource.com/c/chromium/src/+/4394588

* Fixup lint for Move buildtools/third_party/lib*/trunk source paths to third_party/lib*/src

* 4700305: [mac] Fix override of CHILD_PROCESS_EXE

https://chromium-review.googlesource.com/c/chromium/src/+/4700305

Needed because of 4729689: Reland "Remove redundant existence check in PathService" | https://chromium-review.googlesource.com/c/chromium/src/+/4729689

* 4753759: More consistent icon handling for menus.

https://chromium-review.googlesource.com/c/chromium/src/+/4753759

* chore: bump chromium in DEPS to 118.0.5941.0

* chore: update patches

* chore: bump chromium in DEPS to 117.0.5938.0

* test: update nan-spec-runner cflags

* build: fix isystem include path in nan-spec-runner

* fixup! 4666325: Move buildtools/third_party/lib*/trunk source paths to third_party/lib*/src. | https://chromium-review.googlesource.com/c/chromium/src/+/4666325

fix a few more instances of the old path

libc++.a and libc++abi.a are still in buildtools/

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: VerteDinde <vertedinde@electronjs.org>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2023-08-15 10:49:41 -05:00

142 lines
4.4 KiB
JavaScript

const cp = require('node:child_process');
const fs = require('node:fs');
const path = require('node:path');
const BASE = path.resolve(__dirname, '../..');
const NAN_DIR = path.resolve(BASE, 'third_party', 'nan');
const NPX_CMD = process.platform === 'win32' ? 'npx.cmd' : 'npx';
const utils = require('./lib/utils');
const { YARN_VERSION } = require('./yarn');
if (!require.main) {
throw new Error('Must call the nan spec runner directly');
}
const args = require('minimist')(process.argv.slice(2), {
string: ['only']
});
async function main () {
const outDir = utils.getOutDir({ shouldLog: true });
const nodeDir = path.resolve(BASE, 'out', outDir, 'gen', 'node_headers');
const env = {
...process.env,
npm_config_nodedir: nodeDir,
npm_config_msvs_version: '2019',
npm_config_arch: process.env.NPM_CONFIG_ARCH,
npm_config_yes: 'true'
};
const clangDir = path.resolve(BASE, 'third_party', 'llvm-build', 'Release+Asserts', 'bin');
const cc = path.resolve(clangDir, 'clang');
const cxx = path.resolve(clangDir, 'clang++');
const ld = path.resolve(clangDir, 'lld');
const platformFlags = [];
if (process.platform === 'darwin') {
const sdkPath = path.resolve(BASE, 'out', outDir, 'sdk', 'xcode_links');
const sdks = (await fs.promises.readdir(sdkPath)).filter(fileName => fileName.endsWith('.sdk'));
const sdkToUse = sdks[0];
if (!sdkToUse) {
console.error('Could not find an SDK to use for the NAN tests');
process.exit(1);
}
if (sdks.length) {
console.warn(`Multiple SDKs found in the xcode_links directory - using ${sdkToUse}`);
}
platformFlags.push(
`-isysroot ${path.resolve(sdkPath, sdkToUse)}`
);
}
// TODO(ckerr) this is cribbed from read obj/electron/electron_app.ninja.
// Maybe it would be better to have this script literally open up that
// file and pull cflags_cc from it instead of using bespoke code here?
// I think it's unlikely to work; but if it does, it would be more futureproof
const cxxflags = [
'-std=c++20',
'-Wno-trigraphs',
'-fno-exceptions',
'-fno-rtti',
'-nostdinc++',
`-isystem "${path.resolve(BASE, 'buildtools', 'third_party', 'libc++')}"`,
`-isystem "${path.resolve(BASE, 'third_party', 'libc++', 'src', 'include')}"`,
`-isystem "${path.resolve(BASE, 'third_party', 'libc++abi', 'src', 'include')}"`,
' -fvisibility-inlines-hidden',
'-fPIC',
'-D_LIBCPP_ABI_NAMESPACE=Cr',
...platformFlags
].join(' ');
const ldflags = [
'-stdlib=libc++',
'-fuse-ld=lld',
`-L"${path.resolve(BASE, 'out', outDir, 'obj', 'buildtools', 'third_party', 'libc++abi')}"`,
`-L"${path.resolve(BASE, 'out', outDir, 'obj', 'buildtools', 'third_party', 'libc++')}"`,
'-lc++abi',
...platformFlags
].join(' ');
if (process.platform !== 'win32') {
env.CC = cc;
env.CFLAGS = cxxflags;
env.CXX = cxx;
env.LD = ld;
env.CXXFLAGS = cxxflags;
env.LDFLAGS = ldflags;
}
const { status: buildStatus } = cp.spawnSync(NPX_CMD, ['node-gyp', 'rebuild', '--verbose', '--directory', 'test', '-j', 'max'], {
env,
cwd: NAN_DIR,
stdio: 'inherit'
});
if (buildStatus !== 0) {
console.error('Failed to build nan test modules');
return process.exit(buildStatus);
}
const { status: installStatus } = cp.spawnSync(NPX_CMD, [`yarn@${YARN_VERSION}`, 'install'], {
env,
cwd: NAN_DIR,
stdio: 'inherit'
});
if (installStatus !== 0) {
console.error('Failed to install nan node_modules');
return process.exit(installStatus);
}
const onlyTests = args.only && args.only.split(',');
const DISABLED_TESTS = new Set([
'nannew-test.js',
'buffer-test.js'
]);
const testsToRun = fs.readdirSync(path.resolve(NAN_DIR, 'test', 'js'))
.filter(test => !DISABLED_TESTS.has(test))
.filter(test => {
return !onlyTests || onlyTests.includes(test) || onlyTests.includes(test.replace('.js', '')) || onlyTests.includes(test.replace('-test.js', ''));
})
.map(test => `test/js/${test}`);
const testChild = cp.spawn(utils.getAbsoluteElectronExec(), ['node_modules/.bin/tap', ...testsToRun], {
env: {
...process.env,
ELECTRON_RUN_AS_NODE: 'true'
},
cwd: NAN_DIR,
stdio: 'inherit'
});
testChild.on('exit', (testCode) => {
process.exit(testCode);
});
}
main().catch((err) => {
console.error('An unhandled error occurred in the nan spec runner', err);
process.exit(1);
});