blob: f45d8bdfd81aabcb9e4278dbe2c080706de9e06b [file] [log] [blame]
# 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}" ]
}
}
}
}