| # 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. |
| |
| # Defines a core realm shard. |
| # |
| # This template defines a core realm shard, a cml manifest that |
| # is optionally included in the core component. |
| # |
| # The shard target must be included in one of the following GN argument arrays: |
| # |
| # * core_realm_shards |
| # * board_core_realm_shards |
| # * fuchsia_base.extra_core_realm_shards |
| # |
| # Example: |
| # |
| # BUILD.gn |
| # ``` |
| # core_shard("foo") { |
| # shard_file = "foo.core_shard.cml" |
| # } |
| # ``` |
| # |
| # product.gni |
| # ``` |
| # core_realm_shards += [ "//path/to/foo" ] |
| # ``` |
| # |
| # See https://fuchsia.dev/fuchsia-src/contribute/governance/rfcs/0089_core_realm_variations |
| # for more details. |
| # |
| # Parameters |
| # |
| # shard_file (required) |
| # Component manifest file. |
| # Type: path |
| # |
| # includes (optional) |
| # [list of paths to shards] List paths to all cml files which are included |
| # in the shard cml using cml `include`, so that they can be included |
| # in the Assembly Input Bundle. |
| # |
| # All other parameters are forwarded to the generated `group` target. |
| # |
| template("core_shard") { |
| assert( |
| defined(invoker.shard_file), |
| "The `shard_file` argument was missing when calling core_shard($target_name)") |
| |
| if ("cml" != get_path_info(invoker.shard_file, "extension")) { |
| assert( |
| false, |
| "Unknown manifest format for \"${invoker.shard_file)\", must be \".cml\"") |
| } |
| |
| group(target_name) { |
| forward_variables_from(invoker, |
| "*", |
| [ |
| "shard_file", |
| "includes", |
| ]) |
| metadata = { |
| shard_files = [ rebase_path(invoker.shard_file, root_build_dir) ] |
| |
| # TODO(https://fxbug.dev/42055992): Make shard_includes required |
| if (defined(invoker.includes)) { |
| shard_includes = [] |
| foreach(include, invoker.includes) { |
| shard_includes += [ |
| { |
| source = rebase_path(include, root_build_dir) |
| destination = rebase_path(include, "//") |
| }, |
| ] |
| } |
| } |
| } |
| } |
| } |