Debian Codegraph @

BUILD.gn

raw ◀ ▶
1 Debian patch touch this file
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 import("gn/codec.gni")
6 import("gn/pathops.gni")
7 import("gn/rust.gni")
8 import("gn/shared_sources.gni")
9 import("gn/skia.gni")
•10 #import("gn/toolchain/wasm.gni")
11
12 if (defined(skia_settings)) {
13 import(skia_settings)
14 }
15
16 import("gn/ios.gni")
17 import("third_party/dawn/args.gni")
18
19 # Skia public API, generally provided by :skia.
20 config("skia_public") {
21 include_dirs = [ "." ]
22
23 defines = [
24 "SK_CODEC_DECODES_BMP",
25 "SK_CODEC_DECODES_WBMP",
26 ]
27 cflags_objcc = []
28 if (is_component_build) {
29 defines += [ "SKIA_DLL" ]
30 }
31 if (is_linux) {
32 defines += [ "SK_R32_SHIFT=16" ]
33 }
34 if (skia_enable_optimize_size) {
35 defines += [ "SK_ENABLE_OPTIMIZE_SIZE" ]
36 }
37 if (skia_enable_precompile) {
38 defines += [ "SK_ENABLE_PRECOMPILE" ]
39 }
40 if (is_wasm) {
41 defines += wasm_defines
42 }
43 if (skia_gl_standard == "gles") {
44 defines += [ "SK_ASSUME_GL_ES=1" ]
45 } else if (skia_gl_standard == "gl") {
46 defines += [ "SK_ASSUME_GL=1" ]
47 } else if (skia_gl_standard == "webgl") {
48 defines += [ "SK_ASSUME_WEBGL=1" ]
49 }
50 if (skia_enable_ganesh) {
51 defines += [ "SK_GANESH" ]
52 }
53 if (skia_enable_graphite) {
54 defines += [ "SK_GRAPHITE" ]
55 }
56 if (skia_disable_tracing) {
57 defines += [ "SK_DISABLE_TRACING" ]
58 }
59 if (skia_use_perfetto) {
60 defines += [ "SK_USE_PERFETTO" ]
61 }
62 if (!skia_disable_tracing && skia_enable_pipeline_label_tracing) {
63 defines += [ "SK_TRACE_GRAPHITE_PIPELINE_USE" ]
64 }
65 if (skia_use_safe_libcxx) {
66 defines += [ "_LIBCPP_ENABLE_ASSERTIONS=1" ]
67 }
68 if (skia_build_fuzzers) {
69 defines += [ "SK_BUILD_FOR_FUZZER" ]
70 }
71
72 # Some older versions of the Clang toolchain change the visibility of
73 # symbols decorated with API_AVAILABLE macro to be visible. Users of such
74 # toolchains suppress the use of this macro till toolchain updates are made.
75 if (is_mac || is_ios) {
76 if (skia_enable_api_available_macro) {
77 defines += [ "SK_ENABLE_API_AVAILABLE" ]
78 } else {
79 cflags_objcc += [ "-Wno-unguarded-availability" ]
80 }
81 }
82 }
83
84 # Skia internal APIs, used by Skia itself and a few test tools.
85 config("skia_private") {
86 visibility = [ "./*" ]
87
88 defines = [ "SK_GAMMA_APPLY_TO_A8" ]
89 if (skia_use_fixed_gamma_text) {
90 defines += [
91 "SK_GAMMA_EXPONENT=1.4",
92 "SK_GAMMA_CONTRAST=0.0",
93 ]
94 }
95 if (is_skia_dev_build && !is_wasm) {
96 defines += [
97 "SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=1",
98 "GPU_TEST_UTILS=1",
99 ]
100 }
101 libs = []
102 lib_dirs = []
103 if (skia_use_gl && skia_use_angle) {
104 defines += [ "SK_ANGLE" ]
105 }
106 if (skia_enable_winuwp) {
107 defines += [ "SK_WINUWP" ]
108 }
109 if (skia_print_sksl_shaders) {
110 defines += [ "SK_PRINT_SKSL_SHADERS" ]
111 }
112 if (skia_print_native_shaders) {
113 defines += [ "SK_PRINT_NATIVE_SHADERS" ]
114 }
115
116 if (skia_dump_tasks) {
117 defines += [ "SK_DUMP_TASKS" ]
118 }
119
120 # Temporary staging flag:
121 defines += [ "SK_ENABLE_AVX512_OPTS" ]
122 }
123
124 # Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
125 config("skia_library") {
126 visibility = [ "./*" ]
127 defines = [ "SKIA_IMPLEMENTATION=1" ]
128 }
129
130 skia_library_configs = [
131 ":skia_public",
132 ":skia_private",
133 ":skia_library",
134 ]
135
136 # Use for CPU-specific Skia code that needs particular compiler flags.
137 template("opts") {
138 if (invoker.enabled) {
139 skia_source_set(target_name) {
140 visibility = [ ":*" ]
141 check_includes = false
142 configs = skia_library_configs
143 forward_variables_from(invoker, "*")
144 if (defined(invoker.configs)) {
145 configs += invoker.configs
146 }
147 }
148 } else {
149 # If not enabled, a phony empty target that swallows all otherwise unused variables.
150 skia_source_set(target_name) {
151 visibility = [ ":*" ]
152 check_includes = false
153 forward_variables_from(invoker,
154 "*",
155 [
156 "sources",
157 "cflags",
158 ])
159 }
160 }
161 }
162
163 is_x86 = current_cpu == "x64" || current_cpu == "x86"
164 is_loong64 = current_cpu == "loong64"
165
166 opts("hsw") {
167 enabled = is_x86
168 sources = skia_opts.hsw_sources
169 if (is_win) {
170 cflags = [ "/arch:AVX2" ]
171 } else {
172 cflags = [ "-march=haswell" ]
173 }
174 }
175
176 opts("skx") {
177 enabled = is_x86
178 sources = skia_opts.skx_sources
179 if (is_win) {
180 cflags = [ "/arch:AVX512" ]
181 } else {
182 cflags = [ "-march=skylake-avx512" ]
183 }
184 }
185
186 opts("lasx") {
187 enabled = is_loong64
188 sources = skia_opts.lasx_sources
189 cflags = [ "-mlasx" ]
190 }
191
192 # Any feature of Skia that requires third-party code should be optional and use this template.
193 template("optional") {
194 if (invoker.enabled) {
195 config(target_name + "_public") {
196 if (defined(invoker.public_defines)) {
197 defines = invoker.public_defines
198 }
199 if (defined(invoker.public_configs)) {
200 configs = invoker.public_configs
201 }
202 }
203 skia_source_set(target_name) {
204 visibility = [ ":*" ]
205 check_includes = false
206 configs = skia_library_configs
207
208 # "*" clobbers the current scope; append to existing configs
209 forward_variables_from(invoker,
210 "*",
211 [
212 "configs",
213 "public_defines",
214 "sources_for_tests",
215 "sources_when_disabled",
216 ])
217 if (defined(invoker.configs)) {
218 configs += invoker.configs
219 }
220 all_dependent_configs = [ ":" + target_name + "_public" ]
221 }
222
223 if (defined(invoker.sources_for_tests) && skia_enable_tools) {
224 skia_source_set(target_name + "_tests") {
225 visibility = [ ":*" ]
226 check_includes = false
227 configs = skia_library_configs
228
229 # "*" clobbers the current scope; append to existing configs
230 forward_variables_from(invoker,
231 "*",
232 [
233 "configs",
234 "public_defines",
235 "sources",
236 "sources_for_tests",
237 "sources_when_disabled",
238 ])
239 if (defined(invoker.configs)) {
240 configs += invoker.configs
241 }
242 testonly = true
243 sources = invoker.sources_for_tests
244 if (!defined(deps)) {
245 deps = []
246 }
247 deps += [
248 ":test",
249 ":" + target_name,
250 ]
251 all_dependent_configs = [ ":" + target_name + "_public" ]
252 }
253 }
254 } else {
255 skia_source_set(target_name) {
256 visibility = [ ":*" ]
257 configs = skia_library_configs
258
259 # "*" clobbers the current scope; append to existing configs
260 forward_variables_from(invoker,
261 "*",
262 [
263 "configs",
264 "public",
265 "public_configs",
266 "public_defines",
267 "public_deps",
268 "deps",
269 "libs",
270 "frameworks",
271 "sources",
272 "sources_for_tests",
273 "sources_when_disabled",
274 ])
275 if (defined(invoker.configs)) {
276 configs += invoker.configs
277 }
278 if (defined(invoker.sources_when_disabled)) {
279 sources = invoker.sources_when_disabled
280 }
281 }
282
283 if (defined(invoker.sources_for_tests) && skia_enable_tools) {
284 skia_source_set(target_name + "_tests") {
285 visibility = [ ":*" ]
286 }
287 }
288 }
289 }
290
291 optional("android_utils") {
292 enabled = skia_enable_android_utils
293
294 public = [
295 "client_utils/android/BRDAllocator.h",
296 "client_utils/android/BitmapRegionDecoder.h",
297 "client_utils/android/FrontBufferedStream.h",
298 ]
299 public_defines = [ "SK_ENABLE_ANDROID_UTILS" ]
300 sources = [
301 "client_utils/android/BitmapRegionDecoder.cpp",
302 "client_utils/android/FrontBufferedStream.cpp",
303 ]
304 }
305
306 optional("fontmgr_android_parser") {
307 enabled = skia_use_expat
308
309 deps = [ "//third_party/expat" ]
310 sources = skia_ports_fontmgr_android_parser_sources
311 }
312
313 optional("fontmgr_android") {
314 enabled = skia_enable_fontmgr_android
315
316 deps = [
317 ":fontmgr_android_parser",
318 ":typeface_proxy",
319 ]
320 public_defines = [ "SK_FONTMGR_ANDROID_AVAILABLE" ]
321 public = skia_ports_fontmgr_android_public
322 sources = skia_ports_fontmgr_android_sources
323 sources_for_tests = [ "tests/FontMgrAndroidParserTest.cpp" ]
324 }
325
326 # if building Skia for API >= 30 and not using custom fonts, enable
327 # skia_enable_fontmgr_android_ndk and disable skia_enable_fontmgr_android
328 optional("fontmgr_android_ndk") {
329 enabled = skia_enable_fontmgr_android_ndk
330
331 deps = [
332 ":fontmgr_android_parser",
333 ":typeface_proxy",
334 ]
335 libs = [ "android" ]
336 if (defined(ndk_api) && ndk_api >= 31) {
337 libs += [ "icu" ]
338 }
339 public_defines = [ "SK_FONTMGR_ANDROID_NDK_AVAILABLE" ]
340 public = skia_ports_fontmgr_android_ndk_public
341 sources = skia_ports_fontmgr_android_ndk_sources
342 }
343
344 optional("fontmgr_custom") {
345 enabled =
346 skia_enable_fontmgr_custom_directory ||
347 skia_enable_fontmgr_custom_embedded || skia_enable_fontmgr_custom_empty
348
349 deps = [ ":typeface_freetype" ]
350 sources = skia_ports_fontmgr_custom_sources
351 }
352
353 optional("fontmgr_custom_directory") {
354 enabled = skia_enable_fontmgr_custom_directory
355 public_defines = [ "SK_FONTMGR_FREETYPE_DIRECTORY_AVAILABLE" ]
356 deps = [
357 ":fontmgr_custom",
358 ":typeface_freetype",
359 ]
360 public = skia_ports_fontmgr_directory_public
361 sources = skia_ports_fontmgr_directory_sources
362 }
363
364 optional("fontmgr_custom_embedded") {
365 enabled = skia_enable_fontmgr_custom_embedded
366 public_defines = [ "SK_FONTMGR_FREETYPE_EMBEDDED_AVAILABLE" ]
367 deps = [
368 ":fontmgr_custom",
369 ":typeface_freetype",
370 ]
371 public = skia_ports_fontmgr_embedded_public
372 sources = skia_ports_fontmgr_embedded_sources
373 }
374
375 optional("fontmgr_custom_empty") {
376 enabled = skia_enable_fontmgr_custom_empty
377 public_defines = [ "SK_FONTMGR_FREETYPE_EMPTY_AVAILABLE" ]
378 deps = [
379 ":fontmgr_custom",
380 ":typeface_freetype",
381 ]
382 public = skia_ports_fontmgr_empty_public
383 sources = skia_ports_fontmgr_empty_sources
384 }
385
386 skia_source_set("typeface_proxy") {
387 configs = [ ":skia_public" ]
388 sources = skia_ports_typeface_proxy_sources
389 }
390
391 optional("fontmgr_fontconfig") {
392 enabled = skia_enable_fontmgr_fontconfig
393 public_defines = [ "SK_FONTMGR_FONTCONFIG_AVAILABLE" ]
394
395 # The public header includes fontconfig.h and uses FcConfig*
396 public_deps = [ "//third_party:fontconfig" ]
397 public = skia_ports_fontmgr_fontconfig_public
398 deps = [ ":typeface_proxy" ]
399 sources = skia_ports_fontmgr_fontconfig_sources
400 sources_for_tests = [ "tests/FontMgrFontConfigTest.cpp" ]
401 }
402
403 skia_source_set("fontscanner_tests") {
404 testonly = true
405
406 deps = [ ":skia" ]
407 sources = [
408 "tests/FontScanner.cpp",
409 "tests/FontScanner.h",
410 ]
411 }
412
413 optional("fontmgr_FontConfigInterface") {
414 enabled = skia_enable_fontmgr_FontConfigInterface
415 public_defines = [ "SK_FONTMGR_FCI_AVAILABLE" ]
416 deps = [ "//third_party:fontconfig" ]
417 public = skia_ports_fci_public
418 sources = skia_ports_fci_sources
419 sources_for_tests = [ "tests/FCITest.cpp" ]
420 }
421
422 optional("fontmgr_fontations_empty") {
423 enabled = skia_use_fontations
424 public_defines = [ "SK_FONTMGR_FONTATIONS_AVAILABLE" ]
425
426 deps = [ ":typeface_fontations" ]
427 public = skia_ports_fontmgr_fontations_public
428 sources = skia_ports_fontmgr_fontations_sources
429 }
430
431 optional("fontmgr_mac_ct") {
432 enabled = skia_use_fonthost_mac
433
434 public_defines = [
435 "SK_TYPEFACE_FACTORY_CORETEXT",
436 "SK_FONTMGR_CORETEXT_AVAILABLE",
437 ]
438 public = skia_ports_fontmgr_coretext_public
439 sources = skia_ports_fontmgr_coretext_sources
440 sources_for_tests = [ "tests/TypefaceMacTest.cpp" ]
441
442 if (is_mac) {
443 frameworks = [
444 # AppKit symbols NSFontWeightXXX may be dlsym'ed.
445 "AppKit.framework",
446 "ApplicationServices.framework",
447 ]
448 }
449
450 if (is_ios) {
451 frameworks = [
452 "CoreFoundation.framework",
453 "CoreGraphics.framework",
454 "CoreText.framework",
455
456 # UIKit symbols UIFontWeightXXX may be dlsym'ed.
457 "UIKit.framework",
458 ]
459 }
460 }
461
462 optional("fontmgr_win") {
463 enabled = skia_enable_fontmgr_win
464
465 public_defines = [
466 "SK_TYPEFACE_FACTORY_DIRECTWRITE",
467 "SK_FONTMGR_DIRECTWRITE_AVAILABLE",
468 ]
469 public = skia_ports_windows_fonts_public
470 sources = skia_ports_windows_fonts_sources
471 if (skia_dwritecore_sdk != "") {
472 defines = [ "DWRITE_CORE" ]
473 if (is_win && is_clang) {
474 # Clang complains about these headers, so mark them as system. These
475 # headers are hiding SDK headers of the same name, which are also
476 # included as system headers, so these need to go first in the cflags
477 # "includes" before the SDK. gn appends configs in the order listed,
478 # so these flags will be first.
479 cflags = [
480 "-imsvc",
481 "${skia_dwritecore_sdk}/include",
482 ]
483 } else {
484 include_dirs = [ "${skia_dwritecore_sdk}/include" ]
485 }
486 }
487 }
488
489 optional("fontmgr_win_gdi") {
490 enabled = skia_enable_fontmgr_win_gdi
491 public_defines = [ "SK_FONTMGR_GDI_AVAILABLE" ]
492 public = skia_ports_windows_fonts_public
493 sources = skia_ports_fonthost_win_sources
494 libs = [ "Gdi32.lib" ]
495 }
496
497 if (skia_lex) {
498 skia_executable("sksllex") {
499 sources = [
500 "src/sksl/lex/DFA.h",
501 "src/sksl/lex/DFAState.h",
502 "src/sksl/lex/LexUtil.h",
503 "src/sksl/lex/Main.cpp",
504 "src/sksl/lex/NFA.cpp",
505 "src/sksl/lex/NFA.h",
506 "src/sksl/lex/NFAState.h",
507 "src/sksl/lex/NFAtoDFA.h",
508 "src/sksl/lex/RegexNode.cpp",
509 "src/sksl/lex/RegexNode.h",
510 "src/sksl/lex/RegexParser.cpp",
511 "src/sksl/lex/RegexParser.h",
512 "src/sksl/lex/TransitionTable.cpp",
513 "src/sksl/lex/TransitionTable.h",
514 ]
515 include_dirs = [ "." ]
516 }
517
518 action("run_sksllex") {
519 script = "gn/run_sksllex.py"
520 deps = [ ":sksllex(//gn/toolchain:$host_toolchain)" ]
521 sources = [ "src/sksl/lex/sksl.lex" ]
522
523 # GN insists its outputs should go somewhere underneath target_out_dir, so we trick it with a
524 # path that starts with target_out_dir and then uses ".." to back up into the src dir.
525 outputs = [
526 "$target_out_dir/" + rebase_path("src/sksl/SkSLLexer.h", target_out_dir),
527 # the script also modifies the corresponding .cpp file, but if we tell GN that it gets
528 # confused due to the same file being named by two different paths
529 ]
530 sksllex_path = "$root_out_dir/"
531 if (host_toolchain != default_toolchain_name) {
532 sksllex_path += "$host_toolchain/"
533 }
534 sksllex_path += "sksllex"
535 if (host_os == "win") {
536 sksllex_path += ".exe"
537 }
538 args = [
539 rebase_path(sksllex_path),
540 rebase_path("bin/clang-format"),
541 rebase_path("bin/fetch-clang-format"),
542 rebase_path("src"),
543 ]
544 }
545 } else {
546 group("run_sksllex") {
547 }
548 }
549
550 if (skia_compile_modules || skia_compile_sksl_tests) {
551 # Copy the module source files into the same directory as skslc.
552 copy("sksl_modules") {
553 sources = [
554 "src/sksl/sksl_compute.sksl",
555 "src/sksl/sksl_frag.sksl",
556 "src/sksl/sksl_gpu.sksl",
557 "src/sksl/sksl_graphite_frag.sksl",
558 "src/sksl/sksl_graphite_vert.sksl",
559 "src/sksl/sksl_public.sksl",
560 "src/sksl/sksl_rt_shader.sksl",
561 "src/sksl/sksl_shared.sksl",
562 "src/sksl/sksl_vert.sksl",
563 ]
564 skslc_dir = "$root_out_dir/"
565 if (host_toolchain != default_toolchain_name) {
566 skslc_dir += "$host_toolchain/"
567 }
568 outputs = [ "$skslc_dir/{{source_file_part}}" ]
569 }
570 }
571
572 if (skia_compile_modules) {
573 # Generate the sksl-minify binary.
574 skia_executable("sksl-minify") {
575 defines = [
576 "SKSL_STANDALONE",
577 "SK_DISABLE_TRACING",
578 ]
579 sources = skslc_deps
580 sources += [
581 "tools/sksl-minify/SkSLMinify.cpp",
582 "tools/skslc/ProcessWorklist.cpp",
583 "tools/skslc/ProcessWorklist.h",
584 ]
585 libs = []
586 if (is_win) {
587 sources += [ "src/utils/SkGetExecutablePath_win.cpp" ]
588 } else if (is_mac || is_ios) {
589 sources += [ "src/utils/SkGetExecutablePath_mac.cpp" ]
590 } else if (is_linux || is_android) {
591 sources += [ "src/utils/SkGetExecutablePath_linux.cpp" ]
592 }
593 if (is_win) {
594 sources += skia_ports_windows_sources
595 } else {
596 sources += [ "src/ports/SkOSFile_posix.cpp" ]
597 libs += [ "dl" ]
598 }
599 sources += skia_sksl_core_sources
600 sources += skia_sksl_codegen_sources
601 include_dirs = [ "." ]
602 deps = [ ":run_sksllex" ]
603 }
604
605 sksl_minify_path = "$root_out_dir/"
606 if (host_toolchain != default_toolchain_name) {
607 sksl_minify_path += "$host_toolchain/"
608 }
609 sksl_minify_path += "sksl-minify"
610 if (host_os == "win") {
611 sksl_minify_path += ".exe"
612 }
613
614 # Use minify_sksl.py to precompile all of the modules.
615 minify_sksl_sources = get_target_outputs(":sksl_modules")
616
617 minify_sksl_outputs = []
618 foreach(src, minify_sksl_sources) {
619 name = get_path_info(src, "name")
620
621 # GN insists its outputs should go somewhere underneath target_out_dir, so we trick it with a
622 # path that starts with target_out_dir and then uses ".." to back up into the src dir.
623 minify_sksl_outputs += [ "$target_out_dir/" + rebase_path(
624 "src/sksl/generated/$name.minified.sksl",
625 target_out_dir) ]
626 minify_sksl_outputs += [ "$target_out_dir/" + rebase_path(
627 "src/sksl/generated/$name.unoptimized.sksl",
628 target_out_dir) ]
629 }
630
631 action("minify_sksl") {
632 script = "gn/minify_sksl.py"
633 deps = [
634 ":sksl-minify(//gn/toolchain:$host_toolchain)",
635 ":sksl_modules",
636 ]
637 sources = minify_sksl_sources
638 outputs = minify_sksl_outputs
639 args = [
640 rebase_path(sksl_minify_path),
641 rebase_path("src/sksl/generated"),
642 ]
643 args += rebase_path(minify_sksl_sources)
644 }
645
646 if (skia_compile_sksl_tests) {
647 # Minify our existing .rts files into golden minified outputs.
648 import("gn/sksl_tests.gni")
649 action("minify_sksl_tests") {
650 script = "gn/minify_sksl_tests.py"
651 deps = [
652 ":sksl-minify(//gn/toolchain:$host_toolchain)",
653 ":sksl_modules",
654 ]
655 sources = []
656 outputs = []
657 response_file_contents = []
658 args = [
659 # Comments match the variable names in minify_sksl_tests.py
660 rebase_path(sksl_minify_path), # sksl_minify
661 rebase_path("src/sksl/sksl_shared.sksl"), # shared_module
662 rebase_path("src/sksl/sksl_public.sksl"), # public_module
663 rebase_path("src/sksl/sksl_rt_shader.sksl"), # public_module
664 rebase_path("resources"), # input_root_dir
665 rebase_path("tests"), # output_root_dir
666 "{{response_file_name}}", # input_file
667 ]
668
669 testsDir = get_path_info("tests/sksl/", "abspath")
670 resourcesDir = get_path_info("resources/sksl/", "abspath")
671
672 foreach(partialPath, sksl_minify_tests_sources) {
673 dst = testsDir + partialPath
674 src = resourcesDir + partialPath
675
676 dir = get_path_info(dst, "dir")
677 name = get_path_info(dst, "name")
678 ext = get_path_info(dst, "extension")
679 if (ext == "rts" || ext == "privrts" || ext == "rtcf" || ext == "rtb" ||
680 ext == "mfrag" || ext == "mvert") {
681 response_file_contents += [ rebase_path(src) ]
682 sources += [ src ]
683 outputs += [ target_out_dir + "/" +
684 rebase_path(dir + "/" + name + ".minified.sksl",
685 target_out_dir) ]
686 }
687 }
688 }
689 }
690 } else {
691 group("minify_sksl") {
692 }
693 group("minify_sksl_tests") {
694 }
695 }
696
697 # `Compile SkSL Tests` relies on skslc and the precompiled modules.
698 if (skia_compile_sksl_tests) {
699 # Build skslc.
700 skia_executable("skslc") {
701 defines = [
702 "SKSL_STANDALONE",
703 "SK_DISABLE_TRACING",
704 "SK_COMPILE_WITH_GN",
705 ]
706 sources = skslc_deps
707 sources += [
708 "tools/skslc/Main.cpp",
709 "tools/skslc/ProcessWorklist.cpp",
710 "tools/skslc/ProcessWorklist.h",
711 ]
712 libs = []
713 if (is_win) {
714 sources += [ "src/utils/SkGetExecutablePath_win.cpp" ]
715 } else if (is_mac || is_ios) {
716 sources += [ "src/utils/SkGetExecutablePath_mac.cpp" ]
717 } else if (is_linux || is_android) {
718 sources += [ "src/utils/SkGetExecutablePath_linux.cpp" ]
719 }
720 if (is_win) {
721 sources += skia_ports_windows_sources
722 } else {
723 sources += [ "src/ports/SkOSFile_posix.cpp" ]
724 libs += [ "dl" ]
725 }
726 sources += skia_sksl_codegen_sources
727 sources += skia_sksl_core_sources
728 sources += skia_sksl_hlsl_sources
729 sources += skia_sksl_pipeline_sources
730 sources += skia_sksl_tracing_sources
731 sources += skia_sksl_validate_spirv_sources
732 sources += skia_sksl_validate_wgsl_sources
733 include_dirs = [ "." ]
734 deps = [
735 ":run_sksllex",
736 "//third_party/dawn:tint",
737 "//third_party/externals/spirv-tools:spvtools",
738 "//third_party/externals/spirv-tools:spvtools_val",
739 "//third_party/spirv-cross:spirv_cross",
740 ]
741 }
742
743 skslc_path = "$root_out_dir/"
744 if (host_toolchain != default_toolchain_name) {
745 skslc_path += "$host_toolchain/"
746 }
747 skslc_path += "skslc"
748 if (host_os == "win") {
749 skslc_path += ".exe"
750 }
751
752 # Build the test files using skslc.
753 import("gn/sksl_tests.gni")
754 template("compile_sksl") {
755 # Compile the passed-in `sources` into `outputs` using skslc, with the given language/settings.
756 action("compile_sksl_${target_name}") {
757 script = "gn/compile_sksl_tests.py"
758 deps = [
759 ":sksl_modules",
760 ":skslc(//gn/toolchain:$host_toolchain)",
761 ]
762 sources = []
763 outputs = []
764 response_file_contents = []
765 args = [
766 # Comments are the variable name in compile_sksl_tests.py
767 rebase_path(skslc_path), # skslc
768 invoker.lang, # lang
769 invoker.settings, # settings
770 rebase_path("resources"), # input_root_dir
771 rebase_path("tests"), # output_root_dir
772 "{{response_file_name}}", # input_file
773 ]
774
775 testsDir = get_path_info("tests/sksl/", "abspath")
776 resourcesDir = get_path_info("resources/sksl/", "abspath")
777
778 foreach(partialPath, invoker.sources) {
779 dst = testsDir + partialPath
780 src = resourcesDir + partialPath
781
782 dir = get_path_info(dst, "dir")
783 name = get_path_info(dst, "name")
784 ext = get_path_info(dst, "extension")
785 response_file_contents += [ rebase_path(src) ]
786 sources += [ src ]
787
788 foreach(outExtension, invoker.outExtensions) {
789 # SPIR-V uses separate extensions for .vert and .compute shaders.
790 if (ext == "vert" && outExtension == ".asm.frag") {
791 outExtension = ".asm.vert"
792 } else if (ext == "compute" && outExtension == ".asm.frag") {
793 outExtension = ".asm.comp"
794 }
795 outputs +=
796 [ target_out_dir + "/" +
797 rebase_path(dir + "/" + name + outExtension, target_out_dir) ]
798 }
799 }
800 }
801 }
802 compile_sksl("glsl_tests") {
803 sources = sksl_glsl_tests_sources + sksl_glsl_settings_tests_sources
804 outExtensions = [ ".glsl" ]
805 lang = "--glsl"
806 settings = "--settings"
807 }
808 compile_sksl("glsl_nosettings_tests") {
809 sources = sksl_glsl_settings_tests_sources
810 outExtensions = [ "StandaloneSettings.glsl" ]
811 lang = "--glsl"
812 settings = "--nosettings"
813 }
814 compile_sksl("metal_tests") {
815 sources = sksl_metal_tests_sources
816 outExtensions = [ ".metal" ]
817 lang = "--metal"
818 settings = "--settings"
819 }
820 compile_sksl("hlsl_tests") {
821 sources = sksl_hlsl_tests_sources
822 outExtensions = [ ".hlsl" ]
823 lang = "--hlsl"
824 settings = "--settings"
825 }
826 compile_sksl("skrp_tests") {
827 sources = sksl_skrp_tests_sources
828 outExtensions = [ ".skrp" ]
829 lang = "--skrp"
830 settings = "--settings"
831 }
832 compile_sksl("stage_tests") {
833 sources = sksl_stage_tests_sources
834 outExtensions = [ ".stage" ]
835 lang = "--stage"
836 settings = "--settings"
837 }
838 compile_sksl("spirv_tests") {
839 sources = sksl_spirv_tests_sources
840 outExtensions = [ ".asm.frag" ]
841 lang = "--spirv"
842 settings = "--settings"
843 }
844 compile_sksl("wgsl_tests") {
845 sources = sksl_wgsl_tests_sources
846 outExtensions = [ ".wgsl" ]
847 lang = "--wgsl"
848 settings = "--settings"
849 }
850 } else {
851 group("compile_sksl_glsl_tests") {
852 }
853 group("compile_sksl_glsl_nosettings_tests") {
854 }
855 group("compile_sksl_metal_tests") {
856 }
857 group("compile_sksl_hlsl_tests") {
858 }
859 group("compile_sksl_skrp_tests") {
860 }
861 group("compile_sksl_spirv_tests") {
862 }
863 group("compile_sksl_wgsl_tests") {
864 }
865 }
866
867 group("compile_all_sksl_tests") {
868 deps = [
869 ":compile_sksl_glsl_nosettings_tests",
870 ":compile_sksl_glsl_tests",
871 ":compile_sksl_hlsl_tests",
872 ":compile_sksl_metal_tests",
873 ":compile_sksl_skrp_tests",
874 ":compile_sksl_spirv_tests",
875 ":compile_sksl_wgsl_tests",
876 ]
877 }
878
879 optional("gpu_shared") {
880 enabled = skia_enable_ganesh || skia_enable_graphite
881
882 configs = []
883 deps = []
884 libs = []
885 public_defines = []
886 public_deps = []
887 frameworks = []
888
889 sources = skia_shared_gpu_sources
890 sources += skia_sksl_pipeline_sources
891 sources += skia_sksl_codegen_sources
892
893 if (skia_use_dawn) {
894 public_defines += [ "SK_DAWN" ]
895 public_deps += [ "//third_party/dawn" ]
896 }
897
898 if (skia_use_direct3d) {
899 sources += skia_sksl_hlsl_sources
900 deps += [ "//third_party/spirv-cross:spirv_cross" ]
901 }
902
903 if (skia_use_vulkan) {
904 public_defines += [ "SK_VULKAN" ]
905 sources += skia_shared_vk_sources
906 configs += [ ":use_skia_vulkan_headers" ]
907 if (skia_enable_vulkan_debug_layers) {
908 public_defines += [ "SK_ENABLE_VK_LAYERS" ]
909 }
910 if (skia_use_vma) {
911 sources += skia_vma_sources
912 public_deps += [ "src/gpu/vk/vulkanmemoryallocator" ]
913 }
914 }
915
916 if (skia_use_metal) {
917 public_defines += [ "SK_METAL" ]
918 sources += skia_shared_mtl_sources
919 }
920
921 if (is_android) {
922 sources += skia_shared_android_sources
923 }
924 }
925
926 optional("gpu") {
927 enabled = skia_enable_ganesh
928 deps = [
929 ":gpu_shared",
930 ":minify_sksl",
931 ":run_sksllex",
932 ]
933 if (skia_generate_workarounds) {
934 deps += [ ":workaround_list" ]
935 }
936 configs = []
937 public_defines = []
938 public_configs = []
939 public_deps = []
940
941 public = skia_gpu_public
942 sources = skia_ganesh_private
943
944 libs = []
945 frameworks = []
946
947 if (is_android) {
948 public += skia_gpu_android_private_hdrs
949 sources += skia_gpu_android_private
950
951 # this lib is required to link against AHardwareBuffer
952 if (defined(ndk_api) && ndk_api >= 26) {
953 libs += [ "android" ]
954 }
955 }
956
957 if (skia_use_gl) {
958 public_defines += [ "SK_GL" ]
959 if (is_android) {
960 sources += [
961 "src/gpu/ganesh/gl/egl/GrGLMakeEGLInterface.cpp",
962 "src/gpu/ganesh/gl/egl/GrGLMakeNativeInterface_egl.cpp",
963 ]
964 sources += skia_android_gl_sources
965
966 # this lib is required to link against AHardwareBuffer
967 if (defined(ndk_api) && ndk_api >= 26) {
968 libs += [ "android" ]
969 }
970 } else if (skia_use_egl) {
971 if (skia_use_epoxy_egl) {
972 sources += [ "src/gpu/ganesh/gl/epoxy/GrGLMakeEpoxyEGLInterface.cpp" ]
973 libs += [ "epoxy" ]
974 } else {
975 sources += [
976 "src/gpu/ganesh/gl/egl/GrGLMakeEGLInterface.cpp",
977 "src/gpu/ganesh/gl/egl/GrGLMakeNativeInterface_egl.cpp",
978 ]
979 libs += [ "EGL" ]
980 }
981 } else if (skia_use_webgl) {
982 sources += [ "src/gpu/ganesh/gl/webgl/GrGLMakeNativeInterface_webgl.cpp" ]
983 } else if (is_linux && skia_use_x11) {
984 sources += [
985 "src/gpu/ganesh/gl/glx/GrGLMakeGLXInterface.cpp",
986 "src/gpu/ganesh/gl/glx/GrGLMakeNativeInterface_glx.cpp",
987 ]
988 libs += [ "GL" ]
989 } else if (is_mac) {
990 sources += [ "src/gpu/ganesh/gl/mac/GrGLMakeNativeInterface_mac.cpp" ]
991 } else if (is_ios) {
992 sources += [ "src/gpu/ganesh/gl/iOS/GrGLMakeNativeInterface_iOS.cpp" ]
993 } else if (is_win && !skia_enable_winuwp) {
994 sources += [
995 "src/gpu/ganesh/gl/win/GrGLMakeNativeInterface_win.cpp",
996 "src/gpu/ganesh/gl/win/GrGLMakeWinInterface.cpp",
997 ]
998 if (target_cpu != "arm64") {
999 libs += [ "OpenGL32.lib" ]
1000 }
1001 } else {
1002 sources += [ "src/gpu/ganesh/gl/GrGLMakeNativeInterface_none.cpp" ]
1003 }
1004 public += skia_gpu_gl_public
1005 sources += skia_gpu_gl_private
1006 }
1007
1008 if (skia_use_vulkan) {
1009 public += skia_gpu_vk_public
1010 sources += skia_gpu_vk_private
1011 configs += [ ":use_skia_vulkan_headers" ]
1012 if (is_android) {
1013 sources += skia_gpu_vk_android_private
1014 }
1015 }
1016
1017 if (skia_use_direct3d) {
1018 public_defines += [ "SK_DIRECT3D" ]
1019 deps += [ "//third_party/d3d12allocator" ]
1020 sources += skia_direct3d_sources
1021 if (skia_enable_direct3d_debug_layer) {
1022 public_defines += [ "SK_ENABLE_D3D_DEBUG_LAYER" ]
1023 }
1024 libs += [
1025 "d3d12.lib",
1026 "dxgi.lib",
1027 "d3dcompiler.lib",
1028 ]
1029 }
1030
1031 cflags_objcc = []
1032 if (skia_use_metal) {
1033 public_defines += [ "SK_METAL" ]
1034 public += skia_gpu_metal_public
1035 sources += skia_gpu_metal_private
1036 sources += skia_gpu_metal_cpp
1037 if (skia_enable_metal_debug_info) {
1038 public_defines += [ "SK_ENABLE_MTL_DEBUG_INFO" ]
1039 }
1040 frameworks += [ "Metal.framework" ]
1041 frameworks += [ "Foundation.framework" ]
1042 if (is_ios) {
1043 frameworks += [ "UIKit.framework" ]
1044 }
1045 cflags_objcc += [ "-fobjc-arc" ]
1046 }
1047
1048 if (is_debug || skia_build_for_debugger) {
1049 public_defines += [ "SK_ENABLE_DUMP_GPU" ]
1050 }
1051 }
1052
1053 optional("vello") {
1054 enabled = skia_enable_vello_shaders
1055 public_defines = [ "SK_ENABLE_VELLO_SHADERS" ]
1056 public_deps = [ "//third_party/vello" ]
1057 }
1058
1059 optional("avif") {
1060 enabled = skia_use_libavif
1061 public_defines = [ "SK_CODEC_DECODES_AVIF" ]
1062
1063 deps = [ "//third_party/libavif" ]
1064
1065 sources = [ "src/codec/SkAvifCodec.cpp" ]
1066 }
1067
1068 optional("crabbyavif") {
1069 enabled = skia_use_crabbyavif
1070 public_defines = [ "SK_CODEC_DECODES_AVIF" ]
1071
1072 # AVIF decoding is provided by CrabbyAvif (a Rust library). Since skia's
1073 # standalone builds do not support Rust, it is only being enabled when
1074 # building for the Android framework.
1075 # The dependency for Android is set in gn_to_bp.py
1076 deps = []
1077 sources = [ "src/codec/SkCrabbyAvifCodec.cpp" ]
1078 }
1079
1080 optional("jpeg_mpf") {
1081 enabled = skia_use_jpeg_gainmaps &&
1082 (skia_use_libjpeg_turbo_encode || skia_use_libjpeg_turbo_decode)
1083 sources = [
1084 "src/codec/SkJpegMultiPicture.cpp",
1085 "src/codec/SkJpegSegmentScan.cpp",
1086 ]
1087 }
1088
1089 optional("jpeg_decode") {
1090 enabled = skia_use_libjpeg_turbo_decode
1091 public_defines = [ "SK_CODEC_DECODES_JPEG" ]
1092
1093 deps = [ "//third_party/libjpeg-turbo:libjpeg" ]
1094 sources = [
1095 "src/codec/SkJpegCodec.cpp",
1096 "src/codec/SkJpegDecoderMgr.cpp",
1097 "src/codec/SkJpegMetadataDecoderImpl.cpp",
1098 "src/codec/SkJpegSourceMgr.cpp",
1099 "src/codec/SkJpegUtility.cpp",
1100 ]
1101 if (skia_use_jpeg_gainmaps) {
1102 # Theoretically this doesn't need to be public, but this allows gn_to_bp.py to see it, and seems
1103 # to align with other codec support. See b/265939413
1104 public_defines += [ "SK_CODEC_DECODES_JPEG_GAINMAPS" ]
1105 deps += [
1106 ":jpeg_mpf",
1107 ":xml",
1108 ]
1109 sources += skia_codec_jpeg_xmp
1110 }
1111 }
1112
1113 optional("jpeg_encode") {
1114 enabled = skia_use_libjpeg_turbo_encode && !skia_use_ndk_images
1115 public_defines = [ "SK_CODEC_ENCODES_JPEG" ]
1116
1117 deps = [ "//third_party/libjpeg-turbo:libjpeg" ]
1118 public = skia_encode_jpeg_public
1119 sources = skia_encode_jpeg_srcs
1120
1121 if (skia_use_jpeg_gainmaps) {
1122 deps += [ ":jpeg_mpf" ]
1123 sources += [ "src/encode/SkJpegGainmapEncoder.cpp" ]
1124 }
1125 }
1126
1127 optional("jpegxl_decode") {
1128 enabled = skia_use_libjxl_decode
1129 public_defines = [ "SK_CODEC_DECODES_JPEGXL" ]
1130
1131 deps = [ "//third_party/libjxl" ]
1132 sources = [ "src/codec/SkJpegxlCodec.cpp" ]
1133 }
1134
1135 optional("ndk_images") {
1136 enabled = skia_use_ndk_images
1137 public_defines = [ "SK_ENABLE_NDK_IMAGES" ]
1138 sources = [
1139 "src/ports/SkImageEncoder_NDK.cpp",
1140 "src/ports/SkImageGeneratorNDK.cpp",
1141 "src/ports/SkNDKConversions.cpp",
1142 ]
1143 libs = [ "jnigraphics" ]
1144 }
1145
1146 optional("graphite") {
1147 configs = []
1148 libs = []
1149 frameworks = []
1150 public_defines = []
1151 public_configs = []
1152
1153 enabled = skia_enable_graphite
1154 deps = [
1155 ":gpu_shared",
1156 ":vello",
1157 ]
1158 public = skia_graphite_public
1159 sources = skia_graphite_sources
1160 sources += skia_sksl_graphite_modules_sources
1161
1162 if (is_android) {
1163 sources += skia_graphite_android_private
1164 }
1165
1166 if (skia_enable_vello_shaders) {
1167 sources += skia_graphite_vello_sources
1168 }
1169
1170 if (skia_use_dawn) {
1171 public += skia_graphite_dawn_public
1172 sources += skia_graphite_dawn_sources
1173 }
1174 if (skia_use_metal) {
1175 public_defines += [ "SK_METAL" ]
1176 public += skia_graphite_mtl_public
1177 sources += skia_graphite_mtl_sources
1178 if (skia_enable_metal_debug_info) {
1179 public_defines += [ "SK_ENABLE_MTL_DEBUG_INFO" ]
1180 }
1181 frameworks += [ "Metal.framework" ]
1182 frameworks += [ "Foundation.framework" ]
1183 if (is_ios) {
1184 frameworks += [ "UIKit.framework" ]
1185 }
1186 }
1187 if (skia_use_vulkan) {
1188 public += skia_graphite_vk_public
1189 sources += skia_graphite_vk_sources
1190 configs += [ ":use_skia_vulkan_headers" ]
1191 if (skia_enable_precompile) {
1192 public += skia_graphite_vk_precompile_public
1193 sources += skia_graphite_vk_precompile_sources
1194 }
1195 if (is_debug) {
1196 sources += skia_sksl_validate_spirv_sources
1197 deps += [
1198 "//third_party/externals/spirv-tools:spvtools",
1199
1200 #spvtools depends on this but doesn't deps it in.
1201 "//third_party/externals/spirv-tools:spvtools_val",
1202 ]
1203 }
1204 }
1205 if (skia_enable_precompile) {
1206 public += skia_graphite_precompile_public
1207 sources += skia_graphite_precompile_sources
1208 }
1209 if (is_debug) {
1210 public_defines += [ "SK_PIPELINE_LIFETIME_LOGGING" ]
1211 }
1212 }
1213
1214 skia_source_set("pathops") {
1215 configs = skia_library_configs
1216 public = skia_pathops_public
1217 sources = skia_pathops_sources
1218 deps = [ ":core" ]
1219 }
1220
1221 skia_source_set("clipstack_utils") {
1222 configs = skia_library_configs
1223 sources = skia_clipstack_utils_sources
1224 deps = [
1225 ":core",
1226 ":pathops",
1227 ]
1228 }
1229
1230 optional("pdf") {
1231 enabled = skia_use_zlib && skia_enable_pdf
1232 public_defines = [ "SK_SUPPORT_PDF" ]
1233
1234 deps = [
1235 ":clipstack_utils",
1236 ":pathops",
1237 "//third_party/zlib",
1238 ]
1239 public = skia_pdf_public
1240 sources = skia_pdf_sources
1241 sources_when_disabled = [ "src/pdf/SkDocument_PDF_None.cpp" ]
1242 if (skia_pdf_subset_harfbuzz) {
1243 deps += [ "//third_party/harfbuzz" ]
1244 defines = [ "SK_PDF_USE_HARFBUZZ_SUBSET" ]
1245 }
1246 }
1247
1248 optional("pdf_jpeg_helpers") {
1249 enabled = skia_use_zlib && skia_enable_pdf && skia_use_libjpeg_turbo_decode &&
1250 skia_use_libjpeg_turbo_encode
1251 deps = [
1252 ":jpeg_decode",
1253 ":jpeg_encode",
1254 ":pdf",
1255 ]
1256 public = skia_pdf_jpeg_public
1257 }
1258
1259 optional("xps") {
1260 enabled = skia_use_xps && is_win
1261 public_defines = [ "SK_SUPPORT_XPS" ]
1262 deps = [
1263 ":clipstack_utils",
1264 ":pathops",
1265 ]
1266 public = skia_xps_public
1267 sources = skia_xps_sources
1268 }
1269
1270 optional("png_decode_common") {
1271 enabled = skia_use_libpng_decode || skia_use_rust_png_decode
1272 sources = skia_codec_png_base
1273 }
1274
1275 optional("png_decode_libpng") {
1276 enabled = skia_use_libpng_decode
1277 public_defines = [
1278 "SK_CODEC_DECODES_ICO",
1279 "SK_CODEC_DECODES_PNG",
1280 "SK_CODEC_DECODES_PNG_WITH_LIBPNG",
1281 ]
1282 sources_for_tests = [ "tests/PngGainmapTest.cpp" ]
1283
1284 deps = [
1285 ":png_decode_common",
1286 "//third_party/libpng",
1287 ]
1288 sources = [ "src/codec/SkIcoCodec.cpp" ] + skia_codec_libpng_srcs
1289
1290 # Export this so fiddles could decode png using libpng
1291 public = skia_codec_libpng_public
1292 }
1293
1294 optional("png_encode_common") {
1295 enabled = skia_use_libpng_encode || skia_use_rust_png_encode
1296 sources = skia_encode_png_base
1297 }
1298
1299 optional("png_encode_libpng") {
1300 enabled = skia_use_libpng_encode && !skia_use_ndk_images
1301 public_defines = [
1302 "SK_CODEC_ENCODES_PNG",
1303 "SK_CODEC_ENCODES_PNG_WITH_LIBPNG",
1304 ]
1305
1306 public = skia_encode_libpng_public
1307 deps = [
1308 ":png_encode_common",
1309 "//third_party/libpng",
1310 ]
1311 sources = skia_encode_libpng_srcs
1312 }
1313
1314 optional("raw") {
1315 enabled = skia_use_dng_sdk && skia_use_libjpeg_turbo_decode && skia_use_piex
1316 public_defines = [ "SK_CODEC_DECODES_RAW" ]
1317
1318 deps = [
1319 "//third_party/dng_sdk",
1320 "//third_party/libjpeg-turbo:libjpeg",
1321 "//third_party/piex",
1322 ]
1323
1324 # SkRawCodec catches any exceptions thrown by dng_sdk, insulating the rest of
1325 # Skia.
1326 configs = [ "gn/portable:add_exceptions" ]
1327
1328 sources = [ "src/codec/SkRawCodec.cpp" ]
1329 }
1330
1331 optional("typeface_freetype") {
1332 enabled = skia_use_freetype
1333
1334 public_defines = [ "SK_TYPEFACE_FACTORY_FREETYPE" ]
•1335 # Use system freetype instead:
1336 #deps = [ "//third_party/freetype2" ]
1337 libs = [ "freetype" ]
1338 cflags = [ "-isystem/usr/include/freetype2" ]
1339
1340 sources = skia_ports_freetype_sources
1341 sources_for_tests = [ "tests/FontScanner_FreeTypeTest.cpp" ]
1342 }
1343
1344 bazel_args = []
1345 if (is_mac) {
1346 if (target_cpu == "arm64") {
1347 bazel_args += [ "--platforms=//bazel/platform:mac_arm64_hermetic" ]
1348 } else {
1349 bazel_args += [ "--platforms=//bazel/platform:mac_x64_hermetic" ]
1350 }
1351 }
1352 if (is_debug) {
1353 bazel_args += [ "--compilation_mode=dbg" ]
1354 } else {
1355 bazel_args += [ "--compilation_mode=opt" ]
1356 }
1357
1358 # Unified Rust Bazel Build Action
1359 # This single action builds all Rust targets to avoid duplicate symbol issues
1360 # from having multiple copies of the Rust standard library.
1361
1362 if (skia_use_fontations || skia_use_rust_png_decode ||
1363 skia_use_rust_png_encode || skia_use_rust_bmp_decode || skia_use_rust_icc) {
1364 # Collect all Rust targets, sources, outputs based on what's enabled
1365 _rust_targets = []
1366 _rust_sources = []
1367 _rust_outputs = []
1368 _rust_output_mappings = []
1369
1370 # Add cxx dependency if any feature that needs it is enabled
1371 _needs_cxx =
1372 skia_use_fontations || skia_use_rust_png_decode ||
1373 skia_use_rust_png_encode || skia_use_rust_bmp_decode || skia_use_rust_icc
1374 if (_needs_cxx) {
1375 _rust_targets += [ "@crates//:cxx_cc" ]
1376 _rust_sources += [
1377 "MODULE.bazel",
1378 "MODULE.bazel.lock",
1379 "bazel/external/cxx/BUILD.bazel",
1380 "bazel/external/cxx/BUILD.bazel.skia",
1381 ]
1382 _rust_outputs += [
1383 "$root_out_dir/libcxx_cc.a",
1384 "$root_out_dir/third_party/rust/cxx/v1/cxx.h",
1385 ]
1386 _rust_output_mappings += [
1387 rebase_path(
1388 "//bazel-bin/external/rules_rust++crate+crates__cxx-1.0.168/libcxx_cc.a",
1389 root_build_dir) + "=libcxx_cc.a",
1390 rebase_path(
1391 "//bazel-bin/external/rules_rust++crate+crates__cxx-1.0.168/_virtual_includes/cxx_cc/third_party/rust/cxx/v1/cxx.h",
1392 root_build_dir) + "=third_party/rust/cxx/v1/cxx.h",
1393 ]
1394 }
1395
1396 if (skia_use_fontations) {
1397 _rust_targets += [
1398 "//src/ports/fontations:bridge_rust_side",
1399 "//src/ports/fontations:fontations_ffi",
1400 ]
1401 _rust_sources += [ "src/ports/fontations/BUILD.bazel" ]
1402 _rust_sources += skia_ports_fontations_bridge_rust_side_sources
1403 _rust_outputs += [
1404 "$root_out_dir/libbridge_rust_side.a",
1405 "$root_out_dir/src/ports/fontations/src/ffi.rs.h",
1406 "$root_out_dir/src/ports/fontations/src/ffi.rs.cc",
1407 ]
1408 _rust_output_mappings += [
1409 rebase_path("//bazel-bin/src/ports/fontations/libbridge_rust_side.a",
1410 root_build_dir),
1411 rebase_path("//bazel-bin/src/ports/fontations/src/ffi.rs.h",
1412 root_build_dir) + "=src/ports/fontations/src/ffi.rs.h",
1413 rebase_path("//bazel-bin/src/ports/fontations/src/ffi.rs.cc",
1414 root_build_dir) + "=src/ports/fontations/src/ffi.rs.cc",
1415 ]
1416 }
1417
1418 if (skia_use_rust_png_decode || skia_use_rust_png_encode) {
1419 _rust_targets += [ "//rust/png:ffi_rs" ]
1420 _rust_sources += [
1421 "rust/png/BUILD.bazel",
1422 "rust/png/FFI.h",
1423 "rust/png/FFI.rs",
1424 ]
1425 _rust_outputs += [
1426 "$root_out_dir/librust_png_ffi_rs.a",
1427 "$root_out_dir/rust/png/FFI.rs.h",
1428 "$root_out_dir/rust/png/FFI.rs.cc",
1429 ]
1430 _rust_output_mappings += [
1431 rebase_path("//bazel-bin/rust/png/libffi_rs.a", root_build_dir) +
1432 "=librust_png_ffi_rs.a",
1433 rebase_path("//bazel-bin/rust/png/FFI.rs.h", root_build_dir) +
1434 "=rust/png/FFI.rs.h",
1435 rebase_path("//bazel-bin/rust/png/FFI.rs.cc", root_build_dir) +
1436 "=rust/png/FFI.rs.cc",
1437 ]
1438 }
1439
1440 if (skia_use_rust_bmp_decode) {
1441 _rust_targets += [ "//experimental/rust_bmp/ffi:ffi_rs" ]
1442 _rust_sources += [
1443 "experimental/rust_bmp/ffi/BUILD.bazel",
1444 "experimental/rust_bmp/ffi/FFI.rs",
1445 ]
1446 _rust_outputs += [
1447 "$root_out_dir/librust_bmp_ffi_rs.a",
1448 "$root_out_dir/experimental/rust_bmp/ffi/FFI.rs.h",
1449 "$root_out_dir/experimental/rust_bmp/ffi/FFI.rs.cc",
1450 ]
1451 _rust_output_mappings += [
1452 rebase_path("//bazel-bin/experimental/rust_bmp/ffi/libffi_rs.a",
1453 root_build_dir) + "=librust_bmp_ffi_rs.a",
1454 rebase_path("//bazel-bin/experimental/rust_bmp/ffi/FFI.rs.h",
1455 root_build_dir) + "=experimental/rust_bmp/ffi/FFI.rs.h",
1456 rebase_path("//bazel-bin/experimental/rust_bmp/ffi/FFI.rs.cc",
1457 root_build_dir) + "=experimental/rust_bmp/ffi/FFI.rs.cc",
1458 ]
1459 }
1460
1461 if (skia_use_rust_icc) {
1462 _rust_targets += [ "//rust/icc:ffi_rs" ]
1463 _rust_sources += [
1464 "rust/icc/BUILD.bazel",
1465 "rust/icc/FFI.h",
1466 "rust/icc/FFI.rs",
1467 ]
1468 _rust_outputs += [
1469 "$root_out_dir/librust_icc_ffi_rs.a",
1470 "$root_out_dir/rust/icc/FFI.rs.h",
1471 "$root_out_dir/rust/icc/FFI.rs.cc",
1472 ]
1473 _rust_output_mappings += [
1474 rebase_path("//bazel-bin/rust/icc/libffi_rs.a", root_build_dir) +
1475 "=librust_icc_ffi_rs.a",
1476 rebase_path("//bazel-bin/rust/icc/FFI.rs.h", root_build_dir) +
1477 "=rust/icc/FFI.rs.h",
1478 rebase_path("//bazel-bin/rust/icc/FFI.rs.cc", root_build_dir) +
1479 "=rust/icc/FFI.rs.cc",
1480 ]
1481 }
1482
1483 # Single unified action that builds all Rust FFI library targets
1484 action("rust_all_ffi_bazel_build") {
1485 script = "gn/bazel_build.py"
1486 sources = _rust_sources
1487 outputs = _rust_outputs
1488 args = _rust_targets + _rust_output_mappings + bazel_args
1489 }
1490
1491 # This group collects all Rust static libraries that should be linked together.
1492 group("rust_ffi_libs") {
1493 deps = [ ":rust_all_ffi_bazel_build" ]
1494
1495 # Collect all the Rust .a files based on what's enabled
1496 _all_rust_libs = []
1497 if (_needs_cxx) {
1498 _all_rust_libs += [ "$root_out_dir/libcxx_cc.a" ]
1499 }
1500 if (skia_use_fontations) {
1501 _all_rust_libs += [ "$root_out_dir/libbridge_rust_side.a" ]
1502 }
1503 if (skia_use_rust_png_decode || skia_use_rust_png_encode) {
1504 _all_rust_libs += [ "$root_out_dir/librust_png_ffi_rs.a" ]
1505 }
1506 if (skia_use_rust_bmp_decode) {
1507 _all_rust_libs += [ "$root_out_dir/librust_bmp_ffi_rs.a" ]
1508 }
1509 if (skia_use_rust_icc) {
1510 _all_rust_libs += [ "$root_out_dir/librust_icc_ffi_rs.a" ]
1511 }
1512
1513 public_configs = [ ":rust_ffi_libs_config" ]
1514 all_dependent_configs = [ ":rust_ffi_libs_config" ]
1515 }
1516
1517 config("rust_ffi_libs_config") {
1518 _all_rust_libs = []
1519 if (_needs_cxx) {
1520 _all_rust_libs += [ "$root_out_dir/libcxx_cc.a" ]
1521 }
1522 if (skia_use_fontations) {
1523 _all_rust_libs += [ "$root_out_dir/libbridge_rust_side.a" ]
1524 }
1525 if (skia_use_rust_png_decode || skia_use_rust_png_encode) {
1526 _all_rust_libs += [ "$root_out_dir/librust_png_ffi_rs.a" ]
1527 }
1528 if (skia_use_rust_bmp_decode) {
1529 _all_rust_libs += [ "$root_out_dir/librust_bmp_ffi_rs.a" ]
1530 }
1531 if (skia_use_rust_icc) {
1532 _all_rust_libs += [ "$root_out_dir/librust_icc_ffi_rs.a" ]
1533 }
1534 libs = _all_rust_libs
1535
1536 # Allow multiple definitions because Bazel's rust_static_library includes
1537 # transitive C++ dependencies, which can lead to duplicate symbols when
1538 # linking multiple Rust libraries together.
1539 if (!is_mac) {
1540 ldflags = [ "-Wl,--allow-multiple-definition" ]
1541 }
1542 }
1543 }
1544
1545 if (skia_use_fontations) {
1546 config("fontations_ffi_public_config") {
1547 include_dirs = [
1548 # This is where `src/ports/fontations/src/ffi.rs.h` was put by Bazel
1549 "$root_out_dir",
1550 ]
1551 }
1552 config("fontations_ffi_private_config") {
1553 include_dirs = [
1554 # This entry is needed so that `ffi.rs.cc` can resolve
1555 # `#include "src/ports/fontations/src/ffi.rs.h"`
1556 ".",
1557 ]
1558 }
1559 skia_source_set("fontations_ffi") {
1560 deps = [
1561 ":rust_all_ffi_bazel_build",
1562 ":rust_ffi_libs",
1563 ]
1564 public = [ "${root_out_dir}/src/ports/fontations/src/ffi.rs.h" ]
1565 sources = [ "${root_out_dir}/src/ports/fontations/src/ffi.rs.cc" ]
1566 libs = [ "c++" ]
1567 public_configs = [ ":fontations_ffi_public_config" ]
1568 configs = [ ":fontations_ffi_private_config" ]
1569 }
1570 }
1571
1572 optional("typeface_fontations") {
1573 public_defines = [ "SK_TYPEFACE_FACTORY_FONTATIONS" ]
1574 enabled = skia_use_fontations
1575 public_deps = [ ":fontations_ffi" ]
1576 deps = []
1577 if (skia_use_rust_png_decode) {
1578 deps += [ ":png_decode_rust" ]
1579 } else if (skia_use_libpng_decode) {
1580 deps += [ ":png_decode_libpng" ]
1581 } else {
1582 assert(!enabled, "Fontations requires a PNG decoder")
1583 }
1584 sources = skia_ports_typeface_fontations_sources
1585 sources_for_tests = [
1586 "tests/FontationsTest.cpp",
1587 "tests/FontationsFtCompTest.cpp",
1588 "tests/FontScanner_FontationsTest.cpp",
1589 ]
1590 }
1591
1592 if (skia_use_rust_png_decode || skia_use_rust_png_encode) {
1593 config("rust_png_cxx_bridge_private_config") {
1594 include_dirs = [
1595 # This entry is needed so that `FFI.rs.cc` can resolve
1596 # `#include "rust/png/FFI.h"`
1597 ".",
1598 ]
1599 }
1600 skia_source_set("rust_png_cxx_bridge") {
1601 deps = [ ":rust_all_ffi_bazel_build" ]
1602 public = [ "${root_out_dir}/rust/png/FFI.rs.h" ]
1603 sources = [ "${root_out_dir}/rust/png/FFI.rs.cc" ]
1604 public_configs = [ ":rust_common_cxx_bridge_public_config" ]
1605 configs = [ ":rust_png_cxx_bridge_private_config" ]
1606 }
1607 }
1608
1609 if (skia_use_rust_icc) {
1610 config("rust_icc_cxx_bridge_private_config") {
1611 include_dirs = [
1612 # This entry is needed so that `FFI.rs.cc` can resolve
1613 # `#include "rust/icc/FFI.h"`
1614 ".",
1615 ]
1616 }
1617 skia_source_set("rust_icc_cxx_bridge") {
1618 deps = [ ":rust_all_ffi_bazel_build" ]
1619 public = [ "${root_out_dir}/rust/icc/FFI.rs.h" ]
1620 sources = [ "${root_out_dir}/rust/icc/FFI.rs.cc" ]
1621 public_configs = [ ":rust_common_cxx_bridge_public_config" ]
1622 configs = [ ":rust_icc_cxx_bridge_private_config" ]
1623 }
1624 }
1625
1626 config("rust_common_cxx_bridge_public_config") {
1627 include_dirs = [
1628 # This is where `rust/.../*.rs.h` and
1629 # `third_party/rust/cxx/v1/cxx.h` were put by Bazel
1630 "$root_out_dir",
1631 ]
1632 }
1633
1634 optional("rust_common") {
1635 enabled = skia_use_rust_png_decode || skia_use_rust_png_encode
1636 public = skia_rust_common_ffi_cpp_hdrs
1637 sources = skia_rust_common_ffi_cpp_srcs
1638 public_configs = [ ":rust_common_cxx_bridge_public_config" ]
1639 deps = [ ":rust_all_ffi_bazel_build" ]
1640 }
1641
1642 optional("rust_icc") {
1643 enabled = skia_use_rust_icc
1644 public_defines = [ "SK_CODEC_COLOR_PROFILE_PARSE_WITH_RUST" ]
1645 public = skia_rust_icc_ffi_cpp_hdrs + skia_codec_rust_icc_codec_hdrs
1646 sources = skia_rust_icc_ffi_cpp_srcs + skia_codec_rust_icc_codec_srcs
1647 sources_for_tests = [ "tests/RustIccTest.cpp" ]
1648 public_configs = [ ":rust_common_cxx_bridge_public_config" ]
1649 deps = [
1650 ":rust_common",
1651 ":rust_ffi_libs",
1652 ":rust_icc_cxx_bridge",
1653 "//modules/skcms",
1654 ]
1655 }
1656
1657 optional("png_decode_rust") {
1658 public_defines = [ "SK_CODEC_DECODES_PNG_WITH_RUST" ]
1659 enabled = skia_use_rust_png_decode
1660 public = skia_codec_rust_png_public
1661 sources = skia_codec_rust_png
1662 sources_for_tests = [ "tests/SkPngRustDecoderTest.cpp" ]
1663
1664 deps = [
1665 ":png_decode_common",
1666 ":rust_common",
1667 ":rust_ffi_libs",
1668 ":rust_png_cxx_bridge",
1669 ]
1670 libs = [ "c++" ]
1671 }
1672
1673 optional("png_encode_rust") {
1674 public_defines = [ "SK_CODEC_ENCODES_PNG_WITH_RUST" ]
1675 enabled = skia_use_rust_png_encode
1676 public = skia_encode_rust_png_public # From `gn/core.gni`
1677 sources = skia_encode_rust_png_srcs # From `gn/core.gni`
1678 sources_for_tests = [ "tests/SkPngRustEncoderTest.cpp" ]
1679 deps = [
1680 ":png_encode_common",
1681 ":rust_common",
1682 ":rust_ffi_libs",
1683 ":rust_png_cxx_bridge",
1684 ]
1685 libs = [ "c++" ]
1686 }
1687
1688 if (skia_use_rust_bmp_decode) {
1689 config("rust_bmp_cxx_bridge_public_config") {
1690 include_dirs = [ "$root_out_dir" ]
1691 }
1692 config("rust_bmp_cxx_bridge_private_config") {
1693 include_dirs = [ "." ]
1694 }
1695 skia_source_set("rust_bmp_cxx_bridge") {
1696 deps = [ ":rust_all_ffi_bazel_build" ]
1697 public = [ "${root_out_dir}/experimental/rust_bmp/ffi/FFI.rs.h" ]
1698 sources = [ "${root_out_dir}/experimental/rust_bmp/ffi/FFI.rs.cc" ]
1699 public_configs = [ ":rust_bmp_cxx_bridge_public_config" ]
1700 configs = [ ":rust_bmp_cxx_bridge_private_config" ]
1701 }
1702 }
1703
1704 optional("bmp_decode_rust") {
1705 public_defines = [ "SK_CODEC_DECODES_BMP_WITH_RUST" ]
1706 enabled = skia_use_rust_bmp_decode
1707 public = [ "experimental/rust_bmp/decoder/SkBmpRustDecoder.h" ]
1708 sources = [
1709 "experimental/rust_bmp/decoder/SkBmpRustDecoder.cpp",
1710 "experimental/rust_bmp/decoder/SkBmpRustDecoder.h",
1711 "experimental/rust_bmp/decoder/impl/SkBmpRustCodec.cpp",
1712 "experimental/rust_bmp/decoder/impl/SkBmpRustCodec.h",
1713 ]
1714 sources_for_tests = [ "tests/SkBmpRustDecoderTest.cpp" ]
1715 deps = [
1716 ":rust_bmp_cxx_bridge",
1717 ":rust_ffi_libs",
1718 ]
1719 libs = [ "c++" ]
1720 }
1721
1722 optional("webp_decode") {
1723 enabled = skia_use_libwebp_decode
1724 public_defines = [ "SK_CODEC_DECODES_WEBP" ]
1725
1726 deps = [ "//third_party/libwebp" ]
1727 sources = [ "src/codec/SkWebpCodec.cpp" ]
1728 }
1729
1730 optional("webp_encode") {
1731 enabled = skia_use_libwebp_encode && !skia_use_ndk_images
1732 public_defines = [ "SK_CODEC_ENCODES_WEBP" ]
1733 public = skia_encode_webp_public
1734
1735 deps = [ "//third_party/libwebp" ]
1736 sources = skia_encode_webp_srcs
1737 }
1738
1739 optional("wuffs") {
1740 enabled = skia_use_wuffs
1741 public_defines = [
1742 "SK_HAS_WUFFS_LIBRARY",
1743 "SK_CODEC_DECODES_GIF",
1744 ]
1745
1746 deps = [ "//third_party/wuffs" ]
1747 sources = [ "src/codec/SkWuffsCodec.cpp" ]
1748 }
1749
1750 optional("xml") {
1751 enabled = skia_use_expat || skia_use_jpeg_gainmaps
1752 public_defines = [ "SK_XML" ]
1753
1754 deps = [ "//third_party/expat" ]
1755 sources = skia_xml_sources
1756 sources += skia_codec_xmp
1757 sources += skia_svg_writer_sources
1758 sources += skia_svg_writer_public
1759
1760 # TODO(lukasza, kjlubick, bungeman): Remove the `deps` below once the legacy
1761 # SVG factories (see `SK_DISABLE_LEGACY_SVG_FACTORIES`) are not supported
1762 # anymore.
1763 if (skia_use_libpng_encode) {
1764 deps += [ ":png_encode_libpng" ]
1765 }
1766 if (skia_use_rust_png_encode) {
1767 deps += [ ":png_encode_rust" ]
1768 }
1769 }
1770
1771 if (skia_enable_ganesh && skia_generate_workarounds) {
1772 action("workaround_list") {
1773 script = "tools/build_workaround_header.py"
1774
1775 inputs = [ "src/gpu/gpu_workaround_list.txt" ]
1776
1777 # GN insists its outputs should go somewhere underneath root_out_dir, so we trick it with a
1778 # path that starts with root_out_dir and then uses ".." to back up into the src dir.
1779 output_file =
1780 rebase_path("include/gpu/ganesh/GrDriverBugWorkaroundsAutogen.h",
1781 root_out_dir)
1782
1783 outputs = [ "$root_out_dir/$output_file" ]
1784 args = [
1785 "--output-file",
1786 "$output_file",
1787 ]
1788
1789 foreach(file, inputs) {
1790 args += [ rebase_path(file, root_build_dir) ]
1791 }
1792 }
1793 }
1794
1795 import("gn/codec.gni")
1796
1797 skia_source_set("core") {
1798 public_configs = [ ":skia_public" ]
1799 configs = skia_library_configs
1800 public = skia_core_public
1801 sources = skia_core_sources
1802
1803 # These deps don't belong to :core, but they are currently needed to support (de)serialization.
1804 public_deps = [
1805 ":fontmgr_FontConfigInterface",
1806 ":fontmgr_android",
1807 ":fontmgr_android_ndk",
1808 ":fontmgr_custom_directory",
1809 ":fontmgr_custom_embedded",
1810 ":fontmgr_custom_empty",
1811 ":fontmgr_fontations_empty",
1812 ":fontmgr_fontconfig",
1813 ":fontmgr_mac_ct",
1814 ":fontmgr_win",
1815 ":fontmgr_win_gdi",
1816 ":png_decode_libpng",
1817 ":png_encode_libpng",
1818 ]
1819 deps = [ ":typeface_fontations" ]
1820 }
1821
1822 skia_component("skia") {
1823 public_configs = [ ":skia_public" ]
1824 configs = skia_library_configs
1825
1826 public_deps = [
1827 ":core",
1828 ":gpu",
1829 ":graphite",
1830 ":jpeg_encode",
1831 ":pdf",
1832 ":pdf_jpeg_helpers",
1833 ":webp_encode",
1834 ":xps",
1835 ]
1836
1837 deps = [
1838 ":android_utils",
1839 ":avif",
1840 ":crabbyavif",
1841 ":hsw",
1842 ":jpeg_decode",
1843 ":jpegxl_decode",
1844 ":lasx",
1845 ":minify_sksl",
1846 ":ndk_images",
1847 ":png_decode_rust",
1848 ":raw",
1849 ":rust_icc",
1850 ":skx",
1851 ":typeface_fontations",
1852 ":vello",
1853 ":webp_decode",
1854 ":wuffs",
1855 ":xml",
1856 "modules/skcms",
1857 ]
1858
1859 public = []
1860 public += skia_codec_public
1861 public += skia_utils_public
1862 public += skia_effects_public
1863 public += skia_effects_imagefilter_public
1864 public += skia_android_core_hdrs
1865
1866 sources = []
1867 sources += skia_utils_private
1868 sources += skia_utils_chromium
1869 sources += skia_effects_sources
1870 sources += skia_colorfilters_sources
1871 sources += skia_effects_imagefilter_sources
1872 sources += skia_codec_shared
1873 sources += skia_codec_decode_bmp
1874 sources += skia_encode_srcs
1875 sources += skia_sksl_core_sources
1876 sources += skia_sksl_core_module_sources
1877 sources += skia_sksl_tracing_sources
1878 sources += skia_ports_sources
1879 sources += skia_android_core_srcs
1880 sources += [
1881 "src/android/SkAndroidFrameworkUtils.cpp",
1882 "src/codec/SkAndroidCodec.cpp",
1883 "src/codec/SkAndroidCodecAdapter.cpp",
1884 "src/codec/SkSampledCodec.cpp",
1885 "src/ports/SkDiscardableMemory_none.cpp",
1886 "src/ports/SkMemory_malloc.cpp",
1887 "src/sfnt/SkOTTable_name.cpp",
1888 "src/sfnt/SkOTUtils.cpp",
1889 ]
1890
1891 # TODO(fmalita): remove from skia_utils_private after clients are migrated to
1892 # skia_clipstack_utils_sources
1893 sources -= skia_clipstack_utils_sources
1894
1895 defines = []
1896 libs = []
1897
1898 if (skia_build_for_debugger) {
1899 defines += [ "SK_BUILD_FOR_DEBUGGER" ]
1900 }
1901
1902 if (skia_use_no_jpeg_encode) {
1903 sources += skia_no_encode_jpeg_srcs
1904 }
1905 if (skia_use_no_png_encode) {
1906 sources += skia_no_encode_png_srcs
1907 }
1908 if (skia_use_no_webp_encode) {
1909 sources += skia_no_encode_webp_srcs
1910 }
1911
1912 if (is_win) {
1913 sources += skia_ports_windows_sources + [
1914 "src/ports/SkImageGeneratorWIC.cpp",
1915 "src/ports/SkLog_win.cpp",
1916 ]
1917 libs += [
1918 "Ole32.lib",
1919 "OleAut32.lib",
1920 ]
1921
1922 if (!skia_enable_winuwp) {
1923 libs += [
1924 "FontSub.lib",
1925 "User32.lib",
1926 "Usp10.lib",
1927 ]
1928 }
1929 } else {
1930 sources += [ "src/ports/SkOSFile_posix.cpp" ]
1931 if (is_ios) {
1932 sources += [ "src/ports/SkOSFile_ios.h" ]
1933 }
1934 libs += [ "dl" ]
1935 }
1936
1937 if (is_android) {
1938 deps += [ "//third_party/expat" ]
1939 if (defined(ndk) && ndk != "") {
1940 deps += [ "//third_party/cpu-features" ]
1941 }
1942 sources += [ "src/ports/SkLog_android.cpp" ]
1943 libs += [
1944 "EGL",
1945 "GLESv2",
1946 "log",
1947 ]
1948 }
1949
1950 if (is_linux || is_wasm) {
1951 sources += [ "src/ports/SkLog_stdio.cpp" ]
1952 if (skia_use_egl) {
1953 libs += [ "GLESv2" ]
1954 }
1955 }
1956
1957 if (is_mac) {
1958 public += [ "include/ports/SkCFObject.h" ]
1959 sources += [
1960 "src/ports/SkImageGeneratorCG.cpp",
1961 "src/ports/SkLog_stdio.cpp",
1962 ]
1963 frameworks = [
1964 "ApplicationServices.framework",
1965 "OpenGL.framework",
1966 ]
1967 }
1968
1969 if (is_ios) {
1970 public += [ "include/ports/SkCFObject.h" ]
1971 sources += [
1972 "src/ports/SkImageGeneratorCG.cpp",
1973 "src/ports/SkLog_stdio.cpp",
1974 ]
1975 frameworks = [
1976 "CoreFoundation.framework",
1977 "ImageIO.framework",
1978 "MobileCoreServices.framework",
1979 ]
1980 }
1981
1982 if (skia_enable_spirv_validation) {
1983 deps += [ "//third_party/externals/spirv-tools:spvtools_val" ]
1984 defines += [ "SK_ENABLE_SPIRV_VALIDATION" ]
1985 }
1986
1987 if (skia_include_multiframe_procs) {
1988 sources += [ "tools/SkSharingProc.cpp" ]
1989 }
1990
1991 # Overrides TRACE_EVENT0..2 macros (etc) to map to Perfetto's tracing macros.
1992 # Currently only supported in Android framework.
1993 if (skia_android_framework_use_perfetto) {
1994 defines += [ "SK_ANDROID_FRAMEWORK_USE_PERFETTO" ]
1995 sources += [ "src/android/SkAndroidFrameworkPerfettoStaticStorage.cpp" ]
1996 }
1997 }
1998
1999 # DebugCanvas used in experimental/wasm-skp-debugger
2000 if (is_wasm) {
2001 skia_static_library("debugcanvas") {
2002 public_configs = [ ":skia_public" ]
2003
2004 sources = [
2005 "tools/SkSharingProc.cpp",
2006 "tools/UrlDataManager.cpp",
2007 "tools/debugger/DebugCanvas.cpp",
2008 "tools/debugger/DebugLayerManager.cpp",
2009 "tools/debugger/DrawCommand.cpp",
2010 "tools/debugger/JsonWriteBuffer.cpp",
2011 ]
2012 }
2013 }
2014
2015 group("modules") {
2016 deps = [
2017 "modules/bentleyottmann",
2018 "modules/skottie",
2019 "modules/skparagraph",
2020 "modules/skshaper",
2021 "modules/svg",
2022 ]
2023
2024 if (is_wasm) {
2025 deps += [ "modules/canvaskit" ]
2026 }
2027 }
2028
2029 config("use_skia_vulkan_headers") {
2030 include_dirs = [ "include/third_party/vulkan" ]
2031 defines = [ "SK_USE_INTERNAL_VULKAN_HEADERS" ]
2032 }
2033
2034 config("vulkan_memory_allocator") {
2035 include_dirs = [ "$skia_vulkan_memory_allocator_dir/include" ]
2036 }
2037
2038 skia_public_includes = [
2039 "client_utils/android",
2040 "include/android",
2041 "include/codec",
2042 "include/config",
2043 "include/core",
2044 "include/docs",
2045 "include/effects",
2046 "include/encode",
2047 "include/gpu",
2048 "include/pathops",
2049 "include/ports",
2050 "include/svg",
2051 "include/utils",
2052 "include/utils/mac",
2053 "modules/skottie/include",
2054 "modules/skparagraph/include",
2055 "modules/skshaper/include",
2056 "modules/svg/include",
2057 ]
2058
2059 # Used by gn_to_bp.py to list our public include dirs.
2060 skia_source_set("public") {
2061 configs = [ ":skia_public" ]
2062 include_dirs = skia_public_includes
2063 }
2064
2065 config("skia.h_config") {
2066 include_dirs = [ "$target_gen_dir" ]
2067 }
2068 action("skia.h") {
2069 public_configs = [ ":skia.h_config" ]
2070 skia_h = "$target_gen_dir/skia.h"
2071 script = "gn/find_headers.py"
2072
2073 args = [ rebase_path("//bin/gn") ] + [ rebase_path("//") ] +
2074 [ rebase_path(skia_h, root_build_dir) ] +
2075 rebase_path(skia_public_includes)
2076 depfile = "$skia_h.deps"
2077 outputs = [ skia_h ]
2078 }
2079
2080 skia_source_set("public_headers_warnings_check") {
2081 sources = [ "tools/public_headers_warnings_check.cpp" ]
2082 configs = [ ":use_skia_vulkan_headers" ]
2083 if (defined(skia_header_target_default_configs)) {
2084 configs += skia_header_target_default_configs
2085 }
2086 deps = [
2087 ":skia",
2088 ":skia.h",
2089 "modules/skottie",
2090 "modules/skshaper",
2091 ]
2092
2093 if (skia_use_dawn) {
2094 deps += [ "//third_party/dawn" ]
2095 }
2096 }
2097
2098 # TODO: have each optional provide a target with examples and depend on those.
2099 if (((skia_enable_fontmgr_fontconfig && skia_use_freetype) ||
2100 skia_use_fonthost_mac || skia_enable_fontmgr_win ||
2101 skia_enable_fontmgr_custom_directory) && skia_enable_ganesh &&
2102 skia_use_libjpeg_turbo_encode && skia_use_libjpeg_turbo_decode &&
2103 (skia_use_libpng_encode && !skia_use_ndk_images) && skia_use_zlib &&
2104 skia_enable_pdf && !skia_use_vulkan) {
2105 skia_executable("fiddle_examples") {
2106 sources = [
2107 "tools/fiddle/all_examples.cpp",
2108 "tools/fiddle/examples.cpp",
2109 "tools/fiddle/examples.h",
2110 ]
2111 if (is_win) {
2112 cflags = [
2113 "/wd4756", # Overflow in constant arithmetic
2114 "/wd4305", # truncation from 'double' to 'float'
2115 ]
2116 }
2117 deps = [
2118 ":skia",
2119 ":skia.h",
2120 ]
2121 if (skia_use_dawn) {
2122 deps += [ "//third_party/dawn" ]
2123 }
2124 }
2125 }
2126
2127 # Targets guarded by skia_enable_tools may use //third_party freely.
2128 if (skia_enable_tools) {
2129 if (is_linux && target_cpu == "x64" && skia_enable_ganesh) {
2130 skia_executable("fiddle") {
2131 check_includes = false
2132 libs = []
2133 sources = [
2134 "tools/fiddle/draw.cpp",
2135 "tools/fiddle/fiddle_main.cpp",
2136 ]
2137
2138 if (skia_use_egl) {
2139 sources += [ "tools/fiddle/egl_context.cpp" ]
2140 } else {
2141 sources += [ "tools/fiddle/null_context.cpp" ]
2142 }
2143 testonly = true
2144 deps = [
2145 ":flags",
2146 ":gpu_tool_utils",
2147 ":skia",
2148 ":skia.h",
2149 "modules/skottie",
2150 "modules/skparagraph",
2151 "modules/skshaper",
2152 "modules/svg",
2153 ]
2154 }
2155 }
2156
2157 template("test_lib") {
2158 config(target_name + "_config") {
2159 if (defined(invoker.public_defines)) {
2160 defines = invoker.public_defines
2161 }
2162 }
2163 skia_source_set(target_name) {
2164 forward_variables_from(invoker, "*", [])
2165 check_includes = false
2166 public_configs = [
2167 ":" + target_name + "_config",
2168 ":skia_private",
2169 ]
2170
2171 if (!defined(deps)) {
2172 deps = []
2173 }
2174 deps += [ ":skia" ]
2175 testonly = true
2176 }
2177 }
2178
2179 template("test_app") {
2180 if (is_ios) {
2181 ios_app_bundle(target_name) {
2182 forward_variables_from(invoker,
2183 "*",
2184 [
2185 "output_name",
2186 "visibility",
2187 "is_shared_library",
2188 ])
2189 testonly = true
2190 extra_configs = [ ":skia_private" ]
2191 launchscreen = "platform_tools/ios/app/LaunchScreen.storyboard"
2192 data_sources = [ "resources" ]
2193 if ("True" == exec_script("//gn/checkdir.py",
2194 [ rebase_path("skps", root_build_dir) ],
2195 "trim string")) {
2196 data_sources += [ "skps" ]
2197 }
2198 if ("True" == exec_script("//gn/checkdir.py",
2199 [ rebase_path("mskps", root_build_dir) ],
2200 "trim string")) {
2201 data_sources += [ "mskps" ]
2202 }
2203 }
2204 } else {
2205 # !is_ios
2206
2207 if (defined(invoker.is_shared_library) && invoker.is_shared_library) {
2208 skia_shared_library("lib" + target_name) {
2209 output_dir = root_build_dir
2210 forward_variables_from(invoker, "*", [ "is_shared_library" ])
2211 if (!defined(configs)) {
2212 configs = []
2213 }
2214 configs += [ ":skia_private" ]
2215 testonly = true
2216 }
2217 } else {
2218 _executable = target_name
2219 skia_executable(_executable) {
2220 check_includes = false
2221 output_dir = root_build_dir
2222 forward_variables_from(invoker, "*", [ "is_shared_library" ])
2223 if (!defined(configs)) {
2224 configs = []
2225 }
2226 configs += [ ":skia_private" ]
2227 testonly = true
2228 }
2229 }
2230 if (is_android && skia_android_serial != "" && defined(_executable)) {
2231 action("push_" + target_name) {
2232 output_dir = root_build_dir
2233 script = "gn/push_to_android.py"
2234 deps = [ ":" + _executable ]
2235 _stamp = "$target_gen_dir/$_executable.pushed_$skia_android_serial"
2236 outputs = [ _stamp ]
2237 args = [
2238 rebase_path("$root_build_dir/$_executable"),
2239 skia_android_serial,
2240 rebase_path(_stamp),
2241 ]
2242 testonly = true
2243 }
2244 }
2245 }
2246 }
2247
2248 test_lib("load_dynamic_library") {
2249 configs = [ ":skia_private" ]
2250 deps = [ ":skia" ]
2251 sources = [ "tools/library/LoadDynamicLibrary.h" ]
2252 if (is_win) {
2253 sources += [ "tools/library/LoadDynamicLibrary_win.cpp" ]
2254 } else {
2255 sources += [ "tools/library/LoadDynamicLibrary_posix.cpp" ]
2256 }
2257 }
2258
2259 if (skia_enable_graphite || skia_enable_ganesh) {
2260 test_lib("gpu_tool_utils") {
2261 public_defines = []
2262
2263 # Bots and even devs may not have Vulkan headers, so put
2264 # include/third_party/vulkan on our path so they're always available.
2265 all_dependent_configs = [ ":use_skia_vulkan_headers" ]
2266
2267 defines = []
2268 if (skia_enable_discrete_gpu) {
2269 defines += [ "SK_ENABLE_DISCRETE_GPU" ]
2270 }
2271
2272 deps = [ ":load_dynamic_library" ]
2273 public_deps = []
2274 sources = [
2275 "tools/gpu/BackendSurfaceFactory.cpp",
2276 "tools/gpu/BackendSurfaceFactory.h",
2277 "tools/gpu/BackendTextureImageFactory.cpp",
2278 "tools/gpu/BackendTextureImageFactory.h",
2279 "tools/gpu/CompressedTexture.cpp",
2280 "tools/gpu/CompressedTexture.h",
2281 "tools/gpu/ContextType.cpp",
2282 "tools/gpu/ContextType.h",
2283 "tools/gpu/FlushFinishTracker.cpp",
2284 "tools/gpu/FlushFinishTracker.h",
2285 "tools/gpu/ManagedBackendTexture.cpp",
2286 "tools/gpu/ManagedBackendTexture.h",
2287 "tools/gpu/ProtectedUtils.h",
2288 "tools/gpu/YUVUtils.cpp",
2289 "tools/gpu/YUVUtils.h",
2290 ]
2291
2292 libs = []
2293 frameworks = []
2294
2295 if (skia_use_gl && target_cpu != "wasm") {
2296 if (is_android || skia_use_egl) {
2297 sources +=
2298 [ "tools/ganesh/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
2299 libs += [ "EGL" ]
2300 } else if (is_linux) {
2301 sources +=
2302 [ "tools/ganesh/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
2303 libs += [
2304 "GLU",
2305 "GL",
2306 "X11",
2307 ]
2308 } else if (is_win) {
2309 sources += [
2310 "tools/ganesh/gl/win/CreatePlatformGLTestContext_win.cpp",
2311 "tools/ganesh/gl/win/SkWGL.h",
2312 "tools/ganesh/gl/win/SkWGL_win.cpp",
2313 ]
2314 libs += [ "Gdi32.lib" ]
2315 if (target_cpu != "arm64") {
2316 libs += [ "OpenGL32.lib" ]
2317 }
2318 }
2319 }
2320
2321 if (skia_use_vulkan) {
2322 sources += [ "tools/gpu/vk/VkTestHelper.h" ]
2323 sources += [ "tools/gpu/vk/VkTestHelper.cpp" ]
2324 sources += [ "tools/gpu/vk/VkTestMemoryAllocator.h" ]
2325 sources += [ "tools/gpu/vk/VkTestMemoryAllocator.cpp" ]
2326 sources += [ "tools/gpu/vk/VkTestUtils.h" ]
2327 sources += [ "tools/gpu/vk/VkTestUtils.cpp" ]
2328 sources += [ "tools/gpu/vk/VkYcbcrSamplerHelper.h" ]
2329 sources += [ "tools/gpu/vk/VkYcbcrSamplerHelper.cpp" ]
2330 all_dependent_configs += [ ":vulkan_memory_allocator" ]
2331 }
2332
2333 if (skia_use_dawn) {
2334 public_deps += [ "//third_party/dawn" ]
2335 if (is_clang) {
2336 cflags_cc = [ "-Wno-microsoft-cast" ]
2337 }
2338 }
2339 if (skia_enable_ganesh) {
2340 sources += [
2341 "tools/ganesh/AtlasTextOpTools.cpp",
2342 "tools/ganesh/AtlasTextOpTools.h",
2343 "tools/ganesh/DDLPromiseImageHelper.cpp",
2344 "tools/ganesh/DDLPromiseImageHelper.h",
2345 "tools/ganesh/DDLTileHelper.cpp",
2346 "tools/ganesh/DDLTileHelper.h",
2347 "tools/ganesh/GrAtlasTools.cpp",
2348 "tools/ganesh/GrAtlasTools.h",
2349 "tools/ganesh/GrContextFactory.cpp",
2350 "tools/ganesh/GrContextFactory.h",
2351 "tools/ganesh/GrTest.cpp",
2352 "tools/ganesh/MemoryCache.cpp",
2353 "tools/ganesh/MemoryCache.h",
2354 "tools/ganesh/ProtectedUtils_Ganesh.cpp",
2355 "tools/ganesh/ProxyUtils.cpp",
2356 "tools/ganesh/ProxyUtils.h",
2357 "tools/ganesh/TestCanvas.cpp",
2358 "tools/ganesh/TestCanvas.h",
2359 "tools/ganesh/TestContext.cpp",
2360 "tools/ganesh/TestOps.cpp",
2361 "tools/ganesh/TestOps.h",
2362 "tools/ganesh/mock/MockTestContext.cpp",
2363 "tools/text/gpu/TextBlobTools.cpp",
2364 ]
2365 if (skia_use_gl) {
2366 sources += [ "tools/ganesh/gl/GLTestContext.cpp" ]
2367 if (is_ios) {
2368 sources +=
2369 [ "tools/ganesh/gl/iOS/CreatePlatformGLTestContext_iOS.mm" ]
2370 frameworks += [ "OpenGLES.framework" ]
2371 } else if (is_mac) {
2372 sources +=
2373 [ "tools/ganesh/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
2374 }
2375 if (skia_use_angle) {
2376 deps += [ "//third_party/angle2" ]
2377 sources += [ "tools/ganesh/gl/angle/GLTestContext_angle.cpp" ]
2378 }
2379 }
2380 if (skia_use_vulkan) {
2381 sources += [ "tools/ganesh/vk/VkTestContext.h" ]
2382 sources += [ "tools/ganesh/vk/VkTestContext.cpp" ]
2383 }
2384 if (skia_use_metal) {
2385 sources += [ "tools/ganesh/mtl/MtlTestContext.mm" ]
2386 }
2387 if (skia_use_direct3d) {
2388 sources += [ "tools/ganesh/d3d/D3DTestContext.cpp" ]
2389 sources += [ "tools/ganesh/d3d/D3DTestUtils.cpp" ]
2390 }
2391 }
2392 if (skia_enable_graphite) {
2393 sources += [
2394 "tools/graphite/ContextFactory.cpp",
2395 "tools/graphite/ContextFactory.h",
2396 "tools/graphite/GraphiteMemoryPipelineStorage.cpp",
2397 "tools/graphite/GraphiteMemoryPipelineStorage.h",
2398 "tools/graphite/GraphiteTestContext.cpp",
2399 "tools/graphite/GraphiteTestContext.h",
2400 "tools/graphite/GraphiteToolUtils.cpp",
2401 "tools/graphite/GraphiteToolUtils.h",
2402 "tools/graphite/PipelineCallbackHandler.cpp",
2403 "tools/graphite/PipelineCallbackHandler.h",
2404 "tools/graphite/ProtectedUtils_Graphite.cpp",
2405 "tools/graphite/UniqueKeyUtils.cpp",
2406 "tools/graphite/UniqueKeyUtils.h",
2407 ]
2408 if (skia_use_dawn) {
2409 sources += [
2410 "tools/graphite/dawn/GraphiteDawnTestContext.cpp",
2411 "tools/graphite/dawn/GraphiteDawnTestContext.h",
2412 "tools/graphite/dawn/GraphiteDawnToggles.cpp",
2413 "tools/graphite/dawn/GraphiteDawnToggles.h",
2414 ]
2415 }
2416 if (skia_use_metal) {
2417 sources += [
2418 "tools/graphite/mtl/GraphiteMtlTestContext.h",
2419 "tools/graphite/mtl/GraphiteMtlTestContext.mm",
2420 ]
2421 }
2422 if (skia_use_vulkan) {
2423 sources += [
2424 "tools/graphite/vk/GraphiteVulkanTestContext.cpp",
2425 "tools/graphite/vk/GraphiteVulkanTestContext.h",
2426 ]
2427 }
2428 if (skia_enable_precompile) {
2429 sources += [
2430 "tools/graphite/precompile/PrecompileEffectFactories.cpp",
2431 "tools/graphite/precompile/PrecompileEffectFactories.h",
2432 ]
2433 }
2434 }
2435 } # test_lib("gpu_tool_utils")
2436 }
2437
2438 test_lib("flags") {
2439 sources = [
2440 "tools/flags/CommandLineFlags.cpp",
2441 "tools/flags/CommandLineFlags.h",
2442 ]
2443 }
2444
2445 test_lib("common_flags_config") {
2446 sources = [
2447 "tools/flags/CommonFlags.h",
2448 "tools/flags/CommonFlagsConfig.cpp",
2449 "tools/flags/CommonFlagsConfig.h",
2450 ]
2451 deps = [ ":flags" ]
2452 }
2453 if (skia_enable_ganesh) {
2454 test_lib("common_flags_ganesh") {
2455 sources = [ "tools/flags/CommonFlagsGanesh.cpp" ]
2456 deps = [ ":flags" ]
2457 public_deps = [ ":gpu_tool_utils" ]
2458 }
2459 }
2460 if (skia_enable_graphite) {
2461 test_lib("common_flags_graphite") {
2462 sources = [ "tools/flags/CommonFlagsGraphite.cpp" ]
2463 deps = [ ":flags" ]
2464 public_deps = [ ":gpu_tool_utils" ]
2465 }
2466 }
2467 test_lib("common_flags_images") {
2468 sources = [ "tools/flags/CommonFlagsImages.cpp" ]
2469 deps = [ ":flags" ]
2470 }
2471
2472 test_lib("trace") {
2473 deps = [ ":flags" ]
2474 sources = [
2475 "tools/trace/ChromeTracingTracer.cpp",
2476 "tools/trace/ChromeTracingTracer.h",
2477 "tools/trace/EventTracingPriv.cpp",
2478 "tools/trace/EventTracingPriv.h",
2479 "tools/trace/SkDebugfTracer.cpp",
2480 "tools/trace/SkDebugfTracer.h",
2481 ]
2482 if (skia_use_perfetto) {
2483 deps += [ "//third_party/perfetto" ]
2484 sources += [
2485 "tools/trace/SkPerfettoTrace.cpp",
2486 "tools/trace/SkPerfettoTrace.h",
2487 ]
2488 defines = [ "SK_USE_PERFETTO" ]
2489 }
2490 }
2491
2492 test_lib("tool_utils") {
2493 sources = [
2494 "tools/AndroidSkDebugToStdOut.cpp",
2495 "tools/AutoreleasePool.h",
2496 "tools/DecodeUtils.cpp",
2497 "tools/DecodeUtils.h",
2498 "tools/DeserialProcsUtils.cpp",
2499 "tools/DeserialProcsUtils.h",
2500 "tools/EncodeUtils.cpp",
2501 "tools/EncodeUtils.h",
2502 "tools/GpuToolUtils.h",
2503 "tools/LsanSuppressions.cpp",
2504 "tools/ProcStats.cpp",
2505 "tools/ProcStats.h",
2506 "tools/Resources.cpp",
2507 "tools/Resources.h",
2508 "tools/RuntimeBlendUtils.cpp",
2509 "tools/RuntimeBlendUtils.h",
2510 "tools/SkMetaData.cpp",
2511 "tools/SkMetaData.h",
2512 "tools/Stats.h",
2513 "tools/TestFontDataProvider.cpp",
2514 "tools/TestFontDataProvider.h",
2515 "tools/ToolUtils.cpp",
2516 "tools/ToolUtils.h",
2517 "tools/TsanSuppressions.cpp",
2518 "tools/UrlDataManager.cpp",
2519 "tools/UrlDataManager.h",
2520 "tools/debugger/DebugCanvas.cpp",
2521 "tools/debugger/DebugCanvas.h",
2522 "tools/debugger/DebugLayerManager.cpp",
2523 "tools/debugger/DebugLayerManager.h",
2524 "tools/debugger/DrawCommand.cpp",
2525 "tools/debugger/DrawCommand.h",
2526 "tools/debugger/JsonWriteBuffer.cpp",
2527 "tools/debugger/JsonWriteBuffer.h",
2528 "tools/fonts/FontToolUtils.cpp",
2529 "tools/fonts/FontToolUtils.h",
2530 "tools/fonts/RandomScalerContext.cpp",
2531 "tools/fonts/RandomScalerContext.h",
2532 "tools/fonts/TestEmptyTypeface.h",
2533 "tools/fonts/TestFontMgr.cpp",
2534 "tools/fonts/TestFontMgr.h",
2535 "tools/fonts/TestSVGTypeface.cpp",
2536 "tools/fonts/TestSVGTypeface.h",
2537 "tools/fonts/TestTypeface.cpp",
2538 "tools/fonts/TestTypeface.h",
2539 "tools/sksltrace/SkSLTraceUtils.cpp",
2540 "tools/sksltrace/SkSLTraceUtils.h",
2541 "tools/text/SkTextBlobTrace.cpp",
2542 "tools/text/SkTextBlobTrace.h",
2543 "tools/timer/TimeUtils.h",
2544 "tools/timer/Timer.cpp",
2545 "tools/timer/Timer.h",
2546 ]
2547 if (skia_enable_svg) {
2548 sources += [
2549 "tools/SvgPathExtractor.cpp",
2550 "tools/SvgPathExtractor.h",
2551 ]
2552 }
2553 if (skia_use_libpng_decode) {
2554 sources += [
2555 "tools/MSKPPlayer.cpp",
2556 "tools/MSKPPlayer.h",
2557 "tools/SkSharingProc.cpp",
2558 "tools/SkSharingProc.h",
2559 ]
2560 }
2561
2562 if (target_cpu != "wasm") {
2563 sources += [ "tools/CrashHandler.cpp" ]
2564 }
2565 libs = []
2566 frameworks = []
2567 if (is_ios) {
2568 sources += [ "tools/ios_utils.m" ]
2569 sources += [ "tools/ios_utils.h" ]
2570 sources += [ "tools/AutoreleasePool.mm" ]
2571 frameworks += [ "Foundation.framework" ]
2572 } else if (is_mac) {
2573 sources += [ "tools/AutoreleasePool.mm" ]
2574 frameworks += [ "Foundation.framework" ]
2575 } else if (is_win && !skia_enable_winuwp) {
2576 libs += [ "DbgHelp.lib" ]
2577 }
2578
2579 defines = []
2580 if (skia_tools_require_resources) {
2581 defines += [ "SK_TOOLS_REQUIRE_RESOURCES" ]
2582 }
2583 deps = [ ":flags" ]
2584 if (skia_enable_svg) {
2585 deps += [ "modules/svg" ]
2586 }
2587 public_deps = [ "modules/jsonreader" ]
2588 if (skia_enable_ganesh || skia_enable_graphite) {
2589 public_deps += [ ":gpu_tool_utils" ]
2590 }
2591 }
2592
2593 test_lib("etc1") {
2594 sources = [ "third_party/etc1/etc1.cpp" ]
2595 }
2596
2597 import("gn/gm.gni")
2598 test_lib("gm") {
2599 sources = gm_sources
2600 if (skia_use_gl) {
2601 sources += gl_gm_sources
2602 }
2603 if (!skia_enable_ganesh) {
2604 sources -= ganesh_gm_sources
2605 }
2606 if (!skia_enable_graphite) {
2607 sources -= graphite_gm_sources
2608 }
2609 if (!skia_enable_ganesh && !skia_enable_graphite) {
2610 sources -= gpu_gm_sources
2611 }
2612 if (skia_use_fontations) {
2613 sources += fontations_gm_sources
2614 }
2615 deps = [
2616 ":etc1",
2617 ":flags",
2618 ":skia",
2619 ":tool_utils",
2620 "modules/skottie",
2621 "modules/skottie:gm",
2622 "modules/skparagraph",
2623 "modules/skparagraph:gm",
2624 "modules/skresources",
2625 "modules/skshaper",
2626 ]
2627 if (is_skia_dev_build) {
2628 sources += [ "gm/fiddle.cpp" ]
2629 deps += [ ":skia.h" ]
2630 }
2631 if (skia_enable_graphite || skia_enable_ganesh) {
2632 public_deps = [ ":gpu_tool_utils" ]
2633 }
2634
2635 if (skia_use_ffmpeg) {
2636 deps += [ "experimental/ffmpeg:video_decoder" ]
2637 sources += [ "gm/video_decoder.cpp" ]
2638 }
2639 }
2640
2641 test_lib("test") {
2642 sources = [
2643 "tests/ComparePixels.cpp",
2644 "tests/ComparePixels.h",
2645 "tests/CtsEnforcement.cpp",
2646 "tests/Test.cpp",
2647 "tests/Test.h",
2648 "tests/TestHarness.cpp",
2649 "tests/TestHarness.h",
2650 ]
2651 deps = [
2652 ":flags",
2653 ":skia",
2654 ":tool_utils",
2655 ]
2656 if (skia_enable_graphite || skia_enable_ganesh) {
2657 public_deps = [
2658 ":gpu_tool_utils", # Test.h #includes headers from this target.
2659 ]
2660 }
2661 if (skia_enable_ganesh) {
2662 sources += [
2663 "tests/ganesh/GaneshTestUtils.cpp",
2664 "tests/ganesh/GaneshTestUtils.h",
2665 ]
2666 }
2667 }
2668
2669 if (skia_enable_graphite || skia_enable_ganesh) {
2670 import("gn/tests.gni")
2671 test_lib("tests") {
2672 sources = tests_sources + pathops_tests_sources
2673 frameworks = []
2674 if (skia_use_metal) {
2675 cflags_objcc = [ "-fobjc-arc" ]
2676 frameworks += [ "MetalKit.framework" ]
2677 }
2678 if (skia_use_jpeg_gainmaps) {
2679 sources += jpeg_gainmap_tests_sources
2680 }
2681 if (skia_enable_graphite) {
2682 sources += graphite_tests_sources
2683 if (skia_use_dawn) {
2684 sources += graphite_dawn_tests_sources
2685 }
2686 if (skia_use_metal) {
2687 sources += graphite_metal_tests_sources
2688 }
2689 if (skia_use_vulkan) {
2690 sources += graphite_vulkan_tests_sources
2691 }
2692 }
2693 if (skia_enable_ganesh) {
2694 sources += ganesh_tests_sources
2695 if (skia_use_metal) {
2696 sources += ganesh_metal_tests_sources
2697 }
2698 if (skia_use_gl) {
2699 sources += ganesh_gl_tests_sources
2700 }
2701 if (skia_use_vulkan) {
2702 sources += skia_gpu_vk_chromium_public
2703 sources += skia_gpu_vk_chromium_private
2704 }
2705 }
2706 if (skia_enable_precompile) {
2707 sources += precompile_tests_sources
2708 }
2709 deps = [
2710 ":bmp_decode_rust_tests",
2711 ":flags",
2712 ":fontmgr_FontConfigInterface_tests",
2713 ":fontmgr_android_tests",
2714 ":fontmgr_fontconfig_tests",
2715 ":fontmgr_mac_ct_tests",
2716 ":fontscanner_tests",
2717 ":png_decode_libpng_tests",
2718 ":png_decode_rust_tests",
2719 ":png_encode_rust_tests",
2720 ":rust_icc_tests",
2721 ":skia",
2722 ":test",
2723 ":tool_utils",
2724 ":typeface_fontations_tests",
2725 "modules/bentleyottmann:tests",
2726 "modules/skottie:tests",
2727 "modules/skparagraph:tests",
2728 "modules/sksg:tests",
2729 "modules/skshaper",
2730 "modules/skshaper:tests",
2731 "modules/skunicode:tests",
2732 "modules/svg:tests",
2733 "//third_party/libpng",
2734 "//third_party/libwebp",
2735 "//third_party/zlib",
2736 ]
2737 }
2738 }
2739
2740 if (skia_enable_ganesh) {
2741 import("gn/bench.gni")
2742 test_lib("bench") {
2743 sources = bench_sources
2744 if (skia_enable_graphite) {
2745 sources += graphite_bench_sources
2746 }
2747 if (!skia_enable_ganesh) {
2748 sources -= ganesh_bench_sources
2749 }
2750 deps = [
2751 ":flags",
2752 ":gm",
2753 ":gpu_tool_utils",
2754 ":skia",
2755 ":tool_utils",
2756 "modules/skparagraph:bench",
2757 "modules/skshaper",
2758 ]
2759 }
2760 }
2761
2762 if ((is_linux || is_mac || skia_enable_optimize_size) &&
2763 skia_enable_tools_that_might_need_ganesh) {
2764 if (skia_enable_skottie) {
2765 test_app("skottie_tool") {
2766 deps = [ "modules/skottie:tool" ]
2767 }
2768 test_app("skottie_tool_cpu") {
2769 deps = [ "modules/skottie:tool_cpu" ]
2770 }
2771 test_app("skottie_tool_gpu") {
2772 deps = [ "modules/skottie:tool_gpu" ]
2773 }
2774 test_app("skottie_preshape_tool") {
2775 deps = [ "modules/skottie:preshape_tool" ]
2776 }
2777 }
2778 if (skia_enable_svg && skia_use_expat && defined(is_skia_standalone)) {
2779 test_app("svg_tool") {
2780 deps = [ "modules/svg:tool" ]
2781 }
2782 }
2783 }
2784
2785 test_lib("hash_and_encode") {
2786 sources = [
2787 "tools/HashAndEncode.cpp",
2788 "tools/HashAndEncode.h",
2789 ]
2790 deps = [
2791 ":flags",
2792 ":skia",
2793 "//third_party/libpng",
2794 ]
2795 }
2796 if (target_cpu != "wasm") {
2797 if (skia_enable_tools_that_might_need_ganesh) {
2798 test_app("convert-to-nia") {
2799 sources = [ "tools/convert-to-nia.cpp" ]
2800 deps = [ ":skia" ]
2801 }
2802 test_app("imgcvt") {
2803 sources = [ "tools/imgcvt.cpp" ]
2804 configs = [ ":use_skia_vulkan_headers" ]
2805 deps = [
2806 ":skia",
2807 "modules/skcms",
2808 ]
2809 }
2810 }
2811 if (skia_enable_graphite || skia_enable_ganesh) {
2812 test_app("dm") {
2813 sources = [
2814 "dm/DM.cpp",
2815 "dm/DMGpuTestProcs.cpp",
2816 "dm/DMJsonWriter.cpp",
2817 "dm/DMJsonWriter.h",
2818 "dm/DMSrcSink.cpp",
2819 "dm/DMSrcSink.h",
2820 ]
2821 deps = [
2822 ":common_flags_config",
2823 ":common_flags_images",
2824 ":compile_all_sksl_tests",
2825 ":flags",
2826 ":gm",
2827 ":gpu_tool_utils",
2828 ":hash_and_encode",
2829 ":skia",
2830 ":tests",
2831 ":tool_utils",
2832 ":trace",
2833 "modules/skottie",
2834 "modules/skottie:utils",
2835 "modules/skshaper",
2836 "modules/skunicode",
2837 ]
2838 if (skia_use_libpng_decode) {
2839 deps += [ "modules/svg" ]
2840 }
2841 if (skia_enable_graphite) {
2842 deps += [ ":common_flags_graphite" ]
2843 }
2844 if (skia_enable_ganesh) {
2845 deps += [ ":common_flags_ganesh" ]
2846 }
2847 }
2848 }
2849 test_app("filterfuzz") {
2850 sources = [ "experimental/filterfuzz/filterfuzz.cpp" ]
2851 deps = [
2852 ":flags",
2853 ":skia",
2854 ":tool_utils",
2855 ]
2856 }
2857
2858 if (!skia_enable_optimize_size && !skia_use_fontations &&
2859 !skia_use_rust_png_decode && !skia_use_rust_png_encode &&
2860 !skia_use_rust_bmp_decode && !skia_enable_vello_shaders) {
2861 # optional separate library to dlopen when running CanvasStateTests.
2862 # currently does not link in the presence of rust
2863 skia_shared_library("canvas_state_lib") {
2864 sources = [
2865 "tests/CanvasStateHelpers.cpp",
2866 "tests/CanvasStateHelpers.h",
2867 ]
2868 deps = [ ":skia" ]
2869 }
2870 }
2871 }
2872
2873 if (!is_win && skia_enable_tools_that_might_need_ganesh) {
2874 test_app("blob_cache_sim") {
2875 sources = [ "tools/blob_cache_sim.cpp" ]
2876 deps = [
2877 ":skia",
2878 ":tool_utils",
2879 ]
2880 }
2881 }
2882
2883 if (skia_use_libpng_decode && skia_enable_tools_that_might_need_ganesh) {
2884 test_app("nanobench") {
2885 sources = [
2886 "bench/nanobench.cpp",
2887 "bench/nanobench.h",
2888 ]
2889 deps = [
2890 ":bench",
2891 ":common_flags_config",
2892 ":common_flags_ganesh",
2893 ":common_flags_images",
2894 ":flags",
2895 ":gm",
2896 ":gpu_tool_utils",
2897 ":skia",
2898 ":tool_utils",
2899 ":trace",
2900 "modules/skparagraph",
2901 "modules/skshaper",
2902 "modules/skunicode",
2903 "modules/svg",
2904 ]
2905 if (skia_enable_graphite) {
2906 deps += [ ":common_flags_graphite" ]
2907 }
2908 }
2909 }
2910
2911 test_app("skpinfo") {
2912 sources = [ "tools/skpinfo.cpp" ]
2913 configs = [ ":use_skia_vulkan_headers" ]
2914 deps = [
2915 ":flags",
2916 ":skia",
2917 ]
2918 }
2919
2920 if (skia_enable_tools_that_might_need_ganesh) {
2921 if (skia_use_ffmpeg) {
2922 test_app("skottie2movie") {
2923 sources = [ "tools/skottie2movie.cpp" ]
2924 deps = [
2925 ":flags",
2926 ":gpu_tool_utils",
2927 ":skia",
2928 "experimental/ffmpeg:video_encoder",
2929 "modules/skottie",
2930 "modules/skottie:utils",
2931 ]
2932 }
2933 }
2934
2935 if (skia_use_libpng_decode) {
2936 test_app("skpbench") {
2937 sources = [
2938 "bench/BigPath.cpp",
2939 "tools/skpbench/skpbench.cpp",
2940 ]
2941 deps = [
2942 ":common_flags_config",
2943 ":common_flags_ganesh",
2944 ":flags",
2945 ":gpu_tool_utils",
2946 ":skia",
2947 ":tool_utils",
2948 ]
2949 }
2950 }
2951
2952 if (is_linux && skia_use_icu) {
2953 test_app("sktexttopdf") {
2954 sources = [ "tools/using_skia_and_harfbuzz.cpp" ]
2955 deps = [
2956 ":skia",
2957 "modules/skshaper",
2958 ]
2959 }
2960 }
2961
2962 if (is_linux || is_mac) {
2963 test_app("create_test_font") {
2964 sources = [ "tools/fonts/create_test_font.cpp" ]
2965 deps = [ ":skia" ]
2966 assert_no_deps = [
2967 # tool_utils requires the output of this app.
2968 ":tool_utils",
2969 ]
2970 }
2971 }
2972
2973 if (skia_use_expat) {
2974 test_app("create_test_font_color") {
2975 sources = [ "tools/fonts/create_test_font_color.cpp" ]
2976 deps = [
2977 ":flags",
2978 ":skia",
2979 ":tool_utils",
2980 "//modules/svg",
2981 ]
2982 }
2983 }
2984
2985 test_app("get_images_from_skps") {
2986 sources = [ "tools/get_images_from_skps.cpp" ]
2987 deps = [
2988 ":flags",
2989 ":skia",
2990 ]
2991 }
2992
2993 test_app("fuzz") {
2994 sources = [
2995 "fuzz/Fuzz.cpp",
2996 "fuzz/Fuzz.h",
2997 "fuzz/FuzzCanvas.cpp",
2998 "fuzz/FuzzCanvasHelpers.cpp",
2999 "fuzz/FuzzCanvasHelpers.h",
3000 "fuzz/FuzzCommon.cpp",
3001 "fuzz/FuzzCommon.h",
3002 "fuzz/FuzzCreateDDL.cpp",
3003 "fuzz/FuzzCubicRoots.cpp",
3004 "fuzz/FuzzDDLThreading.cpp",
3005 "fuzz/FuzzDrawFunctions.cpp",
3006 "fuzz/FuzzEncoders.cpp",
3007 "fuzz/FuzzGrStyledShape.cpp",
3008 "fuzz/FuzzGradients.cpp",
3009 "fuzz/FuzzMain.cpp",
3010 "fuzz/FuzzParsePath.cpp",
3011 "fuzz/FuzzPathMeasure.cpp",
3012 "fuzz/FuzzPathop.cpp",
3013 "fuzz/FuzzPolyUtils.cpp",
3014 "fuzz/FuzzQuadRoots.cpp",
3015 "fuzz/FuzzRegionOp.cpp",
3016 "fuzz/FuzzSkParagraph.cpp",
3017 "fuzz/FuzzTriangulation.cpp",
3018 "fuzz/oss_fuzz/FuzzAndroidCodec.cpp",
3019 "fuzz/oss_fuzz/FuzzAnimatedImage.cpp",
3020 "fuzz/oss_fuzz/FuzzCOLRv1.cpp",
3021 "fuzz/oss_fuzz/FuzzColorspace.cpp",
3022 "fuzz/oss_fuzz/FuzzImage.cpp",
3023 "fuzz/oss_fuzz/FuzzImageFilterDeserialize.cpp",
3024 "fuzz/oss_fuzz/FuzzIncrementalImage.cpp",
3025 "fuzz/oss_fuzz/FuzzJSON.cpp",
3026 "fuzz/oss_fuzz/FuzzParsePath.cpp",
3027 "fuzz/oss_fuzz/FuzzPathDeserialize.cpp",
3028 "fuzz/oss_fuzz/FuzzRegionDeserialize.cpp",
3029 "fuzz/oss_fuzz/FuzzRegionSetPath.cpp",
3030 "fuzz/oss_fuzz/FuzzSKP.cpp",
3031 "fuzz/oss_fuzz/FuzzSKSL2GLSL.cpp",
3032 "fuzz/oss_fuzz/FuzzSKSL2Metal.cpp",
3033 "fuzz/oss_fuzz/FuzzSKSL2Pipeline.cpp",
3034 "fuzz/oss_fuzz/FuzzSKSL2SPIRV.cpp",
3035 "fuzz/oss_fuzz/FuzzSKSL2WGSL.cpp",
3036 "fuzz/oss_fuzz/FuzzSVG.cpp",
3037 "fuzz/oss_fuzz/FuzzSkDescriptorDeserialize.cpp",
3038 "fuzz/oss_fuzz/FuzzSkMeshSpecification.cpp",
3039 "fuzz/oss_fuzz/FuzzSkParagraph.cpp",
3040 "fuzz/oss_fuzz/FuzzSkRuntimeBlender.cpp",
3041 "fuzz/oss_fuzz/FuzzSkRuntimeColorFilter.cpp",
3042 "fuzz/oss_fuzz/FuzzSkRuntimeEffect.cpp",
3043 "fuzz/oss_fuzz/FuzzTextBlobDeserialize.cpp",
3044 "tools/UrlDataManager.cpp",
3045 "tools/debugger/DebugCanvas.cpp",
3046 "tools/debugger/DebugLayerManager.cpp",
3047 "tools/debugger/DrawCommand.cpp",
3048 "tools/debugger/JsonWriteBuffer.cpp",
3049 "tools/fonts/FontToolUtils.cpp",
3050 ]
3051
3052 if (skia_enable_graphite && skia_enable_precompile) {
3053 sources += [ "fuzz/FuzzPrecompile.cpp" ]
3054 }
3055 if (skia_use_rust_bmp_decode) {
3056 sources += [ "fuzz/oss_fuzz/FuzzBMPRustDecoder.cpp" ]
3057 }
3058 deps = [
3059 ":flags",
3060 ":gpu_tool_utils",
3061 ":skia",
3062 "modules/jsonreader",
3063 "modules/skottie:fuzz",
3064 "modules/skparagraph",
3065 "modules/svg",
3066 ]
3067 if (skia_use_rust_bmp_decode) {
3068 deps += [ ":bmp_decode_rust" ]
3069 }
3070 }
3071
3072 test_app("dump_record") {
3073 sources = [ "tools/dump_record.cpp" ]
3074 deps = [
3075 ":flags",
3076 ":skia",
3077 ]
3078 }
3079
3080 if (skia_use_libpng_decode) {
3081 test_app("skdiff") {
3082 sources = [
3083 "tools/skdiff/skdiff.cpp",
3084 "tools/skdiff/skdiff_html.cpp",
3085 "tools/skdiff/skdiff_main.cpp",
3086 "tools/skdiff/skdiff_utils.cpp",
3087 ]
3088 deps = [ ":skia" ]
3089 }
3090
3091 test_app("skp_parser") {
3092 sources = [ "tools/skp_parser.cpp" ]
3093 deps = [
3094 ":skia",
3095 ":tool_utils",
3096 ]
3097 }
3098 }
3099
3100 if (!is_win) {
3101 source_set("skqp_lib") { # Not a skia_source_set
3102 check_includes = false
3103 testonly = true
3104 public_configs = [ ":skia_private" ]
3105 sources = [
3106 "tools/skqp/src/skqp.cpp",
3107 "tools/skqp/src/skqp.h",
3108 "tools/skqp/src/skqp_GpuTestProcs.cpp",
3109 ]
3110 deps = [
3111 ":gm",
3112 ":skia",
3113 ":tests",
3114 ":tool_utils",
3115 ]
3116 }
3117 if (skia_use_libpng_decode) {
3118 test_app("skqp") {
3119 sources = [ "tools/skqp/src/skqp_main.cpp" ]
3120 include_dirs = [ "//" ]
3121 lib_dirs = []
3122 deps = [ ":skqp_lib" ]
3123 }
3124 }
3125 }
3126 if (is_android) {
3127 shared_library("libskqp_jni") { # Not a skia_shared_library
3128 configs += [ ":skia_private" ]
3129 testonly = true
3130 sources = [ "tools/skqp/src/jni_skqp.cpp" ]
3131 deps = [
3132 ":skia",
3133 ":skqp_lib",
3134 ":tool_utils",
3135 ]
3136 libs = [ "android" ]
3137 }
3138 }
3139 if (is_android && skia_use_gl) {
3140 test_app("skottie_android") {
3141 is_shared_library = true
3142
3143 sources = [ "platform_tools/android/apps/skottie/skottielib/src/main/cpp/native-lib.cpp" ]
3144 libs = []
3145
3146 deps = [
3147 ":skia",
3148 "modules/skottie",
3149 "modules/skshaper",
3150 "modules/skunicode",
3151 ]
3152 }
3153 }
3154
3155 if (is_ios && skia_enable_skottie) {
3156 group("skottie_ios") {
3157 deps = [ "tools/skottie_ios_app" ]
3158 }
3159 }
3160 }
3161
3162 test_lib("sk_app") {
3163 public_deps = [ ":skia" ]
3164 sources = [
3165 "tools/sk_app/Application.h",
3166 "tools/sk_app/CommandSet.cpp",
3167 "tools/sk_app/CommandSet.h",
3168 "tools/sk_app/Window.cpp",
3169 "tools/sk_app/Window.h",
3170 ]
3171 libs = []
3172 frameworks = []
3173
3174 if (skia_enable_graphite || skia_enable_ganesh) {
3175 public_deps += [ ":gpu_tool_utils" ]
3176 }
3177
3178 if (is_android) {
3179 sources += [
3180 "tools/sk_app/android/Window_android.cpp",
3181 "tools/sk_app/android/Window_android.h",
3182 "tools/sk_app/android/main_android.cpp",
3183 "tools/sk_app/android/surface_glue_android.cpp",
3184 "tools/sk_app/android/surface_glue_android.h",
3185 ]
3186 libs += [ "android" ]
3187 } else if (is_linux) {
3188 sources += [
3189 "tools/sk_app/unix/Window_unix.cpp",
3190 "tools/sk_app/unix/Window_unix.h",
3191 "tools/sk_app/unix/keysym2ucs.c",
3192 "tools/sk_app/unix/keysym2ucs.h",
3193 "tools/sk_app/unix/main_unix.cpp",
3194 ]
3195 libs += [
3196 "GL", # Used by raster window context, so cannot be behind skia_use_gl.
3197 "X11",
3198 ]
3199 } else if (is_win) {
3200 sources += [
3201 "tools/sk_app/win/Window_win.cpp",
3202 "tools/sk_app/win/Window_win.h",
3203 "tools/sk_app/win/main_win.cpp",
3204 ]
3205 } else if (is_mac) {
3206 sources += [
3207 "tools/sk_app/mac/Window_mac.h",
3208 "tools/sk_app/mac/Window_mac.mm",
3209 "tools/sk_app/mac/main_mac.mm",
3210 ]
3211 frameworks += [
3212 "QuartzCore.framework",
3213 "Cocoa.framework",
3214 "Foundation.framework",
3215 ]
3216 } else if (is_ios) {
3217 sources += [
3218 "tools/sk_app/ios/Window_ios.h",
3219 "tools/sk_app/ios/Window_ios.mm",
3220 "tools/sk_app/ios/main_ios.mm",
3221 ]
3222 frameworks += [ "QuartzCore.framework" ]
3223 }
3224
3225 deps = [
3226 ":tool_utils",
3227 "tools/window",
3228 ]
3229 if (is_android) {
3230 deps += [ "//third_party/native_app_glue" ]
3231 }
3232 if (skia_use_gl && skia_use_angle) {
3233 deps += [ "//third_party/angle2" ]
3234 }
3235 }
3236
3237 # viewer requires at least one of Ganesh or Graphite. Raster is presented via Ganesh and
3238 # therefore cannot stand alone.
3239 if (skia_enable_ganesh || skia_enable_graphite) {
3240 test_app("viewer") {
3241 is_shared_library = is_android
3242 sources = [
3243 "tools/viewer/3DSlide.cpp",
3244 "tools/viewer/AndroidShadowsSlide.cpp",
3245 "tools/viewer/AnimBlurSlide.cpp",
3246 "tools/viewer/AnimTimer.h",
3247 "tools/viewer/AnimatedImageSlide.cpp",
3248 "tools/viewer/AnimatedImageSlide.h",
3249 "tools/viewer/AnimatedRectsSlide.cpp",
3250 "tools/viewer/AnimatedTextSlide.cpp",
3251 "tools/viewer/ArcSlide.cpp",
3252 "tools/viewer/AtlasSlide.cpp",
3253 "tools/viewer/AudioSlide.cpp",
3254 "tools/viewer/BisectSlide.cpp",
3255 "tools/viewer/BisectSlide.h",
3256 "tools/viewer/CameraSlide.cpp",
3257 "tools/viewer/CaptureSlide.cpp",
3258 "tools/viewer/CaptureSlide.h",
3259 "tools/viewer/ChartSlide.cpp",
3260 "tools/viewer/ChineseFlingSlide.cpp",
3261 "tools/viewer/ClickHandlerSlide.cpp",
3262 "tools/viewer/ClickHandlerSlide.h",
3263 "tools/viewer/ClipSlide.cpp",
3264 "tools/viewer/ClockSlide.cpp",
3265 "tools/viewer/CowboySlide.cpp",
3266 "tools/viewer/DegenerateQuadsSlide.cpp",
3267 "tools/viewer/DegenerateTwoPtRadialsSlide.cpp",
3268 "tools/viewer/EdgeBuilderVizSlide.cpp",
3269 "tools/viewer/FatBitsSlide.cpp",
3270 "tools/viewer/FilterBoundsSlide.cpp",
3271 "tools/viewer/FitCubicToCircleSlide.cpp",
3272 "tools/viewer/FlutterAnimateSlide.cpp",
3273 "tools/viewer/GMSlide.cpp",
3274 "tools/viewer/GMSlide.h",
3275 "tools/viewer/GlyphTransformSlide.cpp",
3276 "tools/viewer/GradientsSlide.cpp",
3277 "tools/viewer/GraphitePrimitivesSlide.cpp",
3278 "tools/viewer/ImGuiLayer.cpp",
3279 "tools/viewer/ImGuiLayer.h",
3280 "tools/viewer/ImageFilterDAGSlide.cpp",
3281 "tools/viewer/ImageSlide.cpp",
3282 "tools/viewer/ImageSlide.h",
3283 "tools/viewer/LayersSlide.cpp",
3284 "tools/viewer/ManyRectsSlide.cpp",
3285 "tools/viewer/MaterialShadowsSlide.cpp",
3286 "tools/viewer/MegaStrokeSlide.cpp",
3287 "tools/viewer/MeshGradientSlide.cpp",
3288 "tools/viewer/MeshSlide.cpp",
3289 "tools/viewer/MixerSlide.cpp",
3290 "tools/viewer/MotionMarkSlide.cpp",
3291 "tools/viewer/PatchSlide.cpp",
3292 "tools/viewer/PathClipSlide.cpp",
3293 "tools/viewer/PathEffectsSlide.cpp",
3294 "tools/viewer/PathLerpSlide.cpp",
3295 "tools/viewer/PathOverstrokeSlide.cpp",
3296 "tools/viewer/PathSlide.cpp",
3297 "tools/viewer/PathTessellatorsSlide.cpp",
3298 "tools/viewer/PathTextSlide.cpp",
3299 "tools/viewer/ProtectedSlide.cpp",
3300 "tools/viewer/QuadStrokerSlide.cpp",
3301 "tools/viewer/RasterPipelineVizSlide.cpp",
3302 "tools/viewer/RectanizerSlide.cpp",
3303 "tools/viewer/RepeatTileSlide.cpp",
3304 "tools/viewer/SBIXSlide.cpp",
3305 "tools/viewer/SGSlide.cpp",
3306 "tools/viewer/SKPSlide.cpp",
3307 "tools/viewer/SKPSlide.h",
3308 "tools/viewer/SVGFileSlide.cpp",
3309 "tools/viewer/ShadowColorSlide.cpp",
3310 "tools/viewer/ShadowReferenceSlide.cpp",
3311 "tools/viewer/ShadowUtilsSlide.cpp",
3312 "tools/viewer/ShipSlide.cpp",
3313 "tools/viewer/SimpleStrokerSlide.cpp",
3314 "tools/viewer/SkSLDebuggerSlide.cpp",
3315 "tools/viewer/SkSLDebuggerSlide.h",
3316 "tools/viewer/SkSLSlide.cpp",
3317 "tools/viewer/SkSLSlide.h",
3318 "tools/viewer/SkottieSlide.cpp",
3319 "tools/viewer/SkottieSlide.h",
3320 "tools/viewer/Slide.h",
3321 "tools/viewer/SlideDir.cpp",
3322 "tools/viewer/SlideDir.h",
3323 "tools/viewer/SlidesSlide.cpp",
3324 "tools/viewer/StatsLayer.cpp",
3325 "tools/viewer/StatsLayer.h",
3326 "tools/viewer/StringArtSlide.cpp",
3327 "tools/viewer/StrokeVerbSlide.cpp",
3328 "tools/viewer/SvgSlide.cpp",
3329 "tools/viewer/SvgSlide.h",
3330 "tools/viewer/TextBoxSlide.cpp",
3331 "tools/viewer/TextureUploadSlide.cpp",
3332 "tools/viewer/ThinAASlide.cpp",
3333 "tools/viewer/TimingSlide.cpp",
3334 "tools/viewer/TouchGesture.cpp",
3335 "tools/viewer/TouchGesture.h",
3336 "tools/viewer/TypefaceSlide.cpp",
3337 "tools/viewer/VariableWidthStrokerSlide.cpp",
3338 "tools/viewer/Viewer.cpp",
3339 "tools/viewer/Viewer.h",
3340 "tools/viewer/XferSlide.cpp",
3341 "tools/viewer/ZoomInSlide.cpp",
3342 "tools/viewer/ZoomInSlide.h",
3343 ]
3344 libs = []
3345
3346 deps = [
3347 ":common_flags_config",
3348 ":flags",
3349 ":gm",
3350 ":sk_app",
3351 ":skia",
3352 ":tool_utils",
3353 ":trace",
3354 ":xml",
3355 "modules/audioplayer",
3356 "modules/skottie",
3357 "modules/skottie:utils",
3358 "modules/skparagraph:slides",
3359 "modules/skresources",
3360 "modules/sksg:slides",
3361 "modules/skshaper",
3362 "modules/skunicode",
3363 "//third_party/delaunator",
3364 "//third_party/imgui",
3365 ]
3366 if (skia_use_libpng_decode) {
3367 deps += [ "modules/svg" ]
3368
3369 sources += [
3370 "tools/viewer/MSKPSlide.cpp",
3371 "tools/viewer/MSKPSlide.h",
3372 ]
3373 }
3374 if (skia_use_vulkan) {
3375 deps += [
3376 "//third_party/externals/spirv-tools:spvtools",
3377
3378 #spvtools depends on this but doesn't deps it in.
3379 "//third_party/externals/spirv-tools:spvtools_val",
3380 ]
3381 }
3382 if (skia_enable_ganesh) {
3383 deps += [
3384 ":common_flags_ganesh",
3385 ":gpu_tool_utils",
3386 ]
3387 }
3388 if (skia_enable_graphite) {
3389 deps += [
3390 ":common_flags_graphite",
3391 ":gpu_tool_utils",
3392 ]
3393 }
3394 }
3395 }
3396
3397 if (skia_enable_tools_that_might_need_ganesh) {
3398 if (skia_use_vulkan) {
3399 test_app("VulkanBasic") {
3400 # Bots and even devs may not have Vulkan headers, so put
3401 # include/third_party/vulkan on our path so they're always available.
3402 all_dependent_configs = [
3403 ":use_skia_vulkan_headers",
3404 ":vulkan_memory_allocator",
3405 ]
3406
3407 sources = [ "example/VulkanBasic.cpp" ]
3408 sources += [ "tools/gpu/vk/VkTestMemoryAllocator.h" ]
3409 sources += [ "tools/gpu/vk/VkTestMemoryAllocator.cpp" ]
3410 sources += [ "tools/gpu/vk/VkTestUtils.h" ]
3411 sources += [ "tools/gpu/vk/VkTestUtils.cpp" ]
3412 deps = [
3413 ":load_dynamic_library",
3414 ":skia",
3415 ]
3416 }
3417 }
3418
3419 if (is_ios && skia_use_metal && skia_enable_ganesh) {
3420 group("minimal_ios_mtl_skia_app") {
3421 deps = [ "experimental/minimal_ios_mtl_skia_app" ]
3422 }
3423 }
3424
3425 if (is_linux || is_win || is_mac) {
3426 test_app("editor") {
3427 is_shared_library = is_android
3428 deps = [ "modules/skplaintexteditor:editor_app" ]
3429 }
3430 }
3431
3432 skia_executable("image_diff_metric") {
3433 sources = [ "tools/image_diff_metric.cpp" ]
3434 deps = [ ":skia" ]
3435 }
3436
3437 group("modules_testonly") {
3438 testonly = true
3439 deps = []
3440 if (is_wasm) {
3441 deps += [ "modules/canvaskit:viewer_wasm" ]
3442 }
3443 }
3444 }
3445 }
3446
3447 if (skia_build_fuzzers) {
3448 assert(is_clang)
3449 template("libfuzzer_app") {
3450 skia_executable(target_name) {
3451 output_dir = root_build_dir
3452 check_includes = false
3453 forward_variables_from(invoker, "*", [ "is_shared_library" ])
3454 if (!defined(configs)) {
3455 configs = []
3456 }
3457 configs += [ ":skia_private" ]
3458 sources += [
3459 "fuzz/Fuzz.cpp",
3460 "fuzz/FuzzCommon.cpp",
3461 ]
3462 deps += [
3463 ":flags",
3464 ":skia",
3465 ":tool_utils",
3466 ]
3467 defines = [ "SK_BUILD_FOR_LIBFUZZER" ]
3468
3469 # oss-fuzz will set this engine itself when building and we don't want a
3470 # conflict (e.g. both libfuzzer and centipede)
3471 if (skia_provide_default_fuzz_engine) {
3472 cflags = [ "-fsanitize=fuzzer" ]
3473 ldflags = [ "-fsanitize=fuzzer" ]
3474 }
3475 testonly = true
3476 }
3477 }
3478
3479 libfuzzer_app("region_deserialize") {
3480 sources = [ "fuzz/oss_fuzz/FuzzRegionDeserialize.cpp" ]
3481 deps = []
3482 }
3483
3484 libfuzzer_app("image_filter_deserialize") {
3485 sources = [ "fuzz/oss_fuzz/FuzzImageFilterDeserialize.cpp" ]
3486 deps = [ "modules/svg" ]
3487 }
3488
3489 libfuzzer_app("region_set_path") {
3490 sources = [ "fuzz/oss_fuzz/FuzzRegionSetPath.cpp" ]
3491 deps = []
3492 }
3493
3494 libfuzzer_app("textblob_deserialize") {
3495 sources = [ "fuzz/oss_fuzz/FuzzTextBlobDeserialize.cpp" ]
3496 deps = [ "modules/svg" ]
3497 }
3498
3499 libfuzzer_app("path_deserialize") {
3500 sources = [ "fuzz/oss_fuzz/FuzzPathDeserialize.cpp" ]
3501 deps = []
3502 }
3503
3504 libfuzzer_app("image_decode") {
3505 sources = [ "fuzz/oss_fuzz/FuzzImage.cpp" ]
3506 deps = []
3507 }
3508
3509 libfuzzer_app("animated_image_decode") {
3510 sources = [ "fuzz/oss_fuzz/FuzzAnimatedImage.cpp" ]
3511 deps = []
3512 }
3513
3514 libfuzzer_app("api_create_ddl") {
3515 sources = [
3516 "fuzz/FuzzCreateDDL.cpp",
3517 "fuzz/oss_fuzz/FuzzAPICreateDDL.cpp",
3518 ]
3519 deps = [
3520 "modules/svg",
3521 "//third_party/libpng",
3522 ]
3523 }
3524
3525 libfuzzer_app("api_draw_functions") {
3526 sources = [
3527 "fuzz/FuzzDrawFunctions.cpp",
3528 "fuzz/oss_fuzz/FuzzDrawFunctions.cpp",
3529 ]
3530 deps = []
3531 }
3532
3533 libfuzzer_app("api_ddl_threading") {
3534 sources = [
3535 "fuzz/FuzzDDLThreading.cpp",
3536 "fuzz/oss_fuzz/FuzzDDLThreading.cpp",
3537 ]
3538 deps = []
3539 }
3540
3541 libfuzzer_app("api_gradients") {
3542 sources = [
3543 "fuzz/FuzzGradients.cpp",
3544 "fuzz/oss_fuzz/FuzzGradients.cpp",
3545 ]
3546 deps = []
3547 }
3548
3549 libfuzzer_app("api_image_filter") {
3550 sources = [
3551 "fuzz/FuzzCanvas.cpp",
3552 "fuzz/FuzzCanvasHelpers.cpp",
3553 "fuzz/FuzzCanvasHelpers.h",
3554 "fuzz/oss_fuzz/FuzzAPIImageFilter.cpp",
3555 ]
3556 deps = [ "//third_party/libpng" ]
3557 }
3558
3559 libfuzzer_app("api_path_measure") {
3560 sources = [
3561 "fuzz/FuzzPathMeasure.cpp",
3562 "fuzz/oss_fuzz/FuzzPathMeasure.cpp",
3563 ]
3564 deps = []
3565 }
3566
3567 libfuzzer_app("api_pathop") {
3568 sources = [
3569 "fuzz/FuzzPathop.cpp",
3570 "fuzz/oss_fuzz/FuzzPathop.cpp",
3571 ]
3572 deps = []
3573 }
3574
3575 libfuzzer_app("api_triangulation") {
3576 sources = [
3577 "fuzz/FuzzTriangulation.cpp",
3578 "fuzz/oss_fuzz/FuzzTriangulation.cpp",
3579 ]
3580 deps = []
3581 }
3582
3583 libfuzzer_app("api_raster_n32_canvas") {
3584 sources = [
3585 "fuzz/FuzzCanvas.cpp",
3586 "fuzz/FuzzCanvasHelpers.cpp",
3587 "fuzz/FuzzCanvasHelpers.h",
3588 "fuzz/oss_fuzz/FuzzRasterN32Canvas.cpp",
3589 ]
3590 deps = [
3591 "modules/svg",
3592 "//third_party/libpng",
3593 ]
3594 }
3595
3596 libfuzzer_app("api_regionop") {
3597 sources = [
3598 "fuzz/FuzzRegionOp.cpp",
3599 "fuzz/oss_fuzz/FuzzRegionOp.cpp",
3600 ]
3601 deps = []
3602 }
3603
3604 if (skia_enable_ganesh) {
3605 libfuzzer_app("api_mock_gpu_canvas") {
3606 sources = [
3607 "fuzz/FuzzCanvas.cpp",
3608 "fuzz/FuzzCanvasHelpers.cpp",
3609 "fuzz/FuzzCanvasHelpers.h",
3610 "fuzz/oss_fuzz/FuzzMockGPUCanvas.cpp",
3611 ]
3612 deps = [
3613 ":gpu_tool_utils",
3614 "modules/svg",
3615 "//third_party/libpng",
3616 ]
3617 }
3618 }
3619
3620 if (skia_enable_graphite && skia_enable_precompile) {
3621 libfuzzer_app("api_precompile") {
3622 sources = [
3623 "fuzz/FuzzPrecompile.cpp",
3624 "fuzz/oss_fuzz/FuzzPrecompile.cpp",
3625 ]
3626 deps = [ ":gpu_tool_utils" ]
3627 }
3628 }
3629
3630 libfuzzer_app("api_null_canvas") {
3631 sources = [
3632 "fuzz/FuzzCanvas.cpp",
3633 "fuzz/FuzzCanvasHelpers.cpp",
3634 "fuzz/FuzzCanvasHelpers.h",
3635 "fuzz/oss_fuzz/FuzzNullCanvas.cpp",
3636 ]
3637 deps = [
3638 "modules/svg",
3639 "//third_party/libpng",
3640 ]
3641 }
3642
3643 libfuzzer_app("api_skparagraph") {
3644 sources = [
3645 "fuzz/FuzzSkParagraph.cpp",
3646 "fuzz/oss_fuzz/FuzzSkParagraph.cpp",
3647 ]
3648 deps = [ "modules/skparagraph" ]
3649 }
3650
3651 libfuzzer_app("api_svg_canvas") {
3652 sources = [
3653 "fuzz/FuzzCanvas.cpp",
3654 "fuzz/FuzzCanvasHelpers.cpp",
3655 "fuzz/FuzzCanvasHelpers.h",
3656 "fuzz/oss_fuzz/FuzzAPISVGCanvas.cpp",
3657 ]
3658 deps = [
3659 "modules/svg",
3660 "//third_party/libpng",
3661 ]
3662 }
3663
3664 if (skia_use_libpng_encode) {
3665 libfuzzer_app("png_encoder") {
3666 sources = [
3667 "fuzz/FuzzEncoders.cpp",
3668 "fuzz/oss_fuzz/FuzzPNGEncoder.cpp",
3669 ]
3670 deps = []
3671 }
3672 }
3673
3674 if (skia_use_rust_png_encode) {
3675 libfuzzer_app("png_rust_encoder") {
3676 sources = [
3677 "fuzz/FuzzEncoders.cpp",
3678 "fuzz/oss_fuzz/FuzzPNGRustEncoder.cpp",
3679 ]
3680 deps = []
3681 }
3682 }
3683
3684 libfuzzer_app("jpeg_encoder") {
3685 sources = [
3686 "fuzz/FuzzEncoders.cpp",
3687 "fuzz/oss_fuzz/FuzzJPEGEncoder.cpp",
3688 ]
3689 deps = []
3690 }
3691
3692 libfuzzer_app("webp_encoder") {
3693 sources = [
3694 "fuzz/FuzzEncoders.cpp",
3695 "fuzz/oss_fuzz/FuzzWEBPEncoder.cpp",
3696 ]
3697 deps = []
3698 }
3699
3700 libfuzzer_app("skottie_json") {
3701 sources = [ "modules/skottie/fuzz/FuzzSkottieJSON.cpp" ]
3702 deps = [
3703 "modules/jsonreader",
3704 "modules/skottie",
3705 "modules/svg",
3706 ]
3707 }
3708
3709 libfuzzer_app("skjson") {
3710 sources = [ "fuzz/oss_fuzz/FuzzJSON.cpp" ]
3711 deps = [ "modules/jsonreader" ]
3712 }
3713
3714 libfuzzer_app("api_polyutils") {
3715 sources = [
3716 "fuzz/FuzzPolyUtils.cpp",
3717 "fuzz/oss_fuzz/FuzzPolyUtils.cpp",
3718 ]
3719 deps = [ ":skia" ]
3720 }
3721
3722 libfuzzer_app("android_codec") {
3723 sources = [ "fuzz/oss_fuzz/FuzzAndroidCodec.cpp" ]
3724 deps = []
3725 }
3726
3727 libfuzzer_app("image_decode_incremental") {
3728 sources = [ "fuzz/oss_fuzz/FuzzIncrementalImage.cpp" ]
3729 deps = []
3730 }
3731
3732 libfuzzer_app("grshape") {
3733 sources = [
3734 "fuzz/FuzzCanvasHelpers.cpp",
3735 "fuzz/FuzzCanvasHelpers.h",
3736 "fuzz/FuzzGrStyledShape.cpp",
3737 "fuzz/oss_fuzz/FuzzGrStyledShape.cpp",
3738 ]
3739 deps = []
3740 }
3741
3742 libfuzzer_app("sksl2glsl") {
3743 sources = [ "fuzz/oss_fuzz/FuzzSKSL2GLSL.cpp" ]
3744 deps = []
3745 }
3746
3747 libfuzzer_app("sksl2metal") {
3748 sources = [ "fuzz/oss_fuzz/FuzzSKSL2Metal.cpp" ]
3749 deps = []
3750 }
3751
3752 libfuzzer_app("sksl2pipeline") {
3753 sources = [ "fuzz/oss_fuzz/FuzzSKSL2Pipeline.cpp" ]
3754 deps = []
3755 }
3756
3757 libfuzzer_app("sksl2spirv") {
3758 sources = [ "fuzz/oss_fuzz/FuzzSKSL2SPIRV.cpp" ]
3759 deps = []
3760 }
3761
3762 libfuzzer_app("sksl2wgsl") {
3763 sources = [ "fuzz/oss_fuzz/FuzzSKSL2WGSL.cpp" ]
3764 deps = []
3765 }
3766
3767 libfuzzer_app("skdescriptor_deserialize") {
3768 sources = [ "fuzz/oss_fuzz/FuzzSkDescriptorDeserialize.cpp" ]
3769 deps = []
3770 }
3771
3772 libfuzzer_app("svg_dom") {
3773 sources = [ "fuzz/oss_fuzz/FuzzSVG.cpp" ]
3774 deps = [ "modules/svg" ]
3775 }
3776
3777 libfuzzer_app("skruntimeblender") {
3778 sources = [ "fuzz/oss_fuzz/FuzzSkRuntimeBlender.cpp" ]
3779 deps = []
3780 }
3781
3782 libfuzzer_app("skruntimecolorfilter") {
3783 sources = [ "fuzz/oss_fuzz/FuzzSkRuntimeColorFilter.cpp" ]
3784 deps = []
3785 }
3786
3787 libfuzzer_app("skruntimeeffect") {
3788 sources = [ "fuzz/oss_fuzz/FuzzSkRuntimeEffect.cpp" ]
3789 deps = []
3790 }
3791
3792 libfuzzer_app("skmeshspecification") {
3793 sources = [ "fuzz/oss_fuzz/FuzzSkMeshSpecification.cpp" ]
3794 deps = []
3795 }
3796
3797 libfuzzer_app("skp") {
3798 sources = [ "fuzz/oss_fuzz/FuzzSKP.cpp" ]
3799 deps = []
3800 }
3801
3802 libfuzzer_app("colrv1") {
3803 sources = [ "fuzz/oss_fuzz/FuzzCOLRv1.cpp" ]
3804 deps = []
3805 }
3806
3807 libfuzzer_app("quad_roots") {
3808 sources = [
3809 "fuzz/FuzzQuadRoots.cpp",
3810 "fuzz/oss_fuzz/FuzzQuadRoots.cpp",
3811 ]
3812 deps = []
3813 }
3814
3815 libfuzzer_app("cubic_roots") {
3816 sources = [
3817 "fuzz/FuzzCubicRoots.cpp",
3818 "fuzz/oss_fuzz/FuzzCubicRoots.cpp",
3819 ]
3820 deps = []
3821 }
3822
3823 libfuzzer_app("skcolorspace") {
3824 sources = [ "fuzz/oss_fuzz/FuzzColorspace.cpp" ]
3825 deps = []
3826 }
3827
3828 libfuzzer_app("parse_path") {
3829 sources = [ "fuzz/oss_fuzz/FuzzParsePath.cpp" ]
3830 deps = []
3831 }
3832 }
3833
3834 if (skia_build_rust_targets) {
3835 action("rust_hello_world") {
3836 script = "gn/bazel_build.py"
3837 sources = [ "experimental/rust_cxx/hello-world.rs" ]
3838 outputs = [ "$root_out_dir/rust_hello_world" ]
3839 args = [
3840 "//experimental/rust_cxx:rust_hello_world",
3841 "../../bazel-bin/experimental/rust_cxx/rust_hello_world",
3842 ]
3843 }
3844
3845 action("cpp_with_rust") {
3846 script = "gn/bazel_build.py"
3847 sources = [
3848 "experimental/rust_cxx/hype-bridge.rs",
3849 "experimental/rust_cxx/main.cpp",
3850 ]
3851 outputs = [ "$root_out_dir/cpp_with_rust" ]
3852 args = [
3853 "//experimental/rust_cxx:cpp_with_rust",
3854 "../../bazel-bin/experimental/rust_cxx/cpp_with_rust",
3855 ]
3856 }
3857 }