blob: 5c50ceb59b1e393d8dfd9813f54343b867a7df65 [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")
sdkable = defined(invoker.sdk_publishable) && invoker.sdk_publishable
assert(!sdkable, "Libraries available in SDKs are currently not supported")
assert(defined(invoker.sdk),
"Can only migrate libraries exposed to the GN build")
shape = invoker.sdk
if (shape == "source" || shape == "static") {
target_type = "static_library"
} else if (shape == "shared") {
target_type = "shared_library"
} else {
assert(false, "Unknown library type: $shape")
}
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)
configs += [ "//build/unification/config:zircon-library" ]
# 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
}