electron/build/zip_libcxx.py

47 lines
1.6 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
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 18:48:38 +00:00
from __future__ import print_function
import os
import subprocess
import sys
import zipfile
def execute(argv):
try:
output = subprocess.check_output(argv, stderr=subprocess.STDOUT)
return output
except subprocess.CalledProcessError as e:
print(e.output)
raise e
def get_object_files(base_path, archive_name):
archive_file = os.path.join(base_path, archive_name)
output = execute(['nm', '-g', archive_file]).decode('ascii')
object_files = set()
lines = output.split("\n")
for line in lines:
if line.startswith(base_path):
object_file = line.split(":")[0]
object_files.add(object_file)
if line.startswith('nm: '):
object_file = line.split(":")[1].lstrip()
object_files.add(object_file)
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 18:48:38 +00:00
return list(object_files) + [archive_file]
def main(argv):
dist_zip, = argv
out_dir = os.path.dirname(dist_zip)
base_path_libcxx = os.path.join(out_dir, 'obj/buildtools/third_party/libc++')
base_path_libcxxabi = os.path.join(out_dir, 'obj/buildtools/third_party/libc++abi')
object_files_libcxx = get_object_files(base_path_libcxx, 'libc++.a')
object_files_libcxxabi = get_object_files(base_path_libcxxabi, 'libc++abi.a')
with zipfile.ZipFile(
dist_zip, 'w', zipfile.ZIP_DEFLATED, allowZip64=True
) as z:
object_files_libcxx.sort()
for object_file in object_files_libcxx:
z.write(object_file, os.path.relpath(object_file, base_path_libcxx))
for object_file in object_files_libcxxabi:
z.write(object_file, os.path.relpath(object_file, base_path_libcxxabi))
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))