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/android_framework_defines.gni")
      7 import("gn/shared_sources.gni")
      8 
      9 if (!defined(is_skia_standalone)) {
     10   is_skia_standalone = false
     11 }
     12 is_skia_dev_build = is_skia_standalone && !is_official_build
     13 
     14 declare_args() {
     15   skia_use_angle = false
     16   skia_use_expat = true
     17   skia_use_fontconfig = is_linux
     18   skia_use_freetype = is_android || is_fuchsia || is_linux
     19   skia_use_gdi = false
     20   skia_use_icu = !is_fuchsia && !is_ios && !is_win  # TODO: Windows
     21   skia_use_libjpeg_turbo = true
     22   skia_use_libpng = true
     23   skia_use_libwebp = !is_fuchsia
     24   skia_use_lua = false
     25   skia_use_mesa = false
     26   skia_use_piex = !is_win
     27   skia_use_zlib = true
     28 
     29   skia_android_serial = ""
     30   skia_enable_android_framework_defines = false
     31   skia_enable_discrete_gpu = true
     32   skia_enable_effects = true
     33   skia_enable_jumper = is_skia_dev_build
     34   skia_enable_gpu = true
     35   skia_enable_pdf = true
     36   skia_enable_spirv_validation = is_skia_dev_build && is_debug
     37   skia_enable_tools = is_skia_dev_build
     38   skia_enable_vulkan_debug_layers = is_skia_dev_build && is_debug
     39   skia_vulkan_sdk = getenv("VULKAN_SDK")
     40 }
     41 declare_args() {
     42   skia_use_dng_sdk = !is_fuchsia && skia_use_libjpeg_turbo && skia_use_zlib
     43   skia_use_sfntly = skia_use_icu
     44 
     45   if (is_android) {
     46     skia_use_vulkan = defined(ndk_api) && ndk_api >= 24
     47   } else {
     48     skia_use_vulkan = skia_vulkan_sdk != ""
     49   }
     50 }
     51 
     52 # Our tools require static linking (they use non-exported symbols).
     53 skia_enable_tools = skia_enable_tools && !is_component_build
     54 
     55 fontmgr_android_enabled = skia_use_expat && skia_use_freetype
     56 
     57 skia_public_includes = [
     58   "include/android",
     59   "include/c",
     60   "include/codec",
     61   "include/config",
     62   "include/core",
     63   "include/effects",
     64   "include/gpu",
     65   "include/gpu/gl",
     66   "include/pathops",
     67   "include/ports",
     68   "include/svg",
     69   "include/utils",
     70   "include/utils/mac",
     71 ]
     72 
     73 # Skia public API, generally provided by :skia.
     74 config("skia_public") {
     75   include_dirs = skia_public_includes
     76   defines = []
     77   if (is_component_build) {
     78     defines += [ "SKIA_DLL" ]
     79   }
     80   if (is_fuchsia || is_linux) {
     81     defines += [ "SK_SAMPLES_FOR_X" ]
     82   }
     83   if (skia_enable_android_framework_defines) {
     84     defines += android_framework_defines
     85   }
     86   if (!skia_enable_gpu) {
     87     defines += [ "SK_SUPPORT_GPU=0" ]
     88   }
     89 }
     90 
     91 # Skia internal APIs, used by Skia itself and a few test tools.
     92 config("skia_private") {
     93   visibility = [ ":*" ]
     94 
     95   include_dirs = [
     96     "include/private",
     97     "src/c",
     98     "src/codec",
     99     "src/core",
    100     "src/effects",
    101     "src/effects/gradients",
    102     "src/fonts",
    103     "src/image",
    104     "src/images",
    105     "src/lazy",
    106     "src/opts",
    107     "src/pathops",
    108     "src/pdf",
    109     "src/ports",
    110     "src/sfnt",
    111     "src/sksl",
    112     "src/utils",
    113     "src/utils/win",
    114     "src/xml",
    115     "third_party/etc1",
    116     "third_party/gif",
    117   ]
    118 
    119   defines = [
    120     "SK_GAMMA_APPLY_TO_A8",
    121     "SK_INTERNAL",
    122   ]
    123   if (is_android) {
    124     defines += [
    125       "SK_GAMMA_EXPONENT=1.4",
    126       "SK_GAMMA_CONTRAST=0.0",
    127     ]
    128   }
    129   if (is_official_build || is_android) {
    130     # TODO(bsalomon): it'd be nice to make Android normal.
    131     defines += [ "SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0" ]
    132   }
    133   libs = []
    134   lib_dirs = []
    135   if (skia_use_vulkan) {
    136     if (skia_vulkan_sdk != "" && !is_android) {
    137       if (is_win) {
    138         include_dirs += [ "$skia_vulkan_sdk/Include/" ]
    139         lib_dirs += [
    140           "$skia_vulkan_sdk/Bin",
    141           "$skia_vulkan_sdk/Lib",
    142         ]
    143       } else {
    144         include_dirs += [ "$skia_vulkan_sdk/include/" ]
    145         lib_dirs += [ "$skia_vulkan_sdk/lib/" ]
    146       }
    147     }
    148     if (is_win) {
    149       libs += [ "vulkan-1.lib" ]
    150     } else {
    151       libs += [ "vulkan" ]
    152     }
    153   }
    154   if (skia_enable_gpu) {
    155     include_dirs += [ "src/gpu" ]
    156   }
    157   if (skia_use_angle) {
    158     defines += [ "SK_ANGLE" ]
    159   }
    160   if (skia_enable_discrete_gpu) {
    161     defines += [ "SK_ENABLE_DISCRETE_GPU" ]
    162   }
    163 }
    164 
    165 # Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
    166 config("skia_library") {
    167   visibility = [ ":*" ]
    168   defines = [ "SKIA_IMPLEMENTATION=1" ]
    169 }
    170 
    171 skia_library_configs = [
    172   ":skia_public",
    173   ":skia_private",
    174   ":skia_library",
    175 ]
    176 
    177 # Use for CPU-specific Skia code that needs particular compiler flags.
    178 template("opts") {
    179   if (invoker.enabled) {
    180     source_set(target_name) {
    181       forward_variables_from(invoker, "*")
    182       configs += skia_library_configs
    183     }
    184   } else {
    185     # If not enabled, a phony empty target that swallows all otherwise unused variables.
    186     source_set(target_name) {
    187       forward_variables_from(invoker,
    188                              "*",
    189                              [
    190                                "sources",
    191                                "cflags",
    192                              ])
    193     }
    194   }
    195 }
    196 
    197 is_x86 = current_cpu == "x64" || current_cpu == "x86"
    198 
    199 opts("none") {
    200   enabled = !is_x86 && current_cpu != "arm" && current_cpu != "arm64"
    201   sources = skia_opts.none_sources
    202   cflags = []
    203 }
    204 
    205 opts("armv7") {
    206   enabled = current_cpu == "arm"
    207   sources = skia_opts.armv7_sources + skia_opts.neon_sources
    208   cflags = []
    209 }
    210 
    211 opts("arm64") {
    212   enabled = current_cpu == "arm64"
    213   sources = skia_opts.arm64_sources
    214   cflags = []
    215 }
    216 
    217 opts("crc32") {
    218   enabled = current_cpu == "arm64"
    219   sources = skia_opts.crc32_sources
    220   cflags = [ "-march=armv8-a+crc" ]
    221 }
    222 
    223 opts("sse2") {
    224   enabled = is_x86
    225   sources = skia_opts.sse2_sources
    226   if (is_win) {
    227     defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE2" ]
    228   } else {
    229     cflags = [ "-msse2" ]
    230   }
    231 }
    232 
    233 opts("ssse3") {
    234   enabled = is_x86
    235   sources = skia_opts.ssse3_sources
    236   if (is_win) {
    237     defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSSE3" ]
    238   } else {
    239     cflags = [ "-mssse3" ]
    240   }
    241 }
    242 
    243 opts("sse41") {
    244   enabled = is_x86
    245   sources = skia_opts.sse41_sources
    246   if (is_win) {
    247     defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE41" ]
    248   } else {
    249     cflags = [ "-msse4.1" ]
    250   }
    251 }
    252 
    253 opts("sse42") {
    254   enabled = is_x86
    255   sources = skia_opts.sse42_sources
    256   if (is_win) {
    257     defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE42" ]
    258   } else {
    259     cflags = [ "-msse4.2" ]
    260   }
    261 }
    262 
    263 opts("avx") {
    264   enabled = is_x86
    265   sources = skia_opts.avx_sources
    266   if (is_win) {
    267     cflags = [ "/arch:AVX" ]
    268   } else {
    269     cflags = [ "-mavx" ]
    270   }
    271 }
    272 
    273 opts("hsw") {
    274   enabled = is_x86
    275   sources = skia_opts.hsw_sources
    276   if (is_win) {
    277     cflags = [ "/arch:AVX2" ]
    278   } else {
    279     cflags = [
    280       "-mavx2",
    281       "-mbmi",
    282       "-mbmi2",
    283       "-mf16c",
    284       "-mfma",
    285     ]
    286   }
    287 }
    288 
    289 # Any feature of Skia that requires third-party code should be optional and use this template.
    290 template("optional") {
    291   if (invoker.enabled) {
    292     config(target_name + "_public") {
    293       if (defined(invoker.public_defines)) {
    294         defines = invoker.public_defines
    295       }
    296     }
    297     source_set(target_name) {
    298       forward_variables_from(invoker,
    299                              "*",
    300                              [
    301                                "public_defines",
    302                                "sources_when_disabled",
    303                                "configs_to_remove",
    304                              ])
    305       all_dependent_configs = [ ":" + target_name + "_public" ]
    306       configs += skia_library_configs
    307       if (defined(invoker.configs_to_remove)) {
    308         configs -= invoker.configs_to_remove
    309       }
    310     }
    311   } else {
    312     source_set(target_name) {
    313       forward_variables_from(invoker,
    314                              "*",
    315                              [
    316                                "public_defines",
    317                                "deps",
    318                                "libs",
    319                                "sources",
    320                                "sources_when_disabled",
    321                                "configs_to_remove",
    322                              ])
    323       if (defined(invoker.sources_when_disabled)) {
    324         sources = invoker.sources_when_disabled
    325       }
    326       configs += skia_library_configs
    327     }
    328   }
    329 }
    330 
    331 optional("effects") {
    332   enabled = skia_enable_effects
    333   sources =
    334       skia_effects_sources + [ "src/ports/SkGlobalInitialization_default.cpp" ]
    335   sources_when_disabled = [ "src/ports/SkGlobalInitialization_none.cpp" ]
    336 }
    337 
    338 optional("fontmgr_android") {
    339   enabled = fontmgr_android_enabled
    340 
    341   deps = [
    342     ":typeface_freetype",
    343     "//third_party/expat",
    344   ]
    345   sources = [
    346     "src/ports/SkFontMgr_android.cpp",
    347     "src/ports/SkFontMgr_android_factory.cpp",
    348     "src/ports/SkFontMgr_android_parser.cpp",
    349   ]
    350 }
    351 
    352 optional("fontmgr_custom") {
    353   enabled = is_linux && skia_use_freetype && !skia_use_fontconfig
    354 
    355   deps = [
    356     ":typeface_freetype",
    357   ]
    358   sources = [
    359     "src/ports/SkFontMgr_custom.cpp",
    360     "src/ports/SkFontMgr_custom.h",
    361     "src/ports/SkFontMgr_custom_directory.cpp",
    362     "src/ports/SkFontMgr_custom_directory_factory.cpp",
    363     "src/ports/SkFontMgr_custom_embedded.cpp",
    364     "src/ports/SkFontMgr_custom_empty.cpp",
    365   ]
    366 }
    367 
    368 optional("fontmgr_fontconfig") {
    369   enabled = skia_use_freetype && skia_use_fontconfig
    370 
    371   deps = [
    372     ":typeface_freetype",
    373     "//third_party:fontconfig",
    374   ]
    375   sources = [
    376     "src/ports/SkFontConfigInterface.cpp",
    377     "src/ports/SkFontConfigInterface_direct.cpp",
    378     "src/ports/SkFontConfigInterface_direct_factory.cpp",
    379     "src/ports/SkFontMgr_FontConfigInterface.cpp",
    380     "src/ports/SkFontMgr_fontconfig.cpp",
    381     "src/ports/SkFontMgr_fontconfig_factory.cpp",
    382   ]
    383 }
    384 
    385 optional("fontmgr_fuchsia") {
    386   enabled = is_fuchsia && skia_use_freetype
    387 
    388   deps = [
    389     ":typeface_freetype",
    390   ]
    391   sources = [
    392     "src/ports/SkFontMgr_custom.cpp",
    393     "src/ports/SkFontMgr_custom_empty.cpp",
    394     "src/ports/SkFontMgr_custom_empty_factory.cpp",
    395   ]
    396 }
    397 
    398 optional("gpu") {
    399   enabled = skia_enable_gpu
    400   public_defines = []
    401 
    402   sources = skia_gpu_sources + skia_sksl_sources +
    403             [ "src/gpu/gl/GrGLDefaultInterface_native.cpp" ]
    404 
    405   # These paths need to be absolute to match the ones produced by shared_sources.gni.
    406   sources -= get_path_info([
    407                              "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
    408                              "src/gpu/gl/GrGLDefaultInterface_none.cpp",
    409                            ],
    410                            "abspath")
    411   libs = []
    412   if (is_android) {
    413     sources += [ "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp" ]
    414   } else if (is_linux) {
    415     sources += [ "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp" ]
    416     libs += [
    417       "GL",
    418       "GLU",
    419     ]
    420   } else if (is_mac) {
    421     sources += [ "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp" ]
    422   } else if (is_ios) {
    423     sources += [ "src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp" ]
    424   } else if (is_win) {
    425     sources += [ "src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp" ]
    426     libs += [ "OpenGL32.lib" ]
    427   } else {
    428     sources += [ "src/gpu/gl/GrGLCreateNativeInterface_none.cpp" ]
    429   }
    430 
    431   if (skia_use_vulkan) {
    432     public_defines += [ "SK_VULKAN" ]
    433     sources += skia_vk_sources
    434     if (skia_enable_vulkan_debug_layers) {
    435       public_defines += [ "SK_ENABLE_VK_LAYERS" ]
    436     }
    437   }
    438   if (skia_enable_spirv_validation) {
    439     deps = [
    440       "//third_party/spirv-tools",
    441     ]
    442     public_defines += [ "SK_ENABLE_SPIRV_VALIDATION" ]
    443   }
    444 }
    445 
    446 optional("jpeg") {
    447   enabled = skia_use_libjpeg_turbo
    448   public_defines = [ "SK_HAS_JPEG_LIBRARY" ]
    449 
    450   deps = [
    451     "//third_party/libjpeg-turbo:libjpeg",
    452   ]
    453   sources = [
    454     "src/codec/SkJpegCodec.cpp",
    455     "src/codec/SkJpegDecoderMgr.cpp",
    456     "src/codec/SkJpegUtility.cpp",
    457     "src/images/SkJPEGImageEncoder.cpp",
    458     "src/images/SkJPEGWriteUtility.cpp",
    459   ]
    460 }
    461 
    462 optional("pdf") {
    463   enabled = skia_use_zlib && skia_enable_pdf
    464   public_defines = [ "SK_SUPPORT_PDF" ]
    465 
    466   deps = [
    467     "//third_party/zlib",
    468   ]
    469   sources = skia_pdf_sources
    470   sources_when_disabled = [ "src/pdf/SkDocument_PDF_None.cpp" ]
    471 
    472   if (skia_use_sfntly) {
    473     deps += [ "//third_party/sfntly" ]
    474     public_defines += [ "SK_PDF_USE_SFNTLY" ]
    475   }
    476 }
    477 
    478 optional("png") {
    479   enabled = skia_use_libpng
    480   public_defines = [ "SK_HAS_PNG_LIBRARY" ]
    481 
    482   deps = [
    483     "//third_party/libpng",
    484   ]
    485   sources = [
    486     "src/codec/SkIcoCodec.cpp",
    487     "src/codec/SkPngCodec.cpp",
    488     "src/images/SkPNGImageEncoder.cpp",
    489   ]
    490 }
    491 
    492 optional("raw") {
    493   enabled = skia_use_dng_sdk && skia_use_libjpeg_turbo && skia_use_piex
    494   public_defines = [ "SK_CODEC_DECODES_RAW" ]
    495 
    496   deps = [
    497     "//third_party/dng_sdk",
    498     "//third_party/libjpeg-turbo:libjpeg",
    499     "//third_party/piex",
    500   ]
    501 
    502   # SkRawCodec catches any exceptions thrown by dng_sdk, insulating the rest of
    503   # Skia.
    504   configs_to_remove = [ "//gn:no_exceptions" ]
    505 
    506   sources = [
    507     "src/codec/SkRawAdapterCodec.cpp",
    508     "src/codec/SkRawCodec.cpp",
    509   ]
    510 }
    511 
    512 optional("jumper") {
    513   enabled = skia_enable_jumper
    514   public_defines = [ "SK_JUMPER" ]
    515   sources = [
    516     "src/jumper/SkJumper.cpp",
    517     "src/jumper/SkJumper_generated.cpp",
    518     "src/jumper/SkJumper_stages.cpp",
    519   ]
    520 }
    521 
    522 optional("typeface_freetype") {
    523   enabled = skia_use_freetype
    524 
    525   deps = [
    526     "//third_party/freetype2",
    527   ]
    528   sources = [
    529     "src/ports/SkFontHost_FreeType.cpp",
    530     "src/ports/SkFontHost_FreeType_common.cpp",
    531   ]
    532 }
    533 
    534 optional("webp") {
    535   enabled = skia_use_libwebp
    536   public_defines = [ "SK_HAS_WEBP_LIBRARY" ]
    537 
    538   deps = [
    539     "//third_party/libwebp",
    540   ]
    541   sources = [
    542     "src/codec/SkWebpAdapterCodec.cpp",
    543     "src/codec/SkWebpCodec.cpp",
    544     "src/images/SkWEBPImageEncoder.cpp",
    545   ]
    546 }
    547 
    548 optional("xml") {
    549   enabled = skia_use_expat
    550   public_defines = [ "SK_XML" ]
    551 
    552   deps = [
    553     "//third_party/expat",
    554   ]
    555   sources = [
    556     "src/svg/SkSVGCanvas.cpp",
    557     "src/svg/SkSVGDevice.cpp",
    558     "src/xml/SkDOM.cpp",
    559     "src/xml/SkXMLParser.cpp",
    560     "src/xml/SkXMLWriter.cpp",
    561   ]
    562 }
    563 
    564 component("skia") {
    565   public_configs = [ ":skia_public" ]
    566   configs += skia_library_configs
    567 
    568   deps = [
    569     ":arm64",
    570     ":armv7",
    571     ":avx",
    572     ":crc32",
    573     ":effects",
    574     ":fontmgr_android",
    575     ":fontmgr_custom",
    576     ":fontmgr_fontconfig",
    577     ":fontmgr_fuchsia",
    578     ":gpu",
    579     ":hsw",
    580     ":jpeg",
    581     ":jumper",
    582     ":none",
    583     ":pdf",
    584     ":png",
    585     ":raw",
    586     ":sse2",
    587     ":sse41",
    588     ":sse42",
    589     ":ssse3",
    590     ":webp",
    591     ":xml",
    592   ]
    593 
    594   # This file (and all GN files in Skia) are designed to work with an
    595   # empty sources assignment filter; we handle all that explicitly.
    596   # We clear the filter here for clients who may have set up a global filter.
    597   set_sources_assignment_filter([])
    598 
    599   sources = []
    600   sources += skia_core_sources
    601   sources += skia_utils_sources
    602   sources += skia_xps_sources
    603   sources += [
    604     "src/android/SkBitmapRegionCodec.cpp",
    605     "src/android/SkBitmapRegionDecoder.cpp",
    606     "src/codec/SkAndroidCodec.cpp",
    607     "src/codec/SkBmpCodec.cpp",
    608     "src/codec/SkBmpMaskCodec.cpp",
    609     "src/codec/SkBmpRLECodec.cpp",
    610     "src/codec/SkBmpStandardCodec.cpp",
    611     "src/codec/SkCodec.cpp",
    612     "src/codec/SkCodecImageGenerator.cpp",
    613     "src/codec/SkGifCodec.cpp",
    614     "src/codec/SkMaskSwizzler.cpp",
    615     "src/codec/SkMasks.cpp",
    616     "src/codec/SkSampledCodec.cpp",
    617     "src/codec/SkSampler.cpp",
    618     "src/codec/SkStreamBuffer.cpp",
    619     "src/codec/SkSwizzler.cpp",
    620     "src/codec/SkWbmpCodec.cpp",
    621     "src/images/SkImageEncoder.cpp",
    622     "src/ports/SkDiscardableMemory_none.cpp",
    623     "src/ports/SkImageGenerator_skia.cpp",
    624     "src/ports/SkMemory_malloc.cpp",
    625     "src/ports/SkOSFile_stdio.cpp",
    626     "src/sfnt/SkOTTable_name.cpp",
    627     "src/sfnt/SkOTUtils.cpp",
    628     "src/utils/mac/SkStream_mac.cpp",
    629     "third_party/etc1/etc1.cpp",
    630     "third_party/gif/SkGifImageReader.cpp",
    631   ]
    632 
    633   libs = []
    634 
    635   if (is_win) {
    636     sources += [
    637       "src/fonts/SkFontMgr_indirect.cpp",
    638       "src/ports/SkDebug_win.cpp",
    639       "src/ports/SkFontHost_win.cpp",
    640       "src/ports/SkFontMgr_win_dw.cpp",
    641       "src/ports/SkImageEncoder_WIC.cpp",
    642       "src/ports/SkImageGeneratorWIC.cpp",
    643       "src/ports/SkOSFile_win.cpp",
    644       "src/ports/SkOSLibrary_win.cpp",
    645       "src/ports/SkScalerContext_win_dw.cpp",
    646       "src/ports/SkTLS_win.cpp",
    647       "src/ports/SkTypeface_win_dw.cpp",
    648     ]
    649     if (skia_use_gdi) {
    650       sources += [ "src/ports/SkFontMgr_win_gdi_factory.cpp" ]
    651       libs += [
    652         "Gdi32.lib",
    653         "Usp10.lib",
    654       ]
    655     } else {
    656       sources += [ "src/ports/SkFontMgr_win_dw_factory.cpp" ]
    657     }
    658     sources -=
    659         [ get_path_info("src/utils/SkThreadUtils_pthread.cpp", "abspath") ]
    660     libs += [
    661       "FontSub.lib",
    662       "Ole32.lib",
    663       "OleAut32.lib",
    664       "User32.lib",
    665     ]
    666   } else {
    667     sources += [
    668       "src/ports/SkOSFile_posix.cpp",
    669       "src/ports/SkOSLibrary_posix.cpp",
    670       "src/ports/SkTLS_pthread.cpp",
    671     ]
    672   }
    673 
    674   if (is_android) {
    675     deps += [ "//third_party/expat" ]
    676     if (defined(ndk) && ndk != "") {
    677       deps += [ "//third_party/cpu-features" ]
    678     }
    679     sources += [ "src/ports/SkDebug_android.cpp" ]
    680     libs += [
    681       "EGL",
    682       "GLESv2",
    683       "log",
    684     ]
    685   }
    686 
    687   if (is_linux) {
    688     sources += [ "src/ports/SkDebug_stdio.cpp" ]
    689   }
    690 
    691   if (is_mac) {
    692     sources += [
    693       "src/ports/SkDebug_stdio.cpp",
    694       "src/ports/SkFontHost_mac.cpp",
    695       "src/ports/SkImageEncoder_CG.cpp",
    696       "src/ports/SkImageGeneratorCG.cpp",
    697     ]
    698     libs += [
    699       "ApplicationServices.framework",
    700       "OpenGL.framework",
    701     ]
    702   }
    703 
    704   if (is_ios) {
    705     sources += [
    706       "src/ports/SkDebug_stdio.cpp",
    707       "src/ports/SkFontHost_mac.cpp",
    708       "src/ports/SkImageEncoder_CG.cpp",
    709       "src/ports/SkImageGeneratorCG.cpp",
    710     ]
    711     libs += [
    712       "CoreFoundation.framework",
    713       "CoreGraphics.framework",
    714       "CoreText.framework",
    715       "ImageIO.framework",
    716       "MobileCoreServices.framework",
    717     ]
    718   }
    719 
    720   if (is_fuchsia) {
    721     sources += [ "src/ports/SkDebug_stdio.cpp" ]
    722   }
    723 }
    724 
    725 # Targets guarded by skia_enable_tools may use //third_party freely.
    726 if (skia_enable_tools) {
    727   # Used by gn_to_bp.py to list our public include dirs.
    728   source_set("public") {
    729     configs += [ ":skia_public" ]
    730   }
    731 
    732   config("skia.h_config") {
    733     include_dirs = [ "$target_gen_dir" ]
    734   }
    735   action("skia.h") {
    736     public_configs = [ ":skia.h_config" ]
    737     skia_h = "$target_gen_dir/skia.h"
    738     script = "gn/find_headers.py"
    739     args = [ rebase_path(skia_h, root_build_dir) ] +
    740            rebase_path(skia_public_includes)
    741     depfile = "$skia_h.deps"
    742     outputs = [
    743       skia_h,
    744     ]
    745   }
    746 
    747   if (skia_enable_gpu && target_cpu == "x64") {
    748     # Our bots only have 64-bit libOSMesa installed.
    749     # TODO: worth fixing?
    750     executable("fiddle") {
    751       libs = []
    752       if (is_linux) {
    753         libs += [ "OSMesa" ]
    754       }
    755 
    756       sources = [
    757         "tools/fiddle/draw.cpp",
    758         "tools/fiddle/fiddle_main.cpp",
    759       ]
    760       deps = [
    761         ":skia",
    762         ":skia.h",
    763       ]
    764     }
    765   }
    766 
    767   if (skia_enable_gpu) {
    768     source_set("public_headers_warnings_check") {
    769       sources = [
    770         "tools/public_headers_warnings_check.cpp",
    771       ]
    772       configs -= [ "//gn:warnings_except_public_headers" ]
    773       deps = [
    774         ":skia",
    775         ":skia.h",
    776       ]
    777     }
    778   }
    779 
    780   template("test_lib") {
    781     config(target_name + "_config") {
    782       include_dirs = invoker.public_include_dirs
    783       if (defined(invoker.public_defines)) {
    784         defines = invoker.public_defines
    785       }
    786     }
    787     source_set(target_name) {
    788       forward_variables_from(invoker, "*", [ "public_include_dirs" ])
    789       public_configs = [
    790         ":" + target_name + "_config",
    791         ":skia_private",
    792       ]
    793 
    794       if (!defined(deps)) {
    795         deps = []
    796       }
    797       deps += [ ":skia" ]
    798       testonly = true
    799     }
    800   }
    801 
    802   template("test_app") {
    803     if (defined(invoker.is_shared_library) && invoker.is_shared_library) {
    804       shared_library("lib" + target_name) {
    805         forward_variables_from(invoker, "*", [ "is_shared_library" ])
    806         testonly = true
    807       }
    808     } else {
    809       _executable = target_name
    810       executable(_executable) {
    811         forward_variables_from(invoker, "*", [ "is_shared_library" ])
    812         testonly = true
    813       }
    814     }
    815     if (is_android && skia_android_serial != "" && defined(_executable)) {
    816       action("push_" + target_name) {
    817         script = "gn/push_to_android.py"
    818         deps = [
    819           ":" + _executable,
    820         ]
    821         _stamp = "$target_gen_dir/$_executable.pushed_$skia_android_serial"
    822         outputs = [
    823           _stamp,
    824         ]
    825         args = [
    826           rebase_path("$root_build_dir/$_executable"),
    827           skia_android_serial,
    828           rebase_path(_stamp),
    829         ]
    830         testonly = true
    831       }
    832     }
    833   }
    834 
    835   test_lib("gpu_tool_utils") {
    836     public_include_dirs = []
    837     if (skia_enable_gpu) {
    838       public_defines = []
    839       public_include_dirs += [ "tools/gpu" ]
    840 
    841       deps = []
    842       sources = [
    843         "tools/gpu/GrContextFactory.cpp",
    844         "tools/gpu/GrTest.cpp",
    845         "tools/gpu/TestContext.cpp",
    846         "tools/gpu/gl/GLTestContext.cpp",
    847         "tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp",
    848         "tools/gpu/gl/debug/DebugGLTestContext.cpp",
    849         "tools/gpu/gl/debug/GrBufferObj.cpp",
    850         "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
    851         "tools/gpu/gl/debug/GrProgramObj.cpp",
    852         "tools/gpu/gl/debug/GrShaderObj.cpp",
    853         "tools/gpu/gl/debug/GrTextureObj.cpp",
    854         "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
    855         "tools/gpu/gl/null/NullGLTestContext.cpp",
    856       ]
    857       libs = []
    858 
    859       if (is_android) {
    860         sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
    861       } else if (is_ios) {
    862         sources += [ "tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm" ]
    863         libs += [ "OpenGLES.framework" ]
    864       } else if (is_linux) {
    865         sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
    866         libs += [ "X11" ]
    867       } else if (is_mac) {
    868         sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
    869       } else if (is_win) {
    870         sources += [ "tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp" ]
    871         libs += [
    872           "Gdi32.lib",
    873           "OpenGL32.lib",
    874         ]
    875       }
    876 
    877       if (skia_use_angle) {
    878         deps += [ "//third_party/angle2" ]
    879         sources += [ "tools/gpu/gl/angle/GLTestContext_angle.cpp" ]
    880       }
    881       if (skia_use_mesa) {
    882         public_defines += [ "SK_MESA" ]
    883         sources += [ "tools/gpu/gl/mesa/GLTestContext_mesa.cpp" ]
    884         libs += [ "OSMesa" ]
    885       }
    886       if (skia_use_vulkan) {
    887         sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
    888       }
    889     }
    890   }
    891 
    892   test_lib("flags") {
    893     public_include_dirs = [ "tools/flags" ]
    894     sources = [
    895       "tools/flags/SkCommandLineFlags.cpp",
    896     ]
    897   }
    898   test_lib("common_flags") {
    899     public_include_dirs = [ "tools/flags" ]
    900     sources = [
    901       "tools/flags/SkCommonFlags.cpp",
    902       "tools/flags/SkCommonFlagsConfig.cpp",
    903     ]
    904     deps = [
    905       ":flags",
    906       ":gpu_tool_utils",
    907     ]
    908   }
    909 
    910   test_lib("tool_utils") {
    911     public_include_dirs = [
    912       "tools",
    913       "tools/debugger",
    914       "tools/timer",
    915     ]
    916     sources = [
    917       "src/utils/SkMultiPictureDocumentReader.cpp",  # TODO(halcanary): move to tools?
    918       "tools/AndroidSkDebugToStdOut.cpp",
    919       "tools/CrashHandler.cpp",
    920       "tools/LsanSuppressions.cpp",
    921       "tools/ProcStats.cpp",
    922       "tools/Resources.cpp",
    923       "tools/ThermalManager.cpp",
    924       "tools/UrlDataManager.cpp",
    925       "tools/debugger/SkDebugCanvas.cpp",
    926       "tools/debugger/SkDrawCommand.cpp",
    927       "tools/debugger/SkJsonWriteBuffer.cpp",
    928       "tools/debugger/SkObjectParser.cpp",
    929       "tools/picture_utils.cpp",
    930       "tools/random_parse_path.cpp",
    931       "tools/sk_tool_utils.cpp",
    932       "tools/sk_tool_utils_font.cpp",
    933       "tools/timer/Timer.cpp",
    934     ]
    935     libs = []
    936     if (is_ios) {
    937       sources += [ "tools/ios_utils.m" ]
    938       libs += [ "Foundation.framework" ]
    939     }
    940     deps = [
    941       ":common_flags",
    942       ":flags",
    943       "//third_party/libpng",
    944     ]
    945     public_deps = [
    946       "//third_party/jsoncpp",
    947     ]
    948   }
    949 
    950   import("gn/gm.gni")
    951   test_lib("gm") {
    952     public_include_dirs = [ "gm" ]
    953     sources = gm_sources
    954     deps = [
    955       ":flags",
    956       ":gpu_tool_utils",
    957       ":skia",
    958       ":tool_utils",
    959     ]
    960   }
    961 
    962   import("gn/tests.gni")
    963   test_lib("tests") {
    964     public_include_dirs = [ "tests" ]
    965     sources = tests_sources + pathops_tests_sources
    966     if (!fontmgr_android_enabled) {
    967       sources -= [ "//tests/FontMgrAndroidParserTest.cpp" ]
    968     }
    969     deps = [
    970       ":experimental_svg_model",
    971       ":flags",
    972       ":skia",
    973       ":tool_utils",
    974       "//third_party/libpng",
    975       "//third_party/zlib",
    976     ]
    977     public_deps = [
    978       ":gpu_tool_utils",  # Test.h #includes headers from this target.
    979     ]
    980   }
    981 
    982   import("gn/bench.gni")
    983   test_lib("bench") {
    984     public_include_dirs = [ "bench" ]
    985     sources = bench_sources
    986     deps = [
    987       ":flags",
    988       ":gm",
    989       ":gpu_tool_utils",
    990       ":skia",
    991       ":tool_utils",
    992     ]
    993   }
    994 
    995   test_lib("experimental_svg_model") {
    996     public_include_dirs = [ "experimental/svg/model" ]
    997     sources = [
    998       "experimental/svg/model/SkSVGAttribute.cpp",
    999       "experimental/svg/model/SkSVGAttributeParser.cpp",
   1000       "experimental/svg/model/SkSVGCircle.cpp",
   1001       "experimental/svg/model/SkSVGClipPath.cpp",
   1002       "experimental/svg/model/SkSVGContainer.cpp",
   1003       "experimental/svg/model/SkSVGDOM.cpp",
   1004       "experimental/svg/model/SkSVGEllipse.cpp",
   1005       "experimental/svg/model/SkSVGLine.cpp",
   1006       "experimental/svg/model/SkSVGLinearGradient.cpp",
   1007       "experimental/svg/model/SkSVGNode.cpp",
   1008       "experimental/svg/model/SkSVGPath.cpp",
   1009       "experimental/svg/model/SkSVGPoly.cpp",
   1010       "experimental/svg/model/SkSVGRect.cpp",
   1011       "experimental/svg/model/SkSVGRenderContext.cpp",
   1012       "experimental/svg/model/SkSVGSVG.cpp",
   1013       "experimental/svg/model/SkSVGShape.cpp",
   1014       "experimental/svg/model/SkSVGStop.cpp",
   1015       "experimental/svg/model/SkSVGTransformableNode.cpp",
   1016       "experimental/svg/model/SkSVGValue.cpp",
   1017     ]
   1018     deps = [
   1019       ":skia",
   1020     ]
   1021   }
   1022 
   1023   test_lib("views") {
   1024     public_include_dirs = [ "include/views" ]
   1025     sources = [
   1026       "src/views/SkEvent.cpp",
   1027       "src/views/SkEventSink.cpp",
   1028       "src/views/SkOSMenu.cpp",
   1029       "src/views/SkTagList.cpp",
   1030       "src/views/SkTouchGesture.cpp",
   1031       "src/views/SkView.cpp",
   1032       "src/views/SkViewPriv.cpp",
   1033     ]
   1034     libs = []
   1035     deps = []
   1036     if (!is_android) {
   1037       sources += [ "src/views/SkWindow.cpp" ]
   1038     }
   1039     if (is_linux) {
   1040       public_include_dirs += [ "src/views/unix" ]
   1041       sources += [
   1042         "src/views/unix/SkOSWindow_Unix.cpp",
   1043         "src/views/unix/keysym2ucs.c",
   1044       ]
   1045       libs += [
   1046         "GL",
   1047         "X11",
   1048       ]
   1049     } else if (is_mac) {
   1050       sources += [
   1051         "src/views/mac/SkEventNotifier.mm",
   1052         "src/views/mac/SkNSView.mm",
   1053         "src/views/mac/SkOSWindow_Mac.mm",
   1054         "src/views/mac/SkTextFieldCell.m",
   1055       ]
   1056       libs += [
   1057         "QuartzCore.framework",
   1058         "Cocoa.framework",
   1059         "Foundation.framework",
   1060       ]
   1061     } else if (is_win) {
   1062       sources += [ "src/views/win/SkOSWindow_win.cpp" ]
   1063     }
   1064     if (skia_use_angle) {
   1065       deps += [ "//third_party/angle2" ]
   1066     }
   1067   }
   1068 
   1069   if (skia_use_lua) {
   1070     test_lib("lua") {
   1071       public_include_dirs = []
   1072       sources = [
   1073         "src/utils/SkLua.cpp",
   1074         "src/utils/SkLuaCanvas.cpp",
   1075       ]
   1076       deps = [
   1077         "//third_party/lua",
   1078       ]
   1079     }
   1080 
   1081     test_app("lua_app") {
   1082       sources = [
   1083         "tools/lua/lua_app.cpp",
   1084       ]
   1085       deps = [
   1086         ":lua",
   1087         ":skia",
   1088         "//third_party/lua",
   1089       ]
   1090     }
   1091 
   1092     test_app("lua_pictures") {
   1093       sources = [
   1094         "tools/lua/lua_pictures.cpp",
   1095       ]
   1096       deps = [
   1097         ":flags",
   1098         ":lua",
   1099         ":skia",
   1100         ":tool_utils",
   1101         "//third_party/lua",
   1102       ]
   1103     }
   1104   }
   1105 
   1106   import("gn/samples.gni")
   1107   test_lib("samples") {
   1108     public_include_dirs = [ "samplecode" ]
   1109     include_dirs = [ "experimental" ]
   1110     sources = samples_sources + [
   1111                 "experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp",
   1112                 "experimental/SkSetPoly3To3.cpp",
   1113                 "experimental/SkSetPoly3To3_A.cpp",
   1114                 "experimental/SkSetPoly3To3_D.cpp",
   1115               ]
   1116     deps = [
   1117       ":experimental_svg_model",
   1118       ":flags",
   1119       ":gm",
   1120       ":tool_utils",
   1121       ":views",
   1122       ":xml",
   1123     ]
   1124 
   1125     if (skia_use_lua) {
   1126       sources += [ "samplecode/SampleLua.cpp" ]
   1127       deps += [
   1128         ":lua",
   1129         "//third_party/lua",
   1130       ]
   1131     }
   1132   }
   1133 
   1134   test_app("dm") {
   1135     sources = [
   1136       "dm/DM.cpp",
   1137       "dm/DMJsonWriter.cpp",
   1138       "dm/DMSrcSink.cpp",
   1139     ]
   1140     include_dirs = [ "tests" ]
   1141     deps = [
   1142       ":common_flags",
   1143       ":experimental_svg_model",
   1144       ":flags",
   1145       ":gm",
   1146       ":gpu_tool_utils",
   1147       ":skia",
   1148       ":tests",
   1149       ":tool_utils",
   1150       "//third_party/jsoncpp",
   1151       "//third_party/libpng",
   1152     ]
   1153   }
   1154 
   1155   test_app("ok") {
   1156     sources = [
   1157       "tools/ok.cpp",
   1158       "tools/ok_dsts.cpp",
   1159       "tools/ok_srcs.cpp",
   1160       "tools/ok_test.cpp",
   1161       "tools/ok_vias.cpp",
   1162     ]
   1163     deps = [
   1164       ":gm",
   1165       ":skia",
   1166       ":tests",
   1167     ]
   1168   }
   1169 
   1170   if (!is_debug) {  # I've benchmarked debug code once too many times...
   1171     test_app("monobench") {
   1172       sources = [
   1173         "tools/monobench.cpp",
   1174       ]
   1175       deps = [
   1176         ":bench",
   1177         ":skia",
   1178       ]
   1179     }
   1180   }
   1181 
   1182   test_app("nanobench") {
   1183     sources = [
   1184       "bench/nanobench.cpp",
   1185     ]
   1186     deps = [
   1187       ":bench",
   1188       ":common_flags",
   1189       ":experimental_svg_model",
   1190       ":flags",
   1191       ":gm",
   1192       ":gpu_tool_utils",
   1193       ":skia",
   1194       ":tool_utils",
   1195       "//third_party/jsoncpp",
   1196     ]
   1197   }
   1198 
   1199   test_app("skpinfo") {
   1200     sources = [
   1201       "tools/skpinfo.cpp",
   1202     ]
   1203     deps = [
   1204       ":flags",
   1205       ":skia",
   1206     ]
   1207   }
   1208 
   1209   if (is_linux || is_win || is_mac) {
   1210     test_app("SampleApp") {
   1211       sources = [
   1212         "samplecode/SampleApp.cpp",
   1213         "samplecode/SamplePictFile.cpp",
   1214       ]
   1215       if (is_mac) {
   1216         sources += [ "src/views/mac/skia_mac.mm" ]
   1217       } else if (is_win) {
   1218         sources += [ "src/views/win/skia_win.cpp" ]
   1219       } else if (is_linux) {
   1220         sources += [ "src/views/unix/skia_unix.cpp" ]
   1221       }
   1222       deps = [
   1223         ":flags",
   1224         ":gm",
   1225         ":gpu_tool_utils",
   1226         ":samples",
   1227         ":skia",
   1228         ":tool_utils",
   1229         ":views",
   1230       ]
   1231       if (skia_use_angle) {
   1232         deps += [ "//third_party/angle2" ]
   1233       }
   1234     }
   1235   }
   1236 
   1237   if (skia_enable_gpu) {
   1238     test_app("skpbench") {
   1239       sources = [
   1240         "tools/skpbench/skpbench.cpp",
   1241       ]
   1242       deps = [
   1243         ":flags",
   1244         ":gpu_tool_utils",
   1245         ":skia",
   1246         ":tool_utils",
   1247       ]
   1248     }
   1249   }
   1250 
   1251   # We can't yet build ICU on iOS or Windows.
   1252   if (!is_ios && !is_win) {
   1253     test_app("sktexttopdf-hb") {
   1254       sources = [
   1255         "tools/SkShaper_harfbuzz.cpp",
   1256         "tools/using_skia_and_harfbuzz.cpp",
   1257       ]
   1258       deps = [
   1259         ":skia",
   1260         "//third_party/harfbuzz",
   1261       ]
   1262     }
   1263   }
   1264   test_app("sktexttopdf") {
   1265     sources = [
   1266       "tools/SkShaper_primitive.cpp",
   1267       "tools/using_skia_and_harfbuzz.cpp",
   1268     ]
   1269     deps = [
   1270       ":skia",
   1271     ]
   1272   }
   1273 
   1274   test_app("get_images_from_skps") {
   1275     sources = [
   1276       "tools/get_images_from_skps.cpp",
   1277     ]
   1278     deps = [
   1279       ":flags",
   1280       ":skia",
   1281       "//third_party/jsoncpp",
   1282     ]
   1283   }
   1284 
   1285   test_app("colorspaceinfo") {
   1286     sources = [
   1287       "tools/colorspaceinfo.cpp",
   1288     ]
   1289     deps = [
   1290       ":flags",
   1291       ":skia",
   1292       ":tool_utils",
   1293     ]
   1294   }
   1295 
   1296   if (!is_ios) {
   1297     test_app("skiaserve") {
   1298       sources = [
   1299         "tools/skiaserve/Request.cpp",
   1300         "tools/skiaserve/Response.cpp",
   1301         "tools/skiaserve/skiaserve.cpp",
   1302         "tools/skiaserve/urlhandlers/BreakHandler.cpp",
   1303         "tools/skiaserve/urlhandlers/ClipAlphaHandler.cpp",
   1304         "tools/skiaserve/urlhandlers/CmdHandler.cpp",
   1305         "tools/skiaserve/urlhandlers/ColorModeHandler.cpp",
   1306         "tools/skiaserve/urlhandlers/DataHandler.cpp",
   1307         "tools/skiaserve/urlhandlers/DownloadHandler.cpp",
   1308         "tools/skiaserve/urlhandlers/EnableGPUHandler.cpp",
   1309         "tools/skiaserve/urlhandlers/ImgHandler.cpp",
   1310         "tools/skiaserve/urlhandlers/InfoHandler.cpp",
   1311         "tools/skiaserve/urlhandlers/OpBoundsHandler.cpp",
   1312         "tools/skiaserve/urlhandlers/OpsHandler.cpp",
   1313         "tools/skiaserve/urlhandlers/OverdrawHandler.cpp",
   1314         "tools/skiaserve/urlhandlers/PostHandler.cpp",
   1315         "tools/skiaserve/urlhandlers/QuitHandler.cpp",
   1316         "tools/skiaserve/urlhandlers/RootHandler.cpp",
   1317       ]
   1318       deps = [
   1319         ":flags",
   1320         ":gpu_tool_utils",
   1321         ":skia",
   1322         ":tool_utils",
   1323         "//third_party/jsoncpp",
   1324         "//third_party/libmicrohttpd",
   1325         "//third_party/libpng",
   1326       ]
   1327     }
   1328   }
   1329 
   1330   test_app("fuzz") {
   1331     sources = [
   1332       "fuzz/FilterFuzz.cpp",
   1333       "fuzz/FuzzCanvas.cpp",
   1334       "fuzz/FuzzDrawFunctions.cpp",
   1335       "fuzz/FuzzGradients.cpp",
   1336       "fuzz/FuzzParsePath.cpp",
   1337       "fuzz/FuzzPathop.cpp",
   1338       "fuzz/FuzzScaleToSides.cpp",
   1339       "fuzz/fuzz.cpp",
   1340     ]
   1341     deps = [
   1342       ":flags",
   1343       ":gpu_tool_utils",
   1344       ":skia",
   1345       ":tool_utils",
   1346     ]
   1347   }
   1348 
   1349   test_app("pathops_unittest") {
   1350     sources = pathops_tests_sources + [
   1351                 rebase_path("tests/skia_test.cpp"),
   1352                 rebase_path("tests/Test.cpp"),
   1353               ]
   1354     deps = [
   1355       ":flags",
   1356       ":gpu_tool_utils",
   1357       ":skia",
   1358       ":tool_utils",
   1359     ]
   1360   }
   1361 
   1362   test_app("dump_record") {
   1363     sources = [
   1364       "tools/DumpRecord.cpp",
   1365       "tools/dump_record.cpp",
   1366     ]
   1367     deps = [
   1368       ":flags",
   1369       ":skia",
   1370     ]
   1371   }
   1372 
   1373   test_app("skdiff") {
   1374     sources = [
   1375       "tools/skdiff/skdiff.cpp",
   1376       "tools/skdiff/skdiff_html.cpp",
   1377       "tools/skdiff/skdiff_main.cpp",
   1378       "tools/skdiff/skdiff_utils.cpp",
   1379     ]
   1380     deps = [
   1381       ":skia",
   1382       ":tool_utils",
   1383     ]
   1384   }
   1385 
   1386   test_app("skp_parser") {
   1387     sources = [
   1388       "tools/skp_parser.cpp",
   1389     ]
   1390     deps = [
   1391       ":skia",
   1392       ":tool_utils",
   1393       "//third_party/jsoncpp",
   1394     ]
   1395   }
   1396 
   1397   if (skia_enable_gpu && (is_android || is_linux || is_win || is_mac)) {
   1398     test_app("viewer") {
   1399       is_shared_library = is_android
   1400       sources = [
   1401         "tools/viewer/GMSlide.cpp",
   1402         "tools/viewer/ImageSlide.cpp",
   1403         "tools/viewer/SKPSlide.cpp",
   1404         "tools/viewer/SampleSlide.cpp",
   1405         "tools/viewer/Viewer.cpp",
   1406         "tools/viewer/sk_app/CommandSet.cpp",
   1407         "tools/viewer/sk_app/GLWindowContext.cpp",
   1408         "tools/viewer/sk_app/Window.cpp",
   1409       ]
   1410       libs = []
   1411 
   1412       if (is_android) {
   1413         sources += [
   1414           "tools/viewer/sk_app/android/GLWindowContext_android.cpp",
   1415           "tools/viewer/sk_app/android/RasterWindowContext_android.cpp",
   1416           "tools/viewer/sk_app/android/Window_android.cpp",
   1417           "tools/viewer/sk_app/android/main_android.cpp",
   1418           "tools/viewer/sk_app/android/surface_glue_android.cpp",
   1419         ]
   1420         libs += [ "android" ]
   1421       } else if (is_linux) {
   1422         sources += [
   1423           "tools/viewer/sk_app/unix/GLWindowContext_unix.cpp",
   1424           "tools/viewer/sk_app/unix/RasterWindowContext_unix.cpp",
   1425           "tools/viewer/sk_app/unix/Window_unix.cpp",
   1426           "tools/viewer/sk_app/unix/main_unix.cpp",
   1427         ]
   1428       } else if (is_win) {
   1429         sources += [
   1430           "tools/viewer/sk_app/win/GLWindowContext_win.cpp",
   1431           "tools/viewer/sk_app/win/RasterWindowContext_win.cpp",
   1432           "tools/viewer/sk_app/win/Window_win.cpp",
   1433           "tools/viewer/sk_app/win/main_win.cpp",
   1434         ]
   1435       } else if (is_mac) {
   1436         sources += [
   1437           "tools/viewer/sk_app/mac/GLWindowContext_mac.cpp",
   1438           "tools/viewer/sk_app/mac/RasterWindowContext_mac.cpp",
   1439           "tools/viewer/sk_app/mac/Window_mac.cpp",
   1440           "tools/viewer/sk_app/mac/main_mac.cpp",
   1441         ]
   1442       }
   1443 
   1444       if (skia_use_vulkan) {
   1445         sources += [ "tools/viewer/sk_app/VulkanWindowContext.cpp" ]
   1446         if (is_android) {
   1447           sources +=
   1448               [ "tools/viewer/sk_app/android/VulkanWindowContext_android.cpp" ]
   1449         } else if (is_linux) {
   1450           sources += [ "tools/viewer/sk_app/unix/VulkanWindowContext_unix.cpp" ]
   1451           libs += [ "X11-xcb" ]
   1452         } else if (is_win) {
   1453           sources += [ "tools/viewer/sk_app/win/VulkanWindowContext_win.cpp" ]
   1454         }
   1455       }
   1456 
   1457       include_dirs = []
   1458       deps = [
   1459         ":flags",
   1460         ":gm",
   1461         ":gpu_tool_utils",
   1462         ":samples",
   1463         ":skia",
   1464         ":tool_utils",
   1465         ":views",
   1466         "//third_party/imgui",
   1467         "//third_party/jsoncpp",
   1468       ]
   1469       if (is_android) {
   1470         deps += [ "//third_party/native_app_glue" ]
   1471       } else if (is_mac) {
   1472         deps += [ "//third_party/libsdl" ]
   1473       }
   1474     }
   1475   }
   1476 
   1477   if (is_android && defined(ndk) && ndk != "") {
   1478     copy("gdbserver") {
   1479       sources = [
   1480         "$ndk/$ndk_gdbserver",
   1481       ]
   1482       outputs = [
   1483         "$root_out_dir/gdbserver",
   1484       ]
   1485     }
   1486   }
   1487 
   1488   if (skia_enable_gpu) {
   1489     test_app("skslc") {
   1490       sources = [
   1491         "src/sksl/SkSLMain.cpp",
   1492       ]
   1493       deps = [
   1494         ":flags",
   1495         ":skia",
   1496       ]
   1497     }
   1498   }
   1499 }
   1500