1# Copyright 2016 Google Inc. 2# 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6import("//build/ohos.gni") 7import("gn/codec.gni") 8import("gn/fuchsia_defines.gni") 9import("gn/shared_sources.gni") 10import("gn/skia.gni") 11import("gn/toolchain/wasm.gni") 12import("../build_overrides/skia.gni") 13import("//build/templates/cxx/prebuilt.gni") 14import("gn/effects.gni") 15import("modules/skottie/skottie.gni") 16 17if (defined(is_mingw) && is_mingw == true) { 18 is_win = true 19} 20 21if (is_fuchsia) { 22 import("${skia_root_dir}/build/fuchsia/sdk.gni") 23 import("build/fuchsia/fuchsia_download_sdk.gni") 24} 25 26if (skia_use_dawn) { 27 import("${skia_third_party_dir}/externals/dawn/scripts/dawn_features.gni") 28} 29 30if (defined(skia_settings)) { 31 import(skia_settings) 32} 33 34import("gn/ios.gni") 35 36config("skia_wno") { 37 cflags = [ 38 "-Wno-deprecated-declarations", 39 "-Wno-pessimizing-move", 40 "-Wno-return-type", 41 "-Wno-sign-compare", 42 "-Wno-sometimes-uninitialized", 43 "-Wno-unknown-pragmas", 44 "-Wno-unused-function", 45 "-Wno-unused-private-field", 46 "-Wno-unused-variable", 47 "-Wno-c++17-extensions", 48 "-std=c++17" 49 ] 50 if (is_ohos && is_clang && (target_cpu == "arm" || target_cpu == "arm64")) { 51 cflags += [ "-flto=thin" ] 52 if (enhanced_opt) { 53 cflags += [ "-fwhole-program-vtables" ] 54 if (skia_feature_enable_pgo && skia_feature_product != "default") { 55 cflags += [ 56 "-fprofile-use=" + 57 rebase_path("${skia_feature_pgo_path}/libskia_canvaskit.profdata", 58 root_build_dir), 59 "-Wno-error=backend-plugin", 60 "-Wno-profile-instr-out-of-date", 61 "-Wno-profile-instr-unprofiled", 62 "-mllvm", 63 "-enable-partial-inlining", 64 ] 65 } 66 if (skia_feature_product == "pc" && target_cpu == "arm64" && 67 current_cpu == "arm64") { 68 cflags += [ "-moutline-atomics" ] 69 } 70 } 71 } 72 73 ldflags = [ 74 "--stdlib=libc++", 75 "-lc++", 76 "-lc++abi", 77 ] 78} 79 80# Skia public API, generally provided by :skia. 81config("skia_public") { 82 include_dirs = [ "." , "./include" ] 83 84 defines = [ 85 "SK_CODEC_DECODES_BMP", 86 "SK_CODEC_DECODES_WBMP", 87 "USE_M133_SKIA", 88 "TODO_M133_SKIA", 89 "SK_USE_LEGACY_BLUR_RASTER", 90 ] 91 if (defined(skia_ohos_debug) && skia_ohos_debug) { 92 defines += [ "SKIA_OHOS_DEBUG" ] 93 } 94 if (use_oh_skia) { 95 defines += [ "ENABLE_TEXT_ENHANCE" ] 96 } 97 cflags_objcc = [] 98 if (is_ohos && (target_cpu == "arm" || target_cpu == "arm64")) { 99 defines += [ 100 "SKIA_OHOS", 101 "SKIA_OHOS_SHADER_REDUCE", 102 "SKIA_DFX_FOR_OHOS", 103 "SKIA_DFX_FOR_RECORD_VKIMAGE", 104 ] 105 } 106 if (is_component_build) { 107 defines += [ "SKIA_DLL" ] 108 } 109 if (is_arkui_x && defined(is_android) && is_android) { 110 defines += [ "SK_BUILD_FOR_ANDROID" ] 111 } 112 if (is_fuchsia || is_linux) { 113 defines += [ "SK_R32_SHIFT=16" ] 114 } 115 if (skia_enable_optimize_size) { 116 defines += [ "SK_ENABLE_OPTIMIZE_SIZE" ] 117 } 118 if (skia_enable_precompile) { 119 defines += [ "SK_ENABLE_PRECOMPILE" ] 120 } 121 if (is_fuchsia) { 122 defines += fuchsia_defines 123 } 124 if (is_wasm) { 125 defines += wasm_defines 126 } 127 if (skia_gl_standard == "gles") { 128 defines += [ "SK_ASSUME_GL_ES=1" ] 129 } else if (skia_gl_standard == "gl") { 130 defines += [ "SK_ASSUME_GL=1" ] 131 } else if (skia_gl_standard == "webgl") { 132 defines += [ "SK_ASSUME_WEBGL=1" ] 133 } 134 if (skia_enable_ganesh) { 135 defines += [ "SK_GANESH" ] 136 } 137 if (skia_enable_graphite) { 138 defines += [ "SK_GRAPHITE" ] 139 } 140 if (skia_disable_tracing) { 141 defines += [ "SK_DISABLE_TRACING" ] 142 } 143 if (skia_use_perfetto) { 144 defines += [ "SK_USE_PERFETTO" ] 145 } 146 if (skia_use_safe_libcxx) { 147 defines += [ "_LIBCPP_ENABLE_ASSERTIONS=1" ] 148 } 149 if (ace_enable_skia_small_page_texture && is_ohos) { 150 defines += [ "SK_ENABLE_SMALL_PAGE" ] 151 } 152 if (is_skia_dev_build && !is_wasm) { 153 defines += [ "GPU_TEST_UTILS=1" ] 154 } 155 156 # Some older versions of the Clang toolchain change the visibility of 157 # symbols decorated with API_AVAILABLE macro to be visible. Users of such 158 # toolchains suppress the use of this macro till toolchain updates are made. 159 if (is_mac) { 160 defines += [ "SK_GL_ENABLE_330_MAC" ] 161 } 162 if (is_mac || is_ios) { 163 if (skia_enable_api_available_macro) { 164 defines += [ "SK_ENABLE_API_AVAILABLE" ] 165 } else { 166 cflags_objcc += [ "-Wno-unguarded-availability" ] 167 } 168 } 169 170 if (is_win) { 171 defines += [ "SK_BUILD_FOR_WIN" ] 172 } 173 174 # OH ISSUE: jpeg optimize 175 if (target_platform == "pc") { 176 defines += [ "TURBO_JPEG_HUFF_DECODE_OPT" ] 177 defines += [ "TURBO_PNG_MULTY_LINE_OPT" ] 178 } 179 180 if (skia_vk_enable_partialrender) { 181 defines += [ "SK_VK_PARTIALRENDER" ] 182 } 183 184 if (is_ohos) { 185 if (!build_ohos_sdk && !is_arkui_x) { 186 if (defined(defines)) { 187 defines += [ "NOT_BUILD_FOR_OHOS_SDK" ] 188 } else { 189 defines = [ "NOT_BUILD_FOR_OHOS_SDK" ] 190 } 191 } 192 } 193} 194 195# Skia internal APIs, used by Skia itself and a few test tools. 196config("skia_private") { 197 visibility = [ "./*", "../*" ] 198 cflags = [ 199 "-Wno-format", 200 ] 201 202 cflags_cc = [ 203 "-Wno-array-parameter", 204 "-fvisibility-inlines-hidden", 205 "-std=c++17", 206 "-Wno-unknown-pragmas", 207 ] 208 209 defines = [ "SK_GAMMA_APPLY_TO_A8" ] 210 if (target_cpu == "x86_64" || current_os == "windows" || 211 current_os == "mac" || current_os == "linux" || current_os == "ios") { 212 cflags_cc += [ "-Wno-psabi" ] 213 } 214 if (skia_use_fixed_gamma_text) { 215 defines += [ 216 "SK_GAMMA_EXPONENT=1.0", 217 "SK_GAMMA_CONTRAST=0.0", 218 ] 219 } 220 if (is_skia_dev_build && !is_wasm) { 221 defines += [ "SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=1" ] 222 } 223 libs = [] 224 lib_dirs = [] 225 if (skia_use_gl && skia_use_angle) { 226 defines += [ "SK_ANGLE" ] 227 } 228 if (skia_use_vma) { 229 defines += [ "SK_USE_VMA" ] 230 } 231 if (skia_enable_winuwp) { 232 defines += [ "SK_WINUWP" ] 233 } 234 if (skia_print_sksl_shaders) { 235 defines += [ "SK_PRINT_SKSL_SHADERS" ] 236 } 237 if (skia_print_native_shaders) { 238 defines += [ "SK_PRINT_NATIVE_SHADERS" ] 239 } 240 241 # Temporary staging flag: 242 defines += [ "SK_ENABLE_AVX512_OPTS" ] 243} 244 245# Any code that's linked into Skia-the-library should use this config via += skia_library_configs. 246config("skia_library") { 247 # visibility = [ "./*" ] 248 defines = [ "SKIA_IMPLEMENTATION=1" ] 249} 250 251skia_library_configs = [ 252 ":skia_public", 253 ":skia_private", 254 ":skia_library", 255] 256 257# Use for CPU-specific Skia code that needs particular compiler flags. 258template("opts") { 259 if (invoker.enabled) { 260 skia_source_set(target_name) { 261 # visibility = [ ":*" ] 262 check_includes = false 263 configs = skia_library_configs 264 forward_variables_from(invoker, "*") 265 if (defined(invoker.configs)) { 266 configs += invoker.configs 267 } 268 } 269 } else { 270 # If not enabled, a phony empty target that swallows all otherwise unused variables. 271 skia_source_set(target_name) { 272 # visibility = [ ":*" ] 273 check_includes = false 274 forward_variables_from(invoker, 275 "*", 276 [ 277 "sources", 278 "cflags", 279 ]) 280 } 281 } 282} 283 284is_x86 = current_cpu == "x64" || current_cpu == "x86" || current_cpu == "x86_64" 285is_loong64 = current_cpu == "loong64" 286opts("none") { 287 enabled = !is_x86 && current_cpu != "arm" && current_cpu != "arm64" 288 sources = skia_opts.none_sources 289 cflags = [] 290} 291 292opts("armv7") { 293 enabled = current_cpu == "arm" 294 sources = skia_opts.armv7_sources + skia_opts.neon_sources 295 cflags = [] 296} 297 298opts("arm64") { 299 enabled = current_cpu == "arm64" 300 sources = skia_opts.arm64_sources 301 cflags = [] 302} 303 304opts("crc32") { 305 enabled = current_cpu == "arm64" 306 sources = skia_opts.crc32_sources 307 cflags = [ "-march=armv8-a+crc" ] 308} 309opts("sse2") { 310 enabled = is_x86 311 sources = skia_opts.sse2_sources 312 if (!is_clang && is_win) { 313 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE2" ] 314 } else { 315 cflags = [ "-msse2" ] 316 } 317} 318 319opts("ssse3") { 320 enabled = is_x86 321 sources = skia_opts.ssse3_sources 322 if (!is_clang && is_win) { 323 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSSE3" ] 324 } else { 325 cflags = [ "-mssse3" ] 326 } 327} 328 329opts("sse41") { 330 enabled = is_x86 331 sources = skia_opts.sse41_sources 332 if (!is_clang && is_win) { 333 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE41" ] 334 } else { 335 cflags = [ "-msse4.1" ] 336 } 337} 338 339opts("sse42") { 340 enabled = is_x86 341 sources = skia_opts.sse42_sources 342 if (!is_clang && is_win) { 343 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE42" ] 344 } else { 345 cflags = [ "-msse4.2" ] 346 } 347} 348 349opts("hsw") { 350 enabled = is_x86 351 sources = skia_opts.hsw_sources 352 if (is_win && !is_mingw) { 353 cflags = [ "/arch:AVX2" ] 354 } else { 355 cflags = [ "-march=haswell", "-mavx" ] 356 } 357} 358 359opts("skx") { 360 enabled = is_x86 361 sources = skia_opts.skx_sources 362 if (is_win && !is_mingw) { 363 cflags = [ "/arch:AVX512" ] 364 } else { 365 cflags = [ "-march=skylake-avx512", "-mavx" ] 366 } 367} 368 369opts("lasx") { 370 enabled = is_loong64 371 sources = skia_opts.lasx_sources 372 cflags = [ "-mlasx" ] 373} 374 375config("harfbuzz_config") { 376 include_dirs = [ "${skia_root_dir}/third_party/externals/harfbuzz/src" ] 377 378 defines = [ 379 "HAVE_ICU", 380 "HAVE_ICU_BUILTIN", 381 "HAVE_OT", 382 "HAVE_CONFIG_OVERRIDE_H", 383 "HB_NO_FALLBACK_SHAPE", 384 "HB_NO_WIN1256", 385 ] 386} 387 388config("icu_config") { 389 if (is_arkui_x) { 390 include_dirs = [ "//third_party/icu/icu4c/source/common" ] 391 } else { 392 include_dirs = [ "${skia_third_party_dir}/externals/icu/source/common" ] 393 } 394} 395 396# Any feature of Skia that requires third-party code should be optional and use this template. 397template("optional") { 398 if (invoker.enabled) { 399 config(target_name + "_public") { 400 if (defined(invoker.public_defines)) { 401 defines = invoker.public_defines 402 } 403 if (defined(invoker.public_configs)) { 404 configs = invoker.public_configs 405 } 406 } 407 skia_source_set(target_name) { 408 # visibility = [ ":*" ] 409 check_includes = false 410 configs = skia_library_configs 411 configs += [ ":skia_wno" ] 412 413 # "*" clobbers the current scope; append to existing configs 414 forward_variables_from(invoker, 415 "*", 416 [ 417 "configs", 418 "public_defines", 419 "sources_for_tests", 420 "sources_when_disabled", 421 ]) 422 if (defined(invoker.configs)) { 423 configs += invoker.configs 424 } 425 public_configs = [ ":" + target_name + "_public" ] 426 } 427 if (defined(invoker.sources_for_tests) && skia_enable_tools) { 428 skia_source_set(target_name + "_tests") { 429 # visibility = [ ":*" ] 430 check_includes = false 431 configs = skia_library_configs 432 433 # "*" clobbers the current scope; append to existing configs 434 forward_variables_from(invoker, 435 "*", 436 [ 437 "configs", 438 "public_defines", 439 "sources", 440 "sources_for_tests", 441 "sources_when_disabled", 442 ]) 443 if (defined(invoker.configs)) { 444 configs += invoker.configs 445 } 446 testonly = true 447 sources = invoker.sources_for_tests 448 if (!defined(deps)) { 449 deps = [] 450 } 451 deps += [ 452 ":test", 453 ":" + target_name, 454 ] 455 public_configs = [ ":" + target_name + "_public" ] 456 } 457 } 458 } else { 459 skia_source_set(target_name) { 460 # visibility = [ ":*" ] 461 configs = skia_library_configs 462 463 # "*" clobbers the current scope; append to existing configs 464 forward_variables_from(invoker, 465 "*", 466 [ 467 "configs", 468 "public", 469 "public_defines", 470 "public_deps", 471 "deps", 472 "libs", 473 "frameworks", 474 "sources", 475 "sources_for_tests", 476 "sources_when_disabled", 477 ]) 478 if (defined(invoker.configs)) { 479 configs += invoker.configs 480 } 481 if (defined(invoker.sources_when_disabled)) { 482 sources = invoker.sources_when_disabled 483 } 484 } 485 if (defined(invoker.sources_for_tests)) { 486 skia_source_set(target_name + "_tests") { 487 # visibility = [ ":*" ] 488 } 489 } 490 } 491} 492 493optional("android_utils") { 494 enabled = skia_enable_android_utils 495 496 public = [ 497 "client_utils/android/BRDAllocator.h", 498 "client_utils/android/BitmapRegionDecoder.h", 499 "client_utils/android/FrontBufferedStream.h", 500 ] 501 public_defines = [ "SK_ENABLE_ANDROID_UTILS" ] 502 sources = [ 503 "client_utils/android/BitmapRegionDecoder.cpp", 504 "client_utils/android/FrontBufferedStream.cpp", 505 ] 506} 507 508optional("fontmgr_android") { 509 enabled = skia_enable_fontmgr_android 510 deps = [ 511 ":typeface_freetype", 512 ":typeface_proxy", 513 ] 514 if (skia_feature_upgrade) { 515 deps += ["${skia_third_party_dir}/expat:expatm133"] 516 } else { 517 deps += ["${skia_third_party_dir}/expat"] 518 } 519 public_defines = [ "SK_FONTMGR_ANDROID_AVAILABLE" ] 520 public = skia_ports_fontmgr_android_public 521 sources = skia_ports_fontmgr_android_sources 522 if (is_arkui_x) { 523 defines = [ "CROSS_PLATFORM" ] 524 deps += [ 525 "//third_party/bounds_checking_function:libsec_static", 526 "//third_party/jsoncpp:jsoncpp_static", 527 ] 528 include_dirs = [ 529 "//third_party/jsoncpp/include", 530 "${skia_root_dir}/src/ports/skia_ohos", 531 ] 532 if (is_arkui_x) { 533 sources += [ "src/ports/skia_ohos/HmSymbolConfig_ohos.cpp" ] 534 } 535 } 536 sources_for_tests = [ "tests/FontMgrAndroidParserTest.cpp" ] 537} 538 539# if building Skia for API >= 30 and not using custom fonts, enable 540# skia_enable_fontmgr_android_ndk and disable skia_enable_fontmgr_android 541optional("fontmgr_android_ndk") { 542 enabled = skia_enable_fontmgr_android_ndk 543 544 deps = [ 545 ":typeface_freetype", 546 ":typeface_proxy", 547 ] 548 libs = [ "android" ] 549 public_defines = [ "SK_FONTMGR_ANDROID_NDK_AVAILABLE" ] 550 public = skia_ports_fontmgr_android_ndk_public 551 sources = skia_ports_fontmgr_android_ndk_sources 552} 553 554optional("fontmgr_symbol_load") { 555 enabled = skia_enable_fontmgr_ohos || skia_enable_fontmgr_win || 556 skia_use_fonthost_mac 557 include_dirs = [ 558 "${skia_root_dir}/include/private", 559 "${skia_root_dir}/include/core", 560 "${skia_root_dir}/src/core", 561 "${skia_root_dir}/src/ports", 562 "${skia_root_dir}/src/ports/skia_ohos", 563 ] 564 deps = [ 565 ":typeface_freetype", 566 ] 567 if (skia_feature_upgrade) { 568 deps += ["${skia_third_party_dir}/expat:expatm133"] 569 } else { 570 deps += ["${skia_third_party_dir}/expat"] 571 } 572 if (is_arkui_x) { 573 deps += [ 574 "//third_party/bounds_checking_function:libsec_static", 575 "//third_party/jsoncpp:jsoncpp_static", 576 ] 577 } else { 578 external_deps = [ "jsoncpp:jsoncpp" ] 579 if (is_component_build) { 580 external_deps += [ "bounds_checking_function:libsec_shared" ] 581 } else { 582 external_deps += [ "bounds_checking_function:libsec_static" ] 583 } 584 } 585 586 deps += [ 587 ":ohos_font_file_map.json", 588 ":ohos_fontconfig.json", 589 ":ohos_fontconfig_old.json", 590 ] 591 if (skia_feature_product == "wearable") { 592 deps += [ ":ohos_fontconfig_wearable.json" ] 593 } 594 public = [ "src/ports/skia_ohos/HmSymbolConfig_ohos.h" ] 595 sources = [ "src/ports/skia_ohos/HmSymbolConfig_ohos.cpp" ] 596} 597 598group("fontmgr_factory") { 599 public_deps = [ skia_fontmgr_factory ] 600} 601 602optional("fontmgr_custom") { 603 enabled = 604 skia_enable_fontmgr_custom_directory || 605 skia_enable_fontmgr_custom_embedded || skia_enable_fontmgr_custom_empty 606 607 deps = [ ":typeface_freetype" ] 608 sources = skia_ports_fontmgr_custom_sources 609} 610 611optional("fontmgr_custom_directory") { 612 enabled = skia_enable_fontmgr_custom_directory 613 public_defines = [ "SK_FONTMGR_FREETYPE_DIRECTORY_AVAILABLE" ] 614 deps = [ 615 ":fontmgr_custom", 616 ":typeface_freetype", 617 ] 618 public = skia_ports_fontmgr_directory_public 619 sources = skia_ports_fontmgr_directory_sources 620} 621 622optional("fontmgr_custom_directory_factory") { 623 enabled = skia_enable_fontmgr_custom_directory 624 deps = [ ":fontmgr_custom_directory" ] 625 sources = [ "src/ports/SkFontMgr_custom_directory_factory.cpp" ] 626 if (use_linux) { 627 defines = [ "SK_BUILD_FONT_MGR_FOR_PREVIEW_LINUX" ] 628 } 629 if (is_arkui_x) { 630 sources -= [ "src/ports/SkFontMgr_custom_directory_factory.cpp" ] 631 } 632} 633 634optional("fontmgr_custom_embedded") { 635 enabled = skia_enable_fontmgr_custom_embedded 636 public_defines = [ "SK_FONTMGR_FREETYPE_EMBEDDED_AVAILABLE" ] 637 deps = [ 638 ":fontmgr_custom", 639 ":typeface_freetype", 640 ] 641 public = skia_ports_fontmgr_embedded_public 642 sources = skia_ports_fontmgr_embedded_sources 643} 644 645optional("fontmgr_custom_embedded_factory") { 646 enabled = skia_enable_fontmgr_custom_embedded 647 deps = [ ":fontmgr_custom_embedded" ] 648 sources = [ "src/ports/SkFontMgr_custom_embedded_factory.cpp" ] 649} 650 651optional("fontmgr_custom_empty") { 652 enabled = skia_enable_fontmgr_custom_empty 653 public_defines = [ "SK_FONTMGR_FREETYPE_EMPTY_AVAILABLE" ] 654 deps = [ 655 ":fontmgr_custom", 656 ":typeface_freetype", 657 ] 658 public = skia_ports_fontmgr_empty_public 659 sources = skia_ports_fontmgr_empty_sources 660} 661 662optional("fontmgr_custom_empty_factory") { 663 enabled = skia_enable_fontmgr_custom_empty 664 deps = [ ":fontmgr_custom_empty" ] 665 sources = [ "src/ports/SkFontMgr_custom_empty_factory.cpp" ] 666} 667 668skia_source_set("typeface_proxy") { 669 configs = [ ":skia_public" ] 670 sources = skia_ports_typeface_proxy_sources 671} 672 673optional("fontmgr_fontconfig") { 674 if (use_oh_skia) { 675 enabled = false 676 } else { 677 enabled = skia_enable_fontmgr_fontconfig 678 } 679 public_defines = [ "SK_FONTMGR_FONTCONFIG_AVAILABLE" ] 680 681 # The public header includes fontconfig.h and uses FcConfig* 682 public_deps = [ "${skia_third_party_dir}:fontconfig" ] 683 public = skia_ports_fontmgr_fontconfig_public 684 deps = [ 685 ":typeface_freetype", 686 ":typeface_proxy", 687 ] 688 sources = skia_ports_fontmgr_fontconfig_sources 689 sources_for_tests = [ "tests/FontMgrFontConfigTest.cpp" ] 690} 691 692skia_source_set("fontscanner_tests") { 693 testonly = true 694 695 deps = [ ":skia" ] 696 sources = [ 697 "tests/FontScanner.cpp", 698 "tests/FontScanner.h", 699 ] 700 if (is_ohos) { 701 external_deps = [ "hitrace:hitrace_meter" ] 702 if (!build_ohos_sdk && !is_arkui_x) { 703 external_deps += [ "init:libbegetutil" ] 704 } 705 } 706 if (is_arkui_x) { 707 deps += [ "//third_party/bounds_checking_function:libsec_static" ] 708 } else if (is_ohos) { 709 if (is_component_build) { 710 external_deps += [ "bounds_checking_function:libsec_shared" ] 711 } else { 712 external_deps += [ "bounds_checking_function:libsec_static" ] 713 } 714 } 715} 716 717optional("fontmgr_FontConfigInterface") { 718 if (use_oh_skia) { 719 enabled = false 720 } else { 721 enabled = skia_enable_fontmgr_FontConfigInterface 722 } 723 public_defines = [ "SK_FONTMGR_FCI_AVAILABLE" ] 724 deps = [ 725 ":typeface_freetype", 726 "${skia_third_party_dir}:fontconfig", 727 ] 728 public = skia_ports_fci_public 729 sources = skia_ports_fci_sources 730 sources_for_tests = [ "tests/FCITest.cpp" ] 731} 732 733optional("fontmgr_fontations_empty") { 734 enabled = skia_use_fontations 735 public_defines = [ "SK_FONTMGR_FONTATIONS_AVAILABLE" ] 736 737 deps = [ ":typeface_fontations" ] 738 public = skia_ports_fontmgr_fontations_public 739 sources = skia_ports_fontmgr_fontations_sources 740} 741 742optional("fontmgr_fuchsia") { 743 enabled = skia_enable_fontmgr_fuchsia 744 public_defines = [ "SK_FONTMGR_FUCHSIA_AVAILABLE" ] 745 deps = [] 746 747 if (is_fuchsia && using_fuchsia_sdk) { 748 deps += [ "${skia_root_dir}/build/fuchsia/fidl:fuchsia.fonts" ] 749 } else { 750 deps = [ "//sdk/fidl/fuchsia.fonts" ] 751 } 752 public = skia_ports_fontmgr_fuchsia_public 753 sources = skia_ports_fontmgr_fuchsia_sources 754} 755 756optional("fontmgr_mac_ct") { 757 enabled = skia_use_fonthost_mac 758 defines = [] 759 deps = [] 760 if (is_arkui_x) { 761 deps += [ 762 "//third_party/bounds_checking_function:libsec_static", 763 "//third_party/jsoncpp:jsoncpp_static", 764 ] 765 defines += [ "CROSS_PLATFORM" ] 766 include_dirs = [ 767 "//third_party/jsoncpp/include", 768 "${skia_root_dir}/skia/src/ports/skia_ohos", 769 ] 770 } 771 public_defines = [ 772 "SK_TYPEFACE_FACTORY_CORETEXT", 773 "SK_FONTMGR_CORETEXT_AVAILABLE", 774 ] 775 public = skia_ports_fontmgr_coretext_public 776 sources = skia_ports_fontmgr_coretext_sources 777 if (is_arkui_x) { 778 sources += [ 779 "src/ports/SkFontMgr_android_parser.cpp", 780 "src/ports/skia_ohos/HmSymbolConfig_ohos.cpp", 781 ] 782 } 783 sources_for_tests = [ "tests/TypefaceMacTest.cpp" ] 784 785 if (use_oh_skia && !is_arkui_x) { 786 # Use hos font 787 sources += [ 788 "${skia_root_dir}/src/ports/SkFontMgr_config_parser.cpp", 789 "${skia_root_dir}/src/ports/SkFontMgr_config_parser.h", 790 "${skia_root_dir}/src/ports/SkFontMgr_preview.cpp", 791 "${skia_root_dir}/src/ports/SkFontMgr_preview.h", 792 ] 793 794 defines += [ "SK_BUILD_FONT_MGR_FOR_PREVIEW_MAC" ] 795 if (!is_arkui_x) { 796 external_deps = [ "jsoncpp:jsoncpp" ] 797 } 798 deps += [ 799 ":fontmgr_symbol_load", 800 ] 801 } 802 803 if (is_mac) { 804 frameworks = [ 805 # AppKit symbols NSFontWeightXXX may be dlsym'ed. 806 "AppKit.framework", 807 "ApplicationServices.framework", 808 ] 809 } 810 811 if (is_ios) { 812 frameworks = [ 813 "CoreFoundation.framework", 814 "CoreGraphics.framework", 815 "CoreText.framework", 816 817 # UIKit symbols UIFontWeightXXX may be dlsym'ed. 818 "UIKit.framework", 819 ] 820 } 821} 822 823optional("fontmgr_mac_ct_factory") { 824 enabled = skia_use_fonthost_mac 825 deps = [ ":fontmgr_mac_ct" ] 826 sources = [ "src/ports/SkFontMgr_mac_ct_factory.cpp" ] 827 defines = [ "SK_BUILD_FONT_MGR_FOR_PREVIEW_MAC" ] 828 if (is_arkui_x) { 829 defines += [ "USE_DEFAULT_FONT" ] 830 } 831} 832 833optional("fontmgr_empty_factory") { 834 if (use_oh_skia) { 835 enabled = false 836 } else { 837 enabled = true 838 } 839 sources = [ "src/ports/SkFontMgr_empty_factory.cpp" ] 840} 841 842optional("fontmgr_android_factory") { 843 enabled = skia_enable_fontmgr_android 844 deps = [ ":fontmgr_android" ] 845 sources = [ "src/ports/SkFontMgr_android_factory.cpp" ] 846} 847 848optional("fontmgr_win_factory") { 849 enabled = skia_enable_fontmgr_win 850 deps = [ ":fontmgr_win" ] 851 sources = [ "src/ports/SkFontMgr_win_dw_factory.cpp" ] 852 defines = [ "SK_BUILD_FONT_MGR_FOR_PREVIEW_WIN" ] 853} 854 855 856optional("fontmgr_fontconfig_factory") { 857 if (use_oh_skia) { 858 enabled = false 859 } else { 860 enabled = skia_enable_fontmgr_fontconfig 861 } 862 863 deps = [ ":fontmgr_fontconfig" ] 864 sources = [ "src/ports/SkFontMgr_fontconfig_factory.cpp" ] 865} 866 867optional("fontmgr_win") { 868 enabled = skia_enable_fontmgr_win 869 870 public_defines = [ 871 "SK_TYPEFACE_FACTORY_DIRECTWRITE", 872 "SK_FONTMGR_DIRECTWRITE_AVAILABLE", 873 ] 874 public = skia_ports_windows_fonts_public 875 sources = skia_ports_windows_fonts_sources 876 if (skia_dwritecore_sdk != "") { 877 defines = [ "DWRITE_CORE" ] 878 if (is_win && is_clang) { 879 # Clang complains about these headers, so mark them as system. These 880 # headers are hiding SDK headers of the same name, which are also 881 # included as system headers, so these need to go first in the cflags 882 # "includes" before the SDK. gn appends configs in the order listed, 883 # so these flags will be first. 884 cflags = [ 885 "-imsvc", 886 "${skia_dwritecore_sdk}/include", 887 ] 888 } else { 889 include_dirs = [ "${skia_dwritecore_sdk}/include" ] 890 } 891 } 892 if (use_oh_skia) { 893 # Use hos font 894 sources += [ 895 "${skia_root_dir}/src/ports/SkFontMgr_config_parser.cpp", 896 "${skia_root_dir}/src/ports/SkFontMgr_config_parser.h", 897 "${skia_root_dir}/src/ports/SkFontMgr_preview.cpp", 898 "${skia_root_dir}/src/ports/SkFontMgr_preview.h", 899 ] 900 901 defines = [ "SK_BUILD_FONT_MGR_FOR_PREVIEW_WIN" ] 902 deps = [ 903 ":fontmgr_symbol_load", 904 ] 905 deps += ["${skia_third_party_dir}/expat:expatm133"] 906 if (is_arkui_x) { 907 deps += [ "//third_party/jsoncpp:jsoncpp_static" ] 908 } else { 909 external_deps = [ "jsoncpp:jsoncpp" ] 910 } 911 } 912} 913 914if (use_oh_skia && !is_arkui_x) { 915 ohos_prebuilt_etc("ohos_fontconfig.json") { 916 source = 917 "${skia_root_dir}/src/ports/skia_ohos/config/fontconfig_ohos.json" 918 part_name = "skia" 919 subsystem_name = "thirdparty" 920 } 921 922 ohos_prebuilt_etc("ohos_fontconfig_old.json") { 923 source = "${skia_root_dir}/src/ports/skia_ohos/config/fontconfig.json" 924 part_name = "skia" 925 subsystem_name = "thirdparty" 926 } 927 928 ohos_prebuilt_etc("ohos_font_file_map.json") { 929 source = "${skia_root_dir}/src/ports/skia_ohos/config/font_file_map.json" 930 part_name = "skia" 931 subsystem_name = "thirdparty" 932 } 933 934 ohos_prebuilt_etc("ohos_fontconfig_wearable.json") { 935 source = "${skia_root_dir}/src/ports/skia_ohos/config/fontconfig_ohos_wearable.json" 936 output = "fontconfig_ohos.json" 937 part_name = "skia" 938 subsystem_name = "thirdparty" 939 } 940 941 optional("fontmgr_ohos") { 942 enabled = skia_enable_fontmgr_ohos 943 944 public = [ 945 "src/ports/skia_ohos/FontConfig_ohos.h", 946 "src/ports/skia_ohos/FontInfo_ohos.h", 947 "src/ports/skia_ohos/SkFontMgr_ohos.h", 948 "src/ports/skia_ohos/SkFontStyleSet_ohos.h", 949 "src/ports/skia_ohos/SkTypeface_ohos.h", 950 ] 951 sources = [ 952 "src/ports/skia_ohos/FontConfig_ohos.cpp", 953 "src/ports/skia_ohos/SkFontMgr_ohos.cpp", 954 "src/ports/skia_ohos/SkFontMgr_ohos_factory.cpp", 955 "src/ports/skia_ohos/SkFontStyleSet_ohos.cpp", 956 "src/ports/skia_ohos/SkTypeface_ohos.cpp", 957 ] 958 959 include_dirs = [ 960 "${skia_root_dir}/include/private", 961 "${skia_root_dir}/include/private/base", 962 "${skia_root_dir}/include/core", 963 "${skia_root_dir}/src/core", 964 "${skia_root_dir}/src/ports", 965 "${skia_root_dir}/src/ports/skia_ohos", 966 ] 967 968 deps = [ 969 ":fontmgr_symbol_load", 970 ":typeface_freetype", 971 ] 972 if (skia_feature_upgrade) { 973 deps += ["${skia_third_party_dir}/expat:expatm133"] 974 } else { 975 deps += ["${skia_third_party_dir}/expat"] 976 } 977 external_deps = [ "jsoncpp:jsoncpp" ] 978 if (is_component_build) { 979 external_deps += [ "bounds_checking_function:libsec_shared" ] 980 } else { 981 external_deps += [ "bounds_checking_function:libsec_static" ] 982 } 983 984 deps += [ 985 ":ohos_font_file_map.json", 986 ":ohos_fontconfig.json", 987 ":ohos_fontconfig_old.json", 988 ] 989 if (skia_feature_product == "wearable") { 990 deps += [ ":ohos_fontconfig_wearable.json" ] 991 } 992 993 if (skia_feature_wuji_enable) { 994 deps += [ "$ace_graphic_ext:ohos_fonts_wuji" ] 995 } else if (skia_enable_standard_fonts) { 996 deps += [] 997 } 998 999 if (use_mingw_win) { 1000 defines = [ "SK_BUILD_FONT_MGR_FOR_PREVIEW_WIN" ] 1001 } else if (use_mac) { 1002 defines = [ "SK_BUILD_FONT_MGR_FOR_PREVIEW_MAC" ] 1003 } else if (use_linux) { 1004 defines = [ "SK_BUILD_FONT_MGR_FOR_PREVIEW_LINUX" ] 1005 } else if (is_ohos) { 1006 external_deps += [ "init:libbegetutil" ] 1007 defines = [ "SK_BUILD_FONT_MGR_FOR_OHOS" ] 1008 } 1009 } 1010} 1011 1012optional("fontmgr_win_gdi") { 1013 enabled = skia_enable_fontmgr_win_gdi 1014 public_defines = [ "SK_FONTMGR_GDI_AVAILABLE" ] 1015 public = skia_ports_windows_fonts_public 1016 sources = skia_ports_fonthost_win_sources 1017 # libs = [ "Gdi32.lib" ] 1018 libs = [ "gdi32" ] 1019} 1020 1021if (skia_lex) { 1022 skia_executable("sksllex") { 1023 sources = [ 1024 "src/sksl/lex/DFA.h", 1025 "src/sksl/lex/DFAState.h", 1026 "src/sksl/lex/LexUtil.h", 1027 "src/sksl/lex/Main.cpp", 1028 "src/sksl/lex/NFA.cpp", 1029 "src/sksl/lex/NFA.h", 1030 "src/sksl/lex/NFAState.h", 1031 "src/sksl/lex/NFAtoDFA.h", 1032 "src/sksl/lex/RegexNode.cpp", 1033 "src/sksl/lex/RegexNode.h", 1034 "src/sksl/lex/RegexParser.cpp", 1035 "src/sksl/lex/RegexParser.h", 1036 "src/sksl/lex/TransitionTable.cpp", 1037 "src/sksl/lex/TransitionTable.h", 1038 ] 1039 include_dirs = [ "." ] 1040 } 1041 1042 action("run_sksllex") { 1043 script = "gn/run_sksllex.py" 1044 deps = [ ":sksllex(${skia_root_dir}/gn/toolchain:$host_toolchain)" ] 1045 sources = [ "src/sksl/lex/sksl.lex" ] 1046 1047 # GN insists its outputs should go somewhere underneath target_out_dir, so we trick it with a 1048 # path that starts with target_out_dir and then uses ".." to back up into the src dir. 1049 outputs = [ 1050 "$target_out_dir/" + rebase_path("src/sksl/SkSLLexer.h", target_out_dir), 1051 # the script also modifies the corresponding .cpp file, but if we tell GN that it gets 1052 # confused due to the same file being named by two different paths 1053 ] 1054 sksllex_path = "$root_out_dir/" 1055 if (host_toolchain != default_toolchain_name) { 1056 sksllex_path += "$host_toolchain/" 1057 } 1058 sksllex_path += "sksllex" 1059 if (host_os == "win") { 1060 sksllex_path += ".exe" 1061 } 1062 args = [ 1063 rebase_path(sksllex_path), 1064 rebase_path("bin/clang-format"), 1065 rebase_path("bin/fetch-clang-format"), 1066 rebase_path("src"), 1067 ] 1068 } 1069} else { 1070 group("run_sksllex") { 1071 } 1072} 1073 1074if (skia_compile_modules || skia_compile_sksl_tests) { 1075 # Copy the module source files into the same directory as skslc. 1076 copy("sksl_modules") { 1077 sources = [ 1078 "src/sksl/sksl_compute.sksl", 1079 "src/sksl/sksl_frag.sksl", 1080 "src/sksl/sksl_gpu.sksl", 1081 "src/sksl/sksl_graphite_frag.sksl", 1082 "src/sksl/sksl_graphite_frag_es2.sksl", 1083 "src/sksl/sksl_graphite_vert.sksl", 1084 "src/sksl/sksl_graphite_vert_es2.sksl", 1085 "src/sksl/sksl_public.sksl", 1086 "src/sksl/sksl_rt_shader.sksl", 1087 "src/sksl/sksl_shared.sksl", 1088 "src/sksl/sksl_vert.sksl", 1089 ] 1090 skslc_dir = "$root_out_dir/" 1091 if (host_toolchain != default_toolchain_name) { 1092 skslc_dir += "$host_toolchain/" 1093 } 1094 outputs = [ "$skslc_dir/{{source_file_part}}" ] 1095 } 1096} 1097 1098if (skia_compile_modules) { 1099 # Generate the sksl-minify binary. 1100 skia_executable("sksl-minify") { 1101 defines = [ 1102 "SKSL_STANDALONE", 1103 "SK_DISABLE_TRACING", 1104 ] 1105 sources = skslc_deps 1106 sources += [ 1107 "tools/sksl-minify/SkSLMinify.cpp", 1108 "tools/skslc/ProcessWorklist.cpp", 1109 "tools/skslc/ProcessWorklist.h", 1110 ] 1111 libs = [] 1112 if (is_win) { 1113 sources += [ "src/utils/SkGetExecutablePath_win.cpp" ] 1114 } else if (is_mac || is_ios) { 1115 sources += [ "src/utils/SkGetExecutablePath_mac.cpp" ] 1116 } else if (is_linux || is_android) { 1117 sources += [ "src/utils/SkGetExecutablePath_linux.cpp" ] 1118 } 1119 if (is_win) { 1120 sources += skia_ports_windows_sources 1121 } else { 1122 sources += [ "src/ports/SkOSFile_posix.cpp" ] 1123 libs += [ "dl" ] 1124 } 1125 sources += skia_sksl_core_sources 1126 sources += skia_sksl_codegen_sources 1127 include_dirs = [ "." ] 1128 deps = [ ":run_sksllex" ] 1129 if (is_ohos) { 1130 external_deps = [ "hitrace:hitrace_meter" ] 1131 if (!build_ohos_sdk && !is_arkui_x) { 1132 external_deps += [ "init:libbegetutil" ] 1133 } 1134 } 1135 if (is_arkui_x) { 1136 deps += [ "//third_party/bounds_checking_function:libsec_static" ] 1137 } else if (is_ohos) { 1138 if (is_component_build) { 1139 external_deps += [ "bounds_checking_function:libsec_shared" ] 1140 } else { 1141 external_deps += [ "bounds_checking_function:libsec_static" ] 1142 } 1143 } 1144 } 1145 1146 sksl_minify_path = "$root_out_dir/" 1147 if (host_toolchain != default_toolchain_name) { 1148 sksl_minify_path += "$host_toolchain/" 1149 } 1150 sksl_minify_path += "sksl-minify" 1151 if (host_os == "win") { 1152 sksl_minify_path += ".exe" 1153 } 1154 1155 # Use minify_sksl.py to precompile all of the modules. 1156 minify_sksl_sources = get_target_outputs(":sksl_modules") 1157 1158 minify_sksl_outputs = [] 1159 foreach(src, minify_sksl_sources) { 1160 name = get_path_info(src, "name") 1161 1162 # GN insists its outputs should go somewhere underneath target_out_dir, so we trick it with a 1163 # path that starts with target_out_dir and then uses ".." to back up into the src dir. 1164 minify_sksl_outputs += [ "$target_out_dir/" + rebase_path( 1165 "src/sksl/generated/$name.minified.sksl", 1166 target_out_dir) ] 1167 minify_sksl_outputs += [ "$target_out_dir/" + rebase_path( 1168 "src/sksl/generated/$name.unoptimized.sksl", 1169 target_out_dir) ] 1170 } 1171 1172 action("minify_sksl") { 1173 script = "gn/minify_sksl.py" 1174 deps = [ 1175 ":sksl-minify(${skia_root_dir}/gn/toolchain:$host_toolchain)", 1176 ":sksl_modules", 1177 ] 1178 sources = minify_sksl_sources 1179 outputs = minify_sksl_outputs 1180 args = [ 1181 rebase_path(sksl_minify_path), 1182 rebase_path("src/sksl/generated"), 1183 ] 1184 args += rebase_path(minify_sksl_sources) 1185 } 1186 1187 if (skia_compile_sksl_tests) { 1188 # Minify our existing .rts files into golden minified outputs. 1189 import("gn/sksl_tests.gni") 1190 action("minify_sksl_tests") { 1191 script = "gn/minify_sksl_tests.py" 1192 deps = [ 1193 ":sksl-minify(${skia_root_dir}/gn/toolchain:$host_toolchain)", 1194 ":sksl_modules", 1195 ] 1196 sources = [] 1197 outputs = [] 1198 response_file_contents = [] 1199 args = [ 1200 # Comments match the variable names in minify_sksl_tests.py 1201 rebase_path(sksl_minify_path), # sksl_minify 1202 rebase_path("src/sksl/sksl_shared.sksl"), # shared_module 1203 rebase_path("src/sksl/sksl_public.sksl"), # public_module 1204 rebase_path("src/sksl/sksl_rt_shader.sksl"), # public_module 1205 rebase_path("resources"), # input_root_dir 1206 rebase_path("tests"), # output_root_dir 1207 "{{response_file_name}}", # input_file 1208 ] 1209 1210 testsDir = get_path_info("tests/sksl/", "abspath") 1211 resourcesDir = get_path_info("resources/sksl/", "abspath") 1212 1213 foreach(partialPath, sksl_minify_tests_sources) { 1214 dst = testsDir + partialPath 1215 src = resourcesDir + partialPath 1216 1217 dir = get_path_info(dst, "dir") 1218 name = get_path_info(dst, "name") 1219 ext = get_path_info(dst, "extension") 1220 if (ext == "rts" || ext == "privrts" || ext == "rtcf" || ext == "rtb" || 1221 ext == "mfrag" || ext == "mvert") { 1222 response_file_contents += [ rebase_path(src) ] 1223 sources += [ src ] 1224 outputs += [ target_out_dir + "/" + 1225 rebase_path(dir + "/" + name + ".minified.sksl", 1226 target_out_dir) ] 1227 } 1228 } 1229 } 1230 } 1231} else { 1232 group("minify_sksl") { 1233 } 1234 group("minify_sksl_tests") { 1235 } 1236} 1237 1238# `Compile SkSL Tests` relies on skslc and the precompiled modules. 1239if (skia_compile_sksl_tests) { 1240 # Build skslc. 1241 skia_executable("skslc") { 1242 defines = [ 1243 "SKSL_STANDALONE", 1244 "SK_DISABLE_TRACING", 1245 "SK_COMPILE_WITH_GN", 1246 ] 1247 sources = skslc_deps 1248 sources += [ 1249 "tools/skslc/Main.cpp", 1250 "tools/skslc/ProcessWorklist.cpp", 1251 "tools/skslc/ProcessWorklist.h", 1252 ] 1253 libs = [] 1254 if (is_win) { 1255 sources += [ "src/utils/SkGetExecutablePath_win.cpp" ] 1256 } else if (is_mac || is_ios) { 1257 sources += [ "src/utils/SkGetExecutablePath_mac.cpp" ] 1258 } else if (is_linux || is_android) { 1259 sources += [ "src/utils/SkGetExecutablePath_linux.cpp" ] 1260 } 1261 if (is_win) { 1262 sources += skia_ports_windows_sources 1263 } else { 1264 sources += [ "src/ports/SkOSFile_posix.cpp" ] 1265 libs += [ "dl" ] 1266 } 1267 sources += skia_sksl_codegen_sources 1268 sources += skia_sksl_core_sources 1269 sources += skia_sksl_hlsl_sources 1270 sources += skia_sksl_pipeline_sources 1271 sources += skia_sksl_tracing_sources 1272 sources += skia_sksl_validate_spirv_sources 1273 sources += skia_sksl_validate_wgsl_sources 1274 include_dirs = [ "." ] 1275 deps = [ 1276 ":run_sksllex", 1277 "${skia_third_party_dir}/externals/dawn/src/tint/api:api", 1278 "${skia_third_party_dir}/externals/spirv-tools:spvtools", 1279 "${skia_third_party_dir}/externals/spirv-tools:spvtools_val", 1280 "${skia_third_party_dir}/spirv-cross:spirv_cross", 1281 ] 1282 if (is_ohos) { 1283 external_deps += [ "hitrace:hitrace_meter" ] 1284 if (!build_ohos_sdk && !is_arkui_x) { 1285 external_deps += [ "init:libbegetutil" ] 1286 if (defined(defines)) { 1287 defines += [ "NOT_BUILD_FOR_OHOS_SDK" ] 1288 } else { 1289 defines = [ "NOT_BUILD_FOR_OHOS_SDK" ] 1290 } 1291 } 1292 } 1293 } 1294 1295 skslc_path = "$root_out_dir/" 1296 if (host_toolchain != default_toolchain_name) { 1297 skslc_path += "$host_toolchain/" 1298 } 1299 skslc_path += "skslc" 1300 if (host_os == "win") { 1301 skslc_path += ".exe" 1302 } 1303 1304 # Build the test files using skslc. 1305 import("gn/sksl_tests.gni") 1306 template("compile_sksl") { 1307 # Compile the passed-in `sources` into `outputs` using skslc, with the given language/settings. 1308 action("compile_sksl_${target_name}") { 1309 script = "gn/compile_sksl_tests.py" 1310 deps = [ 1311 ":sksl_modules", 1312 ":skslc(${skia_root_dir}/gn/toolchain:$host_toolchain)", 1313 ] 1314 sources = [] 1315 outputs = [] 1316 response_file_contents = [] 1317 args = [ 1318 # Comments are the variable name in compile_sksl_tests.py 1319 rebase_path(skslc_path), # skslc 1320 invoker.lang, # lang 1321 invoker.settings, # settings 1322 rebase_path("resources"), # input_root_dir 1323 rebase_path("tests"), # output_root_dir 1324 "{{response_file_name}}", # input_file 1325 ] 1326 1327 testsDir = get_path_info("tests/sksl/", "abspath") 1328 resourcesDir = get_path_info("resources/sksl/", "abspath") 1329 1330 foreach(partialPath, invoker.sources) { 1331 dst = testsDir + partialPath 1332 src = resourcesDir + partialPath 1333 1334 dir = get_path_info(dst, "dir") 1335 name = get_path_info(dst, "name") 1336 ext = get_path_info(dst, "extension") 1337 response_file_contents += [ rebase_path(src) ] 1338 sources += [ src ] 1339 1340 foreach(outExtension, invoker.outExtensions) { 1341 # SPIR-V uses separate extensions for .vert and .compute shaders. 1342 if (ext == "vert" && outExtension == ".asm.frag") { 1343 outExtension = ".asm.vert" 1344 } else if (ext == "compute" && outExtension == ".asm.frag") { 1345 outExtension = ".asm.comp" 1346 } 1347 outputs += 1348 [ target_out_dir + "/" + 1349 rebase_path(dir + "/" + name + outExtension, target_out_dir) ] 1350 } 1351 } 1352 } 1353 } 1354 compile_sksl("glsl_tests") { 1355 sources = sksl_glsl_tests_sources + sksl_glsl_settings_tests_sources 1356 outExtensions = [ ".glsl" ] 1357 lang = "--glsl" 1358 settings = "--settings" 1359 } 1360 compile_sksl("glsl_nosettings_tests") { 1361 sources = sksl_glsl_settings_tests_sources 1362 outExtensions = [ "StandaloneSettings.glsl" ] 1363 lang = "--glsl" 1364 settings = "--nosettings" 1365 } 1366 compile_sksl("metal_tests") { 1367 sources = sksl_metal_tests_sources 1368 outExtensions = [ ".metal" ] 1369 lang = "--metal" 1370 settings = "--settings" 1371 } 1372 compile_sksl("hlsl_tests") { 1373 sources = sksl_hlsl_tests_sources 1374 outExtensions = [ ".hlsl" ] 1375 lang = "--hlsl" 1376 settings = "--settings" 1377 } 1378 compile_sksl("skrp_tests") { 1379 sources = sksl_skrp_tests_sources 1380 outExtensions = [ ".skrp" ] 1381 lang = "--skrp" 1382 settings = "--settings" 1383 } 1384 compile_sksl("stage_tests") { 1385 sources = sksl_stage_tests_sources 1386 outExtensions = [ ".stage" ] 1387 lang = "--stage" 1388 settings = "--settings" 1389 } 1390 compile_sksl("spirv_tests") { 1391 sources = sksl_spirv_tests_sources 1392 outExtensions = [ ".asm.frag" ] 1393 lang = "--spirv" 1394 settings = "--settings" 1395 } 1396 compile_sksl("wgsl_tests") { 1397 sources = sksl_wgsl_tests_sources 1398 outExtensions = [ ".wgsl" ] 1399 lang = "--wgsl" 1400 settings = "--settings" 1401 } 1402} else { 1403 group("compile_sksl_glsl_tests") { 1404 } 1405 group("compile_sksl_glsl_nosettings_tests") { 1406 } 1407 group("compile_sksl_metal_tests") { 1408 } 1409 group("compile_sksl_hlsl_tests") { 1410 } 1411 group("compile_sksl_skrp_tests") { 1412 } 1413 group("compile_sksl_spirv_tests") { 1414 } 1415 group("compile_sksl_wgsl_tests") { 1416 } 1417} 1418 1419group("compile_all_sksl_tests") { 1420 deps = [ 1421 ":compile_sksl_glsl_nosettings_tests", 1422 ":compile_sksl_glsl_tests", 1423 ":compile_sksl_hlsl_tests", 1424 ":compile_sksl_metal_tests", 1425 ":compile_sksl_skrp_tests", 1426 ":compile_sksl_spirv_tests", 1427 ":compile_sksl_wgsl_tests", 1428 ] 1429} 1430 1431optional("gpu_shared") { 1432 enabled = skia_enable_ganesh || skia_enable_graphite 1433 1434 configs = [] 1435 deps = [] 1436 libs = [] 1437 public_defines = [] 1438 public_deps = [] 1439 frameworks = [] 1440 external_deps = [] 1441 1442 sources = skia_shared_gpu_sources 1443 sources += skia_sksl_pipeline_sources 1444 sources += skia_sksl_codegen_sources 1445 1446 if (skia_use_dawn) { 1447 public_defines += [ "SK_DAWN" ] 1448 1449 # When building for WASM, the WebGPU headers are provided by Emscripten. For native builds we 1450 # have to depend on Dawn directly. 1451 if (!skia_use_webgpu) { 1452 public_deps += [ 1453 "${skia_third_party_dir}/externals/dawn/include/dawn:cpp_headers", 1454 "${skia_third_party_dir}/externals/dawn/src/dawn:cpp", 1455 "${skia_third_party_dir}/externals/dawn/src/dawn:proc", 1456 ] 1457 1458 if (dawn_enable_d3d12 || dawn_enable_d3d11 || dawn_enable_desktop_gl || 1459 dawn_enable_metal || dawn_enable_opengles || dawn_enable_vulkan) { 1460 public_deps += [ "${skia_third_party_dir}/externals/dawn/src/dawn/native" ] 1461 } 1462 if (dawn_enable_d3d12) { 1463 libs += [ 1464 "d3d12.lib", 1465 "dxgi.lib", 1466 "d3dcompiler.lib", 1467 ] 1468 } else if (dawn_enable_metal) { 1469 frameworks += [ "Metal.framework" ] 1470 } 1471 } 1472 } 1473 1474 if (skia_use_direct3d) { 1475 sources += skia_sksl_hlsl_sources 1476 deps += [ "${skia_third_party_dir}/spirv-cross:spirv_cross" ] 1477 } 1478 1479 if (skia_use_vulkan) { 1480 public_defines += [ "SK_VULKAN" ] 1481 sources += skia_shared_vk_sources 1482 configs += [ ":use_skia_vulkan_headers" ] 1483 external_deps += [ "vulkan-headers:vulkan_headers" ] 1484 if (skia_enable_vulkan_debug_layers) { 1485 public_defines += [ "SK_ENABLE_VK_LAYERS" ] 1486 } 1487 if (skia_use_vma) { 1488 sources += skia_vma_sources 1489 deps += [ "${skia_third_party_dir}/vulkanmemoryallocator:vulkan_memoryallocator" ] 1490 public_deps += [ "src/gpu/vk/vulkanmemoryallocator" ] 1491 } 1492 if (skia_vk_enable_partialrender) { 1493 public_defines += [ "SK_VK_PARTIALRENDER" ] 1494 } 1495 } 1496 1497 if (skia_use_metal) { 1498 public_defines += [ "SK_METAL" ] 1499 sources += skia_shared_mtl_sources 1500 } 1501 1502 if (is_android) { 1503 sources += skia_shared_android_sources 1504 } 1505 1506 if (is_ohos) { 1507 external_deps += [ "hitrace:hitrace_meter" ] 1508 if (!build_ohos_sdk && !is_arkui_x) { 1509 external_deps += [ "init:libbegetutil" ] 1510 if (defined(defines)) { 1511 defines += [ "NOT_BUILD_FOR_OHOS_SDK" ] 1512 } else { 1513 defines = [ "NOT_BUILD_FOR_OHOS_SDK" ] 1514 } 1515 } 1516 } 1517 1518 if (is_arkui_x) { 1519 deps += [ "//third_party/bounds_checking_function:libsec_static" ] 1520 } else if (is_ohos) { 1521 if (is_component_build) { 1522 external_deps += [ "bounds_checking_function:libsec_shared" ] 1523 } else { 1524 external_deps += [ "bounds_checking_function:libsec_static" ] 1525 } 1526 } 1527} 1528 1529optional("gpu") { 1530 enabled = skia_enable_ganesh 1531 deps = [ 1532 ":gpu_shared", 1533 ":minify_sksl", 1534 ":run_sksllex", 1535 ] 1536 if (skia_generate_workarounds) { 1537 deps += [ ":workaround_list" ] 1538 } 1539 configs = [] 1540 public_defines = [] 1541 public_configs = [] 1542 public_deps = [] 1543 1544 public = skia_gpu_public 1545 sources = skia_ganesh_private 1546 1547 libs = [] 1548 frameworks = [] 1549 1550 if (is_android) { 1551 sources += skia_gpu_android_private 1552 1553 # this lib is required to link against AHardwareBuffer 1554 if (defined(ndk_api) && ndk_api >= 26) { 1555 libs += [ "android" ] 1556 } 1557 } 1558 external_deps = [] 1559 if (skia_use_gl) { 1560 public_defines += [ "SK_GL" ] 1561 if (is_android) { 1562 sources += [ 1563 "src/gpu/ganesh/gl/egl/GrGLMakeEGLInterface.cpp", 1564 "src/gpu/ganesh/gl/egl/GrGLMakeNativeInterface_egl.cpp", 1565 ] 1566 sources += skia_android_gl_sources 1567 1568 # this lib is required to link against AHardwareBuffer 1569 libs += [ "android" ] 1570 } else if (skia_use_egl || is_ohos) { 1571 if (skia_use_epoxy_egl) { 1572 sources += [ "src/gpu/ganesh/gl/epoxy/GrGLMakeEpoxyEGLInterface.cpp" ] 1573 libs += [ "epoxy" ] 1574 } else { 1575 sources += [ 1576 "src/gpu/ganesh/gl/egl/GrGLMakeEGLInterface.cpp", 1577 "src/gpu/ganesh/gl/egl/GrGLMakeNativeInterface_egl.cpp", 1578 ] 1579 if (is_ohos) { 1580 external_deps += [ 1581 "egl:libEGL", 1582 "graphic_2d:EGL", 1583 "graphic_2d:GLESv3", 1584 "opengles:libGLES", 1585 ] 1586 } else { 1587 libs += [ "EGL" ] 1588 } 1589 } 1590 } else if (skia_use_webgl) { 1591 sources += [ "src/gpu/ganesh/gl/webgl/GrGLMakeNativeInterface_webgl.cpp" ] 1592 } else if (is_linux && skia_use_x11) { 1593 sources += [ 1594 "src/gpu/ganesh/gl/glx/GrGLMakeGLXInterface.cpp", 1595 "src/gpu/ganesh/gl/glx/GrGLMakeNativeInterface_glx.cpp", 1596 ] 1597 libs += [ "GL" ] 1598 } else if (is_mac) { 1599 sources += [ "src/gpu/ganesh/gl/mac/GrGLMakeNativeInterface_mac.cpp" ] 1600 } else if (is_ios) { 1601 sources += [ "src/gpu/ganesh/gl/iOS/GrGLMakeNativeInterface_iOS.cpp" ] 1602 } else if (is_win && !skia_enable_winuwp) { 1603 sources += [ 1604 "src/gpu/ganesh/gl/win/GrGLMakeNativeInterface_win.cpp", 1605 "src/gpu/ganesh/gl/win/GrGLMakeWinInterface.cpp", 1606 ] 1607 libs += [ "opengl32" ] 1608 } else { 1609 sources += [ "src/gpu/ganesh/gl/GrGLMakeNativeInterface_none.cpp" ] 1610 } 1611 public += skia_gpu_gl_public 1612 sources += skia_gpu_gl_private 1613 } 1614 1615 if (skia_use_vulkan) { 1616 public += skia_gpu_vk_public 1617 sources += skia_gpu_vk_private 1618 configs += [ ":use_skia_vulkan_headers" ] 1619 external_deps += [ "vulkan-headers:vulkan_headers" ] 1620 if (is_ohos) { 1621 external_deps += [ "hilog:libhilog" ] 1622 } 1623 if (is_fuchsia) { 1624 if (using_fuchsia_sdk) { 1625 public_deps += [ "$fuchsia_sdk_root/pkg:vulkan" ] 1626 } else { 1627 public_deps += [ "${skia_root_dir}/src/graphics/lib/vulkan" ] 1628 } 1629 } 1630 if (is_android) { 1631 sources += skia_gpu_vk_android_private 1632 } 1633 } 1634 1635 if (skia_use_direct3d) { 1636 public_defines += [ "SK_DIRECT3D" ] 1637 deps += [ "${skia_third_party_dir}/d3d12allocator" ] 1638 sources += skia_direct3d_sources 1639 if (skia_enable_direct3d_debug_layer) { 1640 public_defines += [ "SK_ENABLE_D3D_DEBUG_LAYER" ] 1641 } 1642 libs += [ 1643 "d3d12.lib", 1644 "dxgi.lib", 1645 "d3dcompiler.lib", 1646 ] 1647 } 1648 1649 cflags_objcc = [] 1650 if (skia_use_metal) { 1651 public_defines += [ "SK_METAL" ] 1652 public += skia_gpu_metal_public 1653 sources += skia_gpu_metal_private 1654 sources += skia_gpu_metal_cpp 1655 if (skia_enable_metal_debug_info) { 1656 public_defines += [ "SK_ENABLE_MTL_DEBUG_INFO" ] 1657 } 1658 frameworks += [ "Metal.framework" ] 1659 frameworks += [ "Foundation.framework" ] 1660 if (is_ios) { 1661 frameworks += [ "UIKit.framework" ] 1662 } 1663 cflags_objcc += [ "-fobjc-arc" ] 1664 } 1665 1666 if (is_debug || skia_build_for_debugger) { 1667 public_defines += [ "SK_ENABLE_DUMP_GPU" ] 1668 } 1669 1670 if (is_ohos) { 1671 external_deps += [ "hitrace:hitrace_meter" ] 1672 if (!build_ohos_sdk && !is_arkui_x) { 1673 external_deps += [ "init:libbegetutil" ] 1674 } 1675 } 1676 1677 if (is_arkui_x) { 1678 deps += [ "//third_party/bounds_checking_function:libsec_static" ] 1679 } else if (is_ohos) { 1680 if (is_component_build) { 1681 external_deps += [ "bounds_checking_function:libsec_shared" ] 1682 } else { 1683 external_deps += [ "bounds_checking_function:libsec_static" ] 1684 } 1685 } 1686} 1687 1688optional("vello") { 1689 enabled = skia_enable_vello_shaders 1690 public_defines = [ "SK_ENABLE_VELLO_SHADERS" ] 1691 public_deps = [ "${skia_third_party_dir}/vello" ] 1692} 1693 1694optional("heif") { 1695 enabled = skia_use_libheif 1696 public_defines = [ "SK_HAS_HEIF_LIBRARY" ] 1697 1698 # This HEIF decoding functionality is a part of the Android Framework. 1699 # https://android.googlesource.com/platform/frameworks/av/+/master/media/libheif/include/HeifDecoderAPI.h 1700 # There isn't a way to compile that library outside of it, so we just link against 1701 # the library. This feature is not supported on other platforms (and we haven't 1702 # yet tried something like https://github.com/strukturag/libheif/tree/master/libheif). 1703 # The dependency for Android is set in gn_to_bp.py. 1704 deps = [] 1705 1706 sources = [ "src/codec/SkHeifCodec.cpp" ] 1707} 1708 1709optional("avif") { 1710 enabled = skia_use_libavif 1711 public_defines = [ "SK_CODEC_DECODES_AVIF" ] 1712 1713 deps = [ "${skia_third_party_dir}/libavif" ] 1714 1715 sources = [ "src/codec/SkAvifCodec.cpp" ] 1716} 1717 1718optional("crabbyavif") { 1719 enabled = skia_use_crabbyavif 1720 public_defines = [ "SK_CODEC_DECODES_AVIF" ] 1721 1722 # AVIF decoding is provided by CrabbyAvif (a Rust library). Since skia's 1723 # standalone builds do not support Rust, it is only being enabled when 1724 # building for the Android framework. 1725 # The dependency for Android is set in gn_to_bp.py 1726 deps = [] 1727 sources = [ "src/codec/SkCrabbyAvifCodec.cpp" ] 1728} 1729 1730optional("jpeg_mpf") { 1731 enabled = skia_use_jpeg_gainmaps && 1732 (skia_use_libjpeg_turbo_encode || skia_use_libjpeg_turbo_decode) 1733 sources = [ 1734 "src/codec/SkJpegMultiPicture.cpp", 1735 "src/codec/SkJpegSegmentScan.cpp", 1736 ] 1737} 1738 1739optional("jpeg_decode") { 1740 enabled = skia_use_libjpeg_turbo_decode 1741 public_defines = [ "SK_CODEC_DECODES_JPEG" ] 1742 1743 deps = [] 1744 if (skia_use_system_lib) { 1745 external_deps = [ "libjpeg-turbo:turbojpeg" ] 1746 } else { 1747 deps += [ "${skia_third_party_dir}/libjpeg-turbo:libjpegm133" ] 1748 } 1749 sources = [ 1750 "src/codec/SkJpegCodec.cpp", 1751 "src/codec/SkJpegDecoderMgr.cpp", 1752 "src/codec/SkJpegMetadataDecoderImpl.cpp", 1753 "src/codec/SkJpegSourceMgr.cpp", 1754 "src/codec/SkJpegUtility.cpp", 1755 ] 1756 if (skia_use_jpeg_gainmaps) { 1757 # Theoretically this doesn't need to be public, but this allows gn_to_bp.py to see it, and seems 1758 # to align with other codec support. See b/265939413 1759 public_defines += [ "SK_CODEC_DECODES_JPEG_GAINMAPS" ] 1760 deps += [ 1761 ":jpeg_mpf", 1762 ":xml", 1763 ] 1764 sources += skia_codec_jpeg_xmp 1765 } 1766} 1767 1768optional("jpeg_encode") { 1769 enabled = skia_use_libjpeg_turbo_encode && !skia_use_ndk_images 1770 public_defines = [ "SK_CODEC_ENCODES_JPEG" ] 1771 1772 deps = [] 1773 if (skia_use_system_lib) { 1774 external_deps = [ "libjpeg-turbo:turbojpeg" ] 1775 } else { 1776 deps += [ "${skia_third_party_dir}/libjpeg-turbo:libjpegm133" ] 1777 } 1778 public = skia_encode_jpeg_public 1779 sources = skia_encode_jpeg_srcs 1780 1781 if (skia_use_jpeg_gainmaps) { 1782 deps += [ ":jpeg_mpf" ] 1783 sources += [ "src/encode/SkJpegGainmapEncoder.cpp" ] 1784 } 1785} 1786 1787optional("jpegxl_decode") { 1788 enabled = skia_use_libjxl_decode 1789 public_defines = [ "SK_CODEC_DECODES_JPEGXL" ] 1790 1791 deps = [ "${skia_third_party_dir}/libjxl" ] 1792 sources = [ "src/codec/SkJpegxlCodec.cpp" ] 1793} 1794 1795optional("ndk_images") { 1796 enabled = skia_use_ndk_images 1797 public_defines = [ "SK_ENABLE_NDK_IMAGES" ] 1798 sources = [ 1799 "src/ports/SkImageEncoder_NDK.cpp", 1800 "src/ports/SkImageGeneratorNDK.cpp", 1801 "src/ports/SkNDKConversions.cpp", 1802 ] 1803 libs = [ "jnigraphics" ] 1804} 1805 1806optional("graphite") { 1807 configs = [] 1808 libs = [] 1809 frameworks = [] 1810 public_defines = [] 1811 1812 enabled = skia_enable_graphite 1813 deps = [ 1814 ":gpu_shared", 1815 ":vello", 1816 ] 1817 public = skia_graphite_public 1818 sources = skia_graphite_sources 1819 sources += skia_sksl_graphite_modules_sources 1820 1821 if (is_android) { 1822 sources += skia_graphite_android_private 1823 } 1824 1825 if (skia_enable_vello_shaders) { 1826 sources += skia_graphite_vello_sources 1827 } 1828 1829 if (skia_use_dawn) { 1830 public += skia_graphite_dawn_public 1831 sources += skia_graphite_dawn_sources 1832 } 1833 if (skia_use_metal) { 1834 public_defines += [ "SK_METAL" ] 1835 public += skia_graphite_mtl_public 1836 sources += skia_graphite_mtl_sources 1837 if (skia_enable_metal_debug_info) { 1838 public_defines += [ "SK_ENABLE_MTL_DEBUG_INFO" ] 1839 } 1840 frameworks += [ "Metal.framework" ] 1841 frameworks += [ "Foundation.framework" ] 1842 if (is_ios) { 1843 frameworks += [ "UIKit.framework" ] 1844 } 1845 } 1846 if (skia_use_vulkan) { 1847 public += skia_graphite_vk_public 1848 sources += skia_graphite_vk_sources 1849 configs += [ ":use_skia_vulkan_headers" ] 1850 } 1851 if (skia_enable_precompile) { 1852 public += skia_graphite_precompile_public 1853 sources += skia_graphite_precompile_sources 1854 } 1855 if (is_debug) { 1856 public_defines += [ "SK_PIPELINE_LIFETIME_LOGGING" ] 1857 } 1858} 1859 1860optional("pdf") { 1861 enabled = skia_use_zlib && skia_enable_pdf && skia_use_libjpeg_turbo_decode && 1862 skia_use_libjpeg_turbo_encode 1863 public_defines = [ "SK_SUPPORT_PDF" ] 1864 deps = [] 1865 external_deps = [] 1866 if (use_oh_skia) { 1867 external_deps += [ "zlib:libz" ] 1868 } else { 1869 if (skia_feature_zlib != "") { 1870 external_deps += [ skia_feature_zlib ] 1871 } else { 1872 if (skia_use_system_lib) { 1873 external_deps += [ "zlib:libz" ] 1874 } else { 1875 deps += [ "${skia_third_party_dir}/zlib" ] 1876 } 1877 } 1878 } 1879 if (is_ohos) { 1880 external_deps += [ "hitrace:hitrace_meter" ] 1881 if (!build_ohos_sdk && !is_arkui_x) { 1882 external_deps += [ "init:libbegetutil" ] 1883 } 1884 } 1885 1886 if (is_arkui_x) { 1887 deps += [ "//third_party/bounds_checking_function:libsec_static" ] 1888 } else if (is_ohos) { 1889 if (is_component_build) { 1890 external_deps += [ "bounds_checking_function:libsec_shared" ] 1891 } else { 1892 external_deps += [ "bounds_checking_function:libsec_static" ] 1893 } 1894 } 1895 public = skia_pdf_public 1896 sources = skia_pdf_sources 1897 sources_when_disabled = [ "src/pdf/SkDocument_PDF_None.cpp" ] 1898 if (skia_pdf_subset_harfbuzz) { 1899 if (skia_use_system_lib) { 1900 external_deps += [ "harfbuzz:harfbuzz_static_for_skia" ] 1901 } else { 1902 deps += [ "${skia_third_party_dir}/harfbuzz" ] 1903 } 1904 defines = [ "SK_PDF_USE_HARFBUZZ_SUBSET" ] 1905 } 1906 deps += [ 1907 ":jpeg_decode", 1908 ":jpeg_encode", 1909 ] 1910} 1911 1912optional("xps") { 1913 enabled = skia_use_xps && is_win && !is_mingw 1914 public_defines = [ "SK_SUPPORT_XPS" ] 1915 public = skia_xps_public 1916 sources = skia_xps_sources 1917} 1918 1919optional("png_decode_libpng") { 1920 enabled = skia_use_libpng_decode 1921 public_defines = [ 1922 "SK_CODEC_DECODES_ICO", 1923 "SK_CODEC_DECODES_PNG", 1924 "SK_CODEC_DECODES_PNG_WITH_LIBPNG", 1925 ] 1926 1927 if (skia_use_system_lib) { 1928 external_deps = [ "libpng:libpng" ] 1929 } else { 1930 deps = [ "${skia_third_party_dir}/libpng" ] 1931 } 1932 sources = [ "src/codec/SkIcoCodec.cpp" ] + skia_codec_png_base + 1933 skia_codec_libpng_srcs 1934 defines = [ "ICO_CODEC_HW_HIGH_QUALITY_DECODE" ] 1935} 1936 1937optional("png_encode") { 1938 enabled = skia_use_libpng_encode && !skia_use_ndk_images 1939 public_defines = [ 1940 "SK_CODEC_ENCODES_PNG", 1941 "SK_CODEC_ENCODES_PNG_WITH_LIBPNG", 1942 ] 1943 1944 public = skia_encode_png_public 1945 if (skia_use_system_lib) { 1946 external_deps = [ "libpng:libpng" ] 1947 } else { 1948 deps = [ "${skia_third_party_dir}/libpng" ] 1949 } 1950 sources = skia_encode_png_srcs 1951} 1952 1953optional("raw") { 1954 enabled = skia_use_dng_sdk && skia_use_libjpeg_turbo_decode && skia_use_piex 1955 public_defines = [ "SK_CODEC_DECODES_RAW" ] 1956 1957 deps = [ 1958 "${skia_third_party_dir}/dng_sdk", 1959 "${skia_third_party_dir}/piex:piexm133", 1960 ] 1961 if (skia_use_system_lib) { 1962 external_deps = [ "libjpeg-turbo:turbojpeg" ] 1963 } else { 1964 deps += [ "${skia_third_party_dir}/libjpeg-turbo:libjpegm133" ] 1965 } 1966 # SkRawCodec catches any exceptions thrown by dng_sdk, insulating the rest of 1967 # Skia. 1968 configs = [ "gn/portable:add_exceptions" ] 1969 1970 sources = [ "src/codec/SkRawCodec.cpp" ] 1971} 1972 1973optional("typeface_freetype") { 1974 if (use_oh_skia) { 1975 enabled = skia_use_freetype2 1976 } else { 1977 enabled = skia_use_freetype 1978 } 1979 1980 public_defines = [ "SK_TYPEFACE_FACTORY_FREETYPE" ] 1981 if (skia_use_system_lib || ((is_official_build || sanitize_skia != "MSAN") && 1982 !is_fuchsia && !is_wasm)) { 1983 external_deps = [ "freetype:freetype_static" ] 1984 } else { 1985 deps = [ "${skia_third_party_dir}/freetype2" ] 1986 } 1987 if (defined(external_deps)) { 1988 external_deps += [ "bounds_checking_function:libsec_shared" ] 1989 } else { 1990 external_deps = [ "bounds_checking_function:libsec_shared" ] 1991 } 1992 1993 sources = skia_ports_freetype_sources 1994 sources_for_tests = [ "tests/FontScanner_FreeTypeTest.cpp" ] 1995} 1996 1997bazel_args = [] 1998if (is_mac && target_cpu == "arm64") { 1999 # TODO: Normally the target toolchain would be specified with `--platforms` but that doesn't 2000 # work. When building and running on an arm64 mac, setting `--host_platform` seems to do the 2001 # right thing but may not be the right build configuration in the long run. 2002 bazel_args += [ "--host_platform=//bazel/platform:mac_arm64_hermetic" ] 2003} 2004if (is_debug) { 2005 bazel_args += [ "--compilation_mode=dbg" ] 2006} else { 2007 bazel_args += [ "--compilation_mode=opt" ] 2008} 2009 2010if (skia_use_fontations) { 2011 action("fontations_rust_side_bazel_build") { 2012 script = "gn/bazel_build.py" 2013 sources = [ 2014 "src/ports/fontations/BUILD.bazel", 2015 "src/ports/fontations/src/ffi.rs", 2016 ] 2017 outputs = [ "$root_out_dir/libbridge_rust_side.a" ] 2018 args = 2019 [ 2020 "${skia_root_dir}/src/ports/fontations:bridge_rust_side", 2021 rebase_path("//bazel-bin/src/ports/fontations/libbridge_rust_side.a", 2022 root_build_dir), 2023 ] + bazel_args 2024 } 2025 2026 # We only use Bazel to get the generated `.cc` and `.h` file and then compile 2027 # them on GN/ninja side using `skia_source_set` below. This ensures that the 2028 # same C++ stdlib and compiler is used throughout the build (in some scenarios 2029 # Bazel may end up using different ones). 2030 action("fontations_ffi_bazel_build") { 2031 script = "gn/bazel_build.py" 2032 sources = [ 2033 "src/ports/fontations/BUILD.bazel", 2034 "src/ports/fontations/src/ffi.rs", 2035 ] 2036 outputs = [ 2037 "$root_out_dir/src/ports/fontations/src/ffi.rs.h", 2038 "$root_out_dir/src/ports/fontations/src/ffi.rs.cc", 2039 ] 2040 args = [ 2041 "${skia_root_dir}/src/ports/fontations:fontations_ffi", 2042 2043 # we want the header to not simply be copied into the output directory, 2044 # but in the same path as the Bazel build uses. 2045 rebase_path("//bazel-bin/src/ports/fontations/src/ffi.rs.h", 2046 root_build_dir) + "=src/ports/fontations/src/ffi.rs.h", 2047 rebase_path("//bazel-bin/src/ports/fontations/src/ffi.rs.cc", 2048 root_build_dir) + 2049 "=src/ports/fontations/src/ffi.rs.cc", 2050 ] + bazel_args 2051 } 2052 config("fontations_ffi_public_config") { 2053 include_dirs = [ 2054 # This is where `src/ports/fontations/src/ffi.rs.h` was put by Bazel 2055 "$root_out_dir", 2056 ] 2057 } 2058 config("fontations_ffi_private_config") { 2059 include_dirs = [ 2060 # This entry is needed so that `ffi.rs.cc` can resolve 2061 # `#include "src/ports/fontations/src/ffi.rs.h"` 2062 ".", 2063 ] 2064 } 2065 skia_source_set("fontations_ffi") { 2066 deps = [ 2067 ":fontations_ffi_bazel_build", 2068 ":fontations_rust_side_bazel_build", 2069 ] 2070 public = [ "${root_out_dir}/src/ports/fontations/src/ffi.rs.h" ] 2071 sources = [ "${root_out_dir}/src/ports/fontations/src/ffi.rs.cc" ] 2072 libs = [ "$root_out_dir/libbridge_rust_side.a" ] 2073 public_configs = [ ":fontations_ffi_public_config" ] 2074 configs = [ ":fontations_ffi_private_config" ] 2075 } 2076} 2077 2078optional("typeface_fontations") { 2079 public_defines = [ "SK_TYPEFACE_FACTORY_FONTATIONS" ] 2080 enabled = skia_use_fontations 2081 public_deps = [ ":fontations_ffi" ] 2082 sources = skia_ports_typeface_fontations_sources 2083 sources_for_tests = [ 2084 "tests/FontationsTest.cpp", 2085 "tests/FontationsFtCompTest.cpp", 2086 "tests/FontScanner_FontationsTest.cpp", 2087 ] 2088} 2089 2090if (skia_use_rust_png_decode || skia_use_rust_png_encode) { 2091 # We only use Bazel to get the generated `.cc` and `.h` file and then compile 2092 # them on GN/ninja side using `skia_source_set` below. This ensures that the 2093 # same C++ stdlib and compiler is used throughout the build (in some scenarios 2094 # Bazel may end up using different ones). 2095 action("rust_png_ffi_bazel_build") { 2096 script = "gn/bazel_build.py" 2097 sources = [ 2098 "experimental/rust_png/ffi/BUILD.bazel", 2099 "experimental/rust_png/ffi/FFI.h", 2100 "experimental/rust_png/ffi/FFI.rs", 2101 ] 2102 outputs = [ 2103 "$root_out_dir/librust_png_ffi_rs.a", 2104 "$root_out_dir/experimental/rust_png/ffi/FFI.rs.h", 2105 "$root_out_dir/experimental/rust_png/ffi/FFI.rs.cc", 2106 ] 2107 args = 2108 [ 2109 "//experimental/rust_png/ffi:*", 2110 2111 rebase_path("//bazel-bin/experimental/rust_png/ffi/libffi_rs.a", 2112 root_build_dir) + "=librust_png_ffi_rs.a", 2113 2114 # we want the `cxx`-generated headers to not simply be copied into 2115 # the output directory, but in the same path as the Bazel build 2116 # uses. 2117 rebase_path("//bazel-bin/experimental/rust_png/ffi/FFI.rs.h", 2118 root_build_dir) + "=experimental/rust_png/ffi/FFI.rs.h", 2119 rebase_path("//bazel-bin/experimental/rust_png/ffi/FFI.rs.cc", 2120 root_build_dir) + "=experimental/rust_png/ffi/FFI.rs.cc", 2121 ] + bazel_args 2122 } 2123 action("rust_png_cxx_core_bazel_build") { 2124 script = "gn/bazel_build.py" 2125 sources = [ 2126 "WORKSPACE.bazel", 2127 "bazel/external/cxx/BUILD.bazel", 2128 "bazel/external/cxx/BUILD.bazel.skia", 2129 ] 2130 outputs = [ 2131 "$root_out_dir/librust_png_cxx_core_lib.a", 2132 "$root_out_dir/third_party/rust/cxx/v1/cxx.h", 2133 ] 2134 args = [ 2135 "@cxx//:core-lib", 2136 2137 rebase_path("//bazel-bin/external/cxx/libcore-lib.a", 2138 root_build_dir) + "=librust_png_cxx_core_lib.a", 2139 2140 # we want the `cxx.h` header to not simply be copied into the 2141 # output directory, but in the same path as the Bazel build uses. 2142 rebase_path( 2143 "//bazel-bin/external/cxx/_virtual_includes/core-lib/third_party/rust/cxx/v1/cxx.h", 2144 root_build_dir) + "=third_party/rust/cxx/v1/cxx.h", 2145 ] + bazel_args 2146 } 2147 config("rust_png_cxx_bridge_public_config") { 2148 include_dirs = [ 2149 # This is where `experimental/rust_png/ffi/FFI.rs.h` and 2150 # `third_party/rust/cxx/v1/cxx.h` were put by Bazel 2151 "$root_out_dir", 2152 ] 2153 } 2154 config("rust_png_cxx_bridge_private_config") { 2155 include_dirs = [ 2156 # This entry is needed so that `FFI.rs.cc` can resolve 2157 # `#include "experimental/rust_png/ffi/FFI.h"` 2158 ".", 2159 ] 2160 } 2161 skia_source_set("rust_png_cxx_bridge") { 2162 deps = [ ":rust_png_ffi_bazel_build" ] 2163 public = [ "${root_out_dir}/experimental/rust_png/ffi/FFI.rs.h" ] 2164 sources = [ "${root_out_dir}/experimental/rust_png/ffi/FFI.rs.cc" ] 2165 libs = [ "$root_out_dir/librust_png_ffi_rs.a" ] 2166 public_configs = [ ":rust_png_cxx_bridge_public_config" ] 2167 configs = [ ":rust_png_cxx_bridge_private_config" ] 2168 } 2169} 2170 2171optional("png_decode_rust") { 2172 public_defines = [ "SK_CODEC_DECODES_PNG_WITH_RUST" ] 2173 enabled = skia_use_rust_png_decode 2174 public = skia_codec_rust_png_public 2175 sources = skia_codec_rust_png + skia_codec_png_base 2176 sources_for_tests = [ "tests/SkPngRustDecoderTest.cpp" ] 2177 2178 deps = [ 2179 ":rust_png_cxx_bridge", 2180 ":rust_png_cxx_core_bazel_build", 2181 ] 2182 libs = [ "$root_out_dir/librust_png_cxx_core_lib.a" ] 2183} 2184 2185optional("png_encode_rust") { 2186 public_defines = [ "SK_CODEC_ENCODES_PNG_WITH_RUST" ] 2187 enabled = skia_use_rust_png_encode 2188 public = skia_encode_rust_png_public # From `gn/core.gni` 2189 sources = 2190 skia_encode_rust_png_srcs + skia_encode_png_base # From `gn/core.gni` 2191 sources_for_tests = [ "tests/SkPngRustEncoderTest.cpp" ] 2192 deps = [ 2193 ":rust_png_cxx_bridge", 2194 ":rust_png_cxx_core_bazel_build", 2195 ] 2196 libs = [ "$root_out_dir/librust_png_cxx_core_lib.a" ] 2197} 2198 2199optional("webp_decode") { 2200 enabled = skia_use_libwebp_decode 2201 public_defines = [ "SK_CODEC_DECODES_WEBP" ] 2202 if (skia_feature_hispeed_plugin) { 2203 public_defines += [ "USE_HISPEED_PLUGIN" ] 2204 } 2205 deps = [ "${skia_third_party_dir}/libwebp:libwebpm133" ] 2206 sources = [ "src/codec/SkWebpCodec.cpp" ] 2207} 2208 2209optional("webp_encode") { 2210 enabled = skia_use_libwebp_encode && !skia_use_ndk_images 2211 public_defines = [ "SK_CODEC_ENCODES_WEBP" ] 2212 public = skia_encode_webp_public 2213 2214 deps = [ "${skia_third_party_dir}/libwebp:libwebpm133" ] 2215 sources = skia_encode_webp_srcs 2216} 2217 2218optional("wuffs") { 2219 enabled = skia_use_wuffs 2220 public_defines = [ 2221 "SK_HAS_WUFFS_LIBRARY", 2222 "SK_CODEC_DECODES_GIF", 2223 ] 2224 2225 deps = [ "${skia_third_party_dir}/wuffs" ] 2226 sources = [ "src/codec/SkWuffsCodec.cpp" ] 2227} 2228 2229optional("xml") { 2230 enabled = skia_use_expat || skia_use_jpeg_gainmaps 2231 public_defines = [ "SK_XML" ] 2232 2233 if (skia_feature_upgrade) { 2234 deps = ["${skia_third_party_dir}/expat:expatm133"] 2235 } else { 2236 deps = ["${skia_third_party_dir}/expat"] 2237 } 2238 sources = skia_xml_sources + skia_codec_xmp + [ 2239 "src/svg/SkSVGCanvas.cpp", 2240 "src/svg/SkSVGDevice.cpp", 2241 ] 2242} 2243 2244if (skia_enable_ganesh && skia_generate_workarounds) { 2245 action("workaround_list") { 2246 script = "tools/build_workaround_header.py" 2247 2248 inputs = [ "src/gpu/gpu_workaround_list.txt" ] 2249 2250 # GN insists its outputs should go somewhere underneath root_out_dir, so we trick it with a 2251 # path that starts with root_out_dir and then uses ".." to back up into the src dir. 2252 output_file = 2253 rebase_path("include/gpu/ganesh/GrDriverBugWorkaroundsAutogen.h", 2254 root_out_dir) 2255 2256 outputs = [ "$root_out_dir/$output_file" ] 2257 args = [ 2258 "--output-file", 2259 "$output_file", 2260 ] 2261 2262 foreach(file, inputs) { 2263 args += [ rebase_path(file, root_build_dir) ] 2264 } 2265 } 2266} 2267 2268import("gn/codec.gni") 2269 2270skia_component("skia") { 2271 public_configs = [ ":skia_public" ] 2272 configs = skia_library_configs 2273 2274 public_deps = [ 2275 ":fontmgr_FontConfigInterface", 2276 ":fontmgr_android", 2277 ":fontmgr_android_ndk", 2278 ":fontmgr_custom_directory", 2279 ":fontmgr_custom_embedded", 2280 ":fontmgr_custom_empty", 2281 ":fontmgr_fontations_empty", 2282 ":fontmgr_fontconfig", 2283 ":fontmgr_fuchsia", 2284 ":fontmgr_mac_ct", 2285 ":fontmgr_win", 2286 ":fontmgr_win_gdi", 2287 ":gpu", 2288 ":graphite", 2289 ":jpeg_encode", 2290 ":pdf", 2291 ":png_encode", 2292 ":webp_encode", 2293 ":xps", 2294 ] 2295 2296 deps = [ 2297 ":android_utils", 2298 ":avif", 2299 ":crabbyavif", 2300 ":heif", 2301 ":hsw", 2302 ":jpeg_decode", 2303 ":jpegxl_decode", 2304 ":lasx", 2305 ":minify_sksl", 2306 ":ndk_images", 2307 ":png_decode_libpng", 2308 ":png_decode_rust", 2309 ":raw", 2310 ":skx", 2311 ":typeface_fontations", 2312 ":vello", 2313 ":webp_decode", 2314 ":wuffs", 2315 ":xml", 2316 "modules/skcms", 2317 ] 2318 2319 public = skia_core_public 2320 public += skia_codec_public 2321 public += skia_utils_public 2322 public += skia_effects_public 2323 public += skia_effects_imagefilter_public 2324 2325 sources = [] 2326 sources += skia_core_sources 2327 sources += skia_utils_private 2328 sources += skia_utils_chromium 2329 sources += skia_effects_sources 2330 sources += skia_colorfilters_sources 2331 sources += skia_effects_imagefilter_sources 2332 sources += skia_codec_shared 2333 sources += skia_codec_decode_bmp 2334 sources += skia_encode_srcs 2335 sources += skia_sksl_core_sources 2336 sources += skia_sksl_core_module_sources 2337 sources += skia_sksl_tracing_sources 2338 sources += skia_ports_sources 2339 sources += [ 2340 "src/android/SkAndroidFrameworkUtils.cpp", 2341 "src/android/SkAnimatedImage.cpp", 2342 "src/codec/SkAndroidCodec.cpp", 2343 "src/codec/SkAndroidCodecAdapter.cpp", 2344 "src/codec/SkSampledCodec.cpp", 2345 "src/ports/SkDiscardableMemory_none.cpp", 2346 "src/ports/SkMemory_malloc.cpp", 2347 "src/sfnt/SkOTTable_name.cpp", 2348 "src/sfnt/SkOTUtils.cpp", 2349 ] 2350 2351 defines = [] 2352 libs = [] 2353 2354 if (is_arkui_x) { 2355 defines += [ "ARKUI_X_ENABLE" ] 2356 } 2357 2358 if (skia_build_for_debugger) { 2359 defines += [ "SK_BUILD_FOR_DEBUGGER" ] 2360 } 2361 2362 if (skia_use_no_jpeg_encode) { 2363 sources += skia_no_encode_jpeg_srcs 2364 } 2365 if (skia_use_no_png_encode) { 2366 sources += skia_no_encode_png_srcs 2367 } 2368 if (skia_use_no_webp_encode) { 2369 sources += skia_no_encode_webp_srcs 2370 } 2371 2372 if (is_win) { 2373 sources += skia_ports_windows_sources + [ 2374 "src/ports/SkDebug_win.cpp", 2375 "src/ports/SkImageGeneratorWIC.cpp", 2376 ] 2377 libs += [ 2378 "Ole32.lib", 2379 "OleAut32.lib", 2380 ] 2381 2382 if (!skia_enable_winuwp) { 2383 libs += [ 2384 "FontSub.lib", 2385 "User32.lib", 2386 "Usp10.lib", 2387 ] 2388 } 2389 } else { 2390 sources += [ "src/ports/SkOSFile_posix.cpp" ] 2391 if (is_ios) { 2392 sources += [ "src/ports/SkOSFile_ios.h" ] 2393 } 2394 libs += [ "dl" ] 2395 } 2396 2397 if (is_android) { 2398 if (skia_feature_upgrade) { 2399 deps += ["${skia_third_party_dir}/expat:expatm133"] 2400 } else { 2401 deps += ["${skia_third_party_dir}/expat"] 2402 } 2403 if (defined(ndk) && ndk != "") { 2404 deps += [ "${skia_third_party_dir}/cpu-features" ] 2405 } 2406 sources += [ "src/ports/SkDebug_android.cpp" ] 2407 libs += [ 2408 "EGL", 2409 "GLESv2", 2410 "log", 2411 ] 2412 } 2413 2414 if (is_linux || is_wasm) { 2415 sources += [ "src/ports/SkDebug_stdio.cpp" ] 2416 if (skia_use_egl) { 2417 libs += [ "GLESv2" ] 2418 } 2419 } 2420 2421 if (is_mac) { 2422 public += [ "include/ports/SkCFObject.h" ] 2423 sources += [ 2424 "src/ports/SkDebug_stdio.cpp", 2425 "src/ports/SkImageGeneratorCG.cpp", 2426 ] 2427 frameworks = [ 2428 "ApplicationServices.framework", 2429 "OpenGL.framework", 2430 ] 2431 } 2432 2433 if (is_ios) { 2434 public += [ "include/ports/SkCFObject.h" ] 2435 sources += [ 2436 "src/ports/SkDebug_stdio.cpp", 2437 "src/ports/SkImageGeneratorCG.cpp", 2438 ] 2439 frameworks = [ 2440 "CoreFoundation.framework", 2441 "ImageIO.framework", 2442 "MobileCoreServices.framework", 2443 ] 2444 } 2445 2446 if (is_fuchsia) { 2447 sources += [ "src/ports/SkDebug_stdio.cpp" ] 2448 } 2449 2450 # if (skia_enable_spirv_validation) { 2451 # deps += [ "${skia_third_party_dir}/externals/spirv-tools:spvtools_val" ] 2452 # defines += [ "SK_ENABLE_SPIRV_VALIDATION" ] 2453 # } 2454 2455 if (skia_include_multiframe_procs) { 2456 sources += [ "tools/SkSharingProc.cpp" ] 2457 } 2458 2459 #Bisheng control is required in the future 2460 if (is_ohos) { 2461 ldflags = [ "-Wl,-Bsymbolic" ] 2462 } 2463 2464 # Overrides TRACE_EVENT0..2 macros (etc) to map to Perfetto's tracing macros. 2465 # Currently only supported in Android framework. 2466 if (skia_android_framework_use_perfetto) { 2467 defines += [ "SK_ANDROID_FRAMEWORK_USE_PERFETTO" ] 2468 sources += [ "src/android/SkAndroidFrameworkPerfettoStaticStorage.cpp" ] 2469 } 2470 2471 if (!skia_enable_ganesh && !skia_enable_graphite) { 2472 sources += skia_no_slug_srcs 2473 } 2474 if (is_ohos) { 2475 external_deps = [ "hitrace:hitrace_meter" ] 2476 if (!build_ohos_sdk && !is_arkui_x) { 2477 external_deps += [ "init:libbegetutil" ] 2478 } 2479 } 2480 if (is_arkui_x) { 2481 deps += [ "//third_party/bounds_checking_function:libsec_static" ] 2482 } else if (is_ohos) { 2483 if (is_component_build) { 2484 external_deps += [ "bounds_checking_function:libsec_shared" ] 2485 } else { 2486 external_deps += [ "bounds_checking_function:libsec_static" ] 2487 } 2488 } 2489} 2490 2491# DebugCanvas used in experimental/wasm-skp-debugger 2492if (is_wasm) { 2493 skia_static_library("debugcanvas") { 2494 public_configs = [ ":skia_public" ] 2495 2496 sources = [ 2497 "tools/SkSharingProc.cpp", 2498 "tools/UrlDataManager.cpp", 2499 "tools/debugger/DebugCanvas.cpp", 2500 "tools/debugger/DebugLayerManager.cpp", 2501 "tools/debugger/DrawCommand.cpp", 2502 "tools/debugger/JsonWriteBuffer.cpp", 2503 ] 2504 } 2505} 2506 2507skia_static_library("pathkit") { 2508 check_includes = false 2509 public_configs = [ ":skia_public" ] 2510 configs = skia_library_configs 2511 2512 deps = [ ":hsw" ] 2513 external_deps = [] 2514 2515 sources = [] 2516 sources += skia_pathops_sources 2517 sources += skia_pathops_public 2518 sources += [ 2519 "src/base/SkArenaAlloc.cpp", 2520 "src/base/SkBezierCurves.cpp", 2521 "src/base/SkContainers.cpp", 2522 "src/base/SkCubics.cpp", 2523 "src/base/SkFloatingPoint.cpp", 2524 "src/base/SkMalloc.cpp", 2525 "src/base/SkMathPriv.cpp", 2526 "src/base/SkQuads.cpp", 2527 "src/base/SkSafeMath.cpp", 2528 "src/base/SkSemaphore.cpp", 2529 "src/base/SkTDArray.cpp", 2530 "src/base/SkThreadID.cpp", 2531 "src/base/SkUTF.cpp", 2532 "src/base/SkUtils.cpp", 2533 "src/core/SkAnalyticEdge.cpp", 2534 "src/core/SkContourMeasure.cpp", 2535 "src/core/SkCubicMap.cpp", 2536 "src/core/SkEdge.cpp", 2537 "src/core/SkEdgeBuilder.cpp", 2538 "src/core/SkEdgeClipper.cpp", 2539 "src/core/SkGeometry.cpp", 2540 "src/core/SkIDChangeListener.cpp", 2541 "src/core/SkLineClipper.cpp", 2542 "src/core/SkMallocPixelRef.cpp", 2543 "src/core/SkMatrix.cpp", 2544 "src/core/SkOpts.cpp", 2545 "src/core/SkPaint.cpp", 2546 "src/core/SkPaintPriv.cpp", 2547 "src/core/SkPath.cpp", 2548 "src/core/SkPathBuilder.cpp", 2549 "src/core/SkPathEffect.cpp", 2550 "src/core/SkPathMeasure.cpp", 2551 "src/core/SkPathRef.cpp", 2552 "src/core/SkPathUtils.cpp", 2553 "src/core/SkPoint.cpp", 2554 "src/core/SkRRect.cpp", 2555 "src/core/SkReadBuffer.cpp", 2556 "src/core/SkRect.cpp", 2557 "src/core/SkStream.cpp", 2558 "src/core/SkString.cpp", 2559 "src/core/SkStringUtils.cpp", 2560 "src/core/SkStroke.cpp", 2561 "src/core/SkStrokeRec.cpp", 2562 "src/core/SkStrokerPriv.cpp", 2563 "src/effects/SkDashPathEffect.cpp", 2564 "src/effects/SkTrimPathEffect.cpp", 2565 "src/ports/SkDebug_stdio.cpp", 2566 "src/ports/SkMemory_malloc.cpp", 2567 "src/utils/SkDashPath.cpp", 2568 "src/utils/SkParse.cpp", 2569 "src/utils/SkParsePath.cpp", 2570 ] 2571 if (!build_ohos_sdk && !is_arkui_x) { 2572 external_deps += [ "init:libbegetutil" ] 2573 } 2574} 2575 2576group("modules") { 2577 deps = [ 2578 "modules/bentleyottmann", 2579 "modules/skottie", 2580 "modules/skparagraph", 2581 "modules/skshaper", 2582 "modules/svg", 2583 ] 2584 2585 if (is_wasm) { 2586 deps += [ "modules/canvaskit" ] 2587 } 2588} 2589 2590config("use_skia_vulkan_headers") { 2591 defines = [ "SK_USE_INTERNAL_VULKAN_HEADERS" ] 2592} 2593 2594config("vulkan_memory_allocator") { 2595 include_dirs = [ "${skia_third_party_dir}/vulkanmemoryallocator" ] 2596} 2597 2598# Targets guarded by skia_enable_tools may use ${skia_third_party_dir} freely. 2599if (skia_enable_tools) { 2600 skia_public_includes = [ 2601 "client_utils/android", 2602 "include/android", 2603 "include/codec", 2604 "include/config", 2605 "include/core", 2606 "include/docs", 2607 "include/effects", 2608 "include/encode", 2609 "include/gpu", 2610 "include/pathops", 2611 "include/ports", 2612 "include/svg", 2613 "include/utils", 2614 "include/utils/mac", 2615 "modules/skottie/include", 2616 "modules/skparagraph/include", 2617 "modules/skshaper/include", 2618 "modules/svg/include", 2619 ] 2620 2621 # Used by gn_to_bp.py to list our public include dirs. 2622 skia_source_set("public") { 2623 configs = [ ":skia_public" ] 2624 include_dirs = skia_public_includes 2625 } 2626 2627 config("skia.h_config") { 2628 include_dirs = [ "$target_gen_dir" ] 2629 } 2630 action("skia.h") { 2631 public_configs = [ ":skia.h_config" ] 2632 skia_h = "$target_gen_dir/skia.h" 2633 script = "gn/find_headers.py" 2634 2635 args = [ rebase_path("${skia_root_dir}/bin/gn") ] + [ rebase_path("//") ] + 2636 [ rebase_path(skia_h, root_build_dir) ] + 2637 rebase_path(skia_public_includes) 2638 depfile = "$skia_h.deps" 2639 outputs = [ skia_h ] 2640 } 2641 2642 if (is_linux && target_cpu == "x64") { 2643 skia_executable("fiddle") { 2644 check_includes = false 2645 libs = [] 2646 sources = [ 2647 "tools/fiddle/draw.cpp", 2648 "tools/fiddle/fiddle_main.cpp", 2649 ] 2650 2651 if (skia_use_egl) { 2652 sources += [ "tools/fiddle/egl_context.cpp" ] 2653 } else { 2654 sources += [ "tools/fiddle/null_context.cpp" ] 2655 } 2656 testonly = true 2657 deps = [ 2658 ":flags", 2659 ":gpu_tool_utils", 2660 ":skia", 2661 ":skia.h", 2662 "modules/skottie", 2663 "modules/skparagraph", 2664 "modules/skshaper", 2665 "modules/svg", 2666 ] 2667 } 2668 } 2669 2670 config("cpp17") { 2671 if (is_win) { 2672 cflags_cc = [ "/std:c++17" ] 2673 } else { 2674 cflags_cc = [ "-std=c++17" ] 2675 } 2676 } 2677 2678 skia_source_set("public_headers_warnings_check") { 2679 sources = [ "tools/public_headers_warnings_check.cpp" ] 2680 configs = [ 2681 ":use_skia_vulkan_headers", 2682 ":cpp17", 2683 ] 2684 if (defined(skia_header_target_default_configs)) { 2685 configs += skia_header_target_default_configs 2686 } 2687 deps = [ 2688 ":skia", 2689 ":skia.h", 2690 "modules/skottie", 2691 "modules/skshaper", 2692 ] 2693 2694 if (skia_use_dawn) { 2695 deps += [ "${skia_third_party_dir}/externals/dawn/include/dawn:headers" ] 2696 } 2697 } 2698 2699 template("test_lib") { 2700 config(target_name + "_config") { 2701 if (defined(invoker.public_defines)) { 2702 defines = invoker.public_defines 2703 } 2704 } 2705 skia_source_set(target_name) { 2706 forward_variables_from(invoker, "*", []) 2707 check_includes = false 2708 public_configs = [ 2709 ":" + target_name + "_config", 2710 ":skia_private", 2711 ] 2712 2713 if (!defined(deps)) { 2714 deps = [] 2715 } 2716 deps += [ ":skia" ] 2717 testonly = true 2718 } 2719 } 2720 2721 template("test_app") { 2722 if (is_ios) { 2723 ios_app_bundle(target_name) { 2724 forward_variables_from(invoker, 2725 "*", 2726 [ 2727 "output_name", 2728 "visibility", 2729 "is_shared_library", 2730 ]) 2731 testonly = true 2732 extra_configs = [ ":skia_private" ] 2733 launchscreen = "platform_tools/ios/app/LaunchScreen.storyboard" 2734 data_sources = [ "resources" ] 2735 if ("True" == exec_script("${skia_root_dir}/gn/checkdir.py", 2736 [ rebase_path("skps", root_build_dir) ], 2737 "trim string")) { 2738 data_sources += [ "skps" ] 2739 } 2740 if ("True" == exec_script("${skia_root_dir}/gn/checkdir.py", 2741 [ rebase_path("mskps", root_build_dir) ], 2742 "trim string")) { 2743 data_sources += [ "mskps" ] 2744 } 2745 } 2746 } else { 2747 # !is_ios 2748 2749 if (defined(invoker.is_shared_library) && invoker.is_shared_library) { 2750 skia_shared_library("lib" + target_name) { 2751 output_dir = root_build_dir 2752 forward_variables_from(invoker, "*", [ "is_shared_library" ]) 2753 if (!defined(configs)) { 2754 configs = [] 2755 } 2756 configs += [ ":skia_private" ] 2757 testonly = true 2758 } 2759 } else { 2760 _executable = target_name 2761 skia_executable(_executable) { 2762 check_includes = false 2763 output_dir = root_build_dir 2764 forward_variables_from(invoker, "*", [ "is_shared_library" ]) 2765 if (!defined(configs)) { 2766 configs = [] 2767 } 2768 configs += [ ":skia_private" ] 2769 testonly = true 2770 } 2771 } 2772 if (is_android && skia_android_serial != "" && defined(_executable)) { 2773 action("push_" + target_name) { 2774 output_dir = root_build_dir 2775 script = "gn/push_to_android.py" 2776 deps = [ ":" + _executable ] 2777 _stamp = "$target_gen_dir/$_executable.pushed_$skia_android_serial" 2778 outputs = [ _stamp ] 2779 args = [ 2780 rebase_path("$root_build_dir/$_executable"), 2781 skia_android_serial, 2782 rebase_path(_stamp), 2783 ] 2784 testonly = true 2785 } 2786 } 2787 } 2788 } 2789 2790 test_lib("load_dynamic_library") { 2791 configs = [ ":skia_private" ] 2792 deps = [ ":skia" ] 2793 sources = [ "tools/library/LoadDynamicLibrary.h" ] 2794 if (is_win) { 2795 sources += [ "tools/library/LoadDynamicLibrary_win.cpp" ] 2796 } else { 2797 sources += [ "tools/library/LoadDynamicLibrary_posix.cpp" ] 2798 } 2799 } 2800 2801 test_lib("gpu_tool_utils") { 2802 public_defines = [] 2803 public_deps = [] 2804 # Bots and even devs may not have Vulkan headers, so put 2805 # include/third_party/vulkan on our path so they're always available. 2806 configs = [ ":use_skia_vulkan_headers" ] 2807 if (is_ios || is_android) { 2808 public_deps += [ "//third_party/vulkan-headers:vulkan_headers" ] 2809 } else { 2810 external_deps = [] 2811 if (skia_use_vulkan) { 2812 external_deps += [ "vulkan-headers:vulkan_headers" ] 2813 } 2814 } 2815 2816 defines = [] 2817 if (skia_enable_discrete_gpu) { 2818 defines += [ "SK_ENABLE_DISCRETE_GPU" ] 2819 } 2820 2821 deps = [ ":load_dynamic_library" ] 2822 sources = [ 2823 "tools/gpu/BackendSurfaceFactory.cpp", 2824 "tools/gpu/BackendSurfaceFactory.h", 2825 "tools/gpu/BackendTextureImageFactory.cpp", 2826 "tools/gpu/BackendTextureImageFactory.h", 2827 "tools/gpu/ContextType.cpp", 2828 "tools/gpu/ContextType.h", 2829 "tools/gpu/FlushFinishTracker.cpp", 2830 "tools/gpu/FlushFinishTracker.h", 2831 "tools/gpu/GrContextFactory.cpp", 2832 "tools/gpu/GrContextFactory.h", 2833 "tools/gpu/GrTest.cpp", 2834 "tools/gpu/ManagedBackendTexture.cpp", 2835 "tools/gpu/ManagedBackendTexture.h", 2836 "tools/gpu/MemoryCache.cpp", 2837 "tools/gpu/MemoryCache.h", 2838 "tools/gpu/ProtectedUtils.cpp", 2839 "tools/gpu/ProtectedUtils.h", 2840 "tools/gpu/ProxyUtils.cpp", 2841 "tools/gpu/ProxyUtils.h", 2842 "tools/gpu/TestCanvas.cpp", 2843 "tools/gpu/TestCanvas.h", 2844 "tools/gpu/TestContext.cpp", 2845 "tools/gpu/TestOps.cpp", 2846 "tools/gpu/TestOps.h", 2847 "tools/gpu/YUVUtils.cpp", 2848 "tools/gpu/YUVUtils.h", 2849 "tools/gpu/mock/MockTestContext.cpp", 2850 "tools/text/gpu/TextBlobTools.cpp", 2851 ] 2852 2853 libs = [] 2854 frameworks = [] 2855 2856 if (skia_use_gl) { 2857 sources += [ "tools/gpu/gl/GLTestContext.cpp" ] 2858 if (is_ios) { 2859 sources += [ "tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm" ] 2860 frameworks += [ "OpenGLES.framework" ] 2861 } else if (is_mac) { 2862 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ] 2863 } 2864 if (skia_use_angle) { 2865 deps += [ "${skia_third_party_dir}/angle2" ] 2866 sources += [ "tools/gpu/gl/angle/GLTestContext_angle.cpp" ] 2867 } 2868 } 2869 2870 if (skia_use_gl && target_cpu != "wasm") { 2871 if (is_android || skia_use_egl || is_ohos) { 2872 sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ] 2873 if (is_ohos) { 2874 external_deps += [ 2875 "graphic_2d:EGL", 2876 "graphic_2d:GLESv3", 2877 ] 2878 } 2879 } else if (is_linux) { 2880 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ] 2881 libs += [ 2882 "GLU", 2883 "GL", 2884 "X11", 2885 ] 2886 } else if (is_win) { 2887 sources += [ 2888 "tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp", 2889 "tools/gpu/gl/win/SkWGL.h", 2890 "tools/gpu/gl/win/SkWGL_win.cpp", 2891 ] 2892 libs += [ "Gdi32.lib" ] 2893 if (target_cpu != "arm64") { 2894 libs += [ "OpenGL32.lib" ] 2895 } 2896 } 2897 } 2898 2899 if (skia_use_vulkan) { 2900 sources += [ "tools/gpu/vk/VkTestContext.h" ] 2901 sources += [ "tools/gpu/vk/VkTestContext.cpp" ] 2902 sources += [ "tools/gpu/vk/VkTestHelper.h" ] 2903 sources += [ "tools/gpu/vk/VkTestHelper.cpp" ] 2904 sources += [ "tools/gpu/vk/VkTestMemoryAllocator.h" ] 2905 sources += [ "tools/gpu/vk/VkTestMemoryAllocator.cpp" ] 2906 sources += [ "tools/gpu/vk/VkTestUtils.h" ] 2907 sources += [ "tools/gpu/vk/VkTestUtils.cpp" ] 2908 sources += [ "tools/gpu/vk/VkYcbcrSamplerHelper.h" ] 2909 sources += [ "tools/gpu/vk/VkYcbcrSamplerHelper.cpp" ] 2910 deps += [ "${skia_third_party_dir}/vulkanmemoryallocator:vulkan_memoryallocator" ] 2911 } 2912 if (skia_use_metal) { 2913 sources += [ "tools/gpu/mtl/MtlTestContext.mm" ] 2914 } 2915 if (skia_use_direct3d) { 2916 sources += [ "tools/gpu/d3d/D3DTestContext.cpp" ] 2917 sources += [ "tools/gpu/d3d/D3DTestUtils.cpp" ] 2918 } 2919 if (skia_use_dawn) { 2920 public_deps += [ "${skia_third_party_dir}/externals/dawn/include/dawn:headers" ] 2921 if (is_clang) { 2922 cflags_cc = [ "-Wno-microsoft-cast" ] 2923 } 2924 } 2925 if (!skia_enable_ganesh) { 2926 sources -= [ "tools/gpu/GrTest.cpp" ] 2927 sources -= [ "tools/gpu/TestOps.cpp" ] 2928 sources -= [ "tools/gpu/TestOps.h" ] 2929 } else { 2930 sources += [ 2931 "tools/gpu/ganesh/AtlasTextOpTools.cpp", 2932 "tools/gpu/ganesh/AtlasTextOpTools.h", 2933 "tools/gpu/ganesh/GrAtlasTools.cpp", 2934 "tools/gpu/ganesh/GrAtlasTools.h", 2935 ] 2936 } 2937 if (skia_enable_graphite) { 2938 sources += [ 2939 "tools/graphite/ContextFactory.cpp", 2940 "tools/graphite/ContextFactory.h", 2941 "tools/graphite/GraphiteTestContext.cpp", 2942 "tools/graphite/GraphiteTestContext.h", 2943 "tools/graphite/GraphiteToolUtils.cpp", 2944 "tools/graphite/GraphiteToolUtils.h", 2945 "tools/graphite/ProtectedUtils_Graphite.cpp", 2946 "tools/graphite/UniqueKeyUtils.cpp", 2947 "tools/graphite/UniqueKeyUtils.h", 2948 ] 2949 if (skia_use_dawn) { 2950 sources += [ 2951 "tools/graphite/dawn/GraphiteDawnTestContext.cpp", 2952 "tools/graphite/dawn/GraphiteDawnTestContext.h", 2953 ] 2954 } 2955 if (skia_use_metal) { 2956 sources += [ 2957 "tools/graphite/mtl/GraphiteMtlTestContext.h", 2958 "tools/graphite/mtl/GraphiteMtlTestContext.mm", 2959 ] 2960 } 2961 if (skia_use_vulkan) { 2962 sources += [ 2963 "tools/graphite/vk/GraphiteVulkanTestContext.cpp", 2964 "tools/graphite/vk/GraphiteVulkanTestContext.h", 2965 ] 2966 } 2967 } 2968 2969 if (is_fuchsia && using_fuchsia_sdk) { 2970 libs += 2971 [ "${fuchsia_sdk_path}/arch/${target_cpu}/sysroot/lib/libzircon.so" ] 2972 } 2973 if (is_ohos) { 2974 external_deps += [ "hitrace:hitrace_meter" ] 2975 if (!build_ohos_sdk && !is_arkui_x) { 2976 external_deps += [ "init:libbegetutil" ] 2977 } 2978 } 2979 if (is_arkui_x) { 2980 deps += [ "//third_party/bounds_checking_function:libsec_static" ] 2981 } else if (is_ohos) { 2982 if (is_component_build) { 2983 external_deps += [ "bounds_checking_function:libsec_shared" ] 2984 } else { 2985 external_deps += [ "bounds_checking_function:libsec_static" ] 2986 } 2987 } 2988 } # test_lib("gpu_tool_utils") 2989 2990 test_lib("flags") { 2991 sources = [ 2992 "tools/flags/CommandLineFlags.cpp", 2993 "tools/flags/CommandLineFlags.h", 2994 ] 2995 } 2996 2997 test_lib("common_flags_config") { 2998 sources = [ 2999 "tools/flags/CommonFlags.h", 3000 "tools/flags/CommonFlagsConfig.cpp", 3001 "tools/flags/CommonFlagsConfig.h", 3002 ] 3003 deps = [ ":flags" ] 3004 public_deps = [ ":gpu_tool_utils" ] 3005 } 3006 test_lib("common_flags_gpu") { 3007 sources = [ "tools/flags/CommonFlagsGanesh.cpp" ] 3008 deps = [ ":flags" ] 3009 public_deps = [ ":gpu_tool_utils" ] 3010 } 3011 test_lib("common_flags_graphite") { 3012 sources = [ "tools/flags/CommonFlagsGraphite.cpp" ] 3013 deps = [ ":flags" ] 3014 public_deps = [ ":gpu_tool_utils" ] 3015 } 3016 test_lib("common_flags_images") { 3017 sources = [ "tools/flags/CommonFlagsImages.cpp" ] 3018 deps = [ ":flags" ] 3019 } 3020 3021 test_lib("trace") { 3022 deps = [ ":flags" ] 3023 sources = [ 3024 "tools/trace/ChromeTracingTracer.cpp", 3025 "tools/trace/ChromeTracingTracer.h", 3026 "tools/trace/EventTracingPriv.cpp", 3027 "tools/trace/EventTracingPriv.h", 3028 "tools/trace/SkDebugfTracer.cpp", 3029 "tools/trace/SkDebugfTracer.h", 3030 ] 3031 if (skia_use_perfetto) { 3032 deps += [ "${skia_third_party_dir}/perfetto" ] 3033 sources += [ 3034 "tools/trace/SkPerfettoTrace.cpp", 3035 "tools/trace/SkPerfettoTrace.h", 3036 ] 3037 defines = [ "SK_USE_PERFETTO" ] 3038 } 3039 if (is_ohos) { 3040 external_deps = [ "hitrace:hitrace_meter" ] 3041 if (!build_ohos_sdk && !is_arkui_x) { 3042 external_deps += [ "init:libbegetutil" ] 3043 } 3044 } 3045 if (is_arkui_x) { 3046 deps += [ "//third_party/bounds_checking_function:libsec_static" ] 3047 } else if (is_ohos) { 3048 if (is_component_build) { 3049 external_deps += [ "bounds_checking_function:libsec_shared" ] 3050 } else { 3051 external_deps += [ "bounds_checking_function:libsec_static" ] 3052 } 3053 } 3054 } 3055 3056 test_lib("tool_utils") { 3057 sources = [ 3058 "tools/AndroidSkDebugToStdOut.cpp", 3059 "tools/AutoreleasePool.h", 3060 "tools/DDLPromiseImageHelper.cpp", 3061 "tools/DDLPromiseImageHelper.h", 3062 "tools/DDLTileHelper.cpp", 3063 "tools/DDLTileHelper.h", 3064 "tools/DecodeUtils.cpp", 3065 "tools/DecodeUtils.h", 3066 "tools/EncodeUtils.cpp", 3067 "tools/EncodeUtils.h", 3068 "tools/GpuToolUtils.h", 3069 "tools/LsanSuppressions.cpp", 3070 "tools/ProcStats.cpp", 3071 "tools/ProcStats.h", 3072 "tools/Resources.cpp", 3073 "tools/Resources.h", 3074 "tools/RuntimeBlendUtils.cpp", 3075 "tools/RuntimeBlendUtils.h", 3076 "tools/SkMetaData.cpp", 3077 "tools/SkMetaData.h", 3078 "tools/Stats.h", 3079 "tools/TestFontDataProvider.cpp", 3080 "tools/TestFontDataProvider.h", 3081 "tools/ToolUtils.cpp", 3082 "tools/ToolUtils.h", 3083 "tools/TsanSuppressions.cpp", 3084 "tools/UrlDataManager.cpp", 3085 "tools/UrlDataManager.h", 3086 "tools/debugger/DebugCanvas.cpp", 3087 "tools/debugger/DebugCanvas.h", 3088 "tools/debugger/DebugLayerManager.cpp", 3089 "tools/debugger/DebugLayerManager.h", 3090 "tools/debugger/DrawCommand.cpp", 3091 "tools/debugger/DrawCommand.h", 3092 "tools/debugger/JsonWriteBuffer.cpp", 3093 "tools/debugger/JsonWriteBuffer.h", 3094 "tools/fonts/FontToolUtils.cpp", 3095 "tools/fonts/FontToolUtils.h", 3096 "tools/fonts/RandomScalerContext.cpp", 3097 "tools/fonts/RandomScalerContext.h", 3098 "tools/fonts/TestEmptyTypeface.h", 3099 "tools/fonts/TestFontMgr.cpp", 3100 "tools/fonts/TestFontMgr.h", 3101 "tools/fonts/TestSVGTypeface.cpp", 3102 "tools/fonts/TestSVGTypeface.h", 3103 "tools/fonts/TestTypeface.cpp", 3104 "tools/fonts/TestTypeface.h", 3105 "tools/sksltrace/SkSLTraceUtils.cpp", 3106 "tools/sksltrace/SkSLTraceUtils.h", 3107 "tools/text/SkTextBlobTrace.cpp", 3108 "tools/text/SkTextBlobTrace.h", 3109 "tools/timer/TimeUtils.h", 3110 "tools/timer/Timer.cpp", 3111 "tools/timer/Timer.h", 3112 ] 3113 if (skia_enable_svg) { 3114 sources += [ 3115 "tools/SvgPathExtractor.cpp", 3116 "tools/SvgPathExtractor.h", 3117 ] 3118 } 3119 if (skia_use_libpng_decode) { 3120 sources += [ 3121 "tools/MSKPPlayer.cpp", 3122 "tools/MSKPPlayer.h", 3123 "tools/SkSharingProc.cpp", 3124 "tools/SkSharingProc.h", 3125 ] 3126 } 3127 3128 if (target_cpu != "wasm") { 3129 sources += [ "tools/CrashHandler.cpp" ] 3130 } 3131 libs = [] 3132 frameworks = [] 3133 if (is_ios) { 3134 sources += [ "tools/ios_utils.m" ] 3135 sources += [ "tools/ios_utils.h" ] 3136 sources += [ "tools/AutoreleasePool.mm" ] 3137 frameworks += [ "Foundation.framework" ] 3138 } else if (is_mac) { 3139 sources += [ "tools/AutoreleasePool.mm" ] 3140 frameworks += [ "Foundation.framework" ] 3141 } else if (is_win && !skia_enable_winuwp) { 3142 libs += [ "DbgHelp.lib" ] 3143 } 3144 3145 defines = [] 3146 if (skia_tools_require_resources) { 3147 defines += [ "SK_TOOLS_REQUIRE_RESOURCES" ] 3148 } 3149 deps = [ ":flags" ] 3150 if (skia_enable_svg) { 3151 deps += [ "modules/svg" ] 3152 } 3153 deps += [ ":xml" ] 3154 public_deps = [ 3155 ":gpu_tool_utils", 3156 "modules/jsonreader", 3157 ] 3158 } 3159 3160 test_lib("etc1") { 3161 sources = [ "third_party/etc1/etc1.cpp" ] 3162 } 3163 3164 import("gn/gm.gni") 3165 test_lib("gm") { 3166 sources = gm_sources 3167 if (skia_use_gl) { 3168 sources += gl_gm_sources 3169 } 3170 if (!skia_enable_ganesh) { 3171 sources -= ganesh_gm_sources 3172 } 3173 if (skia_use_fontations) { 3174 sources += fontations_gm_sources 3175 } 3176 deps = [ 3177 ":etc1", 3178 ":flags", 3179 ":skia", 3180 ":tool_utils", 3181 "modules/skottie", 3182 "modules/skottie:gm", 3183 "modules/skresources", 3184 "modules/skshaper", 3185 ] 3186 if (skia_use_vulkan) { 3187 external_deps = [ "vulkan-headers:vulkan_headers" ] 3188 } else { 3189 external_deps = [] 3190 } 3191 if (is_ohos) { 3192 external_deps += [ "hitrace:hitrace_meter" ] 3193 if (!build_ohos_sdk && !is_arkui_x) { 3194 external_deps += [ "init:libbegetutil" ] 3195 } 3196 } 3197 if (is_arkui_x) { 3198 deps += [ "//third_party/bounds_checking_function:libsec_static" ] 3199 } else if (is_ohos) { 3200 if (is_component_build) { 3201 external_deps += [ "bounds_checking_function:libsec_shared" ] 3202 } else { 3203 external_deps += [ "bounds_checking_function:libsec_static" ] 3204 } 3205 } 3206 if (gm_test_enable_font) { 3207 deps += [ 3208 "modules/skparagraph", 3209 "modules/skparagraph:gm", 3210 ] 3211 sources += gm_font_sources 3212 } 3213 if (is_skia_dev_build) { 3214 sources += [ "gm/fiddle.cpp" ] 3215 deps += [ ":skia.h" ] 3216 } 3217 public_deps = [ ":gpu_tool_utils" ] 3218 3219 if (skia_use_ffmpeg) { 3220 deps += [ "experimental/ffmpeg:video_decoder" ] 3221 sources += [ "gm/video_decoder.cpp" ] 3222 } 3223 } 3224 3225 test_lib("test") { 3226 sources = [ 3227 "tests/CtsEnforcement.cpp", 3228 "tests/Test.cpp", 3229 "tests/Test.h", 3230 "tests/TestHarness.cpp", 3231 "tests/TestHarness.h", 3232 "tests/TestUtils.cpp", 3233 "tests/TestUtils.h", 3234 ] 3235 deps = [ 3236 ":flags", 3237 ":skia", 3238 ":tool_utils", 3239 ] 3240 public_deps = [ 3241 ":gpu_tool_utils", # Test.h #includes headers from this target. 3242 ] 3243 if (is_ohos) { 3244 external_deps = [ "hitrace:hitrace_meter" ] 3245 if (!build_ohos_sdk && !is_arkui_x) { 3246 external_deps += [ "init:libbegetutil" ] 3247 } 3248 } 3249 if (is_arkui_x) { 3250 deps += [ "//third_party/bounds_checking_function:libsec_static" ] 3251 } else if (is_ohos) { 3252 if (is_component_build) { 3253 external_deps += [ "bounds_checking_function:libsec_shared" ] 3254 } else { 3255 external_deps += [ "bounds_checking_function:libsec_static" ] 3256 } 3257 } 3258 } 3259 3260 import("gn/tests.gni") 3261 test_lib("tests") { 3262 sources = tests_sources + pathops_tests_sources 3263 frameworks = [] 3264 if (skia_use_metal) { 3265 sources += metal_tests_sources 3266 cflags_objcc = [ "-fobjc-arc" ] 3267 frameworks += [ "MetalKit.framework" ] 3268 } 3269 if (skia_use_jpeg_gainmaps) { 3270 sources += jpeg_gainmap_tests_sources 3271 } 3272 if (skia_use_gl) { 3273 sources += gl_tests_sources 3274 } 3275 if (skia_use_vulkan) { 3276 sources += skia_gpu_vk_chromium_public 3277 sources += skia_gpu_vk_chromium_private 3278 } 3279 if (skia_enable_graphite) { 3280 sources += graphite_tests_sources 3281 if (skia_use_dawn) { 3282 sources += graphite_dawn_tests_sources 3283 } 3284 if (skia_use_metal) { 3285 sources += graphite_metal_tests_sources 3286 } 3287 if (skia_use_vulkan) { 3288 sources += graphite_vulkan_tests_sources 3289 } 3290 } 3291 if (!skia_enable_ganesh) { 3292 sources -= ganesh_tests_sources 3293 } 3294 if (skia_enable_precompile) { 3295 sources += precompile_tests_sources 3296 } 3297 if (gm_test_enable_font) { 3298 sources += font_tests_sources 3299 } 3300 deps = [ 3301 ":flags", 3302 ":fontmgr_FontConfigInterface_tests", 3303 ":fontmgr_android_tests", 3304 ":fontmgr_fontconfig_tests", 3305 ":fontmgr_mac_ct_tests", 3306 ":fontscanner_tests", 3307 ":jpeg_decode", 3308 ":png_decode_rust_tests", 3309 ":png_encode_rust_tests", 3310 ":skia", 3311 ":test", 3312 ":tool_utils", 3313 ":typeface_fontations_tests", 3314 "modules/bentleyottmann:tests", 3315 "modules/skottie:tests", 3316 "modules/sksg:tests", 3317 "modules/skshaper", 3318 "modules/skunicode:tests", 3319 "${skia_third_party_dir}/libwebp:libwebpm133", 3320 ] 3321 if (skia_use_vulkan) { 3322 external_deps = [ "vulkan-headers:vulkan_headers" ] 3323 } else { 3324 external_deps = [] 3325 } 3326 if (skia_use_system_lib) { 3327 external_deps += [ 3328 "libpng:libpng", 3329 "zlib:libz", 3330 ] 3331 } else { 3332 deps += [ 3333 "${skia_third_party_dir}/libpng", 3334 "${skia_third_party_dir}/zlib", 3335 ] 3336 } 3337 if (gm_test_enable_font) { 3338 deps += [ 3339 "modules/skparagraph:tests", 3340 "modules/skshaper:tests", 3341 "modules/svg:tests", 3342 ] 3343 } 3344 if (is_ohos) { 3345 external_deps += [ "hitrace:hitrace_meter" ] 3346 if (!build_ohos_sdk && !is_arkui_x) { 3347 external_deps += [ "init:libbegetutil" ] 3348 } 3349 } 3350 if (is_arkui_x) { 3351 deps += [ "//third_party/bounds_checking_function:libsec_static" ] 3352 } else if (is_ohos) { 3353 if (is_component_build) { 3354 external_deps += [ "bounds_checking_function:libsec_shared" ] 3355 } else { 3356 external_deps += [ "bounds_checking_function:libsec_static" ] 3357 } 3358 } 3359 } 3360 3361 import("gn/bench.gni") 3362 test_lib("bench") { 3363 sources = bench_sources 3364 if (skia_enable_graphite) { 3365 sources += graphite_bench_sources 3366 } 3367 if (!skia_enable_ganesh) { 3368 sources -= ganesh_bench_sources 3369 } 3370 deps = [ 3371 ":flags", 3372 ":gm", 3373 ":gpu_tool_utils", 3374 ":skia", 3375 ":tool_utils", 3376 "modules/skparagraph:bench", 3377 "modules/skshaper", 3378 ] 3379 if (is_ohos) { 3380 external_deps = [ "hitrace:hitrace_meter" ] 3381 if (!build_ohos_sdk && !is_arkui_x) { 3382 external_deps += [ "init:libbegetutil" ] 3383 } 3384 } 3385 if (is_arkui_x) { 3386 deps += [ "//third_party/bounds_checking_function:libsec_static" ] 3387 } else if (is_ohos) { 3388 if (is_component_build) { 3389 external_deps += [ "bounds_checking_function:libsec_shared" ] 3390 } else { 3391 external_deps += [ "bounds_checking_function:libsec_static" ] 3392 } 3393 } 3394 } 3395 3396 if (is_linux || is_mac || skia_enable_optimize_size) { 3397 if (skia_enable_skottie) { 3398 test_app("skottie_tool") { 3399 deps = [ "modules/skottie:tool" ] 3400 } 3401 test_app("skottie_tool_cpu") { 3402 deps = [ "modules/skottie:tool_cpu" ] 3403 } 3404 test_app("skottie_tool_gpu") { 3405 deps = [ "modules/skottie:tool_gpu" ] 3406 } 3407 test_app("skottie_preshape_tool") { 3408 deps = [ "modules/skottie:preshape_tool" ] 3409 } 3410 } 3411 if (skia_enable_svg && skia_use_expat && defined(is_skia_standalone)) { 3412 test_app("svg_tool") { 3413 deps = [ "modules/svg:tool" ] 3414 } 3415 } 3416 } 3417 3418 test_lib("hash_and_encode") { 3419 sources = [ 3420 "tools/HashAndEncode.cpp", 3421 "tools/HashAndEncode.h", 3422 ] 3423 deps = [ 3424 ":flags", 3425 ":skia", 3426 ] 3427 if (skia_use_system_lib) { 3428 external_deps = [ "libpng:libpng" ] 3429 } else { 3430 deps += [ "${skia_third_party_dir}/libpng" ] 3431 } 3432 } 3433 if (target_cpu != "wasm") { 3434 test_app("convert-to-nia") { 3435 sources = [ "tools/convert-to-nia.cpp" ] 3436 deps = [ ":skia" ] 3437 } 3438 test_app("imgcvt") { 3439 sources = [ "tools/imgcvt.cpp" ] 3440 configs = [ ":use_skia_vulkan_headers" ] 3441 if (is_ios || is_android) { 3442 public_deps = [ "//third_party/vulkan-headers:vulkan_headers" ] 3443 } else { 3444 if (skia_use_vulkan) { 3445 external_deps = [ "vulkan-headers:vulkan_headers" ] 3446 } else { 3447 external_deps = [] 3448 } 3449 } 3450 deps = [ 3451 ":skia", 3452 "modules/skcms", 3453 ] 3454 } 3455 test_app("dm") { 3456 sources = [ 3457 "dm/DM.cpp", 3458 "dm/DMGpuTestProcs.cpp", 3459 "dm/DMJsonWriter.cpp", 3460 "dm/DMJsonWriter.h", 3461 "dm/DMSrcSink.cpp", 3462 "dm/DMSrcSink.h", 3463 ] 3464 deps = [ 3465 ":common_flags_config", 3466 ":common_flags_gpu", 3467 ":common_flags_graphite", 3468 ":common_flags_images", 3469 ":compile_all_sksl_tests", 3470 ":flags", 3471 ":gm", 3472 ":gpu_tool_utils", 3473 ":hash_and_encode", 3474 ":skia", 3475 ":tests", 3476 ":tool_utils", 3477 ":trace", 3478 "modules/skottie", 3479 "modules/skottie:utils", 3480 "modules/skunicode", 3481 ] 3482 if (gm_test_enable_font) { 3483 deps += [ "modules/skshaper", ] 3484 } 3485 if (skia_use_libpng_decode) { 3486 deps += [ "modules/svg" ] 3487 } 3488 ldflags = [ 3489 "--stdlib=libc++", 3490 "-lc++", 3491 ] 3492 if (is_ohos) { 3493 sources += [ "${skia_root_dir}/src/ports/SkDebug_ohos.cpp" ] 3494 external_deps = [ 3495 "bounds_checking_function:libsec_shared", 3496 "faultloggerd:libbacktrace_local", 3497 "hilog:libhilog", 3498 "hitrace:hitrace_meter", 3499 "init:libbegetutil", 3500 ] 3501 deps += [ "modules/svg" ] 3502 } 3503 } 3504 test_app("filterfuzz") { 3505 sources = [ "experimental/filterfuzz/filterfuzz.cpp" ] 3506 deps = [ 3507 ":flags", 3508 ":skia", 3509 ":tool_utils", 3510 ] 3511 } 3512 3513 if (!skia_enable_optimize_size && !skia_use_fontations && 3514 !skia_enable_vello_shaders) { 3515 # optional separate library to dlopen when running CanvasStateTests. 3516 skia_shared_library("canvas_state_lib") { 3517 sources = [ 3518 "tests/CanvasStateHelpers.cpp", 3519 "tests/CanvasStateHelpers.h", 3520 ] 3521 deps = [ ":skia" ] 3522 } 3523 } 3524 } 3525 3526 if (!is_win) { 3527 test_app("blob_cache_sim") { 3528 sources = [ "tools/blob_cache_sim.cpp" ] 3529 deps = [ 3530 ":skia", 3531 ":tool_utils", 3532 ] 3533 } 3534 } 3535 3536 if (skia_use_libpng_decode) { 3537 test_app("nanobench") { 3538 sources = [ 3539 "bench/nanobench.cpp", 3540 "bench/nanobench.h", 3541 ] 3542 deps = [ 3543 ":bench", 3544 ":common_flags_config", 3545 ":common_flags_gpu", 3546 ":common_flags_graphite", 3547 ":common_flags_images", 3548 ":flags", 3549 ":gm", 3550 ":gpu_tool_utils", 3551 ":skia", 3552 ":tool_utils", 3553 ":trace", 3554 "modules/skunicode", 3555 "modules/svg", 3556 ] 3557 if (gm_test_enable_font) { 3558 deps += [ 3559 "modules/skparagraph", 3560 "modules/skshaper", 3561 ] 3562 } 3563 ldflags = [ 3564 "--stdlib=libc++", 3565 "-lc++", 3566 ] 3567 if (is_ohos) { 3568 sources += [ "${skia_root_dir}/src/ports/SkDebug_ohos.cpp" ] 3569 sources += skia_skottie_sources 3570 external_deps = [ 3571 "bounds_checking_function:libsec_shared", 3572 "faultloggerd:libbacktrace_local", 3573 "hilog:libhilog", 3574 "hitrace:hitrace_meter", 3575 "init:libbegetutil", 3576 ] 3577 deps += [ "modules/sksg" ] 3578 } 3579 } 3580 } 3581 3582 test_app("skpinfo") { 3583 sources = [ "tools/skpinfo.cpp" ] 3584 configs = [ ":use_skia_vulkan_headers" ] 3585 deps = [ 3586 ":flags", 3587 ":skia", 3588 ] 3589 } 3590 3591 if (skia_use_ffmpeg) { 3592 test_app("skottie2movie") { 3593 sources = [ "tools/skottie2movie.cpp" ] 3594 deps = [ 3595 ":flags", 3596 ":gpu_tool_utils", 3597 ":skia", 3598 "experimental/ffmpeg:video_encoder", 3599 "modules/skottie", 3600 "modules/skottie:utils", 3601 ] 3602 } 3603 } 3604 3605 if (skia_use_libpng_decode) { 3606 test_app("skpbench") { 3607 sources = [ 3608 "bench/BigPath.cpp", 3609 "tools/skpbench/skpbench.cpp", 3610 ] 3611 deps = [ 3612 ":common_flags_config", 3613 ":common_flags_gpu", 3614 ":flags", 3615 ":gpu_tool_utils", 3616 ":skia", 3617 ":tool_utils", 3618 ] 3619 } 3620 } 3621 3622 if (is_linux && skia_use_icu) { 3623 test_app("sktexttopdf") { 3624 sources = [ "tools/using_skia_and_harfbuzz.cpp" ] 3625 deps = [ 3626 ":skia", 3627 "modules/skshaper", 3628 ] 3629 } 3630 } 3631 3632 if (is_linux || is_mac) { 3633 test_app("create_test_font") { 3634 sources = [ "tools/fonts/create_test_font.cpp" ] 3635 deps = [ ":skia" ] 3636 assert_no_deps = [ 3637 # tool_utils requires the output of this app. 3638 ":tool_utils", 3639 ] 3640 } 3641 } 3642 3643 if (skia_use_expat) { 3644 test_app("create_test_font_color") { 3645 sources = [ "tools/fonts/create_test_font_color.cpp" ] 3646 deps = [ 3647 ":flags", 3648 ":skia", 3649 ":tool_utils", 3650 "modules/svg", 3651 ] 3652 } 3653 } 3654 3655 test_app("get_images_from_skps") { 3656 sources = [ "tools/get_images_from_skps.cpp" ] 3657 deps = [ 3658 ":flags", 3659 ":skia", 3660 ] 3661 } 3662 3663 test_app("fuzz") { 3664 sources = [ 3665 "fuzz/Fuzz.cpp", 3666 "fuzz/Fuzz.h", 3667 "fuzz/FuzzCanvas.cpp", 3668 "fuzz/FuzzCommon.cpp", 3669 "fuzz/FuzzCommon.h", 3670 "fuzz/FuzzCreateDDL.cpp", 3671 "fuzz/FuzzCubicRoots.cpp", 3672 "fuzz/FuzzDDLThreading.cpp", 3673 "fuzz/FuzzDrawFunctions.cpp", 3674 "fuzz/FuzzEncoders.cpp", 3675 "fuzz/FuzzGradients.cpp", 3676 "fuzz/FuzzMain.cpp", 3677 "fuzz/FuzzParsePath.cpp", 3678 "fuzz/FuzzPathMeasure.cpp", 3679 "fuzz/FuzzPathop.cpp", 3680 "fuzz/FuzzPolyUtils.cpp", 3681 "fuzz/FuzzQuadRoots.cpp", 3682 "fuzz/FuzzRegionOp.cpp", 3683 "fuzz/FuzzSkParagraph.cpp", 3684 "fuzz/FuzzTriangulation.cpp", 3685 "fuzz/oss_fuzz/FuzzAndroidCodec.cpp", 3686 "fuzz/oss_fuzz/FuzzAnimatedImage.cpp", 3687 "fuzz/oss_fuzz/FuzzCOLRv1.cpp", 3688 "fuzz/oss_fuzz/FuzzColorspace.cpp", 3689 "fuzz/oss_fuzz/FuzzImage.cpp", 3690 "fuzz/oss_fuzz/FuzzImageFilterDeserialize.cpp", 3691 "fuzz/oss_fuzz/FuzzIncrementalImage.cpp", 3692 "fuzz/oss_fuzz/FuzzJSON.cpp", 3693 "fuzz/oss_fuzz/FuzzParsePath.cpp", 3694 "fuzz/oss_fuzz/FuzzPathDeserialize.cpp", 3695 "fuzz/oss_fuzz/FuzzRegionDeserialize.cpp", 3696 "fuzz/oss_fuzz/FuzzRegionSetPath.cpp", 3697 "fuzz/oss_fuzz/FuzzSKP.cpp", 3698 "fuzz/oss_fuzz/FuzzSKSL2GLSL.cpp", 3699 "fuzz/oss_fuzz/FuzzSKSL2Metal.cpp", 3700 "fuzz/oss_fuzz/FuzzSKSL2Pipeline.cpp", 3701 "fuzz/oss_fuzz/FuzzSKSL2SPIRV.cpp", 3702 "fuzz/oss_fuzz/FuzzSKSL2WGSL.cpp", 3703 "fuzz/oss_fuzz/FuzzSVG.cpp", 3704 "fuzz/oss_fuzz/FuzzSkDescriptorDeserialize.cpp", 3705 "fuzz/oss_fuzz/FuzzSkMeshSpecification.cpp", 3706 "fuzz/oss_fuzz/FuzzSkParagraph.cpp", 3707 "fuzz/oss_fuzz/FuzzSkRuntimeBlender.cpp", 3708 "fuzz/oss_fuzz/FuzzSkRuntimeColorFilter.cpp", 3709 "fuzz/oss_fuzz/FuzzSkRuntimeEffect.cpp", 3710 "fuzz/oss_fuzz/FuzzTextBlobDeserialize.cpp", 3711 "tools/UrlDataManager.cpp", 3712 "tools/debugger/DebugCanvas.cpp", 3713 "tools/debugger/DebugLayerManager.cpp", 3714 "tools/debugger/DrawCommand.cpp", 3715 "tools/debugger/JsonWriteBuffer.cpp", 3716 "tools/fonts/FontToolUtils.cpp", 3717 ] 3718 3719 if (skia_enable_graphite && skia_enable_precompile) { 3720 sources += [ "fuzz/FuzzPrecompile.cpp" ] 3721 } 3722 deps = [ 3723 ":flags", 3724 ":gpu_tool_utils", 3725 ":skia", 3726 "modules/jsonreader", 3727 "modules/skottie:fuzz", 3728 "modules/skparagraph", 3729 "modules/svg", 3730 ] 3731 } 3732 3733 test_app("dump_record") { 3734 sources = [ "tools/dump_record.cpp" ] 3735 deps = [ 3736 ":flags", 3737 ":skia", 3738 ] 3739 } 3740 3741 if (skia_use_libpng_decode) { 3742 test_app("skdiff") { 3743 sources = [ 3744 "tools/skdiff/skdiff.cpp", 3745 "tools/skdiff/skdiff_html.cpp", 3746 "tools/skdiff/skdiff_main.cpp", 3747 "tools/skdiff/skdiff_utils.cpp", 3748 ] 3749 deps = [ ":skia" ] 3750 } 3751 3752 test_app("skp_parser") { 3753 sources = [ "tools/skp_parser.cpp" ] 3754 deps = [ 3755 ":skia", 3756 ":tool_utils", 3757 ] 3758 } 3759 } 3760 3761 if (!is_win) { 3762 source_set("skqp_lib") { # Not a skia_source_set 3763 check_includes = false 3764 testonly = true 3765 public_configs = [ ":skia_private" ] 3766 sources = [ 3767 "tools/skqp/src/skqp.cpp", 3768 "tools/skqp/src/skqp.h", 3769 "tools/skqp/src/skqp_GpuTestProcs.cpp", 3770 ] 3771 deps = [ 3772 ":gm", 3773 ":skia", 3774 ":tests", 3775 ":tool_utils", 3776 ] 3777 } 3778 if (skia_use_libpng_decode) { 3779 test_app("skqp") { 3780 sources = [ "tools/skqp/src/skqp_main.cpp" ] 3781 deps = [ ":skqp_lib" ] 3782 } 3783 } 3784 } 3785 if (is_fuchsia) { 3786 # Build a package repository for skqp on Fuchsia. 3787 group("skqp_repo") { 3788 testonly = true 3789 deps = [ "${skia_root_dir}/build/fuchsia/skqp:skqp_repo" ] 3790 } 3791 } 3792 if (is_android) { 3793 shared_library("libskqp_jni") { # Not a skia_shared_library 3794 configs += [ ":skia_private" ] 3795 testonly = true 3796 sources = [ "tools/skqp/src/jni_skqp.cpp" ] 3797 deps = [ 3798 ":skia", 3799 ":skqp_lib", 3800 ":tool_utils", 3801 ] 3802 libs = [ "android" ] 3803 } 3804 } 3805 if (is_android && skia_use_gl) { 3806 test_app("skottie_android") { 3807 is_shared_library = true 3808 3809 sources = [ "platform_tools/android/apps/skottie/skottielib/src/main/cpp/native-lib.cpp" ] 3810 libs = [] 3811 3812 deps = [ 3813 ":skia", 3814 "modules/skottie", 3815 "modules/skshaper", 3816 "modules/skunicode", 3817 ] 3818 } 3819 3820 test_app("jetski") { 3821 is_shared_library = true 3822 3823 sources = [ 3824 "modules/jetski/src/Canvas.cpp", 3825 "modules/jetski/src/ColorFilters.cpp", 3826 "modules/jetski/src/Gradients.cpp", 3827 "modules/jetski/src/Image.cpp", 3828 "modules/jetski/src/ImageFilter.cpp", 3829 "modules/jetski/src/JetSki.cpp", 3830 "modules/jetski/src/Matrix.cpp", 3831 "modules/jetski/src/Paint.cpp", 3832 "modules/jetski/src/Path.cpp", 3833 "modules/jetski/src/PathBuilder.cpp", 3834 "modules/jetski/src/RuntimeShaderBuilder.cpp", 3835 "modules/jetski/src/Shader.cpp", 3836 "modules/jetski/src/SkottieAnimation.cpp", 3837 "modules/jetski/src/Surface.cpp", 3838 "modules/jetski/src/Surface.h", 3839 "modules/jetski/src/SurfaceThread.cpp", 3840 "modules/jetski/src/SurfaceThread.h", 3841 "modules/jetski/src/Utils.cpp", 3842 ] 3843 libs = [ 3844 "android", 3845 "jnigraphics", 3846 ] 3847 3848 deps = [ 3849 ":skia", 3850 "modules/skottie:skottie", 3851 "tools/window:window", 3852 ] 3853 } 3854 } 3855 3856 if (is_ios && skia_enable_skottie) { 3857 group("skottie_ios") { 3858 deps = [ "tools/skottie_ios_app" ] 3859 } 3860 } 3861 3862 test_lib("sk_app") { 3863 public_deps = [ 3864 ":gpu_tool_utils", 3865 ":skia", 3866 ] 3867 sources = [ 3868 "tools/sk_app/Application.h", 3869 "tools/sk_app/CommandSet.cpp", 3870 "tools/sk_app/CommandSet.h", 3871 "tools/sk_app/Window.cpp", 3872 "tools/sk_app/Window.h", 3873 ] 3874 libs = [] 3875 frameworks = [] 3876 3877 if (is_android) { 3878 sources += [ 3879 "tools/sk_app/android/Window_android.cpp", 3880 "tools/sk_app/android/Window_android.h", 3881 "tools/sk_app/android/main_android.cpp", 3882 "tools/sk_app/android/surface_glue_android.cpp", 3883 "tools/sk_app/android/surface_glue_android.h", 3884 ] 3885 libs += [ "android" ] 3886 } else if (is_linux) { 3887 sources += [ 3888 "tools/sk_app/unix/Window_unix.cpp", 3889 "tools/sk_app/unix/Window_unix.h", 3890 "tools/sk_app/unix/keysym2ucs.c", 3891 "tools/sk_app/unix/keysym2ucs.h", 3892 "tools/sk_app/unix/main_unix.cpp", 3893 ] 3894 libs += [ 3895 "GL", # Used by raster window context, so cannot be behind skia_use_gl. 3896 "X11", 3897 ] 3898 } else if (is_win) { 3899 sources += [ 3900 "tools/sk_app/win/Window_win.cpp", 3901 "tools/sk_app/win/Window_win.h", 3902 "tools/sk_app/win/main_win.cpp", 3903 ] 3904 } else if (is_mac) { 3905 sources += [ 3906 "tools/sk_app/mac/Window_mac.h", 3907 "tools/sk_app/mac/Window_mac.mm", 3908 "tools/sk_app/mac/main_mac.mm", 3909 ] 3910 frameworks += [ 3911 "QuartzCore.framework", 3912 "Cocoa.framework", 3913 "Foundation.framework", 3914 ] 3915 } else if (is_ios) { 3916 sources += [ 3917 "tools/sk_app/ios/Window_ios.h", 3918 "tools/sk_app/ios/Window_ios.mm", 3919 "tools/sk_app/ios/main_ios.mm", 3920 ] 3921 frameworks += [ "QuartzCore.framework" ] 3922 } 3923 3924 deps = [ 3925 ":tool_utils", 3926 "tools/window", 3927 ] 3928 if (is_android) { 3929 deps += [ "${skia_third_party_dir}/native_app_glue" ] 3930 } 3931 if (skia_use_gl && skia_use_angle) { 3932 deps += [ "${skia_third_party_dir}/angle2" ] 3933 } 3934 } 3935 3936 if (!skia_use_vulkan && (is_mac || is_linux || is_win)) { 3937 test_app("fiddle_examples") { 3938 sources = [ 3939 "tools/fiddle/all_examples.cpp", 3940 "tools/fiddle/examples.cpp", 3941 "tools/fiddle/examples.h", 3942 ] 3943 if (is_win) { 3944 cflags = [ 3945 "/wd4756", # Overflow in constant arithmetic 3946 "/wd4305", # truncation from 'double' to 'float' 3947 ] 3948 } 3949 deps = [ 3950 ":skia", 3951 ":skia.h", 3952 "modules/skottie", 3953 "modules/skparagraph", 3954 "modules/skshaper", 3955 "modules/svg", 3956 ] 3957 } 3958 } 3959 3960 # sk_app can work without GL but viewer always runs raster through a GL window context. 3961 if (skia_use_gl) { 3962 test_app("viewer") { 3963 is_shared_library = is_android 3964 sources = [ 3965 "tools/viewer/3DSlide.cpp", 3966 "tools/viewer/AndroidShadowsSlide.cpp", 3967 "tools/viewer/AnimBlurSlide.cpp", 3968 "tools/viewer/AnimTimer.h", 3969 "tools/viewer/AnimatedImageSlide.cpp", 3970 "tools/viewer/AnimatedImageSlide.h", 3971 "tools/viewer/AnimatedRectsSlide.cpp", 3972 "tools/viewer/AnimatedTextSlide.cpp", 3973 "tools/viewer/ArcSlide.cpp", 3974 "tools/viewer/AtlasSlide.cpp", 3975 "tools/viewer/AudioSlide.cpp", 3976 "tools/viewer/BisectSlide.cpp", 3977 "tools/viewer/BisectSlide.h", 3978 "tools/viewer/CameraSlide.cpp", 3979 "tools/viewer/ChartSlide.cpp", 3980 "tools/viewer/ChineseFlingSlide.cpp", 3981 "tools/viewer/ClickHandlerSlide.cpp", 3982 "tools/viewer/ClickHandlerSlide.h", 3983 "tools/viewer/ClipSlide.cpp", 3984 "tools/viewer/ClockSlide.cpp", 3985 "tools/viewer/CowboySlide.cpp", 3986 "tools/viewer/DegenerateQuadsSlide.cpp", 3987 "tools/viewer/DegenerateTwoPtRadialsSlide.cpp", 3988 "tools/viewer/FatBitsSlide.cpp", 3989 "tools/viewer/FilterBoundsSlide.cpp", 3990 "tools/viewer/FitCubicToCircleSlide.cpp", 3991 "tools/viewer/FlutterAnimateSlide.cpp", 3992 "tools/viewer/GMSlide.cpp", 3993 "tools/viewer/GMSlide.h", 3994 "tools/viewer/GlyphTransformSlide.cpp", 3995 "tools/viewer/GradientsSlide.cpp", 3996 "tools/viewer/GraphitePrimitivesSlide.cpp", 3997 "tools/viewer/ImGuiLayer.cpp", 3998 "tools/viewer/ImGuiLayer.h", 3999 "tools/viewer/ImageFilterDAGSlide.cpp", 4000 "tools/viewer/ImageSlide.cpp", 4001 "tools/viewer/ImageSlide.h", 4002 "tools/viewer/LayersSlide.cpp", 4003 "tools/viewer/ManyRectsSlide.cpp", 4004 "tools/viewer/MaterialShadowsSlide.cpp", 4005 "tools/viewer/MegaStrokeSlide.cpp", 4006 "tools/viewer/MeshGradientSlide.cpp", 4007 "tools/viewer/MeshSlide.cpp", 4008 "tools/viewer/MixerSlide.cpp", 4009 "tools/viewer/MotionMarkSlide.cpp", 4010 "tools/viewer/PatchSlide.cpp", 4011 "tools/viewer/PathClipSlide.cpp", 4012 "tools/viewer/PathEffectsSlide.cpp", 4013 "tools/viewer/PathLerpSlide.cpp", 4014 "tools/viewer/PathOverstrokeSlide.cpp", 4015 "tools/viewer/PathSlide.cpp", 4016 "tools/viewer/PathTessellatorsSlide.cpp", 4017 "tools/viewer/PathTextSlide.cpp", 4018 "tools/viewer/ProtectedSlide.cpp", 4019 "tools/viewer/QuadStrokerSlide.cpp", 4020 "tools/viewer/RectanizerSlide.cpp", 4021 "tools/viewer/RepeatTileSlide.cpp", 4022 "tools/viewer/SBIXSlide.cpp", 4023 "tools/viewer/SGSlide.cpp", 4024 "tools/viewer/SKPSlide.cpp", 4025 "tools/viewer/SKPSlide.h", 4026 "tools/viewer/SVGFileSlide.cpp", 4027 "tools/viewer/ShadowColorSlide.cpp", 4028 "tools/viewer/ShadowReferenceSlide.cpp", 4029 "tools/viewer/ShadowUtilsSlide.cpp", 4030 "tools/viewer/ShipSlide.cpp", 4031 "tools/viewer/SimpleStrokerSlide.cpp", 4032 "tools/viewer/SkSLDebuggerSlide.cpp", 4033 "tools/viewer/SkSLDebuggerSlide.h", 4034 "tools/viewer/SkSLSlide.cpp", 4035 "tools/viewer/SkSLSlide.h", 4036 "tools/viewer/SkottieSlide.cpp", 4037 "tools/viewer/SkottieSlide.h", 4038 "tools/viewer/Slide.h", 4039 "tools/viewer/SlideDir.cpp", 4040 "tools/viewer/SlideDir.h", 4041 "tools/viewer/SlidesSlide.cpp", 4042 "tools/viewer/StatsLayer.cpp", 4043 "tools/viewer/StatsLayer.h", 4044 "tools/viewer/StringArtSlide.cpp", 4045 "tools/viewer/StrokeVerbSlide.cpp", 4046 "tools/viewer/SvgSlide.cpp", 4047 "tools/viewer/SvgSlide.h", 4048 "tools/viewer/TextBoxSlide.cpp", 4049 "tools/viewer/TextureUploadSlide.cpp", 4050 "tools/viewer/ThinAASlide.cpp", 4051 "tools/viewer/TimingSlide.cpp", 4052 "tools/viewer/TouchGesture.cpp", 4053 "tools/viewer/TouchGesture.h", 4054 "tools/viewer/TypefaceSlide.cpp", 4055 "tools/viewer/VariableWidthStrokerSlide.cpp", 4056 "tools/viewer/Viewer.cpp", 4057 "tools/viewer/Viewer.h", 4058 "tools/viewer/XferSlide.cpp", 4059 ] 4060 libs = [] 4061 4062 deps = [ 4063 ":common_flags_config", 4064 ":common_flags_gpu", 4065 ":common_flags_graphite", 4066 ":flags", 4067 ":gm", 4068 ":gpu_tool_utils", 4069 ":sk_app", 4070 ":skia", 4071 ":tool_utils", 4072 ":trace", 4073 ":xml", 4074 "modules/audioplayer", 4075 "modules/skottie", 4076 "modules/skottie:utils", 4077 "modules/skparagraph:slides", 4078 "modules/skresources", 4079 "modules/sksg:slides", 4080 "modules/skshaper:skshaper", 4081 "modules/skunicode", 4082 "${skia_third_party_dir}/delaunator", 4083 "${skia_third_party_dir}/imgui", 4084 ] 4085 if (skia_use_libpng_decode) { 4086 deps += [ "modules/svg" ] 4087 4088 sources += [ 4089 "tools/viewer/MSKPSlide.cpp", 4090 "tools/viewer/MSKPSlide.h", 4091 ] 4092 } 4093 } 4094 } 4095 4096 if (skia_use_vulkan) { 4097 test_app("VulkanBasic") { 4098 # Bots and even devs may not have Vulkan headers, so put 4099 # include/third_party/vulkan on our path so they're always available. 4100 configs = [ 4101 ":use_skia_vulkan_headers", 4102 ":vulkan_memory_allocator", 4103 ] 4104 external_deps = [ "vulkan-headers:vulkan_headers" ] 4105 sources = [ "example/VulkanBasic.cpp" ] 4106 sources += [ "tools/gpu/vk/VkTestMemoryAllocator.h" ] 4107 sources += [ "tools/gpu/vk/VkTestMemoryAllocator.cpp" ] 4108 sources += [ "tools/gpu/vk/VkTestUtils.h" ] 4109 sources += [ "tools/gpu/vk/VkTestUtils.cpp" ] 4110 deps = [ 4111 ":load_dynamic_library", 4112 ":skia", 4113 "${skia_third_party_dir}/vulkanmemoryallocator:vulkan_memoryallocator" 4114 ] 4115 } 4116 } 4117 4118 if (is_ios && skia_use_metal && skia_enable_ganesh) { 4119 group("minimal_ios_mtl_skia_app") { 4120 deps = [ "experimental/minimal_ios_mtl_skia_app" ] 4121 } 4122 } 4123 4124 if (is_linux || is_win || is_mac) { 4125 test_app("editor") { 4126 is_shared_library = is_android 4127 deps = [ "modules/skplaintexteditor:editor_app" ] 4128 } 4129 } 4130 4131 skia_executable("image_diff_metric") { 4132 sources = [ "tools/image_diff_metric.cpp" ] 4133 deps = [ ":skia" ] 4134 } 4135 4136 group("modules_testonly") { 4137 testonly = true 4138 deps = [] 4139 if (is_wasm) { 4140 deps += [ "modules/canvaskit:viewer_wasm" ] 4141 } 4142 } 4143 4144 if (skia_build_fuzzers) { 4145 template("libfuzzer_app") { 4146 skia_executable(target_name) { 4147 output_dir = root_build_dir 4148 check_includes = false 4149 forward_variables_from(invoker, "*", [ "is_shared_library" ]) 4150 if (!defined(configs)) { 4151 configs = [] 4152 } 4153 configs += [ ":skia_private" ] 4154 sources += [ 4155 "fuzz/Fuzz.cpp", 4156 "fuzz/FuzzCommon.cpp", 4157 ] 4158 deps += [ 4159 ":flags", 4160 ":gpu_tool_utils", 4161 ":skia", 4162 ":tool_utils", 4163 ] 4164 defines = [ 4165 "SK_BUILD_FOR_LIBFUZZER", 4166 "SK_BUILD_FOR_FUZZER", 4167 ] 4168 if (skia_use_libfuzzer_defaults) { 4169 cflags = [ "-fsanitize=fuzzer" ] 4170 ldflags = [ "-fsanitize=fuzzer" ] 4171 } 4172 testonly = true 4173 } 4174 } 4175 4176 libfuzzer_app("region_deserialize") { 4177 sources = [ "fuzz/oss_fuzz/FuzzRegionDeserialize.cpp" ] 4178 deps = [] 4179 } 4180 4181 libfuzzer_app("image_filter_deserialize") { 4182 sources = [ "fuzz/oss_fuzz/FuzzImageFilterDeserialize.cpp" ] 4183 deps = [ "modules/svg" ] 4184 } 4185 4186 libfuzzer_app("region_set_path") { 4187 sources = [ "fuzz/oss_fuzz/FuzzRegionSetPath.cpp" ] 4188 deps = [] 4189 } 4190 4191 libfuzzer_app("textblob_deserialize") { 4192 sources = [ "fuzz/oss_fuzz/FuzzTextBlobDeserialize.cpp" ] 4193 deps = [ "modules/svg" ] 4194 } 4195 4196 libfuzzer_app("path_deserialize") { 4197 sources = [ "fuzz/oss_fuzz/FuzzPathDeserialize.cpp" ] 4198 deps = [] 4199 } 4200 4201 libfuzzer_app("image_decode") { 4202 sources = [ "fuzz/oss_fuzz/FuzzImage.cpp" ] 4203 deps = [] 4204 } 4205 4206 libfuzzer_app("animated_image_decode") { 4207 sources = [ "fuzz/oss_fuzz/FuzzAnimatedImage.cpp" ] 4208 deps = [] 4209 } 4210 4211 libfuzzer_app("api_create_ddl") { 4212 sources = [ 4213 "fuzz/FuzzCreateDDL.cpp", 4214 "fuzz/oss_fuzz/FuzzAPICreateDDL.cpp", 4215 ] 4216 deps = [ 4217 "modules/svg", 4218 "${skia_third_party_dir}/libpng", 4219 ] 4220 } 4221 4222 libfuzzer_app("api_draw_functions") { 4223 sources = [ 4224 "fuzz/FuzzDrawFunctions.cpp", 4225 "fuzz/oss_fuzz/FuzzDrawFunctions.cpp", 4226 ] 4227 deps = [] 4228 } 4229 4230 libfuzzer_app("api_ddl_threading") { 4231 sources = [ 4232 "fuzz/FuzzDDLThreading.cpp", 4233 "fuzz/oss_fuzz/FuzzDDLThreading.cpp", 4234 ] 4235 deps = [] 4236 } 4237 4238 libfuzzer_app("api_gradients") { 4239 sources = [ 4240 "fuzz/FuzzGradients.cpp", 4241 "fuzz/oss_fuzz/FuzzGradients.cpp", 4242 ] 4243 deps = [] 4244 } 4245 4246 libfuzzer_app("api_image_filter") { 4247 sources = [ 4248 "fuzz/FuzzCanvas.cpp", 4249 "fuzz/oss_fuzz/FuzzAPIImageFilter.cpp", 4250 ] 4251 deps = [ "${skia_third_party_dir}/libpng" ] 4252 } 4253 4254 libfuzzer_app("api_path_measure") { 4255 sources = [ 4256 "fuzz/FuzzPathMeasure.cpp", 4257 "fuzz/oss_fuzz/FuzzPathMeasure.cpp", 4258 ] 4259 deps = [] 4260 } 4261 4262 libfuzzer_app("api_pathop") { 4263 sources = [ 4264 "fuzz/FuzzPathop.cpp", 4265 "fuzz/oss_fuzz/FuzzPathop.cpp", 4266 ] 4267 deps = [] 4268 } 4269 4270 libfuzzer_app("api_triangulation") { 4271 sources = [ 4272 "fuzz/FuzzTriangulation.cpp", 4273 "fuzz/oss_fuzz/FuzzTriangulation.cpp", 4274 ] 4275 deps = [] 4276 } 4277 4278 libfuzzer_app("api_raster_n32_canvas") { 4279 sources = [ 4280 "fuzz/FuzzCanvas.cpp", 4281 "fuzz/oss_fuzz/FuzzRasterN32Canvas.cpp", 4282 ] 4283 deps = [ 4284 "modules/svg", 4285 "${skia_third_party_dir}/libpng", 4286 ] 4287 } 4288 4289 libfuzzer_app("api_regionop") { 4290 sources = [ 4291 "fuzz/FuzzRegionOp.cpp", 4292 "fuzz/oss_fuzz/FuzzRegionOp.cpp", 4293 ] 4294 deps = [] 4295 } 4296 4297 if (skia_enable_ganesh) { 4298 libfuzzer_app("api_mock_gpu_canvas") { 4299 sources = [ 4300 "fuzz/FuzzCanvas.cpp", 4301 "fuzz/oss_fuzz/FuzzMockGPUCanvas.cpp", 4302 ] 4303 deps = [ 4304 "modules/svg", 4305 "${skia_third_party_dir}/libpng", 4306 ] 4307 } 4308 } 4309 4310 if (skia_enable_graphite && skia_enable_precompile) { 4311 libfuzzer_app("api_precompile") { 4312 sources = [ 4313 "fuzz/FuzzPrecompile.cpp", 4314 "fuzz/oss_fuzz/FuzzPrecompile.cpp", 4315 ] 4316 deps = [] 4317 } 4318 } 4319 4320 libfuzzer_app("api_null_canvas") { 4321 sources = [ 4322 "fuzz/FuzzCanvas.cpp", 4323 "fuzz/oss_fuzz/FuzzNullCanvas.cpp", 4324 ] 4325 deps = [ 4326 "modules/svg", 4327 "${skia_third_party_dir}/libpng", 4328 ] 4329 } 4330 4331 libfuzzer_app("api_skparagraph") { 4332 sources = [ 4333 "fuzz/FuzzSkParagraph.cpp", 4334 "fuzz/oss_fuzz/FuzzSkParagraph.cpp", 4335 ] 4336 deps = [ "modules/skparagraph" ] 4337 } 4338 4339 libfuzzer_app("api_svg_canvas") { 4340 sources = [ 4341 "fuzz/FuzzCanvas.cpp", 4342 "fuzz/oss_fuzz/FuzzAPISVGCanvas.cpp", 4343 ] 4344 deps = [ 4345 "modules/svg", 4346 "${skia_third_party_dir}/libpng", 4347 ] 4348 } 4349 4350 libfuzzer_app("png_encoder") { 4351 sources = [ 4352 "fuzz/FuzzEncoders.cpp", 4353 "fuzz/oss_fuzz/FuzzPNGEncoder.cpp", 4354 ] 4355 deps = [] 4356 } 4357 4358 libfuzzer_app("jpeg_encoder") { 4359 sources = [ 4360 "fuzz/FuzzEncoders.cpp", 4361 "fuzz/oss_fuzz/FuzzJPEGEncoder.cpp", 4362 ] 4363 deps = [] 4364 } 4365 4366 libfuzzer_app("webp_encoder") { 4367 sources = [ 4368 "fuzz/FuzzEncoders.cpp", 4369 "fuzz/oss_fuzz/FuzzWEBPEncoder.cpp", 4370 ] 4371 deps = [] 4372 } 4373 4374 libfuzzer_app("skottie_json") { 4375 sources = [ "modules/skottie/fuzz/FuzzSkottieJSON.cpp" ] 4376 deps = [ 4377 "modules/jsonreader", 4378 "modules/skottie:skottie", 4379 "modules/svg", 4380 ] 4381 } 4382 4383 libfuzzer_app("skjson") { 4384 sources = [ "fuzz/oss_fuzz/FuzzJSON.cpp" ] 4385 deps = [ "modules/jsonreader" ] 4386 } 4387 4388 libfuzzer_app("api_polyutils") { 4389 sources = [ 4390 "fuzz/FuzzPolyUtils.cpp", 4391 "fuzz/oss_fuzz/FuzzPolyUtils.cpp", 4392 ] 4393 deps = [ ":skia" ] 4394 } 4395 4396 libfuzzer_app("android_codec") { 4397 sources = [ "fuzz/oss_fuzz/FuzzAndroidCodec.cpp" ] 4398 deps = [] 4399 } 4400 4401 libfuzzer_app("image_decode_incremental") { 4402 sources = [ "fuzz/oss_fuzz/FuzzIncrementalImage.cpp" ] 4403 deps = [] 4404 } 4405 4406 libfuzzer_app("sksl2glsl") { 4407 sources = [ "fuzz/oss_fuzz/FuzzSKSL2GLSL.cpp" ] 4408 deps = [] 4409 } 4410 4411 libfuzzer_app("sksl2metal") { 4412 sources = [ "fuzz/oss_fuzz/FuzzSKSL2Metal.cpp" ] 4413 deps = [] 4414 } 4415 4416 libfuzzer_app("sksl2pipeline") { 4417 sources = [ "fuzz/oss_fuzz/FuzzSKSL2Pipeline.cpp" ] 4418 deps = [] 4419 } 4420 4421 libfuzzer_app("sksl2spirv") { 4422 sources = [ "fuzz/oss_fuzz/FuzzSKSL2SPIRV.cpp" ] 4423 deps = [] 4424 } 4425 4426 libfuzzer_app("sksl2wgsl") { 4427 sources = [ "fuzz/oss_fuzz/FuzzSKSL2WGSL.cpp" ] 4428 deps = [] 4429 } 4430 4431 libfuzzer_app("skdescriptor_deserialize") { 4432 sources = [ "fuzz/oss_fuzz/FuzzSkDescriptorDeserialize.cpp" ] 4433 deps = [] 4434 } 4435 4436 libfuzzer_app("svg_dom") { 4437 sources = [ "fuzz/oss_fuzz/FuzzSVG.cpp" ] 4438 deps = [ "modules/svg" ] 4439 } 4440 4441 libfuzzer_app("skruntimeblender") { 4442 sources = [ "fuzz/oss_fuzz/FuzzSkRuntimeBlender.cpp" ] 4443 deps = [] 4444 } 4445 4446 libfuzzer_app("skruntimecolorfilter") { 4447 sources = [ "fuzz/oss_fuzz/FuzzSkRuntimeColorFilter.cpp" ] 4448 deps = [] 4449 } 4450 4451 libfuzzer_app("skruntimeeffect") { 4452 sources = [ "fuzz/oss_fuzz/FuzzSkRuntimeEffect.cpp" ] 4453 deps = [] 4454 } 4455 4456 libfuzzer_app("skmeshspecification") { 4457 sources = [ "fuzz/oss_fuzz/FuzzSkMeshSpecification.cpp" ] 4458 deps = [] 4459 } 4460 4461 libfuzzer_app("skp") { 4462 sources = [ "fuzz/oss_fuzz/FuzzSKP.cpp" ] 4463 deps = [] 4464 } 4465 4466 libfuzzer_app("colrv1") { 4467 sources = [ "fuzz/oss_fuzz/FuzzCOLRv1.cpp" ] 4468 deps = [] 4469 } 4470 4471 libfuzzer_app("quad_roots") { 4472 sources = [ 4473 "fuzz/FuzzQuadRoots.cpp", 4474 "fuzz/oss_fuzz/FuzzQuadRoots.cpp", 4475 ] 4476 deps = [] 4477 } 4478 4479 libfuzzer_app("cubic_roots") { 4480 sources = [ 4481 "fuzz/FuzzCubicRoots.cpp", 4482 "fuzz/oss_fuzz/FuzzCubicRoots.cpp", 4483 ] 4484 deps = [] 4485 } 4486 4487 libfuzzer_app("skcolorspace") { 4488 sources = [ "fuzz/oss_fuzz/FuzzColorspace.cpp" ] 4489 deps = [] 4490 } 4491 4492 libfuzzer_app("parse_path") { 4493 sources = [ "fuzz/oss_fuzz/FuzzParsePath.cpp" ] 4494 deps = [] 4495 } 4496 } 4497} 4498 4499if (skia_build_rust_targets) { 4500 action("rust_hello_world") { 4501 script = "gn/bazel_build.py" 4502 sources = [ "experimental/rust_cxx/hello-world.rs" ] 4503 outputs = [ "$root_out_dir/rust_hello_world" ] 4504 args = [ 4505 "//experimental/rust_cxx:rust_hello_world", 4506 "../../bazel-bin/experimental/rust_cxx/rust_hello_world", 4507 ] 4508 } 4509 4510 action("cpp_with_rust") { 4511 script = "gn/bazel_build.py" 4512 sources = [ 4513 "experimental/rust_cxx/hype-bridge.rs", 4514 "experimental/rust_cxx/main.cpp", 4515 ] 4516 outputs = [ "$root_out_dir/cpp_with_rust" ] 4517 args = [ 4518 "//experimental/rust_cxx:cpp_with_rust", 4519 "../../bazel-bin/experimental/rust_cxx/cpp_with_rust", 4520 ] 4521 } 4522} 4523