Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/bin/bash -e | 1 #!/bin/bash -e |
| 2 # | 2 # |
| 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 # This script is used to generate .gypi files needed to build libvpx. | 7 # This script is used to generate .gypi files and files in the config/platform |
| 8 # directories needed to build libvpx. | |
| 8 # Every time libvpx source code is updated just run this script. | 9 # Every time libvpx source code is updated just run this script. |
| 9 # | 10 # |
| 10 # For example: | 11 # For example: |
| 11 # $ ./generate_gypi.sh | 12 # $ ./generate_gypi.sh |
| 12 # | 13 # |
| 13 # And this will update all the .gypi files needed. | 14 # And this will update all the .gypi and config files needed. |
| 14 # | |
| 15 # Configuration for building on each platform is taken from the | |
| 16 # corresponding vpx_config.h | |
| 17 # | 15 # |
| 18 | 16 |
| 19 BASE_DIR=`pwd` | 17 BASE_DIR=`pwd` |
| 20 LIBVPX_SRC_DIR="source/libvpx" | 18 LIBVPX_SRC_DIR="source/libvpx" |
| 21 LIBVPX_CONFIG_DIR="source/config" | 19 LIBVPX_CONFIG_DIR="source/config" |
| 22 | 20 |
| 23 # Convert a list of source files into gypi file. | 21 # Convert a list of source files into gypi file. |
| 24 # $1 - Input file. | 22 # $1 - Input file. |
| 25 # $2 - Output gypi file. | 23 # $2 - Output gypi file. |
| 26 function convert_srcs_to_gypi { | 24 function convert_srcs_to_gypi { |
| 27 # Do the following here: | 25 # Do the following here: |
| 28 # 1. Filter .c, .h, .s, .S and .asm files. | 26 # 1. Filter .c, .h, .s, .S and .asm files. |
| 29 # 2. Exclude *_offsets.c. | 27 # 2. Exclude certain files. If you want to add more files to exclude from |
| 30 # 3. Exclude vpx_config.c. | 28 # the .gypi add a new -v option. I.e. grep -v '_offsets\.c' or grep -v |
| 31 # 4. Repelace .asm.s to .asm because gyp will do the conversion. | 29 # 'vp9_filter_sse4\.c' |
| 32 local source_list=`grep -E '(\.c|\.h|\.S|\.s|\.asm)$' $1 | grep -v '_offsets\. c' | grep -v 'vpx_config\.c' | sed s/\.asm\.s$/.asm/` | 30 # 3. Replace .asm.s to .asm because gyp will do the conversion. |
| 31 local source_list=`grep -E '(\.c|\.h|\.S|\.s|\.asm)$' $1 | \ | |
| 32 grep -v '_offsets\.c' | \ | |
|
Alpha Left Google
2012/12/12 21:52:56
This is hard to read, can you break it into multip
fgalligan1
2012/12/13 00:07:54
Done.
| |
| 33 grep -v 'vpx_config\.c' | \ | |
| 34 grep -v 'denoising_sse2\.c' | \ | |
| 35 grep -v 'vp9_filter_sse2\.c' | \ | |
| 36 grep -v 'vp9_loopfilter_x86\.c' | \ | |
| 37 grep -v 'vp9_sadmxn_x86\.c' | \ | |
| 38 grep -v 'vp9_filter_sse4\.c' | \ | |
| 39 sed s/\.asm\.s$/.asm/` | |
| 33 | 40 |
| 34 # Build the gypi file. | 41 # Build the gypi file. |
| 35 echo "# This file is generated. Do not edit." > $2 | 42 echo "# This file is generated. Do not edit." > $2 |
| 36 echo "# Copyright (c) 2012 The Chromium Authors. All rights reserved." >> $2 | 43 echo "# Copyright (c) 2012 The Chromium Authors. All rights reserved." >> $2 |
| 37 echo "# Use of this source code is governed by a BSD-style license that can be " >> $2 | 44 echo "# Use of this source code is governed by a BSD-style license that can be " >> $2 |
| 38 echo "# found in the LICENSE file." >> $2 | 45 echo "# found in the LICENSE file." >> $2 |
| 39 echo "" >> $2 | 46 echo "" >> $2 |
| 40 echo "{" >> $2 | 47 echo "{" >> $2 |
| 41 echo " 'sources': [" >> $2 | 48 echo " 'sources': [" >> $2 |
| 42 for f in $source_list | 49 for f in $source_list |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 combined_config="$(cat $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.h \ | 84 combined_config="$(cat $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.h \ |
| 78 | grep -E ' +[01] *$')" | 85 | grep -E ' +[01] *$')" |
| 79 combined_config="$(echo "$combined_config" | grep -v DO1STROUNDING)" | 86 combined_config="$(echo "$combined_config" | grep -v DO1STROUNDING)" |
| 80 combined_config="$(echo "$combined_config" | sed 's/[ \t]//g')" | 87 combined_config="$(echo "$combined_config" | sed 's/[ \t]//g')" |
| 81 combined_config="$(echo "$combined_config" | sed 's/.*define//')" | 88 combined_config="$(echo "$combined_config" | sed 's/.*define//')" |
| 82 combined_config="$(echo "$combined_config" | sed 's/0$/=no/')" | 89 combined_config="$(echo "$combined_config" | sed 's/0$/=no/')" |
| 83 combined_config="$(echo "$combined_config" | sed 's/1$/=yes/')" | 90 combined_config="$(echo "$combined_config" | sed 's/1$/=yes/')" |
| 84 echo "$combined_config" | sort | uniq | 91 echo "$combined_config" | sort | uniq |
| 85 } | 92 } |
| 86 | 93 |
| 87 # Generate vpx_rtcd.h. | 94 # Generate *_rtcd.h files. |
| 88 # $1 - Header file directory. | 95 # $1 - Header file directory. |
| 89 # $2 - Architecture. | 96 # $2 - Architecture. |
| 90 function gen_rtcd_header { | 97 function gen_rtcd_header { |
| 91 echo "Generate $LIBVPX_CONFIG_DIR/$1/vpx_rtcd.h." | 98 echo "Generate $LIBVPX_CONFIG_DIR/$1/*_rtcd.h files." |
| 92 | 99 |
| 93 rm -rf $BASE_DIR/$TEMP_DIR/libvpx.config | 100 rm -rf $BASE_DIR/$TEMP_DIR/libvpx.config |
| 94 if [ "$2" = "mipsel" ]; then | 101 if [ "$2" = "mipsel" ]; then |
| 95 print_config_basic $1 > $BASE_DIR/$TEMP_DIR/libvpx.config | 102 print_config_basic $1 > $BASE_DIR/$TEMP_DIR/libvpx.config |
| 96 else | 103 else |
| 97 $BASE_DIR/lint_config.sh -p \ | 104 $BASE_DIR/lint_config.sh -p \ |
| 98 -h $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.h \ | 105 -h $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.h \ |
| 99 -a $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.asm \ | 106 -a $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.asm \ |
| 100 -o $BASE_DIR/$TEMP_DIR/libvpx.config | 107 -o $BASE_DIR/$TEMP_DIR/libvpx.config |
| 101 fi | 108 fi |
| 102 | 109 |
| 103 $BASE_DIR/$LIBVPX_SRC_DIR/build/make/rtcd.sh \ | 110 $BASE_DIR/$LIBVPX_SRC_DIR/build/make/rtcd.sh \ |
| 104 --arch=$2 \ | 111 --arch=$2 \ |
| 105 --sym=vpx_rtcd \ | 112 --sym=vp8_rtcd \ |
| 106 --config=$BASE_DIR/$TEMP_DIR/libvpx.config \ | 113 --config=$BASE_DIR/$TEMP_DIR/libvpx.config \ |
| 107 $BASE_DIR/$LIBVPX_SRC_DIR/vp8/common/rtcd_defs.sh \ | 114 $BASE_DIR/$LIBVPX_SRC_DIR/vp8/common/rtcd_defs.sh \ |
| 108 > $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_rtcd.h | 115 > $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vp8_rtcd.h |
| 116 | |
| 117 $BASE_DIR/$LIBVPX_SRC_DIR/build/make/rtcd.sh \ | |
| 118 --arch=$2 \ | |
| 119 --sym=vp9_rtcd \ | |
| 120 --config=$BASE_DIR/$TEMP_DIR/libvpx.config \ | |
| 121 $BASE_DIR/$LIBVPX_SRC_DIR/vp9/common/vp9_rtcd_defs.sh \ | |
| 122 > $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vp9_rtcd.h | |
| 123 | |
| 124 $BASE_DIR/$LIBVPX_SRC_DIR/build/make/rtcd.sh \ | |
| 125 --arch=$2 \ | |
| 126 --sym=vpx_scale_rtcd \ | |
| 127 --config=$BASE_DIR/$TEMP_DIR/libvpx.config \ | |
| 128 $BASE_DIR/$LIBVPX_SRC_DIR/vpx_scale/vpx_scale_rtcd.sh \ | |
| 129 > $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_scale_rtcd.h | |
| 109 | 130 |
| 110 rm -rf $BASE_DIR/$TEMP_DIR/libvpx.config | 131 rm -rf $BASE_DIR/$TEMP_DIR/libvpx.config |
| 111 } | 132 } |
| 112 | 133 |
| 134 # Generate Config files. "--enable-external-build" must be set to skip | |
| 135 # detection of capabilities on specific targets. | |
| 136 # $1 - Header file directory. | |
| 137 # $2 - Config command line. | |
| 138 function gen_config_files { | |
| 139 ./configure $2 > /dev/null | |
| 140 | |
| 141 # Generate vpx_config.asm. Do not create one for mips. | |
| 142 if [ "$1" -ne "mipsel" ]; then | |
| 143 if [[ "$1" == *x64* ]] || [[ "$1" == *ia32* ]]; then | |
| 144 egrep "#define [A-Z0-9_]+ [01]" vpx_config.h | awk '{print $2 " equ " $3}' > vpx_config.asm | |
| 145 else | |
| 146 egrep "#define [A-Z0-9_]+ [01]" vpx_config.h | awk '{print $2 " EQU " $3}' | perl $BASE_DIR/$LIBVPX_SRC_DIR/build/make/ads2gas.pl > vpx_config.asm | |
| 147 fi | |
| 148 fi | |
| 149 | |
| 150 cp vpx_config.* $BASE_DIR/$LIBVPX_CONFIG_DIR/$1 | |
| 151 make_clean | |
| 152 rm -rf vpx_config.* | |
| 153 } | |
| 154 | |
| 155 all_platforms="--enable-external-build --enable-postproc --disable-install-srcs --enable-multi-res-encoding --enable-temporal-denoising --disable-vp9-encoder -- disable-unit-tests --disable-install-docs --disable-examples" | |
|
Alpha Left Google
2012/12/12 21:52:56
Move this close to echo "Generate Config Files".
fgalligan1
2012/12/13 00:07:54
Done.
| |
| 156 | |
| 157 echo "Create temporary directory." | |
| 158 TEMP_DIR="$LIBVPX_SRC_DIR.temp" | |
| 159 rm -rf $TEMP_DIR | |
| 160 cp -R $LIBVPX_SRC_DIR $TEMP_DIR | |
| 161 cd $TEMP_DIR | |
| 162 | |
| 163 # TODO(fgalligan): Is "--disable-fast-unaligned" needed on mipsel? | |
|
Alpha Left Google
2012/12/12 21:52:56
Move this down to the bottom.
fgalligan1
2012/12/13 00:07:54
Done.
| |
| 164 # TODO(fgalligan): Can we turn on "--enable-realtime-only" for mipsel? | |
| 165 echo "Generate Config Files" | |
| 166 gen_config_files linux/ia32 "--target=x86-linux-gcc --disable-ccache --enable-pi c --enable-realtime-only ${all_platforms}" | |
| 167 gen_config_files linux/x64 "--target=x86_64-linux-gcc --disable-ccache --enable- pic --enable-realtime-only ${all_platforms}" | |
| 168 gen_config_files linux/arm "--target=armv6-linux-gcc --enable-pic --enable-realt ime-only --disable-install-bins --disable-install-libs ${all_platforms}" | |
| 169 gen_config_files linux/arm-neon "--target=armv7-linux-gcc --enable-pic --enable- realtime-only ${all_platforms}" | |
| 170 gen_config_files linux/mipsel "--target=mips32-linux-gcc --disable-fast-unaligne d ${all_platforms}" | |
|
Alpha Left Google
2012/12/12 21:52:56
Move mipsel and comments down to the bottom. MIPS
fgalligan1
2012/12/13 00:07:54
I didn't move because then I would need to create
| |
| 171 gen_config_files win/ia32 "--target=x86-win32-vs7 --enable-realtime-only ${all_p latforms}" | |
| 172 gen_config_files mac/ia32 "--target=x86-darwin9-gcc --enable-pic --enable-realti me-only ${all_platforms}" | |
| 173 gen_config_files mac/x64 "--target=x86_64-darwin9-gcc --enable-pic --enable-real time-only ${all_platforms}" | |
| 174 | |
| 175 echo "Remove temporary directory." | |
| 176 cd $BASE_DIR | |
| 177 rm -rf $TEMP_DIR | |
| 178 | |
| 113 echo "Lint libvpx configuration." | 179 echo "Lint libvpx configuration." |
| 114 lint_config linux/ia32 | 180 lint_config linux/ia32 |
| 115 lint_config linux/x64 | 181 lint_config linux/x64 |
| 116 lint_config linux/arm | 182 lint_config linux/arm |
| 117 lint_config linux/arm-neon | 183 lint_config linux/arm-neon |
| 118 lint_config win/ia32 | 184 lint_config win/ia32 |
| 119 lint_config mac/ia32 | 185 lint_config mac/ia32 |
| 120 lint_config mac/x64 | 186 lint_config mac/x64 |
| 121 | 187 |
| 122 echo "Create temporary directory." | 188 echo "Create temporary directory." |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 137 echo "Prepare Makefile." | 203 echo "Prepare Makefile." |
| 138 ./configure --target=generic-gnu > /dev/null | 204 ./configure --target=generic-gnu > /dev/null |
| 139 make_clean | 205 make_clean |
| 140 | 206 |
| 141 echo "Generate X86 source list." | 207 echo "Generate X86 source list." |
| 142 config=$(print_config linux/ia32) | 208 config=$(print_config linux/ia32) |
| 143 make_clean | 209 make_clean |
| 144 make libvpx_srcs.txt target=libs $config > /dev/null | 210 make libvpx_srcs.txt target=libs $config > /dev/null |
| 145 convert_srcs_to_gypi libvpx_srcs.txt $BASE_DIR/libvpx_srcs_x86.gypi | 211 convert_srcs_to_gypi libvpx_srcs.txt $BASE_DIR/libvpx_srcs_x86.gypi |
| 146 | 212 |
| 213 # Copy vpx_version.h. The file should be the same for all platforms. | |
| 214 cp vpx_version.h $BASE_DIR/$LIBVPX_CONFIG_DIR | |
| 215 | |
| 147 echo "Generate X86_64 source list." | 216 echo "Generate X86_64 source list." |
| 148 config=$(print_config linux/x64) | 217 config=$(print_config linux/x64) |
| 149 make_clean | 218 make_clean |
| 150 make libvpx_srcs.txt target=libs $config > /dev/null | 219 make libvpx_srcs.txt target=libs $config > /dev/null |
| 151 convert_srcs_to_gypi libvpx_srcs.txt $BASE_DIR/libvpx_srcs_x86_64.gypi | 220 convert_srcs_to_gypi libvpx_srcs.txt $BASE_DIR/libvpx_srcs_x86_64.gypi |
| 152 | 221 |
| 153 echo "Generate ARM source list." | 222 echo "Generate ARM source list." |
| 154 config=$(print_config linux/arm) | 223 config=$(print_config linux/arm) |
| 155 make_clean | 224 make_clean |
| 156 make libvpx_srcs.txt target=libs $config > /dev/null | 225 make libvpx_srcs.txt target=libs $config > /dev/null |
| 157 convert_srcs_to_gypi libvpx_srcs.txt $BASE_DIR/libvpx_srcs_arm.gypi | 226 convert_srcs_to_gypi libvpx_srcs.txt $BASE_DIR/libvpx_srcs_arm.gypi |
| 158 | 227 |
| 159 echo "Generate ARM NEON source list." | 228 echo "Generate ARM NEON source list." |
| 160 config=$(print_config linux/arm-neon) | 229 config=$(print_config linux/arm-neon) |
| 161 make_clean | 230 make_clean |
| 162 make libvpx_srcs.txt target=libs $config > /dev/null | 231 make libvpx_srcs.txt target=libs $config > /dev/null |
| 163 convert_srcs_to_gypi libvpx_srcs.txt $BASE_DIR/libvpx_srcs_arm_neon.gypi | 232 convert_srcs_to_gypi libvpx_srcs.txt $BASE_DIR/libvpx_srcs_arm_neon.gypi |
| 164 | 233 |
| 165 echo "Generate MIPS source list." | 234 echo "Generate MIPS source list." |
| 166 config=$(print_config_basic linux/mipsel) | 235 config=$(print_config_basic linux/mipsel) |
| 167 make_clean | 236 make_clean |
| 168 make libvpx_srcs.txt target=libs $config > /dev/null | 237 make libvpx_srcs.txt target=libs $config > /dev/null |
| 169 convert_srcs_to_gypi libvpx_srcs.txt $BASE_DIR/libvpx_srcs_mips.gypi | 238 convert_srcs_to_gypi libvpx_srcs.txt $BASE_DIR/libvpx_srcs_mips.gypi |
| 170 | 239 |
| 171 echo "Remove temporary directory." | 240 echo "Remove temporary directory." |
| 172 cd $BASE_DIR | 241 cd $BASE_DIR |
| 173 rm -rf $TEMP_DIR | 242 rm -rf $TEMP_DIR |
| OLD | NEW |