Debian Codegraph @

BUILD.gn

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