blob: b1a5b7fbd56a81ece3623ddac93dd10c433da42b [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.
import("//build/cpp/sdk_source_set.gni")
template("zx_library") {
template_params = [
"static",
"shared",
"host",
"kernel",
"sdk",
"sdk_headers",
"sdk_publishable",
]
# The following parameters are just ignored, as in the GN build the shape of
# a library is driven by the value of the "sdk" parameter.
not_needed(invoker,
[
"static",
"shared",
"host",
])
assert(!defined(invoker.kernel) || !invoker.kernel,
"Kernel libraries not supported")
assert(defined(invoker.sdk),
"Can only migrate libraries exposed to the GN build")
assert(invoker.sdk == "source",
"Only libraries exposed as sources are supported")
sdkable = defined(invoker.sdk_publishable) && invoker.sdk_publishable
target_type = "source_set"
if (sdkable) {
target_type = "sdk_source_set"
}
main_target_name = target_name
config_target_name = "$target_name.config"
config(config_target_name) {
include_dirs = [ "include" ]
}
target(target_type, main_target_name) {
forward_variables_from(invoker, "*", template_params)
# Binaries depending on migrated libraries cannot be marked as testonly, and
# therefore neither can the libraries themselves.
# See fxb/44278 for more info.
testonly = false
if (defined(invoker.sdk_headers)) {
public = []
foreach(header, invoker.sdk_headers) {
public += [ "include/$header" ]
}
}
public_configs = [ ":$config_target_name" ]
}
}
set_defaults("zx_library") {
configs = default_common_binary_configs
}