blob: bb11b9371040abff7b288d3ea06769d498f2264c [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/components.gni")
# Produces a component with an isoalted driver manager which can be used to launch drivers.
#
# Example Usage:
#
# ```
# isolated_devmgr_component("my-component") {
# args = [ "--svc_name=fuchsia.example.IsolatedDevmgr" ]
# }
#
# fuchsia_package("my-package") {
# deps = [ ":my-component" ]
# }
# ```
# The component above will have the following launch URL:
# `fuchsia-pkg://fuchsia.com/my-package#meta/my-component.cmx`
#
# `isolated_devmgr_component` may depend on any number of `fuchsia_driver()` targets to ensure
# that any `fuchsia_package()` that includes them will include the same drivers.
#
# ```
# fuchsia_driver("my_driver") {
# ...
# }
#
# isolated_devmgr_component("my-component") {
# deps = [ ":my_driver" ]
# ...
# }
# ```
#
# The component defined above will be able to read my_driver under the path
# "/pkg/driver/my_driver.so" in its sandbox.
#
# Parameters
#
# component_name (optional)
# The name of the component.
# Type: string
# Default: target_name
#
# args (optional)
# The list of arguments to pass to isolated_devmgr
# Type: list
#
# deps
# testonly
# visibility
template("isolated_devmgr_component") {
if (current_toolchain == default_toolchain) {
component_name = target_name
if (defined(invoker.component_name)) {
component_name = invoker.component_name
}
manifest_target = "${target_name}_manifest"
fuchsia_test_component_manifest(manifest_target) {
forward_variables_from(invoker, [ "deps" ])
visibility = [ ":*" ]
v2 = false
if (!defined(deps)) {
deps = []
}
deps += [ "//src/lib/isolated_devmgr:isolated_devmgr" ]
metadata = {
# Include args in the generated manifest to be passed to isolated_devmgr
test_component_manifest_cmx = [
{
program = {
forward_variables_from(invoker, [ "args" ])
}
},
]
}
}
fuchsia_component(target_name) {
forward_variables_from(invoker,
[
"deps",
"manifest_deps",
"visibility",
])
manifest = get_target_outputs(":$manifest_target")
manifest = manifest[0]
testonly = true
if (!defined(manifest_deps)) {
manifest_deps = []
}
manifest_deps += [ ":$manifest_target" ]
}
} else {
group(target_name) {
testonly = true
deps = [ ":$target_name($default_toolchain)" ]
}
not_needed(invoker, "*")
}
}