diff options
Diffstat (limited to 'third_party/aom/build/cmake')
-rw-r--r-- | third_party/aom/build/cmake/aom_config_defaults.cmake | 248 | ||||
-rw-r--r-- | third_party/aom/build/cmake/aom_configure.cmake | 55 | ||||
-rw-r--r-- | third_party/aom/build/cmake/aom_experiment_deps.cmake | 4 | ||||
-rw-r--r-- | third_party/aom/build/cmake/aom_optimization.cmake | 4 | ||||
-rw-r--r-- | third_party/aom/build/cmake/exports.cmake | 7 | ||||
-rw-r--r-- | third_party/aom/build/cmake/exports_sources.cmake | 16 | ||||
-rw-r--r-- | third_party/aom/build/cmake/generate_aom_config_templates.cmake | 19 | ||||
-rw-r--r-- | third_party/aom/build/cmake/generate_exports.cmake | 24 | ||||
-rw-r--r-- | third_party/aom/build/cmake/ios-Info.plist | 37 | ||||
-rwxr-xr-x | third_party/aom/build/cmake/iosbuild.sh | 384 | ||||
-rwxr-xr-x | third_party/aom/build/cmake/rtcd.pl | 467 | ||||
-rw-r--r-- | third_party/aom/build/cmake/util.cmake | 91 | ||||
-rwxr-xr-x | third_party/aom/build/cmake/version.pl | 10 |
13 files changed, 1233 insertions, 133 deletions
diff --git a/third_party/aom/build/cmake/aom_config_defaults.cmake b/third_party/aom/build/cmake/aom_config_defaults.cmake index 19af5c43b..a07438cfe 100644 --- a/third_party/aom/build/cmake/aom_config_defaults.cmake +++ b/third_party/aom/build/cmake/aom_config_defaults.cmake @@ -7,90 +7,190 @@ # at www.aomedia.org/license/software. If the Alliance for Open Media Patent # License 1.0 was not distributed with this source code in the PATENTS file, you # can obtain it at www.aomedia.org/license/patent. + +include("${AOM_ROOT}/build/cmake/util.cmake") + +# This file sets default values for libaom configuration variables. All libaom +# config variables are added to the CMake variable cache via the macros provided +# in util.cmake. + # -# Defaults for every libaom configuration variable. Here we add all libaom -# config variables to the cmake variable cache, but omit the FORCE parameter to -# allow users to specify values when executing cmake to generate build files. -# Values here are used only if not set by the user. -set(INLINE "" CACHE STRING "Sets INLINE value for current target.") +# The variables in this section of the file are detected at configuration time, +# but can be overridden via the use of CONFIG_* and ENABLE_* values also defined +# in this file. +# + +set_aom_detect_var(INLINE "" STRING "Sets INLINE value for current target.") # CPUs. -set(ARCH_ARM 0 CACHE NUMBER "Enables ARM architecture.") -set(ARCH_MIPS 0 CACHE NUMBER "Enables MIPS architecture.") -set(ARCH_PPC 0 CACHE NUMBER "Enables PPC architecture.") -set(ARCH_X86 0 CACHE NUMBER "Enables X86 architecture.") -set(ARCH_X86_64 0 CACHE NUMBER "Enables X86_64 architecture.") - -# ARM optimization flags. -set(HAVE_NEON 0 CACHE NUMBER "Enables NEON intrinsics optimizations.") - -# MIPS optimization flags. -set(HAVE_DSPR2 0 CACHE NUMBER "Enables DSPR2 optimizations.") -set(HAVE_MIPS32 0 CACHE NUMBER "Enables MIPS32 optimizations.") -set(HAVE_MIPS64 0 CACHE NUMBER "Enables MIPS64 optimizations. ") -set(HAVE_MSA 0 CACHE NUMBER "Enables MSA optimizations.") - -# PPC optimization flags. -set(HAVE_VSX 0 CACHE NUMBER "Enables VSX optimizations.") - -# x86/x86_64 optimization flags. -set(HAVE_AVX 0 CACHE NUMBER "Enables AVX optimizations.") -set(HAVE_AVX2 0 CACHE NUMBER "Enables AVX2 optimizations.") -set(HAVE_MMX 0 CACHE NUMBER "Enables MMX optimizations. ") -set(HAVE_SSE 0 CACHE NUMBER "Enables SSE optimizations.") -set(HAVE_SSE2 0 CACHE NUMBER "Enables SSE2 optimizations.") -set(HAVE_SSE3 0 CACHE NUMBER "Enables SSE3 optimizations.") -set(HAVE_SSE4_1 0 CACHE NUMBER "Enables SSE 4.1 optimizations.") -set(HAVE_SSE4_2 0 CACHE NUMBER "Enables SSE 4.2 optimizations.") -set(HAVE_SSSE3 0 CACHE NUMBER "Enables SSSE3 optimizations.") +set_aom_detect_var(ARCH_ARM 0 NUMBER "Enables ARM architecture.") +set_aom_detect_var(ARCH_MIPS 0 NUMBER "Enables MIPS architecture.") +set_aom_detect_var(ARCH_PPC 0 NUMBER "Enables PPC architecture.") +set_aom_detect_var(ARCH_X86 0 NUMBER "Enables X86 architecture.") +set_aom_detect_var(ARCH_X86_64 0 NUMBER "Enables X86_64 architecture.") + +# ARM feature flags. +set_aom_detect_var(HAVE_NEON 0 NUMBER "Enables NEON intrinsics optimizations.") + +# MIPS feature flags. +set_aom_detect_var(HAVE_DSPR2 0 NUMBER "Enables DSPR2 optimizations.") +set_aom_detect_var(HAVE_MIPS32 0 NUMBER "Enables MIPS32 optimizations.") +set_aom_detect_var(HAVE_MIPS64 0 NUMBER "Enables MIPS64 optimizations. ") +set_aom_detect_var(HAVE_MSA 0 NUMBER "Enables MSA optimizations.") + +# PPC feature flags. +set_aom_detect_var(HAVE_VSX 0 NUMBER "Enables VSX optimizations.") + +# x86/x86_64 feature flags. +set_aom_detect_var(HAVE_AVX 0 NUMBER "Enables AVX optimizations.") +set_aom_detect_var(HAVE_AVX2 0 NUMBER "Enables AVX2 optimizations.") +set_aom_detect_var(HAVE_MMX 0 NUMBER "Enables MMX optimizations. ") +set_aom_detect_var(HAVE_SSE 0 NUMBER "Enables SSE optimizations.") +set_aom_detect_var(HAVE_SSE2 0 NUMBER "Enables SSE2 optimizations.") +set_aom_detect_var(HAVE_SSE3 0 NUMBER "Enables SSE3 optimizations.") +set_aom_detect_var(HAVE_SSE4_1 0 NUMBER "Enables SSE 4.1 optimizations.") +set_aom_detect_var(HAVE_SSE4_2 0 NUMBER "Enables SSE 4.2 optimizations.") +set_aom_detect_var(HAVE_SSSE3 0 NUMBER "Enables SSSE3 optimizations.") # Flags describing the build environment. -set(HAVE_FEXCEPT 0 CACHE NUMBER "Internal flag, GNU fenv.h present for target.") -set(HAVE_PTHREAD_H 0 CACHE NUMBER "Internal flag, target pthread support.") -set(HAVE_UNISTD_H 0 CACHE NUMBER "Internal flag, unistd.h present for target.") -set(HAVE_WXWIDGETS 0 CACHE NUMBER "WxWidgets present.") +set_aom_detect_var(HAVE_FEXCEPT 0 NUMBER + "Internal flag, GNU fenv.h present for target.") +set_aom_detect_var(HAVE_PTHREAD_H 0 NUMBER + "Internal flag, target pthread support.") +set_aom_detect_var(HAVE_UNISTD_H 0 NUMBER + "Internal flag, unistd.h present for target.") +set_aom_detect_var(HAVE_WXWIDGETS 0 NUMBER "WxWidgets present.") + +# +# Variables in this section can be set from the CMake command line or from +# within the CMake GUI. The variables control libaom features. +# # Build configuration flags. -set(CONFIG_AV1_DECODER 1 CACHE NUMBER "Enable AV1 decoder.") -set(CONFIG_AV1_ENCODER 1 CACHE NUMBER "Enable AV1 encoder.") -set(CONFIG_BIG_ENDIAN 0 CACHE NUMBER "Internal flag.") -set(CONFIG_GCC 0 CACHE NUMBER "Building with GCC (detected).") -set(CONFIG_GCOV 0 CACHE NUMBER "Enable gcov support.") -set(CONFIG_GPROF 0 CACHE NUMBER "Enable gprof support.") -set(CONFIG_LIBYUV 1 CACHE NUMBER "Enables libyuv scaling/conversion support.") -set(CONFIG_MSVS 0 CACHE NUMBER "Building with MS Visual Studio (detected).") -set(CONFIG_MULTITHREAD 1 CACHE NUMBER "Multithread support.") -set(CONFIG_OS_SUPPORT 0 CACHE NUMBER "Internal flag.") -set(CONFIG_PIC 0 CACHE NUMBER "Build with PIC enabled.") -set(CONFIG_RUNTIME_CPU_DETECT 1 CACHE NUMBER "Runtime CPU detection support.") -set(CONFIG_SHARED 0 CACHE NUMBER "Build shared libs.") -set(CONFIG_STATIC 1 CACHE NUMBER "Build static libs.") -set(CONFIG_WEBM_IO 1 CACHE NUMBER "Enables WebM support.") +set_aom_config_var(AOM_RTCD_FLAGS "" STRING + "Arguments to pass to rtcd.pl. Separate with ';'") +set_aom_config_var(CONFIG_AV1_DECODER 1 NUMBER "Enable AV1 decoder.") +set_aom_config_var(CONFIG_AV1_ENCODER 1 NUMBER "Enable AV1 encoder.") +set_aom_config_var(CONFIG_BIG_ENDIAN 0 NUMBER "Internal flag.") +set_aom_config_var(CONFIG_GCC 0 NUMBER "Building with GCC (detect).") +set_aom_config_var(CONFIG_GCOV 0 NUMBER "Enable gcov support.") +set_aom_config_var(CONFIG_GPROF 0 NUMBER "Enable gprof support.") +set_aom_config_var(CONFIG_LIBYUV 1 NUMBER + "Enables libyuv scaling/conversion support.") + +set_aom_config_var(CONFIG_MULTITHREAD 1 NUMBER "Multithread support.") +set_aom_config_var(CONFIG_OS_SUPPORT 0 NUMBER "Internal flag.") +set_aom_config_var(CONFIG_PIC 0 NUMBER "Build with PIC enabled.") +set_aom_config_var(CONFIG_RUNTIME_CPU_DETECT 1 NUMBER + "Runtime CPU detection support.") +set_aom_config_var(CONFIG_SHARED 0 NUMBER "Build shared libs.") +set_aom_config_var(CONFIG_STATIC 1 NUMBER "Build static libs.") +set_aom_config_var(CONFIG_WEBM_IO 1 NUMBER "Enables WebM support.") # Debugging flags. -set(CONFIG_BITSTREAM_DEBUG 0 CACHE NUMBER "Bitstream debugging flag.") -set(CONFIG_DEBUG 0 CACHE NUMBER "Debug build flag.") -set(CONFIG_MISMATCH_DEBUG 0 CACHE NUMBER "Mismatch debugging flag.") +set_aom_config_var(CONFIG_BITSTREAM_DEBUG 0 NUMBER "Bitstream debugging flag.") +set_aom_config_var(CONFIG_DEBUG 0 NUMBER "Debug build flag.") +set_aom_config_var(CONFIG_MISMATCH_DEBUG 0 NUMBER "Mismatch debugging flag.") # AV1 feature flags. -set(CONFIG_ACCOUNTING 0 CACHE NUMBER "Enables bit accounting.") -set(CONFIG_ANALYZER 0 CACHE NUMBER "Enables bit stream analyzer.") -set(CONFIG_COEFFICIENT_RANGE_CHECKING 0 CACHE NUMBER "Coefficient range check.") -set(CONFIG_DENOISE 0 CACHE NUMBER "Denoise/noise modeling support in encoder.") -set(CONFIG_FILEOPTIONS 1 CACHE NUMBER "Enables encoder config file support.") -set(CONFIG_INSPECTION 0 CACHE NUMBER "Enables bitstream inspection.") -set(CONFIG_INTERNAL_STATS 0 CACHE NUMBER "Enables internal encoder stats.") -set(CONFIG_LOWBITDEPTH 0 CACHE NUMBER "Enables 8-bit optimized pipeline.") -set(CONFIG_SIZE_LIMIT 0 CACHE NUMBER "Limit max decode width/height.") -set(CONFIG_SPATIAL_RESAMPLING 1 CACHE NUMBER "Spatial resampling.") -set(DECODE_HEIGHT_LIMIT 0 CACHE NUMBER "Set limit for decode height.") -set(DECODE_WIDTH_LIMIT 0 CACHE NUMBER "Set limit for decode width.") +set_aom_config_var(CONFIG_ACCOUNTING 0 NUMBER "Enables bit accounting.") +set_aom_config_var(CONFIG_ANALYZER 0 NUMBER "Enables bit stream analyzer.") +set_aom_config_var(CONFIG_COEFFICIENT_RANGE_CHECKING 0 NUMBER + "Coefficient range check.") +set_aom_config_var(CONFIG_DENOISE 1 NUMBER + "Denoise/noise modeling support in encoder.") +set_aom_config_var(CONFIG_FILEOPTIONS 1 NUMBER + "Enables encoder config file support.") +set_aom_config_var(CONFIG_FIX_GF_LENGTH 1 NUMBER + "Fix the GF length if possible") +set_aom_config_var(CONFIG_INSPECTION 0 NUMBER "Enables bitstream inspection.") +set_aom_config_var(CONFIG_INTERNAL_STATS 0 NUMBER + "Enables internal encoder stats.") +set_aom_config_var(CONFIG_LOWBITDEPTH 0 NUMBER + "Enables 8-bit optimized pipeline.") +set_aom_config_var(CONFIG_MAX_DECODE_PROFILE 2 NUMBER + "Max profile to support decoding.") +set_aom_config_var(CONFIG_NORMAL_TILE_MODE 0 NUMBER + "Only enables normal tile mode.") +set_aom_config_var( + CONFIG_REDUCED_ENCODER_BORDER 0 NUMBER + "Enable reduced border extention for encoder. \ + Disables superres and resize support." + ) +set_aom_config_var(CONFIG_SIZE_LIMIT 0 NUMBER "Limit max decode width/height.") +set_aom_config_var(CONFIG_SPATIAL_RESAMPLING 1 NUMBER "Spatial resampling.") +set_aom_config_var(DECODE_HEIGHT_LIMIT 0 NUMBER "Set limit for decode height.") +set_aom_config_var(DECODE_WIDTH_LIMIT 0 NUMBER "Set limit for decode width.") +set_aom_config_var(CONFIG_GLOBAL_MOTION_SEARCH 1 NUMBER + "Global motion search flag.") # AV1 experiment flags. -set(CONFIG_COLLECT_INTER_MODE_RD_STATS 1 CACHE NUMBER "AV1 experiment flag.") -set(CONFIG_COLLECT_RD_STATS 0 CACHE NUMBER "AV1 experiment flag.") -set(CONFIG_DIST_8X8 1 CACHE NUMBER "AV1 experiment flag.") -set(CONFIG_ENTROPY_STATS 0 CACHE NUMBER "AV1 experiment flag.") -set(CONFIG_FP_MB_STATS 0 CACHE NUMBER "AV1 experiment flag.") -set(CONFIG_INTER_STATS_ONLY 0 CACHE NUMBER "AV1 experiment flag.") -set(CONFIG_RD_DEBUG 0 CACHE NUMBER "AV1 experiment flag.") +set_aom_config_var(CONFIG_COLLECT_INTER_MODE_RD_STATS 1 NUMBER + "AV1 experiment flag.") +set_aom_config_var(CONFIG_COLLECT_RD_STATS 0 NUMBER "AV1 experiment flag.") +set_aom_config_var(CONFIG_DIST_8X8 0 NUMBER "AV1 experiment flag.") +set_aom_config_var(CONFIG_ENTROPY_STATS 0 NUMBER "AV1 experiment flag.") +set_aom_config_var(CONFIG_FP_MB_STATS 0 NUMBER "AV1 experiment flag.") +set_aom_config_var(CONFIG_INTER_STATS_ONLY 0 NUMBER "AV1 experiment flag.") +set_aom_config_var(CONFIG_RD_DEBUG 0 NUMBER "AV1 experiment flag.") +set_aom_config_var(CONFIG_2PASS_PARTITION_SEARCH_LVL 1 NUMBER + "AV1 experiment flag.") +set_aom_config_var(CONFIG_SHARP_SETTINGS 0 NUMBER + "Use sharper encoding settings") + +# +# Variables in this section control optional features of the build system. +# +set_aom_option_var(ENABLE_CCACHE "Enable ccache support." OFF) +set_aom_option_var(ENABLE_DECODE_PERF_TESTS "Enables decoder performance tests" + OFF) +set_aom_option_var(ENABLE_DISTCC "Enable distcc support." OFF) +set_aom_option_var(ENABLE_DOCS + "Enable documentation generation (doxygen required)." ON) +set_aom_option_var(ENABLE_ENCODE_PERF_TESTS "Enables encoder performance tests" + OFF) +set_aom_option_var(ENABLE_EXAMPLES "Enables build of example code." ON) +set_aom_option_var(ENABLE_GOMA "Enable goma support." OFF) +set_aom_option_var( + ENABLE_IDE_TEST_HOSTING + "Enables running tests within IDEs like Visual Studio and Xcode." OFF) +set_aom_option_var(ENABLE_NASM "Use nasm instead of yasm for x86 assembly." OFF) +set_aom_option_var(ENABLE_TESTDATA "Enables unit test data download targets." + ON) +set_aom_option_var(ENABLE_TESTS "Enables unit tests." ON) +set_aom_option_var(ENABLE_TOOLS "Enable applications in tools sub directory." + ON) +set_aom_option_var(ENABLE_WERROR "Converts warnings to errors at compile time." + OFF) + +# ARM assembly/intrinsics flags. +set_aom_option_var(ENABLE_NEON "Enables NEON optimizations on ARM targets." ON) + +# MIPS assembly/intrinsics flags. +set_aom_option_var(ENABLE_DSPR2 "Enables DSPR2 optimizations on MIPS targets." + OFF) +set_aom_option_var(ENABLE_MSA "Enables MSA optimizations on MIPS targets." OFF) + +# VSX intrinsics flags. +set_aom_option_var(ENABLE_VSX "Enables VSX optimizations on PowerPC targets." + ON) + +# x86/x86_64 assembly/intrinsics flags. +set_aom_option_var(ENABLE_MMX + "Enables MMX optimizations on x86/x86_64 targets." ON) +set_aom_option_var(ENABLE_SSE + "Enables SSE optimizations on x86/x86_64 targets." ON) +set_aom_option_var(ENABLE_SSE2 + "Enables SSE2 optimizations on x86/x86_64 targets." ON) +set_aom_option_var(ENABLE_SSE3 + "Enables SSE3 optimizations on x86/x86_64 targets." ON) +set_aom_option_var(ENABLE_SSSE3 + "Enables SSSE3 optimizations on x86/x86_64 targets." ON) +set_aom_option_var(ENABLE_SSE4_1 + "Enables SSE4_1 optimizations on x86/x86_64 targets." ON) +set_aom_option_var(ENABLE_SSE4_2 + "Enables SSE4_2 optimizations on x86/x86_64 targets." ON) +set_aom_option_var(ENABLE_AVX + "Enables AVX optimizations on x86/x86_64 targets." ON) +set_aom_option_var(ENABLE_AVX2 + "Enables AVX2 optimizations on x86/x86_64 targets." ON) diff --git a/third_party/aom/build/cmake/aom_configure.cmake b/third_party/aom/build/cmake/aom_configure.cmake index a12389778..c0c7381e8 100644 --- a/third_party/aom/build/cmake/aom_configure.cmake +++ b/third_party/aom/build/cmake/aom_configure.cmake @@ -20,19 +20,6 @@ include(FindThreads) set(AOM_SUPPORTED_CPU_TARGETS "arm64 armv7 armv7s generic mips32 mips64 ppc x86 x86_64") -# Generate the user config settings. This must occur before include of -# aom_config_defaults.cmake (because it turns every config variable into a cache -# variable with its own help string). -get_cmake_property(cmake_cache_vars CACHE_VARIABLES) -foreach(cache_var ${cmake_cache_vars}) - get_property(cache_var_helpstring CACHE ${cache_var} PROPERTY HELPSTRING) - set(cmdline_helpstring "No help, variable specified on the command line.") - if("${cache_var_helpstring}" STREQUAL "${cmdline_helpstring}") - set(AOM_CMAKE_CONFIG "${AOM_CMAKE_CONFIG} -D${cache_var}=${${cache_var}}") - endif() -endforeach() -string(STRIP "${AOM_CMAKE_CONFIG}" AOM_CMAKE_CONFIG) - include("${AOM_ROOT}/build/cmake/aom_config_defaults.cmake") include("${AOM_ROOT}/build/cmake/aom_experiment_deps.cmake") include("${AOM_ROOT}/build/cmake/aom_optimization.cmake") @@ -40,6 +27,16 @@ include("${AOM_ROOT}/build/cmake/compiler_flags.cmake") include("${AOM_ROOT}/build/cmake/compiler_tests.cmake") include("${AOM_ROOT}/build/cmake/util.cmake") +# Generate the user config settings. +list(APPEND aom_build_vars ${AOM_CONFIG_VARS} ${AOM_OPTION_VARS}) +foreach(cache_var ${aom_build_vars}) + get_property(cache_var_helpstring CACHE ${cache_var} PROPERTY HELPSTRING) + if("${cache_var_helpstring}" STREQUAL "${cmake_cmdline_helpstring}") + set(AOM_CMAKE_CONFIG "${AOM_CMAKE_CONFIG} -D${cache_var}=${${cache_var}}") + endif() +endforeach() +string(STRIP "${AOM_CMAKE_CONFIG}" AOM_CMAKE_CONFIG) + # Detect target CPU. if(NOT AOM_TARGET_CPU) if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "AMD64" OR @@ -73,7 +70,9 @@ if(NOT AOM_TARGET_CPU) endif() if(CMAKE_TOOLCHAIN_FILE) # Add toolchain file to config string. - set(toolchain_string "-DCMAKE_TOOLCHAIN_FILE=\\\"${CMAKE_TOOLCHAIN_FILE}\\\"") + file(RELATIVE_PATH toolchain_path "${AOM_CONFIG_DIR}" + "${CMAKE_TOOLCHAIN_FILE}") + set(toolchain_string "-DCMAKE_TOOLCHAIN_FILE=\\\"${toolchain_path}\\\"") set(AOM_CMAKE_CONFIG "${toolchain_string} ${AOM_CMAKE_CONFIG}") else() @@ -81,6 +80,8 @@ else() set(AOM_CMAKE_CONFIG "-DAOM_TARGET_CPU=${AOM_TARGET_CPU} ${AOM_CMAKE_CONFIG}") endif() set(AOM_CMAKE_CONFIG "-G \\\"${CMAKE_GENERATOR}\\\" ${AOM_CMAKE_CONFIG}") +file(RELATIVE_PATH source_path "${AOM_CONFIG_DIR}" "${AOM_ROOT}") +set(AOM_CMAKE_CONFIG "cmake ${source_path} ${AOM_CMAKE_CONFIG}") string(STRIP "${AOM_CMAKE_CONFIG}" AOM_CMAKE_CONFIG) message("--- aom_configure: Detected CPU: ${AOM_TARGET_CPU}") @@ -90,13 +91,13 @@ if("${CMAKE_BUILD_TYPE}" MATCHES "Deb") set(CONFIG_DEBUG 1) endif() -if(NOT MSVC) - if(BUILD_SHARED_LIBS) - set(CONFIG_PIC 1) - set(CONFIG_SHARED 1) - set(CONFIG_STATIC 0) - endif() +if(BUILD_SHARED_LIBS) + set(CONFIG_PIC 1) + set(CONFIG_SHARED 1) + set(CONFIG_STATIC 0) +endif() +if(NOT MSVC) if(CONFIG_PIC) # TODO(tomfinegan): clang needs -pie in CMAKE_EXE_LINKER_FLAGS for this to @@ -109,8 +110,6 @@ if(NOT MSVC) set(AOM_AS_FLAGS ${AOM_AS_FLAGS} -DPIC) endif() endif() -else() - set(CONFIG_MSVS 1) endif() if(NOT "${AOM_SUPPORTED_CPU_TARGETS}" MATCHES "${AOM_TARGET_CPU}") @@ -261,13 +260,15 @@ else() add_compiler_flag_if_supported("-Wlogical-op") add_compiler_flag_if_supported("-Wpointer-arith") add_compiler_flag_if_supported("-Wsign-compare") - add_compiler_flag_if_supported("-Wstack-usage=360000") add_compiler_flag_if_supported("-Wstring-conversion") add_compiler_flag_if_supported("-Wtype-limits") add_compiler_flag_if_supported("-Wuninitialized") add_compiler_flag_if_supported("-Wunused") add_compiler_flag_if_supported("-Wvla") + add_c_flag_if_supported("-Wstack-usage=100000") + add_cxx_flag_if_supported("-Wstack-usage=360000") + # TODO(jzern): this could be added as a cxx flags for test/*.cc only, avoiding # third_party. add_c_flag_if_supported("-Wshorten-64-to-32") @@ -278,6 +279,12 @@ else() # Add -Wundef only for C files to avoid massive gtest warning spam. add_c_flag_if_supported("-Wundef") + # Quiet gcc 6 vs 7 abi warnings: + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77728 + if("${AOM_TARGET_CPU}" MATCHES "arm") + add_cxx_flag_if_supported("-Wno-psabi") + endif() + if(ENABLE_WERROR) add_compiler_flag_if_supported("-Werror") endif() @@ -344,7 +351,7 @@ foreach(NUM RANGE ${AOM_RTCD_CUSTOM_COMMAND_COUNT}) list(GET AOM_RTCD_HEADER_FILE_LIST ${NUM} AOM_RTCD_HEADER_FILE) list(GET AOM_RTCD_SOURCE_FILE_LIST ${NUM} AOM_RTCD_SOURCE_FILE) list(GET AOM_RTCD_SYMBOL_LIST ${NUM} AOM_RTCD_SYMBOL) - execute_process(COMMAND ${PERL_EXECUTABLE} "${AOM_ROOT}/build/make/rtcd.pl" + execute_process(COMMAND ${PERL_EXECUTABLE} "${AOM_ROOT}/build/cmake/rtcd.pl" --arch=${AOM_TARGET_CPU} --sym=${AOM_RTCD_SYMBOL} ${AOM_RTCD_FLAGS} --config=${AOM_CONFIG_DIR}/config/aom_config.h diff --git a/third_party/aom/build/cmake/aom_experiment_deps.cmake b/third_party/aom/build/cmake/aom_experiment_deps.cmake index e2c8102aa..0688704e5 100644 --- a/third_party/aom/build/cmake/aom_experiment_deps.cmake +++ b/third_party/aom/build/cmake/aom_experiment_deps.cmake @@ -25,4 +25,8 @@ macro(fix_experiment_configs) change_config_and_warn(CONFIG_RD_DEBUG 0 CONFIG_JNT_COMP) endif() + if(CONFIG_DIST_8X8 AND CONFIG_MULTITHREAD) + change_config_and_warn(CONFIG_DIST_8X8 0 CONFIG_MULTITHREAD) + endif() + endmacro() diff --git a/third_party/aom/build/cmake/aom_optimization.cmake b/third_party/aom/build/cmake/aom_optimization.cmake index ce3dc0340..be32a3212 100644 --- a/third_party/aom/build/cmake/aom_optimization.cmake +++ b/third_party/aom/build/cmake/aom_optimization.cmake @@ -193,13 +193,13 @@ function(test_nasm) endfunction() # Adds build command for generation of rtcd C source files using -# build/make/rtcd.pl. $config is the input perl file, $output is the output C +# build/cmake/rtcd.pl. $config is the input perl file, $output is the output C # include file, $source is the C source file, and $symbol is used for the symbol # argument passed to rtcd.pl. function(add_rtcd_build_step config output source symbol) add_custom_command(OUTPUT ${output} COMMAND ${PERL_EXECUTABLE} ARGS - "${AOM_ROOT}/build/make/rtcd.pl" + "${AOM_ROOT}/build/cmake/rtcd.pl" --arch=${AOM_TARGET_CPU} --sym=${symbol} ${AOM_RTCD_FLAGS} --config=${AOM_CONFIG_DIR}/config/aom_config.h diff --git a/third_party/aom/build/cmake/exports.cmake b/third_party/aom/build/cmake/exports.cmake index 5abfc9a5f..e0813dc0f 100644 --- a/third_party/aom/build/cmake/exports.cmake +++ b/third_party/aom/build/cmake/exports.cmake @@ -34,7 +34,8 @@ function(setup_exports_target) -DAOM_SYM_FILE="${aom_sym_file}" -DAOM_MSVC=${MSVC} -DAOM_XCODE=${XCODE} -DCONFIG_NAME=$<CONFIG> -DCONFIG_AV1_DECODER=${CONFIG_AV1_DECODER} - -DCONFIG_AV1_ENCODER=${CONFIG_AV1_ENCODER} -P + -DCONFIG_AV1_ENCODER=${CONFIG_AV1_ENCODER} + -DENABLE_TESTS=${ENABLE_TESTS} -P "${AOM_ROOT}/build/cmake/generate_exports.cmake" SOURCES ${AOM_EXPORTS_SOURCES} DEPENDS ${AOM_EXPORTS_SOURCES}) @@ -47,10 +48,12 @@ function(setup_exports_target) set_property(TARGET aom APPEND_STRING PROPERTY LINK_FLAGS "-exported_symbols_list ${aom_sym_file}") elseif(WIN32) - message(FATAL_ERROR "Windows DLL builds not supported yet.") if(NOT MSVC) set_property(TARGET aom APPEND_STRING PROPERTY LINK_FLAGS "-Wl,--version-script ${aom_sym_file}") + else() + set_property(TARGET aom APPEND_STRING + PROPERTY LINK_FLAGS "/DEF:${aom_sym_file}") endif() # TODO(tomfinegan): Sort out the import lib situation and flags for MSVC. diff --git a/third_party/aom/build/cmake/exports_sources.cmake b/third_party/aom/build/cmake/exports_sources.cmake index 48790dbaa..576920e36 100644 --- a/third_party/aom/build/cmake/exports_sources.cmake +++ b/third_party/aom/build/cmake/exports_sources.cmake @@ -13,14 +13,20 @@ if(AOM_BUILD_CMAKE_EXPORTS_SOURCES_CMAKE_) endif() # AOM_BUILD_CMAKE_EXPORTS_SOURCES_CMAKE_ set(AOM_BUILD_CMAKE_EXPORTS_SOURCES_CMAKE_ 1) -set(AOM_EXPORTS_SOURCES "${AOM_ROOT}/aom/exports_com") +list(APPEND AOM_EXPORTS_SOURCES "${AOM_ROOT}/aom/exports_com" + "${AOM_ROOT}/av1/exports_com") if(CONFIG_AV1_DECODER) - set(AOM_EXPORTS_SOURCES ${AOM_EXPORTS_SOURCES} "${AOM_ROOT}/aom/exports_dec" - "${AOM_ROOT}/av1/exports_dec") + list(APPEND AOM_EXPORTS_SOURCES "${AOM_ROOT}/aom/exports_dec" + "${AOM_ROOT}/av1/exports_dec") endif() if(CONFIG_AV1_ENCODER) - set(AOM_EXPORTS_SOURCES ${AOM_EXPORTS_SOURCES} "${AOM_ROOT}/aom/exports_enc" - "${AOM_ROOT}/av1/exports_enc") + list(APPEND AOM_EXPORTS_SOURCES "${AOM_ROOT}/aom/exports_enc" + "${AOM_ROOT}/av1/exports_enc") +endif() + +if(ENABLE_TESTS) + list(APPEND AOM_EXPORTS_SOURCES "${AOM_ROOT}/aom/exports_test" + "${AOM_ROOT}/av1/exports_test") endif() diff --git a/third_party/aom/build/cmake/generate_aom_config_templates.cmake b/third_party/aom/build/cmake/generate_aom_config_templates.cmake index 8fbb4737b..b91c036de 100644 --- a/third_party/aom/build/cmake/generate_aom_config_templates.cmake +++ b/third_party/aom/build/cmake/generate_aom_config_templates.cmake @@ -78,23 +78,24 @@ if(NOT EXISTS "${AOM_DEFAULTS}") endif() include("${AOM_ROOT}/build/cmake/aom_config_defaults.cmake") -get_cmake_property(cmake_cache_vars CACHE_VARIABLES) +list(APPEND aom_build_vars ${AOM_DETECT_VARS} ${AOM_CONFIG_VARS}) +list(SORT aom_build_vars) set(aom_config_h_template "${AOM_CONFIG_DIR}/config/aom_config.h.cmake") file(WRITE "${aom_config_h_template}" ${h_file_header_block}) -foreach(cache_var ${cmake_cache_vars}) - if(NOT "${cache_var}" MATCHES "AOM_CONFIG_DIR\|AOM_ROOT\|^CMAKE_") +foreach(aom_var ${aom_build_vars}) + if(NOT "${aom_var}" STREQUAL "AOM_RTCD_FLAGS") file(APPEND "${aom_config_h_template}" - "\#define ${cache_var} \${${cache_var}}\n") + "\#define ${aom_var} \${${aom_var}}\n") endif() endforeach() -file(APPEND "${aom_config_h_template}" "\#endif /* AOM_CONFIG_H_ */") +file(APPEND "${aom_config_h_template}" "\#endif // AOM_CONFIG_H_") set(aom_asm_config_template "${AOM_CONFIG_DIR}/config/aom_config.asm.cmake") file(WRITE "${aom_asm_config_template}" ${asm_file_header_block}) -foreach(cache_var ${cmake_cache_vars}) - if(NOT "${cache_var}" MATCHES "AOM_CONFIG_DIR\|AOM_ROOT\|^CMAKE_\|INLINE") - file(APPEND "${aom_asm_config_template}" - "${cache_var} equ \${${cache_var}}\n") +foreach(aom_var ${aom_build_vars}) + if(NOT "${aom_var}" STREQUAL "INLINE" AND NOT "${aom_var}" STREQUAL + "AOM_RTCD_FLAGS") + file(APPEND "${aom_asm_config_template}" "${aom_var} equ \${${aom_var}}\n") endif() endforeach() diff --git a/third_party/aom/build/cmake/generate_exports.cmake b/third_party/aom/build/cmake/generate_exports.cmake index 4dce3a671..7ab5aaef8 100644 --- a/third_party/aom/build/cmake/generate_exports.cmake +++ b/third_party/aom/build/cmake/generate_exports.cmake @@ -24,9 +24,7 @@ include("${AOM_ROOT}/build/cmake/exports_sources.cmake") if("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin") set(symbol_prefix "_") elseif("${AOM_TARGET_SYSTEM}" MATCHES "Windows\|MSYS" AND AOM_MSVC) - set(symbol_prefix "_") - file(WRITE "${AOM_SYM_FILE}" "LIBRARY libaom INITINSTANCE TERMINSTANCE\n" - "DATA MULTIPLE NONSHARED\n" "EXPORTS\n") + file(WRITE "${AOM_SYM_FILE}" "LIBRARY aom\n" "EXPORTS\n") else() set(symbol_suffix ";") endif() @@ -35,11 +33,10 @@ set(aom_sym_file "${AOM_SYM_FILE}") if("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin") file(REMOVE "${aom_sym_file}") -elseif("${AOM_TARGET_SYSTEM}" MATCHES "Windows\|MSYS") - file(WRITE "${aom_sym_file}" "LIBRARY libaom INITINSTANCE TERMINSTANCE\n" - "DATA MULTIPLE NONSHARED\n" "EXPORTS\n") +elseif("${AOM_TARGET_SYSTEM}" MATCHES "Windows\|MSYS" AND AOM_MSVC) + file(WRITE "${aom_sym_file}" "LIBRARY aom\n" "EXPORTS\n") else() - file(WRITE "${aom_sym_file}" "{ global:\n") + file(WRITE "${aom_sym_file}" "{\nglobal:\n") endif() foreach(export_file ${AOM_EXPORTS_SOURCES}) @@ -50,11 +47,20 @@ endforeach() foreach(exported_symbol ${exported_symbols}) string(STRIP "${exported_symbol}" exported_symbol) + if("${AOM_TARGET_SYSTEM}" MATCHES "Windows\|MSYS" AND AOM_MSVC) + string(SUBSTRING ${exported_symbol} 0 4 export_type) + string(COMPARE EQUAL "${export_type}" "data" is_data) + if(is_data) + set(symbol_suffix " DATA") + else() + set(symbol_suffix "") + endif() + endif() string(REGEX REPLACE "text \|data " "" "exported_symbol" "${exported_symbol}") - set(exported_symbol "${symbol_prefix}${exported_symbol}${symbol_suffix}") + set(exported_symbol " ${symbol_prefix}${exported_symbol}${symbol_suffix}") file(APPEND "${aom_sym_file}" "${exported_symbol}\n") endforeach() if("${aom_sym_file}" MATCHES "ver$") - file(APPEND "${aom_sym_file}" " };") + file(APPEND "${aom_sym_file}" " \nlocal:\n *;\n};") endif() diff --git a/third_party/aom/build/cmake/ios-Info.plist b/third_party/aom/build/cmake/ios-Info.plist new file mode 100644 index 000000000..300e3e310 --- /dev/null +++ b/third_party/aom/build/cmake/ios-Info.plist @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>en</string> + <key>CFBundleExecutable</key> + <string>AOM</string> + <key>CFBundleIdentifier</key> + <string>org.webmproject.AOM</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>AOM</string> + <key>CFBundlePackageType</key> + <string>FMWK</string> + <key>CFBundleShortVersionString</key> + <string>${VERSION}</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleSupportedPlatforms</key> + <array> + <string>iPhoneOS</string> + </array> + <key>CFBundleVersion</key> + <string>${VERSION}</string> + <key>MinimumOSVersion</key> + <string>${IOS_VERSION_MIN}</string> + <key>UIDeviceFamily</key> + <array> + <integer>1</integer> + <integer>2</integer> + </array> + <key>AOMFullVersion</key> + <string>${FULLVERSION}</string> +</dict> +</plist> diff --git a/third_party/aom/build/cmake/iosbuild.sh b/third_party/aom/build/cmake/iosbuild.sh new file mode 100755 index 000000000..167ece200 --- /dev/null +++ b/third_party/aom/build/cmake/iosbuild.sh @@ -0,0 +1,384 @@ +#!/bin/sh +## Copyright (c) 2016, Alliance for Open Media. All rights reserved +## +## This source code is subject to the terms of the BSD 2 Clause License and +## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License +## was not distributed with this source code in the LICENSE file, you can +## obtain it at www.aomedia.org/license/software. If the Alliance for Open +## Media Patent License 1.0 was not distributed with this source code in the +## PATENTS file, you can obtain it at www.aomedia.org/license/patent. +## +## This script generates 'AOM.framework'. An iOS app can encode and decode AVx +## video by including 'AOM.framework'. +## +## Run iosbuild.sh to create 'AOM.framework' in the current directory. +## +set -e +devnull='> /dev/null 2>&1' + +BUILD_ROOT="_iosbuild" +CONFIGURE_ARGS="--disable-docs + --disable-examples + --disable-libyuv + --disable-unit-tests" +DIST_DIR="_dist" +FRAMEWORK_DIR="AOM.framework" +FRAMEWORK_LIB="AOM.framework/AOM" +HEADER_DIR="${FRAMEWORK_DIR}/Headers/aom" +SCRIPT_DIR=$(dirname "$0") +LIBAOM_SOURCE_DIR=$(cd ${SCRIPT_DIR}/../..; pwd) +LIPO=$(xcrun -sdk iphoneos${SDK} -find lipo) +ORIG_PWD="$(pwd)" +ARM_TARGETS="arm64-darwin-gcc + armv7-darwin-gcc + armv7s-darwin-gcc" +SIM_TARGETS="x86-iphonesimulator-gcc + x86_64-iphonesimulator-gcc" +OSX_TARGETS="x86-darwin16-gcc + x86_64-darwin16-gcc" +TARGETS="${ARM_TARGETS} ${SIM_TARGETS}" + +# Configures for the target specified by $1, and invokes make with the dist +# target using $ as the distribution output directory. +build_target() { + local target="$1" + local old_pwd="$(pwd)" + local target_specific_flags="" + + vlog "***Building target: ${target}***" + + case "${target}" in + x86-*) + target_specific_flags="--enable-pic" + vlog "Enabled PIC for ${target}" + ;; + esac + + mkdir "${target}" + cd "${target}" + # TODO(tomfinegan@google.com): switch to cmake. + eval "${LIBAOM_SOURCE_DIR}/configure" --target="${target}" \ + ${CONFIGURE_ARGS} ${EXTRA_CONFIGURE_ARGS} ${target_specific_flags} \ + ${devnull} + export DIST_DIR + eval make dist ${devnull} + cd "${old_pwd}" + + vlog "***Done building target: ${target}***" +} + +# Returns the preprocessor symbol for the target specified by $1. +target_to_preproc_symbol() { + target="$1" + case "${target}" in + arm64-*) + echo "__aarch64__" + ;; + armv7-*) + echo "__ARM_ARCH_7A__" + ;; + armv7s-*) + echo "__ARM_ARCH_7S__" + ;; + x86-*) + echo "__i386__" + ;; + x86_64-*) + echo "__x86_64__" + ;; + *) + echo "#error ${target} unknown/unsupported" + return 1 + ;; + esac +} + +# Create a aom_config.h shim that, based on preprocessor settings for the +# current target CPU, includes the real aom_config.h for the current target. +# $1 is the list of targets. +create_aom_framework_config_shim() { + local targets="$1" + local config_file="${HEADER_DIR}/aom_config.h" + local preproc_symbol="" + local target="" + local include_guard="AOM_FRAMEWORK_HEADERS_AOM_AOM_CONFIG_H_" + + local file_header="/* + * Copyright (c) $(date +%Y), Alliance for Open Media. All rights reserved. + * + * This source code is subject to the terms of the BSD 2 Clause License and + * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License + * was not distributed with this source code in the LICENSE file, you can + * obtain it at www.aomedia.org/license/software. If the Alliance for Open + * Media Patent License 1.0 was not distributed with this source code in the + * PATENTS file, you can obtain it at www.aomedia.org/license/patent. + */ + +/* GENERATED FILE: DO NOT EDIT! */ + +#ifndef ${include_guard} +#define ${include_guard} + +#if defined" + + printf "%s" "${file_header}" > "${config_file}" + for target in ${targets}; do + preproc_symbol=$(target_to_preproc_symbol "${target}") + printf " ${preproc_symbol}\n" >> "${config_file}" + printf "#define AOM_FRAMEWORK_TARGET \"${target}\"\n" >> "${config_file}" + printf "#include \"AOM/aom/${target}/aom_config.h\"\n" >> "${config_file}" + printf "#elif defined" >> "${config_file}" + mkdir "${HEADER_DIR}/${target}" + cp -p "${BUILD_ROOT}/${target}/aom_config.h" "${HEADER_DIR}/${target}" + done + + # Consume the last line of output from the loop: We don't want it. + sed -i '' -e '$d' "${config_file}" + + printf "#endif\n\n" >> "${config_file}" + printf "#endif // ${include_guard}" >> "${config_file}" +} + +# Verifies that $FRAMEWORK_LIB fat library contains requested builds. +verify_framework_targets() { + local requested_cpus="" + local cpu="" + + # Extract CPU from full target name. + for target; do + cpu="${target%%-*}" + if [ "${cpu}" = "x86" ]; then + # lipo -info outputs i386 for libaom x86 targets. + cpu="i386" + fi + requested_cpus="${requested_cpus}${cpu} " + done + + # Get target CPUs present in framework library. + local targets_built=$(${LIPO} -info ${FRAMEWORK_LIB}) + + # $LIPO -info outputs a string like the following: + # Architectures in the fat file: $FRAMEWORK_LIB <architectures> + # Capture only the architecture strings. + targets_built=${targets_built##*: } + + # Sort CPU strings to make the next step a simple string compare. + local actual=$(echo ${targets_built} | tr " " "\n" | sort | tr "\n" " ") + local requested=$(echo ${requested_cpus} | tr " " "\n" | sort | tr "\n" " ") + + vlog "Requested ${FRAMEWORK_LIB} CPUs: ${requested}" + vlog "Actual ${FRAMEWORK_LIB} CPUs: ${actual}" + + if [ "${requested}" != "${actual}" ]; then + elog "Actual ${FRAMEWORK_LIB} targets do not match requested target list." + elog " Requested target CPUs: ${requested}" + elog " Actual target CPUs: ${actual}" + return 1 + fi +} + +# Configures and builds each target specified by $1, and then builds +# AOM.framework. +build_framework() { + local lib_list="" + local targets="$1" + local target="" + local target_dist_dir="" + + # Clean up from previous build(s). + rm -rf "${BUILD_ROOT}" "${FRAMEWORK_DIR}" + + # Create output dirs. + mkdir -p "${BUILD_ROOT}" + mkdir -p "${HEADER_DIR}" + + cd "${BUILD_ROOT}" + + for target in ${targets}; do + build_target "${target}" + target_dist_dir="${BUILD_ROOT}/${target}/${DIST_DIR}" + if [ "${ENABLE_SHARED}" = "yes" ]; then + local suffix="dylib" + else + local suffix="a" + fi + lib_list="${lib_list} ${target_dist_dir}/lib/libaom.${suffix}" + done + + cd "${ORIG_PWD}" + + # The basic libaom API includes are all the same; just grab the most recent + # set. + cp -p "${target_dist_dir}"/include/aom/* "${HEADER_DIR}" + + # Build the fat library. + ${LIPO} -create ${lib_list} -output ${FRAMEWORK_DIR}/AOM + + # Create the aom_config.h shim that allows usage of aom_config.h from + # within AOM.framework. + create_aom_framework_config_shim "${targets}" + + # Copy in aom_version.h. + cp -p "${BUILD_ROOT}/${target}/aom_version.h" "${HEADER_DIR}" + + if [ "${ENABLE_SHARED}" = "yes" ]; then + # Adjust the dylib's name so dynamic linking in apps works as expected. + install_name_tool -id '@rpath/AOM.framework/AOM' ${FRAMEWORK_DIR}/AOM + + # Copy in Info.plist. + cat "${SCRIPT_DIR}/ios-Info.plist" \ + | sed "s/\${FULLVERSION}/${FULLVERSION}/g" \ + | sed "s/\${VERSION}/${VERSION}/g" \ + | sed "s/\${IOS_VERSION_MIN}/${IOS_VERSION_MIN}/g" \ + > "${FRAMEWORK_DIR}/Info.plist" + fi + + # Confirm AOM.framework/AOM contains the targets requested. + verify_framework_targets ${targets} + + vlog "Created fat library ${FRAMEWORK_LIB} containing:" + for lib in ${lib_list}; do + vlog " $(echo ${lib} | awk -F / '{print $2, $NF}')" + done +} + +# Trap function. Cleans up the subtree used to build all targets contained in +# $TARGETS. +cleanup() { + local res=$? + cd "${ORIG_PWD}" + + if [ $res -ne 0 ]; then + elog "build exited with error ($res)" + fi + + if [ "${PRESERVE_BUILD_OUTPUT}" != "yes" ]; then + rm -rf "${BUILD_ROOT}" + fi +} + +print_list() { + local indent="$1" + shift + local list="$@" + for entry in ${list}; do + echo "${indent}${entry}" + done +} + +iosbuild_usage() { +cat << EOF + Usage: ${0##*/} [arguments] + --help: Display this message and exit. + --enable-shared: Build a dynamic framework for use on iOS 8 or later. + --extra-configure-args <args>: Extra args to pass when configuring libaom. + --macosx: Uses darwin16 targets instead of iphonesimulator targets for x86 + and x86_64. Allows linking to framework when builds target MacOSX + instead of iOS. + --preserve-build-output: Do not delete the build directory. + --show-build-output: Show output from each library build. + --targets <targets>: Override default target list. Defaults: +$(print_list " " ${TARGETS}) + --test-link: Confirms all targets can be linked. Functionally identical to + passing --enable-examples via --extra-configure-args. + --verbose: Output information about the environment and each stage of the + build. +EOF +} + +elog() { + echo "${0##*/} failed because: $@" 1>&2 +} + +vlog() { + if [ "${VERBOSE}" = "yes" ]; then + echo "$@" + fi +} + +trap cleanup EXIT + +# Parse the command line. +while [ -n "$1" ]; do + case "$1" in + --extra-configure-args) + EXTRA_CONFIGURE_ARGS="$2" + shift + ;; + --help) + iosbuild_usage + exit + ;; + --enable-shared) + ENABLE_SHARED=yes + ;; + --preserve-build-output) + PRESERVE_BUILD_OUTPUT=yes + ;; + --show-build-output) + devnull= + ;; + --test-link) + EXTRA_CONFIGURE_ARGS="${EXTRA_CONFIGURE_ARGS} --enable-examples" + ;; + --targets) + TARGETS="$2" + shift + ;; + --macosx) + TARGETS="${ARM_TARGETS} ${OSX_TARGETS}" + ;; + --verbose) + VERBOSE=yes + ;; + *) + iosbuild_usage + exit 1 + ;; + esac + shift +done + +if [ "${ENABLE_SHARED}" = "yes" ]; then + CONFIGURE_ARGS="--enable-shared ${CONFIGURE_ARGS}" +fi + +FULLVERSION=$("${SCRIPT_DIR}"/version.sh --bare "${LIBAOM_SOURCE_DIR}") +VERSION=$(echo "${FULLVERSION}" | sed -E 's/^v([0-9]+\.[0-9]+\.[0-9]+).*$/\1/') + +if [ "$ENABLE_SHARED" = "yes" ]; then + IOS_VERSION_OPTIONS="--enable-shared" + IOS_VERSION_MIN="8.0" +else + IOS_VERSION_OPTIONS="" + IOS_VERSION_MIN="6.0" +fi + +if [ "${VERBOSE}" = "yes" ]; then +cat << EOF + BUILD_ROOT=${BUILD_ROOT} + DIST_DIR=${DIST_DIR} + CONFIGURE_ARGS=${CONFIGURE_ARGS} + EXTRA_CONFIGURE_ARGS=${EXTRA_CONFIGURE_ARGS} + FRAMEWORK_DIR=${FRAMEWORK_DIR} + FRAMEWORK_LIB=${FRAMEWORK_LIB} + HEADER_DIR=${HEADER_DIR} + LIBAOM_SOURCE_DIR=${LIBAOM_SOURCE_DIR} + LIPO=${LIPO} + MAKEFLAGS=${MAKEFLAGS} + ORIG_PWD=${ORIG_PWD} + PRESERVE_BUILD_OUTPUT=${PRESERVE_BUILD_OUTPUT} + TARGETS="$(print_list "" ${TARGETS})" + ENABLE_SHARED=${ENABLE_SHARED} + OSX_TARGETS="${OSX_TARGETS}" + SIM_TARGETS="${SIM_TARGETS}" + SCRIPT_DIR="${SCRIPT_DIR}" + FULLVERSION="${FULLVERSION}" + VERSION="${VERSION}" + IOS_VERSION_MIN="${IOS_VERSION_MIN}" +EOF +fi + +build_framework "${TARGETS}" +echo "Successfully built '${FRAMEWORK_DIR}' for:" +print_list "" ${TARGETS} diff --git a/third_party/aom/build/cmake/rtcd.pl b/third_party/aom/build/cmake/rtcd.pl new file mode 100755 index 000000000..46e06907c --- /dev/null +++ b/third_party/aom/build/cmake/rtcd.pl @@ -0,0 +1,467 @@ +#!/usr/bin/env perl +## +## Copyright (c) 2017, Alliance for Open Media. All rights reserved +## +## This source code is subject to the terms of the BSD 2 Clause License and +## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License +## was not distributed with this source code in the LICENSE file, you can +## obtain it at www.aomedia.org/license/software. If the Alliance for Open +## Media Patent License 1.0 was not distributed with this source code in the +## PATENTS file, you can obtain it at www.aomedia.org/license/patent. +## +no strict 'refs'; +use warnings; +use Getopt::Long; +Getopt::Long::Configure("auto_help") if $Getopt::Long::VERSION > 2.32; + +my %ALL_FUNCS = (); +my @ALL_ARCHS; +my @ALL_FORWARD_DECLS; +my @REQUIRES; + +my %opts = (); +my %disabled = (); +my %required = (); + +my @argv; +foreach (@ARGV) { + $disabled{$1} = 1, next if /--disable-(.*)/; + $required{$1} = 1, next if /--require-(.*)/; + push @argv, $_; +} + +# NB: use GetOptions() instead of GetOptionsFromArray() for compatibility. +@ARGV = @argv; +GetOptions( + \%opts, + 'arch=s', + 'sym=s', + 'config=s', +); + +foreach my $opt (qw/arch config/) { + if (!defined($opts{$opt})) { + warn "--$opt is required!\n"; + Getopt::Long::HelpMessage('-exit' => 1); + } +} + +foreach my $defs_file (@ARGV) { + if (!-f $defs_file) { + warn "$defs_file: $!\n"; + Getopt::Long::HelpMessage('-exit' => 1); + } +} + +open CONFIG_FILE, $opts{config} or + die "Error opening config file '$opts{config}': $!\n"; + +my %config = (); +while (<CONFIG_FILE>) { + next if !/^#define\s+(?:CONFIG_|HAVE_)/; + chomp; + my @line_components = split /\s/; + scalar @line_components > 2 or + die "Invalid input passed to rtcd.pl via $opts{config}."; + # $line_components[0] = #define + # $line_components[1] = flag name (CONFIG_SOMETHING or HAVE_SOMETHING) + # $line_components[2] = flag value (0 or 1) + $config{$line_components[1]} = "$line_components[2]" eq "1" ? "yes" : ""; +} +close CONFIG_FILE; + +# +# Routines for the RTCD DSL to call +# +sub aom_config($) { + return (defined $config{$_[0]}) ? $config{$_[0]} : ""; +} + +sub specialize { + if (@_ <= 1) { + die "'specialize' must be called with a function name and at least one ", + "architecture ('C' is implied): \n@_\n"; + } + my $fn=$_[0]; + shift; + foreach my $opt (@_) { + eval "\$${fn}_${opt}=${fn}_${opt}"; + } +} + +sub add_proto { + my $fn = splice(@_, -2, 1); + $ALL_FUNCS{$fn} = \@_; + specialize $fn, "c"; +} + +sub require { + foreach my $fn (keys %ALL_FUNCS) { + foreach my $opt (@_) { + my $ofn = eval "\$${fn}_${opt}"; + next if !$ofn; + + # if we already have a default, then we can disable it, as we know + # we can do better. + my $best = eval "\$${fn}_default"; + if ($best) { + my $best_ofn = eval "\$${best}"; + if ($best_ofn && "$best_ofn" ne "$ofn") { + eval "\$${best}_link = 'false'"; + } + } + eval "\$${fn}_default=${fn}_${opt}"; + eval "\$${fn}_${opt}_link='true'"; + } + } +} + +sub forward_decls { + push @ALL_FORWARD_DECLS, @_; +} + +# +# Include the user's directives +# +foreach my $f (@ARGV) { + open FILE, "<", $f or die "cannot open $f: $!\n"; + my $contents = join('', <FILE>); + close FILE; + eval $contents or warn "eval failed: $@\n"; +} + +# +# Process the directives according to the command line +# +sub process_forward_decls() { + foreach (@ALL_FORWARD_DECLS) { + $_->(); + } +} + +sub determine_indirection { + aom_config("CONFIG_RUNTIME_CPU_DETECT") eq "yes" or &require(@ALL_ARCHS); + foreach my $fn (keys %ALL_FUNCS) { + my $n = ""; + my @val = @{$ALL_FUNCS{$fn}}; + my $args = pop @val; + my $rtyp = "@val"; + my $dfn = eval "\$${fn}_default"; + $dfn = eval "\$${dfn}"; + foreach my $opt (@_) { + my $ofn = eval "\$${fn}_${opt}"; + next if !$ofn; + my $link = eval "\$${fn}_${opt}_link"; + next if $link && $link eq "false"; + $n .= "x"; + } + if ($n eq "x") { + eval "\$${fn}_indirect = 'false'"; + } else { + eval "\$${fn}_indirect = 'true'"; + } + } +} + +sub declare_function_pointers { + foreach my $fn (sort keys %ALL_FUNCS) { + my @val = @{$ALL_FUNCS{$fn}}; + my $args = pop @val; + my $rtyp = "@val"; + my $dfn = eval "\$${fn}_default"; + $dfn = eval "\$${dfn}"; + foreach my $opt (@_) { + my $ofn = eval "\$${fn}_${opt}"; + next if !$ofn; + print "$rtyp ${ofn}($args);\n"; + } + if (eval "\$${fn}_indirect" eq "false") { + print "#define ${fn} ${dfn}\n"; + } else { + print "RTCD_EXTERN $rtyp (*${fn})($args);\n"; + } + print "\n"; + } +} + +sub set_function_pointers { + foreach my $fn (sort keys %ALL_FUNCS) { + my @val = @{$ALL_FUNCS{$fn}}; + my $args = pop @val; + my $rtyp = "@val"; + my $dfn = eval "\$${fn}_default"; + $dfn = eval "\$${dfn}"; + if (eval "\$${fn}_indirect" eq "true") { + print " $fn = $dfn;\n"; + foreach my $opt (@_) { + my $ofn = eval "\$${fn}_${opt}"; + next if !$ofn; + next if "$ofn" eq "$dfn"; + my $link = eval "\$${fn}_${opt}_link"; + next if $link && $link eq "false"; + my $cond = eval "\$have_${opt}"; + print " if (${cond}) $fn = $ofn;\n" + } + } + } +} + +sub filter { + my @filtered; + foreach (@_) { push @filtered, $_ unless $disabled{$_}; } + return @filtered; +} + +# +# Helper functions for generating the arch specific RTCD files +# +sub common_top() { + my $include_guard = uc($opts{sym})."_H_"; + print <<EOF; +// This file is generated. Do not edit. +#ifndef ${include_guard} +#define ${include_guard} + +#ifdef RTCD_C +#define RTCD_EXTERN +#else +#define RTCD_EXTERN extern +#endif + +EOF + +process_forward_decls(); +print <<EOF; + +#ifdef __cplusplus +extern "C" { +#endif + +EOF +declare_function_pointers("c", @ALL_ARCHS); + +print <<EOF; +void $opts{sym}(void); + +EOF +} + +sub common_bottom() { + print <<EOF; + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif +EOF +} + +sub x86() { + determine_indirection("c", @ALL_ARCHS); + + # Assign the helper variable for each enabled extension + foreach my $opt (@ALL_ARCHS) { + my $opt_uc = uc $opt; + eval "\$have_${opt}=\"flags & HAS_${opt_uc}\""; + } + + common_top; + print <<EOF; +#ifdef RTCD_C +#include "aom_ports/x86.h" +static void setup_rtcd_internal(void) +{ + int flags = x86_simd_caps(); + + (void)flags; + +EOF + + set_function_pointers("c", @ALL_ARCHS); + + print <<EOF; +} +#endif +EOF + common_bottom; +} + +sub arm() { + determine_indirection("c", @ALL_ARCHS); + + # Assign the helper variable for each enabled extension + foreach my $opt (@ALL_ARCHS) { + my $opt_uc = uc $opt; + eval "\$have_${opt}=\"flags & HAS_${opt_uc}\""; + } + + common_top; + print <<EOF; +#include "config/aom_config.h" + +#ifdef RTCD_C +#include "aom_ports/arm.h" +static void setup_rtcd_internal(void) +{ + int flags = aom_arm_cpu_caps(); + + (void)flags; + +EOF + + set_function_pointers("c", @ALL_ARCHS); + + print <<EOF; +} +#endif +EOF + common_bottom; +} + +sub mips() { + determine_indirection("c", @ALL_ARCHS); + + # Assign the helper variable for each enabled extension + foreach my $opt (@ALL_ARCHS) { + my $opt_uc = uc $opt; + eval "\$have_${opt}=\"flags & HAS_${opt_uc}\""; + } + + common_top; + + print <<EOF; +#include "config/aom_config.h" + +#ifdef RTCD_C +static void setup_rtcd_internal(void) +{ +EOF + + set_function_pointers("c", @ALL_ARCHS); + + print <<EOF; +#if HAVE_DSPR2 +void aom_dsputil_static_init(); +aom_dsputil_static_init(); +#endif +} +#endif +EOF + common_bottom; +} + +sub ppc() { + determine_indirection("c", @ALL_ARCHS); + + # Assign the helper variable for each enabled extension + foreach my $opt (@ALL_ARCHS) { + my $opt_uc = uc $opt; + eval "\$have_${opt}=\"flags & HAS_${opt_uc}\""; + } + + common_top; + + print <<EOF; +#include "config/aom_config.h" + +#ifdef RTCD_C +#include "aom_ports/ppc.h" +static void setup_rtcd_internal(void) +{ + int flags = ppc_simd_caps(); + + (void)flags; + +EOF + + set_function_pointers("c", @ALL_ARCHS); + + print <<EOF; +} +#endif +EOF + common_bottom; +} + +sub unoptimized() { + determine_indirection "c"; + common_top; + print <<EOF; +#include "config/aom_config.h" + +#ifdef RTCD_C +static void setup_rtcd_internal(void) +{ +EOF + + set_function_pointers "c"; + + print <<EOF; +} +#endif +EOF + common_bottom; +} + +# +# Main Driver +# + +&require("c"); +&require(keys %required); +if ($opts{arch} eq 'x86') { + @ALL_ARCHS = filter(qw/mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 avx avx2/); + x86; +} elsif ($opts{arch} eq 'x86_64') { + @ALL_ARCHS = filter(qw/mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 avx avx2/); + @REQUIRES = filter(qw/mmx sse sse2/); + &require(@REQUIRES); + x86; +} elsif ($opts{arch} eq 'mips32' || $opts{arch} eq 'mips64') { + @ALL_ARCHS = filter("$opts{arch}"); + if (aom_config("HAVE_DSPR2") eq "yes") { + @ALL_ARCHS = filter("$opts{arch}", qw/dspr2/); + } elsif (aom_config("HAVE_MSA") eq "yes") { + @ALL_ARCHS = filter("$opts{arch}", qw/msa/); + } + mips; +} elsif ($opts{arch} =~ /armv7\w?/) { + @ALL_ARCHS = filter(qw/neon/); + arm; +} elsif ($opts{arch} eq 'armv8' || $opts{arch} eq 'arm64' ) { + @ALL_ARCHS = filter(qw/neon/); + &require("neon"); + arm; +} elsif ($opts{arch} eq 'ppc') { + @ALL_ARCHS = filter(qw/vsx/); + ppc; +} else { + unoptimized; +} + +__END__ + +=head1 NAME + +rtcd - + +=head1 SYNOPSIS + +Usage: rtcd.pl [options] FILE + +See 'perldoc rtcd.pl' for more details. + +=head1 DESCRIPTION + +Reads the Run Time CPU Detections definitions from FILE and generates a +C header file on stdout. + +=head1 OPTIONS + +Options: + --arch=ARCH Architecture to generate defs for (required) + --disable-EXT Disable support for EXT extensions + --require-EXT Require support for EXT extensions + --sym=SYMBOL Unique symbol to use for RTCD initialization function + --config=FILE Path to file containing C preprocessor directives to parse diff --git a/third_party/aom/build/cmake/util.cmake b/third_party/aom/build/cmake/util.cmake index a0c705691..b70ec4013 100644 --- a/third_party/aom/build/cmake/util.cmake +++ b/third_party/aom/build/cmake/util.cmake @@ -13,19 +13,21 @@ if(AOM_BUILD_CMAKE_UTIL_CMAKE_) endif() # AOM_BUILD_CMAKE_UTIL_CMAKE_ set(AOM_BUILD_CMAKE_UTIL_CMAKE_ 1) +# Directory where generated sources will be written. +set(AOM_GEN_SRC_DIR "${AOM_CONFIG_DIR}/gen_src") + # Creates dummy source file in $AOM_CONFIG_DIR named $basename.$extension and # returns the full path to the dummy source file via the $out_file_path # parameter. -function(create_dummy_source_file basename extension out_file_path) - set(dummy_source_file "${AOM_CONFIG_DIR}/${basename}_dummy.${extension}") +macro(create_dummy_source_file basename extension out_file_path) + set(dummy_source_file "${AOM_GEN_SRC_DIR}/${basename}_dummy.${extension}") file( WRITE "${dummy_source_file}" "// Generated file. DO NOT EDIT!\n" "// ${target_name} needs a ${extension} file to force link language, \n" "// or to silence a harmless CMake warning: Ignore me.\n" "void ${target_name}_dummy_function(void) {}\n") - set(${out_file_path} ${dummy_source_file} PARENT_SCOPE) -endfunction() +endmacro() # Convenience function for adding a dummy source file to $target_name using # $extension as the file extension. Wraps create_dummy_source_file(). @@ -86,3 +88,84 @@ function(set_compiler_launcher launcher_flag launcher_name) endif() endfunction() +# Sentinel value used to detect when a variable has been set via the -D argument +# passed to CMake on the command line. +set(cmake_cmdline_helpstring "No help, variable specified on the command line.") + +# Wrapper macro for set() that does some book keeping to help with storage of +# build configuration information. +# +# Sets the default value for variable $name when the value of $name has not +# already been set via the CMake command line. +# +# The names of variables defaulted through this macro are added to +# $AOM_CONFIG_VARS to facilitate build logging and diagnostics. +macro(set_aom_detect_var name value type helpstring) + unset(list_index) + list(FIND AOM_DETECT_VARS ${name} list_index) + if(${list_index} EQUAL -1) + list(APPEND AOM_DETECT_VARS ${name}) + endif() + + # Update the variable only when it does not carry the CMake assigned help + # string for variables specified via the command line. + unset(cache_helpstring) + get_property(cache_helpstring CACHE ${name} PROPERTY HELPSTRING) + if(NOT "${cache_helpstring}" STREQUAL "${cmake_cmdline_helpstring}") + set(${name} ${value} CACHE ${type} "${helpstring}") + mark_as_advanced(${name}) + else() + message( + WARNING + "${name} has been set by CMake, but it may be overridden by the build " + "system during environment detection") + endif() +endmacro() + +# Wrapper macro for set() that does some book keeping to help with storage of +# build configuration information. +# +# Sets the default value for variable $name when the value of $name has not +# already been set via the CMake command line. +# +# The names of variables defaulted through this macro are added to +# $AOM_CONFIG_VARS to facilitate build logging and diagnostics. +macro(set_aom_config_var name value type helpstring) + unset(list_index) + list(FIND AOM_CONFIG_VARS ${name} list_index) + if(${list_index} EQUAL -1) + list(APPEND AOM_CONFIG_VARS ${name}) + endif() + + # Update the variable only when it does not carry the CMake assigned help + # string for variables specified via the command line. + unset(cache_helpstring) + get_property(cache_helpstring CACHE ${name} PROPERTY HELPSTRING) + if(NOT "${cache_helpstring}" STREQUAL "${cmake_cmdline_helpstring}") + set(${name} ${value} CACHE ${type} "${helpstring}") + endif() +endmacro() + +# Wrapper macro for option() that does some book keeping to help with storage of +# build configuration information. +# +# Sets the default value for variable $name when the value of $name has not +# already been set via the CMake command line. +# +# The names of variables defaulted through this macro are added to +# $AOM_OPTION_VARS to facilitate build logging and diagnostics. +macro(set_aom_option_var name helpstring value) + unset(list_index) + list(FIND AOM_OPTION_VARS ${name} list_index) + if(${list_index} EQUAL -1) + list(APPEND AOM_OPTION_VARS ${name}) + endif() + + # Update the variable only when it does not carry the CMake assigned help + # string for variables specified via the command line. + unset(cache_helpstring) + get_property(cache_helpstring CACHE ${name} PROPERTY HELPSTRING) + if(NOT "${cache_helpstring}" STREQUAL "${cmake_cmdline_helpstring}") + option(${name} "${helpstring}" ${value}) + endif() +endmacro() diff --git a/third_party/aom/build/cmake/version.pl b/third_party/aom/build/cmake/version.pl index 7c0608aeb..7d23f2b27 100755 --- a/third_party/aom/build/cmake/version.pl +++ b/third_party/aom/build/cmake/version.pl @@ -14,7 +14,7 @@ use warnings; use 5.010; use Getopt::Long; -my $git_desc; +my $git_desc = ''; my $version_data; my $version_filename; GetOptions('version_data=s' => \$version_data, @@ -68,7 +68,7 @@ if (length($git_desc) > 0) { open(my $version_file, '>', $version_filename) or die("Cannot open $version_filename: $!"); -my $version_packed = "((VERSION_MAJOR<<16)|(VERSION_MINOR<<8)|(VERSION_PATCH))"; +my $version_packed = "((VERSION_MAJOR << 16) | (VERSION_MINOR << 8) | (VERSION_PATCH))"; my $year = (localtime)[5] + 1900; my $lic_block = << "EOF"; /* @@ -91,7 +91,8 @@ $lic_block #define VERSION_MINOR $version_minor #define VERSION_PATCH $version_patch #define VERSION_EXTRA \"$version_extra\" -#define VERSION_PACKED $version_packed +#define VERSION_PACKED \\ + $version_packed #define VERSION_STRING_NOSP \"$git_desc\" #define VERSION_STRING \" $git_desc\" EOF @@ -102,7 +103,8 @@ $lic_block #define VERSION_MINOR $version_minor #define VERSION_PATCH $version_patch #define VERSION_EXTRA \"$version_extra\" -#define VERSION_PACKED $version_packed +#define VERSION_PACKED \\ + $version_packed #define VERSION_STRING_NOSP \"v$version_string\" #define VERSION_STRING \" v$version_string\" EOF |