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