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