blob: 2a78a242102f799693ec0a6ac1f9f3bb30e4752c [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("//build/config.gni")
import("//build/package.gni")
import("//tools/cmc/build/cmc.gni")
template("_audio_core_package") {
forward_variables_from(invoker, [ "extra_cmx" ])
cmx_deps = []
processed_meta = []
if (!defined(extra_cmx)) {
processed_meta = invoker.meta
} else {
processed_meta = []
foreach(manifest, invoker.meta) {
cmx_name = get_path_info(manifest.path, "file")
manifest_merge_target = "${cmx_name}_merge"
cmc_merge(manifest_merge_target) {
sources = [ manifest.path ]
sources += extra_cmx
output_name = "${cmx_name}.merged.cmx"
}
merged_manifest = get_target_outputs(":${manifest_merge_target}")
merged_manifest = merged_manifest[0]
cmx_deps += [ ":${manifest_merge_target}" ]
processed_meta += [
{
path = rebase_path(merged_manifest)
dest = manifest.dest
},
]
}
}
package(target_name) {
forward_variables_from(invoker,
[
"effects",
"package_name",
"testonly",
])
deps = [ "//src/media/audio/audio_core:audio_core_bin" ]
deps += cmx_deps
meta = processed_meta
binaries = [
{
name = "audio_core"
},
]
if (defined(effects)) {
assert(defined(effects.target))
assert(defined(effects.name))
deps += [ effects.target ]
loadable_modules = [
{
name = effects.name
},
]
}
}
}
# 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",
])
meta = [
# 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.
{
path = rebase_path(
"//src/media/audio/audio_core/meta/audio_core_nodevfs.cmx")
dest = "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.
{
path = rebase_path(
"//src/media/audio/audio_core/meta/audio_core_nodevfs_noconfigdata.cmx")
dest = "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",
])
meta = [
{
path = rebase_path("//src/media/audio/audio_core/meta/audio_core.cmx")
dest = "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
}
}
}