From 8a89a4a5ceeb58303cd9bc2d3e8d362742d59c96 Mon Sep 17 00:00:00 2001 From: domenic Date: Tue, 28 Apr 2015 07:55:58 -0700 Subject: [PATCH] Allow extra library files to be snapshotted BUG= R=jochen@chromium.org, yangguo@chromium.org Review URL: https://codereview.chromium.org/1113593002 Cr-Commit-Position: refs/heads/master@{#28110} --- tools/gyp/v8.gyp | 10 +++++++--- tools/js2c.py | 36 ++++++++++++++++++++++-------------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/tools/gyp/v8.gyp b/tools/gyp/v8.gyp index e1bee3e1df..ee72d377d5 100644 --- a/tools/gyp/v8.gyp +++ b/tools/gyp/v8.gyp @@ -31,6 +31,7 @@ 'v8_code': 1, 'v8_random_seed%': 314159265, 'embed_script%': "", + 'v8_extra_library_files%': [], 'mksnapshot_exec': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)mksnapshot<(EXECUTABLE_SUFFIX)', }, 'includes': ['../../build/toolchain.gypi', '../../build/features.gypi'], @@ -749,9 +750,9 @@ '../../src/jsregexp-inl.h', '../../src/jsregexp.cc', '../../src/jsregexp.h', - '../../src/layout-descriptor-inl.h', - '../../src/layout-descriptor.cc', - '../../src/layout-descriptor.h', + '../../src/layout-descriptor-inl.h', + '../../src/layout-descriptor.cc', + '../../src/layout-descriptor.h', '../../src/list-inl.h', '../../src/list.h', '../../src/lithium-allocator-inl.h', @@ -1740,6 +1741,7 @@ '../../tools/js2c.py', '<@(library_files)', '<@(i18n_library_files)', + '<@(v8_extra_library_files)', ], 'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/libraries.cc', @@ -1751,6 +1753,8 @@ 'CORE', '<@(library_files)', '<@(i18n_library_files)', + '--extra', + '<@(v8_extra_library_files)', ], 'conditions': [ [ 'v8_use_external_startup_data==1', { diff --git a/tools/js2c.py b/tools/js2c.py index 6a29fbe7f0..4181619a5a 100755 --- a/tools/js2c.py +++ b/tools/js2c.py @@ -32,7 +32,7 @@ # library. import os, re, sys, string -import optparse +import argparse import jsmin import bz2 import textwrap @@ -531,8 +531,10 @@ def WriteStartupBlob(sources, startup_blob): output.close() -def JS2C(source, target, native_type, raw_file, startup_blob): - sources = PrepareSources(source) +def JS2C(source, extraSource, target, native_type, raw_file, startup_blob): + # For now we treat source and extraSource the same, but we keep them separate + # in the input so that we can start treating them differently in the future. + sources = PrepareSources(source + extraSource) sources_bytes = "".join(sources.modules) metadata = BuildMetadata(sources, sources_bytes, native_type) @@ -552,18 +554,24 @@ def JS2C(source, target, native_type, raw_file, startup_blob): def main(): - parser = optparse.OptionParser() - parser.add_option("--raw", action="store", - help="file to write the processed sources array to.") - parser.add_option("--startup_blob", action="store", - help="file to write the startup blob to.") - parser.set_usage("""js2c out.cc type sources.js ... - out.cc: C code to be generated. - type: type parameter for NativesCollection template. - sources.js: JS internal sources or macros.py.""") - (options, args) = parser.parse_args() + parser = argparse.ArgumentParser() + parser.add_argument("out.cc", + help="C code to be generated") + parser.add_argument("type", + help="type parameter for NativesCollection template") + parser.add_argument("sources.js", + help="JS internal sources or macros.py.", + nargs="+") + parser.add_argument("--raw", + help="file to write the processed sources array to.") + parser.add_argument("--startup_blob", + help="file to write the startup blob to.") + parser.add_argument("--extra", + help="extra JS sources.", + nargs="*") - JS2C(args[2:], args[0], args[1], options.raw, options.startup_blob) + args = vars(parser.parse_args()) + JS2C(args["sources.js"], args["extra"] or [], args["out.cc"], args["type"], args["raw"], args["startup_blob"]) if __name__ == "__main__":