# Copyright 2020 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
template("generate_grd") {
action(target_name) {
script = "//ui/webui/resources/tools/generate_grd.py"
forward_variables_from(invoker,
[
"deps",
"public_deps",
"testonly",
"visibility",
])
inputs = []
outputs = [ invoker.out_grd ]
grd_extension = get_path_info(invoker.out_grd, "extension")
assert(grd_extension == "grd" || grd_extension == "grdp",
"Invalid extension '${grd_extension}' found. Must use grd or grdp")
args = [
"--out-grd",
rebase_path(invoker.out_grd, root_build_dir),
"--grd-prefix",
invoker.grd_prefix,
"--root-gen-dir",
rebase_path(root_gen_dir, root_build_dir),
]
if (defined(invoker.manifest_files)) {
inputs += invoker.manifest_files
args += [ "--manifest-files" ] +
rebase_path(invoker.manifest_files, root_build_dir)
}
if (defined(invoker.grdp_files)) {
extension = get_path_info(invoker.out_grd, "extension")
assert(extension == "grd", "grdp files can't be nested.")
inputs += invoker.grdp_files
args +=
[ "--grdp-files" ] + rebase_path(invoker.grdp_files, root_build_dir)
}
if (defined(invoker.input_files)) {
args += [
"--input-files-base-dir",
invoker.input_files_base_dir,
"--input-files",
] + invoker.input_files
}
if (defined(invoker.output_files_base_dir)) {
args += [
"--output-files-base-dir",
invoker.output_files_base_dir,
]
}
if (defined(invoker.resource_path_rewrites)) {
args += [ "--resource-path-rewrites" ] + invoker.resource_path_rewrites
}
if (defined(invoker.resource_path_prefix)) {
args += [
"--resource-path-prefix",
invoker.resource_path_prefix,
]
}
}
}