From 688c3d16f010d1e60524abf4bf0cb1043c11512b Mon Sep 17 00:00:00 2001 From: Zach Anderson Date: Mon, 4 Mar 2024 12:00:18 -0800 Subject: [PATCH] Shift git version fetching to tools/gn --- shell/version/version.gni | 35 +++-------------------------------- tools/gn | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 32 deletions(-) diff --git a/shell/version/version.gni b/shell/version/version.gni index c997b7cc977a3..859f6c2fd61f2 100644 --- a/shell/version/version.gni +++ b/shell/version/version.gni @@ -14,35 +14,6 @@ declare_args() { _flutter_root = "//flutter" -if (engine_version == "") { - engine_version_lines = - exec_script("//flutter/build/git_revision.py", - [ - "--repository", - rebase_path(_flutter_root, "", _flutter_root), - ], - "list lines") - engine_version = engine_version_lines[0] -} - -if (skia_version == "") { - skia_version_lines = exec_script( - "//flutter/build/git_revision.py", - [ - "--repository", - rebase_path("//flutter/third_party/skia", "", _flutter_root), - ], - "list lines") - skia_version = skia_version_lines[0] -} - -if (dart_version == "") { - dart_version_lines = - exec_script("//flutter/build/git_revision.py", - [ - "--repository", - rebase_path("$dart_src", "", _flutter_root), - ], - "list lines") - dart_version = dart_version_lines[0] -} +assert(engine_version != "", "The engine_version argument must be supplied") +assert(skia_version != "", "The skia_version argument must be supplied") +assert(dart_version != "", "The dart_version argument must be supplied") diff --git a/tools/gn b/tools/gn index 67916000bc813..bddc58333cd43 100755 --- a/tools/gn +++ b/tools/gn @@ -344,6 +344,40 @@ def setup_apple_sdks(): return sdks_gn_args +def get_repository_version(repository): + 'Returns the Git HEAD for the supplied repository path as a string.' + if not os.path.exists(repository): + raise IOError('path does not exist') + + git = 'git' + if sys.platform.startswith(('cygwin', 'win')): + git = 'git.bat' + version = subprocess.check_output([ + git, + '-C', + repository, + 'rev-parse', + 'HEAD', + ]) + + return str(version.strip(), 'utf-8') + + +def setup_git_versions(): + revision_args = {} + + engine_path = os.path.join(SRC_ROOT, 'flutter') + revision_args['engine_version'] = get_repository_version(engine_path) + + skia_path = os.path.join(SRC_ROOT, 'flutter', 'third_party', 'skia') + revision_args['skia_version'] = get_repository_version(skia_path) + + dart_path = os.path.join(SRC_ROOT, 'third_party', 'dart') + revision_args['dart_version'] = get_repository_version(dart_path) + + return revision_args + + def to_gn_args(args): if args.simulator: if args.target_os != 'ios': @@ -355,6 +389,8 @@ def to_gn_args(args): gn_args['is_debug'] = args.unoptimized + gn_args.update(setup_git_versions()) + gn_args.update(setup_goma(args)) gn_args.update(setup_rbe(args)) @@ -697,6 +733,8 @@ def to_gn_args(args): # for a host Windows build and make GN think we will be building ANGLE. # Angle is not used on Mac hosts as there are no tests for the OpenGL backend. if is_host_build(args) or (args.target_os == 'android' and get_host_os() == 'win'): + # Don't include git commit information. + gn_args['angle_enable_commit_id'] = False # Do not build unnecessary parts of the ANGLE tree. gn_args['angle_build_all'] = False gn_args['angle_has_astc_encoder'] = False