blob: 369bb0be3441f21e3e582139c580361084cf5822 [file] [log] [blame]
# 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("//src/sys/build/components.gni")
import("//tools/cmc/build/cmc.gni")
template("_audio_core_package") {
components = []
foreach(invoker_manifest, invoker.manifests) {
cmx_name = get_path_info(invoker_manifest, "name")
if (defined(invoker.extra_cmx)) {
manifest_merge_target = "${target_name}_${cmx_name}_merge"
cmc_merge(manifest_merge_target) {
sources = [ invoker_manifest ] + invoker.extra_cmx
output_name = "$manifest_merge_target.cmx"
}
invoker_manifest = get_target_outputs(":$manifest_merge_target")
invoker_manifest = invoker_manifest[0]
}
component_target = "${target_name}_${cmx_name}_component"
fuchsia_component(component_target) {
forward_variables_from(invoker, [ "testonly" ])
component_name = cmx_name
manifest = invoker_manifest
visibility = [
":*",
"/*",
]
deps = [ "//src/media/audio/audio_core:audio_core_bin" ]
if (defined(manifest_merge_target)) {
deps += [ ":$manifest_merge_target" ]
}
}
components += [ ":$component_target" ]
}
fuchsia_package(target_name) {
forward_variables_from(invoker,
[
"effects",
"package_name",
"testonly",
"visibility",
])
deps = components
if (defined(effects)) {
deps += [ effects.target ]
}
}
}
# Creates a 'audio_core' test package, designed to be used in the hermetic testing envirionment.
#
# Example:
# ```
# audio_core_test_package("foo-audio-for-test") {
# package_name = "foo-audio-for-test"
# effects = {
# target = "//path/to/effects/module"
# name = "module_name.so"
# }
# extra_cmx = [
# "meta/manifest.cmx",
# ]
# }
# ```
#
# Parameters
# package_name (optional)
# The name of the audio_core package. Defaults to 'target_name'.
# Type: string
# Default: ${target_name}
#
# effects (optional)
# A scope defining a loadable module that implements audio effects.
# Type: scope with the entries:
#
# target (required)
# The GN `loadable_module` target that builds the effects module.
# Type: path
#
# name (required)
# The name of the loadable module.
# Type: string
#
# extra_cmx (optional)
# Additinoal CMX manifests that will be merged with the base audio_core.cmx manifest.
# This can be used to add additional services or features that may be needed by different
# audio effects.
# Type: list(path)
template("audio_core_test_package") {
_audio_core_package(target_name) {
testonly = true
forward_variables_from(invoker,
[
"effects",
"extra_cmx",
"package_name",
])
manifests = [
# The nodevfs cmx is used in some test environments where we would like to provide our own
# devfs for the test. At this time we need to remove any dev sandbox metadata as appmgr does
# not allow these namespaces to be overridden.
"//src/media/audio/audio_core/meta/audio_core_nodevfs.cmx",
# The noconfigdata cmx additionally doesn't request the config-data feature so that the test
# fixture may provide a custom /config/data directory.
"//src/media/audio/audio_core/meta/audio_core_nodevfs_noconfigdata.cmx",
]
}
}
# Creates a 'audio_core' package. All packages created with this template will be identical, except
# for the addition of the effects module.
#
# Example:
# ```
# audio_core_package("foo_audio") {
# package_name = "audio_package"
# test_package_name = "test_audio_package"
# effects = {
# target = "//path/to/effects/module"
# name = "module_name.so"
# }
# extra_cmx = [
# "meta/manifest.cmx",
# ]
# }
# ```
#
# Parameters
# effects (optional)
# A scope defining a loadable module that implements audio effects.
# Type: scope with the entries:
#
# target (required)
# The GN `loadable_module` target that builds the effects module.
# Type: path
#
# name (required)
# The name of the loadable module.
# Type: string
#
# package_name (optional)
# The name of the audio_core package. Defaults to 'target_name'.
# Type: string
# Default: ${target_name}
#
# extra_cmx (optional)
# Additinoal CMX manifests that will be merged with the base audio_core.cmx manifest.
# This can be used to add additional services or features that may be needed by different
# audio effects.
#
# test_package_name (optional)
# The name of the audio_core test package. This package contains manifests that allow
# for the component to run in a hermetic test environment. No package will be generated
# if this is not provided.
# Type: string
#
# extra_cmx (optional)
# Additinoal CMX manifests that will be merged with the base audio_core.cmx manifest.
# This can be used to add additional services or features that may be needed by different
# audio effects.
# Type: list(path)
template("audio_core_package") {
forward_variables_from(invoker,
[
"package_name",
"test_package_name",
])
_audio_core_package(target_name) {
forward_variables_from(invoker,
[
"effects",
"extra_cmx",
"package_name",
])
manifests = [ "//src/media/audio/audio_core/meta/audio_core.cmx" ]
}
if (defined(test_package_name)) {
audio_core_test_package(test_package_name) {
forward_variables_from(invoker,
[
"effects",
"extra_cmx",
])
package_name = test_package_name
}
}
}