blob: 0fa9afba2908efaafd1f7c84074086954c0374bd [file] [log] [blame]
# Copyright 2022 The Cobalt Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
template("bundle_content") {
bundle_name = invoker.bundle_name
bundle_deps = invoker.bundle_deps
bundle_content_rsp_file = "$target_gen_dir/${target_name}_list.rsp"
file_format = "list lines"
# If the platform bundles content the list of content files can be collected
# from the metadata field of the generated install_content targets.
generated_file("list_$target_name") {
forward_variables_from(invoker, [ "testonly" ])
# Rebase the paths the script working directory.
rebase = root_build_dir
data_keys = [ "install_content" ]
walk_keys = [ "ignore_install_content" ]
deps = []
foreach(dep, bundle_deps) {
deps += [ "${dep}_install_content" ]
}
output_conversion = file_format
outputs = [ bundle_content_rsp_file ]
}
action(target_name) {
forward_variables_from(invoker, [ "testonly" ])
deps = [ ":list_$target_name" ]
sources = [ bundle_content_rsp_file ]
bundle_content_dir =
"$sb_install_output_dir/$bundle_name/$sb_install_content_subdir"
outputs = [ "$target_gen_dir/${target_name}.stamp" ]
depfile = "$target_out_dir/$target_name.d"
script = "//starboard/build/copy_install_content.py"
args = [
"--output_dir",
rebase_path(bundle_content_dir, root_build_dir),
"--base_dir",
# |root_out_dir| changes based on the toolchain:
# * for cobalt/host/default toolchains, this equals |root_build_dir|
# * for starboard toolchain, this equals |root_build_dir/starboard|
# By rebasing the path against root_out_dir, we ensure that the output
# folder structure for copied files mirrors the original tree.
#
# See reference for further details:
# https://gn.googlesource.com/gn/+/main/docs/reference.md#var_root_out_dir
rebase_path(sb_static_contents_output_data_dir, root_out_dir),
"--files_list",
rebase_path(bundle_content_rsp_file, root_build_dir),
"--output",
rebase_path(outputs[0], root_build_dir),
"--depfile",
rebase_path(depfile, root_build_dir),
]
}
}