| # Copyright 2023 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. |
| |
| # Generate a file containing a unique content hash corresponding to the content |
| # of a given prebuilt source directory. |
| # |
| # Arguments: |
| # source_dir: [required] |
| # A path string to the source directory. |
| # |
| # output: [optional] |
| # An optional output path, default is |
| # $target_out_dir/$target_name |
| # |
| # cipd_name: [optiona] |
| # A CIPD archive name for the content of the source directory. |
| # |
| # exclude_suffixes: [optional] |
| # A list of file name suffixes to exclude from the content scan. |
| # |
| template("generate_prebuilt_dir_content_hash") { |
| if (defined(invoker.output)) { |
| _output = invoker.output |
| } else { |
| _output = "$target_out_dir/${target_name}" |
| } |
| action(target_name) { |
| script = "//build/bazel/scripts/compute_content_hash.py" |
| outputs = [ _output ] |
| depfile = "${_output}.d" |
| args = [ |
| "--output", |
| rebase_path(outputs[0], root_build_dir), |
| "--depfile", |
| rebase_path(depfile, root_build_dir), |
| rebase_path(invoker.source_dir, root_build_dir), |
| ] |
| if (defined(invoker.cipd_name)) { |
| args += [ "--cipd-name=${invoker.cipd_name}" ] |
| } |
| if (defined(invoker.exclude_suffixes)) { |
| foreach(suffix, invoker.exclude_suffixes) { |
| args += [ "--exclude-suffix=${suffix}" ] |
| } |
| } |
| } |
| } |
| |
| # Name of the targets in //build/bazel/BUILD.gn that generate content hash |
| # files to version prebuilt toolchains. |
| prebuilt_content_hash_targets = { |
| python = "prebuilt_python_content_hash" |
| clang = "prebuilt_clang_content_hash" |
| } |
| |
| # Labels to the targets above. |
| prebuilt_content_hash_labels = { |
| python = "//build/bazel:${prebuilt_content_hash_targets.python}" |
| clang = "//build/bazel:${prebuilt_content_hash_targets.clang}" |
| } |
| |
| # Output files of the targets above. |
| prebuilt_content_hash_files = { |
| python = "$root_build_dir/prebuilt_content_hashes/python.content_hash" |
| clang = "$root_build_dir/prebuilt_content_hashes/clang.content_hash" |
| } |