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