generate_sources_mozbuild.sh (3248B)
1 #!/bin/bash -e 2 # 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 4 # Use of this source code is governed by a BSD-style license that can be 5 # found in the LICENSE file. 6 7 # Modified from chromium/src/third_party/libaom/generate_gni.sh 8 9 # This script is used to generate sources.mozbuild and files in the 10 # config/platform directories needed to build libaom. 11 # Every time libaom source code is updated just run this script. 12 # 13 # Usage: 14 # $ ./generate_sources_mozbuild.sh 15 16 set -xe 17 18 export LC_ALL=C 19 BASE_DIR=$(pwd) 20 ROOT_DIR="../.." 21 LIBAOM_SRC_DIR="$ROOT_DIR/third_party/aom" 22 LIBAOM_CONFIG_DIR="config" 23 24 # Print license header. 25 # $1 - Output base name 26 function write_license { 27 echo "# This file is generated. Do not edit." >> $1 28 echo "" >> $1 29 } 30 31 # Generate *_rtcd.h files. 32 # $1 - Header file directory. 33 # $2 - Architecture. 34 # $3 - Optional - any additional arguments to pass through. 35 function gen_rtcd_header { 36 echo "Generate $LIBAOM_CONFIG_DIR/$1/*_rtcd.h files." 37 38 AOM_CONFIG=$BASE_DIR/$LIBAOM_CONFIG_DIR/$1/config/aom_config.h 39 40 $BASE_DIR/$LIBAOM_SRC_DIR/build/cmake/rtcd.pl \ 41 --arch=$2 \ 42 --sym=av1_rtcd $3 \ 43 --config=$AOM_CONFIG \ 44 $BASE_DIR/$LIBAOM_SRC_DIR/av1/common/av1_rtcd_defs.pl \ 45 > $BASE_DIR/$LIBAOM_CONFIG_DIR/$1/config/av1_rtcd.h 46 47 $BASE_DIR/$LIBAOM_SRC_DIR/build/cmake/rtcd.pl \ 48 --arch=$2 \ 49 --sym=aom_scale_rtcd $3 \ 50 --config=$AOM_CONFIG \ 51 $BASE_DIR/$LIBAOM_SRC_DIR/aom_scale/aom_scale_rtcd.pl \ 52 > $BASE_DIR/$LIBAOM_CONFIG_DIR/$1/config/aom_scale_rtcd.h 53 54 $BASE_DIR/$LIBAOM_SRC_DIR/build/cmake/rtcd.pl \ 55 --arch=$2 \ 56 --sym=aom_dsp_rtcd $3 \ 57 --config=$AOM_CONFIG \ 58 $BASE_DIR/$LIBAOM_SRC_DIR/aom_dsp/aom_dsp_rtcd_defs.pl \ 59 > $BASE_DIR/$LIBAOM_CONFIG_DIR/$1/config/aom_dsp_rtcd.h 60 } 61 62 # Generate arm64 optional arguments for *_rtcd.h files. 63 # $1 - Header file directory. 64 function gen_arm64_optional_args { 65 local file="$BASE_DIR/$LIBAOM_CONFIG_DIR/$1/config/aom_config.h" 66 67 # The features below are copied from the "ARM64_FLAVORS" in 68 # AOM_DIR/build/cmake/cpu.cmake. 69 local arm64_flavors=( 70 "NEON" 71 "ARM_CRC32" 72 "NEON_DOTPROD" 73 "NEON_I8MM" 74 "SVE" 75 "SVE2" 76 ) 77 78 local config="" 79 local opt="" 80 local args="" 81 while read -r line; do 82 for f in "${arm64_flavors[@]}"; do 83 config="HAVE_$f " 84 if [[ $line == *"$config"* ]]; then 85 enabled=${line//*$config} 86 if [[ $enabled -eq 0 ]]; then 87 opt=$(echo $f | tr '[:upper:]' '[:lower:]') 88 args=$(echo $args; echo "--disable-$opt") 89 fi 90 fi 91 done 92 done < $file 93 94 echo $args 95 } 96 97 echo "Generating config files." 98 python3 -m venv temp 99 . temp/bin/activate 100 pip install -e $ROOT_DIR/python/mozcmakeparser 101 python3 generate_sources_mozbuild.py 102 deactivate 103 rm -r temp 104 105 # Copy aom_version.h once. The file is the same for all platforms. 106 cp aom_version.h $BASE_DIR/$LIBAOM_CONFIG_DIR 107 108 gen_rtcd_header linux/x64 x86_64 109 gen_rtcd_header linux/ia32 x86 110 gen_rtcd_header mac/x64 x86_64 111 gen_rtcd_header win/x64 x86_64 112 gen_rtcd_header win/ia32 x86 113 114 gen_rtcd_header linux/arm armv7 115 116 gen_rtcd_header mac/arm64 arm64 "$(gen_arm64_optional_args mac/arm64)" 117 118 gen_rtcd_header generic generic 119 120 cd $BASE_DIR/$LIBAOM_SRC_DIR 121 122 cd $BASE_DIR