blob: 37871187d960703258442501d18bd7d1d64b4e15 [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.
iroth76a12252016-01-07 07:11:39 -0800221 "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 Lubick8014c482018-10-18 11:05:21 -0400238 "src/core/SkPicture_none.cpp",
Kevin Lubickc9210672018-10-15 11:36:55 -0400239 "src/gpu/GrPathRendering_none.cpp",
Kevin Lubick93faa672018-10-10 15:54:53 -0400240 "src/gpu/ccpr/GrCoverageCountingPathRenderer_none.cpp",
Kevin Lubickc9210672018-10-15 11:36:55 -0400241 "src/gpu/gl/GrGLMakeNativeInterface_none.cpp",
242 "src/pdf/SkDocument_PDF_None.cpp", # We use src/pdf/SkPDFDocument.cpp.
benjaminwagner6f6bef82015-10-15 08:09:44 -0700243
Ben Wagner4ccf49c2018-03-26 15:46:40 -0400244 # Exclude files that don't compile everywhere.
245 "src/svg/**/*", # Depends on xml, SkJpegCodec, and SkPngCodec.
246 "src/xml/**/*", # Avoid dragging in expat when not needed.
benjaminwagner6f6bef82015-10-15 08:09:44 -0700247
benjaminwagner39e7aa42015-11-18 13:26:10 -0800248 # Conflicting dependencies among Lua versions. See cl/107087297.
249 "src/utils/SkLua*",
250
egdaniel32119f12016-02-22 10:07:54 -0800251 # Currently exclude all vulkan specific files
252 "src/gpu/vk/*",
benjaminwagnerc8962512016-09-30 12:06:27 -0700253
254 # Defines main.
255 "src/sksl/SkSLMain.cpp",
Ethan Nicholas8d7f4ae2017-09-07 11:07:42 -0400256
257 # Only used to regenerate the lexer
258 "src/sksl/lex/*",
Brian Salomoncbcb0a12017-11-19 13:20:13 -0500259
260 # Atlas text
261 "src/atlastext/*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700262 ],
263)
264
Ben Wagner9eca72b2017-10-17 10:57:34 -0400265def codec_srcs(limited):
Mike Klein5d58d092018-11-08 09:11:43 -0500266 """Sources for the codecs. Excludes Raw, and Ico, Webp, and Png if limited."""
Ben Wagnerec8c6602018-10-26 12:31:36 -0400267
Leon Scroggins IIIe93ec682018-10-26 09:25:51 -0400268 # TODO: Enable wuffs in Google3
Mike Klein5d58d092018-11-08 09:11:43 -0500269 exclude = ["src/codec/SkWuffsCodec.cpp", "src/codec/*Raw*.cpp"]
Ben Wagnerb303a422018-07-31 10:31:06 -0400270 if limited:
271 exclude += [
272 "src/codec/*Ico*.cpp",
273 "src/codec/*Webp*.cpp",
274 "src/codec/*Png*",
Ben Wagnerb303a422018-07-31 10:31:06 -0400275 ]
Mike Kleine11e5c12019-04-24 12:46:06 -0500276 return native.glob(["src/codec/*.cpp", "third_party/gif/*.cpp"], exclude = exclude)
Ben Wagner9eca72b2017-10-17 10:57:34 -0400277
Mike Klein7f95c292019-03-27 11:16:25 -0500278GL_SRCS_UNIX = struct(
benjaminwagner56f6d062016-01-13 10:45:19 -0800279 include = [
Brian Salomonb3ce76e2017-12-11 15:21:39 -0500280 "src/gpu/gl/GrGLMakeNativeInterface_none.cpp",
Mike Klein7f95c292019-03-27 11:16:25 -0500281 ],
282 exclude = [],
283)
284PORTS_SRCS_UNIX = struct(
285 include = [
benjaminwagner6f6bef82015-10-15 08:09:44 -0700286 "src/ports/**/*.cpp",
287 "src/ports/**/*.h",
288 ],
289 exclude = [
msarett6b4985c2016-03-10 07:15:59 -0800290 "src/ports/*CG*",
msarettfc0b6d12016-03-17 13:50:17 -0700291 "src/ports/*WIC*",
mtklein3f193a92016-03-10 08:52:05 -0800292 "src/ports/*android*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700293 "src/ports/*chromium*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700294 "src/ports/*mac*",
295 "src/ports/*mozalloc*",
296 "src/ports/*nacl*",
297 "src/ports/*win*",
benjaminwagner2211a7b2015-12-01 11:12:05 -0800298 "src/ports/SkFontMgr_custom_directory_factory.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700299 "src/ports/SkFontMgr_custom_embedded_factory.cpp",
benjaminwagnerd9dd5812016-03-21 10:45:01 -0700300 "src/ports/SkFontMgr_custom_empty_factory.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700301 "src/ports/SkFontMgr_empty_factory.cpp",
benjaminwagner2211a7b2015-12-01 11:12:05 -0800302 "src/ports/SkFontMgr_fontconfig_factory.cpp",
Sergey Ulanovf3babcd2018-11-30 17:42:00 -0800303 "src/ports/SkFontMgr_fuchsia.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700304 "src/ports/SkImageGenerator_none.cpp",
305 "src/ports/SkTLS_none.cpp",
mtkleind55d13a2015-08-18 08:51:49 -0700306 ],
307)
308
Mike Klein7f95c292019-03-27 11:16:25 -0500309GL_SRCS_ANDROID = struct(
benjaminwagner56f6d062016-01-13 10:45:19 -0800310 include = [
Ben Wagner773151f2018-08-17 09:28:53 -0400311 "src/gpu/gl/android/*.cpp",
Mike Klein7f95c292019-03-27 11:16:25 -0500312 ],
313 exclude = [],
314)
315PORTS_SRCS_ANDROID = struct(
316 include = [
benjaminwagner86ea33e2015-10-26 10:46:25 -0700317 "src/ports/**/*.cpp",
318 "src/ports/**/*.h",
319 ],
320 exclude = [
msarett6b4985c2016-03-10 07:15:59 -0800321 "src/ports/*CG*",
mtklein3f193a92016-03-10 08:52:05 -0800322 "src/ports/*FontConfig*",
msarettfc0b6d12016-03-17 13:50:17 -0700323 "src/ports/*WIC*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700324 "src/ports/*chromium*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700325 "src/ports/*fontconfig*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700326 "src/ports/*mac*",
327 "src/ports/*mozalloc*",
328 "src/ports/*nacl*",
329 "src/ports/*win*",
330 "src/ports/SkDebug_stdio.cpp",
331 "src/ports/SkFontMgr_custom_directory_factory.cpp",
332 "src/ports/SkFontMgr_custom_embedded_factory.cpp",
benjaminwagnerd9dd5812016-03-21 10:45:01 -0700333 "src/ports/SkFontMgr_custom_empty_factory.cpp",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700334 "src/ports/SkFontMgr_empty_factory.cpp",
Sergey Ulanovf3babcd2018-11-30 17:42:00 -0800335 "src/ports/SkFontMgr_fuchsia.cpp",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700336 "src/ports/SkImageGenerator_none.cpp",
337 "src/ports/SkTLS_none.cpp",
338 ],
339)
340
Mike Klein7f95c292019-03-27 11:16:25 -0500341GL_SRCS_IOS = struct(
benjaminwagner56f6d062016-01-13 10:45:19 -0800342 include = [
Brian Salomon3d6801e2017-12-11 10:06:31 -0500343 "src/gpu/gl/iOS/GrGLMakeNativeInterface_iOS.cpp",
Mike Klein7f95c292019-03-27 11:16:25 -0500344 ],
345 exclude = [],
346)
347PORTS_SRCS_IOS = struct(
348 include = [
iroth8b99ef42015-11-02 11:11:21 -0800349 "src/ports/**/*.cpp",
350 "src/ports/**/*.h",
irothab669de2016-02-16 19:17:01 -0800351 "src/utils/mac/*.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800352 ],
353 exclude = [
mtklein3f193a92016-03-10 08:52:05 -0800354 "src/ports/*FontConfig*",
355 "src/ports/*FreeType*",
msarettfc0b6d12016-03-17 13:50:17 -0700356 "src/ports/*WIC*",
iroth8b99ef42015-11-02 11:11:21 -0800357 "src/ports/*android*",
358 "src/ports/*chromium*",
359 "src/ports/*fontconfig*",
iroth8b99ef42015-11-02 11:11:21 -0800360 "src/ports/*mozalloc*",
361 "src/ports/*nacl*",
362 "src/ports/*win*",
iroth8b99ef42015-11-02 11:11:21 -0800363 "src/ports/SkFontMgr_custom.cpp",
Ben Wagner8ab590f2017-02-08 17:29:33 -0500364 "src/ports/SkFontMgr_custom_directory.cpp",
365 "src/ports/SkFontMgr_custom_embedded.cpp",
366 "src/ports/SkFontMgr_custom_empty.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800367 "src/ports/SkFontMgr_custom_directory_factory.cpp",
368 "src/ports/SkFontMgr_custom_embedded_factory.cpp",
benjaminwagnerd9dd5812016-03-21 10:45:01 -0700369 "src/ports/SkFontMgr_custom_empty_factory.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800370 "src/ports/SkFontMgr_empty_factory.cpp",
Sergey Ulanovf3babcd2018-11-30 17:42:00 -0800371 "src/ports/SkFontMgr_fuchsia.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800372 "src/ports/SkImageGenerator_none.cpp",
373 "src/ports/SkTLS_none.cpp",
374 ],
375)
376
Mike Klein7f95c292019-03-27 11:16:25 -0500377def base_srcs():
378 return skia_glob(BASE_SRCS_ALL)
379
380def ports_srcs(os_conditions):
Mike Klein299ea7b2019-03-27 13:53:08 -0500381 return skia_select(
382 os_conditions,
Ben Wagnerb303a422018-07-31 10:31:06 -0400383 [
Mike Klein7f95c292019-03-27 11:16:25 -0500384 skia_glob(PORTS_SRCS_UNIX),
385 skia_glob(PORTS_SRCS_ANDROID),
386 skia_glob(PORTS_SRCS_IOS),
Mike Klein299ea7b2019-03-27 13:53:08 -0500387 ],
388 )
Mike Klein7f95c292019-03-27 11:16:25 -0500389
390def gl_srcs(os_conditions):
Mike Klein299ea7b2019-03-27 13:53:08 -0500391 return skia_select(
392 os_conditions,
Mike Klein7f95c292019-03-27 11:16:25 -0500393 [
394 skia_glob(GL_SRCS_UNIX),
395 skia_glob(GL_SRCS_ANDROID),
396 skia_glob(GL_SRCS_IOS),
Mike Klein299ea7b2019-03-27 13:53:08 -0500397 ],
398 )
Mike Klein7f95c292019-03-27 11:16:25 -0500399
400def skia_srcs(os_conditions):
401 return base_srcs() + ports_srcs(os_conditions) + gl_srcs(os_conditions)
402
benjaminwagner56f6d062016-01-13 10:45:19 -0800403################################################################################
404## INCLUDES
405################################################################################
benjaminwagner39e7aa42015-11-18 13:26:10 -0800406
benjaminwagner787ca872015-08-17 12:58:10 -0700407# Includes needed by Skia implementation. Not public includes.
408INCLUDES = [
Mike Kleinc0bd9f92019-04-23 12:05:21 -0500409 ".",
benjaminwagnerfa7e1a02015-11-13 12:27:08 -0800410 "include/android",
benjaminwagner787ca872015-08-17 12:58:10 -0700411 "include/c",
412 "include/codec",
413 "include/config",
414 "include/core",
Ben Wagnercc62b5d2018-09-20 16:26:31 -0400415 "include/docs",
benjaminwagner787ca872015-08-17 12:58:10 -0700416 "include/effects",
Matt Sarettd7093c22017-05-09 15:28:32 -0400417 "include/encode",
benjaminwagner787ca872015-08-17 12:58:10 -0700418 "include/gpu",
benjaminwagner787ca872015-08-17 12:58:10 -0700419 "include/pathops",
benjaminwagner787ca872015-08-17 12:58:10 -0700420 "include/ports",
421 "include/private",
Brian Osmanea236bf2019-04-29 10:28:22 -0400422 "include/third_party/skcms",
benjaminwagner787ca872015-08-17 12:58:10 -0700423 "include/utils",
iroth8b99ef42015-11-02 11:11:21 -0800424 "include/utils/mac",
benjaminwagnerfa7e1a02015-11-13 12:27:08 -0800425 "src/codec",
benjaminwagner787ca872015-08-17 12:58:10 -0700426 "src/core",
benjaminwagner787ca872015-08-17 12:58:10 -0700427 "src/gpu",
428 "src/image",
Mike Klein135a1b12017-08-15 13:13:59 -0400429 "src/images",
benjaminwagner787ca872015-08-17 12:58:10 -0700430 "src/lazy",
431 "src/opts",
432 "src/pdf",
Ben Wagner4ccf49c2018-03-26 15:46:40 -0400433 "src/ports",
benjaminwagner787ca872015-08-17 12:58:10 -0700434 "src/sfnt",
Florin Malita5edba452017-05-30 16:39:47 -0400435 "src/shaders",
Michael Ludwig4f94ef62018-09-12 15:22:16 -0400436 "src/shaders/gradients",
benjaminwagnerc8962512016-09-30 12:06:27 -0700437 "src/sksl",
benjaminwagner787ca872015-08-17 12:58:10 -0700438 "src/utils",
Ben Wagnerd0a3b062016-10-24 14:11:12 -0400439 "third_party/gif",
benjaminwagner56f6d062016-01-13 10:45:19 -0800440]
benjaminwagner787ca872015-08-17 12:58:10 -0700441
benjaminwagner56f6d062016-01-13 10:45:19 -0800442################################################################################
443## DM_SRCS
444################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700445
benjaminwagner56f6d062016-01-13 10:45:19 -0800446DM_SRCS_ALL = struct(
447 include = [
benjaminwagner6f6bef82015-10-15 08:09:44 -0700448 "dm/*.cpp",
449 "dm/*.h",
Mike Klein60900b52018-09-21 11:19:45 -0400450 "experimental/pipe/*.cpp",
451 "experimental/pipe/*.h",
Ben Wagner4ccf49c2018-03-26 15:46:40 -0400452 "experimental/svg/model/*.cpp",
453 "experimental/svg/model/*.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700454 "gm/*.cpp",
455 "gm/*.h",
Ben Wagner4ccf49c2018-03-26 15:46:40 -0400456 "src/xml/*.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700457 "tests/*.cpp",
458 "tests/*.h",
Ben Wagnerfb4487b2018-03-26 17:48:09 -0400459 "tools/ios_utils.h",
460 "tools/BinaryAsset.h",
benjaminwagner99fb6702016-07-28 15:12:21 -0700461 "tools/BigPathBench.inc",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700462 "tools/CrashHandler.cpp",
463 "tools/CrashHandler.h",
Robert Phillipse61ba842018-05-30 08:27:26 -0400464 "tools/DDLPromiseImageHelper.cpp",
465 "tools/DDLPromiseImageHelper.h",
466 "tools/DDLTileHelper.cpp",
467 "tools/DDLTileHelper.h",
Mike Kleinb61e25b2019-03-27 10:51:28 -0500468 "tools/HashAndEncode.cpp",
469 "tools/HashAndEncode.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700470 "tools/ProcStats.cpp",
471 "tools/ProcStats.h",
Ben Wagnerfb4487b2018-03-26 17:48:09 -0400472 "tools/Registry.h",
473 "tools/ResourceFactory.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700474 "tools/Resources.cpp",
475 "tools/Resources.h",
benjaminwagner99fb6702016-07-28 15:12:21 -0700476 "tools/UrlDataManager.cpp",
477 "tools/UrlDataManager.h",
478 "tools/debugger/*.cpp",
479 "tools/debugger/*.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700480 "tools/flags/*.cpp",
481 "tools/flags/*.h",
Mike Klein0cffcbf92019-03-20 11:08:46 -0500482 "tools/fonts/RandomScalerContext.cpp",
483 "tools/fonts/RandomScalerContext.h",
484 "tools/fonts/TestFontMgr.cpp",
485 "tools/fonts/TestFontMgr.h",
486 "tools/fonts/TestSVGTypeface.cpp",
487 "tools/fonts/TestSVGTypeface.h",
488 "tools/fonts/TestTypeface.cpp",
489 "tools/fonts/TestTypeface.h",
Mike Kleinea3f0142019-03-20 11:12:10 -0500490 "tools/fonts/ToolUtilsFont.cpp",
Ben Wagner483c7722018-02-20 17:06:07 -0500491 "tools/fonts/test_font_monospace.inc",
492 "tools/fonts/test_font_sans_serif.inc",
493 "tools/fonts/test_font_serif.inc",
494 "tools/fonts/test_font_index.inc",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700495 "tools/gpu/**/*.cpp",
496 "tools/gpu/**/*.h",
mtkleine1fc4522016-02-09 12:32:52 -0800497 "tools/random_parse_path.cpp",
498 "tools/random_parse_path.h",
Mike Kleinea3f0142019-03-20 11:12:10 -0500499 "tools/ToolUtils.cpp",
500 "tools/ToolUtils.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700501 "tools/timer/*.cpp",
502 "tools/timer/*.h",
Brian Salomon40d01192017-07-19 13:05:11 -0400503 "tools/trace/*.cpp",
504 "tools/trace/*.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700505 ],
506 exclude = [
Mike Kleindb537602018-06-01 11:01:11 -0400507 "gm/cgms.cpp",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700508 "tests/FontMgrAndroidParserTest.cpp", # Android-only.
Ben Wagner37a06c02018-06-22 21:11:00 +0000509 "tests/FontMgrFontConfigTest.cpp", # FontConfig-only.
benjaminwagner6f6bef82015-10-15 08:09:44 -0700510 "tests/skia_test.cpp", # Old main.
Brian Salomonf9ec4702017-11-19 14:46:36 -0500511 "tools/gpu/atlastext/*",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700512 "tools/gpu/gl/angle/*",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700513 "tools/gpu/gl/egl/*",
514 "tools/gpu/gl/glx/*",
515 "tools/gpu/gl/iOS/*",
516 "tools/gpu/gl/mac/*",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700517 "tools/gpu/gl/win/*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700518 "tools/timer/SysTimer_mach.cpp",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700519 "tools/timer/SysTimer_windows.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700520 ],
521)
522
Ben Wagnerdea74282017-03-16 19:15:09 -0400523################################################################################
524## dm_srcs()
525################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700526
Ben Wagner9eca72b2017-10-17 10:57:34 -0400527def dm_srcs(os_conditions):
Ben Wagnerb303a422018-07-31 10:31:06 -0400528 """Sources for the dm binary for the specified os."""
529 return skia_glob(DM_SRCS_ALL) + skia_select(
530 os_conditions,
531 [
Ben Wagnerc5ee4992019-03-25 15:58:31 -0400532 ["tests/FontMgrFontConfigTest.cpp"],
Ben Wagnerb303a422018-07-31 10:31:06 -0400533 ["tests/FontMgrAndroidParserTest.cpp"],
534 [],
535 ],
536 )
benjaminwagner56f6d062016-01-13 10:45:19 -0800537
538################################################################################
539## DM_INCLUDES
540################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700541
benjaminwagner6f6bef82015-10-15 08:09:44 -0700542DM_INCLUDES = [
Mike Kleinc0bd9f92019-04-23 12:05:21 -0500543 ".",
benjaminwagnerb1fe8f62016-02-01 09:05:08 -0800544 "dm",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700545 "gm",
Mike Klein60900b52018-09-21 11:19:45 -0400546 "experimental/pipe",
Mike Reed7f302c42017-02-18 14:12:08 -0500547 "experimental/svg/model",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700548 "src/codec",
Mike Reedaab8ce42017-02-18 12:57:09 -0500549 "src/core",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700550 "src/effects",
551 "src/fonts",
Hal Canarydb683012016-11-23 08:55:18 -0700552 "src/images",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700553 "src/pathops",
554 "src/pipe/utils",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700555 "src/ports",
Florin Malita5edba452017-05-30 16:39:47 -0400556 "src/shaders",
557 "src/shaders/gradients",
Mike Reedf71828f2017-02-18 09:51:33 -0500558 "src/xml",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700559 "tests",
560 "tools",
benjaminwagner99fb6702016-07-28 15:12:21 -0700561 "tools/debugger",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700562 "tools/flags",
Ben Wagner483c7722018-02-20 17:06:07 -0500563 "tools/fonts",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700564 "tools/gpu",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700565 "tools/timer",
Brian Salomon40d01192017-07-19 13:05:11 -0400566 "tools/trace",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700567]
568
benjaminwagner56f6d062016-01-13 10:45:19 -0800569################################################################################
570## DM_ARGS
571################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700572
Ben Wagner59f9edb2016-11-28 15:30:37 -0500573def DM_ARGS(asan):
Mike Kleindd650c42018-11-08 14:26:02 -0500574 source = ["gm", "image", "lottie"]
Ben Wagnerb303a422018-07-31 10:31:06 -0400575
576 # TODO(benjaminwagner): f16, pic-8888, serialize-8888, and tiles_rt-8888 fail.
577 config = ["565", "8888", "pdf"]
578 match = ["~Codec_78329453"]
579 return (["--src"] + source + ["--config"] + config + ["--nonativeFonts"] +
580 ["--match"] + match)
benjaminwagner56f6d062016-01-13 10:45:19 -0800581
582################################################################################
583## COPTS
584################################################################################
iroth8b99ef42015-11-02 11:11:21 -0800585
Ben Wagner9eca72b2017-10-17 10:57:34 -0400586def base_copts(os_conditions):
Ben Wagnerb303a422018-07-31 10:31:06 -0400587 return skia_select(
588 os_conditions,
589 [
590 # UNIX
591 [
592 "-Wno-implicit-fallthrough", # Some intentional fallthrough.
593 # Internal use of deprecated methods. :(
594 "-Wno-deprecated-declarations",
595 # TODO(kjlubick)
596 "-Wno-self-assign", # Spurious warning in tests/PathOpsDVectorTest.cpp?
597 ],
598 # ANDROID
599 [
Mike Klein9b7e99e2018-08-22 16:45:11 -0400600 "-Wno-implicit-fallthrough", # Some intentional fallthrough.
Ben Wagnerb303a422018-07-31 10:31:06 -0400601 # 'GrResourceCache' declared with greater visibility than the
602 # type of its field 'GrResourceCache::fPurgeableQueue'... bogus.
603 "-Wno-error=attributes",
604 ],
605 # IOS
Benjamin Barenblatfd10d172018-07-31 16:41:37 -0400606 [
607 "-Wno-implicit-fallthrough", # Some intentional fallthrough.
608 ],
Ben Wagnerb303a422018-07-31 10:31:06 -0400609 ],
610 )
benjaminwagner56f6d062016-01-13 10:45:19 -0800611
612################################################################################
613## DEFINES
614################################################################################
615
Ben Wagner9eca72b2017-10-17 10:57:34 -0400616def base_defines(os_conditions):
Ben Wagnerb303a422018-07-31 10:31:06 -0400617 return [
618 # Chrome DEFINES.
619 "SK_USE_FREETYPE_EMBOLDEN",
620 # Turn on a few Google3-specific build fixes.
621 "SK_BUILD_FOR_GOOGLE3",
622 # Required for building dm.
623 "GR_TEST_UTILS",
Robert Phillips6db27c22019-05-01 10:43:56 -0400624 # Google3 probably doesn't want this feature yet
625 "SK_DISABLE_REDUCE_OPLIST_SPLITTING",
Ben Wagnerb303a422018-07-31 10:31:06 -0400626 # Staging flags for API changes
627 # Should remove after we update golden images
628 "SK_WEBP_ENCODER_USE_DEFAULT_METHOD",
629 # Experiment to diagnose image diffs in Google3
Mike Klein0ade68c2018-10-24 06:52:35 -0400630 "SK_DISABLE_LOWP_RASTER_PIPELINE",
Ben Wagnerb303a422018-07-31 10:31:06 -0400631 # JPEG is in codec_limited
632 "SK_HAS_JPEG_LIBRARY",
633 ] + skia_select(
634 os_conditions,
635 [
636 # UNIX
637 [
638 "PNG_SKIP_SETJMP_CHECK",
639 "SK_BUILD_FOR_UNIX",
Mike Kleinf0a53692019-04-24 11:42:40 -0500640 "SK_R32_SHIFT=16",
Ben Wagnerb303a422018-07-31 10:31:06 -0400641 "SK_PDF_USE_SFNTLY",
Ben Wagnerb303a422018-07-31 10:31:06 -0400642 "SK_HAS_PNG_LIBRARY",
643 "SK_HAS_WEBP_LIBRARY",
644 ],
645 # ANDROID
646 [
647 "SK_BUILD_FOR_ANDROID",
Ben Wagnerb303a422018-07-31 10:31:06 -0400648 "SK_HAS_PNG_LIBRARY",
649 "SK_HAS_WEBP_LIBRARY",
650 ],
651 # IOS
652 [
653 "SK_BUILD_FOR_IOS",
654 "SK_BUILD_NO_OPTS",
655 "SKNX_NO_SIMD",
656 ],
657 ],
658 )
benjaminwagner787ca872015-08-17 12:58:10 -0700659
benjaminwagner56f6d062016-01-13 10:45:19 -0800660################################################################################
661## LINKOPTS
662################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700663
Ben Wagner9eca72b2017-10-17 10:57:34 -0400664def base_linkopts(os_conditions):
Ben Wagnerb303a422018-07-31 10:31:06 -0400665 return [
666 "-ldl",
667 ] + skia_select(
668 os_conditions,
669 [
670 # UNIX
671 [],
672 # ANDROID
673 [
674 "-lEGL",
Ben Wagner773151f2018-08-17 09:28:53 -0400675 "-lGLESv2",
Ben Wagnerb303a422018-07-31 10:31:06 -0400676 ],
677 # IOS
678 [
679 "-framework CoreFoundation",
680 "-framework CoreGraphics",
681 "-framework CoreText",
682 "-framework ImageIO",
683 "-framework MobileCoreServices",
684 ],
685 ],
686 )
Florin Malitadcc9d062018-11-08 14:25:19 -0500687
688################################################################################
689## skottie_tool
690################################################################################
691
692SKOTTIE_TOOL_INCLUDES = [
Mike Kleinc0bd9f92019-04-23 12:05:21 -0500693 ".",
Florin Malitaa8316552018-11-09 16:19:44 -0500694 "modules/skottie/utils",
Florin Malitadcc9d062018-11-08 14:25:19 -0500695 "tools/flags",
696]
697
698SKOTTIE_TOOL_SRCS = [
699 "modules/skottie/src/SkottieTool.cpp",
Florin Malitaa8316552018-11-09 16:19:44 -0500700 "modules/skottie/utils/SkottieUtils.cpp",
701 "modules/skottie/utils/SkottieUtils.h",
Florin Malitadcc9d062018-11-08 14:25:19 -0500702 # TODO(benjaminwagner): Add "flags" target.
Mike Klein88544fb2019-03-20 10:50:33 -0500703 "tools/flags/CommandLineFlags.cpp",
704 "tools/flags/CommandLineFlags.h",
Florin Malitadcc9d062018-11-08 14:25:19 -0500705]
Florin Malita6d415bc2019-01-17 16:42:15 -0500706
707################################################################################
708## SkShaper
709################################################################################
710
711SKSHAPER_INCLUDES = [
Mike Kleinc0bd9f92019-04-23 12:05:21 -0500712 ".",
Florin Malita6d415bc2019-01-17 16:42:15 -0500713 "modules/skshaper/include",
714]
715
Florin Malita226ba982019-01-21 11:55:51 -0500716SKSHAPER_HARFBUZZ_SRCS = [
Florin Malita6d415bc2019-01-17 16:42:15 -0500717 "modules/skshaper/include/SkShaper.h",
718 "modules/skshaper/src/SkShaper.cpp",
719 "modules/skshaper/src/SkShaper_harfbuzz.cpp",
Hal Canary30c9eda2019-02-22 15:23:45 -0500720 "modules/skshaper/src/SkShaper_primitive.cpp",
Florin Malita6d415bc2019-01-17 16:42:15 -0500721]
Florin Malita226ba982019-01-21 11:55:51 -0500722
723SKSHAPER_PRIMITIVE_SRCS = [
724 "modules/skshaper/include/SkShaper.h",
725 "modules/skshaper/src/SkShaper.cpp",
726 "modules/skshaper/src/SkShaper_primitive.cpp",
727]