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 source_list=$(echo "$source_list" | grep -v '_offsets\.c') |
| 33 source_list=$(echo "$source_list" | grep -v 'vpx_config\.c') |
| 34 source_list=$(echo "$source_list" | grep -v 'denoising_sse2\.c') |
| 35 source_list=$(echo "$source_list" | grep -v 'vp9_filter_sse2\.c') |
| 36 source_list=$(echo "$source_list" | grep -v 'vp9_loopfilter_x86\.c') |
| 37 source_list=$(echo "$source_list" | grep -v 'vp9_sadmxn_x86\.c') |
| 38 source_list=$(echo "$source_list" | grep -v 'vp9_filter_sse4\.c') |
| 39 source_list=$(echo "$source_list" | 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 echo "Create temporary directory." |
| 156 TEMP_DIR="$LIBVPX_SRC_DIR.temp" |
| 157 rm -rf $TEMP_DIR |
| 158 cp -R $LIBVPX_SRC_DIR $TEMP_DIR |
| 159 cd $TEMP_DIR |
| 160 |
| 161 echo "Generate Config Files" |
| 162 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" |
| 163 gen_config_files linux/ia32 "--target=x86-linux-gcc --disable-ccache --enable-pi
c --enable-realtime-only ${all_platforms}" |
| 164 gen_config_files linux/x64 "--target=x86_64-linux-gcc --disable-ccache --enable-
pic --enable-realtime-only ${all_platforms}" |
| 165 gen_config_files linux/arm "--target=armv6-linux-gcc --enable-pic --enable-realt
ime-only --disable-install-bins --disable-install-libs ${all_platforms}" |
| 166 gen_config_files linux/arm-neon "--target=armv7-linux-gcc --enable-pic --enable-
realtime-only ${all_platforms}" |
| 167 gen_config_files linux/mipsel "--target=mips32-linux-gcc --disable-fast-unaligne
d ${all_platforms}" |
| 168 gen_config_files win/ia32 "--target=x86-win32-vs7 --enable-realtime-only ${all_p
latforms}" |
| 169 gen_config_files mac/ia32 "--target=x86-darwin9-gcc --enable-pic --enable-realti
me-only ${all_platforms}" |
| 170 gen_config_files mac/x64 "--target=x86_64-darwin9-gcc --enable-pic --enable-real
time-only ${all_platforms}" |
| 171 |
| 172 echo "Remove temporary directory." |
| 173 cd $BASE_DIR |
| 174 rm -rf $TEMP_DIR |
| 175 |
113 echo "Lint libvpx configuration." | 176 echo "Lint libvpx configuration." |
114 lint_config linux/ia32 | 177 lint_config linux/ia32 |
115 lint_config linux/x64 | 178 lint_config linux/x64 |
116 lint_config linux/arm | 179 lint_config linux/arm |
117 lint_config linux/arm-neon | 180 lint_config linux/arm-neon |
118 lint_config win/ia32 | 181 lint_config win/ia32 |
119 lint_config mac/ia32 | 182 lint_config mac/ia32 |
120 lint_config mac/x64 | 183 lint_config mac/x64 |
121 | 184 |
122 echo "Create temporary directory." | 185 echo "Create temporary directory." |
(...skipping 14 matching lines...) Expand all Loading... |
137 echo "Prepare Makefile." | 200 echo "Prepare Makefile." |
138 ./configure --target=generic-gnu > /dev/null | 201 ./configure --target=generic-gnu > /dev/null |
139 make_clean | 202 make_clean |
140 | 203 |
141 echo "Generate X86 source list." | 204 echo "Generate X86 source list." |
142 config=$(print_config linux/ia32) | 205 config=$(print_config linux/ia32) |
143 make_clean | 206 make_clean |
144 make libvpx_srcs.txt target=libs $config > /dev/null | 207 make libvpx_srcs.txt target=libs $config > /dev/null |
145 convert_srcs_to_gypi libvpx_srcs.txt $BASE_DIR/libvpx_srcs_x86.gypi | 208 convert_srcs_to_gypi libvpx_srcs.txt $BASE_DIR/libvpx_srcs_x86.gypi |
146 | 209 |
| 210 # Copy vpx_version.h. The file should be the same for all platforms. |
| 211 cp vpx_version.h $BASE_DIR/$LIBVPX_CONFIG_DIR |
| 212 |
147 echo "Generate X86_64 source list." | 213 echo "Generate X86_64 source list." |
148 config=$(print_config linux/x64) | 214 config=$(print_config linux/x64) |
149 make_clean | 215 make_clean |
150 make libvpx_srcs.txt target=libs $config > /dev/null | 216 make libvpx_srcs.txt target=libs $config > /dev/null |
151 convert_srcs_to_gypi libvpx_srcs.txt $BASE_DIR/libvpx_srcs_x86_64.gypi | 217 convert_srcs_to_gypi libvpx_srcs.txt $BASE_DIR/libvpx_srcs_x86_64.gypi |
152 | 218 |
153 echo "Generate ARM source list." | 219 echo "Generate ARM source list." |
154 config=$(print_config linux/arm) | 220 config=$(print_config linux/arm) |
155 make_clean | 221 make_clean |
156 make libvpx_srcs.txt target=libs $config > /dev/null | 222 make libvpx_srcs.txt target=libs $config > /dev/null |
157 convert_srcs_to_gypi libvpx_srcs.txt $BASE_DIR/libvpx_srcs_arm.gypi | 223 convert_srcs_to_gypi libvpx_srcs.txt $BASE_DIR/libvpx_srcs_arm.gypi |
158 | 224 |
159 echo "Generate ARM NEON source list." | 225 echo "Generate ARM NEON source list." |
160 config=$(print_config linux/arm-neon) | 226 config=$(print_config linux/arm-neon) |
161 make_clean | 227 make_clean |
162 make libvpx_srcs.txt target=libs $config > /dev/null | 228 make libvpx_srcs.txt target=libs $config > /dev/null |
163 convert_srcs_to_gypi libvpx_srcs.txt $BASE_DIR/libvpx_srcs_arm_neon.gypi | 229 convert_srcs_to_gypi libvpx_srcs.txt $BASE_DIR/libvpx_srcs_arm_neon.gypi |
164 | 230 |
165 echo "Generate MIPS source list." | 231 echo "Generate MIPS source list." |
166 config=$(print_config_basic linux/mipsel) | 232 config=$(print_config_basic linux/mipsel) |
167 make_clean | 233 make_clean |
168 make libvpx_srcs.txt target=libs $config > /dev/null | 234 make libvpx_srcs.txt target=libs $config > /dev/null |
169 convert_srcs_to_gypi libvpx_srcs.txt $BASE_DIR/libvpx_srcs_mips.gypi | 235 convert_srcs_to_gypi libvpx_srcs.txt $BASE_DIR/libvpx_srcs_mips.gypi |
170 | 236 |
171 echo "Remove temporary directory." | 237 echo "Remove temporary directory." |
172 cd $BASE_DIR | 238 cd $BASE_DIR |
173 rm -rf $TEMP_DIR | 239 rm -rf $TEMP_DIR |
| 240 |
| 241 # TODO(fgalligan): Is "--disable-fast-unaligned" needed on mipsel? |
| 242 # TODO(fgalligan): Can we turn on "--enable-realtime-only" for mipsel? |
OLD | NEW |