blob: 868747040fc3443b3203fa1cc97bf7875723c301 [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.
import("//build/packages/prebuilt_package.gni")
# Generates a target for a prebuilt CTF package.
#
# The input is a scope with the following properties, which were collected from
# each test's GN metadata when the CTF release was created.
#
# archive_gn_label
# The label (without toolchain) of the GN target that originally generated
# the FAR archive at the time the CTF release was created.
# Type: string
#
# archive_name
# The basename of the archive, relative the manifest's parent directory.
# Type: string
#
# package_name
# The name of the package within the archive.
# Type: string
template("generate_ctf_package") {
assert(defined(invoker.package_name))
assert(defined(invoker.archive_path))
# Without this the build fails with an error that
# ${target_name}_meta_package.txt is missing.
meta_package_target = "${target_name}_meta_package"
generate_meta_package(meta_package_target) {
package_name = invoker.package_name
}
prebuilt_package(target_name) {
forward_variables_from(invoker, [ "testonly" ])
archive = invoker.archive_path
package_name = invoker.package_name
deps = [ ":$meta_package_target" ]
if (defined(invoker.deps)) {
deps += invoker.deps
}
}
}
# Generates a target for each prebuilt CTF package in the given manifest.
#
# Each package is named according the API level it tests. For example, a package
# originally named "fuchsia-echo-tests" in the CTF release for API level 11 can
# be referred to using the label :fuchsia-echo-tests_ctf11.
#
# The input is a JSON list containing the set of packages to generated.
# See `generate_ctf_package` above for the schema used by each object in the list.
template("generate_ctf_packages") {
assert(defined(invoker.api_level), "api_level is required")
assert(defined(invoker.manifest), "manifest is required")
manifest = invoker.manifest
api_level = invoker.api_level
packages = []
root_dir = get_path_info(manifest, "dir")
foreach(item, read_file(manifest, "json")) {
actual_package_name = item.package_name
package_target_name = "${actual_package_name}_ctf${api_level}"
packages += [ ":$package_target_name" ]
generate_ctf_package(package_target_name) {
package_name = actual_package_name
archive_path = "$root_dir/${item.archive_name}.far"
}
}
group(target_name) {
testonly = true
deps = packages
}
}