blob: dc912d65c8e205277e5989dde22fbc225a546a0f [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/components.gni")
import("//build/config.gni")
# Example:
# ```
# audio_core_config_test("foo-audio-core-config-test") {
# config_sources = [
# "//path/to/audio_core_config.json",
# ]
# policy_sources = [
# "//path/to/audio_policy.json",
# ]
# package_name = "foo-audio-core-config-test"
# }
# ```
#
# Parameters
# config_sources (required)
# A list of paths to audio_core_config.json files.
# Type: list (string)
#
# policy_sources (required)
# A list of paths to audio_policy.json files.
# Type: list (string)
#
# package_name (optional)
# The name of the package to create.
# Type: string
# Default: $target_name
#
template("audio_core_config_test") {
assert(defined(invoker.config_sources))
package_name = target_name
if (defined(invoker.package_name)) {
package_name = invoker.package_name
}
test_config_resource = "${target_name}_config_resource"
resource(test_config_resource) {
visibility = [ ":*" ]
testonly = true
sources = invoker.config_sources
outputs = [ "audio_core_config/{{source_file_part}}" ]
}
if (defined(invoker.policy_sources)) {
test_policy_resource = "${target_name}_policy_resource"
resource(test_policy_resource) {
visibility = [ ":*" ]
testonly = true
sources = invoker.policy_sources
outputs = [ "audio_policy/{{source_file_part}}" ]
}
}
fuchsia_unittest_package(target_name) {
deps = [
":${test_config_resource}",
"//src/media/audio/audio_core/test/config_validator",
]
if (defined(invoker.policy_sources)) {
deps += [ ":${test_policy_resource}" ]
}
}
}
# Example:
# ```
# audio_core_config("foo_audio_core_config") {
# for_pkg = "audio_core"
# config = "//path/to/audio_core_config.json"
# policy = "//path/to/audio_policy.json"
# test_package_name = "foo-audio-core-config-test"
# }
# ```
#
# Parameters
# for_pkg (required)
# The name of the audio_core package.
# Type: string
#
# config (required)
# The path of an audio_core_config.json file.
# Type: string
#
# policy (optional)
# The path of an audio_policy.json file.
# Type: string
#
# test_package_name(required)
# The package name of a fuchsia_unittest_package. This test package will validate that
# `config` can be loaded by audio_core.
# Type: string
#
template("audio_core_config") {
assert(defined(invoker.for_pkg))
assert(defined(invoker.config))
assert(defined(invoker.test_package_name))
# Add the config-data for the audio_core package.
config_data(target_name + "-config") {
forward_variables_from(invoker,
[
"testonly",
"for_pkg",
])
sources = [ invoker.config ]
outputs = [ "audio_core_config.json" ]
}
if (defined(invoker.policy)) {
config_data(target_name + "-policy") {
forward_variables_from(invoker,
[
"testonly",
"for_pkg",
])
sources = [ invoker.policy ]
outputs = [ "audio_policy.json" ]
}
}
group(target_name) {
deps = [ ":${target_name}-config" ]
if (defined(invoker.policy)) {
deps += [ ":${target_name}-policy" ]
}
}
audio_core_config_test(invoker.test_package_name) {
config_sources = [ invoker.config ]
if (defined(invoker.policy)) {
policy_sources = [ invoker.policy ]
}
}
}