| OLD | NEW |
| (Empty) | |
| 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 # use_system_ffmpeg |
| 11 # When set to non-zero will build Chromium against the system FFmpeg |
| 12 # headers via pkg-config. When Chromium is launched it will assume that |
| 13 # FFmpeg is present in the system library path. Default value is 0. |
| 14 # build_ffmpegsumo |
| 15 # When set to zero will build Chromium against the patched ffmpegsumo |
| 16 # headers, but not build ffmpegsumo itself. Users are expected to build |
| 17 # and provide their own version of ffmpegsumo. Default value is 1. |
| 18 # |
| 19 # TODO(ihf): Define these variables and use them. |
| 20 # LIBAVCODEC_VERSION_MAJOR=53 |
| 21 # LIBAVFORMAT_VERSION_MAJOR=53 |
| 22 # LIBAVUTIL_VERSION_MAJOR=51 |
| 23 |
| 24 { |
| 25 'target_defaults': { |
| 26 'conditions': [ |
| 27 ['os_posix != 1 or OS == "mac" or OS == "openbsd"', { |
| 28 'sources/': [['exclude', '/linux/']] |
| 29 }], |
| 30 ['OS != "mac"', {'sources/': [['exclude', '/mac/']]}], |
| 31 ['OS != "win"', {'sources/': [['exclude', '/win/']]}], |
| 32 ['OS != "openbsd"', {'sources/': [['exclude', '/openbsd/']]}], |
| 33 ], |
| 34 'variables': { |
| 35 # Since we are not often debugging FFmpeg, and performance is |
| 36 # unacceptable without optimization, freeze the optimizations to -O2. |
| 37 # If someone really wants -O1 , they can change these in their checkout. |
| 38 # If you want -O0, see the Gotchas in README.Chromium for why that |
| 39 # won't work. |
| 40 'debug_optimize': '2', |
| 41 'mac_debug_optimization': '2', |
| 42 }, |
| 43 }, |
| 44 'variables': { |
| 45 # Allow overridding the selection of which FFmpeg binaries to copy via an |
| 46 # environment variable. Affects the ffmpeg_binaries target. |
| 47 |
| 48 'conditions': [ |
| 49 ['armv7 == 1 and arm_neon == 1', { |
| 50 # Need a separate config for arm+neon vs arm |
| 51 'ffmpeg_config%': 'arm-neon', |
| 52 }, { |
| 53 'ffmpeg_config%': '<(target_arch)', |
| 54 }], |
| 55 ['OS == "mac" or OS == "win" or OS == "openbsd"', { |
| 56 'os_config%': '<(OS)', |
| 57 }, { # all other Unix OS's use the linux config |
| 58 'os_config%': 'linux', |
| 59 }], |
| 60 ['chromeos == 1', { |
| 61 'ffmpeg_branding%': '<(branding)OS', |
| 62 }, { # otherwise, assume Chrome/Chromium. |
| 63 'ffmpeg_branding%': '<(branding)', |
| 64 }], |
| 65 ], |
| 66 |
| 67 'ffmpeg_variant%': '<(target_arch)', |
| 68 |
| 69 'use_system_ffmpeg%': 0, |
| 70 'build_ffmpegsumo%': 1, |
| 71 |
| 72 # Locations for generated artifacts. |
| 73 'shared_generated_dir': '<(SHARED_INTERMEDIATE_DIR)/third_party/ffmpeg', |
| 74 'asm_library': 'ffmpegasm', |
| 75 }, |
| 76 'conditions': [ |
| 77 ['OS != "win" and use_system_ffmpeg == 0 and build_ffmpegsumo != 0', { |
| 78 'targets': [ |
| 79 { |
| 80 'target_name': 'ffmpegsumo', |
| 81 'type': 'loadable_module', |
| 82 'sources': [ |
| 83 'config/<(ffmpeg_branding)/<(os_config)/<(ffmpeg_config)/config.h', |
| 84 'config/libavutil/avconfig.h', |
| 85 ], |
| 86 'include_dirs': [ |
| 87 'config/<(ffmpeg_branding)/<(os_config)/<(ffmpeg_config)', |
| 88 'patched-ffmpeg', |
| 89 'config', |
| 90 ], |
| 91 'defines': [ |
| 92 'HAVE_AV_CONFIG_H', |
| 93 '_POSIX_C_SOURCE=200112', |
| 94 '_XOPEN_SOURCE=600', |
| 95 ], |
| 96 'cflags': [ |
| 97 '-fomit-frame-pointer', |
| 98 ], |
| 99 'includes': [ |
| 100 'ffmpeg_generated.gypi', |
| 101 ], |
| 102 'conditions': [ |
| 103 ['clang == 1', { |
| 104 'xcode_settings': { |
| 105 'WARNING_CFLAGS': [ |
| 106 # ffmpeg uses its own deprecated functions. |
| 107 '-Wno-deprecated-declarations', |
| 108 # ffmpeg doesn't care about pointer constness. |
| 109 '-Wno-incompatible-pointer-types', |
| 110 # ffmpeg doesn't follow usual parentheses conventions. |
| 111 '-Wno-parentheses', |
| 112 # ffmpeg doesn't care about pointer signedness. |
| 113 '-Wno-pointer-sign', |
| 114 # ffmpeg doesn't believe in exhaustive switch statements. |
| 115 '-Wno-switch-enum', |
| 116 ], |
| 117 }, |
| 118 'cflags': [ |
| 119 '-Wno-deprecated-declarations', |
| 120 '-Wno-incompatible-pointer-types', |
| 121 '-Wno-logical-op-parentheses', |
| 122 '-Wno-parentheses', |
| 123 '-Wno-pointer-sign', |
| 124 '-Wno-switch-enum', |
| 125 # Don't emit warnings for gcc -f flags clang doesn't implement. |
| 126 '-Qunused-arguments', |
| 127 ], |
| 128 }, { |
| 129 'cflags': [ |
| 130 # gcc doesn't have flags for specific warnings, so disable them |
| 131 # all. |
| 132 '-w', |
| 133 ], |
| 134 }], |
| 135 ['use_system_yasm == 0', { |
| 136 'dependencies': [ |
| 137 '../yasm/yasm.gyp:yasm#host', |
| 138 ], |
| 139 }], |
| 140 ['target_arch == "ia32"', { |
| 141 'cflags!': [ |
| 142 # Turn off valgrind build option that breaks ffmpeg builds. |
| 143 # Allows config.h HAVE_EBP_AVAILABLE 1 and HAVE_EBX_AVAILABLE 1 |
| 144 '-fno-omit-frame-pointer', |
| 145 ], |
| 146 }], # target_arch == "ia32" |
| 147 ['target_arch == "x64"', { |
| 148 # x64 requires PIC for shared libraries. This is opposite |
| 149 # of ia32 where due to a slew of inline assembly using ebx, |
| 150 # FFmpeg CANNOT be built with PIC. |
| 151 'defines': [ |
| 152 'PIC', |
| 153 ], |
| 154 'cflags': [ |
| 155 '-fPIC', |
| 156 ], |
| 157 }], # target_arch == "x64" |
| 158 ['target_arch == "arm"', { |
| 159 'defines': [ |
| 160 'PIC', |
| 161 ], |
| 162 # TODO(ihf): See the long comment in build_ffmpeg.sh |
| 163 # We want to be consistent with CrOS and have configured |
| 164 # ffmpeg for thumb. Protect yourself from -marm. |
| 165 'cflags!': [ |
| 166 '-marm', |
| 167 ], |
| 168 'cflags': [ |
| 169 '-fPIC', |
| 170 '-mthumb', |
| 171 '-march=armv7-a', |
| 172 '-mtune=cortex-a8', |
| 173 '-mfloat-abi=softfp', |
| 174 ], |
| 175 'conditions': [ |
| 176 ['arm_neon == 0', { |
| 177 'cflags': [ |
| 178 '-mfpu=vfpv3-d16', |
| 179 ], |
| 180 }], |
| 181 ['arm_neon == 1', { |
| 182 'cflags': [ |
| 183 '-mfpu=neon', |
| 184 ], |
| 185 }], |
| 186 ], |
| 187 }], |
| 188 ['os_posix == 1 and OS != "mac"', { |
| 189 'defines': [ |
| 190 '_ISOC99_SOURCE', |
| 191 '_LARGEFILE_SOURCE', |
| 192 # BUG(ihf): ffmpeg compiles with this define. But according to |
| 193 # ajwong: I wouldn't change _FILE_OFFSET_BITS. That's a scary c
hange |
| 194 # cause it affects the default length of off_t, and fpos_t, |
| 195 # which can cause strange problems if the loading code doesn't |
| 196 # have it set and you start passing FILE*s or file descriptors |
| 197 # between symbol contexts. |
| 198 # '_FILE_OFFSET_BITS=64', |
| 199 ], |
| 200 'cflags': [ |
| 201 '-std=c99', |
| 202 '-pthread', |
| 203 '-fno-math-errno', |
| 204 '-fno-signed-zeros', |
| 205 '-fno-tree-vectorize', |
| 206 '-fomit-frame-pointer', |
| 207 # Don't warn about libavformat using its own deprecated APIs. |
| 208 '-Wno-deprecated-declarations', |
| 209 ], |
| 210 'cflags!': [ |
| 211 # Ensure the symbols are exported. |
| 212 # |
| 213 # TODO(ajwong): Manually tag the API that we use to be |
| 214 # exported. |
| 215 '-fvisibility=hidden', |
| 216 ], |
| 217 'link_settings': { |
| 218 'ldflags': [ |
| 219 '-Wl,-Bsymbolic', |
| 220 '-L<(shared_generated_dir)', |
| 221 ], |
| 222 'libraries': [ |
| 223 '-lz', |
| 224 ], |
| 225 }, |
| 226 'variables': { |
| 227 'obj_format': 'elf', |
| 228 'conditions': [ |
| 229 [ 'use_system_yasm == 1', { |
| 230 'yasm_path': '<!(which yasm)', |
| 231 }, { |
| 232 'yasm_path': '<(PRODUCT_DIR)/yasm', |
| 233 }], |
| 234 [ 'target_arch == "ia32"', { |
| 235 'yasm_flags': [ |
| 236 '-DARCH_X86_32', |
| 237 # The next two lines are needed to enable AVX assembly. |
| 238 '-Iconfig/<(ffmpeg_branding)/<(os_config)/<(ffmpeg_config)
', |
| 239 '-Pconfig.asm', |
| 240 '-m', 'x86', |
| 241 ], |
| 242 }, { |
| 243 'yasm_flags': [ |
| 244 '-DARCH_X86_64', |
| 245 '-m', 'amd64', |
| 246 '-DPIC', |
| 247 # The next two lines are needed to enable AVX assembly. |
| 248 '-Iconfig/<(ffmpeg_branding)/<(os_config)/<(ffmpeg_config)
', |
| 249 '-Pconfig.asm', |
| 250 ], |
| 251 }], |
| 252 ], |
| 253 }, |
| 254 }], # os_posix == 1 and OS != "mac" |
| 255 ['OS == "openbsd"', { |
| 256 # OpenBSD's gcc (4.2.1) does not support this flag |
| 257 'cflags!': [ |
| 258 '-fno-signed-zeros', |
| 259 ], |
| 260 }], |
| 261 ['OS == "mac"', { |
| 262 'conditions': [ |
| 263 ['mac_breakpad == 1', { |
| 264 'variables': { |
| 265 # A real .dSYM is needed for dump_syms to operate on. |
| 266 'mac_real_dsym': 1, |
| 267 }, |
| 268 }], |
| 269 ], |
| 270 'link_settings': { |
| 271 'libraries': [ |
| 272 '$(SDKROOT)/usr/lib/libz.dylib', |
| 273 ], |
| 274 }, |
| 275 'xcode_settings': { |
| 276 'GCC_SYMBOLS_PRIVATE_EXTERN': 'NO', # No -fvisibility=hidden |
| 277 'GCC_DYNAMIC_NO_PIC': 'YES', # -mdynamic-no-pic |
| 278 # (equiv -fno-PIC) |
| 279 'DYLIB_INSTALL_NAME_BASE': '@loader_path', |
| 280 'LIBRARY_SEARCH_PATHS': [ |
| 281 '<(shared_generated_dir)' |
| 282 ], |
| 283 'OTHER_LDFLAGS': [ |
| 284 # This is needed because FFmpeg cannot be built as PIC, and |
| 285 # thus we need to instruct the linker to allow relocations |
| 286 # for read-only segments for this target to be able to |
| 287 # generated the shared library on Mac. |
| 288 # |
| 289 # This makes Mark sad, but he's okay with it since it is |
| 290 # isolated to this module. When Mark finds this in the |
| 291 # future, and has forgotten this conversation, this comment |
| 292 # should remind him that the world is still nice and |
| 293 # butterflies still exist...as do rainbows, sunshine, |
| 294 # tulips, etc., etc...but not kittens. Those went away |
| 295 # with this flag. |
| 296 '-Wl,-read_only_relocs,suppress', |
| 297 ], |
| 298 }, |
| 299 'variables': { |
| 300 'obj_format': 'macho', |
| 301 'yasm_flags': [ '-DPREFIX' ], |
| 302 'conditions': [ |
| 303 [ 'use_system_yasm == 1', { |
| 304 'yasm_path': '<!(which yasm)', |
| 305 }, { |
| 306 'yasm_path': '<(PRODUCT_DIR)/yasm', |
| 307 }], |
| 308 [ 'target_arch == "ia32"', { |
| 309 'yasm_flags': [ |
| 310 '-DARCH_X86_32', |
| 311 # The next two lines are needed to enable AVX assembly. |
| 312 '-Iconfig/<(ffmpeg_branding)/<(os_config)/<(ffmpeg_config)
', |
| 313 '-Pconfig.asm', |
| 314 '-m', 'x86', |
| 315 ], |
| 316 }, { |
| 317 'yasm_flags': [ |
| 318 '-DARCH_X86_64', |
| 319 '-m', 'amd64', |
| 320 '-DPIC', |
| 321 # The next two lines are needed to enable AVX assembly. |
| 322 '-Iconfig/<(ffmpeg_branding)/<(os_config)/<(ffmpeg_config)
', |
| 323 '-Pconfig.asm', |
| 324 ], |
| 325 }], |
| 326 ], |
| 327 }, |
| 328 }], # OS == "mac" |
| 329 ], |
| 330 'rules': [ |
| 331 { |
| 332 'rule_name': 'assemble', |
| 333 'extension': 'asm', |
| 334 'inputs': [ '<(yasm_path)', ], |
| 335 'outputs': [ |
| 336 '<(shared_generated_dir)/<(RULE_INPUT_ROOT).o', |
| 337 ], |
| 338 'action': [ |
| 339 '<(yasm_path)', |
| 340 '-f', '<(obj_format)', |
| 341 '<@(yasm_flags)', |
| 342 '-I', 'patched-ffmpeg/libavcodec/x86/', |
| 343 '-o', '<(shared_generated_dir)/<(RULE_INPUT_ROOT).o', |
| 344 '<(RULE_INPUT_PATH)', |
| 345 ], |
| 346 'process_outputs_as_sources': 1, |
| 347 'message': 'Build ffmpeg yasm build <(RULE_INPUT_PATH).', |
| 348 }, |
| 349 ], |
| 350 }, |
| 351 ], |
| 352 }], |
| 353 ], # conditions |
| 354 'targets': [ |
| 355 { |
| 356 'variables': { |
| 357 'generate_stubs_script': '../../tools/generate_stubs/generate_stubs.py', |
| 358 'extra_header': 'ffmpeg_stub_headers.fragment', |
| 359 'sig_files': [ |
| 360 # Note that these must be listed in dependency order. |
| 361 # (i.e. if A depends on B, then B must be listed before A.) |
| 362 'avutil-51.sigs', |
| 363 'avcodec-53.sigs', |
| 364 'avformat-53.sigs', |
| 365 ], |
| 366 }, |
| 367 |
| 368 'target_name': 'ffmpeg', |
| 369 'msvs_guid': 'D7A94F58-576A-45D9-A45F-EB87C63ABBB0', |
| 370 'sources': [ |
| 371 # Hacks to introduce C99 types into Visual Studio. |
| 372 'include/win/inttypes.h', |
| 373 'include/win/stdint.h', |
| 374 |
| 375 # Files needed for stub generation rules. |
| 376 '<@(sig_files)', |
| 377 '<(extra_header)' |
| 378 ], |
| 379 'defines': [ |
| 380 '__STDC_CONSTANT_MACROS', # FFmpeg uses INT64_C. |
| 381 ], |
| 382 'hard_dependency': 1, |
| 383 |
| 384 # Do not fear the massive conditional blocks! They do the following: |
| 385 # 1) Use the Window stub generator on Windows |
| 386 # 2) Else, use the POSIX stub generator on non-Windows |
| 387 # a) Use system includes when use_system_ffmpeg != 0 |
| 388 # b) Else, use our local copy in patched-ffmpeg |
| 389 'conditions': [ |
| 390 ['OS == "win"', { |
| 391 'variables': { |
| 392 'outfile_type': 'windows_lib', |
| 393 'output_dir': '<(PRODUCT_DIR)/lib', |
| 394 'intermediate_dir': '<(INTERMEDIATE_DIR)', |
| 395 # TODO(scherkus): Change Windows DEPS directory so we don't need |
| 396 # this conditional. |
| 397 'conditions': [ |
| 398 [ 'ffmpeg_branding == "Chrome"', { |
| 399 'ffmpeg_bin_dir': 'chrome/<(OS)/<(ffmpeg_variant)', |
| 400 }, { # else ffmpeg_branding != "Chrome", assume chromium. |
| 401 'ffmpeg_bin_dir': 'chromium/<(OS)/<(ffmpeg_variant)', |
| 402 }], |
| 403 ], |
| 404 }, |
| 405 'type': 'none', |
| 406 'sources!': [ |
| 407 '<(extra_header)', |
| 408 ], |
| 409 'direct_dependent_settings': { |
| 410 'include_dirs': [ |
| 411 'include/win', |
| 412 'config', |
| 413 'patched-ffmpeg', |
| 414 ], |
| 415 'link_settings': { |
| 416 'libraries': [ |
| 417 '<(output_dir)/avcodec-53.lib', |
| 418 '<(output_dir)/avformat-53.lib', |
| 419 '<(output_dir)/avutil-51.lib', |
| 420 ], |
| 421 'msvs_settings': { |
| 422 'VCLinkerTool': { |
| 423 'DelayLoadDLLs': [ |
| 424 'avcodec-53.dll', |
| 425 'avformat-53.dll', |
| 426 'avutil-51.dll', |
| 427 ], |
| 428 }, |
| 429 }, |
| 430 }, |
| 431 }, |
| 432 'rules': [ |
| 433 { |
| 434 'rule_name': 'generate_libs', |
| 435 'extension': 'sigs', |
| 436 'inputs': [ |
| 437 '<(generate_stubs_script)', |
| 438 '<@(sig_files)', |
| 439 ], |
| 440 'outputs': [ |
| 441 '<(output_dir)/<(RULE_INPUT_ROOT).lib', |
| 442 ], |
| 443 'action': ['python', '<(generate_stubs_script)', |
| 444 '-i', '<(intermediate_dir)', |
| 445 '-o', '<(output_dir)', |
| 446 '-t', '<(outfile_type)', |
| 447 '<@(RULE_INPUT_PATH)', |
| 448 ], |
| 449 'message': 'Generating FFmpeg import libraries.', |
| 450 }, |
| 451 ], |
| 452 |
| 453 # Copy prebuilt binaries to build directory. |
| 454 'dependencies': ['../../build/win/system.gyp:cygwin'], |
| 455 'copies': [{ |
| 456 'destination': '<(PRODUCT_DIR)/', |
| 457 'files': [ |
| 458 'binaries/<(ffmpeg_bin_dir)/avcodec-53.dll', |
| 459 'binaries/<(ffmpeg_bin_dir)/avformat-53.dll', |
| 460 'binaries/<(ffmpeg_bin_dir)/avutil-51.dll', |
| 461 ], |
| 462 }], |
| 463 }, { # else OS != "win", use POSIX stub generator |
| 464 'variables': { |
| 465 'outfile_type': 'posix_stubs', |
| 466 'stubs_filename_root': 'ffmpeg_stubs', |
| 467 'project_path': 'third_party/ffmpeg', |
| 468 'intermediate_dir': '<(INTERMEDIATE_DIR)', |
| 469 'output_root': '<(SHARED_INTERMEDIATE_DIR)/ffmpeg', |
| 470 }, |
| 471 'type': '<(component)', |
| 472 'include_dirs': [ |
| 473 '<(output_root)', |
| 474 '../..', # The chromium 'src' directory. |
| 475 ], |
| 476 'direct_dependent_settings': { |
| 477 'defines': [ |
| 478 '__STDC_CONSTANT_MACROS', # FFmpeg uses INT64_C. |
| 479 ], |
| 480 'include_dirs': [ |
| 481 '<(output_root)', |
| 482 '../..', # The chromium 'src' directory. |
| 483 ], |
| 484 }, |
| 485 'actions': [ |
| 486 { |
| 487 'action_name': 'generate_stubs', |
| 488 'inputs': [ |
| 489 '<(generate_stubs_script)', |
| 490 '<(extra_header)', |
| 491 '<@(sig_files)', |
| 492 ], |
| 493 'outputs': [ |
| 494 '<(intermediate_dir)/<(stubs_filename_root).cc', |
| 495 '<(output_root)/<(project_path)/<(stubs_filename_root).h', |
| 496 ], |
| 497 'action': ['python', |
| 498 '<(generate_stubs_script)', |
| 499 '-i', '<(intermediate_dir)', |
| 500 '-o', '<(output_root)/<(project_path)', |
| 501 '-t', '<(outfile_type)', |
| 502 '-e', '<(extra_header)', |
| 503 '-s', '<(stubs_filename_root)', |
| 504 '-p', '<(project_path)', |
| 505 '<@(_inputs)', |
| 506 ], |
| 507 'process_outputs_as_sources': 1, |
| 508 'message': 'Generating FFmpeg stubs for dynamic loading.', |
| 509 }, |
| 510 ], |
| 511 |
| 512 'conditions': [ |
| 513 # Linux/Solaris need libdl for dlopen() and friends. |
| 514 ['OS == "linux" or OS == "solaris"', { |
| 515 'link_settings': { |
| 516 'libraries': [ |
| 517 '-ldl', |
| 518 ], |
| 519 }, |
| 520 }], |
| 521 |
| 522 ['component == "shared_library"', { |
| 523 'cflags!': ['-fvisibility=hidden'], |
| 524 }], |
| 525 |
| 526 # Add pkg-config result to include path when use_system_ffmpeg != 0 |
| 527 ['use_system_ffmpeg != 0', { |
| 528 'cflags': [ |
| 529 '<!@(pkg-config --cflags libavcodec libavformat libavutil)', |
| 530 ], |
| 531 'direct_dependent_settings': { |
| 532 'cflags': [ |
| 533 '<!@(pkg-config --cflags libavcodec libavformat libavutil)', |
| 534 ], |
| 535 }, |
| 536 }, { # else use_system_ffmpeg == 0, add local copy to include path |
| 537 'include_dirs': [ |
| 538 'config', |
| 539 'patched-ffmpeg', |
| 540 ], |
| 541 'direct_dependent_settings': { |
| 542 'include_dirs': [ |
| 543 'config', |
| 544 'patched-ffmpeg', |
| 545 ], |
| 546 }, |
| 547 'conditions': [ |
| 548 ['build_ffmpegsumo != 0', { |
| 549 'dependencies': [ |
| 550 'ffmpegsumo', |
| 551 ], |
| 552 }], |
| 553 ], |
| 554 }], |
| 555 ], # conditions |
| 556 }], |
| 557 ], # conditions |
| 558 }, |
| 559 ], # targets |
| 560 } |
| OLD | NEW |