Commit 2b7a431e authored by yangguo's avatar yangguo Committed by Commit bot

[tools] backport_node.py increments V8 version in target.

R=franzih@chromium.org, machenbach@chromium.org

Review-Url: https://codereview.chromium.org/2846883002
Cr-Commit-Position: refs/heads/master@{#44943}
parent 1dfcc4b6
...@@ -14,7 +14,8 @@ Usage: ...@@ -14,7 +14,8 @@ Usage:
$ backport_node.py <path_to_v8> <path_to_node> <commit-hash> $ backport_node.py <path_to_v8> <path_to_node> <commit-hash>
This will apply the commit to <path_to_node>/deps/v8 and create a commit in This will apply the commit to <path_to_node>/deps/v8 and create a commit in
the Node.js checkout and copy over the original commit message. the Node.js checkout, increment patch level, and copy over the original
commit message.
Optional flags: Optional flags:
--no-review Run `gclient sync` on the V8 checkout before updating. --no-review Run `gclient sync` on the V8 checkout before updating.
...@@ -23,9 +24,19 @@ Optional flags: ...@@ -23,9 +24,19 @@ Optional flags:
import argparse import argparse
import os import os
import subprocess import subprocess
import re
import sys import sys
from common_includes import *
TARGET_SUBDIR = os.path.join("deps", "v8") TARGET_SUBDIR = os.path.join("deps", "v8")
VERSION_FILE = os.path.join("include", "v8-version.h")
VERSION_PATTERN = r'(?<=#define V8_PATCH_LEVEL )\d+'
def Clean(options):
print ">> Cleaning target directory."
subprocess.check_call(["git", "clean", "-fd"],
cwd = os.path.join(options.node_path, TARGET_SUBDIR))
def CherryPick(options): def CherryPick(options):
print ">> Apply patch." print ">> Apply patch."
...@@ -42,6 +53,16 @@ def CherryPick(options): ...@@ -42,6 +53,16 @@ def CherryPick(options):
while raw_input("[RESOLVED]") != "RESOLVED": while raw_input("[RESOLVED]") != "RESOLVED":
print ">> You need to type RESOLVED" print ">> You need to type RESOLVED"
def UpdateVersion(options):
print ">> Increment patch level."
version_file = os.path.join(options.node_path, TARGET_SUBDIR, VERSION_FILE)
text = FileToText(version_file)
def increment(match):
patch = int(match.group(0))
return str(patch + 1)
text = re.sub(VERSION_PATTERN, increment, text, flags=re.MULTILINE)
TextToFile(text, version_file)
def CreateCommit(options): def CreateCommit(options):
print ">> Creating commit." print ">> Creating commit."
# Find short hash from source. # Find short hash from source.
...@@ -84,8 +105,10 @@ def ParseOptions(args): ...@@ -84,8 +105,10 @@ def ParseOptions(args):
def Main(args): def Main(args):
options = ParseOptions(args) options = ParseOptions(args)
Clean(options)
try: try:
CherryPick(options) CherryPick(options)
UpdateVersion(options)
CreateCommit(options) CreateCommit(options)
except: except:
print ">> Failed. Resetting." print ">> Failed. Resetting."
......
...@@ -10,6 +10,7 @@ import sys ...@@ -10,6 +10,7 @@ import sys
import tempfile import tempfile
import unittest import unittest
from common_includes import FileToText
import backport_node import backport_node
# Base paths. # Base paths.
...@@ -62,5 +63,9 @@ class TestUpdateNode(unittest.TestCase): ...@@ -62,5 +63,9 @@ class TestUpdateNode(unittest.TestCase):
) )
self.assertIn('+zonk', gitlog.strip()) self.assertIn('+zonk', gitlog.strip())
# Check version.
version_file = os.path.join(node_cwd, "deps", "v8", "include", "v8-version.h")
self.assertIn('#define V8_PATCH_LEVEL 4322', FileToText(version_file))
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()
// Copyright 2015 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.
#ifndef V8_INCLUDE_VERSION_H_ // V8_VERSION_H_ conflicts with src/version.h
#define V8_INCLUDE_VERSION_H_
// These macros define the version number for the current version.
// NOTE these macros are used by some of the tool scripts and the build
// system so their names cannot be changed without changing the scripts.
#define V8_MAJOR_VERSION 1
#define V8_MINOR_VERSION 2
#define V8_BUILD_NUMBER 3
#define V8_PATCH_LEVEL 4321
// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
#define V8_IS_CANDIDATE_VERSION 0
#endif // V8_INCLUDE_VERSION_H_
...@@ -56,6 +56,7 @@ ALL_GYP_PREFIXES = [ ...@@ -56,6 +56,7 @@ ALL_GYP_PREFIXES = [
GYP_UNSUPPORTED_FEATURES = [ GYP_UNSUPPORTED_FEATURES = [
'gcmole', 'gcmole',
'setup-isolate-deserialize.cc', 'setup-isolate-deserialize.cc',
'v8-version.h'
] ]
GN_FILES = [ GN_FILES = [
...@@ -80,6 +81,7 @@ GN_UNSUPPORTED_FEATURES = [ ...@@ -80,6 +81,7 @@ GN_UNSUPPORTED_FEATURES = [
'qnx', 'qnx',
'solaris', 'solaris',
'vtune', 'vtune',
'v8-version.h',
'x87', 'x87',
] ]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment