| # Copyright 2018 The Chromium 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/compiled_action.gni") |
| import("//build/package.gni") |
| |
| module_manifest_schema = "//peridot/build/module_manifest_schema.json" |
| |
| # This template generates a target that will verify the supplied module |
| # manifest. |
| # |
| # Parameters |
| # |
| # original_target_name (required) |
| # This is the original parent-level target name for the package that calls |
| # this into template. This name is used for printing out a stamp file. |
| # |
| # module_manifest (required) |
| # Path to the module manifest that needs to be verified. |
| template("verify_module_manifest") { |
| assert(defined(invoker.original_target_name), |
| "Must specify original_target_name.") |
| assert(defined(invoker.module_manifest), |
| "Must specify path to module manifest.") |
| |
| compiled_action(target_name) { |
| tool = "//build/tools/json_validator" |
| stamp_file = "$target_gen_dir/${invoker.original_target_name}.verified" |
| |
| inputs = [ |
| invoker.module_manifest, |
| module_manifest_schema, |
| ] |
| |
| outputs = [ |
| stamp_file, |
| ] |
| |
| args = [ |
| rebase_path(module_manifest_schema), |
| rebase_path(invoker.module_manifest), |
| rebase_path(stamp_file), |
| ] |
| } |
| } |
| |
| # This is a rule used to generate an index of module packages that should be |
| # indexed by the on-device module resolver when it starts up. This template is |
| # meant to be used only once for each layer, but multiple may exist for |
| # different device package sets. This target generates a system package, so |
| # this target *must* be included in your layer's build image. |
| # |
| # The following must be true for each of the listed packages: |
| # |
| # 0) Make sure this module package is built and included on the device image. |
| # E.g: For an index of all topaz modules, make sure all module packages are |
| # transitively included from //topaz/packages/topaz. |
| # 1) Create a Module manifest file as per //peridot/docs/modular/manifests/module.md |
| # and include it in your module package. The flutter_app() template from |
| # topaz includes the specified module manifest in the package for you. |
| # 2) Point the 'binary' attribute in your manifest to the module's package name. |
| # |
| # Example: |
| # |
| # import("//peridot/build/module_manifest.gni") |
| # |
| # initial_module_packages("manifests") { |
| # packages = [ "my_module_package1", "my_module_package2" ] |
| # } |
| template("initial_module_packages") { |
| assert(defined(invoker.packages), |
| "'packages' must be defined for $target_name") |
| |
| # NOTE: The fully resolved path will be |
| # /system/data/module_manifest_repository |
| # This must match that given in bin/module_resolver/module_resolver_main.cc |
| module_index_filename = "$root_build_dir/module_package_index/$target_name" |
| write_file(module_index_filename, invoker.packages) |
| |
| package(target_name) { |
| deprecated_system_image = true |
| resources = [ |
| { |
| path = rebase_path(module_index_filename) |
| dest = "initial_module_packages/$target_name" |
| }, |
| ] |
| } |
| } |
| |
| template("copy_module_manifest") { |
| assert(defined(invoker.module_manifest), "Must specify module_manifest.") |
| assert(defined(invoker.package_name), "Must specify package_name.") |
| |
| copy(target_name) { |
| sources = [ |
| rebase_path(invoker.module_manifest), |
| ] |
| outputs = [ |
| "$root_build_dir/module_manifests/${invoker.package_name}", |
| ] |
| } |
| } |