diff --git BUILD.gn BUILD.gn index d6969b427ed614ec861c338cdd127ba4717dad1d..c6b7c034aea8f2d58c5bb0e4c5590cc1d27f9f5d 100644 --- BUILD.gn +++ BUILD.gn @@ -97,6 +97,9 @@ declare_args() { install_prefix = "" angle_use_crypto_hasher = build_with_chromium + + angle_commit_id = "" + angle_commit_position = "0" } declare_args() { @@ -956,6 +959,8 @@ action("angle_commit_id") { "gen", rebase_path(_commit_id_header, root_build_dir), rebase_path(depfile, root_build_dir), + angle_commit_position, + angle_commit_id, ] public_configs = [ ":angle_commit_id_config" ] diff --git src/commit_id.py src/commit_id.py index 5c28fe8184cbe5430f9253d1b2d6f59e787c1e6b..3a6f89f749fc2da3310ddc0806a486f9a8495864 100755 --- src/commit_id.py +++ src/commit_id.py @@ -13,7 +13,7 @@ import os usage = """\ Usage: commit_id.py position - print commit position - commit_id.py gen [depfile] - generate commit.h""" + commit_id.py gen [depfile] [commit_position] [commit_id] - generate commit.h""" def grab_output(command, cwd): @@ -128,15 +128,24 @@ def main(): sys.exit(usage) output_file = sys.argv[2] - depfile = sys.argv[3] if len(sys.argv) == 4 else None + depfile = sys.argv[3] if len(sys.argv) >= 4 else None commit_id_size = 12 commit_date = 'unknown date' commit_position = '0' + if len(sys.argv) >= 5: + commit_position = sys.argv[4] + assert commit_position.isnumeric(), commit_position + + commit_id = None + if len(sys.argv) >= 6 and len(sys.argv[5]) > 0: + commit_id = sys.argv[5] + assert len(commit_id) == commit_id_size, commit_id + # If the ANGLE_UPSTREAM_HASH environment variable is set, use it as # commit_id. commit_date will be 'unknown date' and commit_position will be 0 # in this case. See details in roll_aosp.sh where commit_id.py is invoked. - commit_id = os.environ.get('ANGLE_UPSTREAM_HASH') + commit_id = os.environ.get('ANGLE_UPSTREAM_HASH', commit_id) # If ANGLE_UPSTREAM_HASH environment variable is not set, use the git command # to get the git hash, when .git is available if git_dir_exists and not commit_id: