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("gn/flutter_defines.gni") 7import("gn/fuchsia_defines.gni") 8import("gn/shared_sources.gni") 9import("gn/skia.gni") 10import("gn/toolchain/wasm.gni") 11 12if (is_fuchsia) { 13 import("//build/fuchsia/sdk.gni") 14 import("build/fuchsia/fuchsia_download_sdk.gni") 15} 16 17if (skia_use_dawn) { 18 import("//third_party/externals/dawn/scripts/dawn_features.gni") 19} 20 21if (defined(skia_settings)) { 22 import(skia_settings) 23} 24 25import("gn/ios.gni") 26 27# Skia public API, generally provided by :skia. 28config("skia_public") { 29 include_dirs = [ "." ] 30 31 defines = [] 32 cflags_objcc = [] 33 if (is_component_build) { 34 defines += [ "SKIA_DLL" ] 35 } 36 if (is_fuchsia || is_linux) { 37 defines += [ "SK_R32_SHIFT=16" ] 38 } 39 if (skia_enable_flutter_defines) { 40 defines += flutter_defines 41 } 42 if (!skia_enable_gpu) { 43 defines += [ "SK_SUPPORT_GPU=0" ] 44 } 45 if (skia_enable_sksl) { 46 defines += [ "SK_ENABLE_SKSL" ] 47 } 48 if (is_fuchsia) { 49 defines += fuchsia_defines 50 } 51 if (is_wasm) { 52 defines += wasm_defines 53 } 54 if (skia_gl_standard == "gles") { 55 defines += [ "SK_ASSUME_GL_ES=1" ] 56 } else if (skia_gl_standard == "gl") { 57 defines += [ "SK_ASSUME_GL=1" ] 58 } else if (skia_gl_standard == "webgl") { 59 defines += [ 60 "SK_ASSUME_WEBGL=1", 61 "SK_USE_WEBGL", 62 ] 63 } 64 if (!skia_enable_skgpu_v1) { 65 defines += [ "SK_GPU_V1=0" ] 66 } 67 68 # Some older versions of the Clang toolchain change the visibility of 69 # symbols decorated with API_AVAILABLE macro to be visible. Users of such 70 # toolchains suppress the use of this macro till toolchain updates are made. 71 if (is_mac || is_ios) { 72 if (skia_enable_api_available_macro) { 73 defines += [ "SK_ENABLE_API_AVAILABLE" ] 74 } else { 75 cflags_objcc += [ "-Wno-unguarded-availability" ] 76 } 77 } 78} 79 80# Skia internal APIs, used by Skia itself and a few test tools. 81config("skia_private") { 82 visibility = [ "./*" ] 83 84 defines = [ "SK_GAMMA_APPLY_TO_A8" ] 85 if (skia_use_fixed_gamma_text) { 86 defines += [ 87 "SK_GAMMA_EXPONENT=1.4", 88 "SK_GAMMA_CONTRAST=0.0", 89 ] 90 } 91 if (is_skia_dev_build && !is_wasm) { 92 defines += [ 93 "SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=1", 94 "GR_TEST_UTILS=1", 95 ] 96 if (skia_enable_graphite) { 97 defines += [ "GRAPHITE_TEST_UTILS=1" ] 98 } 99 } 100 libs = [] 101 lib_dirs = [] 102 if (skia_use_gl && skia_use_angle) { 103 defines += [ "SK_ANGLE" ] 104 } 105 if (skia_use_vma) { 106 defines += [ "SK_USE_VMA" ] 107 } 108 if (skia_enable_winuwp) { 109 defines += [ "SK_WINUWP" ] 110 } 111} 112 113# Any code that's linked into Skia-the-library should use this config via += skia_library_configs. 114config("skia_library") { 115 visibility = [ "./*" ] 116 defines = [ "SKIA_IMPLEMENTATION=1" ] 117} 118 119skia_library_configs = [ 120 ":skia_public", 121 ":skia_private", 122 ":skia_library", 123] 124 125# Use for CPU-specific Skia code that needs particular compiler flags. 126template("opts") { 127 if (invoker.enabled) { 128 skia_source_set(target_name) { 129 visibility = [ ":*" ] 130 check_includes = false 131 configs = skia_library_configs 132 forward_variables_from(invoker, "*") 133 if (defined(invoker.configs)) { 134 configs += invoker.configs 135 } 136 } 137 } else { 138 # If not enabled, a phony empty target that swallows all otherwise unused variables. 139 skia_source_set(target_name) { 140 visibility = [ ":*" ] 141 check_includes = false 142 forward_variables_from(invoker, 143 "*", 144 [ 145 "sources", 146 "cflags", 147 ]) 148 } 149 } 150} 151 152is_x86 = current_cpu == "x64" || current_cpu == "x86" 153 154opts("none") { 155 enabled = !is_x86 && current_cpu != "arm" && current_cpu != "arm64" 156 sources = skia_opts.none_sources 157 cflags = [] 158} 159 160opts("armv7") { 161 enabled = current_cpu == "arm" 162 sources = skia_opts.armv7_sources + skia_opts.neon_sources 163 cflags = [] 164} 165 166opts("arm64") { 167 enabled = current_cpu == "arm64" 168 sources = skia_opts.arm64_sources 169 cflags = [] 170} 171 172opts("crc32") { 173 enabled = current_cpu == "arm64" 174 sources = skia_opts.crc32_sources 175 cflags = [ "-march=armv8-a+crc" ] 176} 177 178opts("sse2") { 179 enabled = is_x86 180 sources = skia_opts.sse2_sources 181 if (!is_clang && is_win) { 182 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE2" ] 183 } else { 184 cflags = [ "-msse2" ] 185 } 186} 187 188opts("ssse3") { 189 enabled = is_x86 190 sources = skia_opts.ssse3_sources 191 if (!is_clang && is_win) { 192 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSSE3" ] 193 } else { 194 cflags = [ "-mssse3" ] 195 } 196} 197 198opts("sse41") { 199 enabled = is_x86 200 sources = skia_opts.sse41_sources 201 if (!is_clang && is_win) { 202 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE41" ] 203 } else { 204 cflags = [ "-msse4.1" ] 205 } 206} 207 208opts("sse42") { 209 enabled = is_x86 210 sources = skia_opts.sse42_sources 211 if (!is_clang && is_win) { 212 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE42" ] 213 } else { 214 cflags = [ "-msse4.2" ] 215 } 216} 217 218opts("avx") { 219 enabled = is_x86 220 sources = skia_opts.avx_sources 221 if (is_win) { 222 cflags = [ "/arch:AVX" ] 223 } else { 224 cflags = [ "-mavx" ] 225 if (is_mac && is_debug) { 226 cflags += [ "-fno-stack-check" ] # Work around skia:9709 227 } 228 } 229} 230 231opts("hsw") { 232 enabled = is_x86 233 sources = skia_opts.hsw_sources 234 if (is_win) { 235 cflags = [ "/arch:AVX2" ] 236 } else { 237 cflags = [ "-march=haswell" ] 238 if (is_mac && is_debug) { 239 cflags += [ "-fno-stack-check" ] # Work around skia:9709 240 } 241 } 242} 243 244opts("skx") { 245 enabled = is_x86 246 sources = skia_opts.skx_sources 247 if (is_win) { 248 cflags = [ "/arch:AVX512" ] 249 } else { 250 cflags = [ "-march=skylake-avx512" ] 251 if (is_mac && is_debug) { 252 cflags += [ "-fno-stack-check" ] # Work around skia:9709 253 } 254 } 255} 256 257# Any feature of Skia that requires third-party code should be optional and use this template. 258template("optional") { 259 if (invoker.enabled) { 260 config(target_name + "_public") { 261 if (defined(invoker.public_defines)) { 262 defines = invoker.public_defines 263 } 264 if (defined(invoker.public_configs)) { 265 configs = invoker.public_configs 266 } 267 if (defined(invoker.public_include_dirs)) { 268 include_dirs = invoker.public_include_dirs 269 } 270 } 271 skia_source_set(target_name) { 272 visibility = [ ":*" ] 273 check_includes = false 274 configs = skia_library_configs 275 276 # "*" clobbers the current scope; append to existing configs 277 forward_variables_from(invoker, 278 "*", 279 [ 280 "configs", 281 "public_defines", 282 "sources_for_tests", 283 "sources_when_disabled", 284 ]) 285 if (defined(invoker.configs)) { 286 configs += invoker.configs 287 } 288 all_dependent_configs = [ ":" + target_name + "_public" ] 289 } 290 if (defined(invoker.sources_for_tests) && skia_enable_tools) { 291 skia_source_set(target_name + "_tests") { 292 visibility = [ ":*" ] 293 check_includes = false 294 configs = skia_library_configs 295 296 # "*" clobbers the current scope; append to existing configs 297 forward_variables_from(invoker, 298 "*", 299 [ 300 "configs", 301 "public_defines", 302 "sources", 303 "sources_for_tests", 304 "sources_when_disabled", 305 ]) 306 if (defined(invoker.configs)) { 307 configs += invoker.configs 308 } 309 testonly = true 310 sources = invoker.sources_for_tests 311 if (!defined(deps)) { 312 deps = [] 313 } 314 deps += [ ":test" ] 315 all_dependent_configs = [ ":" + target_name + "_public" ] 316 } 317 } 318 } else { 319 skia_source_set(target_name) { 320 visibility = [ ":*" ] 321 configs = skia_library_configs 322 323 # "*" clobbers the current scope; append to existing configs 324 forward_variables_from(invoker, 325 "*", 326 [ 327 "configs", 328 "public", 329 "public_defines", 330 "public_deps", 331 "deps", 332 "libs", 333 "frameworks", 334 "sources", 335 "sources_for_tests", 336 "sources_when_disabled", 337 ]) 338 if (defined(invoker.configs)) { 339 configs += invoker.configs 340 } 341 if (defined(invoker.sources_when_disabled)) { 342 sources = invoker.sources_when_disabled 343 } 344 } 345 if (defined(invoker.sources_for_tests)) { 346 skia_source_set(target_name + "_tests") { 347 visibility = [ ":*" ] 348 } 349 } 350 } 351} 352 353optional("android_utils") { 354 enabled = skia_enable_android_utils 355 356 public = [ 357 "client_utils/android/BRDAllocator.h", 358 "client_utils/android/BitmapRegionDecoder.h", 359 "client_utils/android/FrontBufferedStream.h", 360 ] 361 public_defines = [ "SK_ENABLE_ANDROID_UTILS" ] 362 sources = [ 363 "client_utils/android/BitmapRegionDecoder.cpp", 364 "client_utils/android/FrontBufferedStream.cpp", 365 ] 366} 367 368group("fontmgr_factory") { 369 public_deps = [ skia_fontmgr_factory ] 370} 371 372optional("fontmgr_empty_factory") { 373 enabled = true 374 sources = [ "src/ports/SkFontMgr_empty_factory.cpp" ] 375} 376 377optional("fontmgr_android") { 378 enabled = skia_enable_fontmgr_android 379 380 deps = [ 381 ":typeface_freetype", 382 "//third_party/expat", 383 ] 384 public = [ "include/ports/SkFontMgr_android.h" ] 385 sources = [ 386 "src/ports/SkFontMgr_android.cpp", 387 "src/ports/SkFontMgr_android_parser.cpp", 388 "src/ports/SkFontMgr_android_parser.h", 389 ] 390 sources_for_tests = [ "tests/FontMgrAndroidParserTest.cpp" ] 391} 392optional("fontmgr_android_factory") { 393 enabled = skia_enable_fontmgr_android 394 deps = [ ":fontmgr_android" ] 395 sources = [ "src/ports/SkFontMgr_android_factory.cpp" ] 396} 397 398optional("fontmgr_custom") { 399 enabled = 400 skia_enable_fontmgr_custom_directory || 401 skia_enable_fontmgr_custom_embedded || skia_enable_fontmgr_custom_empty 402 403 deps = [ ":typeface_freetype" ] 404 public = [ "src/ports/SkFontMgr_custom.h" ] 405 sources = [ "src/ports/SkFontMgr_custom.cpp" ] 406} 407 408optional("fontmgr_custom_directory") { 409 enabled = skia_enable_fontmgr_custom_directory 410 411 deps = [ 412 ":fontmgr_custom", 413 ":typeface_freetype", 414 ] 415 public = [ "include/ports/SkFontMgr_directory.h" ] 416 sources = [ "src/ports/SkFontMgr_custom_directory.cpp" ] 417} 418optional("fontmgr_custom_directory_factory") { 419 enabled = skia_enable_fontmgr_custom_directory 420 deps = [ ":fontmgr_custom_directory" ] 421 sources = [ "src/ports/SkFontMgr_custom_directory_factory.cpp" ] 422} 423 424optional("fontmgr_custom_embedded") { 425 enabled = skia_enable_fontmgr_custom_embedded 426 427 deps = [ 428 ":fontmgr_custom", 429 ":typeface_freetype", 430 ] 431 sources = [ "src/ports/SkFontMgr_custom_embedded.cpp" ] 432} 433optional("fontmgr_custom_embedded_factory") { 434 enabled = skia_enable_fontmgr_custom_embedded 435 deps = [ ":fontmgr_custom_embedded" ] 436 sources = [ "src/ports/SkFontMgr_custom_embedded_factory.cpp" ] 437} 438 439optional("fontmgr_custom_empty") { 440 enabled = skia_enable_fontmgr_custom_empty 441 442 deps = [ 443 ":fontmgr_custom", 444 ":typeface_freetype", 445 ] 446 public = [ "include/ports/SkFontMgr_empty.h" ] 447 sources = [ "src/ports/SkFontMgr_custom_empty.cpp" ] 448} 449optional("fontmgr_custom_empty_factory") { 450 enabled = skia_enable_fontmgr_custom_empty 451 deps = [ ":fontmgr_custom_empty" ] 452 sources = [ "src/ports/SkFontMgr_custom_empty_factory.cpp" ] 453} 454 455optional("fontmgr_fontconfig") { 456 enabled = skia_enable_fontmgr_fontconfig 457 458 # The public header includes fontconfig.h and uses FcConfig* 459 public_deps = [ "//third_party:fontconfig" ] 460 public = [ "include/ports/SkFontMgr_fontconfig.h" ] 461 deps = [ ":typeface_freetype" ] 462 sources = [ "src/ports/SkFontMgr_fontconfig.cpp" ] 463 sources_for_tests = [ "tests/FontMgrFontConfigTest.cpp" ] 464} 465optional("fontmgr_fontconfig_factory") { 466 enabled = skia_enable_fontmgr_fontconfig 467 deps = [ ":fontmgr_fontconfig" ] 468 sources = [ "src/ports/SkFontMgr_fontconfig_factory.cpp" ] 469} 470 471optional("fontmgr_FontConfigInterface") { 472 enabled = skia_enable_fontmgr_FontConfigInterface 473 474 deps = [ 475 ":typeface_freetype", 476 "//third_party:fontconfig", 477 ] 478 public = [ 479 "include/ports/SkFontConfigInterface.h", 480 "include/ports/SkFontMgr_FontConfigInterface.h", 481 ] 482 sources = [ 483 "src/ports/SkFontConfigInterface.cpp", 484 "src/ports/SkFontConfigInterface_direct.cpp", 485 "src/ports/SkFontConfigInterface_direct_factory.cpp", 486 "src/ports/SkFontConfigTypeface.h", 487 "src/ports/SkFontMgr_FontConfigInterface.cpp", 488 ] 489} 490optional("fontmgr_FontConfigInterface_factory") { 491 enabled = skia_enable_fontmgr_FontConfigInterface 492 deps = [ ":fontmgr_FontConfigInterface" ] 493 sources = [ "src/ports/SkFontMgr_FontConfigInterface_factory.cpp" ] 494} 495 496optional("fontmgr_fuchsia") { 497 enabled = skia_enable_fontmgr_fuchsia 498 499 deps = [] 500 501 if (is_fuchsia && using_fuchsia_sdk) { 502 deps += [ "//build/fuchsia/fidl:fuchsia.fonts" ] 503 } else { 504 deps = [ "//sdk/fidl/fuchsia.fonts" ] 505 } 506 public = [ "src/ports/SkFontMgr_fuchsia.h" ] 507 sources = [ "src/ports/SkFontMgr_fuchsia.cpp" ] 508} 509 510optional("fontmgr_mac_ct") { 511 enabled = skia_use_fonthost_mac 512 513 public = [ 514 "include/ports/SkFontMgr_mac_ct.h", 515 "include/ports/SkTypeface_mac.h", 516 ] 517 sources = [ 518 "src/ports/SkFontMgr_mac_ct.cpp", 519 "src/ports/SkScalerContext_mac_ct.cpp", 520 "src/ports/SkScalerContext_mac_ct.h", 521 "src/ports/SkTypeface_mac_ct.cpp", 522 "src/ports/SkTypeface_mac_ct.h", 523 ] 524 sources_for_tests = [ "tests/TypefaceMacTest.cpp" ] 525 526 if (is_mac) { 527 frameworks = [ 528 # AppKit symbols NSFontWeightXXX may be dlsym'ed. 529 "AppKit.framework", 530 "ApplicationServices.framework", 531 ] 532 } 533 534 if (is_ios) { 535 frameworks = [ 536 "CoreFoundation.framework", 537 "CoreGraphics.framework", 538 "CoreText.framework", 539 540 # UIKit symbols UIFontWeightXXX may be dlsym'ed. 541 "UIKit.framework", 542 ] 543 } 544} 545optional("fontmgr_mac_ct_factory") { 546 enabled = skia_use_fonthost_mac 547 deps = [ ":fontmgr_mac_ct" ] 548 sources = [ "src/ports/SkFontMgr_mac_ct_factory.cpp" ] 549} 550 551optional("fontmgr_win") { 552 enabled = skia_enable_fontmgr_win 553 554 public = [ "include/ports/SkTypeface_win.h" ] 555 sources = [ 556 "src/fonts/SkFontMgr_indirect.cpp", 557 "src/ports/SkFontMgr_win_dw.cpp", 558 "src/ports/SkScalerContext_win_dw.cpp", 559 "src/ports/SkScalerContext_win_dw.h", 560 "src/ports/SkTypeface_win_dw.cpp", 561 "src/ports/SkTypeface_win_dw.h", 562 ] 563} 564optional("fontmgr_win_factory") { 565 enabled = skia_enable_fontmgr_win 566 deps = [ ":fontmgr_win" ] 567 sources = [ "src/ports/SkFontMgr_win_dw_factory.cpp" ] 568} 569 570optional("fontmgr_win_gdi") { 571 enabled = skia_enable_fontmgr_win_gdi 572 573 public = [ "include/ports/SkTypeface_win.h" ] 574 sources = [ "src/ports/SkFontHost_win.cpp" ] 575 libs = [ "Gdi32.lib" ] 576} 577 578if (skia_lex) { 579 skia_executable("sksllex") { 580 sources = [ 581 "src/sksl/lex/DFA.h", 582 "src/sksl/lex/DFAState.h", 583 "src/sksl/lex/LexUtil.h", 584 "src/sksl/lex/Main.cpp", 585 "src/sksl/lex/NFA.cpp", 586 "src/sksl/lex/NFA.h", 587 "src/sksl/lex/NFAState.h", 588 "src/sksl/lex/NFAtoDFA.h", 589 "src/sksl/lex/RegexNode.cpp", 590 "src/sksl/lex/RegexNode.h", 591 "src/sksl/lex/RegexParser.cpp", 592 "src/sksl/lex/RegexParser.h", 593 "src/sksl/lex/TransitionTable.cpp", 594 "src/sksl/lex/TransitionTable.h", 595 ] 596 include_dirs = [ "." ] 597 } 598 599 action("run_sksllex") { 600 script = "gn/run_sksllex.py" 601 deps = [ ":sksllex(//gn/toolchain:$host_toolchain)" ] 602 sources = [ "src/sksl/lex/sksl.lex" ] 603 604 # GN insists its outputs should go somewhere underneath target_out_dir, so we trick it with a 605 # path that starts with target_out_dir and then uses ".." to back up into the src dir. 606 outputs = [ 607 "$target_out_dir/" + rebase_path("src/sksl/SkSLLexer.h", target_out_dir), 608 # the script also modifies the corresponding .cpp file, but if we tell GN that it gets 609 # confused due to the same file being named by two different paths 610 ] 611 sksllex_path = "$root_out_dir/" 612 sksllex_path += "sksllex" 613 if (host_os == "win") { 614 sksllex_path += ".exe" 615 } 616 args = [ 617 rebase_path(sksllex_path), 618 rebase_path("bin/clang-format"), 619 rebase_path("bin/fetch-clang-format"), 620 rebase_path("src"), 621 ] 622 } 623} else { 624 group("run_sksllex") { 625 } 626} 627 628# `Compile SkSL Tests` relies on skslc. 629if (skia_compile_sksl_tests) { 630 skia_executable("skslc") { 631 defines = [ 632 "SKSL_STANDALONE", 633 "SK_DISABLE_TRACING", 634 "SK_ENABLE_SPIRV_CROSS", 635 "SK_ENABLE_SPIRV_VALIDATION", 636 ] 637 sources = [ 638 "src/core/SkArenaAlloc.cpp", 639 "src/core/SkBlockAllocator.cpp", 640 "src/core/SkCpu.cpp", 641 "src/core/SkData.cpp", 642 "src/core/SkHalf.cpp", 643 "src/core/SkMalloc.cpp", 644 "src/core/SkMath.cpp", 645 "src/core/SkMatrixInvert.cpp", 646 "src/core/SkSemaphore.cpp", 647 "src/core/SkStream.cpp", 648 "src/core/SkString.cpp", 649 "src/core/SkStringUtils.cpp", 650 "src/core/SkThreadID.cpp", 651 "src/core/SkUtils.cpp", 652 "src/core/SkVM.cpp", 653 "src/gpu/GrMemoryPool.cpp", 654 "src/ports/SkMemory_malloc.cpp", 655 "src/ports/SkOSFile_stdio.cpp", 656 "src/sksl/SkSLMain.cpp", 657 "src/utils/SkJSON.cpp", 658 "src/utils/SkJSONWriter.cpp", 659 "src/utils/SkParse.cpp", 660 "src/utils/SkShaderUtils.cpp", 661 "src/utils/SkUTF.cpp", 662 "src/utils/SkVMVisualizer.cpp", 663 ] 664 libs = [] 665 if (is_win) { 666 sources += [ "src/ports/SkOSFile_win.cpp" ] 667 } else { 668 sources += [ "src/ports/SkOSFile_posix.cpp" ] 669 libs += [ "dl" ] 670 } 671 sources += skia_sksl_sources 672 sources += skia_sksl_gpu_sources 673 include_dirs = [ "." ] 674 deps = [ 675 ":run_sksllex", 676 ":skvm_jit", 677 "//third_party/externals/spirv-tools:spvtools", 678 "//third_party/externals/spirv-tools:spvtools_val", 679 "//third_party/spirv-cross:spirv_cross", 680 ] 681 } 682 683 skslc_path = "$root_out_dir/" 684 if (host_toolchain != default_toolchain_name) { 685 skslc_path += "$host_toolchain/" 686 } 687 skslc_path += "skslc" 688 if (host_os == "win") { 689 skslc_path += ".exe" 690 } 691 692 copy("sksl_pre_includes") { 693 sources = [ 694 "src/sksl/sksl_frag.sksl", 695 "src/sksl/sksl_gpu.sksl", 696 "src/sksl/sksl_public.sksl", 697 "src/sksl/sksl_rt_shader.sksl", 698 "src/sksl/sksl_vert.sksl", 699 ] 700 outputs = [ "$root_out_dir/{{source_file_part}}" ] 701 } 702 703 dehydrate_sksl_sources = get_target_outputs(":sksl_pre_includes") 704 705 dehydrate_sksl_outputs = [] 706 foreach(src, dehydrate_sksl_sources) { 707 name = get_path_info(src, "name") 708 709 # GN insists its outputs should go somewhere underneath target_out_dir, so we trick it with a 710 # path that starts with target_out_dir and then uses ".." to back up into the src dir. 711 dehydrate_sksl_outputs += [ "$target_out_dir/" + rebase_path( 712 "src/sksl/generated/$name.dehydrated.sksl", 713 target_out_dir) ] 714 } 715 716 action("dehydrate_sksl") { 717 script = "gn/dehydrate_sksl.py" 718 deps = [ 719 ":sksl_pre_includes", 720 ":skslc(//gn/toolchain:$host_toolchain)", 721 ] 722 sources = dehydrate_sksl_sources 723 outputs = dehydrate_sksl_outputs 724 args = [ 725 rebase_path(skslc_path), 726 rebase_path("src/sksl/generated"), 727 ] 728 args += rebase_path(dehydrate_sksl_sources) 729 } 730} else { 731 group("dehydrate_sksl") { 732 } 733} 734 735if (skia_compile_sksl_tests) { 736 import("gn/sksl_tests.gni") 737 738 template("compile_sksl") { 739 # Compile the passed-in `sources` into `outputs` using skslc, with the given language/settings. 740 action("compile_sksl_${target_name}") { 741 script = "gn/compile_sksl_tests.py" 742 deps = [ 743 ":sksl_pre_includes", 744 ":skslc(//gn/toolchain:$host_toolchain)", 745 ] 746 sources = [] 747 outputs = [] 748 response_file_contents = [] 749 args = [ 750 rebase_path(skslc_path), 751 invoker.lang, 752 invoker.settings, 753 "{{response_file_name}}", 754 ] 755 756 testsDir = get_path_info("tests", "abspath") 757 resourcesDir = get_path_info("resources", "abspath") 758 759 foreach(partialPath, invoker.sources) { 760 dst = testsDir + partialPath 761 src = resourcesDir + partialPath 762 763 dir = get_path_info(dst, "dir") 764 765 # We want to support double-extensions (for '.dsl.cpp') but GN doesn't natively handle this. 766 # Workaround: http://go/ggroup/a/chromium.org/g/gn-dev/c/RdEpjeYtb-4 767 # For input path "file.aa.bb", name will contain "file" and ext will contain ".aa.bb". 768 # For input path "file.cc", name will contain "file" and ext will contain ".cc". 769 nameTmp = get_path_info(dst, "name") 770 name = get_path_info(nameTmp, "name") 771 ext = get_path_info(nameTmp, "extension") 772 ext += get_path_info(dst, "extension") 773 response_file_contents += rebase_path([ 774 src, 775 dir, 776 ]) 777 sources += [ src ] 778 779 foreach(outExtension, invoker.outExtensions) { 780 # SPIR-V uses separate extensions for .vert shaders. 781 if (ext == "vert" && outExtension == ".asm.frag") { 782 outExtension = ".asm.vert" 783 } 784 outputs += 785 [ target_out_dir + "/" + 786 rebase_path(dir + "/" + name + outExtension, target_out_dir) ] 787 } 788 } 789 } 790 } 791 compile_sksl("glsl_tests") { 792 sources = sksl_glsl_tests_sources + sksl_glsl_settings_tests_sources 793 outExtensions = [ ".glsl" ] 794 lang = "--glsl" 795 settings = "--settings" 796 } 797 compile_sksl("glsl_nosettings_tests") { 798 sources = sksl_glsl_settings_tests_sources 799 outExtensions = [ "StandaloneSettings.glsl" ] 800 lang = "--glsl" 801 settings = "--nosettings" 802 } 803 compile_sksl("metal_tests") { 804 sources = sksl_metal_tests_sources 805 outExtensions = [ ".metal" ] 806 lang = "--metal" 807 settings = "--settings" 808 } 809 compile_sksl("skvm_tests") { 810 sources = sksl_skvm_tests_sources 811 outExtensions = [ ".skvm" ] 812 lang = "--skvm" 813 settings = "--settings" 814 } 815 compile_sksl("stage_tests") { 816 sources = sksl_stage_tests_sources 817 outExtensions = [ ".stage" ] 818 lang = "--stage" 819 settings = "--settings" 820 } 821 compile_sksl("spirv_tests") { 822 sources = sksl_spirv_tests_sources 823 outExtensions = [ ".asm.frag" ] 824 lang = "--spirv" 825 settings = "--settings" 826 } 827} else { 828 group("compile_sksl_glsl_tests") { 829 } 830 group("compile_sksl_glsl_nosettings_tests") { 831 } 832 group("compile_sksl_metal_tests") { 833 } 834 group("compile_sksl_skvm_tests") { 835 } 836 group("compile_sksl_spirv_tests") { 837 } 838} 839 840optional("gpu_shared") { 841 enabled = skia_enable_gpu || skia_enable_graphite 842 843 sources = skia_shared_gpu_sources 844} 845 846optional("gpu") { 847 enabled = skia_enable_gpu 848 deps = [ 849 ":compile_sksl_glsl_nosettings_tests", 850 ":compile_sksl_glsl_tests", 851 ":compile_sksl_metal_tests", 852 ":compile_sksl_skvm_tests", 853 ":compile_sksl_spirv_tests", 854 ":dehydrate_sksl", 855 ":gpu_shared", 856 ":run_sksllex", 857 ] 858 if (skia_generate_workarounds) { 859 deps += [ ":workaround_list" ] 860 } 861 public_defines = [] 862 public_configs = [] 863 public_deps = [] 864 865 sources = skia_gpu_sources + skia_sksl_gpu_sources 866 if (!skia_enable_skgpu_v1) { 867 sources -= skia_skgpu_v1_sources 868 } 869 870 libs = [] 871 frameworks = [] 872 873 if (skia_use_gl) { 874 public_defines += [ "SK_GL" ] 875 if (is_android) { 876 sources += [ 877 "src/gpu/gl/egl/GrGLMakeEGLInterface.cpp", 878 "src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp", 879 ] 880 881 # this lib is required to link against AHardwareBuffer 882 if (defined(ndk_api) && ndk_api >= 26) { 883 libs += [ "android" ] 884 } 885 } else if (skia_use_egl) { 886 sources += [ 887 "src/gpu/gl/egl/GrGLMakeEGLInterface.cpp", 888 "src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp", 889 ] 890 libs += [ "EGL" ] 891 } else if (skia_use_webgl) { 892 sources += [ "src/gpu/gl/webgl/GrGLMakeNativeInterface_webgl.cpp" ] 893 } else if (is_linux && skia_use_x11) { 894 sources += [ 895 "src/gpu/gl/glx/GrGLMakeGLXInterface.cpp", 896 "src/gpu/gl/glx/GrGLMakeNativeInterface_glx.cpp", 897 ] 898 libs += [ "GL" ] 899 } else if (is_mac) { 900 sources += [ "src/gpu/gl/mac/GrGLMakeNativeInterface_mac.cpp" ] 901 } else if (is_ios) { 902 sources += [ "src/gpu/gl/iOS/GrGLMakeNativeInterface_iOS.cpp" ] 903 } else if (is_win && !skia_enable_winuwp) { 904 sources += [ "src/gpu/gl/win/GrGLMakeNativeInterface_win.cpp" ] 905 if (target_cpu != "arm64") { 906 libs += [ "OpenGL32.lib" ] 907 } 908 } else { 909 sources += [ "src/gpu/gl/GrGLMakeNativeInterface_none.cpp" ] 910 } 911 sources += skia_gl_gpu_sources 912 } 913 914 if (skia_use_vulkan) { 915 public_defines += [ "SK_VULKAN" ] 916 if (skia_use_vma) { 917 deps += [ "third_party/vulkanmemoryallocator" ] 918 } 919 sources += skia_vk_sources 920 if (skia_enable_vulkan_debug_layers) { 921 public_defines += [ "SK_ENABLE_VK_LAYERS" ] 922 } 923 if (is_fuchsia) { 924 if (using_fuchsia_sdk) { 925 public_deps += [ "$fuchsia_sdk_root/pkg:vulkan" ] 926 } else { 927 public_deps += [ "//src/graphics/lib/vulkan" ] 928 } 929 } 930 } 931 932 if (is_android && (skia_use_gl || skia_use_vulkan)) { 933 # this lib is required to link against AHardwareBuffer 934 if (defined(ndk_api) && ndk_api >= 26) { 935 libs += [ "android" ] 936 } 937 } 938 939 if (skia_use_dawn) { 940 public_defines += [ "SK_DAWN" ] 941 sources += skia_dawn_sources 942 public_deps += [ "//third_party/externals/dawn/src/dawn:dawn_headers" ] 943 deps += [ 944 "//third_party/externals/dawn/src/dawn:dawn_proc", 945 "//third_party/externals/dawn/src/dawn:dawncpp", 946 ] 947 if (dawn_enable_d3d12 || dawn_enable_desktop_gl || dawn_enable_metal || 948 dawn_enable_opengles || dawn_enable_vulkan) { 949 deps += [ "//third_party/externals/dawn/src/dawn_native" ] 950 } 951 if (dawn_enable_d3d12) { 952 libs += [ 953 "d3d12.lib", 954 "dxgi.lib", 955 "d3dcompiler.lib", 956 ] 957 } else if (dawn_enable_metal) { 958 frameworks += [ "Metal.framework" ] 959 } 960 } 961 962 if (skia_use_direct3d) { 963 public_defines += [ 964 "SK_DIRECT3D", 965 "SK_ENABLE_SPIRV_CROSS", 966 ] 967 deps += [ 968 "//third_party/d3d12allocator", 969 "//third_party/spirv-cross:spirv_cross", 970 ] 971 sources += skia_direct3d_sources 972 if (skia_enable_direct3d_debug_layer) { 973 public_defines += [ "SK_ENABLE_D3D_DEBUG_LAYER" ] 974 } 975 libs += [ 976 "d3d12.lib", 977 "dxgi.lib", 978 "d3dcompiler.lib", 979 ] 980 } 981 982 cflags_objcc = [] 983 if (skia_use_metal) { 984 public_defines += [ "SK_METAL" ] 985 sources += skia_metal_sources 986 if (skia_enable_metal_debug_info) { 987 public_defines += [ "SK_ENABLE_MTL_DEBUG_INFO" ] 988 } 989 frameworks += [ "Metal.framework" ] 990 frameworks += [ "Foundation.framework" ] 991 if (is_ios) { 992 frameworks += [ "UIKit.framework" ] 993 } 994 cflags_objcc += [ "-fobjc-arc" ] 995 } 996 997 if (is_debug) { 998 public_defines += [ "SK_ENABLE_DUMP_GPU" ] 999 } 1000} 1001 1002optional("gif") { 1003 enabled = !skia_use_wuffs && skia_use_libgifcodec 1004 _libgifcodec_gni_path = "third_party/externals/libgifcodec/libgifcodec.gni" 1005 if ("True" == 1006 exec_script("gn/checkpath.py", 1007 [ rebase_path(_libgifcodec_gni_path, root_build_dir) ], 1008 "trim string")) { 1009 public_defines = [ "SK_USE_LIBGIFCODEC" ] 1010 public_include_dirs = [ 1011 ".", 1012 skia_libgifcodec_path, 1013 ] 1014 include_dirs = public_include_dirs 1015 import(_libgifcodec_gni_path) 1016 sources = rebase_path(libgifcodec_sources + libgifcodec_public, 1017 ".", 1018 skia_libgifcodec_path) 1019 } 1020} 1021 1022optional("heif") { 1023 enabled = skia_use_libheif 1024 public_defines = [ "SK_HAS_HEIF_LIBRARY" ] 1025 1026 # This HEIF decoding functionality is a part of the Android Framework. 1027 # https://android.googlesource.com/platform/frameworks/av/+/master/media/libheif/include/HeifDecoderAPI.h 1028 # There isn't a way to compile that library outside of it, so we just link against 1029 # the library. This feature is not supported on other platforms (and we haven't 1030 # yet tried something like https://github.com/strukturag/libheif/tree/master/libheif). 1031 # The dependency for Android is set in gn_to_bp.py. 1032 deps = [] 1033 1034 sources = [ "src/codec/SkHeifCodec.cpp" ] 1035} 1036 1037optional("jpeg_decode") { 1038 enabled = skia_use_libjpeg_turbo_decode 1039 public_defines = [ "SK_CODEC_DECODES_JPEG" ] 1040 1041 deps = [ "//third_party/libjpeg-turbo:libjpeg" ] 1042 sources = [ 1043 "src/codec/SkJpegCodec.cpp", 1044 "src/codec/SkJpegDecoderMgr.cpp", 1045 "src/codec/SkJpegUtility.cpp", 1046 ] 1047} 1048 1049optional("jpeg_encode") { 1050 enabled = skia_use_libjpeg_turbo_encode 1051 public_defines = [ "SK_ENCODE_JPEG" ] 1052 1053 deps = [ "//third_party/libjpeg-turbo:libjpeg" ] 1054 public = [ "include/encode/SkJpegEncoder.h" ] 1055 sources = [ 1056 "src/images/SkJPEGWriteUtility.cpp", 1057 "src/images/SkJpegEncoder.cpp", 1058 ] 1059} 1060 1061optional("jpegxl_decode") { 1062 enabled = skia_use_libjxl_decode 1063 public_defines = [ "SK_CODEC_DECODES_JPEGXL" ] 1064 1065 deps = [ "//third_party/libjxl" ] 1066 sources = [ "src/codec/SkJpegxlCodec.cpp" ] 1067} 1068 1069optional("ndk_images") { 1070 enabled = skia_use_ndk_images 1071 public_defines = [ "SK_ENABLE_NDK_IMAGES" ] 1072 sources = [ 1073 "src/ports/SkImageEncoder_NDK.cpp", 1074 "src/ports/SkImageGeneratorNDK.cpp", 1075 "src/ports/SkNDKConversions.cpp", 1076 ] 1077 libs = [ "jnigraphics" ] 1078} 1079 1080optional("graphite") { 1081 libs = [] 1082 frameworks = [] 1083 1084 enabled = skia_enable_graphite 1085 deps = [ ":gpu_shared" ] 1086 public_defines = [ "SK_GRAPHITE_ENABLED" ] 1087 public = skia_graphite_public 1088 sources = skia_graphite_sources 1089 if (skia_use_metal) { 1090 public_defines += [ "SK_METAL" ] 1091 sources += skia_graphite_mtl_sources 1092 if (skia_enable_metal_debug_info) { 1093 public_defines += [ "SK_ENABLE_MTL_DEBUG_INFO" ] 1094 } 1095 frameworks += [ "Metal.framework" ] 1096 frameworks += [ "Foundation.framework" ] 1097 if (is_ios) { 1098 frameworks += [ "UIKit.framework" ] 1099 } 1100 } 1101} 1102 1103optional("pdf") { 1104 enabled = skia_use_zlib && skia_enable_pdf 1105 public_defines = [ "SK_SUPPORT_PDF" ] 1106 1107 deps = [ "//third_party/zlib" ] 1108 if (skia_use_libjpeg_turbo_decode) { 1109 deps += [ ":jpeg_decode" ] 1110 } 1111 if (skia_use_libjpeg_turbo_encode) { 1112 deps += [ ":jpeg_encode" ] 1113 } 1114 public = skia_pdf_public 1115 sources = skia_pdf_sources 1116 sources_when_disabled = [ "src/pdf/SkDocument_PDF_None.cpp" ] 1117 if (skia_use_icu && skia_use_harfbuzz && skia_pdf_subset_harfbuzz) { 1118 deps += [ "//third_party/harfbuzz" ] 1119 defines = [ "SK_PDF_USE_HARFBUZZ_SUBSET" ] 1120 } else if (skia_use_icu && skia_use_sfntly) { 1121 deps += [ "//third_party/sfntly" ] 1122 defines = [ "SK_PDF_USE_SFNTLY" ] 1123 } 1124} 1125 1126optional("xps") { 1127 enabled = skia_use_xps && is_win 1128 public_defines = [ "SK_SUPPORT_XPS" ] 1129 public = skia_xps_public 1130 sources = skia_xps_sources 1131} 1132 1133optional("png_decode") { 1134 enabled = skia_use_libpng_decode 1135 public_defines = [ "SK_CODEC_DECODES_PNG" ] 1136 1137 deps = [ "//third_party/libpng" ] 1138 sources = [ 1139 "src/codec/SkIcoCodec.cpp", 1140 "src/codec/SkPngCodec.cpp", 1141 ] 1142} 1143 1144optional("png_encode") { 1145 enabled = skia_use_libpng_encode 1146 public_defines = [ "SK_ENCODE_PNG" ] 1147 1148 deps = [ "//third_party/libpng" ] 1149 sources = [ "src/images/SkPngEncoder.cpp" ] 1150} 1151 1152optional("raw") { 1153 enabled = skia_use_dng_sdk && skia_use_libjpeg_turbo_decode && skia_use_piex 1154 public_defines = [ "SK_CODEC_DECODES_RAW" ] 1155 1156 deps = [ 1157 "//third_party/dng_sdk", 1158 "//third_party/libjpeg-turbo:libjpeg", 1159 "//third_party/piex", 1160 ] 1161 1162 # SkRawCodec catches any exceptions thrown by dng_sdk, insulating the rest of 1163 # Skia. 1164 configs = [ "gn/portable:add_exceptions" ] 1165 1166 sources = [ "src/codec/SkRawCodec.cpp" ] 1167} 1168 1169import("third_party/skcms/skcms.gni") 1170skia_source_set("skcms") { 1171 cflags = [] 1172 if (!is_win || is_clang) { 1173 cflags += [ 1174 "-w", 1175 "-std=c11", 1176 ] 1177 } 1178 1179 public = [ "include/third_party/skcms/skcms.h" ] 1180 include_dirs = [ "include/third_party/skcms" ] 1181 sources = rebase_path(skcms_sources, ".", "third_party/skcms") 1182} 1183 1184optional("typeface_freetype") { 1185 enabled = skia_use_freetype 1186 1187 deps = [ "//third_party/freetype2" ] 1188 sources = [ 1189 "src/ports/SkFontHost_FreeType.cpp", 1190 "src/ports/SkFontHost_FreeType_common.cpp", 1191 "src/ports/SkFontHost_FreeType_common.h", 1192 ] 1193} 1194 1195optional("webp_decode") { 1196 enabled = skia_use_libwebp_decode 1197 public_defines = [ "SK_CODEC_DECODES_WEBP" ] 1198 1199 deps = [ "//third_party/libwebp" ] 1200 sources = [ "src/codec/SkWebpCodec.cpp" ] 1201} 1202 1203optional("webp_encode") { 1204 enabled = skia_use_libwebp_encode 1205 public_defines = [ "SK_ENCODE_WEBP" ] 1206 1207 deps = [ "//third_party/libwebp" ] 1208 sources = [ "src/images/SkWebpEncoder.cpp" ] 1209} 1210 1211optional("wuffs") { 1212 enabled = skia_use_wuffs 1213 public_defines = [ "SK_HAS_WUFFS_LIBRARY" ] 1214 1215 deps = [ "//third_party/wuffs" ] 1216 sources = [ "src/codec/SkWuffsCodec.cpp" ] 1217} 1218 1219optional("xml") { 1220 enabled = skia_use_expat 1221 public_defines = [ "SK_XML" ] 1222 1223 deps = [ "//third_party/expat" ] 1224 sources = [ 1225 "src/svg/SkSVGCanvas.cpp", 1226 "src/svg/SkSVGDevice.cpp", 1227 "src/xml/SkDOM.cpp", 1228 "src/xml/SkXMLParser.cpp", 1229 "src/xml/SkXMLWriter.cpp", 1230 ] 1231} 1232 1233optional("skvm_jit") { 1234 enabled = skia_enable_skvm_jit_when_possible 1235 public_defines = [ "SKVM_JIT_WHEN_POSSIBLE" ] 1236 if (skia_vtune_path != "") { 1237 public_defines += [ "SKVM_JIT_VTUNE" ] 1238 public_include_dirs = [ "$skia_vtune_path/include" ] 1239 libs = [ "$skia_vtune_path/lib64/jitprofiling.lib" ] 1240 } 1241} 1242 1243if (skia_enable_gpu && skia_generate_workarounds) { 1244 action("workaround_list") { 1245 script = "tools/build_workaround_header.py" 1246 1247 inputs = [ "src/gpu/gpu_workaround_list.txt" ] 1248 1249 # GN insists its outputs should go somewhere underneath root_out_dir, so we trick it with a 1250 # path that starts with root_out_dir and then uses ".." to back up into the src dir. 1251 output_file = 1252 rebase_path("include/gpu/GrDriverBugWorkaroundsAutogen.h", root_out_dir) 1253 1254 outputs = [ "$root_out_dir/$output_file" ] 1255 args = [ 1256 "--output-file", 1257 "$output_file", 1258 ] 1259 1260 foreach(file, inputs) { 1261 args += [ rebase_path(file, root_build_dir) ] 1262 } 1263 } 1264} 1265 1266skia_component("skia") { 1267 public_configs = [ ":skia_public" ] 1268 configs = skia_library_configs 1269 1270 public_deps = [ 1271 ":fontmgr_FontConfigInterface", 1272 ":fontmgr_android", 1273 ":fontmgr_custom_directory", 1274 ":fontmgr_custom_embedded", 1275 ":fontmgr_custom_empty", 1276 ":fontmgr_fontconfig", 1277 ":fontmgr_fuchsia", 1278 ":fontmgr_mac_ct", 1279 ":fontmgr_win", 1280 ":fontmgr_win_gdi", 1281 ":gpu", 1282 ":graphite", 1283 ":pdf", 1284 ":skcms", 1285 ":xps", 1286 ] 1287 1288 deps = [ 1289 ":android_utils", 1290 ":arm64", 1291 ":armv7", 1292 ":avx", 1293 ":crc32", 1294 ":fontmgr_factory", 1295 ":gif", 1296 ":heif", 1297 ":hsw", 1298 ":jpeg_decode", 1299 ":jpeg_encode", 1300 ":jpegxl_decode", 1301 ":ndk_images", 1302 ":none", 1303 ":png_decode", 1304 ":png_encode", 1305 ":raw", 1306 ":skvm_jit", 1307 ":skx", 1308 ":sse2", 1309 ":sse41", 1310 ":sse42", 1311 ":ssse3", 1312 ":webp_decode", 1313 ":webp_encode", 1314 ":wuffs", 1315 ":xml", 1316 ] 1317 1318 public = skia_core_public 1319 public += skia_utils_public 1320 public += skia_effects_public 1321 public += skia_effects_imagefilter_public 1322 1323 sources = [] 1324 sources += skia_core_sources 1325 sources += skia_utils_sources 1326 sources += skia_effects_sources 1327 sources += skia_effects_imagefilter_sources 1328 sources += [ 1329 "src/android/SkAndroidFrameworkUtils.cpp", 1330 "src/android/SkAnimatedImage.cpp", 1331 "src/codec/SkAndroidCodec.cpp", 1332 "src/codec/SkAndroidCodecAdapter.cpp", 1333 "src/codec/SkBmpBaseCodec.cpp", 1334 "src/codec/SkBmpCodec.cpp", 1335 "src/codec/SkBmpMaskCodec.cpp", 1336 "src/codec/SkBmpRLECodec.cpp", 1337 "src/codec/SkBmpStandardCodec.cpp", 1338 "src/codec/SkCodec.cpp", 1339 "src/codec/SkCodecImageGenerator.cpp", 1340 "src/codec/SkColorTable.cpp", 1341 "src/codec/SkEncodedInfo.cpp", 1342 "src/codec/SkMaskSwizzler.cpp", 1343 "src/codec/SkMasks.cpp", 1344 "src/codec/SkParseEncodedOrigin.cpp", 1345 "src/codec/SkSampledCodec.cpp", 1346 "src/codec/SkSampler.cpp", 1347 "src/codec/SkStreamBuffer.cpp", 1348 "src/codec/SkSwizzler.cpp", 1349 "src/codec/SkWbmpCodec.cpp", 1350 "src/images/SkImageEncoder.cpp", 1351 "src/ports/SkDiscardableMemory_none.cpp", 1352 "src/ports/SkGlobalInitialization_default.cpp", 1353 "src/ports/SkImageGenerator_skia.cpp", 1354 "src/ports/SkMemory_malloc.cpp", 1355 "src/ports/SkOSFile_stdio.cpp", 1356 "src/sfnt/SkOTTable_name.cpp", 1357 "src/sfnt/SkOTUtils.cpp", 1358 ] 1359 1360 defines = [ "SK_HAS_ANDROID_CODEC" ] 1361 libs = [] 1362 1363 if (skia_enable_sksl) { 1364 deps += [ ":dehydrate_sksl" ] 1365 sources += skia_sksl_sources 1366 } 1367 1368 if (is_win) { 1369 sources += [ 1370 "src/ports/SkDebug_win.cpp", 1371 "src/ports/SkImageEncoder_WIC.cpp", 1372 "src/ports/SkImageGeneratorWIC.cpp", 1373 "src/ports/SkOSFile_win.cpp", 1374 "src/ports/SkOSLibrary_win.cpp", 1375 ] 1376 libs += [ 1377 "Ole32.lib", 1378 "OleAut32.lib", 1379 ] 1380 1381 if (!skia_enable_winuwp) { 1382 libs += [ 1383 "FontSub.lib", 1384 "User32.lib", 1385 "Usp10.lib", 1386 ] 1387 } 1388 } else { 1389 sources += [ 1390 "src/ports/SkOSFile_posix.cpp", 1391 "src/ports/SkOSLibrary_posix.cpp", 1392 ] 1393 libs += [ "dl" ] 1394 } 1395 1396 if (is_android) { 1397 deps += [ "//third_party/expat" ] 1398 if (defined(ndk) && ndk != "") { 1399 deps += [ "//third_party/cpu-features" ] 1400 } 1401 sources += [ "src/ports/SkDebug_android.cpp" ] 1402 libs += [ 1403 "EGL", 1404 "GLESv2", 1405 "log", 1406 ] 1407 } 1408 1409 if (is_linux || target_cpu == "wasm") { 1410 sources += [ "src/ports/SkDebug_stdio.cpp" ] 1411 if (skia_use_egl) { 1412 libs += [ "GLESv2" ] 1413 } 1414 } 1415 1416 if (is_mac) { 1417 public += [ "include/ports/SkCFObject.h" ] 1418 sources += [ 1419 "src/ports/SkDebug_stdio.cpp", 1420 "src/ports/SkImageEncoder_CG.cpp", 1421 "src/ports/SkImageGeneratorCG.cpp", 1422 ] 1423 frameworks = [ 1424 "ApplicationServices.framework", 1425 "OpenGL.framework", 1426 ] 1427 } 1428 1429 if (is_ios) { 1430 public += [ "include/ports/SkCFObject.h" ] 1431 sources += [ 1432 "src/ports/SkDebug_stdio.cpp", 1433 "src/ports/SkImageEncoder_CG.cpp", 1434 "src/ports/SkImageGeneratorCG.cpp", 1435 ] 1436 frameworks = [ 1437 "CoreFoundation.framework", 1438 "ImageIO.framework", 1439 "MobileCoreServices.framework", 1440 ] 1441 } 1442 1443 if (is_fuchsia) { 1444 sources += [ "src/ports/SkDebug_stdio.cpp" ] 1445 } 1446 1447 if (skia_enable_spirv_validation) { 1448 deps += [ "//third_party/externals/spirv-tools:spvtools_val" ] 1449 defines += [ "SK_ENABLE_SPIRV_VALIDATION" ] 1450 } 1451 1452 if (skia_include_multiframe_procs) { 1453 sources += [ "tools/SkSharingProc.cpp" ] 1454 } 1455} 1456 1457# DebugCanvas used in experimental/wasm-skp-debugger 1458if (target_cpu == "wasm") { 1459 skia_static_library("debugcanvas") { 1460 public_configs = [ ":skia_public" ] 1461 1462 sources = [ 1463 "tools/SkSharingProc.cpp", 1464 "tools/UrlDataManager.cpp", 1465 "tools/debugger/DebugCanvas.cpp", 1466 "tools/debugger/DebugLayerManager.cpp", 1467 "tools/debugger/DrawCommand.cpp", 1468 "tools/debugger/JsonWriteBuffer.cpp", 1469 ] 1470 } 1471} 1472 1473skia_static_library("pathkit") { 1474 check_includes = false 1475 public_configs = [ ":skia_public" ] 1476 configs = skia_library_configs 1477 1478 deps = [ 1479 ":arm64", 1480 ":armv7", 1481 ":avx", 1482 ":crc32", 1483 ":hsw", 1484 ":none", 1485 ":sse2", 1486 ":sse41", 1487 ":sse42", 1488 ":ssse3", 1489 ] 1490 1491 sources = [] 1492 sources += skia_pathops_sources 1493 sources += skia_pathops_public 1494 sources += [ 1495 "src/core/SkAnalyticEdge.cpp", 1496 "src/core/SkArenaAlloc.cpp", 1497 "src/core/SkContourMeasure.cpp", 1498 "src/core/SkCubicMap.cpp", 1499 "src/core/SkEdge.cpp", 1500 "src/core/SkEdgeBuilder.cpp", 1501 "src/core/SkEdgeClipper.cpp", 1502 "src/core/SkGeometry.cpp", 1503 "src/core/SkIDChangeListener.cpp", 1504 "src/core/SkLineClipper.cpp", 1505 "src/core/SkMalloc.cpp", 1506 "src/core/SkMallocPixelRef.cpp", 1507 "src/core/SkMath.cpp", 1508 "src/core/SkMatrix.cpp", 1509 "src/core/SkOpts.cpp", 1510 "src/core/SkPaint.cpp", 1511 "src/core/SkPaintPriv.cpp", 1512 "src/core/SkPath.cpp", 1513 "src/core/SkPathBuilder.cpp", 1514 "src/core/SkPathEffect.cpp", 1515 "src/core/SkPathMeasure.cpp", 1516 "src/core/SkPathRef.cpp", 1517 "src/core/SkPoint.cpp", 1518 "src/core/SkRRect.cpp", 1519 "src/core/SkReadBuffer.cpp", 1520 "src/core/SkRect.cpp", 1521 "src/core/SkSemaphore.cpp", 1522 "src/core/SkStream.cpp", 1523 "src/core/SkString.cpp", 1524 "src/core/SkStringUtils.cpp", 1525 "src/core/SkStroke.cpp", 1526 "src/core/SkStrokeRec.cpp", 1527 "src/core/SkStrokerPriv.cpp", 1528 "src/core/SkThreadID.cpp", 1529 "src/core/SkUtils.cpp", 1530 "src/effects/SkDashPathEffect.cpp", 1531 "src/effects/SkTrimPathEffect.cpp", 1532 "src/ports/SkDebug_stdio.cpp", 1533 "src/ports/SkMemory_malloc.cpp", 1534 "src/utils/SkDashPath.cpp", 1535 "src/utils/SkParse.cpp", 1536 "src/utils/SkParsePath.cpp", 1537 "src/utils/SkUTF.cpp", 1538 ] 1539} 1540 1541group("modules") { 1542 deps = [ 1543 "modules/particles", 1544 "modules/skottie", 1545 "modules/skparagraph", 1546 "modules/skshaper", 1547 "modules/svg", 1548 ] 1549 1550 if (is_wasm) { 1551 deps += [ "modules/canvaskit" ] 1552 } 1553} 1554 1555group("experimental") { 1556 deps = [ "experimental/sktext" ] 1557} 1558 1559config("our_vulkan_headers") { 1560 include_dirs = [ "include/third_party/vulkan" ] 1561} 1562 1563# Targets guarded by skia_enable_tools may use //third_party freely. 1564if (skia_enable_tools) { 1565 skia_public_includes = [ 1566 "client_utils/android", 1567 "include/android", 1568 "include/c", 1569 "include/codec", 1570 "include/config", 1571 "include/core", 1572 "include/docs", 1573 "include/effects", 1574 "include/encode", 1575 "include/gpu", 1576 "include/pathops", 1577 "include/ports", 1578 "include/svg", 1579 "include/utils", 1580 "include/utils/mac", 1581 "modules/particles/include", 1582 "modules/skottie/include", 1583 "modules/skparagraph/include", 1584 "modules/skshaper/include", 1585 "modules/svg/include", 1586 ] 1587 1588 # Used by gn_to_bp.py to list our public include dirs. 1589 skia_source_set("public") { 1590 configs = [ ":skia_public" ] 1591 include_dirs = skia_public_includes 1592 } 1593 1594 config("skia.h_config") { 1595 include_dirs = [ "$target_gen_dir" ] 1596 } 1597 action("skia.h") { 1598 public_configs = [ ":skia.h_config" ] 1599 skia_h = "$target_gen_dir/skia.h" 1600 script = "gn/find_headers.py" 1601 1602 args = [ rebase_path("//bin/gn") ] + [ rebase_path("//") ] + 1603 [ rebase_path(skia_h, root_build_dir) ] + 1604 rebase_path(skia_public_includes) 1605 depfile = "$skia_h.deps" 1606 outputs = [ skia_h ] 1607 } 1608 1609 if (target_cpu == "x64") { 1610 skia_executable("fiddle") { 1611 check_includes = false 1612 libs = [] 1613 sources = [ 1614 "tools/fiddle/draw.cpp", 1615 "tools/fiddle/fiddle_main.cpp", 1616 ] 1617 1618 if (skia_use_egl) { 1619 sources += [ "tools/fiddle/egl_context.cpp" ] 1620 } else { 1621 sources += [ "tools/fiddle/null_context.cpp" ] 1622 } 1623 testonly = true 1624 deps = [ 1625 ":flags", 1626 ":gpu_tool_utils", 1627 ":skia", 1628 ":skia.h", 1629 "modules/particles", 1630 "modules/skottie", 1631 "modules/skparagraph", 1632 "modules/skshaper", 1633 "modules/svg", 1634 ] 1635 } 1636 } 1637 1638 config("cpp17") { 1639 if (is_win) { 1640 cflags_cc = [ "/std:c++17" ] 1641 } else { 1642 cflags_cc = [ "-std=c++17" ] 1643 } 1644 } 1645 1646 skia_source_set("public_headers_warnings_check") { 1647 sources = [ "tools/public_headers_warnings_check.cpp" ] 1648 configs = [ 1649 ":our_vulkan_headers", 1650 ":cpp17", 1651 ] 1652 if (defined(skia_header_target_default_configs)) { 1653 configs += skia_header_target_default_configs 1654 } 1655 deps = [ 1656 ":skia", 1657 ":skia.h", 1658 "modules/skottie", 1659 "modules/skshaper", 1660 ] 1661 1662 if (skia_use_dawn) { 1663 deps += [ "//third_party/externals/dawn/src/dawn:dawn_headers" ] 1664 } 1665 } 1666 1667 template("test_lib") { 1668 config(target_name + "_config") { 1669 if (defined(invoker.public_defines)) { 1670 defines = invoker.public_defines 1671 } 1672 } 1673 skia_source_set(target_name) { 1674 forward_variables_from(invoker, "*", []) 1675 check_includes = false 1676 public_configs = [ 1677 ":" + target_name + "_config", 1678 ":skia_private", 1679 ] 1680 1681 if (!defined(deps)) { 1682 deps = [] 1683 } 1684 deps += [ ":skia" ] 1685 testonly = true 1686 } 1687 } 1688 1689 template("test_app") { 1690 if (is_ios) { 1691 ios_app_bundle(target_name) { 1692 forward_variables_from(invoker, 1693 "*", 1694 [ 1695 "output_name", 1696 "visibility", 1697 "is_shared_library", 1698 ]) 1699 testonly = true 1700 extra_configs = [ ":skia_private" ] 1701 launchscreen = "platform_tools/ios/app/LaunchScreen.storyboard" 1702 data_sources = [ "resources" ] 1703 if ("True" == exec_script("//gn/checkdir.py", 1704 [ rebase_path("skps", root_build_dir) ], 1705 "trim string")) { 1706 data_sources += [ "skps" ] 1707 } 1708 if ("True" == exec_script("//gn/checkdir.py", 1709 [ rebase_path("mskps", root_build_dir) ], 1710 "trim string")) { 1711 data_sources += [ "mskps" ] 1712 } 1713 } 1714 } else { 1715 # !is_ios 1716 1717 if (defined(invoker.is_shared_library) && invoker.is_shared_library) { 1718 skia_shared_library("lib" + target_name) { 1719 output_dir = root_build_dir 1720 forward_variables_from(invoker, "*", [ "is_shared_library" ]) 1721 if (!defined(configs)) { 1722 configs = [] 1723 } 1724 configs += [ ":skia_private" ] 1725 testonly = true 1726 } 1727 } else { 1728 _executable = target_name 1729 skia_executable(_executable) { 1730 check_includes = false 1731 output_dir = root_build_dir 1732 forward_variables_from(invoker, "*", [ "is_shared_library" ]) 1733 if (!defined(configs)) { 1734 configs = [] 1735 } 1736 configs += [ ":skia_private" ] 1737 testonly = true 1738 } 1739 } 1740 if (is_android && skia_android_serial != "" && defined(_executable)) { 1741 action("push_" + target_name) { 1742 output_dir = root_build_dir 1743 script = "gn/push_to_android.py" 1744 deps = [ ":" + _executable ] 1745 _stamp = "$target_gen_dir/$_executable.pushed_$skia_android_serial" 1746 outputs = [ _stamp ] 1747 args = [ 1748 rebase_path("$root_build_dir/$_executable"), 1749 skia_android_serial, 1750 rebase_path(_stamp), 1751 ] 1752 testonly = true 1753 } 1754 } 1755 } 1756 } 1757 1758 test_lib("gpu_tool_utils") { 1759 public_defines = [] 1760 1761 # Bots and even devs may not have Vulkan headers, so put 1762 # include/third_party/vulkan on our path so they're always available. 1763 all_dependent_configs = [ ":our_vulkan_headers" ] 1764 1765 defines = [] 1766 if (skia_enable_discrete_gpu) { 1767 defines += [ "SK_ENABLE_DISCRETE_GPU" ] 1768 } 1769 1770 deps = [] 1771 public_deps = [] 1772 sources = [ 1773 "tools/gpu/BackendSurfaceFactory.cpp", 1774 "tools/gpu/BackendSurfaceFactory.h", 1775 "tools/gpu/BackendTextureImageFactory.cpp", 1776 "tools/gpu/BackendTextureImageFactory.h", 1777 "tools/gpu/FlushFinishTracker.cpp", 1778 "tools/gpu/FlushFinishTracker.h", 1779 "tools/gpu/GrContextFactory.cpp", 1780 "tools/gpu/GrTest.cpp", 1781 "tools/gpu/ManagedBackendTexture.cpp", 1782 "tools/gpu/ManagedBackendTexture.h", 1783 "tools/gpu/MemoryCache.cpp", 1784 "tools/gpu/MemoryCache.h", 1785 "tools/gpu/ProxyUtils.cpp", 1786 "tools/gpu/TestContext.cpp", 1787 "tools/gpu/TestOps.cpp", 1788 "tools/gpu/TestOps.h", 1789 "tools/gpu/YUVUtils.cpp", 1790 "tools/gpu/YUVUtils.h", 1791 "tools/gpu/gl/GLTestContext.cpp", # See comment below about 1792 # GrContextFactory workaround. 1793 "tools/gpu/mock/MockTestContext.cpp", 1794 ] 1795 1796 libs = [] 1797 frameworks = [] 1798 1799 if (skia_use_gl) { 1800 sources += 1801 [ "tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp" ] 1802 if (is_ios) { 1803 sources += [ "tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm" ] 1804 frameworks += [ "OpenGLES.framework" ] 1805 } else if (is_mac) { 1806 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ] 1807 } 1808 if (skia_use_angle) { 1809 deps += [ "//third_party/angle2" ] 1810 sources += [ "tools/gpu/gl/angle/GLTestContext_angle.cpp" ] 1811 } 1812 } 1813 1814 if (skia_use_gl && target_cpu != "wasm") { 1815 if (is_android || skia_use_egl) { 1816 sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ] 1817 libs += [ "EGL" ] 1818 } else if (is_linux) { 1819 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ] 1820 libs += [ 1821 "GLU", 1822 "GL", 1823 "X11", 1824 ] 1825 } else if (is_win) { 1826 sources += [ "tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp" ] 1827 libs += [ "Gdi32.lib" ] 1828 if (target_cpu != "arm64") { 1829 libs += [ "OpenGL32.lib" ] 1830 } 1831 } 1832 } 1833 1834 if (skia_use_vulkan) { 1835 sources += [ "tools/gpu/vk/VkTestContext.h" ] 1836 sources += [ "tools/gpu/vk/VkTestContext.cpp" ] 1837 sources += [ "tools/gpu/vk/VkTestHelper.h" ] 1838 sources += [ "tools/gpu/vk/VkTestHelper.cpp" ] 1839 sources += [ "tools/gpu/vk/VkTestUtils.h" ] 1840 sources += [ "tools/gpu/vk/VkTestUtils.cpp" ] 1841 sources += [ "tools/gpu/vk/VkYcbcrSamplerHelper.h" ] 1842 sources += [ "tools/gpu/vk/VkYcbcrSamplerHelper.cpp" ] 1843 } 1844 if (skia_use_metal) { 1845 sources += [ "tools/gpu/mtl/MtlTestContext.mm" ] 1846 } 1847 if (skia_use_direct3d) { 1848 sources += [ "tools/gpu/d3d/D3DTestContext.cpp" ] 1849 sources += [ "tools/gpu/d3d/D3DTestUtils.cpp" ] 1850 } 1851 if (skia_use_dawn) { 1852 public_deps += [ "//third_party/externals/dawn/src/dawn:dawn_headers" ] 1853 sources += [ "tools/gpu/dawn/DawnTestContext.cpp" ] 1854 if (is_clang) { 1855 cflags_cc = [ "-Wno-microsoft-cast" ] 1856 } 1857 } 1858 if (!skia_enable_skgpu_v1) { 1859 sources -= [ "tools/gpu/GrTest.cpp" ] 1860 sources -= [ "tools/gpu/TestOps.cpp" ] 1861 sources -= [ "tools/gpu/TestOps.h" ] 1862 } 1863 if (skia_enable_graphite) { 1864 sources += [ "tools/graphite/ContextFactory.h" ] 1865 sources += [ "tools/graphite/ContextFactory.cpp" ] 1866 sources += [ "tools/graphite/GraphiteTestContext.h" ] 1867 sources += [ "tools/graphite/GraphiteTestContext.cpp" ] 1868 if (skia_use_metal) { 1869 sources += [ "tools/graphite/mtl/GraphiteMtlTestContext.h" ] 1870 sources += [ "tools/graphite/mtl/MtlTestContext.mm" ] 1871 } 1872 } 1873 1874 if (is_fuchsia && using_fuchsia_sdk) { 1875 libs += 1876 [ "${fuchsia_sdk_path}/arch/${target_cpu}/sysroot/lib/libzircon.so" ] 1877 } 1878 } # test_lib("gpu_tool_utils") 1879 1880 test_lib("flags") { 1881 sources = [ "tools/flags/CommandLineFlags.cpp" ] 1882 } 1883 1884 test_lib("common_flags_config") { 1885 sources = [ "tools/flags/CommonFlagsConfig.cpp" ] 1886 deps = [ ":flags" ] 1887 public_deps = [ ":gpu_tool_utils" ] 1888 } 1889 test_lib("common_flags_gpu") { 1890 sources = [ "tools/flags/CommonFlagsGpu.cpp" ] 1891 deps = [ ":flags" ] 1892 public_deps = [ ":gpu_tool_utils" ] 1893 } 1894 test_lib("common_flags_images") { 1895 sources = [ "tools/flags/CommonFlagsImages.cpp" ] 1896 deps = [ ":flags" ] 1897 } 1898 test_lib("common_flags_fontmgr") { 1899 sources = [ "tools/flags/CommonFlagsFontMgr.cpp" ] 1900 deps = [ ":flags" ] 1901 } 1902 test_lib("common_flags_aa") { 1903 sources = [ "tools/flags/CommonFlagsAA.cpp" ] 1904 deps = [ ":flags" ] 1905 } 1906 1907 test_lib("trace") { 1908 deps = [ ":flags" ] 1909 sources = [ 1910 "tools/trace/ChromeTracingTracer.cpp", 1911 "tools/trace/ChromeTracingTracer.h", 1912 "tools/trace/EventTracingPriv.cpp", 1913 "tools/trace/EventTracingPriv.h", 1914 "tools/trace/SkDebugfTracer.cpp", 1915 "tools/trace/SkDebugfTracer.h", 1916 ] 1917 } 1918 1919 test_lib("tool_utils") { 1920 sources = [ 1921 "tools/AndroidSkDebugToStdOut.cpp", 1922 "tools/AutoreleasePool.h", 1923 "tools/DDLPromiseImageHelper.cpp", 1924 "tools/DDLPromiseImageHelper.h", 1925 "tools/DDLTileHelper.cpp", 1926 "tools/DDLTileHelper.h", 1927 "tools/LsanSuppressions.cpp", 1928 "tools/MSKPPlayer.cpp", 1929 "tools/MSKPPlayer.h", 1930 "tools/ProcStats.cpp", 1931 "tools/ProcStats.h", 1932 "tools/Resources.cpp", 1933 "tools/Resources.h", 1934 "tools/RuntimeBlendUtils.cpp", 1935 "tools/RuntimeBlendUtils.h", 1936 "tools/SkMetaData.cpp", 1937 "tools/SkMetaData.h", 1938 "tools/SkSharingProc.cpp", 1939 "tools/SkSharingProc.h", 1940 "tools/Stats.h", 1941 "tools/ToolUtils.cpp", 1942 "tools/ToolUtils.h", 1943 "tools/UrlDataManager.cpp", 1944 "tools/UrlDataManager.h", 1945 "tools/debugger/DebugCanvas.cpp", 1946 "tools/debugger/DebugCanvas.h", 1947 "tools/debugger/DebugLayerManager.cpp", 1948 "tools/debugger/DebugLayerManager.h", 1949 "tools/debugger/DrawCommand.cpp", 1950 "tools/debugger/DrawCommand.h", 1951 "tools/debugger/JsonWriteBuffer.cpp", 1952 "tools/debugger/JsonWriteBuffer.h", 1953 "tools/fonts/RandomScalerContext.cpp", 1954 "tools/fonts/RandomScalerContext.h", 1955 "tools/fonts/TestEmptyTypeface.h", 1956 "tools/fonts/TestFontMgr.cpp", 1957 "tools/fonts/TestFontMgr.h", 1958 "tools/fonts/TestSVGTypeface.cpp", 1959 "tools/fonts/TestSVGTypeface.h", 1960 "tools/fonts/TestTypeface.cpp", 1961 "tools/fonts/TestTypeface.h", 1962 "tools/fonts/ToolUtilsFont.cpp", 1963 "tools/random_parse_path.cpp", 1964 "tools/random_parse_path.h", 1965 "tools/timer/TimeUtils.h", 1966 "tools/timer/Timer.cpp", 1967 "tools/timer/Timer.h", 1968 ] 1969 if (target_cpu != "wasm") { 1970 sources += [ "tools/CrashHandler.cpp" ] 1971 } 1972 libs = [] 1973 frameworks = [] 1974 if (is_ios) { 1975 sources += [ "tools/ios_utils.m" ] 1976 sources += [ "tools/ios_utils.h" ] 1977 if (skia_use_metal) { 1978 sources += [ "tools/AutoreleasePool.mm" ] 1979 } 1980 frameworks += [ "Foundation.framework" ] 1981 } else if (is_mac) { 1982 if (skia_use_metal) { 1983 sources += [ "tools/AutoreleasePool.mm" ] 1984 frameworks += [ "Foundation.framework" ] 1985 } 1986 } else if (is_win && !skia_enable_winuwp) { 1987 libs += [ "DbgHelp.lib" ] 1988 } 1989 1990 defines = [] 1991 if (skia_tools_require_resources) { 1992 defines += [ "SK_TOOLS_REQUIRE_RESOURCES" ] 1993 } 1994 deps = [ 1995 ":flags", 1996 "modules/svg", 1997 ] 1998 public_deps = [ ":gpu_tool_utils" ] 1999 } 2000 2001 test_lib("etc1") { 2002 sources = [ "third_party/etc1/etc1.cpp" ] 2003 } 2004 2005 import("gn/gm.gni") 2006 test_lib("gm") { 2007 sources = gm_sources 2008 if (skia_use_gl) { 2009 sources += gl_gm_sources 2010 } 2011 if (!skia_enable_skgpu_v1) { 2012 sources -= skgpu_v1_gm_sources 2013 } 2014 deps = [ 2015 ":etc1", 2016 ":flags", 2017 ":skia", 2018 ":tool_utils", 2019 "modules/particles", 2020 "modules/skottie", 2021 "modules/skottie:gm", 2022 "modules/skparagraph", 2023 "modules/skparagraph:gm", 2024 "modules/skshaper", 2025 ] 2026 if (is_skia_dev_build) { 2027 sources += [ "gm/fiddle.cpp" ] 2028 deps += [ ":skia.h" ] 2029 } 2030 public_deps = [ ":gpu_tool_utils" ] 2031 2032 if (skia_use_ffmpeg) { 2033 deps += [ "experimental/ffmpeg:video_decoder" ] 2034 sources += [ "gm/video_decoder.cpp" ] 2035 } 2036 } 2037 2038 test_lib("test") { 2039 sources = [ 2040 "tests/Test.cpp", 2041 "tests/Test.h", 2042 "tests/TestHarness.cpp", 2043 "tests/TestHarness.h", 2044 "tests/TestUtils.cpp", 2045 "tests/TestUtils.h", 2046 ] 2047 deps = [ 2048 ":flags", 2049 ":skia", 2050 ":tool_utils", 2051 ] 2052 public_deps = [ 2053 ":gpu_tool_utils", # Test.h #includes headers from this target. 2054 ] 2055 } 2056 2057 import("gn/tests.gni") 2058 test_lib("tests") { 2059 sources = tests_sources + pathops_tests_sources 2060 frameworks = [] 2061 if (skia_use_metal) { 2062 sources += metal_tests_sources 2063 cflags_objcc = [ "-fobjc-arc" ] 2064 frameworks += [ "MetalKit.framework" ] 2065 } 2066 if (skia_use_gl) { 2067 sources += gl_tests_sources 2068 } 2069 if (skia_enable_graphite) { 2070 sources += graphite_tests_sources 2071 if (skia_use_metal) { 2072 sources += graphite_metal_tests_sources 2073 } 2074 } 2075 if (!skia_enable_skgpu_v1) { 2076 sources -= skgpu_v1_tests_sources 2077 } 2078 deps = [ 2079 ":flags", 2080 ":fontmgr_android_tests", 2081 ":fontmgr_fontconfig_tests", 2082 ":fontmgr_mac_ct_tests", 2083 ":skia", 2084 ":test", 2085 ":tool_utils", 2086 "experimental/skrive:tests", 2087 "experimental/sktext:tests", 2088 "modules/skottie:tests", 2089 "modules/skparagraph:tests", 2090 "modules/sksg:tests", 2091 "modules/skshaper", 2092 "modules/svg:tests", 2093 "//third_party/libpng", 2094 "//third_party/libwebp", 2095 "//third_party/zlib", 2096 ] 2097 } 2098 2099 import("gn/bench.gni") 2100 test_lib("bench") { 2101 sources = bench_sources 2102 if (skia_enable_graphite) { 2103 sources += graphite_bench_sources 2104 } 2105 if (!skia_enable_skgpu_v1) { 2106 sources -= skgpu_v1_bench_sources 2107 } 2108 deps = [ 2109 ":flags", 2110 ":gm", 2111 ":gpu_tool_utils", 2112 ":skia", 2113 ":tool_utils", 2114 "modules/skparagraph:bench", 2115 "modules/skshaper", 2116 ] 2117 } 2118 2119 if (is_linux || is_mac) { 2120 if (skia_enable_skottie) { 2121 test_app("skottie_tool") { 2122 deps = [ "modules/skottie:tool" ] 2123 } 2124 } 2125 test_app("svg_tool") { 2126 deps = [ "modules/svg:tool" ] 2127 } 2128 } 2129 2130 import("gn/samples.gni") 2131 test_lib("samples") { 2132 sources = samples_sources 2133 if (!skia_enable_skgpu_v1) { 2134 sources -= skgpu_v1_samples_sources 2135 } 2136 public_deps = [ ":tool_utils" ] 2137 deps = [ 2138 ":flags", 2139 ":gpu_tool_utils", 2140 ":xml", 2141 "experimental/sktext:samples", 2142 "modules/audioplayer", 2143 "modules/skparagraph:samples", 2144 "modules/skshaper", 2145 "modules/svg", 2146 "//third_party/imgui", 2147 ] 2148 } 2149 test_lib("hash_and_encode") { 2150 sources = [ 2151 "tools/HashAndEncode.cpp", 2152 "tools/HashAndEncode.h", 2153 ] 2154 deps = [ 2155 ":flags", 2156 ":skia", 2157 "//third_party/libpng", 2158 ] 2159 } 2160 if (target_cpu != "wasm") { 2161 test_app("convert-to-nia") { 2162 sources = [ "tools/convert-to-nia.cpp" ] 2163 deps = [ ":skia" ] 2164 } 2165 test_app("imgcvt") { 2166 sources = [ "tools/imgcvt.cpp" ] 2167 deps = [ 2168 ":skcms", 2169 ":skia", 2170 ] 2171 } 2172 test_app("fm") { 2173 sources = [ 2174 "dm/DMGpuTestProcs.cpp", # blech 2175 "tools/fm/fm.cpp", 2176 ] 2177 deps = [ 2178 ":common_flags_aa", 2179 ":common_flags_fontmgr", 2180 ":common_flags_gpu", 2181 ":flags", 2182 ":gm", 2183 ":gpu_tool_utils", 2184 ":hash_and_encode", 2185 ":skia", 2186 ":tests", 2187 ":tool_utils", 2188 ":trace", 2189 "modules/skottie", 2190 "modules/skottie:utils", 2191 "modules/svg", 2192 ] 2193 } 2194 test_app("dm") { 2195 sources = [ 2196 "dm/DM.cpp", 2197 "dm/DMGpuTestProcs.cpp", 2198 "dm/DMJsonWriter.cpp", 2199 "dm/DMJsonWriter.h", 2200 "dm/DMSrcSink.cpp", 2201 "dm/DMSrcSink.h", 2202 ] 2203 deps = [ 2204 ":common_flags_aa", 2205 ":common_flags_config", 2206 ":common_flags_fontmgr", 2207 ":common_flags_gpu", 2208 ":common_flags_images", 2209 ":flags", 2210 ":gm", 2211 ":gpu_tool_utils", 2212 ":hash_and_encode", 2213 ":skia", 2214 ":tests", 2215 ":tool_utils", 2216 ":trace", 2217 "experimental/skrive", 2218 "modules/skottie", 2219 "modules/skottie:utils", 2220 "modules/svg", 2221 ] 2222 } 2223 test_app("sorttoy") { 2224 sources = [ 2225 "experimental/sorttoy/Cmds.cpp", 2226 "experimental/sorttoy/Cmds.h", 2227 "experimental/sorttoy/Fake.cpp", 2228 "experimental/sorttoy/Fake.h", 2229 "experimental/sorttoy/SortKey.h", 2230 "experimental/sorttoy/sorttoy.cpp", 2231 "experimental/sorttoy/sorttypes.h", 2232 ] 2233 deps = [ 2234 ":flags", 2235 ":skia", 2236 ":tool_utils", 2237 ] 2238 } 2239 2240 # optional separate library to dlopen when running CanvasStateTests. 2241 skia_shared_library("canvas_state_lib") { 2242 sources = [ 2243 "tests/CanvasStateHelpers.cpp", 2244 "tests/CanvasStateHelpers.h", 2245 ] 2246 deps = [ ":skia" ] 2247 } 2248 } 2249 2250 if (!is_win) { 2251 test_app("remote_demo") { 2252 sources = [ "tools/remote_demo.cpp" ] 2253 deps = [ ":skia" ] 2254 } 2255 } 2256 2257 if (!is_win) { 2258 test_app("blob_cache_sim") { 2259 sources = [ "tools/blob_cache_sim.cpp" ] 2260 deps = [ ":skia" ] 2261 } 2262 } 2263 2264 test_app("nanobench") { 2265 sources = [ "bench/nanobench.cpp" ] 2266 deps = [ 2267 ":bench", 2268 ":common_flags_aa", 2269 ":common_flags_config", 2270 ":common_flags_gpu", 2271 ":common_flags_images", 2272 ":flags", 2273 ":gm", 2274 ":gpu_tool_utils", 2275 ":skia", 2276 ":tool_utils", 2277 ":trace", 2278 "modules/skparagraph", 2279 "modules/skshaper", 2280 "modules/svg", 2281 ] 2282 } 2283 2284 test_app("skpinfo") { 2285 sources = [ "tools/skpinfo.cpp" ] 2286 configs = [ ":our_vulkan_headers" ] 2287 deps = [ 2288 ":flags", 2289 ":skia", 2290 ] 2291 } 2292 2293 if (skia_use_ffmpeg) { 2294 test_app("skottie2movie") { 2295 sources = [ "tools/skottie2movie.cpp" ] 2296 deps = [ 2297 ":flags", 2298 ":gpu_tool_utils", 2299 ":skia", 2300 "experimental/ffmpeg:video_encoder", 2301 "modules/skottie", 2302 "modules/skottie:utils", 2303 ] 2304 } 2305 } 2306 2307 test_app("skpbench") { 2308 sources = [ 2309 "bench/BigPath.cpp", 2310 "tools/skpbench/skpbench.cpp", 2311 ] 2312 deps = [ 2313 ":common_flags_config", 2314 ":common_flags_gpu", 2315 ":flags", 2316 ":gpu_tool_utils", 2317 ":skia", 2318 ":tool_utils", 2319 ] 2320 } 2321 2322 test_app("sktexttopdf") { 2323 sources = [ "tools/using_skia_and_harfbuzz.cpp" ] 2324 deps = [ 2325 ":skia", 2326 "modules/skshaper", 2327 ] 2328 } 2329 2330 test_app("create_test_font") { 2331 sources = [ "tools/fonts/create_test_font.cpp" ] 2332 deps = [ ":skia" ] 2333 assert_no_deps = [ 2334 # tool_utils requires the output of this app. 2335 ":tool_utils", 2336 ] 2337 } 2338 2339 if (skia_use_expat) { 2340 test_app("create_test_font_color") { 2341 sources = [ "tools/fonts/create_test_font_color.cpp" ] 2342 deps = [ 2343 ":flags", 2344 ":skia", 2345 ":tool_utils", 2346 ] 2347 } 2348 } 2349 2350 test_app("get_images_from_skps") { 2351 sources = [ "tools/get_images_from_skps.cpp" ] 2352 deps = [ 2353 ":flags", 2354 ":skia", 2355 ] 2356 } 2357 2358 if (!is_ios && target_cpu != "wasm" && !(is_win && target_cpu == "arm64")) { 2359 test_app("skiaserve") { 2360 sources = [ 2361 "tools/skiaserve/Request.cpp", 2362 "tools/skiaserve/Response.cpp", 2363 "tools/skiaserve/skiaserve.cpp", 2364 "tools/skiaserve/urlhandlers/BreakHandler.cpp", 2365 "tools/skiaserve/urlhandlers/ClipAlphaHandler.cpp", 2366 "tools/skiaserve/urlhandlers/CmdHandler.cpp", 2367 "tools/skiaserve/urlhandlers/ColorModeHandler.cpp", 2368 "tools/skiaserve/urlhandlers/DataHandler.cpp", 2369 "tools/skiaserve/urlhandlers/DownloadHandler.cpp", 2370 "tools/skiaserve/urlhandlers/EnableGPUHandler.cpp", 2371 "tools/skiaserve/urlhandlers/ImgHandler.cpp", 2372 "tools/skiaserve/urlhandlers/InfoHandler.cpp", 2373 "tools/skiaserve/urlhandlers/OpBoundsHandler.cpp", 2374 "tools/skiaserve/urlhandlers/OpsHandler.cpp", 2375 "tools/skiaserve/urlhandlers/OverdrawHandler.cpp", 2376 "tools/skiaserve/urlhandlers/PostHandler.cpp", 2377 "tools/skiaserve/urlhandlers/QuitHandler.cpp", 2378 "tools/skiaserve/urlhandlers/RootHandler.cpp", 2379 ] 2380 deps = [ 2381 ":flags", 2382 ":gpu_tool_utils", 2383 ":skia", 2384 ":tool_utils", 2385 "//third_party/libmicrohttpd", 2386 ] 2387 } 2388 } 2389 2390 test_app("fuzz") { 2391 sources = [ 2392 "fuzz/Fuzz.cpp", 2393 "fuzz/Fuzz.h", 2394 "fuzz/FuzzCanvas.cpp", 2395 "fuzz/FuzzCommon.cpp", 2396 "fuzz/FuzzCommon.h", 2397 "fuzz/FuzzCreateDDL.cpp", 2398 "fuzz/FuzzDDLThreading.cpp", 2399 "fuzz/FuzzDrawFunctions.cpp", 2400 "fuzz/FuzzEncoders.cpp", 2401 "fuzz/FuzzGradients.cpp", 2402 "fuzz/FuzzMain.cpp", 2403 "fuzz/FuzzParsePath.cpp", 2404 "fuzz/FuzzPathMeasure.cpp", 2405 "fuzz/FuzzPathop.cpp", 2406 "fuzz/FuzzPolyUtils.cpp", 2407 "fuzz/FuzzRegionOp.cpp", 2408 "fuzz/FuzzSkParagraph.cpp", 2409 "fuzz/FuzzTriangulation.cpp", 2410 "fuzz/oss_fuzz/FuzzAndroidCodec.cpp", 2411 "fuzz/oss_fuzz/FuzzAnimatedImage.cpp", 2412 "fuzz/oss_fuzz/FuzzImage.cpp", 2413 "fuzz/oss_fuzz/FuzzImageFilterDeserialize.cpp", 2414 "fuzz/oss_fuzz/FuzzIncrementalImage.cpp", 2415 "fuzz/oss_fuzz/FuzzJSON.cpp", 2416 "fuzz/oss_fuzz/FuzzPathDeserialize.cpp", 2417 "fuzz/oss_fuzz/FuzzRegionDeserialize.cpp", 2418 "fuzz/oss_fuzz/FuzzRegionSetPath.cpp", 2419 "fuzz/oss_fuzz/FuzzSKP.cpp", 2420 "fuzz/oss_fuzz/FuzzSKSL2GLSL.cpp", 2421 "fuzz/oss_fuzz/FuzzSKSL2Metal.cpp", 2422 "fuzz/oss_fuzz/FuzzSKSL2Pipeline.cpp", 2423 "fuzz/oss_fuzz/FuzzSKSL2SPIRV.cpp", 2424 "fuzz/oss_fuzz/FuzzSVG.cpp", 2425 "fuzz/oss_fuzz/FuzzSkDescriptorDeserialize.cpp", 2426 "fuzz/oss_fuzz/FuzzSkParagraph.cpp", 2427 "fuzz/oss_fuzz/FuzzSkRuntimeEffect.cpp", 2428 "fuzz/oss_fuzz/FuzzTextBlobDeserialize.cpp", 2429 "tools/UrlDataManager.cpp", 2430 "tools/debugger/DebugCanvas.cpp", 2431 "tools/debugger/DebugLayerManager.cpp", 2432 "tools/debugger/DrawCommand.cpp", 2433 "tools/debugger/JsonWriteBuffer.cpp", 2434 ] 2435 deps = [ 2436 ":flags", 2437 ":gpu_tool_utils", 2438 ":skia", 2439 "modules/skottie:fuzz", 2440 "modules/skparagraph", 2441 ] 2442 } 2443 2444 test_app("dump_record") { 2445 sources = [ "tools/dump_record.cpp" ] 2446 deps = [ 2447 ":flags", 2448 ":skia", 2449 ] 2450 } 2451 2452 test_app("skdiff") { 2453 sources = [ 2454 "tools/skdiff/skdiff.cpp", 2455 "tools/skdiff/skdiff_html.cpp", 2456 "tools/skdiff/skdiff_main.cpp", 2457 "tools/skdiff/skdiff_utils.cpp", 2458 ] 2459 deps = [ 2460 ":skia", 2461 ":tool_utils", 2462 ] 2463 } 2464 2465 test_app("skp_parser") { 2466 sources = [ "tools/skp_parser.cpp" ] 2467 deps = [ 2468 ":skia", 2469 ":tool_utils", 2470 ] 2471 } 2472 2473 if (!is_win) { 2474 source_set("skqp_lib") { # Not a skia_source_set 2475 check_includes = false 2476 testonly = true 2477 public_configs = [ ":skia_private" ] 2478 sources = [ 2479 "dm/DMGpuTestProcs.cpp", 2480 "tools/skqp/src/skqp.cpp", 2481 "tools/skqp/src/skqp.h", 2482 ] 2483 deps = [ 2484 ":gm", 2485 ":skia", 2486 ":tests", 2487 ":tool_utils", 2488 ] 2489 } 2490 test_app("skqp") { 2491 sources = [ "tools/skqp/src/skqp_main.cpp" ] 2492 include_dirs = [ "//" ] 2493 lib_dirs = [] 2494 deps = [ ":skqp_lib" ] 2495 } 2496 } 2497 if (is_fuchsia) { 2498 # Build a package repository for skqp on Fuchsia. 2499 group("skqp_repo") { 2500 testonly = true 2501 deps = [ "//build/fuchsia/skqp:skqp_repo" ] 2502 } 2503 } 2504 if (is_android) { 2505 shared_library("libskqp_app") { # Not a skia_shared_library 2506 configs += [ ":skia_private" ] 2507 testonly = true 2508 sources = [ "tools/skqp/src/jni_skqp.cpp" ] 2509 deps = [ 2510 ":skia", 2511 ":skqp_lib", 2512 ":tool_utils", 2513 ] 2514 libs = [ "android" ] 2515 } 2516 } 2517 if (is_android && skia_use_gl) { 2518 test_app("skottie_android") { 2519 is_shared_library = true 2520 2521 sources = [ "platform_tools/android/apps/skottie/skottielib/src/main/cpp/native-lib.cpp" ] 2522 libs = [] 2523 2524 deps = [ 2525 ":skia", 2526 "modules/skottie", 2527 ] 2528 } 2529 2530 test_app("androidkit") { 2531 is_shared_library = true 2532 2533 sources = [ 2534 "modules/androidkit/src/AndroidKit.cpp", 2535 "modules/androidkit/src/Canvas.cpp", 2536 "modules/androidkit/src/ColorFilters.cpp", 2537 "modules/androidkit/src/Font.cpp", 2538 "modules/androidkit/src/FontChainAdapter.cpp", 2539 "modules/androidkit/src/Gradients.cpp", 2540 "modules/androidkit/src/Image.cpp", 2541 "modules/androidkit/src/ImageFilter.cpp", 2542 "modules/androidkit/src/Matrix.cpp", 2543 "modules/androidkit/src/Paint.cpp", 2544 "modules/androidkit/src/Path.cpp", 2545 "modules/androidkit/src/PathBuilder.cpp", 2546 "modules/androidkit/src/RuntimeShaderBuilder.cpp", 2547 "modules/androidkit/src/Shader.cpp", 2548 "modules/androidkit/src/SkottieAnimation.cpp", 2549 "modules/androidkit/src/Surface.cpp", 2550 "modules/androidkit/src/Surface.h", 2551 "modules/androidkit/src/SurfaceThread.cpp", 2552 "modules/androidkit/src/SurfaceThread.h", 2553 "modules/androidkit/src/Text.cpp", 2554 "modules/androidkit/src/Utils.cpp", 2555 ] 2556 libs = [ 2557 "android", 2558 "jnigraphics", 2559 ] 2560 2561 deps = [ 2562 ":sk_app", 2563 ":skia", 2564 "experimental/sktext:sktext", 2565 "modules/skottie:skottie", 2566 ] 2567 } 2568 } 2569 2570 test_app("list_gms") { 2571 sources = [ "tools/list_gms.cpp" ] 2572 deps = [ 2573 ":gm", 2574 ":skia", 2575 ] 2576 } 2577 test_app("list_gpu_unit_tests") { 2578 sources = [ 2579 "dm/DMGpuTestProcs.cpp", 2580 "tools/list_gpu_unit_tests.cpp", 2581 ] 2582 deps = [ 2583 ":skia", 2584 ":tests", 2585 ] 2586 } 2587 2588 test_lib("sk_app") { 2589 public_deps = [ 2590 ":gpu_tool_utils", 2591 ":skia", 2592 ] 2593 sources = [ 2594 "tools/sk_app/Application.h", 2595 "tools/sk_app/CommandSet.cpp", 2596 "tools/sk_app/CommandSet.h", 2597 "tools/sk_app/DisplayParams.h", 2598 "tools/sk_app/RasterWindowContext.h", 2599 "tools/sk_app/Window.cpp", 2600 "tools/sk_app/Window.h", 2601 "tools/sk_app/WindowContext.cpp", 2602 "tools/sk_app/WindowContext.h", 2603 ] 2604 libs = [] 2605 frameworks = [] 2606 2607 if (is_android) { 2608 sources += [ 2609 "tools/sk_app/android/RasterWindowContext_android.cpp", 2610 "tools/sk_app/android/WindowContextFactory_android.h", 2611 "tools/sk_app/android/Window_android.cpp", 2612 "tools/sk_app/android/Window_android.h", 2613 "tools/sk_app/android/main_android.cpp", 2614 "tools/sk_app/android/surface_glue_android.cpp", 2615 "tools/sk_app/android/surface_glue_android.h", 2616 ] 2617 libs += [ "android" ] 2618 } else if (is_linux) { 2619 sources += [ 2620 "tools/sk_app/unix/RasterWindowContext_unix.cpp", 2621 "tools/sk_app/unix/WindowContextFactory_unix.h", 2622 "tools/sk_app/unix/Window_unix.cpp", 2623 "tools/sk_app/unix/Window_unix.h", 2624 "tools/sk_app/unix/keysym2ucs.c", 2625 "tools/sk_app/unix/keysym2ucs.h", 2626 "tools/sk_app/unix/main_unix.cpp", 2627 ] 2628 libs += [ 2629 "GL", # Used by raster window context, so cannot be behind skia_use_gl. 2630 "X11", 2631 ] 2632 } else if (is_win) { 2633 sources += [ 2634 "tools/sk_app/win/RasterWindowContext_win.cpp", 2635 "tools/sk_app/win/WindowContextFactory_win.h", 2636 "tools/sk_app/win/Window_win.cpp", 2637 "tools/sk_app/win/Window_win.h", 2638 "tools/sk_app/win/main_win.cpp", 2639 ] 2640 } else if (is_mac) { 2641 sources += [ 2642 "tools/sk_app/mac/WindowContextFactory_mac.h", 2643 "tools/sk_app/mac/Window_mac.h", 2644 "tools/sk_app/mac/Window_mac.mm", 2645 "tools/sk_app/mac/main_mac.mm", 2646 ] 2647 frameworks += [ 2648 "QuartzCore.framework", 2649 "Cocoa.framework", 2650 "Foundation.framework", 2651 ] 2652 } else if (is_ios) { 2653 sources += [ 2654 "tools/sk_app/ios/WindowContextFactory_ios.h", 2655 "tools/sk_app/ios/Window_ios.h", 2656 "tools/sk_app/ios/Window_ios.mm", 2657 "tools/sk_app/ios/main_ios.mm", 2658 ] 2659 frameworks += [ "QuartzCore.framework" ] 2660 } 2661 2662 if (skia_use_gl) { 2663 sources += [ "tools/sk_app/GLWindowContext.cpp" ] 2664 sources += [ "tools/sk_app/GLWindowContext.h" ] 2665 if (is_android) { 2666 sources += [ "tools/sk_app/android/GLWindowContext_android.cpp" ] 2667 } else if (is_linux) { 2668 sources += [ "tools/sk_app/unix/GLWindowContext_unix.cpp" ] 2669 } else if (is_win) { 2670 sources += [ "tools/sk_app/win/GLWindowContext_win.cpp" ] 2671 if (skia_use_angle) { 2672 sources += [ "tools/sk_app/win/ANGLEWindowContext_win.cpp" ] 2673 } 2674 } else if (is_mac) { 2675 sources += [ 2676 "tools/sk_app/mac/GLWindowContext_mac.mm", 2677 "tools/sk_app/mac/RasterWindowContext_mac.mm", 2678 ] 2679 } else if (is_ios) { 2680 sources += [ 2681 "tools/sk_app/ios/GLWindowContext_ios.mm", 2682 "tools/sk_app/ios/RasterWindowContext_ios.mm", 2683 ] 2684 } 2685 } 2686 2687 if (skia_use_vulkan) { 2688 sources += [ "tools/sk_app/VulkanWindowContext.cpp" ] 2689 sources += [ "tools/sk_app/VulkanWindowContext.h" ] 2690 if (is_android) { 2691 sources += [ "tools/sk_app/android/VulkanWindowContext_android.cpp" ] 2692 } else if (is_linux) { 2693 sources += [ "tools/sk_app/unix/VulkanWindowContext_unix.cpp" ] 2694 libs += [ "X11-xcb" ] 2695 } else if (is_win) { 2696 sources += [ "tools/sk_app/win/VulkanWindowContext_win.cpp" ] 2697 } 2698 } 2699 2700 if (skia_use_metal) { 2701 sources += [ "tools/sk_app/MetalWindowContext.mm" ] 2702 sources += [ "tools/sk_app/MetalWindowContext.h" ] 2703 if (skia_enable_graphite) { 2704 sources += [ "tools/sk_app/GraphiteMetalWindowContext.mm" ] 2705 sources += [ "tools/sk_app/GraphiteMetalWindowContext.h" ] 2706 } 2707 if (is_mac) { 2708 sources += [ "tools/sk_app/mac/MetalWindowContext_mac.mm" ] 2709 if (skia_enable_graphite) { 2710 sources += [ "tools/sk_app/mac/GraphiteMetalWindowContext_mac.mm" ] 2711 } 2712 } else if (is_ios) { 2713 sources += [ "tools/sk_app/ios/MetalWindowContext_ios.mm" ] 2714 } 2715 } 2716 2717 if (skia_use_direct3d) { 2718 sources += [ "tools/sk_app/win/D3D12WindowContext_win.cpp" ] 2719 } 2720 2721 if (skia_use_dawn) { 2722 sources += [ "tools/sk_app/DawnWindowContext.cpp" ] 2723 sources += [ "tools/sk_app/DawnWindowContext.h" ] 2724 if (is_linux) { 2725 if (dawn_enable_vulkan) { 2726 sources += [ "tools/sk_app/unix/DawnVulkanWindowContext_unix.cpp" ] 2727 defines = [ "VK_USE_PLATFORM_XCB_KHR" ] 2728 libs += [ "X11-xcb" ] 2729 } 2730 } else if (is_win) { 2731 if (dawn_enable_d3d12) { 2732 sources += [ "tools/sk_app/win/DawnD3D12WindowContext_win.cpp" ] 2733 } 2734 } else if (is_mac) { 2735 if (dawn_enable_metal) { 2736 sources += [ "tools/sk_app/mac/DawnMTLWindowContext_mac.mm" ] 2737 } 2738 } 2739 } 2740 2741 deps = [ ":tool_utils" ] 2742 if (is_android) { 2743 deps += [ "//third_party/native_app_glue" ] 2744 } 2745 if (skia_use_gl && skia_use_angle) { 2746 deps += [ "//third_party/angle2" ] 2747 } 2748 } 2749 2750 if (!skia_use_vulkan && (is_mac || is_linux || is_win)) { 2751 test_app("fiddle_examples") { 2752 sources = [ 2753 "tools/fiddle/all_examples.cpp", 2754 "tools/fiddle/examples.cpp", 2755 "tools/fiddle/examples.h", 2756 ] 2757 if (is_win) { 2758 cflags = [ 2759 "/wd4756", # Overflow in constant arithmetic 2760 "/wd4305", # truncation from 'double' to 'float' 2761 ] 2762 } 2763 deps = [ 2764 ":skia", 2765 ":skia.h", 2766 "modules/particles", 2767 "modules/skottie", 2768 "modules/skparagraph", 2769 "modules/skshaper", 2770 "modules/svg", 2771 ] 2772 } 2773 } 2774 2775 # sk_app can work without GL but viewer always runs raster through a GL window context. 2776 if (skia_use_gl) { 2777 test_app("viewer") { 2778 is_shared_library = is_android 2779 sources = [ 2780 "tools/viewer/AnimTimer.h", 2781 "tools/viewer/BisectSlide.cpp", 2782 "tools/viewer/BisectSlide.h", 2783 "tools/viewer/GMSlide.cpp", 2784 "tools/viewer/GMSlide.h", 2785 "tools/viewer/ImGuiLayer.cpp", 2786 "tools/viewer/ImGuiLayer.h", 2787 "tools/viewer/ImageSlide.cpp", 2788 "tools/viewer/ImageSlide.h", 2789 "tools/viewer/MSKPSlide.cpp", 2790 "tools/viewer/MSKPSlide.h", 2791 "tools/viewer/ParticlesSlide.cpp", 2792 "tools/viewer/ParticlesSlide.h", 2793 "tools/viewer/SKPSlide.cpp", 2794 "tools/viewer/SKPSlide.h", 2795 "tools/viewer/SampleSlide.cpp", 2796 "tools/viewer/SampleSlide.h", 2797 "tools/viewer/SkRiveSlide.cpp", 2798 "tools/viewer/SkRiveSlide.h", 2799 "tools/viewer/SkSLDebuggerSlide.cpp", 2800 "tools/viewer/SkSLDebuggerSlide.h", 2801 "tools/viewer/SkSLSlide.cpp", 2802 "tools/viewer/SkSLSlide.h", 2803 "tools/viewer/SkottieSlide.cpp", 2804 "tools/viewer/SkottieSlide.h", 2805 "tools/viewer/Slide.h", 2806 "tools/viewer/SlideDir.cpp", 2807 "tools/viewer/SlideDir.h", 2808 "tools/viewer/StatsLayer.cpp", 2809 "tools/viewer/StatsLayer.h", 2810 "tools/viewer/SvgSlide.cpp", 2811 "tools/viewer/SvgSlide.h", 2812 "tools/viewer/TouchGesture.cpp", 2813 "tools/viewer/TouchGesture.h", 2814 "tools/viewer/Viewer.cpp", 2815 "tools/viewer/Viewer.h", 2816 ] 2817 libs = [] 2818 2819 deps = [ 2820 ":common_flags_fontmgr", 2821 ":common_flags_gpu", 2822 ":flags", 2823 ":gm", 2824 ":gpu_tool_utils", 2825 ":samples", 2826 ":sk_app", 2827 ":skia", 2828 ":tool_utils", 2829 ":trace", 2830 "experimental/skrive", 2831 "experimental/sktext", 2832 "modules/audioplayer", 2833 "modules/particles", 2834 "modules/skottie", 2835 "modules/skottie:utils", 2836 "modules/sksg:samples", 2837 "modules/svg", 2838 "//third_party/imgui", 2839 ] 2840 if (skia_use_vulkan) { 2841 deps += [ 2842 "//third_party/externals/spirv-tools:spvtools", 2843 2844 #spvtools depends on this but doesn't deps it in. 2845 "//third_party/externals/spirv-tools:spvtools_val", 2846 ] 2847 } 2848 } 2849 } 2850 2851 if (skia_use_gl && !skia_use_angle && (is_linux || is_win || is_mac)) { 2852 test_app("HelloWorld") { 2853 sources = [ "example/HelloWorld.cpp" ] 2854 libs = [] 2855 2856 deps = [ 2857 ":flags", 2858 ":gpu_tool_utils", 2859 ":sk_app", 2860 ":skia", 2861 ":tool_utils", 2862 ] 2863 } 2864 } 2865 2866 if (skia_qt_path != "" && (is_win || is_linux || is_mac)) { 2867 action_foreach("generate_mocs") { 2868 script = "gn/call.py" 2869 sources = [ "tools/mdbviz/MainWindow.h" ] 2870 outputs = [ "$target_gen_dir/mdbviz/{{source_name_part}}_moc.cpp" ] 2871 args = [ 2872 "$skia_qt_path" + "/bin/moc", 2873 "{{source}}", 2874 "-o", 2875 "gen/mdbviz/{{source_name_part}}_moc.cpp", 2876 ] 2877 } 2878 action_foreach("generate_resources") { 2879 script = "gn/call.py" 2880 sources = [ "tools/mdbviz/resources.qrc" ] 2881 outputs = [ "$target_gen_dir/mdbviz/{{source_name_part}}_res.cpp" ] 2882 args = [ 2883 "$skia_qt_path" + "/bin/rcc", 2884 "{{source}}", 2885 "-o", 2886 "gen/mdbviz/{{source_name_part}}_res.cpp", 2887 ] 2888 } 2889 test_app("mdbviz") { 2890 if (is_win) { 2891 # on Windows we need to disable some exception handling warnings due to the Qt headers 2892 cflags = [ "/Wv:18" ] # 18 -> VS2013, 19 -> VS2015, 1910 -> VS2017 2893 } 2894 sources = [ 2895 "tools/UrlDataManager.cpp", 2896 "tools/debugger/DebugCanvas.cpp", 2897 "tools/debugger/DebugLayerManager.cpp", 2898 "tools/debugger/DrawCommand.cpp", 2899 "tools/debugger/JsonWriteBuffer.cpp", 2900 "tools/mdbviz/MainWindow.cpp", 2901 "tools/mdbviz/Model.cpp", 2902 "tools/mdbviz/main.cpp", 2903 2904 # generated files 2905 "$target_gen_dir/mdbviz/MainWindow_moc.cpp", 2906 "$target_gen_dir/mdbviz/resources_res.cpp", 2907 ] 2908 lib_dirs = [ "$skia_qt_path/lib" ] 2909 libs = [ 2910 "Qt5Core.lib", 2911 "Qt5Gui.lib", 2912 "Qt5Widgets.lib", 2913 ] 2914 include_dirs = [ 2915 "$skia_qt_path/include", 2916 "$skia_qt_path/include/QtCore", 2917 "$skia_qt_path/include/QtWidgets", 2918 ] 2919 deps = [ 2920 ":generate_mocs", 2921 ":generate_resources", 2922 ":skia", 2923 ] 2924 } 2925 } 2926 2927 if (is_android && defined(ndk) && ndk != "") { 2928 copy("gdbserver") { 2929 sources = [ "$ndk/$ndk_gdbserver" ] 2930 outputs = [ "$root_out_dir/gdbserver" ] 2931 } 2932 } 2933 2934 skia_executable("cpu_modules") { 2935 sources = [ "tools/cpu_modules.cpp" ] 2936 deps = [ 2937 ":skia", 2938 "modules/particles", 2939 ] 2940 } 2941 2942 if (skia_use_icu && skia_use_harfbuzz) { 2943 test_app("editor") { 2944 is_shared_library = is_android 2945 deps = [ "modules/skplaintexteditor:editor_app" ] 2946 } 2947 test_app("text_editor") { 2948 is_shared_library = is_android 2949 deps = [ "experimental/sktext:text_editor" ] 2950 } 2951 } 2952 2953 skia_executable("image_diff_metric") { 2954 sources = [ "tools/image_diff_metric.cpp" ] 2955 deps = [ ":skia" ] 2956 } 2957 2958 group("modules_testonly") { 2959 testonly = true 2960 deps = [] 2961 if (is_wasm) { 2962 deps += [ "modules/canvaskit:viewer_wasm" ] 2963 } 2964 } 2965 2966 if (skia_build_fuzzers) { 2967 template("libfuzzer_app") { 2968 skia_executable(target_name) { 2969 output_dir = root_build_dir 2970 check_includes = false 2971 forward_variables_from(invoker, "*", [ "is_shared_library" ]) 2972 if (!defined(configs)) { 2973 configs = [] 2974 } 2975 configs += [ ":skia_private" ] 2976 sources += [ 2977 "fuzz/Fuzz.cpp", 2978 "fuzz/FuzzCommon.cpp", 2979 ] 2980 deps += [ 2981 ":flags", 2982 ":gpu_tool_utils", 2983 ":skia", 2984 ] 2985 defines = [ "SK_BUILD_FOR_LIBFUZZER" ] 2986 if (skia_use_libfuzzer_defaults) { 2987 cflags = [ "-fsanitize=fuzzer" ] 2988 ldflags = [ "-fsanitize=fuzzer" ] 2989 } 2990 testonly = true 2991 } 2992 } 2993 2994 libfuzzer_app("region_deserialize") { 2995 sources = [ "fuzz/oss_fuzz/FuzzRegionDeserialize.cpp" ] 2996 deps = [] 2997 } 2998 2999 libfuzzer_app("image_filter_deserialize") { 3000 include_dirs = [ 3001 "tools", 3002 "tools/fonts", 3003 ] 3004 sources = [ 3005 "fuzz/oss_fuzz/FuzzImageFilterDeserialize.cpp", 3006 "tools/Resources.cpp", 3007 "tools/fonts/TestFontMgr.cpp", 3008 "tools/fonts/TestSVGTypeface.cpp", 3009 "tools/fonts/TestTypeface.cpp", 3010 ] 3011 deps = [ "modules/svg" ] 3012 } 3013 3014 libfuzzer_app("region_set_path") { 3015 sources = [ "fuzz/oss_fuzz/FuzzRegionSetPath.cpp" ] 3016 deps = [] 3017 } 3018 3019 libfuzzer_app("textblob_deserialize") { 3020 include_dirs = [ 3021 "tools", 3022 "tools/fonts", 3023 ] 3024 sources = [ 3025 "fuzz/oss_fuzz/FuzzTextBlobDeserialize.cpp", 3026 "tools/Resources.cpp", 3027 "tools/fonts/TestFontMgr.cpp", 3028 "tools/fonts/TestSVGTypeface.cpp", 3029 "tools/fonts/TestTypeface.cpp", 3030 ] 3031 deps = [ "modules/svg" ] 3032 } 3033 3034 libfuzzer_app("path_deserialize") { 3035 sources = [ "fuzz/oss_fuzz/FuzzPathDeserialize.cpp" ] 3036 deps = [] 3037 } 3038 3039 libfuzzer_app("image_decode") { 3040 sources = [ "fuzz/oss_fuzz/FuzzImage.cpp" ] 3041 deps = [] 3042 } 3043 3044 libfuzzer_app("animated_image_decode") { 3045 sources = [ "fuzz/oss_fuzz/FuzzAnimatedImage.cpp" ] 3046 deps = [] 3047 } 3048 3049 libfuzzer_app("api_create_ddl") { 3050 include_dirs = [ 3051 "include", 3052 "include/gpu", 3053 ] 3054 sources = [ 3055 "fuzz/FuzzCreateDDL.cpp", 3056 "fuzz/oss_fuzz/FuzzAPICreateDDL.cpp", 3057 "tools/Resources.cpp", 3058 "tools/UrlDataManager.cpp", 3059 "tools/debugger/DebugCanvas.cpp", 3060 "tools/debugger/DebugLayerManager.cpp", 3061 "tools/debugger/DrawCommand.cpp", 3062 "tools/debugger/JsonWriteBuffer.cpp", 3063 "tools/fonts/TestFontMgr.cpp", 3064 "tools/fonts/TestSVGTypeface.cpp", 3065 "tools/fonts/TestTypeface.cpp", 3066 ] 3067 deps = [ 3068 "modules/svg", 3069 "//third_party/libpng", 3070 ] 3071 } 3072 3073 libfuzzer_app("api_draw_functions") { 3074 sources = [ 3075 "fuzz/FuzzDrawFunctions.cpp", 3076 "fuzz/oss_fuzz/FuzzDrawFunctions.cpp", 3077 ] 3078 deps = [] 3079 } 3080 3081 libfuzzer_app("api_ddl_threading") { 3082 sources = [ 3083 "fuzz/FuzzDDLThreading.cpp", 3084 "fuzz/oss_fuzz/FuzzDDLThreading.cpp", 3085 ] 3086 deps = [] 3087 } 3088 3089 libfuzzer_app("api_gradients") { 3090 sources = [ 3091 "fuzz/FuzzGradients.cpp", 3092 "fuzz/oss_fuzz/FuzzGradients.cpp", 3093 ] 3094 deps = [] 3095 } 3096 3097 libfuzzer_app("api_image_filter") { 3098 include_dirs = [ 3099 "tools", 3100 "tools/debugger", 3101 ] 3102 sources = [ 3103 "fuzz/FuzzCanvas.cpp", 3104 "fuzz/oss_fuzz/FuzzAPIImageFilter.cpp", 3105 "tools/UrlDataManager.cpp", 3106 "tools/debugger/DebugCanvas.cpp", 3107 "tools/debugger/DebugLayerManager.cpp", 3108 "tools/debugger/DrawCommand.cpp", 3109 "tools/debugger/JsonWriteBuffer.cpp", 3110 ] 3111 deps = [ "//third_party/libpng" ] 3112 } 3113 3114 libfuzzer_app("api_path_measure") { 3115 sources = [ 3116 "fuzz/FuzzPathMeasure.cpp", 3117 "fuzz/oss_fuzz/FuzzPathMeasure.cpp", 3118 ] 3119 deps = [] 3120 } 3121 3122 libfuzzer_app("api_pathop") { 3123 sources = [ 3124 "fuzz/FuzzPathop.cpp", 3125 "fuzz/oss_fuzz/FuzzPathop.cpp", 3126 ] 3127 deps = [] 3128 } 3129 3130 libfuzzer_app("api_triangulation") { 3131 sources = [ 3132 "fuzz/FuzzTriangulation.cpp", 3133 "fuzz/oss_fuzz/FuzzTriangulation.cpp", 3134 ] 3135 deps = [] 3136 } 3137 3138 libfuzzer_app("api_raster_n32_canvas") { 3139 include_dirs = [ 3140 "tools", 3141 "tools/debugger", 3142 "tools/fonts", 3143 ] 3144 sources = [ 3145 "fuzz/FuzzCanvas.cpp", 3146 "fuzz/oss_fuzz/FuzzRasterN32Canvas.cpp", 3147 "tools/Resources.cpp", 3148 "tools/UrlDataManager.cpp", 3149 "tools/debugger/DebugCanvas.cpp", 3150 "tools/debugger/DebugLayerManager.cpp", 3151 "tools/debugger/DrawCommand.cpp", 3152 "tools/debugger/JsonWriteBuffer.cpp", 3153 "tools/fonts/TestFontMgr.cpp", 3154 "tools/fonts/TestSVGTypeface.cpp", 3155 "tools/fonts/TestTypeface.cpp", 3156 ] 3157 deps = [ 3158 "modules/svg", 3159 "//third_party/libpng", 3160 ] 3161 } 3162 3163 libfuzzer_app("api_regionop") { 3164 sources = [ 3165 "fuzz/FuzzRegionOp.cpp", 3166 "fuzz/oss_fuzz/FuzzRegionOp.cpp", 3167 ] 3168 deps = [] 3169 } 3170 3171 if (skia_enable_gpu) { 3172 libfuzzer_app("api_mock_gpu_canvas") { 3173 include_dirs = [ 3174 "tools", 3175 "tools/debugger", 3176 "tools/fonts", 3177 ] 3178 sources = [ 3179 "fuzz/FuzzCanvas.cpp", 3180 "fuzz/oss_fuzz/FuzzMockGPUCanvas.cpp", 3181 "tools/LsanSuppressions.cpp", 3182 "tools/Resources.cpp", 3183 "tools/UrlDataManager.cpp", 3184 "tools/debugger/DebugCanvas.cpp", 3185 "tools/debugger/DebugLayerManager.cpp", 3186 "tools/debugger/DrawCommand.cpp", 3187 "tools/debugger/JsonWriteBuffer.cpp", 3188 "tools/fonts/TestFontMgr.cpp", 3189 "tools/fonts/TestSVGTypeface.cpp", 3190 "tools/fonts/TestTypeface.cpp", 3191 ] 3192 deps = [ 3193 "modules/svg", 3194 "//third_party/libpng", 3195 ] 3196 } 3197 } 3198 3199 libfuzzer_app("api_null_canvas") { 3200 include_dirs = [ 3201 "tools", 3202 "tools/debugger", 3203 "tools/fonts", 3204 ] 3205 sources = [ 3206 "fuzz/FuzzCanvas.cpp", 3207 "fuzz/oss_fuzz/FuzzNullCanvas.cpp", 3208 "tools/Resources.cpp", 3209 "tools/UrlDataManager.cpp", 3210 "tools/debugger/DebugCanvas.cpp", 3211 "tools/debugger/DebugLayerManager.cpp", 3212 "tools/debugger/DrawCommand.cpp", 3213 "tools/debugger/JsonWriteBuffer.cpp", 3214 "tools/fonts/TestFontMgr.cpp", 3215 "tools/fonts/TestSVGTypeface.cpp", 3216 "tools/fonts/TestTypeface.cpp", 3217 ] 3218 deps = [ 3219 "modules/svg", 3220 "//third_party/libpng", 3221 ] 3222 } 3223 3224 libfuzzer_app("api_skparagraph") { 3225 sources = [ 3226 "fuzz/FuzzSkParagraph.cpp", 3227 "fuzz/oss_fuzz/FuzzSkParagraph.cpp", 3228 "tools/Resources.cpp", 3229 ] 3230 deps = [ "modules/skparagraph" ] 3231 } 3232 3233 libfuzzer_app("api_svg_canvas") { 3234 include_dirs = [ 3235 "include", 3236 "include/svg", 3237 ] 3238 sources = [ 3239 "fuzz/FuzzCanvas.cpp", 3240 "fuzz/oss_fuzz/FuzzAPISVGCanvas.cpp", 3241 "tools/Resources.cpp", 3242 "tools/UrlDataManager.cpp", 3243 "tools/debugger/DebugCanvas.cpp", 3244 "tools/debugger/DebugLayerManager.cpp", 3245 "tools/debugger/DrawCommand.cpp", 3246 "tools/debugger/JsonWriteBuffer.cpp", 3247 "tools/fonts/TestFontMgr.cpp", 3248 "tools/fonts/TestSVGTypeface.cpp", 3249 "tools/fonts/TestTypeface.cpp", 3250 ] 3251 deps = [ 3252 "modules/svg", 3253 "//third_party/libpng", 3254 ] 3255 } 3256 3257 libfuzzer_app("png_encoder") { 3258 sources = [ 3259 "fuzz/FuzzEncoders.cpp", 3260 "fuzz/oss_fuzz/FuzzPNGEncoder.cpp", 3261 ] 3262 deps = [] 3263 } 3264 3265 libfuzzer_app("jpeg_encoder") { 3266 sources = [ 3267 "fuzz/FuzzEncoders.cpp", 3268 "fuzz/oss_fuzz/FuzzJPEGEncoder.cpp", 3269 ] 3270 deps = [] 3271 } 3272 3273 libfuzzer_app("webp_encoder") { 3274 sources = [ 3275 "fuzz/FuzzEncoders.cpp", 3276 "fuzz/oss_fuzz/FuzzWEBPEncoder.cpp", 3277 ] 3278 deps = [] 3279 } 3280 3281 libfuzzer_app("skottie_json") { 3282 sources = [ 3283 "modules/skottie/fuzz/FuzzSkottieJSON.cpp", 3284 "tools/Resources.cpp", 3285 "tools/fonts/TestFontMgr.cpp", 3286 "tools/fonts/TestSVGTypeface.cpp", 3287 "tools/fonts/TestTypeface.cpp", 3288 ] 3289 deps = [ 3290 "modules/skottie:skottie", 3291 "modules/svg", 3292 ] 3293 } 3294 3295 libfuzzer_app("skjson") { 3296 sources = [ "fuzz/oss_fuzz/FuzzJSON.cpp" ] 3297 deps = [] 3298 } 3299 3300 libfuzzer_app("api_polyutils") { 3301 sources = [ 3302 "fuzz/FuzzPolyUtils.cpp", 3303 "fuzz/oss_fuzz/FuzzPolyUtils.cpp", 3304 ] 3305 deps = [ ":skia" ] 3306 } 3307 3308 libfuzzer_app("android_codec") { 3309 sources = [ "fuzz/oss_fuzz/FuzzAndroidCodec.cpp" ] 3310 deps = [] 3311 } 3312 3313 libfuzzer_app("image_decode_incremental") { 3314 sources = [ "fuzz/oss_fuzz/FuzzIncrementalImage.cpp" ] 3315 deps = [] 3316 } 3317 3318 libfuzzer_app("sksl2glsl") { 3319 sources = [ "fuzz/oss_fuzz/FuzzSKSL2GLSL.cpp" ] 3320 deps = [] 3321 } 3322 3323 libfuzzer_app("sksl2spirv") { 3324 sources = [ "fuzz/oss_fuzz/FuzzSKSL2SPIRV.cpp" ] 3325 deps = [] 3326 } 3327 3328 libfuzzer_app("sksl2metal") { 3329 sources = [ "fuzz/oss_fuzz/FuzzSKSL2Metal.cpp" ] 3330 deps = [] 3331 } 3332 3333 libfuzzer_app("sksl2pipeline") { 3334 sources = [ "fuzz/oss_fuzz/FuzzSKSL2Pipeline.cpp" ] 3335 deps = [] 3336 } 3337 3338 libfuzzer_app("skdescriptor_deserialize") { 3339 sources = [ "fuzz/oss_fuzz/FuzzSkDescriptorDeserialize.cpp" ] 3340 deps = [] 3341 } 3342 3343 libfuzzer_app("svg_dom") { 3344 sources = [ "fuzz/oss_fuzz/FuzzSVG.cpp" ] 3345 deps = [ "modules/svg" ] 3346 } 3347 3348 libfuzzer_app("skruntimeeffect") { 3349 sources = [ "fuzz/oss_fuzz/FuzzSkRuntimeEffect.cpp" ] 3350 deps = [] 3351 } 3352 3353 libfuzzer_app("skp") { 3354 sources = [ "fuzz/oss_fuzz/FuzzSKP.cpp" ] 3355 deps = [] 3356 } 3357 } 3358} 3359 3360if (is_ios && skia_use_metal && skia_enable_gpu && 3361 !skia_enable_flutter_defines) { 3362 group("minimal_ios_mtl_skia_app") { 3363 deps = [ "experimental/minimal_ios_mtl_skia_app" ] 3364 } 3365} 3366 3367if (is_ios && skia_enable_skottie && !skia_enable_flutter_defines) { 3368 group("skottie_ios") { 3369 deps = [ "tools/skottie_ios_app" ] 3370 } 3371} 3372 3373skia_executable("skia_c_api_example") { 3374 sources = [ "experimental/c-api-example/skia-c-example.c" ] 3375 include_dirs = [ "." ] 3376 deps = [ ":skia" ] 3377} 3378