Reviewers: Jakob, jochen (slow), tandrii(chromium),

Message:
PTAL


https://codereview.chromium.org/797503007/diff/1/BUILD.gn
File BUILD.gn (right):

https://codereview.chromium.org/797503007/diff/1/BUILD.gn#newcode966
BUILD.gn:966: "$target_gen_dir/version.cc",
I'm not so happy about the sorting. Should it just be on top?

Description:
Auto-generate v8 version base on tags.

BUG=chromium:446166
LOG=y

Please review this at https://codereview.chromium.org/797503007/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+74, -17 lines):
  M BUILD.gn
  M tools/gyp/v8.gyp
  M tools/push-to-trunk/generate_version.py


Index: BUILD.gn
diff --git a/BUILD.gn b/BUILD.gn
index 6534eea85948104dffd43635282a3d14f370bc82..b9cabf05fb3ebbcd967608ca64500fc476009c2d 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -341,6 +341,24 @@ 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)
@@ -945,7 +963,7 @@ source_set("v8_base") {
     "src/v8threads.h",
     "src/variables.cc",
     "src/variables.h",
-    "src/version.cc",
+    "$target_gen_dir/version.cc",
     "src/version.h",
     "src/vm-state-inl.h",
     "src/vm-state.h",
@@ -1217,7 +1235,7 @@ source_set("v8_base") {
   }

   defines = []
-  deps = [ ":v8_libbase" ]
+  deps = [ ":v8_libbase", ":generate_v8_version" ]

   if (is_win) {
     # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
Index: tools/gyp/v8.gyp
diff --git a/tools/gyp/v8.gyp b/tools/gyp/v8.gyp
index 696434daf8a6ced0e6f6937453808079f43740eb..a00b994bd1d6d68254316160ebef25417b66ad32 100644
--- a/tools/gyp/v8.gyp
+++ b/tools/gyp/v8.gyp
@@ -329,6 +329,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': [
@@ -875,7 +903,7 @@
         '../../src/variables.cc',
         '../../src/variables.h',
         '../../src/vector.h',
-        '../../src/version.cc',
+        '<(SHARED_INTERMEDIATE_DIR)/version.cc',
         '../../src/version.h',
         '../../src/vm-state-inl.h',
         '../../src/vm-state.h',
@@ -887,8 +915,14 @@
       ],
       'conditions': [
         ['want_separate_host_toolset==1', {
+          'dependencies': [
+            'v8_version#host',
+          ],
           'toolsets': ['host', 'target'],
         }, {
+          'dependencies': [
+            'v8_version',
+          ],
           'toolsets': ['target'],
         }],
         ['v8_target_arch=="arm"', {
Index: tools/push-to-trunk/generate_version.py
diff --git a/tools/push-to-trunk/generate_version.py b/tools/push-to-trunk/generate_version.py index b4a0221eae5c10224a18d79bf8067ca3df958177..28cd2033c935b397eb1b2b917aa54000ed057b22 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 ""


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to