blob: 9698191cd0511bed95ac79fc7b2239944304dfbe [file] [log] [blame]
# 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("//build/compiled_action.gni")
import("//build/dist/resource.gni")
# Generates binary config using FIDL format and .json data values.
#
# Example instantiation:
#
# ```
# component_config("some_config") {
# source = "config.json"
# }
# ```
#
# Inputs:
#
# - JSON file with config values.
#
# Outputs:
#
# - Persistent FIDL binary config file.
#
# Parameters:
#
# source: (required string), path to json file containing config values.
#
# output_name: (optional string), path to the binary config destination.
# By default, rule name is used as a file name.
template("component_config") {
# Best practices forward.
forward_variables_from(invoker,
[
"testonly",
"visibility",
"sources",
])
assert(defined(sources), "Parameter source=... is required")
if (defined(invoker.output_name)) {
output_name = invoker.output_name
} else {
output_name = target_name
}
output_file_name = "${target_gen_dir}/${output_name}"
compiled_target = "${target_name}"
compiled_action(compiled_target) {
forward_variables_from(invoker,
[
"deps",
"testonly",
])
tool = "//tools/component_manager_config:generate_config_bin"
tool_output_name = "generate_config"
inputs = sources
outputs = [ output_file_name ]
args = [
"--output",
rebase_path(output_file_name, root_build_dir),
]
foreach(source, sources) {
args += [
"--input",
rebase_path(source, root_build_dir),
]
}
}
}