blob: 60ce79db3bbd758bc3c1f81132cb37f2639b19b6 [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/*",
Mike Klein83ee4632018-03-27 13:22:50 -0400262
Mike Kleinb056e7f2018-06-20 09:44:59 -0400263 # Compute backend not yet even hooked into Skia.
Ben Wagnerb303a422018-07-31 10:31:06 -0400264 "src/compute/**/*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700265 ],
266)
267
Ben Wagner9eca72b2017-10-17 10:57:34 -0400268def codec_srcs(limited):
Mike Klein5d58d092018-11-08 09:11:43 -0500269 """Sources for the codecs. Excludes Raw, and Ico, Webp, and Png if limited."""
Ben Wagnerec8c6602018-10-26 12:31:36 -0400270
Leon Scroggins IIIe93ec682018-10-26 09:25:51 -0400271 # TODO: Enable wuffs in Google3
Mike Klein5d58d092018-11-08 09:11:43 -0500272 exclude = ["src/codec/SkWuffsCodec.cpp", "src/codec/*Raw*.cpp"]
Ben Wagnerb303a422018-07-31 10:31:06 -0400273 if limited:
274 exclude += [
275 "src/codec/*Ico*.cpp",
276 "src/codec/*Webp*.cpp",
277 "src/codec/*Png*",
Ben Wagnerb303a422018-07-31 10:31:06 -0400278 ]
Mike Klein4991cd32018-11-07 08:46:29 -0500279 return native.glob(["src/codec/*.cpp", "third_party/gif/*.cpp"], exclude = exclude)
Ben Wagner9eca72b2017-10-17 10:57:34 -0400280
benjaminwagner6f6bef82015-10-15 08:09:44 -0700281# Platform-dependent SRCS for google3-default platform.
benjaminwagner56f6d062016-01-13 10:45:19 -0800282BASE_SRCS_UNIX = struct(
283 include = [
Brian Salomonb3ce76e2017-12-11 15:21:39 -0500284 "src/gpu/gl/GrGLMakeNativeInterface_none.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700285 "src/ports/**/*.cpp",
286 "src/ports/**/*.h",
287 ],
288 exclude = [
msarett6b4985c2016-03-10 07:15:59 -0800289 "src/ports/*CG*",
msarettfc0b6d12016-03-17 13:50:17 -0700290 "src/ports/*WIC*",
mtklein3f193a92016-03-10 08:52:05 -0800291 "src/ports/*android*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700292 "src/ports/*chromium*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700293 "src/ports/*mac*",
294 "src/ports/*mozalloc*",
295 "src/ports/*nacl*",
296 "src/ports/*win*",
benjaminwagner2211a7b2015-12-01 11:12:05 -0800297 "src/ports/SkFontMgr_custom_directory_factory.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700298 "src/ports/SkFontMgr_custom_embedded_factory.cpp",
benjaminwagnerd9dd5812016-03-21 10:45:01 -0700299 "src/ports/SkFontMgr_custom_empty_factory.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700300 "src/ports/SkFontMgr_empty_factory.cpp",
benjaminwagner404816e2015-12-03 05:04:03 -0800301 "src/ports/SkFontMgr_fontconfig.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
benjaminwagner86ea33e2015-10-26 10:46:25 -0700309# Platform-dependent SRCS for google3-default Android.
benjaminwagner56f6d062016-01-13 10:45:19 -0800310BASE_SRCS_ANDROID = struct(
311 include = [
Ben Wagner773151f2018-08-17 09:28:53 -0400312 "src/gpu/gl/android/*.cpp",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700313 "src/ports/**/*.cpp",
314 "src/ports/**/*.h",
315 ],
316 exclude = [
msarett6b4985c2016-03-10 07:15:59 -0800317 "src/ports/*CG*",
mtklein3f193a92016-03-10 08:52:05 -0800318 "src/ports/*FontConfig*",
msarettfc0b6d12016-03-17 13:50:17 -0700319 "src/ports/*WIC*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700320 "src/ports/*chromium*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700321 "src/ports/*fontconfig*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700322 "src/ports/*mac*",
323 "src/ports/*mozalloc*",
324 "src/ports/*nacl*",
325 "src/ports/*win*",
326 "src/ports/SkDebug_stdio.cpp",
327 "src/ports/SkFontMgr_custom_directory_factory.cpp",
328 "src/ports/SkFontMgr_custom_embedded_factory.cpp",
benjaminwagnerd9dd5812016-03-21 10:45:01 -0700329 "src/ports/SkFontMgr_custom_empty_factory.cpp",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700330 "src/ports/SkFontMgr_empty_factory.cpp",
Sergey Ulanovf3babcd2018-11-30 17:42:00 -0800331 "src/ports/SkFontMgr_fuchsia.cpp",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700332 "src/ports/SkImageGenerator_none.cpp",
333 "src/ports/SkTLS_none.cpp",
334 ],
335)
336
iroth8b99ef42015-11-02 11:11:21 -0800337# Platform-dependent SRCS for google3-default iOS.
benjaminwagner56f6d062016-01-13 10:45:19 -0800338BASE_SRCS_IOS = struct(
339 include = [
Brian Salomon3d6801e2017-12-11 10:06:31 -0500340 "src/gpu/gl/iOS/GrGLMakeNativeInterface_iOS.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800341 "src/ports/**/*.cpp",
342 "src/ports/**/*.h",
irothab669de2016-02-16 19:17:01 -0800343 "src/utils/mac/*.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800344 ],
345 exclude = [
mtklein3f193a92016-03-10 08:52:05 -0800346 "src/ports/*FontConfig*",
347 "src/ports/*FreeType*",
msarettfc0b6d12016-03-17 13:50:17 -0700348 "src/ports/*WIC*",
iroth8b99ef42015-11-02 11:11:21 -0800349 "src/ports/*android*",
350 "src/ports/*chromium*",
351 "src/ports/*fontconfig*",
iroth8b99ef42015-11-02 11:11:21 -0800352 "src/ports/*mozalloc*",
353 "src/ports/*nacl*",
354 "src/ports/*win*",
iroth8b99ef42015-11-02 11:11:21 -0800355 "src/ports/SkFontMgr_custom.cpp",
Ben Wagner8ab590f2017-02-08 17:29:33 -0500356 "src/ports/SkFontMgr_custom_directory.cpp",
357 "src/ports/SkFontMgr_custom_embedded.cpp",
358 "src/ports/SkFontMgr_custom_empty.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800359 "src/ports/SkFontMgr_custom_directory_factory.cpp",
360 "src/ports/SkFontMgr_custom_embedded_factory.cpp",
benjaminwagnerd9dd5812016-03-21 10:45:01 -0700361 "src/ports/SkFontMgr_custom_empty_factory.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800362 "src/ports/SkFontMgr_empty_factory.cpp",
Sergey Ulanovf3babcd2018-11-30 17:42:00 -0800363 "src/ports/SkFontMgr_fuchsia.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800364 "src/ports/SkImageGenerator_none.cpp",
365 "src/ports/SkTLS_none.cpp",
366 ],
367)
368
benjaminwagner56f6d062016-01-13 10:45:19 -0800369################################################################################
Ben Wagnerdea74282017-03-16 19:15:09 -0400370## skia_srcs()
benjaminwagner56f6d062016-01-13 10:45:19 -0800371################################################################################
Ben Wagner9eca72b2017-10-17 10:57:34 -0400372def skia_srcs(os_conditions):
Ben Wagnerb303a422018-07-31 10:31:06 -0400373 """Sources to be compiled into the skia library."""
374 return skia_glob(BASE_SRCS_ALL) + skia_select(
375 os_conditions,
376 [
377 skia_glob(BASE_SRCS_UNIX),
378 skia_glob(BASE_SRCS_ANDROID),
379 skia_glob(BASE_SRCS_IOS),
380 ],
381 )
benjaminwagner39e7aa42015-11-18 13:26:10 -0800382
benjaminwagner56f6d062016-01-13 10:45:19 -0800383################################################################################
384## INCLUDES
385################################################################################
benjaminwagner39e7aa42015-11-18 13:26:10 -0800386
benjaminwagner787ca872015-08-17 12:58:10 -0700387# Includes needed by Skia implementation. Not public includes.
388INCLUDES = [
benjaminwagnerfa7e1a02015-11-13 12:27:08 -0800389 "include/android",
benjaminwagner787ca872015-08-17 12:58:10 -0700390 "include/c",
391 "include/codec",
392 "include/config",
393 "include/core",
Ben Wagnercc62b5d2018-09-20 16:26:31 -0400394 "include/docs",
benjaminwagner787ca872015-08-17 12:58:10 -0700395 "include/effects",
Matt Sarettd7093c22017-05-09 15:28:32 -0400396 "include/encode",
benjaminwagner787ca872015-08-17 12:58:10 -0700397 "include/gpu",
benjaminwagner787ca872015-08-17 12:58:10 -0700398 "include/pathops",
benjaminwagner787ca872015-08-17 12:58:10 -0700399 "include/ports",
400 "include/private",
401 "include/utils",
iroth8b99ef42015-11-02 11:11:21 -0800402 "include/utils/mac",
benjaminwagnerfa7e1a02015-11-13 12:27:08 -0800403 "src/codec",
benjaminwagner787ca872015-08-17 12:58:10 -0700404 "src/core",
benjaminwagner787ca872015-08-17 12:58:10 -0700405 "src/gpu",
406 "src/image",
Mike Klein135a1b12017-08-15 13:13:59 -0400407 "src/images",
benjaminwagner787ca872015-08-17 12:58:10 -0700408 "src/lazy",
409 "src/opts",
410 "src/pdf",
Ben Wagner4ccf49c2018-03-26 15:46:40 -0400411 "src/ports",
benjaminwagner787ca872015-08-17 12:58:10 -0700412 "src/sfnt",
Florin Malita5edba452017-05-30 16:39:47 -0400413 "src/shaders",
Michael Ludwig4f94ef62018-09-12 15:22:16 -0400414 "src/shaders/gradients",
benjaminwagnerc8962512016-09-30 12:06:27 -0700415 "src/sksl",
benjaminwagner787ca872015-08-17 12:58:10 -0700416 "src/utils",
Ben Wagnerd0a3b062016-10-24 14:11:12 -0400417 "third_party/gif",
benjaminwagner56f6d062016-01-13 10:45:19 -0800418]
benjaminwagner787ca872015-08-17 12:58:10 -0700419
benjaminwagner56f6d062016-01-13 10:45:19 -0800420################################################################################
421## DM_SRCS
422################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700423
benjaminwagner56f6d062016-01-13 10:45:19 -0800424DM_SRCS_ALL = struct(
425 include = [
benjaminwagner6f6bef82015-10-15 08:09:44 -0700426 "dm/*.cpp",
427 "dm/*.h",
Mike Klein60900b52018-09-21 11:19:45 -0400428 "experimental/pipe/*.cpp",
429 "experimental/pipe/*.h",
Ben Wagner4ccf49c2018-03-26 15:46:40 -0400430 "experimental/svg/model/*.cpp",
431 "experimental/svg/model/*.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700432 "gm/*.cpp",
433 "gm/*.h",
Ben Wagner4ccf49c2018-03-26 15:46:40 -0400434 "src/xml/*.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700435 "tests/*.cpp",
436 "tests/*.h",
Ben Wagnerfb4487b2018-03-26 17:48:09 -0400437 "tools/ios_utils.h",
438 "tools/BinaryAsset.h",
benjaminwagner99fb6702016-07-28 15:12:21 -0700439 "tools/BigPathBench.inc",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700440 "tools/CrashHandler.cpp",
441 "tools/CrashHandler.h",
Robert Phillipse61ba842018-05-30 08:27:26 -0400442 "tools/DDLPromiseImageHelper.cpp",
443 "tools/DDLPromiseImageHelper.h",
444 "tools/DDLTileHelper.cpp",
445 "tools/DDLTileHelper.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700446 "tools/ProcStats.cpp",
447 "tools/ProcStats.h",
Ben Wagnerfb4487b2018-03-26 17:48:09 -0400448 "tools/Registry.h",
449 "tools/ResourceFactory.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700450 "tools/Resources.cpp",
451 "tools/Resources.h",
benjaminwagner99fb6702016-07-28 15:12:21 -0700452 "tools/SkJSONCPP.h",
453 "tools/UrlDataManager.cpp",
454 "tools/UrlDataManager.h",
455 "tools/debugger/*.cpp",
456 "tools/debugger/*.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700457 "tools/flags/*.cpp",
458 "tools/flags/*.h",
Ben Wagner483c7722018-02-20 17:06:07 -0500459 "tools/fonts/SkRandomScalerContext.cpp",
460 "tools/fonts/SkRandomScalerContext.h",
461 "tools/fonts/SkTestFontMgr.cpp",
462 "tools/fonts/SkTestFontMgr.h",
Ben Wagner97182cc2018-02-15 10:20:04 -0500463 "tools/fonts/SkTestSVGTypeface.cpp",
464 "tools/fonts/SkTestSVGTypeface.h",
465 "tools/fonts/SkTestTypeface.cpp",
466 "tools/fonts/SkTestTypeface.h",
Ben Wagner483c7722018-02-20 17:06:07 -0500467 "tools/fonts/sk_tool_utils_font.cpp",
468 "tools/fonts/test_font_monospace.inc",
469 "tools/fonts/test_font_sans_serif.inc",
470 "tools/fonts/test_font_serif.inc",
471 "tools/fonts/test_font_index.inc",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700472 "tools/gpu/**/*.cpp",
473 "tools/gpu/**/*.h",
mtkleine1fc4522016-02-09 12:32:52 -0800474 "tools/random_parse_path.cpp",
475 "tools/random_parse_path.h",
Ben Wagnerfb4487b2018-03-26 17:48:09 -0400476 "tools/sk_pixel_iter.h",
benjaminwagner32885142015-10-24 07:55:31 -0700477 "tools/sk_tool_utils.cpp",
478 "tools/sk_tool_utils.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700479 "tools/timer/*.cpp",
480 "tools/timer/*.h",
Brian Salomon40d01192017-07-19 13:05:11 -0400481 "tools/trace/*.cpp",
482 "tools/trace/*.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700483 ],
484 exclude = [
Mike Kleindb537602018-06-01 11:01:11 -0400485 "gm/cgms.cpp",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700486 "tests/FontMgrAndroidParserTest.cpp", # Android-only.
Ben Wagner37a06c02018-06-22 21:11:00 +0000487 "tests/FontMgrFontConfigTest.cpp", # FontConfig-only.
benjaminwagner6f6bef82015-10-15 08:09:44 -0700488 "tests/skia_test.cpp", # Old main.
Brian Salomonf9ec4702017-11-19 14:46:36 -0500489 "tools/gpu/atlastext/*",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700490 "tools/gpu/gl/angle/*",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700491 "tools/gpu/gl/egl/*",
492 "tools/gpu/gl/glx/*",
493 "tools/gpu/gl/iOS/*",
494 "tools/gpu/gl/mac/*",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700495 "tools/gpu/gl/win/*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700496 "tools/timer/SysTimer_mach.cpp",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700497 "tools/timer/SysTimer_windows.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700498 ],
499)
500
Ben Wagnerdea74282017-03-16 19:15:09 -0400501################################################################################
502## dm_srcs()
503################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700504
Ben Wagner9eca72b2017-10-17 10:57:34 -0400505def dm_srcs(os_conditions):
Ben Wagnerb303a422018-07-31 10:31:06 -0400506 """Sources for the dm binary for the specified os."""
507 return skia_glob(DM_SRCS_ALL) + skia_select(
508 os_conditions,
509 [
510 [],
511 ["tests/FontMgrAndroidParserTest.cpp"],
512 [],
513 ],
514 )
benjaminwagner56f6d062016-01-13 10:45:19 -0800515
516################################################################################
517## DM_INCLUDES
518################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700519
benjaminwagner6f6bef82015-10-15 08:09:44 -0700520DM_INCLUDES = [
benjaminwagnerb1fe8f62016-02-01 09:05:08 -0800521 "dm",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700522 "gm",
Mike Klein60900b52018-09-21 11:19:45 -0400523 "experimental/pipe",
Mike Reed7f302c42017-02-18 14:12:08 -0500524 "experimental/svg/model",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700525 "src/codec",
Mike Reedaab8ce42017-02-18 12:57:09 -0500526 "src/core",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700527 "src/effects",
528 "src/fonts",
Hal Canarydb683012016-11-23 08:55:18 -0700529 "src/images",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700530 "src/pathops",
531 "src/pipe/utils",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700532 "src/ports",
Florin Malita5edba452017-05-30 16:39:47 -0400533 "src/shaders",
534 "src/shaders/gradients",
Mike Reedf71828f2017-02-18 09:51:33 -0500535 "src/xml",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700536 "tests",
537 "tools",
benjaminwagner99fb6702016-07-28 15:12:21 -0700538 "tools/debugger",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700539 "tools/flags",
Ben Wagner483c7722018-02-20 17:06:07 -0500540 "tools/fonts",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700541 "tools/gpu",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700542 "tools/timer",
Brian Salomon40d01192017-07-19 13:05:11 -0400543 "tools/trace",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700544]
545
benjaminwagner56f6d062016-01-13 10:45:19 -0800546################################################################################
547## DM_ARGS
548################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700549
Ben Wagner59f9edb2016-11-28 15:30:37 -0500550def DM_ARGS(asan):
Mike Kleindd650c42018-11-08 14:26:02 -0500551 source = ["gm", "image", "lottie"]
Ben Wagnerb303a422018-07-31 10:31:06 -0400552
553 # TODO(benjaminwagner): f16, pic-8888, serialize-8888, and tiles_rt-8888 fail.
554 config = ["565", "8888", "pdf"]
555 match = ["~Codec_78329453"]
556 return (["--src"] + source + ["--config"] + config + ["--nonativeFonts"] +
557 ["--match"] + match)
benjaminwagner56f6d062016-01-13 10:45:19 -0800558
559################################################################################
560## COPTS
561################################################################################
iroth8b99ef42015-11-02 11:11:21 -0800562
Ben Wagner9eca72b2017-10-17 10:57:34 -0400563def base_copts(os_conditions):
Ben Wagnerb303a422018-07-31 10:31:06 -0400564 return skia_select(
565 os_conditions,
566 [
567 # UNIX
568 [
569 "-Wno-implicit-fallthrough", # Some intentional fallthrough.
570 # Internal use of deprecated methods. :(
571 "-Wno-deprecated-declarations",
572 # TODO(kjlubick)
573 "-Wno-self-assign", # Spurious warning in tests/PathOpsDVectorTest.cpp?
574 ],
575 # ANDROID
576 [
Mike Klein9b7e99e2018-08-22 16:45:11 -0400577 "-Wno-implicit-fallthrough", # Some intentional fallthrough.
Ben Wagnerb303a422018-07-31 10:31:06 -0400578 # 'GrResourceCache' declared with greater visibility than the
579 # type of its field 'GrResourceCache::fPurgeableQueue'... bogus.
580 "-Wno-error=attributes",
581 ],
582 # IOS
Benjamin Barenblatfd10d172018-07-31 16:41:37 -0400583 [
584 "-Wno-implicit-fallthrough", # Some intentional fallthrough.
585 ],
Ben Wagnerb303a422018-07-31 10:31:06 -0400586 ],
587 )
benjaminwagner56f6d062016-01-13 10:45:19 -0800588
589################################################################################
590## DEFINES
591################################################################################
592
Ben Wagner9eca72b2017-10-17 10:57:34 -0400593def base_defines(os_conditions):
Ben Wagnerb303a422018-07-31 10:31:06 -0400594 return [
595 # Chrome DEFINES.
596 "SK_USE_FREETYPE_EMBOLDEN",
597 # Turn on a few Google3-specific build fixes.
598 "SK_BUILD_FOR_GOOGLE3",
599 # Required for building dm.
600 "GR_TEST_UTILS",
601 # Staging flags for API changes
602 # Should remove after we update golden images
603 "SK_WEBP_ENCODER_USE_DEFAULT_METHOD",
604 # Experiment to diagnose image diffs in Google3
Mike Klein0ade68c2018-10-24 06:52:35 -0400605 "SK_DISABLE_LOWP_RASTER_PIPELINE",
Ben Wagnerb303a422018-07-31 10:31:06 -0400606 # JPEG is in codec_limited
607 "SK_HAS_JPEG_LIBRARY",
608 ] + skia_select(
609 os_conditions,
610 [
611 # UNIX
612 [
613 "PNG_SKIP_SETJMP_CHECK",
614 "SK_BUILD_FOR_UNIX",
615 "SK_SAMPLES_FOR_X",
616 "SK_PDF_USE_SFNTLY",
Ben Wagnerb303a422018-07-31 10:31:06 -0400617 "SK_HAS_PNG_LIBRARY",
618 "SK_HAS_WEBP_LIBRARY",
619 ],
620 # ANDROID
621 [
622 "SK_BUILD_FOR_ANDROID",
Ben Wagnerb303a422018-07-31 10:31:06 -0400623 "SK_HAS_PNG_LIBRARY",
624 "SK_HAS_WEBP_LIBRARY",
625 ],
626 # IOS
627 [
628 "SK_BUILD_FOR_IOS",
629 "SK_BUILD_NO_OPTS",
630 "SKNX_NO_SIMD",
631 ],
632 ],
633 )
benjaminwagner787ca872015-08-17 12:58:10 -0700634
benjaminwagner56f6d062016-01-13 10:45:19 -0800635################################################################################
636## LINKOPTS
637################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700638
Ben Wagner9eca72b2017-10-17 10:57:34 -0400639def base_linkopts(os_conditions):
Ben Wagnerb303a422018-07-31 10:31:06 -0400640 return [
641 "-ldl",
642 ] + skia_select(
643 os_conditions,
644 [
645 # UNIX
646 [],
647 # ANDROID
648 [
649 "-lEGL",
Ben Wagner773151f2018-08-17 09:28:53 -0400650 "-lGLESv2",
Ben Wagnerb303a422018-07-31 10:31:06 -0400651 ],
652 # IOS
653 [
654 "-framework CoreFoundation",
655 "-framework CoreGraphics",
656 "-framework CoreText",
657 "-framework ImageIO",
658 "-framework MobileCoreServices",
659 ],
660 ],
661 )
Florin Malitadcc9d062018-11-08 14:25:19 -0500662
663################################################################################
664## skottie_tool
665################################################################################
666
667SKOTTIE_TOOL_INCLUDES = [
Florin Malitaa8316552018-11-09 16:19:44 -0500668 "modules/skottie/utils",
Florin Malitadcc9d062018-11-08 14:25:19 -0500669 "tools/flags",
670]
671
672SKOTTIE_TOOL_SRCS = [
673 "modules/skottie/src/SkottieTool.cpp",
Florin Malitaa8316552018-11-09 16:19:44 -0500674 "modules/skottie/utils/SkottieUtils.cpp",
675 "modules/skottie/utils/SkottieUtils.h",
Florin Malitadcc9d062018-11-08 14:25:19 -0500676 # TODO(benjaminwagner): Add "flags" target.
677 "tools/flags/SkCommandLineFlags.cpp",
678 "tools/flags/SkCommandLineFlags.h",
679]