- add third_party src.
[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"', {
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" and target_arch != "armv7") and target_arch != "mipsel"', {
53       'targets': [
54         {
55           # This libvpx target contains both encoder and decoder.
56           # Encoder is configured to be realtime only.
57           'target_name': 'libvpx',
58           'type': 'static_library',
59           'variables': {
60             'yasm_output_path': '<(SHARED_INTERMEDIATE_DIR)/third_party/libvpx',
61             'OS_CATEGORY%': '<(OS_CATEGORY)',
62             'yasm_flags': [
63               '-D', 'CHROMIUM',
64               '-I', 'source/config/<(OS_CATEGORY)/<(target_arch)',
65               '-I', 'source/config',
66               '-I', '<(libvpx_source)',
67               '-I', '<(shared_generated_dir)', # Generated assembly offsets
68             ],
69           },
70           'dependencies': [
71             'gen_asm_offsets_vp8',
72           ],
73           'includes': [
74             '../yasm/yasm_compile.gypi'
75           ],
76           'include_dirs': [
77             'source/config/<(OS_CATEGORY)/<(target_arch)',
78             'source/config',
79             '<(libvpx_source)',
80             '<(libvpx_source)/vp8/common',
81             '<(libvpx_source)/vp8/decoder',
82             '<(libvpx_source)/vp8/encoder',
83             '<(shared_generated_dir)', # Provides vpx_rtcd.h.
84           ],
85           'direct_dependent_settings': {
86             'include_dirs': [
87               '<(libvpx_source)',
88             ],
89           },
90           # VS2010 does not correctly incrementally link obj files generated
91           # from asm files. This flag disables UseLibraryDependencyInputs to
92           # avoid this problem.
93           'msvs_2010_disable_uldi_when_referenced': 1,
94           'conditions': [
95             ['target_arch=="ia32"', {
96               'includes': [
97                 'libvpx_srcs_x86.gypi',
98               ],
99               'dependencies': [
100                 'libvpx_intrinsics_mmx',
101                 'libvpx_intrinsics_sse2',
102                 # Currently no sse3 intrinsic functions
103                 #'libvpx_intrinsics_sse3',
104                 'libvpx_intrinsics_ssse3',
105                 # Currently no sse4_1 intrinsic functions
106                 #'libvpx_intrinsics_sse4_1',
107               ],
108             }],
109             ['target_arch=="x64"', {
110               'includes': [
111                 'libvpx_srcs_x86_64.gypi',
112               ],
113               'dependencies': [
114                 'libvpx_intrinsics_mmx',
115                 'libvpx_intrinsics_sse2',
116                 # Currently no sse3 intrinsic functions
117                 #'libvpx_intrinsics_sse3',
118                 'libvpx_intrinsics_ssse3',
119                 # Currently no sse4_1 intrinsic functions
120                 #'libvpx_intrinsics_sse4_1',
121               ],
122             }],
123             ['clang == 1', {
124               'xcode_settings': {
125                 'WARNING_CFLAGS': [
126                   # libvpx heavily relies on implicit enum casting.
127                   '-Wno-conversion',
128                   # libvpx does `if ((a == b))` in some places.
129                   '-Wno-parentheses-equality',
130                 ],
131               },
132               'cflags': [
133                 '-Wno-conversion',
134                 '-Wno-parentheses-equality',
135               ],
136             }],
137             ['chromeos == 1', {
138               # ChromeOS needs these files for animated WebM avatars.
139               'sources': [
140                 '<(libvpx_source)/third_party/libmkv/EbmlIDs.h',
141                 '<(libvpx_source)/third_party/libmkv/EbmlWriter.c',
142                 '<(libvpx_source)/third_party/libmkv/EbmlWriter.h',
143               ],
144             }],
145           ],
146         },
147       ],
148     },
149     ],
150     # 'libvpx' target for mips builds.
151     [ 'target_arch=="mipsel" ', {
152       'targets': [
153         {
154           # This libvpx target contains both encoder and decoder.
155           # Encoder is configured to be realtime only.
156           'target_name': 'libvpx',
157           'type': 'static_library',
158           'variables': {
159             'shared_generated_dir':
160               '<(SHARED_INTERMEDIATE_DIR)/third_party/libvpx',
161           },
162           'includes': [
163             'libvpx_srcs_mips.gypi',
164           ],
165           'cflags': [
166             '-EL -static -mips32',
167           ],
168           'include_dirs': [
169             'source/config/<(OS_CATEGORY)/<(target_arch)',
170             'source/config',
171             '<(libvpx_source)',
172             '<(libvpx_source)/vp8/common',
173             '<(libvpx_source)/vp8/decoder',
174             '<(libvpx_source)/vp8/encoder',
175           ],
176           'direct_dependent_settings': {
177             'include_dirs': [
178               '<(libvpx_source)',
179             ],
180           },
181           'sources': [
182             'source/config/<(OS_CATEGORY)/<(target_arch)/vpx_config.c',
183           ],
184         },
185       ],
186     },
187     ],
188     # 'libvpx' target for ARM builds.
189     [ '(target_arch=="arm" or target_arch=="armv7") ', {
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           'dependencies': [
197             'gen_asm_offsets_vp8',
198             'gen_asm_offsets_vpx_scale',
199           ],
200
201           # Copy the script to the output folder so that we can use it with
202           # absolute path.
203           'copies': [{
204             'destination': '<(shared_generated_dir)',
205             'files': [
206               '<(ads2gas_script_path)',
207               '<(ads2gas_script_include)',
208             ],
209           }],
210
211           # Rule to convert .asm files to .S files.
212           'rules': [
213             {
214               'rule_name': 'convert_asm',
215               'extension': 'asm',
216               'inputs': [
217                 '<(shared_generated_dir)/<(ads2gas_script)',
218                 '<(shared_generated_dir)/thumb.pm',
219               ],
220               'outputs': [
221                 '<(shared_generated_dir)/<(RULE_INPUT_ROOT).S',
222               ],
223               'action': [
224                 'bash',
225                 '-c',
226                 'cat <(RULE_INPUT_PATH) | perl <(shared_generated_dir)/<(ads2gas_script) > <(shared_generated_dir)/<(RULE_INPUT_ROOT).S',
227               ],
228               'process_outputs_as_sources': 1,
229               'message': 'Convert libvpx asm file for ARM <(RULE_INPUT_PATH).',
230             },
231           ],
232
233           'variables': {
234             'variables': {
235               'conditions': [
236                 ['OS=="ios"', {
237                   'ads2gas_script%': 'ads2gas_apple.pl',
238                 }, {
239                   'ads2gas_script%': 'ads2gas.pl',
240                 }],
241               ],
242             },
243             'ads2gas_script%': '<(ads2gas_script)',
244             # Location of the assembly conversion script.
245             'ads2gas_script_path': '<(libvpx_source)/build/make/<(ads2gas_script)',
246             'ads2gas_script_include': '<(libvpx_source)/build/make/thumb.pm',
247           },
248           # We need to explicitly tell the assembler to look for
249           # .include directive files from the place where they're
250           # generated to.
251           'cflags': [
252              '-Wa,-I,<!(pwd)/source/config/<(OS_CATEGORY)/<(target_arch_full)',
253              '-Wa,-I,<!(pwd)/source/config',
254              '-Wa,-I,<(shared_generated_dir)',
255           ],
256           'xcode_settings': {
257             'OTHER_CFLAGS': [
258               '-I<!(pwd)/source/config/<(OS_CATEGORY)/<(target_arch_full)',
259               '-I<!(pwd)/source/config',
260               '-I<(shared_generated_dir)',
261             ],
262           },
263           'include_dirs': [
264             'source/config/<(OS_CATEGORY)/<(target_arch_full)',
265             'source/config',
266             '<(libvpx_source)',
267           ],
268           'direct_dependent_settings': {
269             'include_dirs': [
270               '<(libvpx_source)',
271             ],
272           },
273           'conditions': [
274             # Libvpx optimizations for ARMv6 or ARMv7 without NEON.
275             ['arm_neon==0', {
276               'conditions': [
277                 ['OS=="android"', {
278                   'includes': [
279                     'libvpx_srcs_arm_neon_cpu_detect.gypi',
280                   ],
281                   'cflags': [
282                     '-Wa,-mfpu=neon',
283                   ],
284                 }, {
285                   'includes': [
286                     'libvpx_srcs_arm.gypi',
287                   ],
288                 }],
289               ],
290             }],
291             # Libvpx optimizations for ARMv7 with NEON.
292             ['arm_neon==1', {
293               'includes': [
294                 'libvpx_srcs_arm_neon.gypi',
295               ],
296             }],
297             ['OS == "android"', {
298               'include_dirs': [
299                 '<(android_ndk_include)',
300                 '<(android_ndk_root)/sources/android/cpufeatures',
301               ],
302             }],
303             ['chromeos == 1', {
304               # ChromeOS needs these files for animated WebM avatars.
305               'sources': [
306                 '<(libvpx_source)/third_party/libmkv/EbmlIDs.h',
307                 '<(libvpx_source)/third_party/libmkv/EbmlWriter.c',
308                 '<(libvpx_source)/third_party/libmkv/EbmlWriter.h',
309               ],
310             }],
311           ],
312         },
313       ],
314     }],
315   ],
316   'targets': [
317     {
318       # A tool that runs on host to extract integers from object file.
319       'target_name': 'libvpx_obj_int_extract',
320       'type': 'executable',
321       'toolsets': ['host'],
322       'include_dirs': [
323         'source/config/<(OS_CATEGORY)/<(target_arch_full)',
324         'source/config',
325         '<(libvpx_source)',
326       ],
327       'sources': [
328         '<(libvpx_source)/build/make/obj_int_extract.c',
329       ]
330     },
331     {
332       # A library that contains assembly offsets needed.
333       'target_name': 'libvpx_asm_offsets_vp8',
334       'type': 'static_library',
335       'hard_dependency': 1,
336       'include_dirs': [
337         'source/config/<(OS_CATEGORY)/<(target_arch_full)',
338         'source/config',
339         '<(libvpx_source)',
340       ],
341       'conditions': [
342         ['asan==1', {
343           'cflags!': [ '-fsanitize=address' ],
344           'xcode_settings': { 'OTHER_CFLAGS!': [ '-fsanitize=address' ] },
345           'ldflags!': [ '-fsanitize=address' ],
346         }],
347       ],
348       'sources': [
349         '<(libvpx_source)/vp8/encoder/vp8_asm_enc_offsets.c',
350       ],
351     },
352     {
353       # A library that contains assembly offsets needed.
354       # TODO(fgalligan): Merge libvpx_asm_offsets_vpx_scale into
355       # libvpx_asm_offsets.
356       'target_name': 'libvpx_asm_offsets_vpx_scale',
357       'type': 'static_library',
358       'hard_dependency': 1,
359       'include_dirs': [
360         'source/config/<(OS_CATEGORY)/<(target_arch_full)',
361         'source/config',
362         '<(libvpx_source)',
363       ],
364       'conditions': [
365         ['asan==1', {
366           'cflags!': [ '-faddress-sanitizer', '-fsanitize=address', ],
367           'xcode_settings': {
368             'OTHER_CFLAGS!': [ '-faddress-sanitizer','-fsanitize=address' ],
369           },
370           'ldflags!': [ '-faddress-sanitizer', '-fsanitize=address', ],
371         }],
372       ],
373       'sources': [
374         '<(libvpx_source)/vpx_scale/vpx_scale_asm_offsets.c',
375       ],
376     },
377     {
378       # A target that takes assembly offsets library and generate the
379       # corresponding assembly files.
380       # This target is a hard dependency because the generated .asm files
381       # are needed all assembly optimized files in libvpx.
382       'target_name': 'gen_asm_offsets_vp8',
383       'type': 'none',
384       'hard_dependency': 1,
385       'dependencies': [
386         'libvpx_asm_offsets_vp8',
387         'libvpx_obj_int_extract#host',
388       ],
389       'conditions': [
390         ['OS=="win"', {
391           'variables': {
392             'ninja_obj_dir': '<(PRODUCT_DIR)/obj/third_party/libvpx/<(libvpx_source)/vp8',
393           },
394           'actions': [
395             {
396               'action_name': 'copy_enc_offsets_obj',
397               'inputs': [ 'copy_obj.sh' ],
398               'outputs': [ '<(INTERMEDIATE_DIR)/vp8_asm_enc_offsets.obj' ],
399               'action': [
400                 '<(DEPTH)/third_party/libvpx/copy_obj.sh',
401                 '-d', '<@(_outputs)',
402                 '-s', '<(PRODUCT_DIR)/obj/libvpx_asm_offsets_vp8/vp8_asm_enc_offsets.obj',
403                 '-s', '<(ninja_obj_dir)/encoder/libvpx_asm_offsets_vp8.vp8_asm_enc_offsets.obj',
404                 '-s', '<(PRODUCT_DIR)/obj/Source/WebKit/chromium/third_party/libvpx/<(libvpx_source)/vp8/encoder/libvpx_asm_offsets_vp8.vp8_asm_enc_offsets.obj',
405               ],
406               'process_output_as_sources': 1,
407               'msvs_cygwin_shell': 1,
408             },
409           ],
410           'sources': [
411             '<(INTERMEDIATE_DIR)/vp8_asm_enc_offsets.obj',
412           ],
413         }, {
414           'actions': [
415             {
416               # Take archived .a file and unpack it unto .o files.
417               'action_name': 'unpack_lib_posix',
418               'inputs': [
419                 'unpack_lib_posix.sh',
420               ],
421               'outputs': [
422                 '<(INTERMEDIATE_DIR)/vp8_asm_enc_offsets.o',
423               ],
424               'action': [
425                 '<(DEPTH)/third_party/libvpx/unpack_lib_posix.sh',
426                 '-d', '<(INTERMEDIATE_DIR)',
427                 '-a', '<(PRODUCT_DIR)/libvpx_asm_offsets_vp8.a',
428                 '-a', '<(LIB_DIR)/third_party/libvpx/libvpx_asm_offsets_vp8.a',
429                 '-a', '<(LIB_DIR)/Source/WebKit/chromium/third_party/libvpx/libvpx_asm_offsets_vp8.a',
430                 '-f', 'vp8_asm_enc_offsets.o',
431               ],
432               'process_output_as_sources': 1,
433               'msvs_cygwin_shell': 1,
434             },
435           ],
436           # Need this otherwise gyp won't run the rule on them.
437           'sources': [
438             '<(INTERMEDIATE_DIR)/vp8_asm_enc_offsets.o',
439           ],
440         }],
441       ],
442       'rules': [
443         {
444           # Rule to extract integer values for each symbol from an object file.
445           'rule_name': 'obj_int_extract',
446           'extension': '<(asm_obj_extension)',
447           'inputs': [
448             '<(PRODUCT_DIR)/libvpx_obj_int_extract',
449             'obj_int_extract.sh',
450           ],
451           'outputs': [
452             '<(shared_generated_dir)/<(RULE_INPUT_ROOT).asm',
453           ],
454           'variables': {
455             'conditions': [
456               ['(target_arch=="arm" or target_arch=="armv7")', {
457                 'asm_format': 'gas',
458               }, {
459                 'asm_format': 'rvds',
460               }],
461             ],
462           },
463           'action': [
464             '<(DEPTH)/third_party/libvpx/obj_int_extract.sh',
465             '-e', '<(PRODUCT_DIR)/libvpx_obj_int_extract',
466             '-f', '<(asm_format)',
467             '-b', '<(RULE_INPUT_PATH)',
468             '-o', '<(shared_generated_dir)/<(RULE_INPUT_ROOT).asm',
469           ],
470           'message': 'Generate assembly offsets <(RULE_INPUT_PATH).',
471           'msvs_cygwin_shell': 1,
472         },
473       ],
474     },
475     {
476       # A target that takes assembly offsets library and generate the
477       # corresponding assembly files.
478       # This target is a hard dependency because the generated .asm files
479       # are needed all assembly optimized files in libvpx.
480       'target_name': 'gen_asm_offsets_vpx_scale',
481       'type': 'none',
482       'hard_dependency': 1,
483       'dependencies': [
484         'libvpx_asm_offsets_vpx_scale',
485         'libvpx_obj_int_extract#host',
486       ],
487       'conditions': [
488         ['OS=="win"', {
489           'variables': {
490             'ninja_obj_dir': '<(PRODUCT_DIR)/obj/third_party/libvpx/<(libvpx_source)/vpx_scale',
491           },
492           'actions': [
493             {
494               'action_name': 'copy_enc_offsets_obj',
495               'inputs': [ 'copy_obj.sh' ],
496               'outputs': [ '<(INTERMEDIATE_DIR)/vpx_scale_asm_offsets.obj' ],
497               'action': [
498                 '<(DEPTH)/third_party/libvpx/copy_obj.sh',
499                 '-d', '<@(_outputs)',
500                 '-s', '<(PRODUCT_DIR)/obj/libvpx_asm_offsets_vpx_scale/vpx_scale_asm_offsets.obj',
501                 '-s', '<(ninja_obj_dir)/encoder/libvpx_asm_offsets_vpx_scale.vpx_scale_asm_offsets.obj',
502                 '-s', '<(PRODUCT_DIR)/obj/Source/WebKit/chromium/third_party/libvpx/<(libvpx_source)/vpx_scale/libvpx_asm_offsets_vpx_scale.vpx_scale_asm_offsets.obj',
503               ],
504               'process_output_as_sources': 1,
505               'msvs_cygwin_shell': 1,
506             },
507           ],
508           'sources': [
509             '<(INTERMEDIATE_DIR)/vpx_scale_asm_offsets.obj',
510           ],
511         }, {
512           'actions': [
513             {
514               # Take archived .a file and unpack it unto .o files.
515               'action_name': 'unpack_lib_posix',
516               'inputs': [
517                 'unpack_lib_posix.sh',
518               ],
519               'outputs': [
520                 '<(INTERMEDIATE_DIR)/vpx_scale_asm_offsets.o',
521               ],
522               'action': [
523                 '<(DEPTH)/third_party/libvpx/unpack_lib_posix.sh',
524                 '-d', '<(INTERMEDIATE_DIR)',
525                 '-a', '<(PRODUCT_DIR)/libvpx_asm_offsets_vpx_scale.a',
526                 '-a', '<(LIB_DIR)/third_party/libvpx/libvpx_asm_offsets_vpx_scale.a',
527                 '-a', '<(LIB_DIR)/Source/WebKit/chromium/third_party/libvpx/libvpx_asm_offsets_vpx_scale.a',
528                 '-f', 'vpx_scale_asm_offsets.o',
529               ],
530               'process_output_as_sources': 1,
531             },
532           ],
533           # Need this otherwise gyp won't run the rule on them.
534           'sources': [
535             '<(INTERMEDIATE_DIR)/vpx_scale_asm_offsets.o',
536           ],
537         }],
538       ],
539       'rules': [
540         {
541           # Rule to extract integer values for each symbol from an object file.
542           'rule_name': 'obj_int_extract',
543           'extension': '<(asm_obj_extension)',
544           'inputs': [
545             '<(PRODUCT_DIR)/libvpx_obj_int_extract',
546             'obj_int_extract.sh',
547           ],
548           'outputs': [
549             '<(shared_generated_dir)/<(RULE_INPUT_ROOT).asm',
550           ],
551           'variables': {
552             'conditions': [
553               ['(target_arch=="arm" or target_arch=="armv7")', {
554                 'asm_format': 'gas',
555               }, {
556                 'asm_format': 'rvds',
557               }],
558             ],
559           },
560           'action': [
561             '<(DEPTH)/third_party/libvpx/obj_int_extract.sh',
562             '-e', '<(PRODUCT_DIR)/libvpx_obj_int_extract',
563             '-f', '<(asm_format)',
564             '-b', '<(RULE_INPUT_PATH)',
565             '-o', '<(shared_generated_dir)/<(RULE_INPUT_ROOT).asm',
566           ],
567           'message': 'Generate assembly offsets <(RULE_INPUT_PATH).',
568           'msvs_cygwin_shell': 1,
569         },
570       ],
571     },
572     {
573       'target_name': 'simple_encoder',
574       'type': 'executable',
575       'dependencies': [
576         'libvpx',
577       ],
578
579       # Copy the script to the output folder so that we can use it with
580       # absolute path.
581       'copies': [{
582         'destination': '<(shared_generated_dir)/simple_encoder',
583         'files': [
584           '<(libvpx_source)/examples/gen_example_code.sh',
585         ],
586       }],
587
588       # Rule to convert .txt files to .c files.
589       'rules': [
590         {
591           'rule_name': 'generate_example',
592           'extension': 'txt',
593           'inputs': [ '<(shared_generated_dir)/simple_encoder/gen_example_code.sh', ],
594           'outputs': [
595             '<(shared_generated_dir)/<(RULE_INPUT_ROOT).c',
596           ],
597           'action': [
598             'bash',
599             '-c',
600             '<(shared_generated_dir)/simple_encoder/gen_example_code.sh <(RULE_INPUT_PATH) > <(shared_generated_dir)/<(RULE_INPUT_ROOT).c',
601           ],
602           'process_outputs_as_sources': 1,
603           'message': 'Generate libvpx example code <(RULE_INPUT_PATH).',
604         },
605       ],
606       'sources': [
607         '<(libvpx_source)/examples/simple_encoder.txt',
608       ]
609     },
610     {
611       'target_name': 'simple_decoder',
612       'type': 'executable',
613       'dependencies': [
614         'libvpx',
615       ],
616
617       # Copy the script to the output folder so that we can use it with
618       # absolute path.
619       'copies': [{
620         'destination': '<(shared_generated_dir)/simple_decoder',
621         'files': [
622           '<(libvpx_source)/examples/gen_example_code.sh',
623         ],
624       }],
625
626       # Rule to convert .txt files to .c files.
627       'rules': [
628         {
629           'rule_name': 'generate_example',
630           'extension': 'txt',
631           'inputs': [ '<(shared_generated_dir)/simple_decoder/gen_example_code.sh', ],
632           'outputs': [
633             '<(shared_generated_dir)/<(RULE_INPUT_ROOT).c',
634           ],
635           'action': [
636             'bash',
637             '-c',
638             '<(shared_generated_dir)/simple_decoder/gen_example_code.sh <(RULE_INPUT_PATH) > <(shared_generated_dir)/<(RULE_INPUT_ROOT).c',
639           ],
640           'process_outputs_as_sources': 1,
641           'message': 'Generate libvpx example code <(RULE_INPUT_PATH).',
642         },
643       ],
644       'sources': [
645         '<(libvpx_source)/examples/simple_decoder.txt',
646       ]
647     },
648   ],
649 }