OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import("//build/config/arm.gni") | 5 # This config is applied to targets that depend on libvpx. |
6 import("//build/config/android/config.gni") | 6 config("libvpx_external_config") { |
7 import("//build/config/sanitizers/sanitizers.gni") | 7 include_dirs = [ "//third_party/libvpx/source/libvpx" ] |
8 import("//third_party/libvpx_new/libvpx_srcs.gni") | |
9 import("//third_party/yasm/yasm_assemble.gni") | |
10 | |
11 # Sets the architecture name for building libvpx. | |
12 if (current_cpu == "x86") { | |
13 cpu_arch_full = "ia32" | |
14 } else if (current_cpu == "x64") { | |
15 if (is_msan) { | |
16 cpu_arch_full = "generic" | |
17 } else { | |
18 cpu_arch_full = "x64" | |
19 } | |
20 } else if (current_cpu == "arm") { | |
21 if (arm_use_neon) { | |
22 cpu_arch_full = "arm-neon" | |
23 } else if (is_android) { | |
24 cpu_arch_full = "arm-neon-cpu-detect" | |
25 } else { | |
26 cpu_arch_full = "arm" | |
27 } | |
28 } else { | |
29 cpu_arch_full = current_cpu | |
30 } | 8 } |
31 | 9 |
32 if (is_nacl) { | 10 group("libvpx_new") { |
33 platform_include_dir = "//third_party/libvpx_new/source/config/nacl" | 11 public_deps = [ |
34 } else { | 12 "//third_party/libvpx", |
35 if (is_posix && !is_mac) { | |
36 os_category = "linux" | |
37 } else { | |
38 os_category = current_os | |
39 } | |
40 platform_include_dir = | |
41 "//third_party/libvpx_new/source/config/$os_category/$cpu_arch_full" | |
42 } | |
43 | |
44 config("libvpx_config") { | |
45 include_dirs = [ | |
46 "//third_party/libvpx_new/source/config", | |
47 platform_include_dir, | |
48 "//third_party/libvpx_new/source/libvpx", | |
49 "$root_gen_dir/third_party/libvpx_new", # Provides vpx_rtcd.h. | |
50 ] | 13 ] |
51 | |
52 if (current_cpu == "arm" && is_clang) { | |
53 # TODO(hans) Enable integrated-as (crbug.com/124610). | |
54 asmflags = [ "-fno-integrated-as" ] | |
55 if (is_android) { | |
56 rebased_android_toolchain_root = | |
57 rebase_path(android_toolchain_root, root_build_dir) | |
58 | |
59 # Else /usr/bin/as gets picked up. | |
60 asmflags += [ "-B${rebased_android_toolchain_root}/bin" ] | |
61 } | |
62 } | |
63 } | |
64 | |
65 # gn orders flags on a target before flags from configs. The default config | |
66 # adds -Wall, and these flags have to be after -Wall -- so they need to come | |
67 # from a config and can't be on the target directly. | |
68 config("libvpx_warnings") { | |
69 if (is_clang) { | |
70 cflags = [ | |
71 # libvpx heavily relies on implicit enum casting. | |
72 "-Wno-conversion", | |
73 | |
74 # libvpx does `if ((a == b))` in some places. | |
75 "-Wno-parentheses-equality", | |
76 | |
77 # libvpx has many static functions in header, which trigger this warning. | |
78 "-Wno-unused-function", | |
79 ] | |
80 } else if (!is_win) { | |
81 cflags = [ | |
82 "-Wno-unused-function", | |
83 "-Wno-sign-compare", | |
84 ] | |
85 } | |
86 } | |
87 | |
88 # This config is applied to targets that depend on libvpx. | |
89 config("libvpx_external_config") { | |
90 include_dirs = [ "//third_party/libvpx_new/source/libvpx" ] | |
91 } | |
92 | |
93 if (current_cpu == "x86" || current_cpu == "x64") { | |
94 yasm_assemble("libvpx_yasm") { | |
95 if (current_cpu == "x86") { | |
96 sources = libvpx_srcs_x86_assembly | |
97 } else if (current_cpu == "x64") { | |
98 sources = libvpx_srcs_x86_64_assembly | |
99 } | |
100 | |
101 defines = [ "CHROMIUM" ] | |
102 if (is_android) { | |
103 # On Android, define __ANDROID__ to use alternative standard library | |
104 # functions. | |
105 defines += [ "__ANDROID__" ] | |
106 } | |
107 include_dirs = [ | |
108 platform_include_dir, | |
109 "//third_party/libvpx_new/source/config", | |
110 "//third_party/libvpx_new/source/libvpx", | |
111 target_gen_dir, | |
112 ] | |
113 } | |
114 } | |
115 | |
116 static_library("libvpx_intrinsics_mmx") { | |
117 configs += [ ":libvpx_config" ] | |
118 configs -= [ "//build/config/compiler:chromium_code" ] | |
119 configs += [ "//build/config/compiler:no_chromium_code" ] | |
120 configs += [ ":libvpx_warnings" ] | |
121 if (!is_win) { | |
122 cflags = [ "-mmmx" ] | |
123 } | |
124 if (current_cpu == "x86") { | |
125 sources = libvpx_srcs_x86_mmx | |
126 } else if (current_cpu == "x64") { | |
127 sources = libvpx_srcs_x86_64_mmx | |
128 } | |
129 } | |
130 | |
131 static_library("libvpx_intrinsics_sse2") { | |
132 configs += [ ":libvpx_config" ] | |
133 configs -= [ "//build/config/compiler:chromium_code" ] | |
134 configs += [ "//build/config/compiler:no_chromium_code" ] | |
135 configs += [ ":libvpx_warnings" ] | |
136 if (!is_win || is_clang) { | |
137 cflags = [ "-msse2" ] | |
138 } | |
139 if (current_cpu == "x86") { | |
140 sources = libvpx_srcs_x86_sse2 | |
141 } else if (current_cpu == "x64") { | |
142 sources = libvpx_srcs_x86_64_sse2 | |
143 } | |
144 } | |
145 | |
146 static_library("libvpx_intrinsics_ssse3") { | |
147 configs += [ ":libvpx_config" ] | |
148 configs -= [ "//build/config/compiler:chromium_code" ] | |
149 configs += [ "//build/config/compiler:no_chromium_code" ] | |
150 configs += [ ":libvpx_warnings" ] | |
151 if (!is_win || is_clang) { | |
152 cflags = [ "-mssse3" ] | |
153 } | |
154 if (current_cpu == "x86") { | |
155 sources = libvpx_srcs_x86_ssse3 | |
156 } else if (current_cpu == "x64") { | |
157 sources = libvpx_srcs_x86_64_ssse3 | |
158 } | |
159 } | |
160 | |
161 static_library("libvpx_intrinsics_sse4_1") { | |
162 configs += [ ":libvpx_config" ] | |
163 configs -= [ "//build/config/compiler:chromium_code" ] | |
164 configs += [ "//build/config/compiler:no_chromium_code" ] | |
165 configs += [ ":libvpx_warnings" ] | |
166 if (!is_win || is_clang) { | |
167 cflags = [ "-msse4.1" ] | |
168 } | |
169 if (current_cpu == "x86") { | |
170 sources = libvpx_srcs_x86_sse4_1 | |
171 } else if (current_cpu == "x64") { | |
172 sources = libvpx_srcs_x86_64_sse4_1 | |
173 } | |
174 } | |
175 | |
176 static_library("libvpx_intrinsics_avx") { | |
177 configs += [ ":libvpx_config" ] | |
178 configs -= [ "//build/config/compiler:chromium_code" ] | |
179 configs += [ "//build/config/compiler:no_chromium_code" ] | |
180 configs += [ ":libvpx_warnings" ] | |
181 if (is_win) { | |
182 cflags = [ "/arch:AVX" ] | |
183 } else { | |
184 cflags = [ "-mavx" ] | |
185 } | |
186 if (current_cpu == "x86") { | |
187 sources = libvpx_srcs_x86_avx | |
188 } else if (current_cpu == "x64") { | |
189 sources = libvpx_srcs_x86_64_avx | |
190 } | |
191 } | |
192 | |
193 static_library("libvpx_intrinsics_avx2") { | |
194 configs += [ ":libvpx_config" ] | |
195 configs -= [ "//build/config/compiler:chromium_code" ] | |
196 configs += [ "//build/config/compiler:no_chromium_code" ] | |
197 configs += [ ":libvpx_warnings" ] | |
198 if (is_win) { | |
199 cflags = [ "/arch:AVX2" ] | |
200 } else { | |
201 cflags = [ "-mavx2" ] | |
202 } | |
203 if (current_cpu == "x86") { | |
204 sources = libvpx_srcs_x86_avx2 | |
205 } else if (current_cpu == "x64") { | |
206 sources = libvpx_srcs_x86_64_avx2 | |
207 } | |
208 } | |
209 | |
210 if (cpu_arch_full == "arm-neon-cpu-detect") { | |
211 static_library("libvpx_intrinsics_neon") { | |
212 configs -= [ "//build/config/compiler:compiler_arm_fpu" ] | |
213 configs += [ ":libvpx_config" ] | |
214 configs += [ ":libvpx_warnings" ] | |
215 cflags = [ "-mfpu=neon" ] | |
216 sources = libvpx_srcs_arm_neon_cpu_detect_neon | |
217 } | |
218 } | |
219 | |
220 # Converts ARM assembly files to GAS style. | |
221 if (current_cpu == "arm") { | |
222 action_foreach("convert_arm_assembly") { | |
223 script = "//third_party/libvpx_new/run_perl.py" | |
224 if (cpu_arch_full == "arm-neon") { | |
225 sources = libvpx_srcs_arm_neon_assembly | |
226 } else if (cpu_arch_full == "arm-neon-cpu-detect") { | |
227 sources = libvpx_srcs_arm_neon_cpu_detect_assembly | |
228 } else { | |
229 sources = libvpx_srcs_arm_assembly | |
230 } | |
231 outputs = [ | |
232 "$target_gen_dir/{{source_name_part}}.S", | |
233 ] | |
234 args = [ | |
235 "-s", | |
236 rebase_path( | |
237 "//third_party/libvpx_new/source/libvpx/build/make/ads2gas.pl", | |
238 root_build_dir), | |
239 "-i", | |
240 "{{source}}", | |
241 "-o", | |
242 rebase_path("$target_gen_dir/{{source_name_part}}.S"), | |
243 ] | |
244 } | |
245 | |
246 static_library("libvpx_assembly_arm") { | |
247 sources = get_target_outputs(":convert_arm_assembly") | |
248 configs -= [ "//build/config/compiler:compiler_arm_fpu" ] | |
249 configs += [ ":libvpx_config" ] | |
250 configs += [ ":libvpx_warnings" ] | |
251 if (cpu_arch_full == "arm-neon" || cpu_arch_full == "arm-neon-cpu-detect") { | |
252 asmflags = [ "-mfpu=neon" ] | |
253 } | |
254 deps = [ | |
255 ":convert_arm_assembly", | |
256 ] | |
257 } | |
258 } | |
259 | |
260 static_library("libvpx_new") { | |
261 if (!is_debug && is_win) { | |
262 configs -= [ "//build/config/compiler:default_optimization" ] | |
263 configs += [ "//build/config/compiler:optimize_max" ] | |
264 } | |
265 | |
266 if (is_nacl) { | |
267 sources = libvpx_srcs_generic | |
268 } else if (current_cpu == "x86") { | |
269 sources = libvpx_srcs_x86 | |
270 } else if (current_cpu == "x64") { | |
271 if (is_msan) { | |
272 sources = libvpx_srcs_generic | |
273 } else { | |
274 sources = libvpx_srcs_x86_64 | |
275 } | |
276 } else if (current_cpu == "mipsel") { | |
277 sources = libvpx_srcs_mips | |
278 } else if (current_cpu == "arm") { | |
279 if (arm_use_neon) { | |
280 sources = libvpx_srcs_arm_neon | |
281 } else if (is_android) { | |
282 sources = libvpx_srcs_arm_neon_cpu_detect | |
283 } else { | |
284 sources = libvpx_srcs_arm | |
285 } | |
286 } else if (current_cpu == "arm64") { | |
287 sources = libvpx_srcs_arm64 | |
288 } | |
289 | |
290 configs += [ ":libvpx_config" ] | |
291 configs -= [ "//build/config/compiler:chromium_code" ] | |
292 configs += [ "//build/config/compiler:no_chromium_code" ] | |
293 configs += [ ":libvpx_warnings" ] | |
294 deps = [] | |
295 if (current_cpu == "x86" || (current_cpu == "x64" && !is_msan)) { | |
296 deps += [ | |
297 ":libvpx_intrinsics_avx", | |
298 ":libvpx_intrinsics_avx2", | |
299 ":libvpx_intrinsics_mmx", | |
300 ":libvpx_intrinsics_sse2", | |
301 ":libvpx_intrinsics_sse4_1", | |
302 ":libvpx_intrinsics_ssse3", | |
303 ":libvpx_yasm", | |
304 ] | |
305 } | |
306 if (cpu_arch_full == "arm-neon-cpu-detect") { | |
307 deps += [ ":libvpx_intrinsics_neon" ] | |
308 } | |
309 if (is_android) { | |
310 deps += [ "//third_party/android_tools:cpu_features" ] | |
311 } | |
312 if (current_cpu == "arm") { | |
313 deps += [ ":libvpx_assembly_arm" ] | |
314 } | |
315 | |
316 public_configs = [ ":libvpx_external_config" ] | 14 public_configs = [ ":libvpx_external_config" ] |
317 } | 15 } |
OLD | NEW |