blob: 83840fcab6fde6dd4e5dc987a3613e946737b565 [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.
# Collects build outputs and data files for inclusion in the CTS archive.
#
# This is a helper template that declares metadata for the cts_artifacts
# build api module. See //sdk/cts:cts_artifacts. Package archives and data
# files are copied to the root of $root_gen_dir/cts. For example:
#
# package_archives = [//my/pkg.far] generates $root_gen_dir/cts/pkg.far
# data = [my/data/file.txt] generates $root_gen_dir/cts/file.txt
#
# Parameters
#
# package_archives (optional)
# A list of targets declared earlier in the same file which generate Fuchsia
# package archives.
# Type: list(label)
#
# data (optional)
# A list of metadata files to include. Filepaths are relative to the
# target directory. This should not be used for source files: the directory
# structure is not preserved in the output.
# Type: list(string)
#
# testonly
template("cts_artifacts") {
group(target_name) {
forward_variables_from(invoker, [ "testonly" ])
metadata = {
# TODO(jcecil): Remove "_old" entry after fxr/559550 lands.
cts_artifacts = []
cts_artifacts_old = []
}
_cts_artifacts_dir = "$root_out_dir/cts"
deps = []
if (defined(invoker.deps)) {
deps = invoker.deps
}
# Copies all package archives into _cts_artifacts_dir.
if (defined(invoker.package_archives)) {
copy_archives_target_name = "copy_${target_name}_archives"
copy(copy_archives_target_name) {
sources = []
foreach(a, invoker.package_archives) {
sources += get_target_outputs(a)
}
outputs = [ "$_cts_artifacts_dir/{{source_file_part}}" ]
deps = invoker.package_archives
}
foreach(o, get_target_outputs(":$copy_archives_target_name")) {
# TODO(jcecil): Remove "_old" entry after fxr/559550 lands.
metadata.cts_artifacts += [ rebase_path(o, root_build_dir) ]
metadata.cts_artifacts_old += [ rebase_path(o, root_build_dir) ]
}
deps += [ ":$copy_archives_target_name" ]
}
# Copies all data files into _cts_artifacts_dir.
if (defined(invoker.data)) {
copy_data_target_name = "copy_${target_name}_data"
copy(copy_data_target_name) {
sources = invoker.data
outputs = [ "$_cts_artifacts_dir/{{source_file_part}}" ]
}
foreach(o, get_target_outputs(":$copy_data_target_name")) {
# TODO(jcecil): Remove "_old" entry after fxr/559550 lands.
metadata.cts_artifacts += [ rebase_path(o, root_build_dir) ]
metadata.cts_artifacts_old += [ rebase_path(o, root_build_dir) ]
}
deps += [ ":$copy_data_target_name" ]
}
}
}