chore: fix nan spec runner on macOS (#34447)
This commit is contained in:
parent
30d15715a9
commit
4ec2de659f
1 changed files with 28 additions and 5 deletions
|
@ -18,7 +18,8 @@ const args = require('minimist')(process.argv.slice(2), {
|
||||||
});
|
});
|
||||||
|
|
||||||
async function main () {
|
async function main () {
|
||||||
const nodeDir = path.resolve(BASE, `out/${utils.getOutDir({ shouldLog: true })}/gen/node_headers`);
|
const outDir = utils.getOutDir({ shouldLog: true });
|
||||||
|
const nodeDir = path.resolve(BASE, 'out', outDir, 'gen', 'node_headers');
|
||||||
const env = Object.assign({}, process.env, {
|
const env = Object.assign({}, process.env, {
|
||||||
npm_config_nodedir: nodeDir,
|
npm_config_nodedir: nodeDir,
|
||||||
npm_config_msvs_version: '2019',
|
npm_config_msvs_version: '2019',
|
||||||
|
@ -31,6 +32,25 @@ async function main () {
|
||||||
const cxx = path.resolve(clangDir, 'clang++');
|
const cxx = path.resolve(clangDir, 'clang++');
|
||||||
const ld = path.resolve(clangDir, 'lld');
|
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.
|
// 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
|
// 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?
|
// file and pull cflags_cc from it instead of using bespoke code here?
|
||||||
|
@ -41,15 +61,17 @@ async function main () {
|
||||||
`-isystem"${path.resolve(BASE, 'buildtools', 'third_party', 'libc++')}"`,
|
`-isystem"${path.resolve(BASE, 'buildtools', 'third_party', 'libc++')}"`,
|
||||||
`-isystem"${path.resolve(BASE, 'buildtools', 'third_party', 'libc++', 'trunk', 'include')}"`,
|
`-isystem"${path.resolve(BASE, 'buildtools', 'third_party', 'libc++', 'trunk', 'include')}"`,
|
||||||
`-isystem"${path.resolve(BASE, 'buildtools', 'third_party', 'libc++abi', 'trunk', 'include')}"`,
|
`-isystem"${path.resolve(BASE, 'buildtools', 'third_party', 'libc++abi', 'trunk', 'include')}"`,
|
||||||
'-fPIC'
|
'-fPIC',
|
||||||
|
...platformFlags
|
||||||
].join(' ');
|
].join(' ');
|
||||||
|
|
||||||
const ldflags = [
|
const ldflags = [
|
||||||
'-stdlib=libc++',
|
'-stdlib=libc++',
|
||||||
'-fuse-ld=lld',
|
'-fuse-ld=lld',
|
||||||
`-L"${path.resolve(BASE, 'out', `${utils.getOutDir({ shouldLog: true })}`, 'obj', 'buildtools', 'third_party', 'libc++abi')}"`,
|
`-L"${path.resolve(BASE, 'out', outDir, 'obj', 'buildtools', 'third_party', 'libc++abi')}"`,
|
||||||
`-L"${path.resolve(BASE, 'out', `${utils.getOutDir({ shouldLog: true })}`, 'obj', 'buildtools', 'third_party', 'libc++')}"`,
|
`-L"${path.resolve(BASE, 'out', outDir, 'obj', 'buildtools', 'third_party', 'libc++')}"`,
|
||||||
'-lc++abi'
|
'-lc++abi',
|
||||||
|
...platformFlags
|
||||||
].join(' ');
|
].join(' ');
|
||||||
|
|
||||||
if (process.platform !== 'win32') {
|
if (process.platform !== 'win32') {
|
||||||
|
@ -66,6 +88,7 @@ async function main () {
|
||||||
cwd: NAN_DIR,
|
cwd: NAN_DIR,
|
||||||
stdio: 'inherit'
|
stdio: 'inherit'
|
||||||
});
|
});
|
||||||
|
|
||||||
if (buildStatus !== 0) {
|
if (buildStatus !== 0) {
|
||||||
console.error('Failed to build nan test modules');
|
console.error('Failed to build nan test modules');
|
||||||
return process.exit(buildStatus);
|
return process.exit(buildStatus);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue