Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / ffmpeg / ffmpeg.gyp
1 # Copyright (c) 2011 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 # There's a couple key GYP variables that control how FFmpeg is built:
6 #   ffmpeg_branding
7 #     Controls whether we build the Chromium or Google Chrome version of
8 #     FFmpeg.  The Google Chrome version contains additional codecs.
9 #     Typical values are Chromium, Chrome, ChromiumOS, and ChromeOS.
10 #   build_ffmpegsumo
11 #     When set to zero will build Chromium against Chrome's FFmpeg headers, but
12 #     not build ffmpegsumo itself.  Users are expected to build and provide
13 #     their own version of ffmpegsumo.  Default value is 1.
14 #
15
16 {
17   'target_defaults': {
18     'variables': {
19       # Since we are not often debugging FFmpeg, and performance is
20       # unacceptable without optimization, freeze the optimizations to -O2.
21       # If someone really wants -O1 , they can change these in their checkout.
22       # If you want -O0, see the Gotchas in README.Chromium for why that
23       # won't work.
24       'release_optimize': '2',
25       'debug_optimize': '2',
26       'mac_debug_optimization': '2',
27       # In addition to the above reasons, /Od optimization won't remove symbols
28       # that are under "if (0)" style sections.  Which lead to link time errors
29       # when for example it tries to link an ARM symbol on X86.
30       'win_debug_Optimization': '2',
31       # Run time checks are incompatible with any level of optimizations.
32       'win_debug_RuntimeChecks': '0',
33       'conditions': [
34         ['OS == "win"', {
35           # Setting the optimizations to 'speed' or to 'max' results in a lot of
36           # unresolved symbols. The only supported mode is 'size' (see
37           # crbug.com/264459).
38           'optimize' :'size',
39         }],
40       ],
41     },
42   },
43   'variables': {
44     # Make sure asm_sources is always defined even if an arch doesn't have any
45     # asm sources (e.g. mips or x86 with forcefully disabled asm).
46     'asm_sources': [
47     ],
48
49     # Allow overriding the selection of which FFmpeg binaries to copy via an
50     # environment variable.  Affects the ffmpeg_binaries target.
51     'conditions': [
52       ['target_arch == "arm" and arm_version == 7 and arm_neon == 1', {
53         # Need a separate config for arm+neon vs arm
54         'ffmpeg_config%': 'arm-neon',
55       }, {
56         'ffmpeg_config%': '<(target_arch)',
57       }],
58       ['OS == "mac" or OS == "win" or OS == "openbsd"', {
59         'os_config%': '<(OS)',
60       }, {  # all other Unix OS's use the linux config
61         'conditions': [
62           ['msan==1', {
63             # MemorySanitizer doesn't like assembly code.
64             'os_config%': 'linux-noasm',
65           }, {
66             'os_config%': 'linux',
67           }]
68         ],
69       }],
70       ['chromeos == 1', {
71         'ffmpeg_branding%': '<(branding)OS',
72       }, {  # otherwise, assume Chrome/Chromium.
73         'ffmpeg_branding%': '<(branding)',
74       }],
75     ],
76
77     'build_ffmpegsumo%': 1,
78
79     # Locations for generated artifacts.
80     'shared_generated_dir': '<(SHARED_INTERMEDIATE_DIR)/third_party/ffmpeg',
81
82     # Stub generator script and signatures of all functions used by Chrome.
83     'generate_stubs_script': '../../tools/generate_stubs/generate_stubs.py',
84     'sig_files': ['chromium/ffmpegsumo.sigs'],
85     'extra_header': 'chromium/ffmpeg_stub_headers.fragment',
86   },
87   'conditions': [
88     ['target_arch != "arm" and os_config != "linux-noasm"', {
89       'targets': [
90         {
91           'target_name': 'ffmpeg_yasm',
92           'type': 'static_library',
93           'includes': [
94             'ffmpeg_generated.gypi',
95             '../yasm/yasm_compile.gypi',
96           ],
97           'sources': [
98             '<@(asm_sources)',
99             # XCode doesn't want to link a pure assembly target and will fail
100             # to link when it creates an empty file list.  So add a dummy file
101             # keep the linker happy.  See http://crbug.com/157073
102             'xcode_hack.c',
103           ],
104           'variables': {
105             # Path to platform configuration files.
106             'platform_config_root': 'chromium/config/<(ffmpeg_branding)/<(os_config)/<(ffmpeg_config)',
107
108             'conditions': [
109               ['target_arch == "ia32"', {
110                 'more_yasm_flags': [
111                   '-DARCH_X86_32',
112                  ],
113               }, {
114                 'more_yasm_flags': [
115                   '-DARCH_X86_64',
116                 ],
117               }],
118               ['OS == "mac"', {
119                 'more_yasm_flags': [
120                   # Necessary to ensure symbols end up with a _ prefix; added by
121                   # yasm_compile.gypi for Windows, but not Mac.
122                   '-DPREFIX',
123                 ]
124               }],
125             ],
126             'yasm_flags': [
127               '-DPIC',
128               '>@(more_yasm_flags)',
129               '-I', '<(platform_config_root)',
130               '-I', 'libavcodec/x86/',
131               '-I', 'libavutil/x86/',
132               '-I', '.',
133               # Disable warnings, prevents log spam for things we won't fix.
134               '-w',
135               '-P', 'config.asm',
136             ],
137             'yasm_output_path': '<(shared_generated_dir)/yasm'
138           },
139         },
140       ] # targets
141     }], # arch != arm
142     ['build_ffmpegsumo != 0', {
143       'includes': [
144         'ffmpeg_generated.gypi',
145         '../../build/util/version.gypi',
146       ],
147       'variables': {
148         # Path to platform configuration files.
149         'platform_config_root': 'chromium/config/<(ffmpeg_branding)/<(os_config)/<(ffmpeg_config)',
150       },
151       'targets': [
152         {
153           'target_name': 'ffmpegsumo_resources',
154           'type': 'none',
155           'conditions': [
156             ['branding == "Chrome"', {
157               'variables': {
158                  'branding_path': '../../chrome/app/theme/google_chrome/BRANDING',
159               },
160             }, { # else branding!="Chrome"
161               'variables': {
162                  'branding_path': '../../chrome/app/theme/chromium/BRANDING',
163               },
164             }],
165           ],
166           'variables': {
167             'output_dir': 'ffmpegsumo',
168             'template_input_path': '../../chrome/app/chrome_version.rc.version',
169           },
170           'sources': [
171             'ffmpegsumo.ver',
172           ],
173           'includes': [
174             '../../chrome/version_resource_rules.gypi',
175           ],
176         },
177         {
178           'target_name': 'ffmpegsumo',
179           'type': 'loadable_module',
180           'sources': [
181             '<@(c_sources)',
182             '<(platform_config_root)/config.h',
183             '<(platform_config_root)/libavutil/avconfig.h',
184             '<(SHARED_INTERMEDIATE_DIR)/ffmpegsumo/ffmpegsumo_version.rc',
185           ],
186           'include_dirs': [
187             '<(platform_config_root)',
188             '.',
189           ],
190           'dependencies': [
191             'ffmpegsumo_resources',
192           ],
193           'defines': [
194             'HAVE_AV_CONFIG_H',
195             '_POSIX_C_SOURCE=200112',
196             '_XOPEN_SOURCE=600',
197             'PIC',
198             # Disable deprecated features which generate spammy warnings.
199             'FF_API_PIX_FMT_DESC=0',
200             'FF_API_OLD_DECODE_AUDIO=0',
201             'FF_API_DESTRUCT_PACKET=0',
202             'FF_API_GET_BUFFER=0',
203           ],
204           'variables': {
205             'clang_warning_flags': [
206               '-Wno-absolute-value',
207               # ffmpeg uses its own deprecated functions.
208               '-Wno-deprecated-declarations',
209               # ffmpeg doesn't care about pointer constness.
210               '-Wno-incompatible-pointer-types',
211               # ffmpeg doesn't follow usual parentheses conventions.
212               '-Wno-parentheses',
213               # ffmpeg doesn't care about pointer signedness.
214               '-Wno-pointer-sign',
215               # ffmpeg doesn't believe in exhaustive switch statements.
216               '-Wno-switch',
217               # matroskadec.c has a "failed:" label that's only used if some
218               # CONFIG_ flags we don't set are set.
219               '-Wno-unused-label',
220             ],
221           },
222           'cflags': [
223             '-fPIC',
224             '-fomit-frame-pointer',
225             # ffmpeg uses its own deprecated functions.
226             '-Wno-deprecated-declarations',
227           ],
228           'conditions': [
229             ['target_arch != "arm" and target_arch != "mipsel" and os_config != "linux-noasm"', {
230               'dependencies': [
231                 'ffmpeg_yasm',
232               ],
233             }],
234             ['clang != 1', {
235               'cflags': [
236                 # gcc doesn't have flags for specific warnings, so disable them
237                 # all.
238                 '-w',
239               ],
240             }],
241             ['target_arch == "ia32"', {
242               # Turn off valgrind build option that breaks ffmpeg builds.
243               'cflags!': [
244                 '-fno-omit-frame-pointer',
245               ],
246               'debug_extra_cflags!': [
247                 '-fno-omit-frame-pointer',
248               ],
249               'release_extra_cflags!': [
250                 '-fno-omit-frame-pointer',
251               ],
252             }],  # target_arch == "ia32"
253             ['target_arch == "arm"', {
254               # TODO(ihf): See the long comment in build_ffmpeg.sh
255               # We want to be consistent with CrOS and have configured
256               # ffmpeg for thumb. Protect yourself from -marm.
257               'cflags!': [
258                 '-marm',
259               ],
260               'cflags': [
261                 '-mthumb',
262                 '-march=armv7-a',
263                 '-mtune=cortex-a8',
264               ],
265               # On arm we use gcc to compile the assembly.
266               'sources': [
267                 '<@(asm_sources)',
268               ],
269               'conditions': [
270                 ['arm_neon == 0', {
271                   'cflags': [
272                     '-mfpu=vfpv3-d16',
273                   ],
274                 }, {
275                   'cflags': [
276                     '-mfpu=neon',
277                   ],
278                 }],
279                 ['arm_float_abi == "hard"', {
280                   'cflags': [
281                     '-DHAVE_VFP_ARGS=1'
282                   ],
283                 }, {
284                   'cflags': [
285                     '-DHAVE_VFP_ARGS=0'
286                   ],
287                 }],
288               ],
289             }],
290             ['target_arch == "mipsel"', {
291               'cflags': [
292                 '-mips32',
293                 '-EL -Wl,-EL',
294               ],
295             }],  # target_arch == "mipsel"
296             ['os_posix == 1 and OS != "mac"', {
297               'defines': [
298                 '_ISOC99_SOURCE',
299                 '_LARGEFILE_SOURCE',
300                 # BUG(ihf): ffmpeg compiles with this define. But according to
301                 # ajwong: I wouldn't change _FILE_OFFSET_BITS.  That's a scary change
302                 # cause it affects the default length of off_t, and fpos_t,
303                 # which can cause strange problems if the loading code doesn't
304                 # have it set and you start passing FILE*s or file descriptors
305                 # between symbol contexts.
306                 # '_FILE_OFFSET_BITS=64',
307               ],
308               'cflags': [
309                 '-std=c99',
310                 '-pthread',
311                 '-fno-math-errno',
312                 '-fno-signed-zeros',
313                 '-fno-tree-vectorize',
314               ],
315               'cflags!': [
316                 # Ensure the symbols are exported.
317                 #
318                 # TODO(ajwong): Manually tag the API that we use to be
319                 # exported.
320                 '-fvisibility=hidden',
321               ],
322               'link_settings': {
323                 'ldflags': [
324                   '-Wl,-Bsymbolic',
325                   '-L<(shared_generated_dir)',
326                 ],
327                 'libraries': [
328                   '-lz',
329                 ],
330               },
331             }],  # os_posix == 1 and OS != "mac"
332             ['OS == "openbsd"', {
333               # OpenBSD's gcc (4.2.1) does not support this flag
334               'cflags!': [
335                 '-fno-signed-zeros',
336               ],
337             }],
338             ['OS == "mac"', {
339               'defines': [
340                 '_DARWIN_C_SOURCE',
341               ],
342               'conditions': [
343                 ['mac_breakpad == 1', {
344                   'variables': {
345                     # A real .dSYM is needed for dump_syms to operate on.
346                     'mac_real_dsym': 1,
347                   },
348                 }],
349                 ['target_arch != "x64"', {
350                   # -read_only_relocs cannot be used with x86_64
351                   'xcode_settings': {
352                     'OTHER_LDFLAGS': [
353                       # This is needed because even though FFmpeg now builds
354                       # with -fPIC, it's not quite a complete PIC build, only
355                       # partial :( Thus we need to instruct the linker to allow
356                       # relocations for read-only segments for this target to be
357                       # able to generated the shared library on Mac.
358                       #
359                       # This makes Mark sad, but he's okay with it since it is
360                       # isolated to this module. When Mark finds this in the
361                       # future, and has forgotten this conversation, this
362                       # comment should remind him that the world is still nice
363                       # and butterflies still exist...as do rainbows, sunshine,
364                       # tulips, etc., etc...but not kittens. Those went away
365                       # with this flag.
366                       '-Wl,-read_only_relocs,suppress',
367                     ],
368                   },
369                 }],
370               ],
371               'link_settings': {
372                 'libraries': [
373                   '$(SDKROOT)/usr/lib/libz.dylib',
374                 ],
375               },
376               'xcode_settings': {
377                 'GCC_SYMBOLS_PRIVATE_EXTERN': 'NO',  # No -fvisibility=hidden
378                 'DYLIB_INSTALL_NAME_BASE': '@loader_path',
379                 'LIBRARY_SEARCH_PATHS': [
380                   '<(shared_generated_dir)'
381                 ],
382               },
383             }],  # OS == "mac"
384             ['OS == "win"', {
385               'sources': [
386                 '<(shared_generated_dir)/ffmpegsumo.def',
387               ],
388               'include_dirs': [
389                 'chromium/include/win',
390               ],
391               # TODO(dalecurtis): We should fix these.  http://crbug.com/154421
392               'msvs_disabled_warnings': [
393                 4996, 4018, 4090, 4305, 4133, 4146, 4554, 4028, 4334, 4101, 4102,
394                 4116, 4307, 4273, 4005, 4056, 4756,
395               ],
396               'conditions': [
397                 ['clang == 1', {
398                   'msvs_settings': {
399                     'VCCLCompilerTool': {
400                       # This corresponds to msvs_disabled_warnings 4273 above.
401                       'AdditionalOptions': [ '-Wno-inconsistent-dllimport' ],
402                     },
403                   },
404                 }],
405                 ['clang == 1 or (MSVS_VERSION == "2013" or MSVS_VERSION == "2013e")', {
406                   'defines': [
407                     'inline=__inline',
408                     'strtoll=_strtoi64',
409                     '_ISOC99_SOURCE',
410                     '_LARGEFILE_SOURCE',
411                     'HAVE_AV_CONFIG_H',
412                     'strtod=avpriv_strtod',
413                     'snprintf=avpriv_snprintf',
414                     '_snprintf=avpriv_snprintf',
415                     'vsnprintf=avpriv_vsnprintf',
416                   ],
417                 }],
418                 ['target_arch == "x64"', {
419                   # TODO(wolenetz): We should fix this.  http://crbug.com/171009
420                   'msvs_disabled_warnings' : [
421                     4267
422                   ],
423                 }],
424               ],
425               'msvs_settings': {
426                 # Ignore warnings about a local symbol being inefficiently imported,
427                 # upstream is working on a fix.
428                 'VCLinkerTool': {
429                   'AdditionalOptions': ['/ignore:4049', '/ignore:4217'],
430                 }
431               },
432               'actions': [
433                 {
434                   'action_name': 'generate_def',
435                   'inputs': [
436                     '<(generate_stubs_script)',
437                     '<@(sig_files)',
438                   ],
439                   'outputs': [
440                     '<(shared_generated_dir)/ffmpegsumo.def',
441                   ],
442                   'action': ['python',
443                              '<(generate_stubs_script)',
444                              '-i', '<(INTERMEDIATE_DIR)',
445                              '-o', '<(shared_generated_dir)',
446                              '-t', 'windows_def',
447                              '-m', 'ffmpegsumo.dll',
448                              '<@(_inputs)',
449                   ],
450                   'message': 'Generating FFmpeg export definitions',
451                 },
452               ],
453             }],
454           ],
455         },
456       ],
457     }],
458   ],  # conditions
459   'targets': [
460     {
461       'target_name': 'ffmpeg',
462       'sources': [
463         # Files needed for stub generation rules.
464         '<@(sig_files)',
465       ],
466       'defines': [
467         '__STDC_CONSTANT_MACROS',  # FFmpeg uses INT64_C.
468       ],
469       'hard_dependency': 1,
470
471       # Do not fear the massive conditional blocks!  They do the following:
472       #   1) Use the Window stub generator on Windows
473       #   2) Else, use the POSIX stub generator on non-Windows
474       'conditions': [
475         ['OS == "win"', {
476           'msvs_guid': 'D7A94F58-576A-45D9-A45F-EB87C63ABBB0',
477           'variables': {
478             'conditions': [
479               ['target_arch == "x64"', {
480                 'outfile_type': 'windows_lib_x64',
481               }, {  # else, generate x86 stub library
482                 'outfile_type': 'windows_lib',
483               }],
484             ],
485             'output_dir': '<(PRODUCT_DIR)/lib',
486             'intermediate_dir': '<(INTERMEDIATE_DIR)',
487           },
488           'type': 'none',
489           'sources': [
490             # Adds C99 types for Visual C++.
491             'chromium/include/win/inttypes.h',
492           ],
493           'dependencies': [
494             'ffmpegsumo',
495           ],
496           'direct_dependent_settings': {
497             'include_dirs': [
498               '<(platform_config_root)',
499               'chromium/include/win',
500               '.',
501             ],
502             'link_settings': {
503               'libraries': [
504                 '<(output_dir)/ffmpegsumo.lib',
505               ],
506               'msvs_settings': {
507                 'VCLinkerTool': {
508                   'DelayLoadDLLs': [
509                     'ffmpegsumo.dll',
510                   ],
511                 },
512               },
513             },
514           },
515           'rules': [
516             {
517               'rule_name': 'generate_libs',
518               'extension': 'sigs',
519               'inputs': [
520                 '<(generate_stubs_script)',
521                 '<@(sig_files)',
522               ],
523               'outputs': [
524                 '<(output_dir)/<(RULE_INPUT_ROOT).lib',
525               ],
526               'action': ['python', '<(generate_stubs_script)',
527                          '-i', '<(intermediate_dir)',
528                          '-o', '<(output_dir)',
529                          '-t', '<(outfile_type)',
530                          '<@(RULE_INPUT_PATH)',
531               ],
532               'message': 'Generating FFmpeg import libraries',
533             },
534           ],
535         }, {  # else OS != "win", use POSIX stub generator
536           'variables': {
537             'outfile_type': 'posix_stubs',
538             'stubs_filename_root': 'ffmpeg_stubs',
539             'project_path': 'third_party/ffmpeg',
540             'intermediate_dir': '<(INTERMEDIATE_DIR)',
541             'output_root': '<(SHARED_INTERMEDIATE_DIR)/ffmpeg',
542             'platform_config_root': 'chromium/config/<(ffmpeg_branding)/<(os_config)/<(ffmpeg_config)'
543           },
544           'sources': [
545             '<(extra_header)',
546           ],
547           'type': '<(component)',
548           'include_dirs': [
549             '<(output_root)',
550             '../..',  # The chromium 'src' directory.
551             '<(platform_config_root)',
552             '.',
553           ],
554           'dependencies': [
555             # Required for the logging done in the stubs generator.
556             '../../base/base.gyp:base',
557           ],
558           'direct_dependent_settings': {
559             'defines': [
560               '__STDC_CONSTANT_MACROS',  # FFmpeg uses INT64_C.
561             ],
562             'include_dirs': [
563               '<(output_root)',
564               '../..',  # The chromium 'src' directory.
565               '<(platform_config_root)',
566               '.',
567             ],
568           },
569           'actions': [
570             {
571               'action_name': 'generate_stubs',
572               'inputs': [
573                 '<(generate_stubs_script)',
574                 '<(extra_header)',
575                 '<@(sig_files)',
576               ],
577               'outputs': [
578                 '<(intermediate_dir)/<(stubs_filename_root).cc',
579                 '<(output_root)/<(project_path)/<(stubs_filename_root).h',
580               ],
581               'action': ['python',
582                          '<(generate_stubs_script)',
583                          '-i', '<(intermediate_dir)',
584                          '-o', '<(output_root)/<(project_path)',
585                          '-t', '<(outfile_type)',
586                          '-e', '<(extra_header)',
587                          '-s', '<(stubs_filename_root)',
588                          '-p', '<(project_path)',
589                          '<@(_inputs)',
590               ],
591               'process_outputs_as_sources': 1,
592               'message': 'Generating FFmpeg stubs for dynamic loading',
593             },
594           ],
595           'conditions': [
596             # Linux/Solaris need libdl for dlopen() and friends.
597             ['OS == "linux" or OS == "solaris"', {
598               'link_settings': {
599                 'libraries': [
600                   '-ldl',
601                 ],
602               },
603             }],
604             ['component == "shared_library"', {
605               'cflags!': ['-fvisibility=hidden'],
606               'xcode_settings': {
607                 'GCC_SYMBOLS_PRIVATE_EXTERN': 'NO',  # no -fvisibility=hidden
608               },
609             }],
610             ['build_ffmpegsumo != 0', {
611               'dependencies': [
612                 'ffmpegsumo',
613               ],
614             }],
615           ],  # conditions
616         }],
617       ],  # conditions
618     },
619   ],  # targets
620 }