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