From b301b85be895c6fcd1edfe2fd1e60b5abd0ac64d Mon Sep 17 00:00:00 2001 From: machenbach Date: Wed, 14 Jan 2015 08:43:24 -0800 Subject: [PATCH] Auto-generate v8 version based on tags. BUG=chromium:446166 LOG=y Review URL: https://codereview.chromium.org/797503007 Cr-Commit-Position: refs/heads/master@{#26062} --- BUILD.gn | 22 +++++++++++++++++++- tools/gyp/v8.gyp | 36 ++++++++++++++++++++++++++++++++- tools/push-to-trunk/generate_version.py | 33 +++++++++++++++++------------- 3 files changed, 75 insertions(+), 16 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index a524ba1..6822f30 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -314,6 +314,25 @@ action("run_mksnapshot") { } } +action("generate_v8_version") { + visibility = [ ":*" ] # Only targets in this file can depend on this. + + script = "tools/push-to-trunk/generate_version.py" + + sources = [ + "src/version.cc", + ] + + outputs = [ + "$target_gen_dir/version.cc" + ] + + args = [ + rebase_path("$target_gen_dir/version.cc", root_build_dir), + ] +} + + ############################################################################### # Source Sets (aka static libraries) # @@ -398,6 +417,7 @@ source_set("v8_base") { visibility = [ ":*" ] # Only targets in this file can depend on this. sources = [ + "$target_gen_dir/version.cc", "src/accessors.cc", "src/accessors.h", "src/allocation.cc", @@ -933,7 +953,6 @@ source_set("v8_base") { "src/v8threads.h", "src/variables.cc", "src/variables.h", - "src/version.cc", "src/version.h", "src/vm-state-inl.h", "src/vm-state.h", @@ -1211,6 +1230,7 @@ source_set("v8_base") { defines = [] deps = [ ":v8_libbase", + ":generate_v8_version", ] if (is_win) { diff --git a/tools/gyp/v8.gyp b/tools/gyp/v8.gyp index 2472b33..76a2a73 100644 --- a/tools/gyp/v8.gyp +++ b/tools/gyp/v8.gyp @@ -336,6 +336,34 @@ ], }, { + 'target_name': 'v8_version', + 'type': 'none', + 'conditions': [ + ['want_separate_host_toolset==1', { + 'toolsets': ['host'], + }, { + 'toolsets': ['target'], + }], + ], + 'actions': [ + { + 'action_name': 'generate_v8_version', + 'inputs': [ + '../../tools/push-to-trunk/generate_version.py', + '../../src/version.cc', + ], + 'outputs': [ + '<(SHARED_INTERMEDIATE_DIR)/version.cc', + ], + 'action': [ + 'python', + '../../tools/push-to-trunk/generate_version.py', + '<(SHARED_INTERMEDIATE_DIR)/version.cc', + ], + }, + ], + }, + { 'target_name': 'v8_base', 'type': 'static_library', 'dependencies': [ @@ -348,6 +376,7 @@ '../..', ], 'sources': [ ### gcmole(all) ### + '<(SHARED_INTERMEDIATE_DIR)/version.cc', '../../src/accessors.cc', '../../src/accessors.h', '../../src/allocation.cc', @@ -886,7 +915,6 @@ '../../src/variables.cc', '../../src/variables.h', '../../src/vector.h', - '../../src/version.cc', '../../src/version.h', '../../src/vm-state-inl.h', '../../src/vm-state.h', @@ -898,8 +926,14 @@ ], 'conditions': [ ['want_separate_host_toolset==1', { + 'dependencies': [ + 'v8_version#host', + ], 'toolsets': ['host', 'target'], }, { + 'dependencies': [ + 'v8_version', + ], 'toolsets': ['target'], }], ['v8_target_arch=="arm"', { diff --git a/tools/push-to-trunk/generate_version.py b/tools/push-to-trunk/generate_version.py index b4a0221..28cd203 100755 --- a/tools/push-to-trunk/generate_version.py +++ b/tools/push-to-trunk/generate_version.py @@ -19,6 +19,12 @@ CWD = os.path.abspath( VERSION_CC = os.path.join(CWD, "src", "version.cc") def main(): + if len(sys.argv) != 2: + print "Error: Specify the output file path for version.cc" + return 1 + version_out = sys.argv[1] + assert os.path.exists(os.path.dirname(version_out)) + tag = subprocess.check_output( "git describe --tags", shell=True, @@ -50,21 +56,20 @@ def main(): patch = "0" # Modify version.cc with the new values. - with open(VERSION_CC, "r") as f: - text = f.read() output = [] - for line in text.split("\n"): - for definition, substitute in ( - ("MAJOR_VERSION", major), - ("MINOR_VERSION", minor), - ("BUILD_NUMBER", build), - ("PATCH_LEVEL", patch), - ("IS_CANDIDATE_VERSION", candidate)): - if line.startswith("#define %s" % definition): - line = re.sub("\d+$", substitute, line) - output.append(line) - with open(VERSION_CC, "w") as f: - f.write("\n".join(output)) + with open(VERSION_CC, "r") as f: + for line in f: + for definition, substitute in ( + ("MAJOR_VERSION", major), + ("MINOR_VERSION", minor), + ("BUILD_NUMBER", build), + ("PATCH_LEVEL", patch), + ("IS_CANDIDATE_VERSION", candidate)): + if line.startswith("#define %s" % definition): + line = re.sub("\d+$", substitute, line) + output.append(line) + with open(version_out, "w") as f: + f.write("".join(output)) # Log what was done. candidate_txt = " (candidate)" if candidate == "1" else "" -- 2.7.4