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