Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / libvpx / libvpx.gyp
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4 {
5   'variables': {
6     'libvpx_build_vp9%': 1,
7     'libvpx_source%': 'source/libvpx',
8     'conditions': [
9       ['os_posix==1', {
10         'asm_obj_extension': 'o',
11       }],
12       ['OS=="win"', {
13         'asm_obj_extension': 'obj',
14       }],
15
16       ['(target_arch=="arm" or target_arch=="armv7") and arm_neon==1', {
17         'target_arch_full': 'arm-neon',
18       }, {
19         'conditions': [
20           ['OS=="android" and ((target_arch=="arm" or target_arch=="armv7") and arm_neon==0)', {
21             'target_arch_full': 'arm-neon-cpu-detect',
22           }, {
23            'target_arch_full': '<(target_arch)',
24           }],
25         ],
26       }],
27
28       ['os_posix == 1 and OS != "mac"', {
29         'OS_CATEGORY%': 'linux',
30       }, {
31         'OS_CATEGORY%': '<(OS)',
32       }],
33     ],
34
35     # Location of the intermediate output.
36     'shared_generated_dir': '<(SHARED_INTERMEDIATE_DIR)/third_party/libvpx',
37   },
38   'target_defaults': {
39     'target_conditions': [
40       ['<(libvpx_build_vp9)==0', {
41         'sources/': [ ['exclude', '(^|/)vp9/'], ],
42       }],
43     ],
44   },
45   'conditions': [
46     ['target_arch=="ia32"', {
47       'includes': ['libvpx_srcs_x86_intrinsics.gypi', ],
48     }],
49     ['target_arch=="x64"', {
50       'includes': ['libvpx_srcs_x86_64_intrinsics.gypi', ],
51     }],
52     [ '(target_arch=="arm" or target_arch=="armv7") and arm_neon==0 and OS=="android"', {
53       # When building for targets which may not have NEON (but may!), include
54       # support for neon and hide it behind Android cpu-features.
55       'includes': ['libvpx_srcs_arm_neon_cpu_detect_intrinsics.gypi', ],
56     }],
57     [ '(target_arch != "arm" and target_arch != "armv7") and target_arch != "mipsel"', {
58       'targets': [
59         {
60           # This libvpx target contains both encoder and decoder.
61           # Encoder is configured to be realtime only.
62           'target_name': 'libvpx',
63           'type': 'static_library',
64           'variables': {
65             'yasm_output_path': '<(SHARED_INTERMEDIATE_DIR)/third_party/libvpx',
66             'OS_CATEGORY%': '<(OS_CATEGORY)',
67             'yasm_flags': [
68               '-D', 'CHROMIUM',
69               '-I', 'source/config/<(OS_CATEGORY)/<(target_arch_full)',
70               '-I', 'source/config',
71               '-I', '<(libvpx_source)',
72               '-I', '<(shared_generated_dir)', # Generated assembly offsets
73             ],
74           },
75           'dependencies': [
76             'gen_asm_offsets_vp8',
77           ],
78           'includes': [
79             '../yasm/yasm_compile.gypi'
80           ],
81           'include_dirs': [
82             'source/config/<(OS_CATEGORY)/<(target_arch_full)',
83             'source/config',
84             '<(libvpx_source)',
85             '<(libvpx_source)/vp8/common',
86             '<(libvpx_source)/vp8/decoder',
87             '<(libvpx_source)/vp8/encoder',
88             '<(shared_generated_dir)', # Provides vpx_rtcd.h.
89           ],
90           'direct_dependent_settings': {
91             'include_dirs': [
92               '<(libvpx_source)',
93             ],
94           },
95           # VS2010 does not correctly incrementally link obj files generated
96           # from asm files. This flag disables UseLibraryDependencyInputs to
97           # avoid this problem.
98           'msvs_2010_disable_uldi_when_referenced': 1,
99           'conditions': [
100             ['target_arch=="ia32"', {
101               'includes': [
102                 'libvpx_srcs_x86.gypi',
103               ],
104               'dependencies': [
105                 'libvpx_intrinsics_mmx',
106                 'libvpx_intrinsics_sse2',
107                 # Currently no sse3 intrinsic functions
108                 #'libvpx_intrinsics_sse3',
109                 'libvpx_intrinsics_ssse3',
110                 # Currently no sse4_1 intrinsic functions
111                 #'libvpx_intrinsics_sse4_1',
112                 # Currently no avx intrinsic functions
113                 #'libvpx_intrinsics_avx',
114                 # Add avx2 support when VS2013 lands: crbug.com/328981
115                 #'libvpx_intrinsics_avx2',
116               ],
117             }],
118             ['target_arch=="x64"', {
119               'includes': [
120                 'libvpx_srcs_x86_64.gypi',
121               ],
122               'dependencies': [
123                 'libvpx_intrinsics_mmx',
124                 'libvpx_intrinsics_sse2',
125                 # Currently no sse3 intrinsic functions
126                 #'libvpx_intrinsics_sse3',
127                 'libvpx_intrinsics_ssse3',
128                 # Currently no sse4_1 intrinsic functions
129                 #'libvpx_intrinsics_sse4_1',
130                 # Currently no avx intrinsic functions
131                 #'libvpx_intrinsics_avx',
132                 # Add avx2 support when VS2013 lands: crbug.com/328981
133                 #'libvpx_intrinsics_avx2',
134               ],
135             }],
136             ['clang == 1', {
137               'xcode_settings': {
138                 'WARNING_CFLAGS': [
139                   # libvpx heavily relies on implicit enum casting.
140                   '-Wno-conversion',
141                   # libvpx does `if ((a == b))` in some places.
142                   '-Wno-parentheses-equality',
143                 ],
144               },
145               'cflags': [
146                 '-Wno-conversion',
147                 '-Wno-parentheses-equality',
148               ],
149             }],
150             ['chromeos == 1', {
151               # ChromeOS needs these files for animated WebM avatars.
152               'sources': [
153                 '<(libvpx_source)/third_party/libmkv/EbmlIDs.h',
154                 '<(libvpx_source)/third_party/libmkv/EbmlWriter.c',
155                 '<(libvpx_source)/third_party/libmkv/EbmlWriter.h',
156               ],
157             }],
158           ],
159         },
160       ],
161     },
162     ],
163     # 'libvpx' target for mips builds.
164     [ 'target_arch=="mipsel" ', {
165       'targets': [
166         {
167           # This libvpx target contains both encoder and decoder.
168           # Encoder is configured to be realtime only.
169           'target_name': 'libvpx',
170           'type': 'static_library',
171           'variables': {
172             'shared_generated_dir':
173               '<(SHARED_INTERMEDIATE_DIR)/third_party/libvpx',
174           },
175           'includes': [
176             'libvpx_srcs_mips.gypi',
177           ],
178           'cflags': [
179             '-EL -static -mips32',
180           ],
181           'include_dirs': [
182             'source/config/<(OS_CATEGORY)/<(target_arch_full)',
183             'source/config',
184             '<(libvpx_source)',
185             '<(libvpx_source)/vp8/common',
186             '<(libvpx_source)/vp8/decoder',
187             '<(libvpx_source)/vp8/encoder',
188           ],
189           'direct_dependent_settings': {
190             'include_dirs': [
191               '<(libvpx_source)',
192             ],
193           },
194           'sources': [
195             'source/config/<(OS_CATEGORY)/<(target_arch_full)/vpx_config.c',
196           ],
197         },
198       ],
199     },
200     ],
201     # 'libvpx' target for ARM builds.
202     [ '(target_arch=="arm" or target_arch=="armv7") ', {
203       'targets': [
204         {
205           # This libvpx target contains both encoder and decoder.
206           # Encoder is configured to be realtime only.
207           'target_name': 'libvpx',
208           'type': 'static_library',
209           'dependencies': [
210             'gen_asm_offsets_vp8',
211             'gen_asm_offsets_vpx_scale',
212           ],
213
214           # Copy the script to the output folder so that we can use it with
215           # absolute path.
216           'copies': [{
217             'destination': '<(shared_generated_dir)',
218             'files': [
219               '<(ads2gas_script_path)',
220               '<(ads2gas_script_include)',
221             ],
222           }],
223
224           # Rule to convert .asm files to .S files.
225           'rules': [
226             {
227               'rule_name': 'convert_asm',
228               'extension': 'asm',
229               'inputs': [
230                 '<(shared_generated_dir)/<(ads2gas_script)',
231                 '<(shared_generated_dir)/thumb.pm',
232               ],
233               'outputs': [
234                 '<(shared_generated_dir)/<(RULE_INPUT_ROOT).S',
235               ],
236               'action': [
237                 'bash',
238                 '-c',
239                 'cat <(RULE_INPUT_PATH) | perl <(shared_generated_dir)/<(ads2gas_script) -chromium > <(shared_generated_dir)/<(RULE_INPUT_ROOT).S',
240               ],
241               'process_outputs_as_sources': 1,
242               'message': 'Convert libvpx asm file for ARM <(RULE_INPUT_PATH)',
243             },
244           ],
245
246           'variables': {
247             'variables': {
248               'conditions': [
249                 ['OS=="ios"', {
250                   'ads2gas_script%': 'ads2gas_apple.pl',
251                 }, {
252                   'ads2gas_script%': 'ads2gas.pl',
253                 }],
254               ],
255             },
256             'ads2gas_script%': '<(ads2gas_script)',
257             # Location of the assembly conversion script.
258             'ads2gas_script_path': '<(libvpx_source)/build/make/<(ads2gas_script)',
259             'ads2gas_script_include': '<(libvpx_source)/build/make/thumb.pm',
260           },
261           # We need to explicitly tell the assembler to look for
262           # .include directive files from the place where they're
263           # generated to.
264           'cflags': [
265              '-Wa,-I,<!(pwd)/source/config/<(OS_CATEGORY)/<(target_arch_full)',
266              '-Wa,-I,<!(pwd)/source/config',
267              '-Wa,-I,<(shared_generated_dir)',
268           ],
269           'xcode_settings': {
270             'OTHER_CFLAGS': [
271               '-I<!(pwd)/source/config/<(OS_CATEGORY)/<(target_arch_full)',
272               '-I<!(pwd)/source/config',
273               '-I<(shared_generated_dir)',
274             ],
275           },
276           'include_dirs': [
277             'source/config/<(OS_CATEGORY)/<(target_arch_full)',
278             'source/config',
279             '<(libvpx_source)',
280           ],
281           'direct_dependent_settings': {
282             'include_dirs': [
283               '<(libvpx_source)',
284             ],
285           },
286           'conditions': [
287             # Libvpx optimizations for ARMv6 or ARMv7 without NEON.
288             ['arm_neon==0', {
289               'conditions': [
290                 ['OS=="android"', {
291                   'includes': [
292                     'libvpx_srcs_arm_neon_cpu_detect.gypi',
293                   ],
294                   'dependencies': [
295                     'libvpx_intrinsics_neon',
296                   ],
297                   'cflags': [
298                     '-Wa,-mfpu=neon',
299                   ],
300                 }, {
301                   'includes': [
302                     'libvpx_srcs_arm.gypi',
303                   ],
304                 }],
305               ],
306             }],
307             # Libvpx optimizations for ARMv7 with NEON.
308             ['arm_neon==1', {
309               'includes': [
310                 'libvpx_srcs_arm_neon.gypi',
311               ],
312             }],
313             ['OS == "android"', {
314               'includes': [
315                 '../../build/android/cpufeatures.gypi',
316               ],
317             }],
318             ['chromeos == 1', {
319               # ChromeOS needs these files for animated WebM avatars.
320               'sources': [
321                 '<(libvpx_source)/third_party/libmkv/EbmlIDs.h',
322                 '<(libvpx_source)/third_party/libmkv/EbmlWriter.c',
323                 '<(libvpx_source)/third_party/libmkv/EbmlWriter.h',
324               ],
325             }],
326           ],
327         },
328       ],
329     }],
330   ],
331   'targets': [
332     {
333       # A tool that runs on host to extract integers from object file.
334       'target_name': 'libvpx_obj_int_extract',
335       'type': 'executable',
336       'toolsets': ['host'],
337       'include_dirs': [
338         'source/config/<(OS_CATEGORY)/<(target_arch_full)',
339         'source/config',
340         '<(libvpx_source)',
341       ],
342       'sources': [
343         '<(libvpx_source)/build/make/obj_int_extract.c',
344       ]
345     },
346     {
347       # A library that contains assembly offsets needed.
348       'target_name': 'libvpx_asm_offsets_vp8',
349       'type': 'static_library',
350       'android_unmangled_name': 1,
351       'hard_dependency': 1,
352       'include_dirs': [
353         'source/config/<(OS_CATEGORY)/<(target_arch_full)',
354         'source/config',
355         '<(libvpx_source)',
356       ],
357       'conditions': [
358         ['asan==1', {
359           'cflags!': [ '-fsanitize=address' ],
360           'xcode_settings': { 'OTHER_CFLAGS!': [ '-fsanitize=address' ] },
361           'ldflags!': [ '-fsanitize=address' ],
362         }],
363       ],
364       'sources': [
365         '<(libvpx_source)/vp8/encoder/vp8_asm_enc_offsets.c',
366       ],
367     },
368     {
369       # A library that contains assembly offsets needed.
370       # TODO(fgalligan): Merge libvpx_asm_offsets_vpx_scale into
371       # libvpx_asm_offsets.
372       'target_name': 'libvpx_asm_offsets_vpx_scale',
373       'type': 'static_library',
374       'android_unmangled_name': 1,
375       'hard_dependency': 1,
376       'include_dirs': [
377         'source/config/<(OS_CATEGORY)/<(target_arch_full)',
378         'source/config',
379         '<(libvpx_source)',
380       ],
381       'conditions': [
382         ['asan==1', {
383           'cflags!': [ '-faddress-sanitizer', '-fsanitize=address', ],
384           'xcode_settings': {
385             'OTHER_CFLAGS!': [ '-faddress-sanitizer','-fsanitize=address' ],
386           },
387           'ldflags!': [ '-faddress-sanitizer', '-fsanitize=address', ],
388         }],
389       ],
390       'sources': [
391         '<(libvpx_source)/vpx_scale/vpx_scale_asm_offsets.c',
392       ],
393     },
394     {
395       # A target that takes assembly offsets library and generate the
396       # corresponding assembly files.
397       # This target is a hard dependency because the generated .asm files
398       # are needed all assembly optimized files in libvpx.
399       'target_name': 'gen_asm_offsets_vp8',
400       'type': 'none',
401       'hard_dependency': 1,
402       'dependencies': [
403         'libvpx_asm_offsets_vp8',
404         'libvpx_obj_int_extract#host',
405       ],
406       'variables' : {
407         'lib_intermediate_name' : '',
408         'output_format':'',
409         'output_dir': '<(shared_generated_dir)',
410         'conditions' : [
411           ['android_webview_build==1', {
412             'lib_intermediate_name' : '<(android_src)/$(call intermediates-dir-for, STATIC_LIBRARIES, libvpx_asm_offsets_vp8)/libvpx_asm_offsets_vp8.a',
413           }],
414           ['(target_arch=="arm" or target_arch=="armv7")', {
415             'output_format': 'gas',
416           }, {
417             'output_format': 'rvds',
418           }],
419         ],
420       },
421       'conditions': [
422         ['OS=="win"', {
423           'variables': {
424             'ninja_obj_dir': '<(PRODUCT_DIR)/obj/third_party/libvpx/<(libvpx_source)/vp8',
425           },
426           'actions': [
427             {
428               'action_name': 'copy_enc_offsets_obj',
429               'inputs': [ 'copy_obj.py' ],
430               'outputs': [ '<(INTERMEDIATE_DIR)/vp8_asm_enc_offsets.obj' ],
431               'action': [
432                 'python',
433                 '<(DEPTH)/third_party/libvpx/copy_obj.py',
434                 '-d', '<@(_outputs)',
435                 '-s', '<(PRODUCT_DIR)/obj/libvpx_asm_offsets_vp8/vp8_asm_enc_offsets.obj',
436                 '-s', '<(ninja_obj_dir)/encoder/libvpx_asm_offsets_vp8.vp8_asm_enc_offsets.obj',
437                 '-s', '<(PRODUCT_DIR)/obj/Source/WebKit/chromium/third_party/libvpx/<(libvpx_source)/vp8/encoder/libvpx_asm_offsets_vp8.vp8_asm_enc_offsets.obj',
438               ],
439               'process_output_as_sources': 1,
440             },
441           ],
442           'sources': [
443             '<(INTERMEDIATE_DIR)/vp8_asm_enc_offsets.obj',
444           ],
445         }, {
446           'variables': {
447             'unpack_lib_search_path_list': [
448               '-a', '<(PRODUCT_DIR)/libvpx_asm_offsets_vp8.a',
449               '-a', '<(LIB_DIR)/third_party/libvpx/libvpx_asm_offsets_vp8.a',
450               '-a', '<(LIB_DIR)/Source/WebKit/chromium/third_party/libvpx/libvpx_asm_offsets_vp8.a',
451               '-a', '<(lib_intermediate_name)',
452             ],
453             'unpack_lib_output_dir':'<(INTERMEDIATE_DIR)',
454             'unpack_lib_name':'vp8_asm_enc_offsets.o'
455           },
456           'includes': ['unpack_lib_posix.gypi'],
457           # Need this otherwise gyp won't run the rule on them.
458           'sources': [
459             '<(INTERMEDIATE_DIR)/vp8_asm_enc_offsets.o',
460           ],
461         }],
462       ],
463       'includes': ['obj_int_extract.gypi'],
464     },
465     {
466       # A target that takes assembly offsets library and generate the
467       # corresponding assembly files.
468       # This target is a hard dependency because the generated .asm files
469       # are needed all assembly optimized files in libvpx.
470       'target_name': 'gen_asm_offsets_vpx_scale',
471       'type': 'none',
472       'hard_dependency': 1,
473       'dependencies': [
474         'libvpx_asm_offsets_vpx_scale',
475         'libvpx_obj_int_extract#host',
476       ],
477       'variables' : {
478         'lib_intermediate_name' : '',
479         'output_format':'',
480         'output_dir': '<(shared_generated_dir)',
481         'conditions' : [
482           ['android_webview_build==1', {
483             'lib_intermediate_name' : '<(android_src)/$(call intermediates-dir-for, STATIC_LIBRARIES, libvpx_asm_offsets_vpx_scale)/libvpx_asm_offsets_vpx_scale.a',
484           }],
485           ['(target_arch=="arm" or target_arch=="armv7")', {
486             'output_format': 'gas',
487           }, {
488             'output_format': 'rvds',
489           }],
490         ],
491       },
492       'conditions': [
493         ['OS=="win"', {
494           'variables': {
495             'ninja_obj_dir': '<(PRODUCT_DIR)/obj/third_party/libvpx/<(libvpx_source)/vpx_scale',
496           },
497           'actions': [
498             {
499               'action_name': 'copy_enc_offsets_obj',
500               'inputs': [ 'copy_obj.py' ],
501               'outputs': [ '<(INTERMEDIATE_DIR)/vpx_scale_asm_offsets.obj' ],
502               'action': [
503                 'python',
504                 '<(DEPTH)/third_party/libvpx/copy_obj.py',
505                 '-d', '<@(_outputs)',
506                 '-s', '<(PRODUCT_DIR)/obj/libvpx_asm_offsets_vpx_scale/vpx_scale_asm_offsets.obj',
507                 '-s', '<(ninja_obj_dir)/encoder/libvpx_asm_offsets_vpx_scale.vpx_scale_asm_offsets.obj',
508                 '-s', '<(PRODUCT_DIR)/obj/Source/WebKit/chromium/third_party/libvpx/<(libvpx_source)/vpx_scale/libvpx_asm_offsets_vpx_scale.vpx_scale_asm_offsets.obj',
509               ],
510               'process_output_as_sources': 1,
511             },
512           ],
513           'sources': [
514             '<(INTERMEDIATE_DIR)/vpx_scale_asm_offsets.obj',
515           ],
516         }, {
517           'variables': {
518             'unpack_lib_search_path_list': [
519               '-a', '<(PRODUCT_DIR)/libvpx_asm_offsets_vpx_scale.a',
520               '-a', '<(LIB_DIR)/third_party/libvpx/libvpx_asm_offsets_vpx_scale.a',
521               '-a', '<(LIB_DIR)/Source/WebKit/chromium/third_party/libvpx/libvpx_asm_offsets_vpx_scale.a',
522               '-a', '<(lib_intermediate_name)',
523             ],
524             'unpack_lib_output_dir':'<(INTERMEDIATE_DIR)',
525             'unpack_lib_name':'vpx_scale_asm_offsets.o'
526           },
527           'includes': ['unpack_lib_posix.gypi'],
528          # Need this otherwise gyp won't run the rule on them.
529           'sources': [
530             '<(INTERMEDIATE_DIR)/vpx_scale_asm_offsets.o',
531           ],
532         }],
533       ],
534       'includes': ['obj_int_extract.gypi'],
535     },
536   ],
537 }