| # Copyright 2026 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| assert(current_toolchain == default_toolchain, |
| "git_revisions.gni must only be imported in the default toolchain") |
| |
| import("//build/config/python_interpreter.gni") |
| |
| _paths_script = "//build/git/resolve_git_paths.py" |
| _revisions_script = "//build/git/resolve_git_revisions.py" |
| |
| # 1. Get paths of git files to watch. |
| _paths = exec_script(python_exe_src, |
| [ |
| "-S", |
| rebase_path(_paths_script, root_build_dir), |
| ], |
| "json", |
| [ |
| _paths_script, |
| "//build/git/git_utils.py", |
| ]) |
| |
| # 2. Get revisions. We pass the resolved watch files as dependencies |
| # so that GN reruns if the git HEAD or refs change. |
| _dep_files = [ |
| _revisions_script, |
| _paths.fuchsia_head, |
| _paths.fuchsia_ref, |
| _paths.mesa_head, |
| _paths.mesa_ref, |
| ] |
| |
| _revisions = exec_script(python_exe_src, |
| [ |
| "-S", |
| rebase_path(_revisions_script, root_build_dir), |
| ], |
| "json", |
| _dep_files) |
| |
| git_paths = { |
| fuchsia_index = _paths.fuchsia_index |
| fuchsia_head = _paths.fuchsia_head |
| fuchsia_ref = _paths.fuchsia_ref |
| mesa_head = _paths.mesa_head |
| mesa_ref = _paths.mesa_ref |
| if (defined(_paths.glslang_head)) { |
| glslang_head = _paths.glslang_head |
| } |
| } |
| |
| git_revisions = { |
| fuchsia_revision = _revisions.fuchsia_revision |
| mesa_revision = _revisions.mesa_revision |
| } |