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