• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1################################################################################
2# Skylark macros
3################################################################################
4
5def skia_select(conditions, results):
6    """select() for conditions provided externally.
7
8    Instead of {"conditionA": resultA, "conditionB": resultB},
9    this takes two arrays, ["conditionA", "conditionB"] and [resultA, resultB].
10
11    This allows the exact targets of the conditions to be provided externally while
12    the results can live here, hiding the structure of those conditions in Google3.
13
14    Maybe this is too much paranoia?
15
16    Args:
17      conditions: [CONDITION_UNIX, CONDITION_ANDROID, CONDITION_IOS, CONDITION_WASM, ...]
18      results: [RESULT_UNIX, RESULT_ANDROID, RESULT_IOS, RESULT_WASM, ....]
19    Returns:
20      The result matching the active condition.
21    """
22    selector = {}
23    for i in range(len(conditions)):
24        selector[conditions[i]] = results[i]
25    return select(selector)
26
27def skia_glob(srcs):
28    """Replaces glob() with a version that accepts a struct.
29
30    Args:
31      srcs: struct(include=[], exclude=[])
32    Returns:
33      Equivalent of glob(srcs.include, exclude=srcs.exclude)
34    """
35    if hasattr(srcs, "include"):
36        if hasattr(srcs, "exclude"):
37            return native.glob(srcs.include, exclude = srcs.exclude)
38        else:
39            return native.glob(srcs.include)
40    return []
41
42################################################################################
43## skia_{all,public}_hdrs()
44################################################################################
45def skia_all_hdrs():
46    return native.glob([
47        "src/**/*.h",
48        "include/**/*.h",
49        "third_party/**/*.h",
50    ])
51
52def skia_public_hdrs():
53    return native.glob(
54        ["include/**/*.h"],
55        exclude = [
56            "include/private/**/*",
57        ],
58    )
59
60################################################################################
61## skia_opts_srcs()
62################################################################################
63# Intel
64SKIA_OPTS_SSE2 = "SSE2"
65
66SKIA_OPTS_SSSE3 = "SSSE3"
67
68SKIA_OPTS_SSE41 = "SSE41"
69
70SKIA_OPTS_SSE42 = "SSE42"
71
72SKIA_OPTS_AVX = "AVX"
73
74SKIA_OPTS_HSW = "HSW"
75
76# Arm
77SKIA_OPTS_NEON = "NEON"
78
79SKIA_OPTS_CRC32 = "CRC32"  # arm64
80
81def opts_srcs(opts):
82    if opts == SKIA_OPTS_SSE2:
83        return native.glob([
84            "src/opts/*_SSE2.cpp",
85            "src/opts/*_sse2.cpp",  # No matches currently.
86        ])
87    elif opts == SKIA_OPTS_SSSE3:
88        return native.glob([
89            "src/opts/*_SSSE3.cpp",
90            "src/opts/*_ssse3.cpp",
91        ])
92    elif opts == SKIA_OPTS_SSE41:
93        return native.glob([
94            "src/opts/*_sse41.cpp",
95        ])
96    elif opts == SKIA_OPTS_SSE42:
97        return native.glob([
98            "src/opts/*_sse42.cpp",
99        ])
100    elif opts == SKIA_OPTS_AVX:
101        return native.glob([
102            "src/opts/*_avx.cpp",
103        ])
104    elif opts == SKIA_OPTS_HSW:
105        return native.glob([
106            "src/opts/*_hsw.cpp",
107        ])
108    elif opts == SKIA_OPTS_NEON:
109        return native.glob([
110            "src/opts/*_neon.cpp",
111        ])
112    elif opts == SKIA_OPTS_CRC32:
113        return native.glob([
114            "src/opts/*_crc32.cpp",
115        ])
116    else:
117        fail("skia_opts_srcs parameter 'opts' must be one of SKIA_OPTS_*.")
118
119def opts_cflags(opts):
120    if opts == SKIA_OPTS_SSE2:
121        return ["-msse2"]
122    elif opts == SKIA_OPTS_SSSE3:
123        return ["-mssse3"]
124    elif opts == SKIA_OPTS_SSE41:
125        return ["-msse4.1"]
126    elif opts == SKIA_OPTS_SSE42:
127        return ["-msse4.2"]
128    elif opts == SKIA_OPTS_AVX:
129        return ["-mavx"]
130    elif opts == SKIA_OPTS_HSW:
131        return ["-mavx2", "-mf16c", "-mfma"]
132    elif opts == SKIA_OPTS_NEON:
133        return ["-mfpu=neon"]
134    elif opts == SKIA_OPTS_CRC32:
135        # NDK r11's Clang (3.8) doesn't pass along this -march setting correctly to an external
136        # assembler, so we do it manually with -Wa.  This is just a bug, fixed in later Clangs.
137        return ["-march=armv8-a+crc", "-Wa,-march=armv8-a+crc"]
138    else:
139        return []
140
141SKIA_CPU_ARM = "ARM"
142
143SKIA_CPU_ARM64 = "ARM64"
144
145SKIA_CPU_X86 = "X86"
146
147SKIA_CPU_OTHER = "OTHER"
148
149def opts_rest_srcs(cpu):
150    srcs = []
151    if cpu == SKIA_CPU_ARM or cpu == SKIA_CPU_ARM64:
152        srcs += native.glob([
153            "src/opts/*_arm.cpp",
154            "src/opts/SkBitmapProcState_opts_none.cpp",
155        ])
156        if cpu == SKIA_CPU_ARM64:
157            # NEON doesn't need special flags to compile on ARM64.
158            srcs += native.glob([
159                "src/opts/*_neon.cpp",
160            ])
161    elif cpu == SKIA_CPU_X86:
162        srcs += native.glob([
163            "src/opts/*_x86.cpp",
164        ])
165    elif cpu == SKIA_CPU_OTHER:
166        srcs += native.glob([
167            "src/opts/*_none.cpp",
168        ])
169    else:
170        fail("opts_rest_srcs parameter 'cpu' must be one of " +
171             "SKIA_CPU_{ARM,ARM64,X86,OTHER}.")
172    return srcs
173
174def skia_opts_deps(cpu):
175    res = [":opts_rest"]
176
177    if cpu == SKIA_CPU_ARM:
178        res += [":opts_neon"]
179
180    if cpu == SKIA_CPU_ARM64:
181        res += [":opts_crc32"]
182
183    if cpu == SKIA_CPU_X86:
184        res += [
185            ":opts_sse2",
186            ":opts_ssse3",
187            ":opts_sse41",
188            ":opts_sse42",
189            ":opts_avx",
190            ":opts_hsw",
191        ]
192
193    return res
194
195################################################################################
196## BASE_SRCS
197################################################################################
198
199# All platform-independent SRCS.
200BASE_SRCS_ALL = struct(
201    include = [
202        "include/private/**/*.h",
203        "src/**/*.h",
204        "src/**/*.cpp",
205        "src/**/*.inc",
206    ],
207    exclude = [
208        # Exclude platform-dependent files.
209        "src/codec/*",
210        "src/device/xps/*",  # Windows-only. Move to ports?
211        "src/doc/*_XPS.cpp",  # Windows-only. Move to ports?
212        "src/gpu/gl/android/*",
213        "src/gpu/gl/egl/*",
214        "src/gpu/gl/glfw/*",
215        "src/gpu/gl/glx/*",
216        "src/gpu/gl/iOS/*",
217        "src/gpu/gl/mac/*",
218        "src/gpu/gl/win/*",
219        "src/opts/**/*",
220        "src/ports/**/*",
221        "src/utils/android/**/*",
222        "src/utils/mac/**/*",
223        "src/utils/win/**/*",
224
225        # Exclude multiple definitions.
226        "src/gpu/gl/GrGLMakeNativeInterface_none.cpp",
227        "src/pdf/SkDocument_PDF_None.cpp",  # We use src/pdf/SkPDFDocument.cpp.
228
229        # Exclude files that don't compile everywhere.
230        "src/svg/**/*",  # Depends on xml, SkJpegCodec, and SkPngCodec.
231        "src/xml/**/*",  # Avoid dragging in expat when not needed.
232
233        # Exclude all GL specific files
234        "src/gpu/gl/*",
235        "src/gpu/gl/builders/*",
236
237        # Exclude all WebGL specific files
238        "src/gpu/gl/webgl/*",
239
240        # Currently exclude all vulkan specific files
241        "src/gpu/vk/*",
242
243        # Currently exclude all Direct3D specific files
244        "src/gpu/d3d/*",
245
246        # Currently exclude all Dawn-specific files
247        "src/gpu/dawn/*",
248
249        # Defines main.
250        "src/sksl/SkSLMain.cpp",
251
252        # Only used to regenerate the lexer
253        "src/sksl/lex/*",
254    ],
255)
256
257def codec_srcs(limited):
258    """Sources for the codecs. Excludes Raw, and Ico, Webp, and Png if limited."""
259
260    exclude = ["src/codec/*Raw*.cpp"]
261    if limited:
262        exclude += [
263            "src/codec/*Ico*.cpp",
264            "src/codec/*Webp*.cpp",
265            "src/codec/*Png*",
266        ]
267    return native.glob(["src/codec/*.cpp"], exclude = exclude)
268
269GL_SRCS_UNIX = struct(
270    include = [
271        "src/gpu/gl/*.cpp",
272        "src/gpu/gl/*.h",
273        "src/gpu/gl/builders/*.cpp",
274        "src/gpu/gl/builders/*.h",
275    ],
276    exclude = [],
277)
278PORTS_SRCS_UNIX = struct(
279    include = [
280        "src/ports/**/*.cpp",
281        "src/ports/**/*.h",
282    ],
283    exclude = [
284        "src/ports/*CG*",
285        "src/ports/*WIC*",
286        "src/ports/*android*",
287        "src/ports/*chromium*",
288        "src/ports/*mac*",
289        "src/ports/*mozalloc*",
290        "src/ports/*nacl*",
291        "src/ports/*win*",
292        "src/ports/*NDK*",
293        "src/ports/SkFontMgr_custom_directory_factory.cpp",
294        "src/ports/SkFontMgr_custom_embedded_factory.cpp",
295        "src/ports/SkFontMgr_custom_empty_factory.cpp",
296        "src/ports/SkFontMgr_empty_factory.cpp",
297        "src/ports/SkFontMgr_fontconfig_factory.cpp",
298        "src/ports/SkFontMgr_fuchsia.cpp",
299        "src/ports/SkImageGenerator_none.cpp",
300    ],
301)
302
303GL_SRCS_ANDROID = struct(
304    include = [
305        "src/gpu/gl/*.cpp",
306        "src/gpu/gl/*.h",
307        "src/gpu/gl/builders/*.cpp",
308        "src/gpu/gl/builders/*.h",
309        "src/gpu/gl/android/*.cpp",
310    ],
311    exclude = [
312        "src/gpu/gl/GrGLMakeNativeInterface_none.cpp",
313    ],
314)
315PORTS_SRCS_ANDROID = struct(
316    include = [
317        "src/ports/**/*.cpp",
318        "src/ports/**/*.h",
319    ],
320    exclude = [
321        "src/ports/*CG*",
322        "src/ports/*FontConfig*",
323        "src/ports/*WIC*",
324        "src/ports/*chromium*",
325        "src/ports/*fontconfig*",
326        "src/ports/*mac*",
327        "src/ports/*mozalloc*",
328        "src/ports/*nacl*",
329        "src/ports/*win*",
330        "src/ports/*NDK*",  # TODO (scroggo): enable NDK decoding/encoding in Google3
331        "src/ports/SkDebug_stdio.cpp",
332        "src/ports/SkFontMgr_custom_directory_factory.cpp",
333        "src/ports/SkFontMgr_custom_embedded_factory.cpp",
334        "src/ports/SkFontMgr_custom_empty_factory.cpp",
335        "src/ports/SkFontMgr_empty_factory.cpp",
336        "src/ports/SkFontMgr_fuchsia.cpp",
337        "src/ports/SkImageGenerator_none.cpp",
338    ],
339)
340
341PORTS_SRCS_ANDROID_NO_FONT = struct(
342    include = [
343        "src/ports/**/*.cpp",
344        "src/ports/**/*.h",
345    ],
346    exclude = [
347        "src/ports/*CG*",
348        "src/ports/*FontConfig*",
349        "src/ports/*WIC*",
350        "src/ports/*chromium*",
351        "src/ports/*fontconfig*",
352        "src/ports/*mac*",
353        "src/ports/*mozalloc*",
354        "src/ports/*nacl*",
355        "src/ports/*win*",
356        "src/ports/*NDK*",
357        "src/ports/SkDebug_stdio.cpp",
358        "src/ports/SkFontMgr_a*",
359        "src/ports/SkFontHost_Free*",
360        "src/ports/SkFontMgr_custom*",
361        "src/ports/SkFontMgr_fuchsia.cpp",
362        "src/ports/SkImageGenerator_none.cpp",
363    ],
364)
365
366GL_SRCS_IOS = struct(
367    include = [
368        "src/gpu/gl/*.cpp",
369        "src/gpu/gl/*.h",
370        "src/gpu/gl/builders/*.cpp",
371        "src/gpu/gl/builders/*.h",
372        "src/gpu/gl/iOS/GrGLMakeNativeInterface_iOS.cpp",
373    ],
374    exclude = [
375        "src/gpu/gl/GrGLMakeNativeInterface_none.cpp",
376    ],
377)
378PORTS_SRCS_IOS = struct(
379    include = [
380        "src/ports/**/*.cpp",
381        "src/ports/**/*.h",
382        "src/utils/mac/*.cpp",
383    ],
384    exclude = [
385        "src/ports/*FontConfig*",
386        "src/ports/*FreeType*",
387        "src/ports/*WIC*",
388        "src/ports/*android*",
389        "src/ports/*chromium*",
390        "src/ports/*fontconfig*",
391        "src/ports/*mozalloc*",
392        "src/ports/*nacl*",
393        "src/ports/*win*",
394        "src/ports/*NDK*",
395        "src/ports/SkFontMgr_custom.cpp",
396        "src/ports/SkFontMgr_custom_directory.cpp",
397        "src/ports/SkFontMgr_custom_embedded.cpp",
398        "src/ports/SkFontMgr_custom_empty.cpp",
399        "src/ports/SkFontMgr_custom_directory_factory.cpp",
400        "src/ports/SkFontMgr_custom_embedded_factory.cpp",
401        "src/ports/SkFontMgr_custom_empty_factory.cpp",
402        "src/ports/SkFontMgr_empty_factory.cpp",
403        "src/ports/SkFontMgr_fuchsia.cpp",
404        "src/ports/SkImageGenerator_none.cpp",
405    ],
406)
407
408GL_SRCS_WASM = struct(
409    include = [
410        "src/gpu/gl/*.cpp",
411        "src/gpu/gl/*.h",
412        "src/gpu/gl/builders/*.cpp",
413        "src/gpu/gl/builders/*.h",
414        "src/gpu/gl/egl/GrGLMakeEGLInterface.cpp",
415        "src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp",
416    ],
417    exclude = [
418        "src/gpu/gl/GrGLMakeNativeInterface_none.cpp",
419    ],
420)
421PORTS_SRCS_WASM = struct(
422    include = [
423        "src/ports/**/*.cpp",
424        "src/ports/**/*.h",
425    ],
426    exclude = [
427        # commented lines below left in because they indicate specifically what is
428        # included here and not in other PORTS_SRCS lists.
429        "src/ports/*FontConfig*",
430        #"src/ports/*FreeType*",
431        "src/ports/*WIC*",
432        "src/ports/*CG*",
433        "src/ports/*android*",
434        "src/ports/*chromium*",
435        "src/ports/*fontconfig*",
436        "src/ports/*mac*",
437        "src/ports/*mozalloc*",
438        "src/ports/*nacl*",
439        "src/ports/*win*",
440        "src/ports/*NDK*",
441        #"src/ports/SkDebug_stdio.cpp",
442        #"src/ports/SkFontMgr_custom.cpp",
443        "src/ports/SkFontMgr_custom_directory.cpp",
444        "src/ports/SkFontMgr_custom_directory_factory.cpp",
445        "src/ports/SkFontMgr_custom_embedded.cpp",
446        "src/ports/SkFontMgr_custom_embedded_factory.cpp",
447        "src/ports/SkFontMgr_custom_empty.cpp",
448        "src/ports/SkFontMgr_custom_empty_factory.cpp",
449        # "src/ports/SkFontMgr_empty_factory.cpp",
450        "src/ports/SkFontMgr_fontconfig_factory.cpp",
451        "src/ports/SkFontMgr_fuchsia.cpp",
452        "src/ports/SkImageGenerator_none.cpp",
453    ],
454)
455
456GL_SRCS_FUCHSIA = struct(
457    include = [
458        "src/gpu/vk/*.cpp",
459        "src/gpu/vk/*.h",
460    ],
461    exclude = [],
462)
463PORTS_SRCS_FUCHSIA = struct(
464    include = [
465        "src/ports/**/*.cpp",
466        "src/ports/**/*.h",
467    ],
468    exclude = [
469        "src/ports/*FontConfig*",
470        #"src/ports/*FreeType*",
471        "src/ports/*WIC*",
472        "src/ports/*CG*",
473        "src/ports/*android*",
474        "src/ports/*chromium*",
475        "src/ports/*fontconfig*",
476        "src/ports/*mac*",
477        "src/ports/*mozalloc*",
478        "src/ports/*nacl*",
479        "src/ports/*win*",
480        "src/ports/*NDK*",
481        #"src/ports/SkDebug_stdio.cpp",
482        #"src/ports/SkFontMgr_custom.cpp",
483        "src/ports/SkFontMgr_custom_directory.cpp",
484        "src/ports/SkFontMgr_custom_directory_factory.cpp",
485        "src/ports/SkFontMgr_custom_embedded.cpp",
486        "src/ports/SkFontMgr_custom_embedded_factory.cpp",
487        "src/ports/SkFontMgr_custom_empty.cpp",
488        "src/ports/SkFontMgr_custom_empty_factory.cpp",
489        #"src/ports/SkFontMgr_empty_factory.cpp",
490        "src/ports/SkFontMgr_fontconfig_factory.cpp",
491        #"src/ports/SkFontMgr_fuchsia.cpp",
492        "src/ports/SkImageGenerator_none.cpp",
493    ],
494)
495
496GL_SRCS_MACOS = struct(
497    include = [
498        "src/gpu/gl/*.cpp",
499        "src/gpu/gl/*.h",
500        "src/gpu/gl/builders/*.cpp",
501        "src/gpu/gl/builders/*.h",
502        "src/gpu/gl/mac/GrGLMakeNativeInterface_mac.cpp",
503    ],
504    exclude = [
505        "src/gpu/gl/GrGLMakeNativeInterface_none.cpp",
506    ],
507)
508PORTS_SRCS_MACOS = PORTS_SRCS_IOS
509
510def base_srcs():
511    return skia_glob(BASE_SRCS_ALL)
512
513def ports_srcs(os_conditions):
514    return skia_select(
515        os_conditions,
516        [
517            skia_glob(PORTS_SRCS_UNIX),
518            skia_glob(PORTS_SRCS_ANDROID),
519            skia_glob(PORTS_SRCS_IOS),
520            skia_glob(PORTS_SRCS_WASM),
521            skia_glob(PORTS_SRCS_FUCHSIA),
522            skia_glob(PORTS_SRCS_MACOS),
523            skia_glob(PORTS_SRCS_ANDROID_NO_FONT),
524        ],
525    )
526
527def gl_srcs(os_conditions):
528    return skia_select(
529        os_conditions,
530        [
531            skia_glob(GL_SRCS_UNIX),
532            skia_glob(GL_SRCS_ANDROID),
533            skia_glob(GL_SRCS_IOS),
534            skia_glob(GL_SRCS_WASM),
535            skia_glob(GL_SRCS_FUCHSIA),
536            skia_glob(GL_SRCS_MACOS),
537            skia_glob(GL_SRCS_ANDROID),
538        ],
539    )
540
541def skia_srcs(os_conditions):
542    return base_srcs() + ports_srcs(os_conditions) + gl_srcs(os_conditions)
543
544def metal_objc_srcs():
545    return native.glob(
546        [
547            "include/**/*.h",
548            "src/**/*.h",
549            "src/gpu/mtl/**/*.mm",
550            "third_party/**/*.h",
551        ],
552    ) + [
553        "src/image/SkSurface_GpuMtl.mm",
554    ]
555
556################################################################################
557## INCLUDES
558################################################################################
559
560# Includes needed by Skia implementation.  Not public includes.
561INCLUDES = [
562    ".",
563    "include/android",
564    "include/c",
565    "include/codec",
566    "include/config",
567    "include/core",
568    "include/docs",
569    "include/effects",
570    "include/encode",
571    "include/gpu",
572    "include/pathops",
573    "include/ports",
574    "include/private",
575    "include/third_party/skcms",
576    "include/utils",
577    "include/utils/mac",
578    "src/codec",
579    "src/core",
580    "src/gpu",
581    "src/image",
582    "src/images",
583    "src/lazy",
584    "src/opts",
585    "src/pdf",
586    "src/ports",
587    "src/sfnt",
588    "src/shaders",
589    "src/shaders/gradients",
590    "src/sksl",
591    "src/utils",
592    "third_party/gif",
593]
594
595################################################################################
596## DM_SRCS
597################################################################################
598
599DM_SRCS_ALL = struct(
600    include = [
601        "dm/*.cpp",
602        "dm/*.h",
603        "experimental/pipe/*.cpp",
604        "experimental/pipe/*.h",
605        "gm/*.cpp",
606        "gm/*.h",
607        "gm/verifiers/*.cpp",
608        "gm/verifiers/*.h",
609        # TODO(fmalita): SVG sources should not be included here
610        "modules/svg/include/*.h",
611        "modules/svg/src/*.cpp",
612        "src/utils/SkMultiPictureDocument.cpp",
613        "src/xml/*.cpp",
614        "tests/*.cpp",
615        "tests/*.h",
616        "tools/AutoreleasePool.h",
617        "tools/BinaryAsset.h",
618        "tools/CrashHandler.cpp",
619        "tools/CrashHandler.h",
620        "tools/DDLPromiseImageHelper.cpp",
621        "tools/DDLPromiseImageHelper.h",
622        "tools/DDLTileHelper.cpp",
623        "tools/DDLTileHelper.h",
624        "tools/HashAndEncode.cpp",
625        "tools/HashAndEncode.h",
626        "tools/ProcStats.cpp",
627        "tools/ProcStats.h",
628        "tools/Registry.h",
629        "tools/ResourceFactory.h",
630        "tools/Resources.cpp",
631        "tools/Resources.h",
632        "tools/RuntimeBlendUtils.cpp",
633        "tools/RuntimeBlendUtils.h",
634        "tools/SkMetaData.cpp",
635        "tools/SkMetaData.h",
636        "tools/SkSharingProc.cpp",
637        "tools/ToolUtils.cpp",
638        "tools/ToolUtils.h",
639        "tools/UrlDataManager.cpp",
640        "tools/UrlDataManager.h",
641        "tools/debugger/*.cpp",
642        "tools/debugger/*.h",
643        "tools/flags/*.cpp",
644        "tools/flags/*.h",
645        "tools/fonts/RandomScalerContext.cpp",
646        "tools/fonts/RandomScalerContext.h",
647        "tools/fonts/TestFontMgr.cpp",
648        "tools/fonts/TestFontMgr.h",
649        "tools/fonts/TestSVGTypeface.cpp",
650        "tools/fonts/TestSVGTypeface.h",
651        "tools/fonts/TestTypeface.cpp",
652        "tools/fonts/TestTypeface.h",
653        "tools/fonts/ToolUtilsFont.cpp",
654        "tools/fonts/test_font_index.inc",
655        "tools/fonts/test_font_monospace.inc",
656        "tools/fonts/test_font_sans_serif.inc",
657        "tools/fonts/test_font_serif.inc",
658        "tools/gpu/**/*.cpp",
659        "tools/gpu/**/*.h",
660        "tools/ios_utils.h",
661        "tools/random_parse_path.cpp",
662        "tools/random_parse_path.h",
663        "tools/timer/*.cpp",
664        "tools/timer/*.h",
665        "tools/trace/*.cpp",
666        "tools/trace/*.h",
667    ],
668    exclude = [
669        "gm/cgms.cpp",
670        "gm/fiddle.cpp",
671        "gm/video_decoder.cpp",
672        "tests/FontMgrAndroidParserTest.cpp",  # Android-only.
673        "tests/FontMgrFontConfigTest.cpp",  # FontConfig-only.
674        "tests/TypefaceMacTest.cpp",  # CoreText-only.
675        "tests/SkParagraphTest.cpp",  # Skipping tests for now.
676        "tools/gpu/d3d/*",
677        "tools/gpu/dawn/*",
678        "tools/gpu/gl/angle/*",
679        "tools/gpu/gl/egl/*",
680        "tools/gpu/gl/glx/*",
681        "tools/gpu/gl/iOS/*",
682        "tools/gpu/gl/mac/*",
683        "tools/gpu/gl/win/*",
684        "tools/timer/SysTimer_mach.cpp",
685        "tools/timer/SysTimer_windows.cpp",
686    ],
687)
688
689################################################################################
690## dm_srcs()
691################################################################################
692
693def dm_srcs(os_conditions):
694    """Sources for the dm binary for the specified os."""
695    return skia_glob(DM_SRCS_ALL) + skia_select(
696        os_conditions,
697        [
698            ["tests/FontMgrFontConfigTest.cpp"],  # Unix
699            ["tests/FontMgrAndroidParserTest.cpp"],  # Android
700            ["tests/TypefaceMacTest.cpp"],  # iOS
701            [],  # WASM
702            [],  # Fuchsia
703            ["tests/TypefaceMacTest.cpp"],  # macOS
704        ],
705    )
706
707################################################################################
708## DM_ARGS
709################################################################################
710
711def DM_ARGS(asan):
712    source = ["gm", "image", "lottie"]
713
714    # TODO(benjaminwagner): f16, pic-8888, serialize-8888, and tiles_rt-8888 fail.
715    config = ["565", "8888", "pdf"]
716    match = ["~Codec_78329453"]
717    return (["--src"] + source + ["--config"] + config + ["--nonativeFonts"] +
718            ["--match"] + match)
719
720################################################################################
721## COPTS
722################################################################################
723
724def base_copts(os_conditions):
725    return ["-Wno-implicit-fallthrough"] + skia_select(
726        os_conditions,
727        [
728            # UNIX
729            [
730                # Internal use of deprecated methods. :(
731                "-Wno-deprecated-declarations",
732                # TODO(kjlubick)
733                "-Wno-self-assign",  # Spurious warning in tests/PathOpsDVectorTest.cpp?
734            ],
735            # ANDROID
736            [
737                # 'GrResourceCache' declared with greater visibility than the
738                # type of its field 'GrResourceCache::fPurgeableQueue'... bogus.
739                "-Wno-error=attributes",
740            ],
741            [],  # iOS
742            [],  # wasm
743            [],  # Fuchsia
744            [],  # macOS
745        ],
746    )
747
748################################################################################
749## DEFINES
750################################################################################
751
752def base_defines(os_conditions):
753    return [
754        # Chrome DEFINES.
755        "SK_USE_FREETYPE_EMBOLDEN",
756        # Turn on a few Google3-specific build fixes.
757        "SK_BUILD_FOR_GOOGLE3",
758        # Required for building dm.
759        "GR_TEST_UTILS",
760        # Staging flags for API changes
761        "SK_PARAGRAPH_GRAPHEME_EDGES",
762        # Should remove after we update golden images
763        "SK_WEBP_ENCODER_USE_DEFAULT_METHOD",
764        # Experiment to diagnose image diffs in Google3
765        "SK_DISABLE_LOWP_RASTER_PIPELINE",
766        # JPEG is in codec_limited and is included in all
767        # builds except the no_codec android build
768    ] + skia_select(
769        os_conditions,
770        [
771            # UNIX
772            [
773                "PNG_SKIP_SETJMP_CHECK",
774                "SK_BUILD_FOR_UNIX",
775                "SK_CODEC_DECODES_PNG",
776                "SK_CODEC_DECODES_WEBP",
777                "SK_ENCODE_PNG",
778                "SK_ENCODE_WEBP",
779                "SK_R32_SHIFT=16",
780                "SK_GL",
781                "SK_CODEC_DECODES_JPEG",
782                "SK_ENCODE_JPEG",
783                "SK_HAS_ANDROID_CODEC",
784            ],
785            # ANDROID
786            [
787                "SK_BUILD_FOR_ANDROID",
788                "SK_CODEC_DECODES_PNG",
789                "SK_CODEC_DECODES_WEBP",
790                "SK_ENCODE_PNG",
791                "SK_ENCODE_WEBP",
792                "SK_GL",
793                "SK_CODEC_DECODES_JPEG",
794                "SK_ENCODE_JPEG",
795                "SK_HAS_ANDROID_CODEC",
796            ],
797            # IOS
798            [
799                "SK_BUILD_FOR_IOS",
800                "SK_NO_COMMAND_BUFFER",  # Test tools that use thread_local.
801                "SK_GL",
802                "SK_CODEC_DECODES_JPEG",
803                "SK_ENCODE_JPEG",
804                "SK_HAS_ANDROID_CODEC",
805            ],
806            # WASM
807            [
808                "SK_DISABLE_LEGACY_SHADERCONTEXT",
809                "SK_DISABLE_TRACING",
810                "SK_GL",
811                "SK_SUPPORT_GPU=1",
812                "SK_DISABLE_AAA",
813                "SK_DISABLE_EFFECT_DESERIALIZATION",
814                "SK_FORCE_8_BYTE_ALIGNMENT",
815                "SKNX_NO_SIMD",
816                "SK_CODEC_DECODES_JPEG",
817                "SK_ENCODE_JPEG",
818                "SK_HAS_ANDROID_CODEC",
819            ],
820            # FUCHSIA
821            [
822                "SK_BUILD_FOR_UNIX",
823                "SK_CODEC_DECODES_PNG",
824                "SK_CODEC_DECODES_WEBP",
825                "SK_ENCODE_PNG",
826                "SK_ENCODE_WEBP",
827                "SK_R32_SHIFT=16",
828                "SK_VULKAN",
829                "SK_CODEC_DECODES_JPEG",
830                "SK_ENCODE_JPEG",
831                "SK_HAS_ANDROID_CODEC",
832            ],
833            # MACOS
834            [
835                "SK_BUILD_FOR_MAC",
836                "SK_GL",
837                "SK_CODEC_DECODES_JPEG",
838                "SK_ENCODE_JPEG",
839                "SK_HAS_ANDROID_CODEC",
840            ],
841            # ANDROID W/ NO CODECS
842            [
843                "SK_BUILD_FOR_ANDROID",
844                "SK_GL",
845            ],
846        ],
847    )
848
849################################################################################
850## LINKOPTS
851################################################################################
852
853def base_linkopts(os_conditions):
854    return [
855        "-ldl",
856    ] + skia_select(
857        os_conditions,
858        [
859            [],  # Unix
860            # ANDROID
861            [
862                "-lEGL",
863                "-lGLESv2",
864            ],
865            # IOS
866            [
867                "-framework CoreFoundation",
868                "-framework CoreGraphics",
869                "-framework CoreText",
870                "-framework ImageIO",
871                "-framework MobileCoreServices",
872            ],
873            [],  # wasm
874            [],  # Fuchsia
875            # MACOS
876            [
877                "-framework CoreFoundation",
878                "-framework CoreGraphics",
879                "-framework CoreText",
880                "-framework ImageIO",
881                "-framework ApplicationServices",
882            ],
883        ],
884    )
885
886################################################################################
887## sksg_lib
888################################################################################
889
890def sksg_lib_hdrs():
891    return native.glob(["modules/sksg/include/*.h"])
892
893def sksg_lib_srcs():
894    return native.glob([
895        "modules/sksg/src/*.cpp",
896        "modules/sksg/src/*.h",
897    ])
898
899################################################################################
900## skparagraph_lib
901################################################################################
902
903def skparagraph_lib_hdrs():
904    return native.glob(["modules/skparagraph/include/*.h"])
905
906def skparagraph_lib_srcs():
907    return native.glob(["modules/skparagraph/src/*.cpp"])
908
909################################################################################
910## skresources_lib
911################################################################################
912
913def skresources_lib_hdrs():
914    return ["modules/skresources/include/SkResources.h"]
915
916def skresources_lib_srcs():
917    return ["modules/skresources/src/SkResources.cpp"]
918
919################################################################################
920## skottie_lib
921################################################################################
922
923def skottie_lib_hdrs():
924    return native.glob(["modules/skottie/include/*.h"])
925
926def skottie_lib_srcs():
927    return native.glob(
928        [
929            "modules/skottie/src/*.cpp",
930            "modules/skottie/src/*.h",
931            "modules/skottie/src/animator/*.cpp",
932            "modules/skottie/src/animator/*.h",
933            "modules/skottie/src/effects/*.cpp",
934            "modules/skottie/src/effects/*.h",
935            "modules/skottie/src/layers/*.cpp",
936            "modules/skottie/src/layers/*.h",
937            "modules/skottie/src/layers/shapelayer/*.cpp",
938            "modules/skottie/src/layers/shapelayer/*.h",
939            "modules/skottie/src/text/*.cpp",
940            "modules/skottie/src/text/*.h",
941        ],
942        exclude = [
943            "modules/skottie/src/SkottieTest.cpp",
944            "modules/skottie/src/SkottieTool.cpp",
945        ],
946    )
947
948################################################################################
949## skottie_utils
950################################################################################
951
952SKOTTIE_UTILS_HDRS = [
953    "modules/skottie/utils/SkottieUtils.h",
954]
955
956SKOTTIE_UTILS_SRCS = [
957    "modules/skottie/utils/SkottieUtils.cpp",
958]
959
960################################################################################
961## skottie_shaper
962################################################################################
963
964SKOTTIE_SHAPER_HDRS = [
965    "modules/skottie/src/text/SkottieShaper.h",
966]
967
968SKOTTIE_SHAPER_SRCS = [
969    "modules/skottie/src/text/SkottieShaper.cpp",
970]
971
972################################################################################
973## skottie_tool
974################################################################################
975
976SKOTTIE_TOOL_SRCS = [
977    "modules/skottie/src/SkottieTool.cpp",
978    "modules/skresources/src/SkResources.cpp",
979    "modules/skresources/include/SkResources.h",
980    # TODO(benjaminwagner): Add "flags" target.
981    "tools/flags/CommandLineFlags.cpp",
982    "tools/flags/CommandLineFlags.h",
983]
984
985################################################################################
986## SkShaper
987################################################################################
988
989# Stubs, pending SkUnicode fission
990SKUNICODE_ICU_BUILTIN_SRCS = [
991    "modules/skunicode/include/SkUnicode.h",
992    "modules/skunicode/src/SkUnicode_icu.cpp",
993    "modules/skunicode/src/SkUnicode_icu.h",
994    "modules/skunicode/src/SkUnicode_icu_builtin.cpp",
995]
996
997SKUNICODE_ICU_RUNTIME_SRCS = [
998    "modules/skunicode/include/SkUnicode.h",
999    "modules/skunicode/src/SkUnicode_icu.cpp",
1000    "modules/skunicode/src/SkUnicode_icu.h",
1001    "modules/skunicode/src/SkUnicode_icu_runtime.cpp",
1002]
1003
1004SKSHAPER_HARFBUZZ_SRCS = [
1005    "modules/skshaper/include/SkShaper.h",
1006    "modules/skshaper/src/SkShaper.cpp",
1007    "modules/skshaper/src/SkShaper_harfbuzz.cpp",
1008    "modules/skshaper/src/SkShaper_primitive.cpp",
1009]
1010
1011SKSHAPER_PRIMITIVE_SRCS = [
1012    "modules/skshaper/include/SkShaper.h",
1013    "modules/skshaper/src/SkShaper.cpp",
1014    "modules/skshaper/src/SkShaper_primitive.cpp",
1015]
1016
1017################################################################################
1018## skottie_ios_lib
1019################################################################################
1020
1021SKOTTIE_IOS_LIB_SRCS = [
1022    "tools/skottie_ios_app/SkiaContext.mm",
1023    "tools/skottie_ios_app/SkiaUIContext.mm",
1024    "tools/skottie_ios_app/SkiaViewController.mm",
1025    "tools/skottie_ios_app/SkottieViewController.mm",
1026]
1027
1028SKOTTIE_IOS_LIB_HDRS = [
1029    "tools/skottie_ios_app/SkiaContext.h",
1030    "tools/skottie_ios_app/SkiaViewController.h",
1031    "tools/skottie_ios_app/SkottieViewController.h",
1032]
1033
1034SKOTTIE_IOS_LIB_SDK_FRAMEWORKS = [
1035    "Foundation",
1036    "UIKit",
1037]
1038
1039################################################################################
1040## svg_lib
1041################################################################################
1042
1043def svg_lib_hdrs():
1044    return native.glob(["modules/svg/include/*.h"])
1045
1046def svg_lib_srcs():
1047    return native.glob(["modules/svg/src/*.cpp"])
1048
1049################################################################################
1050## svg_tool
1051################################################################################
1052
1053SVG_TOOL_SRCS = [
1054    "modules/svg/utils/SvgTool.cpp",
1055    # TODO(benjaminwagner): Add "flags" target.
1056    "tools/flags/CommandLineFlags.cpp",
1057    "tools/flags/CommandLineFlags.h",
1058]
1059