| # 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/components.gni") |
| import("//tools/cmc/build/cmc.gni") |
| |
| # Parameters |
| # package_name (optional) |
| # See audio_core_package and audio_core_test_package |
| # |
| # effects (optional) |
| # See audio_core_package and audio_core_test_package |
| # |
| # extra_cmx (optional) |
| # See audio_core_package and audio_core_test_package |
| # |
| # production_extra_cmx (optional) |
| # See audio_core_package |
| # |
| # use_prebuilt_coefficient_tables (optional) |
| # See audio_core_package and audio_core_test_package |
| # |
| # manifests (required) |
| # A list of CMX manifest files. One component will be created per manifest. |
| # |
| template("_audio_core_package") { |
| components = [] |
| use_prebuilt_coefficient_tables = |
| defined(invoker.use_prebuilt_coefficient_tables) && |
| invoker.use_prebuilt_coefficient_tables |
| |
| foreach(invoker_manifest, invoker.manifests) { |
| cmx_name = get_path_info(invoker_manifest, "name") |
| |
| # Merge in extra_cmx |
| if (defined(invoker.extra_cmx) || defined(invoker.production_extra_cmx)) { |
| manifest_merge_target = "${target_name}_${cmx_name}_merge" |
| cmc_merge(manifest_merge_target) { |
| sources = [ invoker_manifest ] |
| if (defined(invoker.extra_cmx)) { |
| sources += invoker.extra_cmx |
| } |
| if (defined(invoker.production_extra_cmx)) { |
| sources += invoker.production_extra_cmx |
| } |
| output_name = "${manifest_merge_target}.cmx" |
| } |
| invoker_manifest = get_target_outputs(":$manifest_merge_target") |
| invoker_manifest = invoker_manifest[0] |
| } |
| |
| # Fix binary name. |
| if (use_prebuilt_coefficient_tables) { |
| manifest_rewrite_target = "${target_name}_${cmx_name}_rewrite" |
| action(manifest_rewrite_target) { |
| forward_variables_from(invoker, [ "testonly" ]) |
| script = "//src/media/audio/replace_string.sh" |
| sources = [ invoker_manifest ] |
| outputs = [ "${target_gen_dir}/${manifest_rewrite_target}.cmx" ] |
| args = [ |
| rebase_path(invoker_manifest, root_build_dir), |
| rebase_path(target_gen_dir, root_build_dir) + |
| "/${manifest_rewrite_target}.cmx", |
| "bin/audio_core", |
| "bin/audio_core_with_prebuilt_coefficient_tables", |
| ] |
| if (defined(manifest_merge_target)) { |
| deps = [ ":$manifest_merge_target" ] |
| } |
| } |
| invoker_manifest = get_target_outputs(":$manifest_rewrite_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 = [ |
| ":*", |
| "/*", |
| ] |
| |
| if (use_prebuilt_coefficient_tables) { |
| deps = [ "//src/media/audio/audio_core:audio_core_bin_with_prebuilt_coefficient_tables" ] |
| manifest_deps = [ ":$manifest_rewrite_target" ] |
| } else { |
| deps = [ "//src/media/audio/audio_core:audio_core_bin" ] |
| manifest_deps = [] |
| } |
| if (defined(manifest_merge_target)) { |
| manifest_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) |
| # Additional 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) |
| # |
| # use_prebuilt_coefficient_tables (optional) |
| # If set, we will include a few prebuilt tables in the executable. This improves startup |
| # performance at the cost of a larger executable image. |
| # Type: bool |
| # |
| template("audio_core_test_package") { |
| _audio_core_package(target_name) { |
| testonly = true |
| forward_variables_from(invoker, |
| [ |
| "effects", |
| "extra_cmx", |
| "package_name", |
| "use_prebuilt_coefficient_tables", |
| ]) |
| |
| 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", |
| ] |
| |
| # Tests run faster with prebuilt tables and don't have tight executable size requirements. |
| use_prebuilt_coefficient_tables = true |
| } |
| } |
| |
| # 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} |
| # |
| # 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) |
| # Additional 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. Will be forwarded to the test package as well. |
| # Type: list(path) |
| # |
| # production_extra_cmx (optional) |
| # Additional 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. Will not be forwarded to the test package. |
| # Type: list(path) |
| # |
| # use_prebuilt_coefficient_tables (optional) |
| # If set, we will include a few prebuilt tables in the executable. This improves startup |
| # performance at the cost of a larger executable image. |
| # Type: bool |
| # |
| 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", |
| "production_extra_cmx", |
| "package_name", |
| "use_prebuilt_coefficient_tables", |
| ]) |
| 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 |
| } |
| } |
| } |