diff --git a/media/libaom/generate_sources_mozbuild.py b/media/libaom/generate_sources_mozbuild.py index 8c25ef0a790b..337660234d12 100755 --- a/media/libaom/generate_sources_mozbuild.py +++ b/media/libaom/generate_sources_mozbuild.py @@ -24,13 +24,6 @@ def write_aom_config(system, arch, variables, cache_variables): # inherit this from the mozilla build config cache_variables.remove('HAVE_PTHREAD_H') - if arch == 'arm64': - print("Please ensure the generated arm64 rtcd headers follow the feature settings here") - # The features below are copied from the "ARM64_FLAVORS" in AOM_DIR/build/cmake/cpu.cmake. - arm64_flavors = ["NEON", "ARM_CRC32", "NEON_DOTPROD", "NEON_I8MM", "SVE", "SVE2"] - for flavor in arm64_flavors: - print("ENABLE_{}: {}, HAVE_{}: {}".format(flavor, variables['ENABLE_' + flavor], flavor, variables['HAVE_' + flavor])) - outdir = os.path.join('config', system, arch, 'config') try: os.makedirs(outdir) diff --git a/media/libaom/generate_sources_mozbuild.sh b/media/libaom/generate_sources_mozbuild.sh index 8ece4b1ec773..22c6531413c1 100755 --- a/media/libaom/generate_sources_mozbuild.sh +++ b/media/libaom/generate_sources_mozbuild.sh @@ -56,6 +56,41 @@ function gen_rtcd_header { > $BASE_DIR/$LIBAOM_CONFIG_DIR/$1/config/aom_dsp_rtcd.h } +# Generate arm64 optional arguments for *_rtcd.h files. +# $1 - Header file directory. +function gen_arm64_optional_args { + local file="$BASE_DIR/$LIBAOM_CONFIG_DIR/$1/config/aom_config.h" + + # The features below are copied from the "ARM64_FLAVORS" in + # AOM_DIR/build/cmake/cpu.cmake. + local arm64_flavors=( + "NEON" + "ARM_CRC32" + "NEON_DOTPROD" + "NEON_I8MM" + "SVE" + "SVE2" + ) + + local config="" + local opt="" + local args="" + while read -r line; do + for f in "${arm64_flavors[@]}"; do + config="HAVE_$f " + if [[ $line == *"$config"* ]]; then + enabled=${line//*$config} + if [[ $enabled -eq 0 ]]; then + opt=$(echo $f | tr '[:upper:]' '[:lower:]') + args=$(echo $args; echo "--disable-$opt") + fi + fi + done + done < $file + + echo $args +} + echo "Generating config files." python3 -m venv temp . temp/bin/activate @@ -75,8 +110,7 @@ gen_rtcd_header win/ia32 x86 gen_rtcd_header linux/arm armv7 -# TODO: Parse feature settings from the generated aom_config.h -gen_rtcd_header mac/arm64 arm64 "--disable-sve --disable-sve2" +gen_rtcd_header mac/arm64 arm64 "$(gen_arm64_optional_args mac/arm64)" gen_rtcd_header generic generic