electron/script/gen-libc++-filenames.js
Keeley Hammond d03325541f
test: rebuild nan tests with libc++ and libc++abi (#29281)
* test: re-enable nan test: typedarrays-test.js

Fixes #28414.

I've confirmed this fix wfm on Linux. Pushing into a PR to get CI to run
it out on Win and Mac platforms too.

* chore: clarify comment

* test: fix NAN test string alignment

* test: (wip) add ldflags, archive file for libc++

* test: (wip) add libc++ to CircleCI

* test: (wip) add llvm flags

* test: (wip) change ldflag syntax

* test: (wip) build libc++abi as static

* fix: correct ldflags

* test: add ld env

* fix: do not commit this

* test: add lld from src to circleci

* test: add lld link to ld

* chore: preserve third_party

* seems legit

* sam swears this works kinda sort of sometimes'
:

* build: add gn visibility patch

* chore: update patches

* build: check for flatten_relative_to = false

* build: upload zip files, add to release.js validation

* debug: what the hell gn

* build: add libcxx gni to lint ignore

Linting the file adjusted the licenses array, which only contains
one value, and causes the gn check to fail later

* build: also use nan-spec-runner flags on Windows

* build: add linked flags for win32 only

* build: build libc++ as source on win

* build: clean up patch, add -fPIC for IA32

* build: delete libcxx .a files from root

* build: rename libc++.zip, clean up upload per platform

* build: fix gni lint

* ci: add libcxx gen to circleci config

* build: correct libcxx-object syntax

Co-authored-by: Samuel Attard <sam@electronjs.org>

Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: clavin <clavin@electronjs.org>
Co-authored-by: Samuel Attard <sattard@slack-corp.com>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: Samuel Attard <sam@electronjs.org>
2021-05-22 11:48:38 -07:00

48 lines
1.6 KiB
JavaScript

const fs = require('fs');
const path = require('path');
const check = process.argv.includes('--check');
function findAllHeaders (basePath) {
const allFiles = fs.readdirSync(basePath);
const toReturn = [];
for (const file of allFiles) {
const absPath = path.resolve(basePath, file);
if (fs.statSync(absPath).isDirectory()) {
toReturn.push(...findAllHeaders(absPath));
} else {
toReturn.push(absPath);
}
}
return toReturn;
}
for (const folder of ['libc++', 'libc++abi']) {
const prettyName = folder.replace(/\+/g, 'x');
const libcxxIncludeDir = path.resolve(__dirname, '..', '..', 'buildtools', 'third_party', folder, 'trunk', 'include');
const gclientPath = `buildtools/third_party/${folder}/trunk/include`;
const headers = findAllHeaders(libcxxIncludeDir).map(absPath => path.relative(path.resolve(__dirname, '../..', gclientPath), absPath));
const content = `${prettyName}_headers = [
${headers.map(f => `"//${path.posix.join(gclientPath, f)}"`).join(',\n ')},
]
${prettyName}_licenses = [ "//buildtools/third_party/${folder}/trunk/LICENSE.TXT" ]
`;
const filenamesPath = path.resolve(__dirname, '..', `filenames.${prettyName}.gni`);
if (check) {
const currentContent = fs.readFileSync(filenamesPath, 'utf8');
if (currentContent !== content) {
console.log('currentContent: ', currentContent);
console.log('content: ', content);
throw new Error(`${prettyName} filenames need to be regenerated, latest generation does not match current file. Please run node gen-libc++-filenames.js`);
}
} else {
console.log(filenamesPath);
fs.writeFileSync(filenamesPath, content);
}
}