| # 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("//src/sys/build/fuchsia_component.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 `driver_module()` targets to ensure | |
| # that any `fuchsia_package()` that includes them will include the same drivers. | |
| # | |
| # ``` | |
| # driver_module("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") { | |
| component_name = target_name | |
| if (defined(invoker.component_name)) { | |
| component_name = invoker.component_name | |
| } | |
| manifest_path = "${target_gen_dir}/meta/${component_name}.cmx" | |
| devmgr_args = [] | |
| if (defined(invoker.args)) { | |
| devmgr_args = invoker.args | |
| } | |
| devmgr_args += [ "--path_prefix=/pkg/" ] | |
| manifest_name = "${component_name}.cmx" | |
| generated_file(manifest_name) { | |
| outputs = [ manifest_path ] | |
| contents = { | |
| program = { | |
| args = devmgr_args | |
| binary = "bin/isolated_devmgr" | |
| } | |
| sandbox = { | |
| services = [ | |
| "fuchsia.exception.Handler", | |
| "fuchsia.logger.LogSink", | |
| "fuchsia.process.Launcher", | |
| ] | |
| } | |
| } | |
| output_conversion = "json" | |
| } | |
| fuchsia_component(target_name) { | |
| forward_variables_from(invoker, [ "visibility" ]) | |
| testonly = true | |
| component_name = component_name | |
| manifest = manifest_path | |
| deps = [] | |
| if (defined(invoker.deps)) { | |
| deps = invoker.deps | |
| } | |
| deps += [ | |
| ":${manifest_name}", | |
| "//src/bringup/bin/device-name-provider", | |
| "//src/devices/bin/driver_host", | |
| "//src/devices/bin/driver_manager", | |
| "//src/lib/isolated_devmgr:isolated_devmgr", | |
| "//src/storage/fshost", | |
| ] | |
| } | |
| } |