blob: a12cf644cc5ed0e30fb56fab7b7e14ca7f53ade1 [file] [log] [blame]
# Copyright 2020 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.
assert(is_fuchsia, "Zircon libraries only available for Fuchsia targets")
import("//build/config/fuchsia/zircon.gni")
import("//build/unification/images/artifacts.gni")
# Exposes a library provided by the ZN build to the manifest metadata collection
# scheme.
#
# This template allows such libraries and their various variants to be included
# in manifests generated from metadata.
#
# Parameters
#
# library (required)
# [string] Name of the library to expose.
template("zircon_runtime_library") {
assert(defined(invoker.library), "Must provide a library")
name = "lib.${invoker.library}"
if (toolchain_variant.instrumented && toolchain_variant.name != "") {
# Fuzzers just use the base variant.
name += "." + string_replace(toolchain_variant.name, "-fuzzer", "")
}
artifact = false
foreach(entry, zircon_artifacts) {
if (entry.name == name) {
assert(artifact == false, "Duplicate Zircon library: $name")
artifact = entry
}
}
assert(artifact != false, "Could not find Zircon library: $name")
assert(artifact.deps == [],
"Cannot handle Zircon library $name, deps not supported")
format_args = [
"--zircon-build-dir",
rebase_path(zircon_root_build_dir),
"--build-dir",
rebase_path(root_build_dir),
# NOTE: not including the toolchain here as this target can be reached from
# different paths due to its hacky nature, and label stability is key to
# ensure the build does not fail due to a bogus duplicate.
# This will go away naturally when these libraries are handled directly in
# the GN build.
"--label",
get_label_info(":$target_name", "label_no_toolchain"),
]
foreach(line, artifact.lines) {
format_args += [
"--entry",
line,
]
}
metadata_entries = exec_script("//build/unification/lib/format_metadata.py",
format_args,
"json")
group(target_name) {
metadata = {
# Used by the distribution_manifest template.
distribution_entries_barrier = []
distribution_entries = metadata_entries
}
}
}