forked from google/skia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BUILD.gn
3572 lines (3275 loc) · 96 KB
/
BUILD.gn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright 2016 Google Inc.
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("gn/flutter_defines.gni")
import("gn/fuchsia_defines.gni")
import("gn/shared_sources.gni")
import("gn/skia.gni")
import("gn/toolchain/wasm.gni")
if (is_fuchsia) {
import("//build/fuchsia/sdk.gni")
import("build/fuchsia/fuchsia_download_sdk.gni")
}
if (skia_use_dawn) {
import("//third_party/externals/dawn/scripts/dawn_features.gni")
}
if (defined(skia_settings)) {
import(skia_settings)
}
import("gn/ios.gni")
# Skia public API, generally provided by :skia.
config("skia_public") {
include_dirs = [ "." ]
defines = []
cflags_objcc = []
if (is_component_build) {
defines += [ "SKIA_DLL" ]
}
if (is_fuchsia || is_linux) {
defines += [ "SK_R32_SHIFT=16" ]
}
if (skia_enable_flutter_defines) {
defines += flutter_defines
}
if (skia_enable_optimize_size) {
defines += [
"SK_ENABLE_OPTIMIZE_SIZE",
"SK_FORCE_AAA",
]
}
if (skia_enable_sksl) {
defines += [ "SK_ENABLE_SKSL" ]
}
if (skia_enable_sksl_in_raster_pipeline) {
defines += [ "SK_ENABLE_SKSL_IN_RASTER_PIPELINE" ]
}
if (skia_enable_skvm) {
defines += [ "SK_ENABLE_SKVM" ]
}
if (skia_enable_precompile) {
defines += [ "SK_ENABLE_PRECOMPILE" ]
}
if (is_fuchsia) {
defines += fuchsia_defines
}
if (is_wasm) {
defines += wasm_defines
}
if (skia_gl_standard == "gles") {
defines += [ "SK_ASSUME_GL_ES=1" ]
} else if (skia_gl_standard == "gl") {
defines += [ "SK_ASSUME_GL=1" ]
} else if (skia_gl_standard == "webgl") {
defines += [
"SK_ASSUME_WEBGL=1",
"SK_USE_WEBGL",
]
}
if (skia_enable_ganesh) {
defines += [ "SK_GANESH" ]
}
if (skia_enable_graphite) {
defines += [ "SK_GRAPHITE" ]
}
if (skia_use_perfetto) {
defines += [ "SK_USE_PERFETTO" ]
}
# Some older versions of the Clang toolchain change the visibility of
# symbols decorated with API_AVAILABLE macro to be visible. Users of such
# toolchains suppress the use of this macro till toolchain updates are made.
if (is_mac || is_ios) {
if (skia_enable_api_available_macro) {
defines += [ "SK_ENABLE_API_AVAILABLE" ]
} else {
cflags_objcc += [ "-Wno-unguarded-availability" ]
}
}
}
# Skia internal APIs, used by Skia itself and a few test tools.
config("skia_private") {
visibility = [ "./*" ]
defines = [ "SK_GAMMA_APPLY_TO_A8" ]
if (skia_use_fixed_gamma_text) {
defines += [
"SK_GAMMA_EXPONENT=1.4",
"SK_GAMMA_CONTRAST=0.0",
]
}
if (is_skia_dev_build && !is_wasm) {
defines += [
"SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=1",
"GR_TEST_UTILS=1",
]
if (skia_enable_graphite) {
defines += [ "GRAPHITE_TEST_UTILS=1" ]
}
}
libs = []
lib_dirs = []
if (skia_use_gl && skia_use_angle) {
defines += [ "SK_ANGLE" ]
}
if (skia_use_vma) {
defines += [ "SK_USE_VMA" ]
}
if (skia_enable_winuwp) {
defines += [ "SK_WINUWP" ]
}
if (skia_print_sksl_shaders) {
defines += [ "SK_PRINT_SKSL_SHADERS" ]
}
if (skia_print_native_shaders) {
defines += [ "SK_PRINT_NATIVE_SHADERS" ]
}
}
# Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
config("skia_library") {
visibility = [ "./*" ]
defines = [ "SKIA_IMPLEMENTATION=1" ]
}
skia_library_configs = [
":skia_public",
":skia_private",
":skia_library",
]
# Use for CPU-specific Skia code that needs particular compiler flags.
template("opts") {
if (invoker.enabled) {
skia_source_set(target_name) {
visibility = [ ":*" ]
check_includes = false
configs = skia_library_configs
forward_variables_from(invoker, "*")
if (defined(invoker.configs)) {
configs += invoker.configs
}
}
} else {
# If not enabled, a phony empty target that swallows all otherwise unused variables.
skia_source_set(target_name) {
visibility = [ ":*" ]
check_includes = false
forward_variables_from(invoker,
"*",
[
"sources",
"cflags",
])
}
}
}
is_x86 = current_cpu == "x64" || current_cpu == "x86"
opts("ssse3") {
enabled = is_x86
sources = skia_opts.ssse3_sources
if (!is_clang && is_win) {
defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSSE3" ]
} else {
cflags = [ "-mssse3" ]
}
}
opts("avx") {
enabled = is_x86
sources = skia_opts.avx_sources
if (is_win) {
cflags = [ "/arch:AVX" ]
} else {
cflags = [ "-mavx" ]
}
}
opts("hsw") {
enabled = is_x86
sources = skia_opts.hsw_sources
if (is_win) {
cflags = [ "/arch:AVX2" ]
} else {
cflags = [ "-march=haswell" ]
}
}
opts("skx") {
enabled = is_x86
sources = skia_opts.skx_sources
if (is_win) {
cflags = [ "/arch:AVX512" ]
} else {
cflags = [ "-march=skylake-avx512" ]
}
}
# Any feature of Skia that requires third-party code should be optional and use this template.
template("optional") {
if (invoker.enabled) {
config(target_name + "_public") {
if (defined(invoker.public_defines)) {
defines = invoker.public_defines
}
if (defined(invoker.public_configs)) {
configs = invoker.public_configs
}
if (defined(invoker.public_include_dirs)) {
include_dirs = invoker.public_include_dirs
}
}
skia_source_set(target_name) {
visibility = [ ":*" ]
check_includes = false
configs = skia_library_configs
# "*" clobbers the current scope; append to existing configs
forward_variables_from(invoker,
"*",
[
"configs",
"public_defines",
"sources_for_tests",
"sources_when_disabled",
])
if (defined(invoker.configs)) {
configs += invoker.configs
}
all_dependent_configs = [ ":" + target_name + "_public" ]
}
if (defined(invoker.sources_for_tests) && skia_enable_tools) {
skia_source_set(target_name + "_tests") {
visibility = [ ":*" ]
check_includes = false
configs = skia_library_configs
# "*" clobbers the current scope; append to existing configs
forward_variables_from(invoker,
"*",
[
"configs",
"public_defines",
"sources",
"sources_for_tests",
"sources_when_disabled",
])
if (defined(invoker.configs)) {
configs += invoker.configs
}
testonly = true
sources = invoker.sources_for_tests
if (!defined(deps)) {
deps = []
}
deps += [ ":test" ]
all_dependent_configs = [ ":" + target_name + "_public" ]
}
}
} else {
skia_source_set(target_name) {
visibility = [ ":*" ]
configs = skia_library_configs
# "*" clobbers the current scope; append to existing configs
forward_variables_from(invoker,
"*",
[
"configs",
"public",
"public_defines",
"public_deps",
"deps",
"libs",
"frameworks",
"sources",
"sources_for_tests",
"sources_when_disabled",
])
if (defined(invoker.configs)) {
configs += invoker.configs
}
if (defined(invoker.sources_when_disabled)) {
sources = invoker.sources_when_disabled
}
}
if (defined(invoker.sources_for_tests)) {
skia_source_set(target_name + "_tests") {
visibility = [ ":*" ]
}
}
}
}
optional("android_utils") {
enabled = skia_enable_android_utils
public = [
"client_utils/android/BRDAllocator.h",
"client_utils/android/BitmapRegionDecoder.h",
"client_utils/android/FrontBufferedStream.h",
]
public_defines = [ "SK_ENABLE_ANDROID_UTILS" ]
sources = [
"client_utils/android/BitmapRegionDecoder.cpp",
"client_utils/android/FrontBufferedStream.cpp",
]
}
group("fontmgr_factory") {
public_deps = [ skia_fontmgr_factory ]
}
optional("fontmgr_empty_factory") {
enabled = true
sources = [ "src/ports/SkFontMgr_empty_factory.cpp" ]
}
optional("fontmgr_android") {
enabled = skia_enable_fontmgr_android
deps = [
":typeface_freetype",
"//third_party/expat",
]
public = [ "include/ports/SkFontMgr_android.h" ]
sources = [
"src/ports/SkFontMgr_android.cpp",
"src/ports/SkFontMgr_android_parser.cpp",
"src/ports/SkFontMgr_android_parser.h",
]
sources_for_tests = [ "tests/FontMgrAndroidParserTest.cpp" ]
}
optional("fontmgr_android_factory") {
enabled = skia_enable_fontmgr_android
deps = [ ":fontmgr_android" ]
sources = [ "src/ports/SkFontMgr_android_factory.cpp" ]
}
optional("fontmgr_custom") {
enabled =
skia_enable_fontmgr_custom_directory ||
skia_enable_fontmgr_custom_embedded || skia_enable_fontmgr_custom_empty
deps = [ ":typeface_freetype" ]
public = [ "src/ports/SkFontMgr_custom.h" ]
sources = [ "src/ports/SkFontMgr_custom.cpp" ]
}
optional("fontmgr_custom_directory") {
enabled = skia_enable_fontmgr_custom_directory
deps = [
":fontmgr_custom",
":typeface_freetype",
]
public = [ "include/ports/SkFontMgr_directory.h" ]
sources = [ "src/ports/SkFontMgr_custom_directory.cpp" ]
}
optional("fontmgr_custom_directory_factory") {
enabled = skia_enable_fontmgr_custom_directory
deps = [ ":fontmgr_custom_directory" ]
sources = [ "src/ports/SkFontMgr_custom_directory_factory.cpp" ]
}
optional("fontmgr_custom_embedded") {
enabled = skia_enable_fontmgr_custom_embedded
deps = [
":fontmgr_custom",
":typeface_freetype",
]
sources = [ "src/ports/SkFontMgr_custom_embedded.cpp" ]
}
optional("fontmgr_custom_embedded_factory") {
enabled = skia_enable_fontmgr_custom_embedded
deps = [ ":fontmgr_custom_embedded" ]
sources = [ "src/ports/SkFontMgr_custom_embedded_factory.cpp" ]
}
optional("fontmgr_custom_empty") {
enabled = skia_enable_fontmgr_custom_empty
deps = [
":fontmgr_custom",
":typeface_freetype",
]
public = [ "include/ports/SkFontMgr_empty.h" ]
sources = [ "src/ports/SkFontMgr_custom_empty.cpp" ]
}
optional("fontmgr_custom_empty_factory") {
enabled = skia_enable_fontmgr_custom_empty
deps = [ ":fontmgr_custom_empty" ]
sources = [ "src/ports/SkFontMgr_custom_empty_factory.cpp" ]
}
optional("fontmgr_fontconfig") {
enabled = skia_enable_fontmgr_fontconfig
# The public header includes fontconfig.h and uses FcConfig*
public_deps = [ "//third_party:fontconfig" ]
public = [ "include/ports/SkFontMgr_fontconfig.h" ]
deps = [ ":typeface_freetype" ]
sources = [ "src/ports/SkFontMgr_fontconfig.cpp" ]
sources_for_tests = [ "tests/FontMgrFontConfigTest.cpp" ]
}
optional("fontmgr_fontconfig_factory") {
enabled = skia_enable_fontmgr_fontconfig
deps = [ ":fontmgr_fontconfig" ]
sources = [ "src/ports/SkFontMgr_fontconfig_factory.cpp" ]
}
optional("fontmgr_FontConfigInterface") {
enabled = skia_enable_fontmgr_FontConfigInterface
deps = [
":typeface_freetype",
"//third_party:fontconfig",
]
public = [
"include/ports/SkFontConfigInterface.h",
"include/ports/SkFontMgr_FontConfigInterface.h",
]
sources = [
"src/ports/SkFontConfigInterface.cpp",
"src/ports/SkFontConfigInterface_direct.cpp",
"src/ports/SkFontConfigInterface_direct_factory.cpp",
"src/ports/SkFontConfigTypeface.h",
"src/ports/SkFontMgr_FontConfigInterface.cpp",
]
sources_for_tests = [ "tests/FCITest.cpp" ]
}
optional("fontmgr_FontConfigInterface_factory") {
enabled = skia_enable_fontmgr_FontConfigInterface
deps = [ ":fontmgr_FontConfigInterface" ]
sources = [ "src/ports/SkFontMgr_FontConfigInterface_factory.cpp" ]
}
optional("fontmgr_fuchsia") {
enabled = skia_enable_fontmgr_fuchsia
deps = []
if (is_fuchsia && using_fuchsia_sdk) {
deps += [ "//build/fuchsia/fidl:fuchsia.fonts" ]
} else {
deps = [ "//sdk/fidl/fuchsia.fonts" ]
}
public = [ "src/ports/SkFontMgr_fuchsia.h" ]
sources = [ "src/ports/SkFontMgr_fuchsia.cpp" ]
}
optional("fontmgr_mac_ct") {
enabled = skia_use_fonthost_mac
public_defines = [ "SK_TYPEFACE_FACTORY_CORETEXT" ]
public = [
"include/ports/SkFontMgr_mac_ct.h",
"include/ports/SkTypeface_mac.h",
]
sources = [
"src/ports/SkFontMgr_mac_ct.cpp",
"src/ports/SkScalerContext_mac_ct.cpp",
"src/ports/SkScalerContext_mac_ct.h",
"src/ports/SkTypeface_mac_ct.cpp",
"src/ports/SkTypeface_mac_ct.h",
]
sources_for_tests = [ "tests/TypefaceMacTest.cpp" ]
if (is_mac) {
frameworks = [
# AppKit symbols NSFontWeightXXX may be dlsym'ed.
"AppKit.framework",
"ApplicationServices.framework",
]
}
if (is_ios) {
frameworks = [
"CoreFoundation.framework",
"CoreGraphics.framework",
"CoreText.framework",
# UIKit symbols UIFontWeightXXX may be dlsym'ed.
"UIKit.framework",
]
}
}
optional("fontmgr_mac_ct_factory") {
enabled = skia_use_fonthost_mac
deps = [ ":fontmgr_mac_ct" ]
sources = [ "src/ports/SkFontMgr_mac_ct_factory.cpp" ]
}
optional("fontmgr_win") {
enabled = skia_enable_fontmgr_win
public_defines = [ "SK_TYPEFACE_FACTORY_DIRECTWRITE" ]
public = [ "include/ports/SkTypeface_win.h" ]
sources = [
"include/ports/SkFontMgr_indirect.h",
"include/ports/SkRemotableFontMgr.h",
"src/fonts/SkFontMgr_indirect.cpp",
"src/ports/SkFontMgr_win_dw.cpp",
"src/ports/SkScalerContext_win_dw.cpp",
"src/ports/SkScalerContext_win_dw.h",
"src/ports/SkTypeface_win_dw.cpp",
"src/ports/SkTypeface_win_dw.h",
]
}
optional("fontmgr_win_factory") {
enabled = skia_enable_fontmgr_win
deps = [ ":fontmgr_win" ]
sources = [ "src/ports/SkFontMgr_win_dw_factory.cpp" ]
}
optional("fontmgr_win_gdi") {
enabled = skia_enable_fontmgr_win_gdi
public = [ "include/ports/SkTypeface_win.h" ]
sources = [ "src/ports/SkFontHost_win.cpp" ]
libs = [ "Gdi32.lib" ]
}
if (skia_lex) {
skia_executable("sksllex") {
sources = [
"src/sksl/lex/DFA.h",
"src/sksl/lex/DFAState.h",
"src/sksl/lex/LexUtil.h",
"src/sksl/lex/Main.cpp",
"src/sksl/lex/NFA.cpp",
"src/sksl/lex/NFA.h",
"src/sksl/lex/NFAState.h",
"src/sksl/lex/NFAtoDFA.h",
"src/sksl/lex/RegexNode.cpp",
"src/sksl/lex/RegexNode.h",
"src/sksl/lex/RegexParser.cpp",
"src/sksl/lex/RegexParser.h",
"src/sksl/lex/TransitionTable.cpp",
"src/sksl/lex/TransitionTable.h",
]
include_dirs = [ "." ]
}
action("run_sksllex") {
script = "gn/run_sksllex.py"
deps = [ ":sksllex(//gn/toolchain:$host_toolchain)" ]
sources = [ "src/sksl/lex/sksl.lex" ]
# GN insists its outputs should go somewhere underneath target_out_dir, so we trick it with a
# path that starts with target_out_dir and then uses ".." to back up into the src dir.
outputs = [
"$target_out_dir/" + rebase_path("src/sksl/SkSLLexer.h", target_out_dir),
# the script also modifies the corresponding .cpp file, but if we tell GN that it gets
# confused due to the same file being named by two different paths
]
sksllex_path = "$root_out_dir/"
sksllex_path += "sksllex"
if (host_os == "win") {
sksllex_path += ".exe"
}
args = [
rebase_path(sksllex_path),
rebase_path("bin/clang-format"),
rebase_path("bin/fetch-clang-format"),
rebase_path("src"),
]
}
} else {
group("run_sksllex") {
}
}
if (skia_compile_modules || skia_compile_sksl_tests) {
# Copy the module source files into the same directory as skslc.
copy("sksl_modules") {
sources = [
"src/sksl/sksl_compute.sksl",
"src/sksl/sksl_frag.sksl",
"src/sksl/sksl_gpu.sksl",
"src/sksl/sksl_graphite_frag.sksl",
"src/sksl/sksl_graphite_vert.sksl",
"src/sksl/sksl_public.sksl",
"src/sksl/sksl_rt_shader.sksl",
"src/sksl/sksl_shared.sksl",
"src/sksl/sksl_vert.sksl",
]
skslc_dir = "$root_out_dir/"
if (host_toolchain != default_toolchain_name) {
skslc_dir += "$host_toolchain/"
}
outputs = [ "$skslc_dir/{{source_file_part}}" ]
}
}
if (skia_compile_modules) {
# Generate the sksl-minify binary.
skia_executable("sksl-minify") {
defines = [
"SKSL_STANDALONE",
"SK_DISABLE_TRACING",
]
sources = skslc_deps
sources += [
"tools/sksl-minify/SkSLMinify.cpp",
"tools/skslc/ProcessWorklist.cpp",
"tools/skslc/ProcessWorklist.h",
]
libs = []
if (is_win) {
sources += [ "tools/SkGetExecutablePath_win.cpp" ]
} else if (is_mac || is_ios) {
sources += [ "tools/SkGetExecutablePath_mac.cpp" ]
} else if (is_linux || is_android) {
sources += [ "tools/SkGetExecutablePath_linux.cpp" ]
}
if (is_win) {
sources += [ "src/ports/SkOSFile_win.cpp" ]
} else {
sources += [ "src/ports/SkOSFile_posix.cpp" ]
libs += [ "dl" ]
}
sources += skia_sksl_sources
sources += skia_sksl_gpu_sources
include_dirs = [ "." ]
deps = [ ":run_sksllex" ]
}
sksl_minify_path = "$root_out_dir/"
if (host_toolchain != default_toolchain_name) {
sksl_minify_path += "$host_toolchain/"
}
sksl_minify_path += "sksl-minify"
if (host_os == "win") {
sksl_minify_path += ".exe"
}
# Use minify_sksl.py to precompile all of the modules.
minify_sksl_sources = get_target_outputs(":sksl_modules")
minify_sksl_outputs = []
foreach(src, minify_sksl_sources) {
name = get_path_info(src, "name")
# GN insists its outputs should go somewhere underneath target_out_dir, so we trick it with a
# path that starts with target_out_dir and then uses ".." to back up into the src dir.
minify_sksl_outputs += [ "$target_out_dir/" + rebase_path(
"src/sksl/generated/$name.minified.sksl",
target_out_dir) ]
minify_sksl_outputs += [ "$target_out_dir/" + rebase_path(
"src/sksl/generated/$name.unoptimized.sksl",
target_out_dir) ]
}
action("minify_sksl") {
script = "gn/minify_sksl.py"
deps = [
":sksl-minify(//gn/toolchain:$host_toolchain)",
":sksl_modules",
]
sources = minify_sksl_sources
outputs = minify_sksl_outputs
args = [
rebase_path(sksl_minify_path),
rebase_path("src/sksl/generated"),
]
args += rebase_path(minify_sksl_sources)
}
if (skia_compile_sksl_tests) {
# Minify our existing .rts files into golden minified outputs.
import("gn/sksl_tests.gni")
action("minify_sksl_tests") {
script = "gn/minify_sksl_tests.py"
deps = [
":sksl-minify(//gn/toolchain:$host_toolchain)",
":sksl_modules",
]
sources = []
outputs = []
response_file_contents = []
args = [
# Comments are the variable name in minify_sksl_tests.py
rebase_path(sksl_minify_path), # sksl_minify
rebase_path("src/sksl/sksl_shared.sksl"), # shared_module
rebase_path("src/sksl/sksl_public.sksl"), # public_module
rebase_path("resources"), # input_root_dir
rebase_path("tests"), # output_root_dir
"{{response_file_name}}", # input_file
]
testsDir = get_path_info("tests/sksl/", "abspath")
resourcesDir = get_path_info("resources/sksl/", "abspath")
foreach(partialPath, sksl_minify_tests_sources) {
dst = testsDir + partialPath
src = resourcesDir + partialPath
dir = get_path_info(dst, "dir")
name = get_path_info(dst, "name")
ext = get_path_info(dst, "extension")
if (ext == "rts" || ext == "rtcf" || ext == "rtb") {
response_file_contents += [ rebase_path(src) ]
sources += [ src ]
outputs += [ target_out_dir + "/" +
rebase_path(dir + "/" + name + ".minified.sksl",
target_out_dir) ]
}
}
}
}
} else {
group("minify_sksl") {
}
group("minify_sksl_tests") {
}
}
# `Compile SkSL Tests` relies on skslc and the precompiled modules.
if (skia_compile_sksl_tests) {
# Build skslc.
skia_executable("skslc") {
defines = [
"SKSL_ENABLE_TRACING",
"SKSL_STANDALONE",
"SK_DISABLE_TRACING",
"SK_ENABLE_SKVM",
"SK_ENABLE_SKSL_IN_RASTER_PIPELINE",
"SK_ENABLE_SPIRV_CROSS",
"SK_ENABLE_SPIRV_VALIDATION",
"SK_ENABLE_WGSL_VALIDATION",
]
sources = skslc_deps
sources += [
"tools/skslc/Main.cpp",
"tools/skslc/ProcessWorklist.cpp",
"tools/skslc/ProcessWorklist.h",
]
libs = []
if (is_win) {
sources += [ "tools/SkGetExecutablePath_win.cpp" ]
} else if (is_mac || is_ios) {
sources += [ "tools/SkGetExecutablePath_mac.cpp" ]
} else if (is_linux || is_android) {
sources += [ "tools/SkGetExecutablePath_linux.cpp" ]
}
if (is_win) {
sources += [ "src/ports/SkOSFile_win.cpp" ]
} else {
sources += [ "src/ports/SkOSFile_posix.cpp" ]
libs += [ "dl" ]
}
sources += skia_sksl_sources
sources += skia_sksl_gpu_sources
sources += skia_sksl_tracing_sources
include_dirs = [ "." ]
deps = [
":run_sksllex",
":skvm_jit",
"//third_party/externals/dawn/src/tint:libtint",
"//third_party/externals/spirv-tools:spvtools",
"//third_party/externals/spirv-tools:spvtools_val",
"//third_party/spirv-cross:spirv_cross",
]
}
skslc_path = "$root_out_dir/"
if (host_toolchain != default_toolchain_name) {
skslc_path += "$host_toolchain/"
}
skslc_path += "skslc"
if (host_os == "win") {
skslc_path += ".exe"
}
# Build the test files using skslc.
import("gn/sksl_tests.gni")
template("compile_sksl") {
# Compile the passed-in `sources` into `outputs` using skslc, with the given language/settings.
action("compile_sksl_${target_name}") {
script = "gn/compile_sksl_tests.py"
deps = [
":sksl_modules",
":skslc(//gn/toolchain:$host_toolchain)",
]
sources = []
outputs = []
response_file_contents = []
args = [
# Comments are the variable name in compile_sksl_tests.py
rebase_path(skslc_path), # skslc
invoker.lang, # lang
invoker.settings, # settings
rebase_path("resources"), # input_root_dir
rebase_path("tests"), # output_root_dir
"{{response_file_name}}", # input_file
]
testsDir = get_path_info("tests/sksl/", "abspath")
resourcesDir = get_path_info("resources/sksl/", "abspath")
foreach(partialPath, invoker.sources) {
dst = testsDir + partialPath
src = resourcesDir + partialPath
dir = get_path_info(dst, "dir")
name = get_path_info(dst, "name")
ext = get_path_info(dst, "extension")
response_file_contents += [ rebase_path(src) ]
sources += [ src ]
foreach(outExtension, invoker.outExtensions) {
# SPIR-V uses separate extensions for .vert shaders.
if (ext == "vert" && outExtension == ".asm.frag") {
outExtension = ".asm.vert"
}
outputs +=
[ target_out_dir + "/" +
rebase_path(dir + "/" + name + outExtension, target_out_dir) ]
}
}
}
}
compile_sksl("glsl_tests") {
sources = sksl_glsl_tests_sources + sksl_glsl_settings_tests_sources
outExtensions = [ ".glsl" ]
lang = "--glsl"
settings = "--settings"
}
compile_sksl("glsl_nosettings_tests") {
sources = sksl_glsl_settings_tests_sources
outExtensions = [ "StandaloneSettings.glsl" ]
lang = "--glsl"
settings = "--nosettings"
}
compile_sksl("metal_tests") {
sources = sksl_metal_tests_sources
outExtensions = [ ".metal" ]
lang = "--metal"
settings = "--settings"
}
compile_sksl("hlsl_tests") {
sources = sksl_hlsl_tests_sources
outExtensions = [ ".hlsl" ]
lang = "--hlsl"
settings = "--settings"
}
compile_sksl("skrp_tests") {
sources = sksl_skrp_tests_sources
outExtensions = [ ".skrp" ]
lang = "--skrp"
settings = "--settings"
}
compile_sksl("stage_tests") {
sources = sksl_stage_tests_sources
outExtensions = [ ".stage" ]
lang = "--stage"
settings = "--settings"
}
compile_sksl("spirv_tests") {
sources = sksl_spirv_tests_sources
outExtensions = [ ".asm.frag" ]
lang = "--spirv"
settings = "--settings"
}
compile_sksl("wgsl_tests") {
sources = sksl_wgsl_tests_sources
outExtensions = [ ".wgsl" ]
lang = "--wgsl"
settings = "--settings"
}
} else {
group("compile_sksl_glsl_tests") {
}
group("compile_sksl_glsl_nosettings_tests") {
}
group("compile_sksl_metal_tests") {
}
group("compile_sksl_hlsl_tests") {
}
group("compile_sksl_skrp_tests") {
}
group("compile_sksl_spirv_tests") {
}
group("compile_sksl_wgsl_tests") {
}
}
optional("gpu_shared") {
enabled = skia_enable_ganesh || skia_enable_graphite
deps = []
libs = []
public_defines = []
public_deps = []
frameworks = []
sources = skia_shared_gpu_sources + skia_sksl_gpu_sources
if (skia_use_dawn) {
public_defines += [ "SK_DAWN" ]
sources += skia_shared_dawn_sources
# When building for WASM, the WebGPU headers are provided by Emscripten. For native builds we
# have to depend on Dawn directly.
if (!skia_use_webgpu) {
public_deps += [
"//third_party/externals/dawn/include/dawn:cpp_headers",
"//third_party/externals/dawn/src/dawn:cpp",
"//third_party/externals/dawn/src/dawn:proc",
]
if (dawn_enable_d3d12 || dawn_enable_desktop_gl || dawn_enable_metal ||
dawn_enable_opengles || dawn_enable_vulkan) {
public_deps += [ "//third_party/externals/dawn/src/dawn/native" ]
}
if (dawn_enable_d3d12) {
libs += [
"d3d12.lib",
"dxgi.lib",
"d3dcompiler.lib",
]
} else if (dawn_enable_metal) {
frameworks += [ "Metal.framework" ]
}
}
}
if (skia_use_direct3d) {
# Must be defined when 'skia_sksl_gpu_sources' is built, even if the rest of skia_use_direct3d
# is handled only in the 'gpu' component.
public_defines += [ "SK_ENABLE_SPIRV_CROSS" ]
deps += [ "//third_party/spirv-cross:spirv_cross" ]
}
if (skia_use_vulkan) {
public_defines += [ "SK_VULKAN" ]
sources += skia_shared_vk_sources
if (skia_enable_vulkan_debug_layers) {
public_defines += [ "SK_ENABLE_VK_LAYERS" ]
}
if (skia_use_vma) {
public_deps += [ "third_party/vulkanmemoryallocator" ]
}
}
if (skia_use_metal) {
public_defines += [ "SK_METAL" ]
sources += skia_shared_mtl_sources
}
}
optional("gpu") {
enabled = skia_enable_ganesh
deps = [
":compile_sksl_glsl_nosettings_tests",
":compile_sksl_glsl_tests",
":compile_sksl_metal_tests",
":compile_sksl_skrp_tests",
":compile_sksl_spirv_tests",
":gpu_shared",
":minify_sksl",
":run_sksllex",
]
if (skia_generate_workarounds) {
deps += [ ":workaround_list" ]
}
public_defines = []
public_configs = []
public_deps = []
public = skia_gpu_public
sources = skia_ganesh_private
libs = []
frameworks = []
if (skia_use_gl) {
public_defines += [ "SK_GL" ]
if (is_android) {