From e3e0b6f46b2139333a0667eaeb63878285dc6e94 Mon Sep 17 00:00:00 2001 From: Michael Achenbach Date: Thu, 22 Jun 2017 16:11:01 +0200 Subject: [PATCH] Reland "[build] Add filter script for official build" This is a reland of 54b42a55e7bbc8a1eeac1a0adac8389c907de463 Original change's description: > [build] Add filter script for official build > > This adds a V8-side script to list the files contained in an official archive. > > This'll accompany the infra-side archive recipe: > https://chromium-review.googlesource.com/c/544298/ > > Keeping this script on the V8-side will make it easy to change the > archived build product. > > NOTRY=true > > Bug: v8:5918 > Change-Id: I9fcb2eae183a26e7ce11c839d95a583a049cbe75 > Reviewed-on: https://chromium-review.googlesource.com/544877 > Commit-Queue: Michael Achenbach > Reviewed-by: Daniel Vogelheim > Cr-Commit-Position: refs/heads/master@{#46135} TBR=vogelheim@chromium.org NOTRY=true Bug: v8:5918 Change-Id: I87b58c78a2cbd97f4da37ac93fe1e8ee77bf5ca0 Reviewed-on: https://chromium-review.googlesource.com/544979 Reviewed-by: Michael Achenbach Commit-Queue: Michael Achenbach Cr-Commit-Position: refs/heads/master@{#46138} --- BUILD.gn | 9 ++++ tools/release/filter_build_files.py | 79 +++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100755 tools/release/filter_build_files.py diff --git a/BUILD.gn b/BUILD.gn index bdb1ddc288..b9b69cd971 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -2774,6 +2774,15 @@ group("v8_clusterfuzz") { } } +group("v8_archive") { + deps = [ + ":d8", + ":v8_hello_world", + ":v8_parser_shell", + ":v8_sample_process", + ] +} + group("v8_fuzzers") { testonly = true deps = [ diff --git a/tools/release/filter_build_files.py b/tools/release/filter_build_files.py new file mode 100755 index 0000000000..09344c64df --- /dev/null +++ b/tools/release/filter_build_files.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python +# Copyright 2017 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +""" +Enumerates relevant build files for each platform. + +This can be used to filter the build directory before making an official +archive. The archive should only contain files required for running or +static linking, e.g. executables, startup files, libraries. + +The script is limited to release builds and assumes GN. +""" + +import argparse +import glob +import itertools +import json +import os +import re +import sys + +EXECUTABLES = [ + 'd8', + 'v8_hello_world', + 'v8_parser_shell', + 'v8_sample_process', + 'v8_shell', +] + +SUPPLEMENTARY_FILES = [ + 'icudtl.dat', + 'natives_blob.bin', + 'snapshot_blob.bin', + 'v8_build_config.json', +] + +LIBS = { + 'linux': ['*.a', '*.so', 'obj/*.a', 'obj/*.so'], + 'mac': ['*.a', '*.so', 'obj/*.a', 'obj/*.so'], + 'win': ['*.lib', '*.dll', 'obj\\*.a', 'obj\\*.so'], +} + + +def main(argv): + parser = argparse.ArgumentParser(description=__doc__) + + parser.add_argument('-d', '--dir', required=True, + help='Path to the build directory.') + parser.add_argument('-p', '--platform', required=True, + help='Target platform name: win|mac|linux.') + parser.add_argument('-o', '--json-output', required=True, + help='Path to an output file. The files will ' + 'be stored in json list with absolute paths.') + args = parser.parse_args() + + if not os.path.isdir(args.dir): + parser.error('%s is not an existing directory.' % args.dir) + + args.dir = os.path.abspath(args.dir) + + extended_executables = [ + f + '.exe' if args.platform == 'win' else f + for f in EXECUTABLES] + + all_globs = [ + os.path.join(args.dir, f) + for f in extended_executables + SUPPLEMENTARY_FILES + LIBS[args.platform] + ] + + with open(args.json_output, 'w') as f: + json.dump(list(itertools.chain(*map(glob.iglob, all_globs))), f) + + return 0 + + +if __name__ == '__main__': + sys.exit(main(sys.argv))