| # Copyright 2018 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") |
| |
| # The list of variants that can use prebuilt ffmpeg libraries. |
| ffmpeg_prebuilt_variants = [ |
| "", |
| "debug", |
| "release", |
| "asan", |
| "asan-ubsan", |
| "lto", |
| "profile", |
| "coverage", |
| "coverage-rust", |
| "coverage-sdk", |
| "thinlto", |
| "ubsan", |
| ] |
| |
| has_prebuilt_ffmpeg = ffmpeg_prebuilt_variants + [ toolchain_variant.name ] - |
| [ toolchain_variant.name ] != ffmpeg_prebuilt_variants |
| |
| declare_args() { |
| # Use a prebuilt ffmpeg binary rather than building it locally. See |
| # //src/media/lib/ffmpeg/README.md for details. This is ignored when |
| # building in variant builds for which there is no prebuilt. In that |
| # case, ffmpeg is always built from source so as to be built with the |
| # selected variant's config. When this is false (either explicitly or in |
| # a variant build) then //third_party/ffmpeg must be in the source tree, |
| # which requires: |
| # `jiri import -name third_party/ffmpeg -revision HEAD third_party/ffmpeg http://fuchsia.googlesource.com/integration` |
| # or, if already importing a different manifest from there, resulting in errors from jiri update, |
| # it can work to just git clone (but jiri update won't manage third_party/ffmpeg in this case): |
| # mkdir third_party/ffmpeg |
| # git clone "sso://fuchsia.googlesource.com/third_party/ffmpeg" third_party/ffmpeg |
| use_prebuilt_ffmpeg = has_prebuilt_ffmpeg |
| } |
| |
| group("ffmpeg") { |
| visibility = [ |
| "//src/media/codec/codecs/sw/ffmpeg:codec_runner_sw_ffmpeg", |
| "//src/media/lib", |
| "//src/media/playback/mediaplayer/ffmpeg", |
| "//src/media/playback/mediaplayer_tmp/ffmpeg", |
| ] |
| |
| if (use_prebuilt_ffmpeg) { |
| public_deps = [ ":prebuilt_ffmpeg($shlib_toolchain)" ] |
| } else { |
| deps = [ "//third_party/ffmpeg" ] |
| public_configs = [ "//third_party/ffmpeg:ffmpeg_dependent_config" ] |
| } |
| } |
| |
| if (use_prebuilt_ffmpeg) { |
| assert(has_prebuilt_ffmpeg, |
| "No prebuilt ffmpeg for this variant (${toolchain_variant.name}), " + |
| "did you set use_prebuilt_ffmpeg=true mistakenly in your args.gn?") |
| |
| group("prebuilt_ffmpeg") { |
| deps = [ ":prebuilt_ffmpeg_shared_library" ] |
| |
| public_configs = [ ":prebuilt_ffmpeg_config" ] |
| } |
| |
| variant_prefix = toolchain_variant.name |
| if (variant_prefix == "debug" || variant_prefix == "release") { |
| variant_prefix = "" |
| } |
| |
| # THe 'coverage-sdk' build variant only builds the SDK sdk_source_set() targets |
| # with instrumentation, all other targets are built with the default toolchain |
| # suite otherwise. |
| if (variant_prefix == "coverage-sdk") { |
| variant_prefix = "" |
| } |
| if (variant_prefix != "") { |
| variant_prefix += "/" |
| } |
| |
| prebuilt_dir = "//prebuilt/third_party/ffmpeg/arch/$current_cpu" |
| if (variant_prefix == "debug") { |
| lib_dir = "$prebuilt_dir/debug/" |
| } else { |
| lib_dir = "$prebuilt_dir/lib/" |
| } |
| |
| config("prebuilt_ffmpeg_config") { |
| visibility = [ ":prebuilt_ffmpeg" ] |
| |
| ffmpeg_include = "//prebuilt/third_party/ffmpeg/pkg/ffmpeg/include" |
| if (current_cpu == "x64") { |
| ffmpeg_config = "max" |
| } else { |
| ffmpeg_config = "default" |
| } |
| |
| include_dirs = [ |
| ffmpeg_include, |
| "$ffmpeg_include/fuchsia/config/$ffmpeg_config/$current_cpu", |
| ] |
| |
| libs = [ "ffmpeg" ] |
| lib_dirs = [ lib_dir ] |
| } |
| |
| resource("prebuilt_ffmpeg_shared_library") { |
| sources = [ "$lib_dir/${variant_prefix}libffmpeg.so" ] |
| |
| # NOTE: prebuilt shared libraries for instrumented variants should be |
| # installed into lib/<variant>/, and lib/ for non-instrumented ones |
| # (e.g. thinlto). |
| _libprefix = "" |
| if (toolchain_variant.instrumented) { |
| _libprefix = string_replace(toolchain_variant.name, "-fuzzer", "") + "/" |
| } |
| outputs = [ "lib/${_libprefix}libffmpeg.so" ] |
| } |
| } |