blob: 729d99eabe2eb86285f070f0ec6b1dc640f78291 [file] [log] [blame]
benjaminwagner56f6d062016-01-13 10:45:19 -08001################################################################################
2# Skylark macros
3################################################################################
benjaminwagner787ca872015-08-17 12:58:10 -07004
benjaminwagner56f6d062016-01-13 10:45:19 -08005is_bazel = not hasattr(native, "genmpm")
6
7def portable_select(select_dict, bazel_condition, default_condition):
Ben Wagnerb303a422018-07-31 10:31:06 -04008 """Replaces select() with a Bazel-friendly wrapper.
benjaminwagner56f6d062016-01-13 10:45:19 -08009
Ben Wagnerb303a422018-07-31 10:31:06 -040010 Args:
11 select_dict: Dictionary in the same format as select().
12 Returns:
13 If Blaze platform, returns select() using select_dict.
14 If Bazel platform, returns dependencies for condition
15 bazel_condition, or empty list if none specified.
16 """
17 if is_bazel:
18 return select_dict.get(bazel_condition, select_dict[default_condition])
19 else:
20 return select(select_dict)
benjaminwagner56f6d062016-01-13 10:45:19 -080021
22def skia_select(conditions, results):
Ben Wagnerb303a422018-07-31 10:31:06 -040023 """Replaces select() for conditions [UNIX, ANDROID, IOS]
benjaminwagner56f6d062016-01-13 10:45:19 -080024
Ben Wagnerb303a422018-07-31 10:31:06 -040025 Args:
26 conditions: [CONDITION_UNIX, CONDITION_ANDROID, CONDITION_IOS]
27 results: [RESULT_UNIX, RESULT_ANDROID, RESULT_IOS]
28 Returns:
29 The result matching the platform condition.
30 """
31 if len(conditions) != 3 or len(results) != 3:
32 fail("Must provide exactly 3 conditions and 3 results")
benjaminwagner56f6d062016-01-13 10:45:19 -080033
Ben Wagnerb303a422018-07-31 10:31:06 -040034 selector = {}
35 for i in range(3):
36 selector[conditions[i]] = results[i]
37 return portable_select(selector, conditions[2], conditions[0])
benjaminwagner56f6d062016-01-13 10:45:19 -080038
39def skia_glob(srcs):
Ben Wagnerb303a422018-07-31 10:31:06 -040040 """Replaces glob() with a version that accepts a struct.
benjaminwagner56f6d062016-01-13 10:45:19 -080041
Ben Wagnerb303a422018-07-31 10:31:06 -040042 Args:
43 srcs: struct(include=[], exclude=[])
44 Returns:
45 Equivalent of glob(srcs.include, exclude=srcs.exclude)
46 """
47 if hasattr(srcs, "include"):
48 if hasattr(srcs, "exclude"):
49 return native.glob(srcs.include, exclude = srcs.exclude)
50 else:
51 return native.glob(srcs.include)
52 return []
benjaminwagner56f6d062016-01-13 10:45:19 -080053
54################################################################################
Ben Wagner9eca72b2017-10-17 10:57:34 -040055## skia_{all,public}_hdrs()
56################################################################################
57def skia_all_hdrs():
Ben Wagnerb303a422018-07-31 10:31:06 -040058 return native.glob([
59 "src/**/*.h",
60 "include/**/*.h",
61 "third_party/**/*.h",
62 ])
Ben Wagner9eca72b2017-10-17 10:57:34 -040063
64def skia_public_hdrs():
Ben Wagnerb303a422018-07-31 10:31:06 -040065 return native.glob(
66 ["include/**/*.h"],
67 exclude = [
68 "include/private/**/*",
Ben Wagnerb303a422018-07-31 10:31:06 -040069 ],
70 )
Ben Wagner9eca72b2017-10-17 10:57:34 -040071
72################################################################################
73## skia_opts_srcs()
74################################################################################
75# Intel
76SKIA_OPTS_SSE2 = "SSE2"
77
78SKIA_OPTS_SSSE3 = "SSSE3"
79
80SKIA_OPTS_SSE41 = "SSE41"
81
82SKIA_OPTS_SSE42 = "SSE42"
83
84SKIA_OPTS_AVX = "AVX"
85
Mike Klein33d077d2018-02-27 13:43:53 -050086SKIA_OPTS_HSW = "HSW"
87
Ben Wagner9eca72b2017-10-17 10:57:34 -040088# Arm
89SKIA_OPTS_NEON = "NEON"
90
91SKIA_OPTS_CRC32 = "CRC32" # arm64
92
93def opts_srcs(opts):
Ben Wagnerb303a422018-07-31 10:31:06 -040094 if opts == SKIA_OPTS_SSE2:
95 return native.glob([
96 "src/opts/*_SSE2.cpp",
97 "src/opts/*_sse2.cpp", # No matches currently.
98 ])
99 elif opts == SKIA_OPTS_SSSE3:
100 return native.glob([
101 "src/opts/*_SSSE3.cpp",
102 "src/opts/*_ssse3.cpp",
103 ])
104 elif opts == SKIA_OPTS_SSE41:
105 return native.glob([
106 "src/opts/*_sse41.cpp",
107 ])
108 elif opts == SKIA_OPTS_SSE42:
109 return native.glob([
110 "src/opts/*_sse42.cpp",
111 ])
112 elif opts == SKIA_OPTS_AVX:
113 return native.glob([
114 "src/opts/*_avx.cpp",
115 ])
116 elif opts == SKIA_OPTS_HSW:
117 return native.glob([
118 "src/opts/*_hsw.cpp",
119 ])
120 elif opts == SKIA_OPTS_NEON:
121 return native.glob([
122 "src/opts/*_neon.cpp",
123 ])
124 elif opts == SKIA_OPTS_CRC32:
125 return native.glob([
126 "src/opts/*_crc32.cpp",
127 ])
128 else:
129 fail("skia_opts_srcs parameter 'opts' must be one of SKIA_OPTS_*.")
Ben Wagner9eca72b2017-10-17 10:57:34 -0400130
131def opts_cflags(opts):
Ben Wagnerb303a422018-07-31 10:31:06 -0400132 if opts == SKIA_OPTS_SSE2:
133 return ["-msse2"]
134 elif opts == SKIA_OPTS_SSSE3:
135 return ["-mssse3"]
136 elif opts == SKIA_OPTS_SSE41:
137 return ["-msse4.1"]
138 elif opts == SKIA_OPTS_SSE42:
139 return ["-msse4.2"]
140 elif opts == SKIA_OPTS_AVX:
141 return ["-mavx"]
142 elif opts == SKIA_OPTS_HSW:
143 return ["-mavx2", "-mf16c", "-mfma"]
144 elif opts == SKIA_OPTS_NEON:
145 return ["-mfpu=neon"]
146 elif opts == SKIA_OPTS_CRC32:
147 # NDK r11's Clang (3.8) doesn't pass along this -march setting correctly to an external
148 # assembler, so we do it manually with -Wa. This is just a bug, fixed in later Clangs.
149 return ["-march=armv8-a+crc", "-Wa,-march=armv8-a+crc"]
150 else:
151 return []
Ben Wagner9eca72b2017-10-17 10:57:34 -0400152
153SKIA_CPU_ARM = "ARM"
154
155SKIA_CPU_ARM64 = "ARM64"
156
157SKIA_CPU_X86 = "X86"
158
159SKIA_CPU_OTHER = "OTHER"
160
161def opts_rest_srcs(cpu):
Ben Wagnerb303a422018-07-31 10:31:06 -0400162 srcs = []
163 if cpu == SKIA_CPU_ARM or cpu == SKIA_CPU_ARM64:
164 srcs += native.glob([
165 "src/opts/*_arm.cpp",
166 "src/opts/SkBitmapProcState_opts_none.cpp",
167 ])
168 if cpu == SKIA_CPU_ARM64:
169 # NEON doesn't need special flags to compile on ARM64.
170 srcs += native.glob([
171 "src/opts/*_neon.cpp",
172 ])
173 elif cpu == SKIA_CPU_X86:
174 srcs += native.glob([
175 "src/opts/*_x86.cpp",
176 ])
177 elif cpu == SKIA_CPU_OTHER:
178 srcs += native.glob([
179 "src/opts/*_none.cpp",
180 ])
181 else:
182 fail("opts_rest_srcs parameter 'cpu' must be one of " +
183 "SKIA_CPU_{ARM,ARM64,X86,OTHER}.")
184 return srcs
Ben Wagner9eca72b2017-10-17 10:57:34 -0400185
186def skia_opts_deps(cpu):
Ben Wagnerb303a422018-07-31 10:31:06 -0400187 res = [":opts_rest"]
Ben Wagner9eca72b2017-10-17 10:57:34 -0400188
Ben Wagnerb303a422018-07-31 10:31:06 -0400189 if cpu == SKIA_CPU_ARM:
190 res += [":opts_neon"]
Ben Wagner9eca72b2017-10-17 10:57:34 -0400191
Ben Wagnerb303a422018-07-31 10:31:06 -0400192 if cpu == SKIA_CPU_ARM64:
193 res += [":opts_crc32"]
Mike Kleinc29bb572017-10-24 11:40:41 -0400194
Ben Wagnerb303a422018-07-31 10:31:06 -0400195 if cpu == SKIA_CPU_X86:
196 res += [
197 ":opts_sse2",
198 ":opts_ssse3",
199 ":opts_sse41",
200 ":opts_sse42",
201 ":opts_avx",
202 ":opts_hsw",
203 ]
Ben Wagner9eca72b2017-10-17 10:57:34 -0400204
Ben Wagnerb303a422018-07-31 10:31:06 -0400205 return res
Ben Wagner9eca72b2017-10-17 10:57:34 -0400206
207################################################################################
benjaminwagner56f6d062016-01-13 10:45:19 -0800208## BASE_SRCS
209################################################################################
benjaminwagner787ca872015-08-17 12:58:10 -0700210
benjaminwagner39e7aa42015-11-18 13:26:10 -0800211# All platform-independent SRCS.
benjaminwagner56f6d062016-01-13 10:45:19 -0800212BASE_SRCS_ALL = struct(
213 include = [
Ben Wagnerdea74282017-03-16 19:15:09 -0400214 "include/private/**/*.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700215 "src/**/*.h",
216 "src/**/*.cpp",
Ben Wagnerdea74282017-03-16 19:15:09 -0400217 "src/**/*.inc",
benjaminwagner787ca872015-08-17 12:58:10 -0700218 ],
Ben Wagnerdea74282017-03-16 19:15:09 -0400219 exclude = [
benjaminwagner6f6bef82015-10-15 08:09:44 -0700220 # Exclude platform-dependent files.
Mike Klein9509e042019-05-15 21:57:48 +0000221 "src/codec/*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700222 "src/device/xps/*", # Windows-only. Move to ports?
223 "src/doc/*_XPS.cpp", # Windows-only. Move to ports?
224 "src/gpu/gl/android/*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700225 "src/gpu/gl/egl/*",
benjaminwagneraf3b35e2016-03-28 13:27:28 -0700226 "src/gpu/gl/glfw/*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700227 "src/gpu/gl/glx/*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700228 "src/gpu/gl/iOS/*",
229 "src/gpu/gl/mac/*",
230 "src/gpu/gl/win/*",
231 "src/opts/**/*",
232 "src/ports/**/*",
233 "src/utils/android/**/*",
234 "src/utils/mac/**/*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700235 "src/utils/win/**/*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700236
237 # Exclude multiple definitions.
Kevin Lubickc9210672018-10-15 11:36:55 -0400238 "src/gpu/GrPathRendering_none.cpp",
Kevin Lubick93faa672018-10-10 15:54:53 -0400239 "src/gpu/ccpr/GrCoverageCountingPathRenderer_none.cpp",
Kevin Lubickc9210672018-10-15 11:36:55 -0400240 "src/gpu/gl/GrGLMakeNativeInterface_none.cpp",
241 "src/pdf/SkDocument_PDF_None.cpp", # We use src/pdf/SkPDFDocument.cpp.
benjaminwagner6f6bef82015-10-15 08:09:44 -0700242
Ben Wagner4ccf49c2018-03-26 15:46:40 -0400243 # Exclude files that don't compile everywhere.
244 "src/svg/**/*", # Depends on xml, SkJpegCodec, and SkPngCodec.
245 "src/xml/**/*", # Avoid dragging in expat when not needed.
benjaminwagner6f6bef82015-10-15 08:09:44 -0700246
benjaminwagner39e7aa42015-11-18 13:26:10 -0800247 # Conflicting dependencies among Lua versions. See cl/107087297.
248 "src/utils/SkLua*",
249
egdaniel32119f12016-02-22 10:07:54 -0800250 # Currently exclude all vulkan specific files
251 "src/gpu/vk/*",
benjaminwagnerc8962512016-09-30 12:06:27 -0700252
Stephen White985741a2019-07-18 11:43:45 -0400253 # Currently exclude all Dawn-specific files
254 "src/gpu/dawn/*",
255
benjaminwagnerc8962512016-09-30 12:06:27 -0700256 # Defines main.
257 "src/sksl/SkSLMain.cpp",
Ethan Nicholas8d7f4ae2017-09-07 11:07:42 -0400258
259 # Only used to regenerate the lexer
260 "src/sksl/lex/*",
Brian Salomoncbcb0a12017-11-19 13:20:13 -0500261
262 # Atlas text
263 "src/atlastext/*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700264 ],
265)
266
Hal Canaryce4693f2019-11-20 21:43:54 +0000267def codec_srcs(limited):
268 """Sources for the codecs. Excludes Raw, and Ico, Webp, and Png if limited."""
Ben Wagnerec8c6602018-10-26 12:31:36 -0400269
Hal Canaryb5c217b2019-11-20 10:16:10 -0500270 exclude = ["src/codec/*Raw*.cpp"]
Hal Canaryce4693f2019-11-20 21:43:54 +0000271 if limited:
272 exclude += [
273 "src/codec/*Ico*.cpp",
274 "src/codec/*Webp*.cpp",
275 "src/codec/*Png*",
276 ]
Hal Canaryb5c217b2019-11-20 10:16:10 -0500277 return native.glob(["src/codec/*.cpp"], exclude = exclude)
Ben Wagner9eca72b2017-10-17 10:57:34 -0400278
Mike Klein7f95c292019-03-27 11:16:25 -0500279GL_SRCS_UNIX = struct(
benjaminwagner56f6d062016-01-13 10:45:19 -0800280 include = [
Brian Salomonb3ce76e2017-12-11 15:21:39 -0500281 "src/gpu/gl/GrGLMakeNativeInterface_none.cpp",
Mike Klein7f95c292019-03-27 11:16:25 -0500282 ],
283 exclude = [],
284)
285PORTS_SRCS_UNIX = struct(
286 include = [
benjaminwagner6f6bef82015-10-15 08:09:44 -0700287 "src/ports/**/*.cpp",
288 "src/ports/**/*.h",
289 ],
290 exclude = [
msarett6b4985c2016-03-10 07:15:59 -0800291 "src/ports/*CG*",
msarettfc0b6d12016-03-17 13:50:17 -0700292 "src/ports/*WIC*",
mtklein3f193a92016-03-10 08:52:05 -0800293 "src/ports/*android*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700294 "src/ports/*chromium*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700295 "src/ports/*mac*",
296 "src/ports/*mozalloc*",
297 "src/ports/*nacl*",
298 "src/ports/*win*",
benjaminwagner2211a7b2015-12-01 11:12:05 -0800299 "src/ports/SkFontMgr_custom_directory_factory.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700300 "src/ports/SkFontMgr_custom_embedded_factory.cpp",
benjaminwagnerd9dd5812016-03-21 10:45:01 -0700301 "src/ports/SkFontMgr_custom_empty_factory.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700302 "src/ports/SkFontMgr_empty_factory.cpp",
benjaminwagner2211a7b2015-12-01 11:12:05 -0800303 "src/ports/SkFontMgr_fontconfig_factory.cpp",
Sergey Ulanovf3babcd2018-11-30 17:42:00 -0800304 "src/ports/SkFontMgr_fuchsia.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700305 "src/ports/SkImageGenerator_none.cpp",
306 "src/ports/SkTLS_none.cpp",
mtkleind55d13a2015-08-18 08:51:49 -0700307 ],
308)
309
Mike Klein7f95c292019-03-27 11:16:25 -0500310GL_SRCS_ANDROID = struct(
benjaminwagner56f6d062016-01-13 10:45:19 -0800311 include = [
Ben Wagner773151f2018-08-17 09:28:53 -0400312 "src/gpu/gl/android/*.cpp",
Mike Klein7f95c292019-03-27 11:16:25 -0500313 ],
314 exclude = [],
315)
316PORTS_SRCS_ANDROID = struct(
317 include = [
benjaminwagner86ea33e2015-10-26 10:46:25 -0700318 "src/ports/**/*.cpp",
319 "src/ports/**/*.h",
320 ],
321 exclude = [
msarett6b4985c2016-03-10 07:15:59 -0800322 "src/ports/*CG*",
mtklein3f193a92016-03-10 08:52:05 -0800323 "src/ports/*FontConfig*",
msarettfc0b6d12016-03-17 13:50:17 -0700324 "src/ports/*WIC*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700325 "src/ports/*chromium*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700326 "src/ports/*fontconfig*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700327 "src/ports/*mac*",
328 "src/ports/*mozalloc*",
329 "src/ports/*nacl*",
330 "src/ports/*win*",
331 "src/ports/SkDebug_stdio.cpp",
332 "src/ports/SkFontMgr_custom_directory_factory.cpp",
333 "src/ports/SkFontMgr_custom_embedded_factory.cpp",
benjaminwagnerd9dd5812016-03-21 10:45:01 -0700334 "src/ports/SkFontMgr_custom_empty_factory.cpp",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700335 "src/ports/SkFontMgr_empty_factory.cpp",
Sergey Ulanovf3babcd2018-11-30 17:42:00 -0800336 "src/ports/SkFontMgr_fuchsia.cpp",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700337 "src/ports/SkImageGenerator_none.cpp",
338 "src/ports/SkTLS_none.cpp",
339 ],
340)
341
Mike Klein7f95c292019-03-27 11:16:25 -0500342GL_SRCS_IOS = struct(
benjaminwagner56f6d062016-01-13 10:45:19 -0800343 include = [
Brian Salomon3d6801e2017-12-11 10:06:31 -0500344 "src/gpu/gl/iOS/GrGLMakeNativeInterface_iOS.cpp",
Mike Klein7f95c292019-03-27 11:16:25 -0500345 ],
346 exclude = [],
347)
348PORTS_SRCS_IOS = struct(
349 include = [
iroth8b99ef42015-11-02 11:11:21 -0800350 "src/ports/**/*.cpp",
351 "src/ports/**/*.h",
irothab669de2016-02-16 19:17:01 -0800352 "src/utils/mac/*.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800353 ],
354 exclude = [
mtklein3f193a92016-03-10 08:52:05 -0800355 "src/ports/*FontConfig*",
356 "src/ports/*FreeType*",
msarettfc0b6d12016-03-17 13:50:17 -0700357 "src/ports/*WIC*",
iroth8b99ef42015-11-02 11:11:21 -0800358 "src/ports/*android*",
359 "src/ports/*chromium*",
360 "src/ports/*fontconfig*",
iroth8b99ef42015-11-02 11:11:21 -0800361 "src/ports/*mozalloc*",
362 "src/ports/*nacl*",
363 "src/ports/*win*",
iroth8b99ef42015-11-02 11:11:21 -0800364 "src/ports/SkFontMgr_custom.cpp",
Ben Wagner8ab590f2017-02-08 17:29:33 -0500365 "src/ports/SkFontMgr_custom_directory.cpp",
366 "src/ports/SkFontMgr_custom_embedded.cpp",
367 "src/ports/SkFontMgr_custom_empty.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800368 "src/ports/SkFontMgr_custom_directory_factory.cpp",
369 "src/ports/SkFontMgr_custom_embedded_factory.cpp",
benjaminwagnerd9dd5812016-03-21 10:45:01 -0700370 "src/ports/SkFontMgr_custom_empty_factory.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800371 "src/ports/SkFontMgr_empty_factory.cpp",
Sergey Ulanovf3babcd2018-11-30 17:42:00 -0800372 "src/ports/SkFontMgr_fuchsia.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800373 "src/ports/SkImageGenerator_none.cpp",
374 "src/ports/SkTLS_none.cpp",
375 ],
376)
377
Mike Klein7f95c292019-03-27 11:16:25 -0500378def base_srcs():
379 return skia_glob(BASE_SRCS_ALL)
380
381def ports_srcs(os_conditions):
Mike Klein299ea7b2019-03-27 13:53:08 -0500382 return skia_select(
383 os_conditions,
Ben Wagnerb303a422018-07-31 10:31:06 -0400384 [
Mike Klein7f95c292019-03-27 11:16:25 -0500385 skia_glob(PORTS_SRCS_UNIX),
386 skia_glob(PORTS_SRCS_ANDROID),
387 skia_glob(PORTS_SRCS_IOS),
Mike Klein299ea7b2019-03-27 13:53:08 -0500388 ],
389 )
Mike Klein7f95c292019-03-27 11:16:25 -0500390
391def gl_srcs(os_conditions):
Mike Klein299ea7b2019-03-27 13:53:08 -0500392 return skia_select(
393 os_conditions,
Mike Klein7f95c292019-03-27 11:16:25 -0500394 [
395 skia_glob(GL_SRCS_UNIX),
396 skia_glob(GL_SRCS_ANDROID),
397 skia_glob(GL_SRCS_IOS),
Mike Klein299ea7b2019-03-27 13:53:08 -0500398 ],
399 )
Mike Klein7f95c292019-03-27 11:16:25 -0500400
401def skia_srcs(os_conditions):
402 return base_srcs() + ports_srcs(os_conditions) + gl_srcs(os_conditions)
403
Hal Canary6ad6c502019-12-11 14:09:16 -0500404def metal_objc_srcs():
405 return native.glob(
406 [
407 "include/**/*.h",
408 "src/**/*.h",
409 "src/gpu/mtl/**/*.mm",
410 "third_party/**/*.h",
Ben Wagner8718be92019-12-11 20:11:30 -0500411 ],
Hal Canary6ad6c502019-12-11 14:09:16 -0500412 ) + [
413 "src/image/SkSurface_GpuMtl.mm",
414 ]
415
benjaminwagner56f6d062016-01-13 10:45:19 -0800416################################################################################
417## INCLUDES
418################################################################################
benjaminwagner39e7aa42015-11-18 13:26:10 -0800419
benjaminwagner787ca872015-08-17 12:58:10 -0700420# Includes needed by Skia implementation. Not public includes.
421INCLUDES = [
Mike Kleinc0bd9f92019-04-23 12:05:21 -0500422 ".",
benjaminwagnerfa7e1a02015-11-13 12:27:08 -0800423 "include/android",
benjaminwagner787ca872015-08-17 12:58:10 -0700424 "include/c",
425 "include/codec",
426 "include/config",
427 "include/core",
Ben Wagnercc62b5d2018-09-20 16:26:31 -0400428 "include/docs",
benjaminwagner787ca872015-08-17 12:58:10 -0700429 "include/effects",
Matt Sarettd7093c22017-05-09 15:28:32 -0400430 "include/encode",
benjaminwagner787ca872015-08-17 12:58:10 -0700431 "include/gpu",
benjaminwagner787ca872015-08-17 12:58:10 -0700432 "include/pathops",
benjaminwagner787ca872015-08-17 12:58:10 -0700433 "include/ports",
434 "include/private",
Brian Osmanea236bf2019-04-29 10:28:22 -0400435 "include/third_party/skcms",
benjaminwagner787ca872015-08-17 12:58:10 -0700436 "include/utils",
iroth8b99ef42015-11-02 11:11:21 -0800437 "include/utils/mac",
benjaminwagnerfa7e1a02015-11-13 12:27:08 -0800438 "src/codec",
benjaminwagner787ca872015-08-17 12:58:10 -0700439 "src/core",
benjaminwagner787ca872015-08-17 12:58:10 -0700440 "src/gpu",
441 "src/image",
Mike Klein135a1b12017-08-15 13:13:59 -0400442 "src/images",
benjaminwagner787ca872015-08-17 12:58:10 -0700443 "src/lazy",
444 "src/opts",
445 "src/pdf",
Ben Wagner4ccf49c2018-03-26 15:46:40 -0400446 "src/ports",
benjaminwagner787ca872015-08-17 12:58:10 -0700447 "src/sfnt",
Florin Malita5edba452017-05-30 16:39:47 -0400448 "src/shaders",
Michael Ludwig4f94ef62018-09-12 15:22:16 -0400449 "src/shaders/gradients",
benjaminwagnerc8962512016-09-30 12:06:27 -0700450 "src/sksl",
benjaminwagner787ca872015-08-17 12:58:10 -0700451 "src/utils",
Ben Wagnerd0a3b062016-10-24 14:11:12 -0400452 "third_party/gif",
benjaminwagner56f6d062016-01-13 10:45:19 -0800453]
benjaminwagner787ca872015-08-17 12:58:10 -0700454
benjaminwagner56f6d062016-01-13 10:45:19 -0800455################################################################################
456## DM_SRCS
457################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700458
benjaminwagner56f6d062016-01-13 10:45:19 -0800459DM_SRCS_ALL = struct(
460 include = [
benjaminwagner6f6bef82015-10-15 08:09:44 -0700461 "dm/*.cpp",
462 "dm/*.h",
Mike Klein60900b52018-09-21 11:19:45 -0400463 "experimental/pipe/*.cpp",
464 "experimental/pipe/*.h",
Ben Wagner4ccf49c2018-03-26 15:46:40 -0400465 "experimental/svg/model/*.cpp",
466 "experimental/svg/model/*.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700467 "gm/*.cpp",
468 "gm/*.h",
Nathaniel Nifong0426c382019-06-21 11:09:19 -0400469 "src/utils/SkMultiPictureDocument.cpp",
Ben Wagner4ccf49c2018-03-26 15:46:40 -0400470 "src/xml/*.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700471 "tests/*.cpp",
472 "tests/*.h",
Jim Van Verth8a9a3712019-05-31 10:49:12 -0400473 "tools/AutoreleasePool.h",
benjaminwagner99fb6702016-07-28 15:12:21 -0700474 "tools/BigPathBench.inc",
Hal Canarye574f1e2019-07-15 14:01:37 -0400475 "tools/BinaryAsset.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700476 "tools/CrashHandler.cpp",
477 "tools/CrashHandler.h",
Robert Phillipse61ba842018-05-30 08:27:26 -0400478 "tools/DDLPromiseImageHelper.cpp",
479 "tools/DDLPromiseImageHelper.h",
480 "tools/DDLTileHelper.cpp",
481 "tools/DDLTileHelper.h",
Mike Kleinb61e25b2019-03-27 10:51:28 -0500482 "tools/HashAndEncode.cpp",
483 "tools/HashAndEncode.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700484 "tools/ProcStats.cpp",
485 "tools/ProcStats.h",
Ben Wagnerfb4487b2018-03-26 17:48:09 -0400486 "tools/Registry.h",
487 "tools/ResourceFactory.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700488 "tools/Resources.cpp",
489 "tools/Resources.h",
Hal Canarye574f1e2019-07-15 14:01:37 -0400490 "tools/SkMetaData.cpp",
491 "tools/SkMetaData.h",
492 "tools/SkSharingProc.cpp",
Mike Kleina4bb0202019-06-04 13:40:15 -0500493 "tools/SkVMBuilders.cpp",
494 "tools/SkVMBuilders.h",
Hal Canarye574f1e2019-07-15 14:01:37 -0400495 "tools/ToolUtils.cpp",
496 "tools/ToolUtils.h",
benjaminwagner99fb6702016-07-28 15:12:21 -0700497 "tools/UrlDataManager.cpp",
498 "tools/UrlDataManager.h",
499 "tools/debugger/*.cpp",
500 "tools/debugger/*.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700501 "tools/flags/*.cpp",
502 "tools/flags/*.h",
Mike Klein0cffcbf92019-03-20 11:08:46 -0500503 "tools/fonts/RandomScalerContext.cpp",
504 "tools/fonts/RandomScalerContext.h",
505 "tools/fonts/TestFontMgr.cpp",
506 "tools/fonts/TestFontMgr.h",
507 "tools/fonts/TestSVGTypeface.cpp",
508 "tools/fonts/TestSVGTypeface.h",
509 "tools/fonts/TestTypeface.cpp",
510 "tools/fonts/TestTypeface.h",
Mike Kleinea3f0142019-03-20 11:12:10 -0500511 "tools/fonts/ToolUtilsFont.cpp",
Hal Canarye574f1e2019-07-15 14:01:37 -0400512 "tools/fonts/test_font_index.inc",
Ben Wagner483c7722018-02-20 17:06:07 -0500513 "tools/fonts/test_font_monospace.inc",
514 "tools/fonts/test_font_sans_serif.inc",
515 "tools/fonts/test_font_serif.inc",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700516 "tools/gpu/**/*.cpp",
517 "tools/gpu/**/*.h",
Hal Canarye574f1e2019-07-15 14:01:37 -0400518 "tools/ios_utils.h",
mtkleine1fc4522016-02-09 12:32:52 -0800519 "tools/random_parse_path.cpp",
520 "tools/random_parse_path.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700521 "tools/timer/*.cpp",
522 "tools/timer/*.h",
Brian Salomon40d01192017-07-19 13:05:11 -0400523 "tools/trace/*.cpp",
524 "tools/trace/*.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700525 ],
526 exclude = [
Mike Kleindb537602018-06-01 11:01:11 -0400527 "gm/cgms.cpp",
Mike Kleinc4abade2019-08-09 10:11:35 -0400528 "gm/fiddle.cpp",
Mike Reed7bf160e2019-05-17 16:50:51 -0400529 "gm/video_decoder.cpp",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700530 "tests/FontMgrAndroidParserTest.cpp", # Android-only.
Ben Wagner37a06c02018-06-22 21:11:00 +0000531 "tests/FontMgrFontConfigTest.cpp", # FontConfig-only.
Julia Lavrovaf0ade8a2019-11-08 12:58:57 -0500532 "tests/SkParagraphTest.cpp", # Skipping tests for now.
benjaminwagner6f6bef82015-10-15 08:09:44 -0700533 "tests/skia_test.cpp", # Old main.
Brian Salomonf9ec4702017-11-19 14:46:36 -0500534 "tools/gpu/atlastext/*",
Stephen White985741a2019-07-18 11:43:45 -0400535 "tools/gpu/dawn/*",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700536 "tools/gpu/gl/angle/*",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700537 "tools/gpu/gl/egl/*",
538 "tools/gpu/gl/glx/*",
539 "tools/gpu/gl/iOS/*",
540 "tools/gpu/gl/mac/*",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700541 "tools/gpu/gl/win/*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700542 "tools/timer/SysTimer_mach.cpp",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700543 "tools/timer/SysTimer_windows.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700544 ],
545)
546
Ben Wagnerdea74282017-03-16 19:15:09 -0400547################################################################################
548## dm_srcs()
549################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700550
Ben Wagner9eca72b2017-10-17 10:57:34 -0400551def dm_srcs(os_conditions):
Ben Wagnerb303a422018-07-31 10:31:06 -0400552 """Sources for the dm binary for the specified os."""
553 return skia_glob(DM_SRCS_ALL) + skia_select(
554 os_conditions,
555 [
Ben Wagnerc5ee4992019-03-25 15:58:31 -0400556 ["tests/FontMgrFontConfigTest.cpp"],
Ben Wagnerb303a422018-07-31 10:31:06 -0400557 ["tests/FontMgrAndroidParserTest.cpp"],
558 [],
559 ],
560 )
benjaminwagner56f6d062016-01-13 10:45:19 -0800561
562################################################################################
benjaminwagner56f6d062016-01-13 10:45:19 -0800563## DM_ARGS
564################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700565
Ben Wagner59f9edb2016-11-28 15:30:37 -0500566def DM_ARGS(asan):
Mike Kleindd650c42018-11-08 14:26:02 -0500567 source = ["gm", "image", "lottie"]
Ben Wagnerb303a422018-07-31 10:31:06 -0400568
569 # TODO(benjaminwagner): f16, pic-8888, serialize-8888, and tiles_rt-8888 fail.
570 config = ["565", "8888", "pdf"]
571 match = ["~Codec_78329453"]
572 return (["--src"] + source + ["--config"] + config + ["--nonativeFonts"] +
573 ["--match"] + match)
benjaminwagner56f6d062016-01-13 10:45:19 -0800574
575################################################################################
576## COPTS
577################################################################################
iroth8b99ef42015-11-02 11:11:21 -0800578
Ben Wagner9eca72b2017-10-17 10:57:34 -0400579def base_copts(os_conditions):
Ben Wagnerb303a422018-07-31 10:31:06 -0400580 return skia_select(
581 os_conditions,
582 [
583 # UNIX
584 [
585 "-Wno-implicit-fallthrough", # Some intentional fallthrough.
586 # Internal use of deprecated methods. :(
587 "-Wno-deprecated-declarations",
588 # TODO(kjlubick)
589 "-Wno-self-assign", # Spurious warning in tests/PathOpsDVectorTest.cpp?
590 ],
591 # ANDROID
592 [
Mike Klein9b7e99e2018-08-22 16:45:11 -0400593 "-Wno-implicit-fallthrough", # Some intentional fallthrough.
Ben Wagnerb303a422018-07-31 10:31:06 -0400594 # 'GrResourceCache' declared with greater visibility than the
595 # type of its field 'GrResourceCache::fPurgeableQueue'... bogus.
596 "-Wno-error=attributes",
597 ],
598 # IOS
Benjamin Barenblatfd10d172018-07-31 16:41:37 -0400599 [
600 "-Wno-implicit-fallthrough", # Some intentional fallthrough.
601 ],
Ben Wagnerb303a422018-07-31 10:31:06 -0400602 ],
603 )
benjaminwagner56f6d062016-01-13 10:45:19 -0800604
605################################################################################
606## DEFINES
607################################################################################
608
Ben Wagner9eca72b2017-10-17 10:57:34 -0400609def base_defines(os_conditions):
Ben Wagnerb303a422018-07-31 10:31:06 -0400610 return [
611 # Chrome DEFINES.
612 "SK_USE_FREETYPE_EMBOLDEN",
613 # Turn on a few Google3-specific build fixes.
614 "SK_BUILD_FOR_GOOGLE3",
615 # Required for building dm.
616 "GR_TEST_UTILS",
Robert Phillips6db27c22019-05-01 10:43:56 -0400617 # Google3 probably doesn't want this feature yet
618 "SK_DISABLE_REDUCE_OPLIST_SPLITTING",
Ben Wagnerb303a422018-07-31 10:31:06 -0400619 # Staging flags for API changes
620 # Should remove after we update golden images
621 "SK_WEBP_ENCODER_USE_DEFAULT_METHOD",
622 # Experiment to diagnose image diffs in Google3
Mike Klein0ade68c2018-10-24 06:52:35 -0400623 "SK_DISABLE_LOWP_RASTER_PIPELINE",
Ben Wagnerb303a422018-07-31 10:31:06 -0400624 # JPEG is in codec_limited
625 "SK_HAS_JPEG_LIBRARY",
Brian Osman489cf882019-07-09 10:48:28 -0400626 # Needed for some tests in dm
627 "SK_ENABLE_SKSL_INTERPRETER",
Ben Wagnerb303a422018-07-31 10:31:06 -0400628 ] + skia_select(
629 os_conditions,
630 [
631 # UNIX
632 [
633 "PNG_SKIP_SETJMP_CHECK",
634 "SK_BUILD_FOR_UNIX",
Mike Kleinf0a53692019-04-24 11:42:40 -0500635 "SK_R32_SHIFT=16",
Ben Wagnerb303a422018-07-31 10:31:06 -0400636 "SK_HAS_PNG_LIBRARY",
637 "SK_HAS_WEBP_LIBRARY",
638 ],
639 # ANDROID
640 [
641 "SK_BUILD_FOR_ANDROID",
Ben Wagnerb303a422018-07-31 10:31:06 -0400642 "SK_HAS_PNG_LIBRARY",
643 "SK_HAS_WEBP_LIBRARY",
644 ],
645 # IOS
646 [
647 "SK_BUILD_FOR_IOS",
648 "SK_BUILD_NO_OPTS",
649 "SKNX_NO_SIMD",
650 ],
651 ],
652 )
benjaminwagner787ca872015-08-17 12:58:10 -0700653
benjaminwagner56f6d062016-01-13 10:45:19 -0800654################################################################################
655## LINKOPTS
656################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700657
Ben Wagner9eca72b2017-10-17 10:57:34 -0400658def base_linkopts(os_conditions):
Ben Wagnerb303a422018-07-31 10:31:06 -0400659 return [
660 "-ldl",
661 ] + skia_select(
662 os_conditions,
663 [
664 # UNIX
665 [],
666 # ANDROID
667 [
668 "-lEGL",
Ben Wagner773151f2018-08-17 09:28:53 -0400669 "-lGLESv2",
Ben Wagnerb303a422018-07-31 10:31:06 -0400670 ],
671 # IOS
672 [
673 "-framework CoreFoundation",
674 "-framework CoreGraphics",
675 "-framework CoreText",
676 "-framework ImageIO",
677 "-framework MobileCoreServices",
678 ],
679 ],
680 )
Florin Malitadcc9d062018-11-08 14:25:19 -0500681
682################################################################################
Florin Malitae4e95512019-05-03 14:03:50 -0400683## sksg_lib
Florin Malitadcc9d062018-11-08 14:25:19 -0500684################################################################################
685
Florin Malitae4e95512019-05-03 14:03:50 -0400686def sksg_lib_hdrs():
687 return native.glob(["modules/sksg/include/*.h"])
688
689def sksg_lib_srcs():
Florin Malitaccacfa02019-07-10 13:38:48 -0400690 return native.glob([
691 "modules/sksg/src/*.cpp",
692 "modules/sksg/src/*.h",
693 ])
Florin Malitae4e95512019-05-03 14:03:50 -0400694
695################################################################################
Julia Lavrova5ec1b8f2019-06-10 11:10:17 -0400696## skparagraph_lib
697################################################################################
698
699def skparagraph_lib_hdrs():
700 return native.glob(["modules/skparagraph/include/*.h"])
701
702def skparagraph_lib_srcs():
703 return native.glob(["modules/skparagraph/src/*.cpp"])
704
705################################################################################
Mike Reeddaf19452019-06-11 17:20:33 -0400706## experimental xform
707################################################################################
708
709def exp_xform_lib_hdrs():
710 return native.glob(["experimental/xform/*.h"])
711
712def exp_xform_lib_srcs():
713 return native.glob(["experimental/xform/*.cpp"])
714
715################################################################################
Hal Canary484384b2019-12-17 10:50:26 -0500716## skresources_lib
717################################################################################
718
719def skresources_lib_hdrs():
720 return ["modules/skresources/include/SkResources.h"]
721
722def skresources_lib_srcs():
723 return ["modules/skresources/src/SkResources.cpp"]
724
725################################################################################
Florin Malitae4e95512019-05-03 14:03:50 -0400726## skottie_lib
727################################################################################
728
729def skottie_lib_hdrs():
Florin Malita1b1b6572019-05-03 15:16:30 -0400730 return native.glob(["modules/skottie/include/*.h"])
Florin Malitae4e95512019-05-03 14:03:50 -0400731
732def skottie_lib_srcs():
733 return native.glob(
734 [
735 "modules/skottie/src/*.cpp",
736 "modules/skottie/src/*.h",
Florin Malitae47d8af2019-06-14 12:20:10 -0400737 "modules/skottie/src/effects/*.cpp",
738 "modules/skottie/src/effects/*.h",
Florin Malita45dc1f02019-07-01 13:57:43 -0400739 "modules/skottie/src/layers/*.cpp",
740 "modules/skottie/src/layers/*.h",
Florin Malitaca449d52019-05-08 10:04:09 -0400741 "modules/skottie/src/text/*.cpp",
742 "modules/skottie/src/text/*.h",
Florin Malitae4e95512019-05-03 14:03:50 -0400743 ],
744 exclude = [
745 "modules/skottie/src/SkottieTest.cpp",
746 "modules/skottie/src/SkottieTool.cpp",
747 ],
748 )
749
750################################################################################
751## skottie_shaper
752################################################################################
753
754SKOTTIE_SHAPER_HDRS = [
Florin Malitaca449d52019-05-08 10:04:09 -0400755 "modules/skottie/src/text/SkottieShaper.h",
Florin Malitadcc9d062018-11-08 14:25:19 -0500756]
757
Florin Malitae4e95512019-05-03 14:03:50 -0400758SKOTTIE_SHAPER_SRCS = [
Florin Malitaca449d52019-05-08 10:04:09 -0400759 "modules/skottie/src/text/SkottieShaper.cpp",
Florin Malitae4e95512019-05-03 14:03:50 -0400760]
761
762################################################################################
763## skottie_tool
764################################################################################
765
Florin Malitadcc9d062018-11-08 14:25:19 -0500766SKOTTIE_TOOL_SRCS = [
767 "modules/skottie/src/SkottieTool.cpp",
Brian Osman849f4d62019-11-26 08:58:26 -0500768 "modules/skresources/src/SkResources.cpp",
769 "modules/skresources/include/SkResources.h",
Florin Malitadcc9d062018-11-08 14:25:19 -0500770 # TODO(benjaminwagner): Add "flags" target.
Mike Klein88544fb2019-03-20 10:50:33 -0500771 "tools/flags/CommandLineFlags.cpp",
772 "tools/flags/CommandLineFlags.h",
Florin Malitadcc9d062018-11-08 14:25:19 -0500773]
Florin Malita6d415bc2019-01-17 16:42:15 -0500774
775################################################################################
776## SkShaper
777################################################################################
778
Florin Malita226ba982019-01-21 11:55:51 -0500779SKSHAPER_HARFBUZZ_SRCS = [
Florin Malita6d415bc2019-01-17 16:42:15 -0500780 "modules/skshaper/include/SkShaper.h",
781 "modules/skshaper/src/SkShaper.cpp",
782 "modules/skshaper/src/SkShaper_harfbuzz.cpp",
Hal Canary30c9eda2019-02-22 15:23:45 -0500783 "modules/skshaper/src/SkShaper_primitive.cpp",
Florin Malita6d415bc2019-01-17 16:42:15 -0500784]
Florin Malita226ba982019-01-21 11:55:51 -0500785
786SKSHAPER_PRIMITIVE_SRCS = [
787 "modules/skshaper/include/SkShaper.h",
788 "modules/skshaper/src/SkShaper.cpp",
789 "modules/skshaper/src/SkShaper_primitive.cpp",
790]
Hal Canaryb56b5542019-12-19 09:48:28 -0500791
792################################################################################
793## skottie_ios_lib
794################################################################################
795
796SKOTTIE_IOS_LIB_SRCS = [
Hal Canary118df7c2019-12-18 16:26:19 -0500797 "tools/skottie_ios_app/SkiaContext.mm",
798 "tools/skottie_ios_app/SkiaUIContext.mm",
799 "tools/skottie_ios_app/SkiaViewController.mm",
800 "tools/skottie_ios_app/SkottieViewController.mm",
Hal Canaryb56b5542019-12-19 09:48:28 -0500801]
802
803SKOTTIE_IOS_LIB_HDRS = [
Hal Canary118df7c2019-12-18 16:26:19 -0500804 "tools/skottie_ios_app/SkiaContext.h",
805 "tools/skottie_ios_app/SkiaViewController.h",
806 "tools/skottie_ios_app/SkottieViewController.h",
Hal Canaryb56b5542019-12-19 09:48:28 -0500807]
Hal Canary76cc2c52020-01-07 12:39:13 -0500808
809SKOTTIE_IOS_LIB_SDK_FRAMEWORKS = [
810 "Foundation",
811 "UIKit",
812]