| # Copyright 2019 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/config.gni") | |
| import("//build/json/validate_json.gni") | |
| declare_args() { | |
| # Indicates whether to include basemgr.cmx in the boot sequence for the | |
| # product image. | |
| launch_basemgr_on_boot = true | |
| } | |
| # Validates a modular framework configuration file against a schema | |
| # | |
| # Parameters | |
| # config (required) | |
| # This is a modular framework configuration file that needs to be validated. | |
| template("modular_config_validate") { | |
| validate_json(target_name) { | |
| forward_variables_from(invoker, | |
| [ | |
| "deps", | |
| "public_deps", | |
| "testonly", | |
| "visibility", | |
| ]) | |
| data = invoker.config | |
| schema = "//sdk/docs/modular_config_schema.json" | |
| } | |
| } | |
| # Packages a modular framework configuration after validating the configuration. | |
| # Configuration will be found in basemgr's /config/data/startup.config. | |
| # | |
| # Parameters | |
| # config (required) | |
| # This is a file containing configuration for the modular framework. | |
| # It will be schema-validated. | |
| template("modular_config") { | |
| modular_config_validate(target_name + "_validate") { | |
| forward_variables_from(invoker, | |
| [ | |
| "deps", | |
| "testonly", | |
| "visibility", | |
| ]) | |
| config = invoker.config | |
| } | |
| config_data(target_name + "_basemgr.config") { | |
| for_pkg = "sysmgr" | |
| sources = [ | |
| "//src/modular/build/modular_config/basemgr.config", | |
| ] | |
| outputs = [ | |
| "basemgr.config", | |
| ] | |
| } | |
| # By default, add the sysmgr config to automatically launch basemgr.cmx, | |
| # unless the invoker explicitly disables this with | |
| # launch_basemgr_on_boot = false. | |
| config_data_deps = [ ":${invoker.target_name}_validate" ] | |
| if (launch_basemgr_on_boot) { | |
| config_data_deps += [ ":" + target_name + "_basemgr.config" ] | |
| } | |
| config_data(invoker.target_name) { | |
| for_pkg = "basemgr" | |
| sources = [ | |
| rebase_path(invoker.config), | |
| ] | |
| outputs = [ | |
| "startup.config", | |
| ] | |
| deps = config_data_deps | |
| } | |
| } |