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