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") 10 11if (is_fuchsia) { 12 import("//build/fuchsia/sdk.gni") 13 import("//build/vulkan/config.gni") 14} 15 16declare_args() { 17 skia_enable_flutter_defines = false 18} 19 20declare_args() { 21 skia_use_angle = false 22 skia_use_egl = false 23 skia_use_expat = true 24 skia_use_experimental_xform = false 25 skia_use_ffmpeg = false 26 skia_use_fontconfig = is_linux 27 skia_use_fonthost_mac = is_mac 28 skia_use_freetype = is_android || is_fuchsia || is_linux 29 skia_use_fixed_gamma_text = is_android 30 skia_use_libjpeg_turbo = true 31 skia_use_libpng = true 32 skia_use_libwebp = !is_fuchsia 33 skia_use_lua = is_skia_dev_build && !is_ios 34 skia_use_opencl = false 35 skia_use_piex = !is_win 36 skia_use_wuffs = false 37 skia_use_zlib = true 38 skia_use_metal = false 39 skia_use_dawn = false 40 skia_use_libheif = is_skia_dev_build 41 skia_use_x11 = is_linux 42 skia_use_xps = true 43} 44 45declare_args() { 46 skia_android_serial = "" 47 skia_enable_ccpr = true 48 skia_enable_nvpr = !skia_enable_flutter_defines 49 skia_enable_discrete_gpu = true 50 skia_enable_pdf = true 51 skia_enable_spirv_validation = is_skia_dev_build && is_debug && !skia_use_dawn 52 skia_enable_sksl_interpreter = is_skia_dev_build 53 skia_enable_skvm_jit = 54 is_skia_dev_build && ((target_cpu == "x64" && (is_linux || is_mac)) || 55 (target_cpu == "arm64" && is_android)) 56 skia_enable_vulkan_debug_layers = is_skia_dev_build && is_debug 57 skia_qt_path = getenv("QT_PATH") 58 skia_compile_processors = false 59 skia_generate_workarounds = false 60 skia_lex = false 61 62 skia_skqp_global_error_tolerance = 0 63 64 skia_llvm_path = "" 65 skia_llvm_lib = "LLVM" 66 67 skia_tools_require_resources = false 68 skia_include_multiframe_procs = false 69} 70 71if (skia_use_dawn) { 72 import("third_party/externals/dawn/scripts/dawn_features.gni") 73} 74 75declare_args() { 76 skia_use_dng_sdk = !is_fuchsia && skia_use_libjpeg_turbo && skia_use_zlib 77 skia_use_sfntly = skia_use_icu 78 skia_enable_atlas_text = is_skia_dev_build && skia_enable_gpu 79 skia_enable_fontmgr_empty = false 80 skia_enable_fontmgr_custom = 81 is_linux && skia_use_freetype && !skia_use_fontconfig 82 skia_enable_fontmgr_custom_empty = is_fuchsia && skia_use_freetype 83 skia_enable_fontmgr_android = skia_use_expat && skia_use_freetype 84 skia_enable_fontmgr_fuchsia = is_fuchsia 85 skia_enable_fontmgr_win = is_win 86 skia_enable_fontmgr_win_gdi = is_win 87 88 if (is_mac) { 89 skia_gl_standard = "gl" 90 } else if (is_ios) { 91 skia_gl_standard = "gles" 92 } else { 93 skia_gl_standard = "" 94 } 95 96 if (is_android) { 97 skia_use_vulkan = defined(ndk_api) && ndk_api >= 24 98 } else if (is_fuchsia) { 99 skia_use_vulkan = fuchsia_use_vulkan 100 } else { 101 skia_use_vulkan = defined(skia_moltenvk_path) && skia_moltenvk_path != "" 102 } 103 104 if (is_ios) { 105 skia_ios_identity = ".*Google.*" 106 skia_ios_profile = "Google Development" 107 } 108} 109 110if (defined(skia_settings)) { 111 import(skia_settings) 112} 113 114# Skia public API, generally provided by :skia. 115config("skia_public") { 116 include_dirs = [ "." ] 117 118 defines = [] 119 if (is_component_build) { 120 defines += [ "SKIA_DLL" ] 121 } 122 if (is_fuchsia || is_linux) { 123 defines += [ "SK_R32_SHIFT=16" ] 124 } 125 if (skia_enable_flutter_defines) { 126 defines += flutter_defines 127 } 128 if (!skia_enable_gpu) { 129 defines += [ "SK_SUPPORT_GPU=0" ] 130 } 131 if (skia_enable_atlas_text) { 132 defines += [ "SK_SUPPORT_ATLAS_TEXT=1" ] 133 } 134 if (is_fuchsia) { 135 defines += fuchsia_defines 136 } 137 if (skia_gl_standard == "gles") { 138 defines += [ "SK_ASSUME_GL_ES=1" ] 139 } else if (skia_gl_standard == "gl") { 140 defines += [ "SK_ASSUME_GL=1" ] 141 } else if (skia_gl_standard == "webgl") { 142 defines += [ "SK_ASSUME_WEBGL=1" ] 143 } 144} 145 146# Skia internal APIs, used by Skia itself and a few test tools. 147config("skia_private") { 148 visibility = [ ":*" ] 149 150 defines = [ "SK_GAMMA_APPLY_TO_A8" ] 151 if (skia_use_fixed_gamma_text) { 152 defines += [ 153 "SK_GAMMA_EXPONENT=1.4", 154 "SK_GAMMA_CONTRAST=0.0", 155 ] 156 } 157 if (is_skia_dev_build) { 158 defines += [ 159 "SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=1", 160 "GR_TEST_UTILS=1", 161 ] 162 } 163 libs = [] 164 lib_dirs = [] 165 if (skia_use_angle) { 166 defines += [ "SK_ANGLE" ] 167 } 168 if (skia_llvm_path != "") { 169 defines += [ "SK_LLVM_AVAILABLE" ] 170 include_dirs += [ "$skia_llvm_path/include" ] 171 libs += [ skia_llvm_lib ] 172 lib_dirs += [ "$skia_llvm_path/lib/" ] 173 } 174} 175 176# Any code that's linked into Skia-the-library should use this config via += skia_library_configs. 177config("skia_library") { 178 visibility = [ ":*" ] 179 defines = [ "SKIA_IMPLEMENTATION=1" ] 180} 181 182skia_library_configs = [ 183 ":skia_public", 184 ":skia_private", 185 ":skia_library", 186] 187 188# Use for CPU-specific Skia code that needs particular compiler flags. 189template("opts") { 190 visibility = [ ":*" ] 191 if (invoker.enabled) { 192 source_set(target_name) { 193 check_includes = false 194 forward_variables_from(invoker, "*") 195 configs += skia_library_configs 196 } 197 } else { 198 # If not enabled, a phony empty target that swallows all otherwise unused variables. 199 source_set(target_name) { 200 check_includes = false 201 forward_variables_from(invoker, 202 "*", 203 [ 204 "sources", 205 "cflags", 206 ]) 207 } 208 } 209} 210 211is_x86 = current_cpu == "x64" || current_cpu == "x86" 212 213opts("none") { 214 enabled = !is_x86 && current_cpu != "arm" && current_cpu != "arm64" 215 sources = skia_opts.none_sources 216 cflags = [] 217} 218 219opts("armv7") { 220 enabled = current_cpu == "arm" 221 sources = skia_opts.armv7_sources + skia_opts.neon_sources 222 cflags = [] 223} 224 225opts("arm64") { 226 enabled = current_cpu == "arm64" 227 sources = skia_opts.arm64_sources 228 cflags = [] 229} 230 231opts("crc32") { 232 enabled = current_cpu == "arm64" 233 sources = skia_opts.crc32_sources 234 cflags = [ "-march=armv8-a+crc" ] 235} 236 237opts("sse2") { 238 enabled = is_x86 239 sources = skia_opts.sse2_sources 240 if (!is_clang && is_win) { 241 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE2" ] 242 } else { 243 cflags = [ "-msse2" ] 244 } 245} 246 247opts("ssse3") { 248 enabled = is_x86 249 sources = skia_opts.ssse3_sources 250 if (!is_clang && is_win) { 251 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSSE3" ] 252 } else { 253 cflags = [ "-mssse3" ] 254 } 255} 256 257opts("sse41") { 258 enabled = is_x86 259 sources = skia_opts.sse41_sources 260 if (!is_clang && is_win) { 261 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE41" ] 262 } else { 263 cflags = [ "-msse4.1" ] 264 } 265} 266 267opts("sse42") { 268 enabled = is_x86 269 sources = skia_opts.sse42_sources 270 if (!is_clang && is_win) { 271 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE42" ] 272 } else { 273 cflags = [ "-msse4.2" ] 274 } 275} 276 277opts("avx") { 278 enabled = is_x86 279 sources = skia_opts.avx_sources 280 if (is_win) { 281 cflags = [ "/arch:AVX" ] 282 } else { 283 cflags = [ "-mavx" ] 284 } 285} 286 287opts("hsw") { 288 enabled = is_x86 289 sources = skia_opts.hsw_sources 290 if (is_win) { 291 cflags = [ "/arch:AVX2" ] 292 } else { 293 if (host_cpu != "arm64") { 294 cflags = [ "-march=haswell" ] 295 } 296 } 297} 298 299# Any feature of Skia that requires third-party code should be optional and use this template. 300template("optional") { 301 visibility = [ ":*" ] 302 if (invoker.enabled) { 303 config(target_name + "_public") { 304 if (defined(invoker.public_defines)) { 305 defines = invoker.public_defines 306 } 307 if (defined(invoker.public_configs)) { 308 configs = invoker.public_configs 309 } 310 } 311 source_set(target_name) { 312 check_includes = false 313 forward_variables_from(invoker, 314 "*", 315 [ 316 "public_defines", 317 "sources_when_disabled", 318 "configs_to_remove", 319 ]) 320 all_dependent_configs = [ ":" + target_name + "_public" ] 321 configs += skia_library_configs 322 if (defined(invoker.configs_to_remove)) { 323 configs -= invoker.configs_to_remove 324 } 325 } 326 } else { 327 source_set(target_name) { 328 forward_variables_from(invoker, 329 "*", 330 [ 331 "public_defines", 332 "public_deps", 333 "deps", 334 "libs", 335 "sources", 336 "sources_when_disabled", 337 "configs_to_remove", 338 ]) 339 if (defined(invoker.sources_when_disabled)) { 340 sources = invoker.sources_when_disabled 341 } 342 configs += skia_library_configs 343 } 344 } 345} 346 347optional("fontmgr_android") { 348 enabled = skia_enable_fontmgr_android 349 350 deps = [ 351 ":typeface_freetype", 352 "//third_party/expat", 353 ] 354 sources = [ 355 "src/ports/SkFontMgr_android.cpp", 356 "src/ports/SkFontMgr_android_factory.cpp", 357 "src/ports/SkFontMgr_android_parser.cpp", 358 ] 359} 360 361optional("fontmgr_custom") { 362 enabled = skia_enable_fontmgr_custom 363 364 deps = [ ":typeface_freetype" ] 365 sources = [ 366 "src/ports/SkFontMgr_custom.cpp", 367 "src/ports/SkFontMgr_custom.h", 368 "src/ports/SkFontMgr_custom_directory.cpp", 369 "src/ports/SkFontMgr_custom_directory_factory.cpp", 370 "src/ports/SkFontMgr_custom_embedded.cpp", 371 "src/ports/SkFontMgr_custom_empty.cpp", 372 ] 373} 374 375optional("fontmgr_custom_empty") { 376 enabled = skia_enable_fontmgr_custom_empty 377 378 deps = [ ":typeface_freetype" ] 379 sources = [ 380 "src/ports/SkFontMgr_custom.cpp", 381 "src/ports/SkFontMgr_custom_empty.cpp", 382 "src/ports/SkFontMgr_custom_empty_factory.cpp", 383 ] 384} 385 386optional("fontmgr_empty") { 387 enabled = skia_enable_fontmgr_empty 388 sources = [ "src/ports/SkFontMgr_empty_factory.cpp" ] 389} 390 391optional("fontmgr_fontconfig") { 392 enabled = skia_use_freetype && skia_use_fontconfig 393 394 deps = [ 395 ":typeface_freetype", 396 "//third_party:fontconfig", 397 ] 398 sources = [ 399 "src/ports/SkFontConfigInterface.cpp", 400 "src/ports/SkFontConfigInterface_direct.cpp", 401 "src/ports/SkFontConfigInterface_direct_factory.cpp", 402 "src/ports/SkFontMgr_FontConfigInterface.cpp", 403 "src/ports/SkFontMgr_fontconfig.cpp", 404 "src/ports/SkFontMgr_fontconfig_factory.cpp", 405 ] 406} 407 408optional("fontmgr_fuchsia") { 409 enabled = skia_enable_fontmgr_fuchsia 410 411 deps = [] 412 413 if (is_fuchsia && using_fuchsia_sdk) { 414 deps += [ "$fuchsia_sdk_root/fidl:fuchsia.fonts" ] 415 } else { 416 deps += [ "//sdk/fidl/fuchsia.fonts" ] 417 } 418 sources = [ 419 "src/ports/SkFontMgr_fuchsia.cpp", 420 "src/ports/SkFontMgr_fuchsia.h", 421 ] 422} 423 424optional("fontmgr_wasm") { 425 enabled = !skia_enable_fontmgr_empty && target_cpu == "wasm" 426 427 deps = [ ":typeface_freetype" ] 428 sources = [ 429 "src/ports/SkFontMgr_custom.cpp", 430 "src/ports/SkFontMgr_custom.h", 431 "src/ports/SkFontMgr_custom_embedded.cpp", 432 "src/ports/SkFontMgr_custom_embedded_factory.cpp", 433 ] 434} 435 436optional("fontmgr_win") { 437 enabled = skia_enable_fontmgr_win 438 439 sources = [ 440 "src/fonts/SkFontMgr_indirect.cpp", 441 "src/ports/SkFontMgr_win_dw.cpp", 442 "src/ports/SkFontMgr_win_dw_factory.cpp", 443 "src/ports/SkScalerContext_win_dw.cpp", 444 "src/ports/SkTypeface_win_dw.cpp", 445 ] 446} 447 448optional("fontmgr_win_gdi") { 449 enabled = skia_enable_fontmgr_win_gdi 450 451 sources = [ "src/ports/SkFontHost_win.cpp" ] 452 libs = [ "Gdi32.lib" ] 453} 454 455if (skia_lex) { 456 executable("sksllex") { 457 sources = [ 458 "src/sksl/lex/Main.cpp", 459 "src/sksl/lex/NFA.cpp", 460 "src/sksl/lex/RegexNode.cpp", 461 "src/sksl/lex/RegexParser.cpp", 462 ] 463 include_dirs = [ "." ] 464 } 465 466 action("run_sksllex") { 467 script = "gn/run_sksllex.py" 468 deps = [ ":sksllex(//gn/toolchain:$host_toolchain)" ] 469 sources = [ "src/sksl/lex/sksl.lex" ] 470 471 # GN insists its outputs should go somewhere underneath target_out_dir, so we trick it with a 472 # path that starts with target_out_dir and then uses ".." to back up into the src dir. 473 outputs = [ 474 "$target_out_dir/" + 475 rebase_path("src/sksl/lex/SkSLLexer.h", target_out_dir), 476 # the script also modifies the corresponding .cpp file, but if we tell GN that it gets 477 # confused due to the same file being named by two different paths 478 ] 479 sksllex_path = "$root_out_dir/" 480 sksllex_path += "sksllex" 481 if (host_os == "win") { 482 sksllex_path += ".exe" 483 } 484 args = [ 485 rebase_path(sksllex_path), 486 rebase_path("bin/clang-format"), 487 rebase_path("src"), 488 ] 489 } 490} else { 491 group("run_sksllex") { 492 } 493} 494 495if (skia_compile_processors) { 496 executable("skslc") { 497 defines = [ "SKSL_STANDALONE" ] 498 sources = [ "src/sksl/SkSLMain.cpp" ] 499 sources += skia_sksl_sources 500 sources += skia_sksl_gpu_sources 501 include_dirs = [ "." ] 502 deps = [ 503 ":run_sksllex", 504 "//third_party/spirv-tools", 505 ] 506 } 507 508 skia_gpu_processor_outputs = [] 509 foreach(src, skia_gpu_processor_sources) { 510 dir = get_path_info(src, "dir") 511 name = get_path_info(src, "name") 512 513 # GN insists its outputs should go somewhere underneath target_out_dir, so we trick it with a 514 # path that starts with target_out_dir and then uses ".." to back up into the src dir. 515 skia_gpu_processor_outputs += [ 516 "$target_out_dir/" + 517 rebase_path("$dir/generated/$name.h", target_out_dir), 518 # the script also modifies the corresponding .cpp file, but if we tell GN that it gets 519 # confused due to the same file being named by two different paths 520 ] 521 } 522 523 action("create_sksl_enums") { 524 script = "gn/create_sksl_enums.py" 525 sources = [ "include/private/GrSharedEnums.h" ] 526 outputs = [ "$target_out_dir/" + 527 rebase_path("src/sksl/sksl_enums.inc", target_out_dir) ] 528 args = [ 529 rebase_path(sources[0]), 530 rebase_path(outputs[0]), 531 ] 532 } 533 534 action("compile_processors") { 535 script = "gn/compile_processors.py" 536 deps = [ 537 ":create_sksl_enums", 538 ":skslc(//gn/toolchain:$host_toolchain)", 539 ] 540 sources = skia_gpu_processor_sources 541 outputs = skia_gpu_processor_outputs 542 skslc_path = "$root_out_dir/" 543 if (host_toolchain != default_toolchain_name) { 544 skslc_path += "$host_toolchain/" 545 } 546 skslc_path += "skslc" 547 if (host_os == "win") { 548 skslc_path += ".exe" 549 } 550 args = [ 551 rebase_path(skslc_path), 552 rebase_path("bin/clang-format"), 553 ] 554 args += rebase_path(skia_gpu_processor_sources) 555 } 556} else { 557 skia_gpu_processor_outputs = [] 558 group("compile_processors") { 559 } 560} 561 562optional("gpu") { 563 enabled = skia_enable_gpu 564 deps = [ 565 ":compile_processors", 566 ":run_sksllex", 567 ] 568 if (skia_generate_workarounds) { 569 deps += [ ":workaround_list" ] 570 } 571 public_defines = [ "SK_GL" ] 572 public_configs = [] 573 public_deps = [] 574 575 sources = 576 skia_gpu_sources + skia_sksl_gpu_sources + skia_gpu_processor_outputs 577 if (!skia_enable_ccpr) { 578 sources -= skia_ccpr_sources 579 sources += [ "src/gpu/ccpr/GrCoverageCountingPathRenderer_none.cpp" ] 580 } 581 if (!skia_enable_nvpr) { 582 sources -= skia_nvpr_sources 583 sources += [ "src/gpu/GrPathRendering_none.cpp" ] 584 } 585 586 # These paths need to be absolute to match the ones produced by shared_sources.gni. 587 sources -= get_path_info([ "src/gpu/gl/GrGLMakeNativeInterface_none.cpp" ], 588 "abspath") 589 libs = [] 590 if (is_android) { 591 sources += [ "src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp" ] 592 593 # this lib is required to link against AHardwareBuffer 594 if (defined(ndk_api) && ndk_api >= 26) { 595 libs += [ "android" ] 596 } 597 } else if (skia_use_egl) { 598 sources += [ "src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp" ] 599 libs += [ "EGL" ] 600 } else if (is_linux && skia_use_x11) { 601 sources += [ "src/gpu/gl/glx/GrGLMakeNativeInterface_glx.cpp" ] 602 libs += [ "GL" ] 603 } else if (is_mac) { 604 sources += [ "src/gpu/gl/mac/GrGLMakeNativeInterface_mac.cpp" ] 605 } else if (is_ios) { 606 sources += [ "src/gpu/gl/iOS/GrGLMakeNativeInterface_iOS.cpp" ] 607 } else if (is_win) { 608 sources += [ "src/gpu/gl/win/GrGLMakeNativeInterface_win.cpp" ] 609 if (target_cpu != "arm64") { 610 libs += [ "OpenGL32.lib" ] 611 } 612 } else { 613 sources += [ "src/gpu/gl/GrGLMakeNativeInterface_none.cpp" ] 614 } 615 616 if (skia_use_vulkan) { 617 public_defines += [ "SK_VULKAN" ] 618 deps += [ "third_party/vulkanmemoryallocator" ] 619 sources += skia_vk_sources 620 if (skia_enable_vulkan_debug_layers) { 621 public_defines += [ "SK_ENABLE_VK_LAYERS" ] 622 } 623 if (is_fuchsia) { 624 if (using_fuchsia_sdk) { 625 public_deps += [ "$fuchsia_sdk_root/pkg:vulkan" ] 626 } else { 627 public_deps += [ "//src/graphics/lib/vulkan" ] 628 } 629 } 630 } 631 632 if (skia_use_dawn) { 633 public_defines += [ "SK_DAWN" ] 634 sources += skia_dawn_sources 635 public_deps += [ 636 "//third_party/dawn:dawn_headers", 637 "//third_party/dawn:libdawn", 638 "//third_party/dawn:libdawn_native_sources", 639 ] 640 if (dawn_enable_d3d12) { 641 libs += [ 642 "d3d12.lib", 643 "dxgi.lib", 644 "d3dcompiler.lib", 645 ] 646 } else if (dawn_enable_metal) { 647 libs += [ "Metal.framework" ] 648 } 649 } 650 651 cflags_objcc = [] 652 if (skia_use_metal) { 653 public_defines += [ "SK_METAL" ] 654 sources += skia_metal_sources 655 libs += [ "Metal.framework" ] 656 libs += [ "Foundation.framework" ] 657 cflags_objcc += [ "-fobjc-arc" ] 658 } 659 660 if (skia_enable_atlas_text) { 661 sources += skia_atlas_text_sources 662 } 663 664 if (is_debug) { 665 public_defines += [ "SK_ENABLE_DUMP_GPU" ] 666 } 667} 668 669optional("gif") { 670 enabled = !skia_use_wuffs 671 sources = [ 672 "src/codec/SkGifCodec.cpp", 673 "third_party/gif/SkGifImageReader.cpp", 674 ] 675} 676 677optional("heif") { 678 enabled = skia_use_libheif 679 public_defines = [ "SK_HAS_HEIF_LIBRARY" ] 680 681 deps = [] 682 683 sources = [ "src/codec/SkHeifCodec.cpp" ] 684} 685 686optional("jpeg") { 687 enabled = skia_use_libjpeg_turbo 688 public_defines = [ "SK_HAS_JPEG_LIBRARY" ] 689 690 deps = [ "//third_party/libjpeg-turbo:libjpeg" ] 691 public = [ "include/encode/SkJpegEncoder.h" ] 692 sources = [ 693 "src/codec/SkJpegCodec.cpp", 694 "src/codec/SkJpegDecoderMgr.cpp", 695 "src/codec/SkJpegUtility.cpp", 696 "src/images/SkJPEGWriteUtility.cpp", 697 "src/images/SkJpegEncoder.cpp", 698 ] 699} 700 701optional("pdf") { 702 enabled = skia_use_zlib && skia_enable_pdf 703 public_defines = [ "SK_SUPPORT_PDF" ] 704 705 deps = [ "//third_party/zlib" ] 706 if (skia_use_libjpeg_turbo) { 707 deps += [ ":jpeg" ] 708 } 709 sources = skia_pdf_sources 710 sources_when_disabled = [ "src/pdf/SkDocument_PDF_None.cpp" ] 711 if (skia_use_icu && skia_use_harfbuzz && skia_pdf_subset_harfbuzz) { 712 deps += [ "//third_party/harfbuzz" ] 713 defines = [ "SK_PDF_USE_HARFBUZZ_SUBSET" ] 714 } else if (skia_use_icu && skia_use_sfntly) { 715 deps += [ "//third_party/sfntly" ] 716 defines = [ "SK_PDF_USE_SFNTLY" ] 717 } 718} 719 720optional("png") { 721 enabled = skia_use_libpng 722 public_defines = [ "SK_HAS_PNG_LIBRARY" ] 723 724 deps = [ "//third_party/libpng" ] 725 sources = [ 726 "src/codec/SkIcoCodec.cpp", 727 "src/codec/SkPngCodec.cpp", 728 "src/images/SkPngEncoder.cpp", 729 ] 730} 731 732optional("raw") { 733 enabled = skia_use_dng_sdk && skia_use_libjpeg_turbo && skia_use_piex 734 public_defines = [ "SK_CODEC_DECODES_RAW" ] 735 736 deps = [ 737 "//third_party/dng_sdk", 738 "//third_party/libjpeg-turbo:libjpeg", 739 "//third_party/piex", 740 ] 741 742 # SkRawCodec catches any exceptions thrown by dng_sdk, insulating the rest of 743 # Skia. 744 configs_to_remove = [ "//gn:no_exceptions" ] 745 746 sources = [ "src/codec/SkRawCodec.cpp" ] 747} 748 749import("third_party/skcms/skcms.gni") 750source_set("skcms") { 751 cflags = [] 752 if (!is_win || is_clang) { 753 cflags += [ 754 "-w", 755 "-std=c11", 756 ] 757 } 758 759 public = [ "include/third_party/skcms/skcms.h" ] 760 include_dirs = [ "include/third_party/skcms" ] 761 sources = rebase_path(skcms_sources, ".", "third_party/skcms") 762} 763 764optional("typeface_freetype") { 765 enabled = skia_use_freetype 766 767 deps = [ "//third_party/freetype2" ] 768 sources = [ 769 "src/ports/SkFontHost_FreeType.cpp", 770 "src/ports/SkFontHost_FreeType_common.cpp", 771 ] 772} 773 774optional("webp") { 775 enabled = skia_use_libwebp 776 public_defines = [ "SK_HAS_WEBP_LIBRARY" ] 777 778 deps = [ "//third_party/libwebp" ] 779 sources = [ 780 "src/codec/SkWebpCodec.cpp", 781 "src/images/SkWebpEncoder.cpp", 782 ] 783} 784 785optional("wuffs") { 786 enabled = skia_use_wuffs 787 public_defines = [ "SK_HAS_WUFFS_LIBRARY" ] 788 789 deps = [ "//third_party/wuffs" ] 790 sources = [ "src/codec/SkWuffsCodec.cpp" ] 791} 792 793optional("xml") { 794 enabled = skia_use_expat 795 public_defines = [ "SK_XML" ] 796 797 deps = [ "//third_party/expat" ] 798 sources = [ 799 "src/svg/SkSVGCanvas.cpp", 800 "src/svg/SkSVGDevice.cpp", 801 "src/xml/SkDOM.cpp", 802 "src/xml/SkXMLParser.cpp", 803 "src/xml/SkXMLWriter.cpp", 804 ] 805} 806 807optional("sksl_interpreter") { 808 enabled = skia_enable_sksl_interpreter 809 public_defines = [ "SK_ENABLE_SKSL_INTERPRETER" ] 810} 811 812optional("skvm_jit") { 813 enabled = skia_enable_skvm_jit 814 public_defines = [ "SKVM_JIT" ] 815} 816 817if (skia_enable_gpu && skia_generate_workarounds) { 818 action("workaround_list") { 819 script = "tools/build_workaround_header.py" 820 821 inputs = [ "src/gpu/gpu_workaround_list.txt" ] 822 823 # see comments in skia_compile_processors about out dir path shenanigans. 824 output_file = 825 rebase_path("include/gpu/GrDriverBugWorkaroundsAutogen.h", root_out_dir) 826 827 outputs = [ "$root_out_dir/$output_file" ] 828 args = [ 829 "--output-file", 830 "$output_file", 831 ] 832 833 foreach(file, inputs) { 834 args += [ rebase_path(file, root_build_dir) ] 835 } 836 } 837} 838 839component("skia") { 840 public_configs = [ ":skia_public" ] 841 configs += skia_library_configs 842 843 public_deps = [ 844 ":gpu", 845 ":pdf", 846 ":skcms", 847 ] 848 849 deps = [ 850 ":arm64", 851 ":armv7", 852 ":avx", 853 ":compile_processors", 854 ":crc32", 855 ":fontmgr_android", 856 ":fontmgr_custom", 857 ":fontmgr_custom_empty", 858 ":fontmgr_empty", 859 ":fontmgr_fontconfig", 860 ":fontmgr_fuchsia", 861 ":fontmgr_wasm", 862 ":fontmgr_win", 863 ":fontmgr_win_gdi", 864 ":gif", 865 ":heif", 866 ":hsw", 867 ":jpeg", 868 ":none", 869 ":png", 870 ":raw", 871 ":sksl_interpreter", 872 ":skvm_jit", 873 ":sse2", 874 ":sse41", 875 ":sse42", 876 ":ssse3", 877 ":webp", 878 ":wuffs", 879 ":xml", 880 ] 881 882 # This file (and all GN files in Skia) are designed to work with an 883 # empty sources assignment filter; we handle all that explicitly. 884 # We clear the filter here for clients who may have set up a global filter. 885 886 public = skia_core_public 887 public += skia_utils_public 888 public += skia_effects_public 889 public += skia_effects_imagefilter_public 890 public += skia_xps_public 891 892 sources = [] 893 sources += skia_core_sources 894 sources += skia_utils_sources 895 if (skia_use_xps) { 896 sources += skia_xps_sources 897 } 898 sources += skia_effects_sources 899 sources += skia_effects_imagefilter_sources 900 sources += skia_sksl_sources 901 sources += [ 902 "src/android/SkAndroidFrameworkUtils.cpp", 903 "src/android/SkAnimatedImage.cpp", 904 "src/android/SkBitmapRegionCodec.cpp", 905 "src/android/SkBitmapRegionDecoder.cpp", 906 "src/codec/SkAndroidCodec.cpp", 907 "src/codec/SkAndroidCodecAdapter.cpp", 908 "src/codec/SkBmpBaseCodec.cpp", 909 "src/codec/SkBmpCodec.cpp", 910 "src/codec/SkBmpMaskCodec.cpp", 911 "src/codec/SkBmpRLECodec.cpp", 912 "src/codec/SkBmpStandardCodec.cpp", 913 "src/codec/SkCodec.cpp", 914 "src/codec/SkCodecImageGenerator.cpp", 915 "src/codec/SkColorTable.cpp", 916 "src/codec/SkEncodedInfo.cpp", 917 "src/codec/SkMaskSwizzler.cpp", 918 "src/codec/SkMasks.cpp", 919 "src/codec/SkSampledCodec.cpp", 920 "src/codec/SkSampler.cpp", 921 "src/codec/SkStreamBuffer.cpp", 922 "src/codec/SkSwizzler.cpp", 923 "src/codec/SkWbmpCodec.cpp", 924 "src/images/SkImageEncoder.cpp", 925 "src/ports/SkDiscardableMemory_none.cpp", 926 "src/ports/SkGlobalInitialization_default.cpp", 927 "src/ports/SkImageGenerator_skia.cpp", 928 "src/ports/SkMemory_malloc.cpp", 929 "src/ports/SkOSFile_stdio.cpp", 930 "src/sfnt/SkOTTable_name.cpp", 931 "src/sfnt/SkOTUtils.cpp", 932 "src/utils/mac/SkStream_mac.cpp", 933 ] 934 935 defines = [] 936 libs = [] 937 938 if (is_win) { 939 sources += [ 940 "src/ports/SkDebug_win.cpp", 941 "src/ports/SkImageEncoder_WIC.cpp", 942 "src/ports/SkImageGeneratorWIC.cpp", 943 "src/ports/SkOSFile_win.cpp", 944 "src/ports/SkOSLibrary_win.cpp", 945 "src/ports/SkTLS_win.cpp", 946 ] 947 libs += [ 948 "FontSub.lib", 949 "Ole32.lib", 950 "OleAut32.lib", 951 "User32.lib", 952 "Usp10.lib", 953 ] 954 } else { 955 sources += [ 956 "src/ports/SkOSFile_posix.cpp", 957 "src/ports/SkOSLibrary_posix.cpp", 958 "src/ports/SkTLS_pthread.cpp", 959 ] 960 libs += [ "dl" ] 961 } 962 963 if (is_android) { 964 deps += [ "//third_party/expat" ] 965 if (defined(ndk) && ndk != "") { 966 deps += [ "//third_party/cpu-features" ] 967 } 968 sources += [ "src/ports/SkDebug_android.cpp" ] 969 libs += [ 970 "EGL", 971 "GLESv2", 972 "log", 973 ] 974 } 975 976 if (is_linux || target_cpu == "wasm") { 977 sources += [ "src/ports/SkDebug_stdio.cpp" ] 978 if (skia_use_egl) { 979 libs += [ "GLESv2" ] 980 } 981 } 982 983 if (skia_use_fonthost_mac) { 984 sources += [ "src/ports/SkFontHost_mac.cpp" ] 985 } 986 987 if (is_mac) { 988 sources += [ 989 "src/ports/SkDebug_stdio.cpp", 990 "src/ports/SkImageEncoder_CG.cpp", 991 "src/ports/SkImageGeneratorCG.cpp", 992 ] 993 libs += [ 994 # AppKit symbols NSFontWeightXXX may be dlsym'ed. 995 "AppKit.framework", 996 "ApplicationServices.framework", 997 "OpenGL.framework", 998 ] 999 } 1000 1001 if (is_ios) { 1002 sources += [ 1003 "src/ports/SkDebug_stdio.cpp", 1004 "src/ports/SkFontHost_mac.cpp", 1005 "src/ports/SkImageEncoder_CG.cpp", 1006 "src/ports/SkImageGeneratorCG.cpp", 1007 ] 1008 frameworks = [ 1009 "CoreFoundation.framework", 1010 "CoreGraphics.framework", 1011 "CoreText.framework", 1012 "ImageIO.framework", 1013 "MobileCoreServices.framework", 1014 1015 # UIKit symbols UIFontWeightXXX may be dlsym'ed. 1016 "UIKit.framework", 1017 ] 1018 } 1019 1020 if (is_fuchsia) { 1021 sources += [ "src/ports/SkDebug_stdio.cpp" ] 1022 } 1023 1024 if (skia_enable_spirv_validation) { 1025 deps += [ "//third_party/spirv-tools" ] 1026 defines += [ "SK_ENABLE_SPIRV_VALIDATION" ] 1027 } 1028 1029 if (skia_include_multiframe_procs) { 1030 sources += [ "tools/SkSharingProc.cpp" ] 1031 } 1032} 1033 1034# DebugCanvas used in experimental/wasm-skp-debugger 1035if (target_cpu == "wasm") { 1036 static_library("debugcanvas") { 1037 public_configs = [ ":skia_public" ] 1038 1039 sources = [ 1040 "tools/SkSharingProc.cpp", 1041 "tools/UrlDataManager.cpp", 1042 "tools/debugger/DebugCanvas.cpp", 1043 "tools/debugger/DrawCommand.cpp", 1044 "tools/debugger/JsonWriteBuffer.cpp", 1045 ] 1046 1047 deps = [ ":fontmgr_wasm" ] 1048 } 1049} 1050 1051static_library("pathkit") { 1052 check_includes = false 1053 public_configs = [ ":skia_public" ] 1054 configs += skia_library_configs 1055 1056 deps = [ 1057 ":arm64", 1058 ":armv7", 1059 ":avx", 1060 ":crc32", 1061 ":hsw", 1062 ":none", 1063 ":sse2", 1064 ":sse41", 1065 ":sse42", 1066 ":ssse3", 1067 ] 1068 1069 # This file (and all GN files in Skia) are designed to work with an 1070 # empty sources assignment filter; we handle all that explicitly. 1071 # We clear the filter here for clients who may have set up a global filter. 1072 1073 sources = [] 1074 sources += skia_pathops_sources 1075 sources += skia_pathops_public 1076 sources += [ 1077 "src/core/SkAnalyticEdge.cpp", 1078 "src/core/SkArenaAlloc.cpp", 1079 "src/core/SkContourMeasure.cpp", 1080 "src/core/SkCubicMap.cpp", 1081 "src/core/SkEdge.cpp", 1082 "src/core/SkEdgeBuilder.cpp", 1083 "src/core/SkEdgeClipper.cpp", 1084 "src/core/SkGeometry.cpp", 1085 "src/core/SkLineClipper.cpp", 1086 "src/core/SkMallocPixelRef.cpp", 1087 "src/core/SkMath.cpp", 1088 "src/core/SkMatrix.cpp", 1089 "src/core/SkOpts.cpp", 1090 "src/core/SkPaint.cpp", 1091 "src/core/SkPath.cpp", 1092 "src/core/SkPathEffect.cpp", 1093 "src/core/SkPathMeasure.cpp", 1094 "src/core/SkPathRef.cpp", 1095 "src/core/SkPoint.cpp", 1096 "src/core/SkRRect.cpp", 1097 "src/core/SkRect.cpp", 1098 "src/core/SkSemaphore.cpp", 1099 "src/core/SkStream.cpp", 1100 "src/core/SkString.cpp", 1101 "src/core/SkStringUtils.cpp", 1102 "src/core/SkStroke.cpp", 1103 "src/core/SkStrokeRec.cpp", 1104 "src/core/SkStrokerPriv.cpp", 1105 "src/core/SkThreadID.cpp", 1106 "src/core/SkUtils.cpp", 1107 "src/effects/SkDashPathEffect.cpp", 1108 "src/effects/SkTrimPathEffect.cpp", 1109 "src/ports/SkDebug_stdio.cpp", 1110 "src/ports/SkMemory_malloc.cpp", 1111 "src/utils/SkDashPath.cpp", 1112 "src/utils/SkParse.cpp", 1113 "src/utils/SkParsePath.cpp", 1114 "src/utils/SkUTF.cpp", 1115 ] 1116} 1117 1118group("modules") { 1119 deps = [ 1120 "modules/particles", 1121 "modules/skottie", 1122 "modules/skshaper", 1123 ] 1124} 1125 1126# Targets guarded by skia_enable_tools may use //third_party freely. 1127if (skia_enable_tools) { 1128 skia_public_includes = [ 1129 "include/android", 1130 "include/atlastext", 1131 "include/c", 1132 "include/codec", 1133 "include/config", 1134 "include/core", 1135 "include/docs", 1136 "include/effects", 1137 "include/encode", 1138 "include/gpu", 1139 "include/pathops", 1140 "include/ports", 1141 "include/svg", 1142 "include/utils", 1143 "include/utils/mac", 1144 "modules/sksg/include", 1145 "modules/skshaper/include", 1146 "modules/skottie/include", 1147 ] 1148 1149 # Used by gn_to_bp.py to list our public include dirs. 1150 source_set("public") { 1151 configs += [ ":skia_public" ] 1152 include_dirs = skia_public_includes 1153 } 1154 1155 config("skia.h_config") { 1156 include_dirs = [ "$target_gen_dir" ] 1157 } 1158 action("skia.h") { 1159 public_configs = [ ":skia.h_config" ] 1160 skia_h = "$target_gen_dir/skia.h" 1161 script = "gn/find_headers.py" 1162 1163 args = [ rebase_path("//bin/gn") ] + [ rebase_path("//") ] + 1164 [ rebase_path(skia_h, root_build_dir) ] + 1165 rebase_path(skia_public_includes) 1166 depfile = "$skia_h.deps" 1167 outputs = [ skia_h ] 1168 } 1169 1170 if (target_cpu == "x64") { 1171 executable("fiddle") { 1172 check_includes = false 1173 libs = [] 1174 sources = [ 1175 "tools/fiddle/draw.cpp", 1176 "tools/fiddle/fiddle_main.cpp", 1177 ] 1178 1179 if (skia_use_egl) { 1180 sources += [ "tools/fiddle/egl_context.cpp" ] 1181 } else { 1182 sources += [ "tools/fiddle/null_context.cpp" ] 1183 } 1184 testonly = true 1185 deps = [ 1186 ":flags", 1187 ":gpu_tool_utils", 1188 ":skia", 1189 ":skia.h", 1190 "modules/skottie", 1191 "modules/skshaper", 1192 ] 1193 } 1194 } 1195 1196 config("our_vulkan_headers") { 1197 # We add this directory to simulate the client already have 1198 # vulkan/vulkan_core.h on their path. 1199 include_dirs = [ "include/third_party/vulkan" ] 1200 } 1201 1202 source_set("public_headers_warnings_check") { 1203 sources = [ "tools/public_headers_warnings_check.cpp" ] 1204 configs -= [ "//gn:warnings_except_public_headers" ] 1205 configs += [ ":our_vulkan_headers" ] 1206 deps = [ 1207 ":skia", 1208 ":skia.h", 1209 "modules/skottie", 1210 "modules/skshaper", 1211 ] 1212 1213 if (skia_use_dawn) { 1214 deps += [ "//third_party/dawn:dawn_headers" ] 1215 } 1216 } 1217 1218 template("test_lib") { 1219 config(target_name + "_config") { 1220 if (defined(invoker.public_defines)) { 1221 defines = invoker.public_defines 1222 } 1223 } 1224 source_set(target_name) { 1225 forward_variables_from(invoker, "*", []) 1226 check_includes = false 1227 public_configs = [ 1228 ":" + target_name + "_config", 1229 ":skia_private", 1230 ] 1231 1232 if (!defined(deps)) { 1233 deps = [] 1234 } 1235 deps += [ ":skia" ] 1236 testonly = true 1237 } 1238 } 1239 1240 template("test_app") { 1241 if (is_ios) { 1242 app_name = target_name 1243 gen_path = target_gen_dir 1244 1245 action("${app_name}_generate_info_plist") { 1246 script = "//gn/gen_plist_ios.py" 1247 outputs = [ "$gen_path/${app_name}_Info.plist" ] 1248 args = [ rebase_path("$gen_path/$app_name", root_build_dir) ] 1249 } 1250 1251 bundle_data("${app_name}_bundle_info_plist") { 1252 public_deps = [ ":${app_name}_generate_info_plist" ] 1253 sources = [ "$gen_path/${app_name}_Info.plist" ] 1254 outputs = [ "{{bundle_root_dir}}/Info.plist" ] 1255 } 1256 1257 has_skps = "True" == exec_script("//gn/checkdir.py", 1258 [ rebase_path("skps", root_build_dir) ], 1259 "trim string") 1260 bundle_data("${app_name}_bundle_resources") { 1261 sources = [ "resources" ] 1262 outputs = [ 1263 # iOS reserves the folders 'Resources' and 'resources' so store one level deeper 1264 "{{bundle_resources_dir}}/data/resources", 1265 ] 1266 } 1267 if (has_skps) { 1268 bundle_data("${app_name}_bundle_skps") { 1269 sources = [ "skps" ] 1270 outputs = [ 1271 # Store in same folder as resources 1272 "{{bundle_resources_dir}}/data/skps", 1273 ] 1274 } 1275 } 1276 1277 executable("${app_name}_generate_executable") { 1278 forward_variables_from(invoker, 1279 "*", 1280 [ 1281 "output_name", 1282 "visibility", 1283 "is_shared_library", 1284 ]) 1285 configs += [ ":skia_private" ] 1286 testonly = true 1287 output_name = rebase_path("$gen_path/$app_name", root_build_dir) 1288 } 1289 1290 bundle_data("${app_name}_bundle_executable") { 1291 public_deps = [ ":${app_name}_generate_executable" ] 1292 sources = [ "$gen_path/$app_name" ] 1293 outputs = [ "{{bundle_executable_dir}}/$app_name" ] 1294 testonly = true 1295 } 1296 1297 bundle_data("${app_name}_bundle_symbols") { 1298 public_deps = [ ":${app_name}_generate_executable" ] 1299 sources = [ "$gen_path/${app_name}.dSYM" ] 1300 outputs = [ "{{bundle_executable_dir}}/${app_name}.dSYM" ] 1301 testonly = true 1302 } 1303 1304 create_bundle("$app_name") { 1305 product_type = "com.apple.product-type.application" 1306 testonly = true 1307 1308 bundle_root_dir = "${root_build_dir}/${target_name}.app" 1309 bundle_resources_dir = bundle_root_dir 1310 bundle_executable_dir = bundle_root_dir 1311 1312 deps = [ 1313 ":${app_name}_bundle_executable", 1314 ":${app_name}_bundle_info_plist", 1315 ":${app_name}_bundle_resources", 1316 ":${app_name}_bundle_symbols", 1317 ] 1318 if (has_skps) { 1319 deps += [ ":${app_name}_bundle_skps" ] 1320 } 1321 1322 # should only code sign when running on a device, not the simulator 1323 if (target_cpu != "x64") { 1324 code_signing_script = "//gn/codesign_ios.py" 1325 code_signing_sources = [ "$target_gen_dir/$app_name" ] 1326 code_signing_outputs = [ 1327 "$bundle_root_dir/_CodeSignature/CodeResources", 1328 "$bundle_root_dir/embedded.mobileprovision", 1329 ] 1330 code_signing_args = [ 1331 rebase_path("$bundle_root_dir", root_build_dir), 1332 skia_ios_identity, 1333 skia_ios_profile, 1334 ] 1335 } 1336 } 1337 } else { 1338 # !is_ios 1339 1340 if (defined(invoker.is_shared_library) && invoker.is_shared_library) { 1341 shared_library("lib" + target_name) { 1342 forward_variables_from(invoker, "*", [ "is_shared_library" ]) 1343 configs += [ ":skia_private" ] 1344 testonly = true 1345 } 1346 } else { 1347 _executable = target_name 1348 executable(_executable) { 1349 check_includes = false 1350 forward_variables_from(invoker, "*", [ "is_shared_library" ]) 1351 configs += [ ":skia_private" ] 1352 testonly = true 1353 } 1354 } 1355 if (is_android && skia_android_serial != "" && defined(_executable)) { 1356 action("push_" + target_name) { 1357 script = "gn/push_to_android.py" 1358 deps = [ ":" + _executable ] 1359 _stamp = "$target_gen_dir/$_executable.pushed_$skia_android_serial" 1360 outputs = [ _stamp ] 1361 args = [ 1362 rebase_path("$root_build_dir/$_executable"), 1363 skia_android_serial, 1364 rebase_path(_stamp), 1365 ] 1366 testonly = true 1367 } 1368 } 1369 } 1370 } 1371 1372 config("moltenvk_config") { 1373 if (defined(skia_moltenvk_path) && skia_moltenvk_path != "") { 1374 if (is_ios) { 1375 moltenvk_framework_path = "$skia_moltenvk_path/MoltenVK/iOS" 1376 } else { 1377 moltenvk_framework_path = "$skia_moltenvk_path/MoltenVK/macOS" 1378 } 1379 cflags = [ "-F$moltenvk_framework_path" ] 1380 ldflags = [ "-F$moltenvk_framework_path" ] 1381 libs = [ 1382 "MoltenVK.framework", 1383 "Metal.framework", 1384 "IOSurface.framework", 1385 "QuartzCore.framework", 1386 "Foundation.framework", 1387 ] 1388 if (is_ios) { 1389 libs += [ "UIKit.framework" ] 1390 } else { 1391 libs += [ "IOKit.framework" ] 1392 } 1393 defines = [ "SK_MOLTENVK" ] 1394 } 1395 } 1396 1397 source_set("moltenvk") { 1398 public_configs = [ ":moltenvk_config" ] 1399 } 1400 1401 test_lib("gpu_tool_utils") { 1402 public_defines = [] 1403 1404 # Bots and even devs may not have Vulkan headers, so put 1405 # include/third_party/vulkan on our path so they're always available. 1406 all_dependent_configs = [ ":our_vulkan_headers" ] 1407 1408 defines = [] 1409 if (skia_enable_discrete_gpu) { 1410 defines += [ "SK_ENABLE_DISCRETE_GPU" ] 1411 } 1412 1413 deps = [] 1414 public_deps = [] 1415 sources = [ 1416 "tools/gpu/GrContextFactory.cpp", 1417 "tools/gpu/GrTest.cpp", 1418 "tools/gpu/MemoryCache.cpp", 1419 "tools/gpu/MemoryCache.h", 1420 "tools/gpu/ProxyUtils.cpp", 1421 "tools/gpu/TestContext.cpp", 1422 "tools/gpu/YUVUtils.cpp", 1423 "tools/gpu/YUVUtils.h", 1424 "tools/gpu/atlastext/GLTestAtlasTextRenderer.cpp", 1425 "tools/gpu/gl/GLTestContext.cpp", 1426 "tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp", 1427 "tools/gpu/mock/MockTestContext.cpp", 1428 ] 1429 libs = [] 1430 1431 if (is_android || skia_use_egl) { 1432 sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ] 1433 } else if (is_ios) { 1434 sources += [ "tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm" ] 1435 libs += [ "OpenGLES.framework" ] 1436 } else if (is_linux) { 1437 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ] 1438 libs += [ 1439 "GLU", 1440 "X11", 1441 ] 1442 } else if (is_mac) { 1443 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ] 1444 } else if (is_win) { 1445 sources += [ "tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp" ] 1446 libs += [ "Gdi32.lib" ] 1447 if (target_cpu != "arm64") { 1448 libs += [ "OpenGL32.lib" ] 1449 } 1450 } 1451 1452 cflags_objcc = [ "-fobjc-arc" ] 1453 1454 if (skia_use_angle) { 1455 deps += [ "//third_party/angle2" ] 1456 sources += [ "tools/gpu/gl/angle/GLTestContext_angle.cpp" ] 1457 } 1458 1459 if (skia_use_vulkan) { 1460 sources += [ "tools/gpu/vk/VkTestContext.cpp" ] 1461 sources += [ "tools/gpu/vk/VkTestUtils.cpp" ] 1462 if (defined(skia_moltenvk_path) && skia_moltenvk_path != "") { 1463 public_deps += [ ":moltenvk" ] 1464 } 1465 } 1466 if (skia_use_metal) { 1467 sources += [ "tools/gpu/mtl/MtlTestContext.mm" ] 1468 } 1469 if (skia_use_dawn) { 1470 public_deps += [ "//third_party/dawn:dawn_headers" ] 1471 sources += [ "tools/gpu/dawn/DawnTestContext.cpp" ] 1472 } 1473 } 1474 1475 test_lib("flags") { 1476 sources = [ "tools/flags/CommandLineFlags.cpp" ] 1477 } 1478 1479 test_lib("common_flags_config") { 1480 sources = [ "tools/flags/CommonFlagsConfig.cpp" ] 1481 deps = [ ":flags" ] 1482 public_deps = [ ":gpu_tool_utils" ] 1483 } 1484 test_lib("common_flags_gpu") { 1485 sources = [ "tools/flags/CommonFlagsGpu.cpp" ] 1486 deps = [ ":flags" ] 1487 public_deps = [ ":gpu_tool_utils" ] 1488 } 1489 test_lib("common_flags_images") { 1490 sources = [ "tools/flags/CommonFlagsImages.cpp" ] 1491 deps = [ ":flags" ] 1492 } 1493 test_lib("common_flags_aa") { 1494 sources = [ "tools/flags/CommonFlagsAA.cpp" ] 1495 deps = [ ":flags" ] 1496 } 1497 1498 test_lib("trace") { 1499 deps = [ ":flags" ] 1500 sources = [ 1501 "tools/trace/ChromeTracingTracer.cpp", 1502 "tools/trace/ChromeTracingTracer.h", 1503 "tools/trace/EventTracingPriv.cpp", 1504 "tools/trace/EventTracingPriv.h", 1505 "tools/trace/SkDebugfTracer.cpp", 1506 "tools/trace/SkDebugfTracer.h", 1507 ] 1508 } 1509 1510 test_lib("tool_utils") { 1511 sources = [ 1512 "tools/AndroidSkDebugToStdOut.cpp", 1513 "tools/AutoreleasePool.h", 1514 "tools/CrashHandler.cpp", 1515 "tools/DDLPromiseImageHelper.cpp", 1516 "tools/DDLTileHelper.cpp", 1517 "tools/LsanSuppressions.cpp", 1518 "tools/ProcStats.cpp", 1519 "tools/Resources.cpp", 1520 "tools/SkMetaData.cpp", 1521 "tools/SkMetaData.h", 1522 "tools/SkSharingProc.cpp", 1523 "tools/ToolUtils.cpp", 1524 "tools/UrlDataManager.cpp", 1525 "tools/debugger/DebugCanvas.cpp", 1526 "tools/debugger/DrawCommand.cpp", 1527 "tools/debugger/JsonWriteBuffer.cpp", 1528 "tools/fonts/RandomScalerContext.cpp", 1529 "tools/fonts/TestEmptyTypeface.h", 1530 "tools/fonts/TestFontMgr.cpp", 1531 "tools/fonts/TestFontMgr.h", 1532 "tools/fonts/TestSVGTypeface.cpp", 1533 "tools/fonts/TestSVGTypeface.h", 1534 "tools/fonts/TestTypeface.cpp", 1535 "tools/fonts/TestTypeface.h", 1536 "tools/fonts/ToolUtilsFont.cpp", 1537 "tools/random_parse_path.cpp", 1538 "tools/timer/TimeUtils.h", 1539 "tools/timer/Timer.cpp", 1540 ] 1541 libs = [] 1542 if (is_ios) { 1543 sources += [ "tools/ios_utils.m" ] 1544 sources += [ "tools/ios_utils.h" ] 1545 if (skia_use_metal) { 1546 sources += [ "tools/AutoreleasePool.mm" ] 1547 } 1548 libs += [ "Foundation.framework" ] 1549 } else if (is_mac) { 1550 if (skia_use_metal) { 1551 sources += [ "tools/AutoreleasePool.mm" ] 1552 libs += [ "Foundation.framework" ] 1553 } 1554 } else if (is_win) { 1555 libs += [ "DbgHelp.lib" ] 1556 } 1557 1558 defines = [] 1559 if (skia_tools_require_resources) { 1560 defines += [ "SK_TOOLS_REQUIRE_RESOURCES" ] 1561 } 1562 deps = [ 1563 ":experimental_svg_model", 1564 ":flags", 1565 ] 1566 public_deps = [ ":gpu_tool_utils" ] 1567 } 1568 1569 test_lib("etc1") { 1570 sources = [ "third_party/etc1/etc1.cpp" ] 1571 } 1572 1573 if (skia_use_ffmpeg) { 1574 test_lib("video_decoder") { 1575 sources = [ 1576 "experimental/ffmpeg/SkVideoDecoder.cpp", 1577 "experimental/ffmpeg/SkVideoDecoder.h", 1578 "experimental/ffmpeg/SkVideoEncoder.cpp", 1579 "experimental/ffmpeg/SkVideoEncoder.h", 1580 ] 1581 libs = [ 1582 "swscale", 1583 "avcodec", 1584 "avformat", 1585 "avutil", 1586 ] 1587 } 1588 } 1589 1590 import("gn/gm.gni") 1591 test_lib("gm") { 1592 sources = gm_sources 1593 deps = [ 1594 ":etc1", 1595 ":flags", 1596 ":skia", 1597 ":tool_utils", 1598 "modules/skottie", 1599 "modules/skottie:gm", 1600 "modules/sksg", 1601 "modules/skshaper", 1602 ] 1603 if (is_skia_dev_build) { 1604 sources += [ "gm/fiddle.cpp" ] 1605 deps += [ ":skia.h" ] 1606 } 1607 public_deps = [ ":gpu_tool_utils" ] 1608 1609 if (skia_use_ffmpeg) { 1610 deps += [ ":video_decoder" ] 1611 sources += [ "gm/video_decoder.cpp" ] 1612 } 1613 } 1614 1615 test_lib("skvm_builders") { 1616 sources = [ 1617 "tools/SkVMBuilders.cpp", 1618 "tools/SkVMBuilders.h", 1619 ] 1620 } 1621 1622 import("gn/tests.gni") 1623 test_lib("tests") { 1624 sources = tests_sources + pathops_tests_sources 1625 if (skia_use_metal) { 1626 sources += metal_tests_sources 1627 } 1628 if (!skia_enable_fontmgr_android) { 1629 sources -= [ "//tests/FontMgrAndroidParserTest.cpp" ] 1630 } 1631 if (!(skia_use_freetype && skia_use_fontconfig)) { 1632 sources -= [ "//tests/FontMgrFontConfigTest.cpp" ] 1633 } 1634 deps = [ 1635 ":experimental_svg_model", 1636 ":flags", 1637 ":skia", 1638 ":skvm_builders", 1639 ":tool_utils", 1640 "modules/skottie:tests", 1641 "modules/skparagraph:tests", 1642 "modules/sksg:tests", 1643 "modules/skshaper", 1644 "//third_party/libpng", 1645 "//third_party/libwebp", 1646 "//third_party/zlib", 1647 ] 1648 public_deps = [ 1649 ":gpu_tool_utils", # Test.h #includes headers from this target. 1650 ] 1651 } 1652 1653 import("gn/bench.gni") 1654 test_lib("bench") { 1655 sources = bench_sources 1656 deps = [ 1657 ":flags", 1658 ":gm", 1659 ":gpu_tool_utils", 1660 ":skia", 1661 ":skvm_builders", 1662 ":tool_utils", 1663 "modules/skparagraph:bench", 1664 "modules/skshaper", 1665 ] 1666 } 1667 1668 test_lib("experimental_svg_model") { 1669 if (skia_use_expat) { 1670 sources = [ 1671 "experimental/svg/model/SkSVGAttribute.cpp", 1672 "experimental/svg/model/SkSVGAttributeParser.cpp", 1673 "experimental/svg/model/SkSVGCircle.cpp", 1674 "experimental/svg/model/SkSVGClipPath.cpp", 1675 "experimental/svg/model/SkSVGContainer.cpp", 1676 "experimental/svg/model/SkSVGDOM.cpp", 1677 "experimental/svg/model/SkSVGEllipse.cpp", 1678 "experimental/svg/model/SkSVGGradient.cpp", 1679 "experimental/svg/model/SkSVGLine.cpp", 1680 "experimental/svg/model/SkSVGLinearGradient.cpp", 1681 "experimental/svg/model/SkSVGNode.cpp", 1682 "experimental/svg/model/SkSVGPath.cpp", 1683 "experimental/svg/model/SkSVGPattern.cpp", 1684 "experimental/svg/model/SkSVGPoly.cpp", 1685 "experimental/svg/model/SkSVGRadialGradient.cpp", 1686 "experimental/svg/model/SkSVGRect.cpp", 1687 "experimental/svg/model/SkSVGRenderContext.cpp", 1688 "experimental/svg/model/SkSVGSVG.cpp", 1689 "experimental/svg/model/SkSVGShape.cpp", 1690 "experimental/svg/model/SkSVGStop.cpp", 1691 "experimental/svg/model/SkSVGTransformableNode.cpp", 1692 "experimental/svg/model/SkSVGUse.cpp", 1693 "experimental/svg/model/SkSVGValue.cpp", 1694 ] 1695 deps = [ 1696 ":skia", 1697 ":xml", 1698 ] 1699 } 1700 } 1701 1702 test_lib("experimental_xform") { 1703 sources = [ 1704 "experimental/xform/SkShape.cpp", 1705 "experimental/xform/SkXform.cpp", 1706 "experimental/xform/XContext.cpp", 1707 ] 1708 deps = [ ":skia" ] 1709 } 1710 1711 if (skia_use_lua) { 1712 test_lib("lua") { 1713 sources = [ 1714 "src/utils/SkLua.cpp", 1715 "src/utils/SkLuaCanvas.cpp", 1716 ] 1717 deps = [ 1718 "modules/skshaper", 1719 "//third_party/lua", 1720 ] 1721 } 1722 1723 test_app("lua_app") { 1724 sources = [ "tools/lua/lua_app.cpp" ] 1725 deps = [ 1726 ":lua", 1727 ":skia", 1728 "//third_party/lua", 1729 ] 1730 } 1731 1732 test_app("lua_pictures") { 1733 sources = [ "tools/lua/lua_pictures.cpp" ] 1734 deps = [ 1735 ":flags", 1736 ":lua", 1737 ":skia", 1738 ":tool_utils", 1739 "//third_party/lua", 1740 ] 1741 } 1742 } 1743 1744 if (is_linux || is_mac) { 1745 test_app("skottie_tool") { 1746 deps = [ "modules/skottie:tool" ] 1747 } 1748 } 1749 1750 test_app("make_skqp_model") { 1751 sources = [ "tools/skqp/make_skqp_model.cpp" ] 1752 deps = [ ":skia" ] 1753 } 1754 1755 if (target_cpu != "wasm") { 1756 import("gn/samples.gni") 1757 test_lib("samples") { 1758 sources = samples_sources 1759 public_deps = [ ":tool_utils" ] 1760 deps = [ 1761 ":experimental_svg_model", 1762 ":flags", 1763 ":gpu_tool_utils", 1764 ":xml", 1765 "modules/skparagraph:samples", 1766 "modules/sksg", 1767 "modules/skshaper", 1768 ] 1769 1770 if (skia_use_lua) { 1771 sources += [ "samplecode/SampleLua.cpp" ] 1772 deps += [ 1773 ":lua", 1774 "//third_party/lua", 1775 ] 1776 } 1777 } 1778 test_app("imgcvt") { 1779 sources = [ "tools/imgcvt.cpp" ] 1780 deps = [ 1781 ":skcms", 1782 ":skia", 1783 ] 1784 } 1785 test_lib("hash_and_encode") { 1786 sources = [ 1787 "tools/HashAndEncode.cpp", 1788 "tools/HashAndEncode.h", 1789 ] 1790 deps = [ 1791 ":flags", 1792 ":skia", 1793 "//third_party/libpng", 1794 ] 1795 } 1796 test_app("fm") { 1797 sources = [ "tools/fm/fm.cpp" ] 1798 deps = [ 1799 ":common_flags_aa", 1800 ":common_flags_gpu", 1801 ":experimental_svg_model", 1802 ":flags", 1803 ":gm", 1804 ":gpu_tool_utils", 1805 ":hash_and_encode", 1806 ":skia", 1807 ":tool_utils", 1808 ":trace", 1809 "modules/skottie", 1810 "modules/skottie:utils", 1811 ] 1812 } 1813 test_app("dm") { 1814 sources = [ 1815 "dm/DM.cpp", 1816 "dm/DMGpuTestProcs.cpp", 1817 "dm/DMJsonWriter.cpp", 1818 "dm/DMSrcSink.cpp", 1819 ] 1820 deps = [ 1821 ":common_flags_aa", 1822 ":common_flags_config", 1823 ":common_flags_gpu", 1824 ":common_flags_images", 1825 ":experimental_svg_model", 1826 ":flags", 1827 ":gm", 1828 ":gpu_tool_utils", 1829 ":hash_and_encode", 1830 ":skia", 1831 ":tests", 1832 ":tool_utils", 1833 ":trace", 1834 "modules/skottie", 1835 "modules/skottie:utils", 1836 "modules/sksg", 1837 ] 1838 } 1839 } 1840 1841 if (!is_win) { 1842 test_app("remote_demo") { 1843 sources = [ "tools/remote_demo.cpp" ] 1844 deps = [ ":skia" ] 1845 } 1846 } 1847 1848 test_app("nanobench") { 1849 sources = [ "bench/nanobench.cpp" ] 1850 deps = [ 1851 ":bench", 1852 ":common_flags_aa", 1853 ":common_flags_config", 1854 ":common_flags_gpu", 1855 ":common_flags_images", 1856 ":experimental_svg_model", 1857 ":flags", 1858 ":gm", 1859 ":gpu_tool_utils", 1860 ":skia", 1861 ":tool_utils", 1862 ":trace", 1863 "modules/skparagraph:bench", 1864 "modules/sksg", 1865 "modules/skshaper", 1866 ] 1867 } 1868 1869 test_app("skpinfo") { 1870 sources = [ "tools/skpinfo.cpp" ] 1871 deps = [ 1872 ":flags", 1873 ":skia", 1874 ] 1875 } 1876 1877 if (skia_use_ffmpeg) { 1878 test_app("skottie2movie") { 1879 sources = [ "tools/skottie2movie.cpp" ] 1880 deps = [ 1881 ":flags", 1882 ":skia", 1883 ":video_decoder", 1884 "modules/skottie", 1885 "modules/skottie:utils", 1886 ] 1887 } 1888 } 1889 1890 test_app("skpbench") { 1891 sources = [ "tools/skpbench/skpbench.cpp" ] 1892 deps = [ 1893 ":common_flags_config", 1894 ":common_flags_gpu", 1895 ":flags", 1896 ":gpu_tool_utils", 1897 ":skia", 1898 ":tool_utils", 1899 ] 1900 } 1901 1902 test_app("sktexttopdf") { 1903 sources = [ "tools/using_skia_and_harfbuzz.cpp" ] 1904 deps = [ 1905 ":skia", 1906 "modules/skshaper", 1907 ] 1908 } 1909 1910 test_app("create_test_font") { 1911 sources = [ "tools/fonts/create_test_font.cpp" ] 1912 deps = [ ":skia" ] 1913 assert_no_deps = [ 1914 # tool_utils requires the output of this app. 1915 ":tool_utils", 1916 ] 1917 } 1918 1919 if (skia_use_expat) { 1920 test_app("create_test_font_color") { 1921 sources = [ "tools/fonts/create_test_font_color.cpp" ] 1922 deps = [ 1923 ":flags", 1924 ":skia", 1925 ":tool_utils", 1926 ] 1927 } 1928 } 1929 1930 test_app("get_images_from_skps") { 1931 sources = [ "tools/get_images_from_skps.cpp" ] 1932 deps = [ 1933 ":flags", 1934 ":skia", 1935 ] 1936 } 1937 1938 if (!is_ios && target_cpu != "wasm" && !(is_win && target_cpu == "arm64")) { 1939 test_app("skiaserve") { 1940 sources = [ 1941 "tools/skiaserve/Request.cpp", 1942 "tools/skiaserve/Response.cpp", 1943 "tools/skiaserve/skiaserve.cpp", 1944 "tools/skiaserve/urlhandlers/BreakHandler.cpp", 1945 "tools/skiaserve/urlhandlers/ClipAlphaHandler.cpp", 1946 "tools/skiaserve/urlhandlers/CmdHandler.cpp", 1947 "tools/skiaserve/urlhandlers/ColorModeHandler.cpp", 1948 "tools/skiaserve/urlhandlers/DataHandler.cpp", 1949 "tools/skiaserve/urlhandlers/DownloadHandler.cpp", 1950 "tools/skiaserve/urlhandlers/EnableGPUHandler.cpp", 1951 "tools/skiaserve/urlhandlers/ImgHandler.cpp", 1952 "tools/skiaserve/urlhandlers/InfoHandler.cpp", 1953 "tools/skiaserve/urlhandlers/OpBoundsHandler.cpp", 1954 "tools/skiaserve/urlhandlers/OpsHandler.cpp", 1955 "tools/skiaserve/urlhandlers/OverdrawHandler.cpp", 1956 "tools/skiaserve/urlhandlers/PostHandler.cpp", 1957 "tools/skiaserve/urlhandlers/QuitHandler.cpp", 1958 "tools/skiaserve/urlhandlers/RootHandler.cpp", 1959 ] 1960 deps = [ 1961 ":flags", 1962 ":gpu_tool_utils", 1963 ":skia", 1964 ":tool_utils", 1965 "//third_party/libmicrohttpd", 1966 ] 1967 } 1968 } 1969 1970 test_app("fuzz") { 1971 sources = [ 1972 "fuzz/Fuzz.cpp", 1973 "fuzz/FuzzCanvas.cpp", 1974 "fuzz/FuzzCommon.cpp", 1975 "fuzz/FuzzDrawFunctions.cpp", 1976 "fuzz/FuzzEncoders.cpp", 1977 "fuzz/FuzzGradients.cpp", 1978 "fuzz/FuzzMain.cpp", 1979 "fuzz/FuzzParsePath.cpp", 1980 "fuzz/FuzzPathMeasure.cpp", 1981 "fuzz/FuzzPathop.cpp", 1982 "fuzz/FuzzPolyUtils.cpp", 1983 "fuzz/FuzzRegionOp.cpp", 1984 "fuzz/oss_fuzz/FuzzAndroidCodec.cpp", 1985 "fuzz/oss_fuzz/FuzzAnimatedImage.cpp", 1986 "fuzz/oss_fuzz/FuzzImage.cpp", 1987 "fuzz/oss_fuzz/FuzzImageFilterDeserialize.cpp", 1988 "fuzz/oss_fuzz/FuzzIncrementalImage.cpp", 1989 "fuzz/oss_fuzz/FuzzJSON.cpp", 1990 "fuzz/oss_fuzz/FuzzPathDeserialize.cpp", 1991 "fuzz/oss_fuzz/FuzzRegionDeserialize.cpp", 1992 "fuzz/oss_fuzz/FuzzRegionSetPath.cpp", 1993 "fuzz/oss_fuzz/FuzzSKSL2GLSL.cpp", 1994 "fuzz/oss_fuzz/FuzzSKSL2Metal.cpp", 1995 "fuzz/oss_fuzz/FuzzSKSL2Pipeline.cpp", 1996 "fuzz/oss_fuzz/FuzzSKSL2SPIRV.cpp", 1997 "fuzz/oss_fuzz/FuzzTextBlobDeserialize.cpp", 1998 "tools/UrlDataManager.cpp", 1999 "tools/debugger/DebugCanvas.cpp", 2000 "tools/debugger/DrawCommand.cpp", 2001 "tools/debugger/JsonWriteBuffer.cpp", 2002 ] 2003 deps = [ 2004 ":flags", 2005 ":gpu_tool_utils", 2006 ":skia", 2007 "modules/skottie:fuzz", 2008 ] 2009 } 2010 2011 test_app("pathops_unittest") { 2012 sources = pathops_tests_sources + [ 2013 rebase_path("tests/skia_test.cpp"), 2014 rebase_path("tests/Test.cpp"), 2015 ] 2016 deps = [ 2017 ":flags", 2018 ":gpu_tool_utils", 2019 ":skia", 2020 ":tool_utils", 2021 ] 2022 } 2023 2024 test_app("dump_record") { 2025 sources = [ 2026 "tools/DumpRecord.cpp", 2027 "tools/dump_record.cpp", 2028 ] 2029 deps = [ 2030 ":flags", 2031 ":skia", 2032 ] 2033 } 2034 2035 test_app("skdiff") { 2036 sources = [ 2037 "tools/skdiff/skdiff.cpp", 2038 "tools/skdiff/skdiff_html.cpp", 2039 "tools/skdiff/skdiff_main.cpp", 2040 "tools/skdiff/skdiff_utils.cpp", 2041 ] 2042 deps = [ 2043 ":skia", 2044 ":tool_utils", 2045 ] 2046 } 2047 2048 test_app("skp_parser") { 2049 sources = [ "tools/skp_parser.cpp" ] 2050 deps = [ 2051 ":skia", 2052 ":tool_utils", 2053 ] 2054 } 2055 2056 if (!is_win) { 2057 test_lib("skqp_lib") { 2058 defines = 2059 [ "SK_SKQP_GLOBAL_ERROR_TOLERANCE=$skia_skqp_global_error_tolerance" ] 2060 sources = [ 2061 "dm/DMGpuTestProcs.cpp", 2062 "tools/skqp/src/skqp.cpp", 2063 "tools/skqp/src/skqp_model.cpp", 2064 ] 2065 deps = [ 2066 ":gm", 2067 ":gpu_tool_utils", 2068 ":skia", 2069 ":tests", 2070 ":tool_utils", 2071 ] 2072 } 2073 test_app("skqp") { 2074 sources = [ "tools/skqp/src/skqp_main.cpp" ] 2075 deps = [ 2076 ":skia", 2077 ":skqp_lib", 2078 ":tool_utils", 2079 ] 2080 } 2081 test_app("jitter_gms") { 2082 sources = [ "tools/skqp/jitter_gms.cpp" ] 2083 deps = [ 2084 ":gm", 2085 ":skia", 2086 ":skqp_lib", 2087 ] 2088 } 2089 } 2090 if (is_android) { 2091 test_app("skqp_app") { 2092 is_shared_library = true 2093 sources = [ "tools/skqp/src/jni_skqp.cpp" ] 2094 deps = [ 2095 ":skia", 2096 ":skqp_lib", 2097 ":tool_utils", 2098 ] 2099 libs = [ "android" ] 2100 } 2101 } 2102 if (is_android && skia_enable_gpu) { 2103 test_app("skottie_android") { 2104 is_shared_library = true 2105 2106 sources = [ 2107 "platform_tools/android/apps/skottie/src/main/cpp/JavaInputStreamAdaptor.cpp", 2108 "platform_tools/android/apps/skottie/src/main/cpp/native-lib.cpp", 2109 ] 2110 libs = [] 2111 2112 deps = [ 2113 ":skia", 2114 "modules/skottie", 2115 "modules/sksg:samples", 2116 ] 2117 } 2118 } 2119 2120 test_app("list_gms") { 2121 sources = [ "tools/list_gms.cpp" ] 2122 deps = [ 2123 ":gm", 2124 ":skia", 2125 ] 2126 } 2127 test_app("list_gpu_unit_tests") { 2128 sources = [ 2129 "dm/DMGpuTestProcs.cpp", 2130 "tools/list_gpu_unit_tests.cpp", 2131 ] 2132 deps = [ 2133 ":skia", 2134 ":tests", 2135 ] 2136 } 2137 2138 test_lib("sk_app") { 2139 public_deps = [ 2140 ":gpu_tool_utils", 2141 ":skia", 2142 ] 2143 sources = [ 2144 "tools/sk_app/CommandSet.cpp", 2145 "tools/sk_app/GLWindowContext.cpp", 2146 "tools/sk_app/Window.cpp", 2147 ] 2148 libs = [] 2149 2150 if (skia_use_dawn) { 2151 sources += [ "tools/sk_app/DawnWindowContext.cpp" ] 2152 } 2153 2154 if (is_android) { 2155 sources += [ 2156 "tools/sk_app/android/GLWindowContext_android.cpp", 2157 "tools/sk_app/android/RasterWindowContext_android.cpp", 2158 "tools/sk_app/android/Window_android.cpp", 2159 "tools/sk_app/android/main_android.cpp", 2160 "tools/sk_app/android/surface_glue_android.cpp", 2161 ] 2162 libs += [ "android" ] 2163 } else if (is_linux) { 2164 sources += [ 2165 "tools/sk_app/unix/GLWindowContext_unix.cpp", 2166 "tools/sk_app/unix/RasterWindowContext_unix.cpp", 2167 "tools/sk_app/unix/Window_unix.cpp", 2168 "tools/sk_app/unix/keysym2ucs.c", 2169 "tools/sk_app/unix/main_unix.cpp", 2170 ] 2171 if (skia_use_dawn) { 2172 if (dawn_enable_vulkan) { 2173 sources += [ "tools/sk_app/unix/DawnVulkanWindowContext_unix.cpp" ] 2174 defines = [ "VK_USE_PLATFORM_XCB_KHR" ] 2175 libs += [ "X11-xcb" ] 2176 } 2177 } 2178 libs += [ 2179 "GL", 2180 "X11", 2181 ] 2182 } else if (is_win) { 2183 sources += [ 2184 "tools/sk_app/win/GLWindowContext_win.cpp", 2185 "tools/sk_app/win/RasterWindowContext_win.cpp", 2186 "tools/sk_app/win/Window_win.cpp", 2187 "tools/sk_app/win/main_win.cpp", 2188 ] 2189 if (skia_use_angle) { 2190 sources += [ "tools/sk_app/win/ANGLEWindowContext_win.cpp" ] 2191 } 2192 if (skia_use_dawn) { 2193 if (dawn_enable_d3d12) { 2194 sources += [ "tools/sk_app/win/DawnD3D12WindowContext_win.cpp" ] 2195 } 2196 } 2197 } else if (is_mac) { 2198 sources += [ 2199 "tools/sk_app/mac/GLWindowContext_mac.mm", 2200 "tools/sk_app/mac/RasterWindowContext_mac.mm", 2201 "tools/sk_app/mac/Window_mac.mm", 2202 "tools/sk_app/mac/main_mac.mm", 2203 ] 2204 if (skia_use_dawn) { 2205 if (dawn_enable_metal) { 2206 sources += [ "tools/sk_app/mac/DawnMTLWindowContext_mac.mm" ] 2207 } 2208 } 2209 libs += [ 2210 "QuartzCore.framework", 2211 "Cocoa.framework", 2212 "Foundation.framework", 2213 ] 2214 } else if (is_ios) { 2215 sources += [ 2216 "tools/sk_app/ios/GLWindowContext_ios.cpp", 2217 "tools/sk_app/ios/RasterWindowContext_ios.cpp", 2218 "tools/sk_app/ios/Window_ios.cpp", 2219 "tools/sk_app/ios/main_ios.cpp", 2220 ] 2221 } 2222 2223 if (skia_use_vulkan) { 2224 sources += [ "tools/sk_app/VulkanWindowContext.cpp" ] 2225 if (is_android) { 2226 sources += [ "tools/sk_app/android/VulkanWindowContext_android.cpp" ] 2227 } else if (is_linux) { 2228 sources += [ "tools/sk_app/unix/VulkanWindowContext_unix.cpp" ] 2229 libs += [ "X11-xcb" ] 2230 } else if (is_win) { 2231 sources += [ "tools/sk_app/win/VulkanWindowContext_win.cpp" ] 2232 } else if (is_mac) { 2233 sources += [ "tools/sk_app/mac/VulkanWindowContext_mac.mm" ] 2234 libs += [ "MetalKit.framework" ] 2235 } 2236 } 2237 2238 if (skia_use_metal) { 2239 sources += [ "tools/sk_app/MetalWindowContext.mm" ] 2240 if (is_mac) { 2241 sources += [ "tools/sk_app/mac/MetalWindowContext_mac.mm" ] 2242 } 2243 libs += [ "MetalKit.framework" ] 2244 } 2245 2246 deps = [ ":tool_utils" ] 2247 if (is_android) { 2248 deps += [ "//third_party/native_app_glue" ] 2249 } else if (is_ios) { 2250 deps += [ "//third_party/libsdl" ] 2251 } 2252 if (skia_use_angle) { 2253 deps += [ "//third_party/angle2" ] 2254 } 2255 } 2256 2257 if (!skia_use_vulkan && (is_mac || is_linux || is_win)) { 2258 test_app("fiddle_examples") { 2259 sources = [ 2260 "tools/fiddle/all_examples.cpp", 2261 "tools/fiddle/examples.cpp", 2262 "tools/fiddle/examples.h", 2263 ] 2264 if (is_win) { 2265 cflags = [ "/wd4756" ] # Overflow in constant arithmetic 2266 } 2267 deps = [ 2268 ":skia", 2269 ":skia.h", 2270 "modules/skottie", 2271 "modules/skshaper", 2272 ] 2273 } 2274 } 2275 test_app("viewer") { 2276 is_shared_library = is_android 2277 sources = [ 2278 "tools/viewer/AnimTimer.h", 2279 "tools/viewer/BisectSlide.cpp", 2280 "tools/viewer/GMSlide.cpp", 2281 "tools/viewer/ImGuiLayer.cpp", 2282 "tools/viewer/ImageSlide.cpp", 2283 "tools/viewer/ParticlesSlide.cpp", 2284 "tools/viewer/SKPSlide.cpp", 2285 "tools/viewer/SampleSlide.cpp", 2286 "tools/viewer/SkottieSlide.cpp", 2287 "tools/viewer/SlideDir.cpp", 2288 "tools/viewer/StatsLayer.cpp", 2289 "tools/viewer/SvgSlide.cpp", 2290 "tools/viewer/TouchGesture.cpp", 2291 "tools/viewer/TouchGesture.h", 2292 "tools/viewer/Viewer.cpp", 2293 ] 2294 libs = [] 2295 2296 deps = [ 2297 ":common_flags_gpu", 2298 ":experimental_svg_model", 2299 ":flags", 2300 ":gm", 2301 ":gpu_tool_utils", 2302 ":samples", 2303 ":sk_app", 2304 ":skia", 2305 ":tool_utils", 2306 ":trace", 2307 "modules/particles", 2308 "modules/skottie", 2309 "modules/skottie:utils", 2310 "modules/sksg", 2311 "modules/sksg:samples", 2312 "//third_party/imgui", 2313 ] 2314 if (skia_use_experimental_xform) { 2315 deps += [ ":experimental_xform" ] 2316 sources += [ "gm/xform.cpp" ] 2317 } 2318 } 2319 2320 if (!skia_use_angle && (is_linux || is_win || is_mac)) { 2321 test_app("HelloWorld") { 2322 sources = [ "example/HelloWorld.cpp" ] 2323 libs = [] 2324 2325 deps = [ 2326 ":flags", 2327 ":gpu_tool_utils", 2328 ":sk_app", 2329 ":skia", 2330 ":tool_utils", 2331 ] 2332 } 2333 } 2334 2335 if (is_linux || is_mac || is_ios) { 2336 test_app("SkiaSDLExample") { 2337 sources = [ "example/SkiaSDLExample.cpp" ] 2338 libs = [] 2339 deps = [ 2340 ":gpu_tool_utils", 2341 ":skia", 2342 "//third_party/libsdl", 2343 ] 2344 } 2345 } 2346 2347 if (skia_qt_path != "" && (is_win || is_linux || is_mac)) { 2348 action_foreach("generate_mocs") { 2349 script = "gn/call.py" 2350 sources = [ "tools/mdbviz/MainWindow.h" ] 2351 outputs = [ "$target_gen_dir/mdbviz/{{source_name_part}}_moc.cpp" ] 2352 args = [ 2353 "$skia_qt_path" + "/bin/moc", 2354 "{{source}}", 2355 "-o", 2356 "gen/mdbviz/{{source_name_part}}_moc.cpp", 2357 ] 2358 } 2359 action_foreach("generate_resources") { 2360 script = "gn/call.py" 2361 sources = [ "tools/mdbviz/resources.qrc" ] 2362 outputs = [ "$target_gen_dir/mdbviz/{{source_name_part}}_res.cpp" ] 2363 args = [ 2364 "$skia_qt_path" + "/bin/rcc", 2365 "{{source}}", 2366 "-o", 2367 "gen/mdbviz/{{source_name_part}}_res.cpp", 2368 ] 2369 } 2370 test_app("mdbviz") { 2371 if (is_win) { 2372 # on Windows we need to disable some exception handling warnings due to the Qt headers 2373 cflags = [ "/Wv:18" ] # 18 -> VS2013, 19 -> VS2015, 1910 -> VS2017 2374 } 2375 sources = [ 2376 "tools/UrlDataManager.cpp", 2377 "tools/debugger/DebugCanvas.cpp", 2378 "tools/debugger/DrawCommand.cpp", 2379 "tools/debugger/JsonWriteBuffer.cpp", 2380 "tools/mdbviz/MainWindow.cpp", 2381 "tools/mdbviz/Model.cpp", 2382 "tools/mdbviz/main.cpp", 2383 2384 # generated files 2385 "$target_gen_dir/mdbviz/MainWindow_moc.cpp", 2386 "$target_gen_dir/mdbviz/resources_res.cpp", 2387 ] 2388 lib_dirs = [ "$skia_qt_path/lib" ] 2389 libs = [ 2390 "Qt5Core.lib", 2391 "Qt5Gui.lib", 2392 "Qt5Widgets.lib", 2393 ] 2394 include_dirs = [ 2395 "$skia_qt_path/include", 2396 "$skia_qt_path/include/QtCore", 2397 "$skia_qt_path/include/QtWidgets", 2398 ] 2399 deps = [ 2400 ":generate_mocs", 2401 ":generate_resources", 2402 ":skia", 2403 ] 2404 } 2405 } 2406 2407 if (is_android && defined(ndk) && ndk != "") { 2408 copy("gdbserver") { 2409 sources = [ "$ndk/$ndk_gdbserver" ] 2410 outputs = [ "$root_out_dir/gdbserver" ] 2411 } 2412 } 2413 2414 if (skia_use_opencl) { 2415 test_app("hello-opencl") { 2416 sources = [ "tools/hello-opencl.cpp" ] 2417 deps = [ "//third_party/opencl" ] 2418 } 2419 } 2420 2421 executable("cpu_modules") { 2422 sources = [ "tools/cpu_modules.cpp" ] 2423 deps = [ 2424 ":skia", 2425 "modules/particles", 2426 ] 2427 } 2428 2429 if (skia_use_icu && skia_use_harfbuzz) { 2430 test_app("editor") { 2431 is_shared_library = is_android 2432 deps = [ "experimental/editor:editor_app" ] 2433 } 2434 } 2435 2436 if (skia_enable_skvm_jit) { 2437 test_app("skvmtool") { 2438 defines = [ 2439 "SKVM_JIT", 2440 "SKVM_PERF_DUMPS", 2441 ] 2442 include_dirs = [ "." ] 2443 sources = [ 2444 "src/core/SkSpinlock.cpp", 2445 "src/core/SkThreadID.cpp", 2446 "src/core/SkVM.cpp", 2447 "tools/SkVMBuilders.cpp", 2448 "tools/SkVMTool.cpp", 2449 ] 2450 if (target_cpu == "x64") { 2451 sources += [ "src/core/SkCpu.cpp" ] 2452 } 2453 } 2454 } 2455} 2456