blob: 9bfbedc0b8d2872e6ef068c541b65e2df5b4dc84 [file] [log] [blame]
# Copyright 2021 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.
# Invokes the check-licenses tool.
#
# Parameters
#
# configs (optional)
# [list] Paths to config files.
# Default: "//tools/check-licenses/config/config.json"
#
# skip_dirs (optional)
# [list] Directories to skip checking.
#
# notice_txt (optional)
# [list] Paths to NOTICE.txt files to parse.
#
# license_allow_list (optional)
# [list] Map of license pattern file (.lic) to list of directories
# where the license can be used.
#
# testonly, visibility
template("license_data") {
action(target_name) {
forward_variables_from(invoker,
[
"configs",
"license_allow_list",
"notice_txt",
"outputs",
"skip_dirs",
"testonly",
"visibility",
])
# check-licenses assumes that it runs from //,
# but actions run from root_build_dir.
# This shell script sets the CWD and then calls check-licenses.
script = "//tools/check-licenses/license_data.sh"
license_tool = "//tools/check-licenses($host_toolchain)"
deps = [ license_tool ]
if (!defined(configs)) {
configs = [ "//tools/check-licenses/config/config.json" ]
}
sources = configs
outputs = [
"$target_out_dir/NOTICE.html.gz",
"$target_out_dir/NOTICE.txt.gz",
]
args = [
### Args for license_data.sh
rebase_path("//", root_build_dir),
rebase_path(
get_label_info(license_tool, "root_out_dir") + "/check-licenses",
"//"),
### Args for check-licenses
# TODO: Remove once all files are attributed in the file generated by
# check-licenses.
"--exit_on_unlicensed_files=false",
"--config_file",
string_join(",", rebase_path(configs, "//")),
"--out_dir",
rebase_path(target_out_dir, "//"),
]
if (defined(skip_dirs)) {
args += [ "--skip_dirs" ] + string_join(",", rebase_path(skip_dirs, "//"))
}
if (defined(notice_txt)) {
args +=
[ "--notice_txt" ] + string_join(",", rebase_path(notice_txt, "//"))
}
if (defined(license_allow_list)) {
args += [ "--license_allow_list" ] + "{ " +
string_join(", ", rebase_path(notice_txt, "//")) + " }"
}
}
}