| # Copyright 2021 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") |
| import("//src/sys/core/build/core_shard.gni") |
| import("//tools/cmc/build/cmc.gni") |
| |
| template("_weavestack_package_v2") { |
| invoker_manifest_v2 = invoker.manifest_v2 |
| cml_name = get_path_info(invoker_manifest_v2, "name") |
| if (defined(invoker.extra_cml)) { |
| manifest_merge_target_v2 = "${target_name}_${cml_name}_merge_v2" |
| cmc_merge(manifest_merge_target_v2) { |
| sources = [ invoker_manifest_v2 ] + invoker.extra_cml |
| output_name = "$manifest_merge_target_v2.cml" |
| } |
| invoker_manifest_v2 = get_target_outputs(":$manifest_merge_target_v2") |
| invoker_manifest_v2 = invoker_manifest_v2[0] |
| } |
| |
| component_target_v2 = "${target_name}_${cml_name}_component_v2" |
| fuchsia_component(component_target_v2) { |
| forward_variables_from(invoker, [ "testonly" ]) |
| component_name = cml_name |
| manifest = invoker_manifest_v2 |
| visibility = [ ":*" ] |
| |
| if (!defined(deps)) { |
| deps = [] |
| } |
| if (!defined(manifest_deps)) { |
| manifest_deps = [] |
| } |
| deps += [ |
| "//src/connectivity/weave/weavestack:bin", |
| "//src/connectivity/weave/weavestack:default_environment_schema", |
| ] |
| if (defined(manifest_merge_target_v2)) { |
| manifest_deps += [ ":$manifest_merge_target_v2" ] |
| } |
| } |
| |
| fuchsia_package(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "applets", |
| "package_name", |
| "testonly", |
| "visibility", |
| ]) |
| deps = [ ":$component_target_v2" ] |
| |
| if (defined(applets)) { |
| deps += [ applets.target ] |
| } |
| } |
| |
| core_shard("weavestack-core-shard") { |
| shard_file = invoker.component_shard_file |
| deps = |
| [ "//src/connectivity/network/tun/network-tun:network-tun-core-shard" ] |
| } |
| } |
| |
| # Creates a 'weavestack' package. All packages created with this template will be identical, except |
| # for the addition of selected applet modules. |
| # |
| # Example: |
| # ``` |
| # weavestack_package_v2("foo_weave") { |
| # package_name = "weave_package" |
| # applets = { |
| # target = "//path/to/applets/module" |
| # name = "module_name.so" |
| # } |
| # extra_cml = [ |
| # "meta/manifest.cml", |
| # ] |
| # component_shard_file = "meta/core_shard.cml" |
| # } |
| # ``` |
| # |
| # Parameters |
| # applets (optional) |
| # A scope defining a loadable module that implements weave applets. |
| # Type: scope with the entries: |
| # |
| # target (required) |
| # The GN `loadable_module` target that builds the applets module. |
| # Type: path |
| # |
| # name (required) |
| # The name of the loadable module. |
| # Type: string |
| # |
| # package_name (optional) |
| # The name of the weavestack package. Defaults to 'target_name'. |
| # Type: string |
| # Default: ${target_name} |
| # |
| # extra_cml (optional) |
| # Additional CML manifests that will be merged with the base weavestack.cml manifest. |
| # This can be used to add additional services or features that may be needed by different |
| # weave applets. |
| # Type: list(path) |
| # |
| # component_shard_file (required) |
| # Manifest shards that will be merged with weavestack_common.core_shard.cml. One of the |
| # manifest shard should define this component as child to be included in core's manifest. |
| # This can also be used to add additional offer declaration that may be needed by different |
| # weave applets. |
| # Type: path |
| template("weavestack_package_v2") { |
| _weavestack_package_v2(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "applets", |
| "component_shard_file", |
| "extra_cml", |
| "package_name", |
| ]) |
| manifest_v2 = "//src/connectivity/weave/meta/weavestack.cml" |
| } |
| } |