aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Bosch <tbosch@google.com>2019-10-01 15:01:18 -0700
committerTobias Bosch <tbosch@google.com>2019-10-08 21:28:01 +0000
commit2a197341d04799f6b4f5d4c952a06add9a5feda2 (patch)
tree9a691c7b309f8197d1d39e76bbb39da6dbe8e820
parent0dcc7e318fdf0460f12a8146fd8fa2e7df22ef63 (diff)
downloadtoolchain-utils-2a197341d04799f6b4f5d4c952a06add9a5feda2.tar.gz
Android wrapper: Support build.py without bundle.py
For Android, we don't want to first clone the sources to a target directory in order to build the wrapper. TEST=manually ran the script. BUG=chromium:773875 Change-Id: I6b45868b8fb06274c29ce7e8dfc3d40f9a2f6aa5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1834484 Tested-by: Tobias Bosch <tbosch@google.com> Reviewed-by: George Burgess <gbiv@chromium.org>
-rwxr-xr-xcompiler_wrapper/build.py15
-rwxr-xr-xcompiler_wrapper/bundle.py7
2 files changed, 17 insertions, 5 deletions
diff --git a/compiler_wrapper/build.py b/compiler_wrapper/build.py
index af3064e9..6b647714 100755
--- a/compiler_wrapper/build.py
+++ b/compiler_wrapper/build.py
@@ -10,6 +10,7 @@ from __future__ import print_function
import argparse
import os.path
+import re
import subprocess
import sys
@@ -45,8 +46,18 @@ def calc_go_args(args, version):
def read_version(build_dir):
- with open(os.path.join(build_dir, 'VERSION'), 'r') as r:
- return r.read()
+ version_path = os.path.join(build_dir, 'VERSION')
+ if os.path.exists(version_path):
+ with open(version_path, 'r') as r:
+ return r.read()
+
+ last_commit_msg = subprocess.check_output(
+ ['git', '-C', build_dir, 'log', '-1', '--pretty=%B'])
+ # Use last found change id to support reverts as well.
+ change_ids = re.findall(r'Change-Id: (\w+)', last_commit_msg)
+ if not change_ids:
+ sys.exit("Couldn't find Change-Id in last commit message.")
+ return change_ids[-1]
def main():
diff --git a/compiler_wrapper/bundle.py b/compiler_wrapper/bundle.py
index 63757f78..c1fa53e0 100755
--- a/compiler_wrapper/bundle.py
+++ b/compiler_wrapper/bundle.py
@@ -33,10 +33,11 @@ def copy_files(input_dir, output_dir):
def read_change_id(input_dir):
last_commit_msg = subprocess.check_output(
['git', '-C', input_dir, 'log', '-1', '--pretty=%B'])
- match = re.search('Change-Id: (\\w+)', last_commit_msg)
- if not match:
+ # Use last found change id to support reverts as well.
+ change_ids = re.findall(r'Change-Id: (\w+)', last_commit_msg)
+ if not change_ids:
sys.exit("Couldn't find Change-Id in last commit message.")
- return match.group(1)
+ return change_ids[-1]
def write_readme(input_dir, output_dir, change_id):