blob: 1c171caef4648eaf381ab05451d0cbaa28794322 [file] [log] [blame]
# 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/compiled_action.gni")
import("//build/config.gni")
# Define a thermal configuration target for a given JSON file.
#
# The template validates the provided JSON file to ensure it matches the expected thermal
# configuration schema and criteria. If valid, a `resource` target will be created to allow the file
# to be included in a package. If invalid, the build will fail.
#
# When a `thermal_config` target is added as a bootfs dependency, the provided JSON file will be
# accessible at the path "/pkg/config/power_manager/thermal_config.json" on the device.
#
# Parameters
#
# config_file (required)
# [string] The path to the JSON thermal trip point configuration file.
#
# output (optional)
# [string] The name of the JSON file as it will be published on the filesystem. Defaults to
# "thermal_config.json", but the template accepts this as an argument to allow overriding for
# tests.
#
# Example usage:
#
# thermal_config("astro") {
# config_file = "astro.json5"
# }
#
# thermal_config("test_config") {
# config_file = "valid_thermal_config.json5"
# output = "test_config.json"
# }
#
template("thermal_config") {
assert(defined(invoker.config_file), "Need to specify a config file")
output_config_name = "thermal_config.json"
if (defined(invoker.output)) {
output_config_name = invoker.output
}
compiled_action("${target_name}_validate") {
forward_variables_from(invoker,
[
"deps",
"testonly",
])
tool = "//src/power/power-manager/thermal_config/validator"
tool_output_name = "thermal_config_validator"
inputs = [ invoker.config_file ]
outputs = [ "$target_gen_dir/$target_name.validated" ]
args = [
"--input",
rebase_path(inputs[0], root_build_dir),
"--stamp",
rebase_path(outputs[0], root_build_dir),
]
}
resource("${target_name}_data") {
forward_variables_from(invoker,
[
"deps",
"testonly",
])
sources = [ invoker.config_file ]
outputs = [ "config/power_manager/${output_config_name}" ]
}
group(target_name) {
forward_variables_from(invoker, [ "testonly" ])
deps = [
":${target_name}_data",
":${target_name}_validate",
]
}
}