blob: b466cac9a97187b30a81487052c4d6a1e46f6630 [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):
8 """Replaces select() with a Bazel-friendly wrapper.
9
10 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)
21
22def skia_select(conditions, results):
23 """Replaces select() for conditions [UNIX, ANDROID, IOS]
24
25 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")
33
34 selector = {}
35 for i in range(3):
36 selector[conditions[i]] = results[i]
37 return portable_select(selector, conditions[2], conditions[0])
38
39def skia_glob(srcs):
40 """Replaces glob() with a version that accepts a struct.
41
42 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 []
53
54################################################################################
55## BASE_SRCS
56################################################################################
benjaminwagner787ca872015-08-17 12:58:10 -070057
benjaminwagner39e7aa42015-11-18 13:26:10 -080058# All platform-independent SRCS.
benjaminwagner56f6d062016-01-13 10:45:19 -080059BASE_SRCS_ALL = struct(
60 include = [
Ben Wagnerdea74282017-03-16 19:15:09 -040061 "include/private/**/*.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -070062 "src/**/*.h",
63 "src/**/*.cpp",
Ben Wagnerdea74282017-03-16 19:15:09 -040064 "src/**/*.inc",
Mike Klein0a64e322017-03-29 17:32:50 -040065 "src/jumper/SkJumper_generated.S",
benjaminwagner787ca872015-08-17 12:58:10 -070066
mtkleind55d13a2015-08-18 08:51:49 -070067 # Third Party
benjaminwagner787ca872015-08-17 12:58:10 -070068 "third_party/etc1/*.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -070069 "third_party/etc1/*.h",
Ben Wagnerd0a3b062016-10-24 14:11:12 -040070 "third_party/gif/*.cpp",
71 "third_party/gif/*.h",
benjaminwagner787ca872015-08-17 12:58:10 -070072 ],
Ben Wagnerdea74282017-03-16 19:15:09 -040073 exclude = [
benjaminwagner6f6bef82015-10-15 08:09:44 -070074 # Exclude platform-dependent files.
irothd2ccc772016-01-25 11:24:57 -080075 "src/android/*",
iroth76a12252016-01-07 07:11:39 -080076 "src/codec/*",
benjaminwagner6f6bef82015-10-15 08:09:44 -070077 "src/device/xps/*", # Windows-only. Move to ports?
78 "src/doc/*_XPS.cpp", # Windows-only. Move to ports?
79 "src/gpu/gl/android/*",
benjaminwagner86ea33e2015-10-26 10:46:25 -070080 "src/gpu/gl/egl/*",
benjaminwagneraf3b35e2016-03-28 13:27:28 -070081 "src/gpu/gl/glfw/*",
benjaminwagner86ea33e2015-10-26 10:46:25 -070082 "src/gpu/gl/glx/*",
benjaminwagner6f6bef82015-10-15 08:09:44 -070083 "src/gpu/gl/iOS/*",
84 "src/gpu/gl/mac/*",
85 "src/gpu/gl/win/*",
iroth76a12252016-01-07 07:11:39 -080086 "src/images/*",
benjaminwagner6f6bef82015-10-15 08:09:44 -070087 "src/opts/**/*",
88 "src/ports/**/*",
89 "src/utils/android/**/*",
90 "src/utils/mac/**/*",
benjaminwagner6f6bef82015-10-15 08:09:44 -070091 "src/utils/SkThreadUtils_win.cpp", # Windows-only. Move to ports?
92 "src/utils/win/**/*",
93 "src/views/sdl/*",
94 "src/views/win/*",
95 "src/views/unix/*",
96
97 # Exclude multiple definitions.
98 # TODO(mtklein): Move to opts?
benjaminwagnerca26a182016-03-14 15:21:12 -070099 "src/pdf/SkDocument_PDF_None.cpp", # We use src/pdf/SkPDFDocument.cpp.
benjaminwagner86ea33e2015-10-26 10:46:25 -0700100 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
101 "src/gpu/gl/GrGLDefaultInterface_native.cpp",
iroth5f0de062016-02-17 12:47:27 -0800102 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700103
104 # Exclude files that don't compile with the current DEFINES.
benjaminwagner6f6bef82015-10-15 08:09:44 -0700105 "src/gpu/gl/mesa/*", # Requires SK_MESA define.
benjaminwagner921e48b2016-07-15 11:27:27 -0700106 "src/svg/**/*", # Depends on XML.
107 "src/xml/**/*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700108
benjaminwagner39e7aa42015-11-18 13:26:10 -0800109 # Conflicting dependencies among Lua versions. See cl/107087297.
110 "src/utils/SkLua*",
111
benjaminwagner6f6bef82015-10-15 08:09:44 -0700112 # Not used.
benjaminwagner6f6bef82015-10-15 08:09:44 -0700113 "src/views/**/*",
egdaniel32119f12016-02-22 10:07:54 -0800114
115 # Currently exclude all vulkan specific files
116 "src/gpu/vk/*",
benjaminwagnerc8962512016-09-30 12:06:27 -0700117
118 # Defines main.
119 "src/sksl/SkSLMain.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700120 ],
121)
122
123# Platform-dependent SRCS for google3-default platform.
benjaminwagner56f6d062016-01-13 10:45:19 -0800124BASE_SRCS_UNIX = struct(
125 include = [
irothd2ccc772016-01-25 11:24:57 -0800126 "src/android/*",
iroth76a12252016-01-07 07:11:39 -0800127 "src/codec/*",
iroth5f0de062016-02-17 12:47:27 -0800128 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
iroth76a12252016-01-07 07:11:39 -0800129 "src/images/*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700130 "src/opts/**/*.cpp",
131 "src/opts/**/*.h",
132 "src/ports/**/*.cpp",
133 "src/ports/**/*.h",
134 ],
135 exclude = [
Ben Wagnerdea74282017-03-16 19:15:09 -0400136 "src/opts/opts_check_x86.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700137 "src/opts/*arm*",
138 "src/opts/*mips*",
139 "src/opts/*NEON*",
140 "src/opts/*neon*",
Ben Wagnerdea74282017-03-16 19:15:09 -0400141 # Included in :opts_sse2 library.
142 "src/opts/*SSE2*",
143 "src/opts/*sse2*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700144 # Included in :opts_ssse3 library.
benjaminwagner6f6bef82015-10-15 08:09:44 -0700145 "src/opts/*SSSE3*",
146 "src/opts/*ssse3*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700147 # Included in :opts_sse4 library.
benjaminwagner6f6bef82015-10-15 08:09:44 -0700148 "src/opts/*SSE4*",
149 "src/opts/*sse4*",
Mike Klein71475052016-09-30 11:34:54 -0400150 # Included in :opts_avx or :opts_hsw
mtkleinf6d8d282015-12-17 10:18:04 -0800151 "src/opts/*avx*",
Mike Klein71475052016-09-30 11:34:54 -0400152 "src/opts/*hsw*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700153 "src/opts/SkBitmapProcState_opts_none.cpp",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700154 "src/opts/SkBlitMask_opts_none.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700155 "src/opts/SkBlitRow_opts_none.cpp",
msarett6b4985c2016-03-10 07:15:59 -0800156 "src/ports/*CG*",
msarettfc0b6d12016-03-17 13:50:17 -0700157 "src/ports/*WIC*",
mtklein3f193a92016-03-10 08:52:05 -0800158 "src/ports/*android*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700159 "src/ports/*chromium*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700160 "src/ports/*mac*",
161 "src/ports/*mozalloc*",
162 "src/ports/*nacl*",
163 "src/ports/*win*",
benjaminwagner2211a7b2015-12-01 11:12:05 -0800164 "src/ports/SkFontMgr_custom_directory_factory.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700165 "src/ports/SkFontMgr_custom_embedded_factory.cpp",
benjaminwagnerd9dd5812016-03-21 10:45:01 -0700166 "src/ports/SkFontMgr_custom_empty_factory.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700167 "src/ports/SkFontMgr_empty_factory.cpp",
benjaminwagner404816e2015-12-03 05:04:03 -0800168 "src/ports/SkFontMgr_fontconfig.cpp",
benjaminwagner2211a7b2015-12-01 11:12:05 -0800169 "src/ports/SkFontMgr_fontconfig_factory.cpp",
Mike Klein4b698cb2017-02-09 15:28:53 -0500170 "src/ports/SkGlobalInitialization_none.cpp",
msarettc1d03122016-03-25 08:58:55 -0700171 "src/ports/SkImageEncoder_none.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700172 "src/ports/SkImageGenerator_none.cpp",
173 "src/ports/SkTLS_none.cpp",
mtkleind55d13a2015-08-18 08:51:49 -0700174 ],
175)
176
benjaminwagner86ea33e2015-10-26 10:46:25 -0700177# Platform-dependent SRCS for google3-default Android.
benjaminwagner56f6d062016-01-13 10:45:19 -0800178BASE_SRCS_ANDROID = struct(
179 include = [
irothd2ccc772016-01-25 11:24:57 -0800180 "src/android/*",
iroth76a12252016-01-07 07:11:39 -0800181 "src/codec/*",
iroth5f0de062016-02-17 12:47:27 -0800182 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
iroth76a12252016-01-07 07:11:39 -0800183 "src/images/*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700184 # TODO(benjaminwagner): Figure out how to compile with EGL.
benjaminwagner86ea33e2015-10-26 10:46:25 -0700185 "src/opts/**/*.cpp",
186 "src/opts/**/*.h",
187 "src/ports/**/*.cpp",
188 "src/ports/**/*.h",
189 ],
190 exclude = [
191 "src/opts/*mips*",
192 "src/opts/*SSE2*",
193 "src/opts/*SSSE3*",
194 "src/opts/*ssse3*",
195 "src/opts/*SSE4*",
196 "src/opts/*sse4*",
mtkleinf6d8d282015-12-17 10:18:04 -0800197 "src/opts/*avx*",
Mike Kleinfb2c6332017-01-26 14:40:53 -0500198 "src/opts/*hsw*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700199 "src/opts/*x86*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700200 "src/opts/SkBlitMask_opts_none.cpp",
201 "src/opts/SkBlitRow_opts_none.cpp",
msarett6b4985c2016-03-10 07:15:59 -0800202 "src/ports/*CG*",
mtklein3f193a92016-03-10 08:52:05 -0800203 "src/ports/*FontConfig*",
msarettfc0b6d12016-03-17 13:50:17 -0700204 "src/ports/*WIC*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700205 "src/ports/*chromium*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700206 "src/ports/*fontconfig*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700207 "src/ports/*mac*",
208 "src/ports/*mozalloc*",
209 "src/ports/*nacl*",
210 "src/ports/*win*",
211 "src/ports/SkDebug_stdio.cpp",
212 "src/ports/SkFontMgr_custom_directory_factory.cpp",
213 "src/ports/SkFontMgr_custom_embedded_factory.cpp",
benjaminwagnerd9dd5812016-03-21 10:45:01 -0700214 "src/ports/SkFontMgr_custom_empty_factory.cpp",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700215 "src/ports/SkFontMgr_empty_factory.cpp",
Mike Klein4b698cb2017-02-09 15:28:53 -0500216 "src/ports/SkGlobalInitialization_none.cpp",
msarettc1d03122016-03-25 08:58:55 -0700217 "src/ports/SkImageEncoder_none.cpp",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700218 "src/ports/SkImageGenerator_none.cpp",
219 "src/ports/SkTLS_none.cpp",
220 ],
221)
222
iroth8b99ef42015-11-02 11:11:21 -0800223# Platform-dependent SRCS for google3-default iOS.
benjaminwagner56f6d062016-01-13 10:45:19 -0800224BASE_SRCS_IOS = struct(
225 include = [
msarett2775cf52016-02-17 14:14:25 -0800226 "src/android/*",
227 "src/codec/*",
iroth5f0de062016-02-17 12:47:27 -0800228 "src/gpu/gl/GrGLDefaultInterface_native.cpp",
229 "src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800230 "src/opts/**/*.cpp",
231 "src/opts/**/*.h",
232 "src/ports/**/*.cpp",
233 "src/ports/**/*.h",
irothab669de2016-02-16 19:17:01 -0800234 "src/utils/mac/*.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800235 ],
236 exclude = [
msarett2775cf52016-02-17 14:14:25 -0800237 "src/codec/*Ico*.cpp",
msarett2775cf52016-02-17 14:14:25 -0800238 "src/codec/*Webp*.cpp",
239 "src/codec/*Png*",
240 "src/codec/*Raw*.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800241 "src/opts/*mips*",
242 "src/opts/*NEON*",
243 "src/opts/*neon*",
244 "src/opts/*SSE2*",
245 "src/opts/*SSSE3*",
246 "src/opts/*ssse3*",
247 "src/opts/*SSE4*",
248 "src/opts/*sse4*",
mtkleinf6d8d282015-12-17 10:18:04 -0800249 "src/opts/*avx*",
Mike Kleinfb2c6332017-01-26 14:40:53 -0500250 "src/opts/*hsw*",
iroth8b99ef42015-11-02 11:11:21 -0800251 "src/opts/*x86*",
irothd2ccc772016-01-25 11:24:57 -0800252 "src/opts/SkBlitMask_opts_arm*.cpp",
253 "src/opts/SkBlitRow_opts_arm*.cpp",
mtklein3f193a92016-03-10 08:52:05 -0800254 "src/ports/*CG*",
255 "src/ports/*FontConfig*",
256 "src/ports/*FreeType*",
msarettfc0b6d12016-03-17 13:50:17 -0700257 "src/ports/*WIC*",
iroth8b99ef42015-11-02 11:11:21 -0800258 "src/ports/*android*",
259 "src/ports/*chromium*",
260 "src/ports/*fontconfig*",
iroth8b99ef42015-11-02 11:11:21 -0800261 "src/ports/*mozalloc*",
262 "src/ports/*nacl*",
263 "src/ports/*win*",
iroth8b99ef42015-11-02 11:11:21 -0800264 "src/ports/SkFontMgr_custom.cpp",
Ben Wagner8ab590f2017-02-08 17:29:33 -0500265 "src/ports/SkFontMgr_custom_directory.cpp",
266 "src/ports/SkFontMgr_custom_embedded.cpp",
267 "src/ports/SkFontMgr_custom_empty.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800268 "src/ports/SkFontMgr_custom_directory_factory.cpp",
269 "src/ports/SkFontMgr_custom_embedded_factory.cpp",
benjaminwagnerd9dd5812016-03-21 10:45:01 -0700270 "src/ports/SkFontMgr_custom_empty_factory.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800271 "src/ports/SkFontMgr_empty_factory.cpp",
Mike Klein4b698cb2017-02-09 15:28:53 -0500272 "src/ports/SkGlobalInitialization_none.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800273 "src/ports/SkImageGenerator_none.cpp",
274 "src/ports/SkTLS_none.cpp",
275 ],
276)
277
benjaminwagner56f6d062016-01-13 10:45:19 -0800278################################################################################
Ben Wagnerdea74282017-03-16 19:15:09 -0400279## skia_{all,public}_hdrs()
benjaminwagner56f6d062016-01-13 10:45:19 -0800280################################################################################
Ben Wagnerdea74282017-03-16 19:15:09 -0400281def skia_all_hdrs():
282 return native.glob(["src/**/*.h", "include/**/*.h"])
benjaminwagner86ea33e2015-10-26 10:46:25 -0700283
Ben Wagnerdea74282017-03-16 19:15:09 -0400284def skia_public_hdrs():
285 return native.glob(["include/**/*.h"],
286 exclude=[
287 "include/private/**/*.h",
288 "include/views/**/*", # Not used.
289 ])
290
291################################################################################
292## skia_opts_srcs()
293################################################################################
294# Intel
295SKIA_OPTS_SSE2 = "SSE2"
296
297SKIA_OPTS_SSSE3 = "SSSE3"
298
299SKIA_OPTS_SSE4 = "SSE4"
300
301SKIA_OPTS_AVX = "AVX"
302
303SKIA_OPTS_HSW = "HSW"
304
305# Arm
306SKIA_OPTS_ARMV7 = "ARMV7"
307
308SKIA_OPTS_NEON = "NEON"
309
310SKIA_OPTS_ARM64 = "ARM64"
311
312SKIA_OPTS_CRC32 = "CRC32" # arm64
313
314# Other
315SKIA_OPTS_NONE = "NONE" # not x86, arm, or arm64
316
317def skia_opts_srcs(opts):
318 if opts == SKIA_OPTS_SSE2:
319 return native.glob([
320 "src/opts/*SSE2*.cpp",
321 "src/opts/*sse2*.cpp",
322 ])
323 elif opts == SKIA_OPTS_SSSE3:
324 return native.glob([
mtkleind55d13a2015-08-18 08:51:49 -0700325 "src/opts/*SSSE3*.cpp",
326 "src/opts/*ssse3*.cpp",
Ben Wagnerdea74282017-03-16 19:15:09 -0400327 ])
328 elif opts == SKIA_OPTS_SSE4:
329 return native.glob([
mtkleind55d13a2015-08-18 08:51:49 -0700330 "src/opts/*SSE4*.cpp",
331 "src/opts/*sse4*.cpp",
Ben Wagnerdea74282017-03-16 19:15:09 -0400332 ])
333 elif opts == SKIA_OPTS_AVX:
334 return native.glob([
mtkleinf6d8d282015-12-17 10:18:04 -0800335 "src/opts/*_avx.cpp",
Ben Wagnerdea74282017-03-16 19:15:09 -0400336 ])
337 elif opts == SKIA_OPTS_HSW:
338 return native.glob([
Mike Klein78d5a3b2016-09-30 10:48:01 -0400339 "src/opts/*_hsw.cpp",
Ben Wagnerdea74282017-03-16 19:15:09 -0400340 ])
341 elif opts == SKIA_OPTS_ARMV7:
342 return native.glob([
343 "src/opts/*_arm.cpp",
344 ])
345 elif opts == SKIA_OPTS_NEON:
346 return native.glob([
347 "src/opts/*_neon.cpp",
348 ])
349 elif opts == SKIA_OPTS_CRC32:
350 return native.glob([
351 "src/opts/*_crc32.cpp",
352 ])
353 elif opts == SKIA_OPTS_NONE:
354 return native.glob([
355 "src/opts/*_none.cpp",
356 ])
357 else:
358 fail("skia_opts_srcs parameter 'opts' must be one of SKIA_OPTS_*.")
359
360def skia_opts_cflags(opts):
361 if opts == SKIA_OPTS_SSE2:
362 return ["-msse2"]
363 elif opts == SKIA_OPTS_SSSE3:
364 return ["-mssse3"]
365 elif opts == SKIA_OPTS_SSE4:
366 return ["-msse4"]
367 elif opts == SKIA_OPTS_AVX:
368 return ["-mavx"]
369 elif opts == SKIA_OPTS_HSW:
370 return ["-mavx2", "-mbmi", "-mbmi2", "-mf16c", "-mfma"]
371 elif opts == SKIA_OPTS_CRC32:
372 return ["-march=armv8-a+crc"]
373 else:
374 return []
Mike Klein78d5a3b2016-09-30 10:48:01 -0400375
benjaminwagner56f6d062016-01-13 10:45:19 -0800376################################################################################
Ben Wagnerdea74282017-03-16 19:15:09 -0400377## skia_srcs()
benjaminwagner56f6d062016-01-13 10:45:19 -0800378################################################################################
Ben Wagnerdea74282017-03-16 19:15:09 -0400379SKIA_OS_UNIX = "UNIX"
benjaminwagner56f6d062016-01-13 10:45:19 -0800380
Ben Wagnerdea74282017-03-16 19:15:09 -0400381SKIA_OS_ANDROID = "ANDROID"
benjaminwagner787ca872015-08-17 12:58:10 -0700382
Ben Wagnerdea74282017-03-16 19:15:09 -0400383SKIA_OS_IOS = "IOS"
benjaminwagner56f6d062016-01-13 10:45:19 -0800384
Ben Wagnerdea74282017-03-16 19:15:09 -0400385SKIA_CPU_UNSPECIFIED = "UNSPECIFIED"
benjaminwagner56f6d062016-01-13 10:45:19 -0800386
Ben Wagnerdea74282017-03-16 19:15:09 -0400387SKIA_CPU_PPC = "PPC"
benjaminwagner39e7aa42015-11-18 13:26:10 -0800388
Ben Wagnerdea74282017-03-16 19:15:09 -0400389def skia_srcs(os=SKIA_OS_UNIX, cpu=SKIA_CPU_UNSPECIFIED):
390 """Sources to be compiled into the skia library."""
391 srcs = skia_glob(BASE_SRCS_ALL)
392 if os == SKIA_OS_IOS:
393 if cpu != SKIA_CPU_UNSPECIFIED:
394 fail("Do not specify IOS and a cpu.")
395 srcs = srcs + skia_glob(BASE_SRCS_IOS)
396 elif os == SKIA_OS_ANDROID:
397 if cpu != SKIA_CPU_UNSPECIFIED:
398 fail("Do not specify ANDROID and a cpu.")
399 srcs = srcs + skia_glob(BASE_SRCS_ANDROID)
400 elif os == SKIA_OS_UNIX:
401 if cpu == SKIA_CPU_UNSPECIFIED:
402 srcs = srcs + ["src/opts/opts_check_x86.cpp"] + skia_glob(BASE_SRCS_UNIX)
403 elif cpu == SKIA_CPU_PPC:
404 srcs = srcs + skia_glob(BASE_SRCS_UNIX)
405 else:
406 fail("cpu must be one of SKIA_CPU_*")
407 else:
408 fail("skia_srcs parameter 'os' must be one of SKIA_OS_{UNIX,ANDROID,IOS}.")
409 return srcs
benjaminwagner39e7aa42015-11-18 13:26:10 -0800410
benjaminwagner56f6d062016-01-13 10:45:19 -0800411################################################################################
412## INCLUDES
413################################################################################
benjaminwagner39e7aa42015-11-18 13:26:10 -0800414
benjaminwagner787ca872015-08-17 12:58:10 -0700415# Includes needed by Skia implementation. Not public includes.
416INCLUDES = [
benjaminwagnerfa7e1a02015-11-13 12:27:08 -0800417 "include/android",
benjaminwagner787ca872015-08-17 12:58:10 -0700418 "include/c",
robertphillips188d44c2016-02-01 04:54:14 -0800419 "include/client/android",
benjaminwagner787ca872015-08-17 12:58:10 -0700420 "include/codec",
421 "include/config",
422 "include/core",
benjaminwagner787ca872015-08-17 12:58:10 -0700423 "include/effects",
424 "include/gpu",
425 "include/images",
426 "include/pathops",
benjaminwagner787ca872015-08-17 12:58:10 -0700427 "include/pipe",
428 "include/ports",
429 "include/private",
430 "include/utils",
iroth8b99ef42015-11-02 11:11:21 -0800431 "include/utils/mac",
432 "include/utils/win",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700433 "include/svg",
benjaminwagner787ca872015-08-17 12:58:10 -0700434 "include/xml",
benjaminwagnerfa7e1a02015-11-13 12:27:08 -0800435 "src/codec",
benjaminwagner787ca872015-08-17 12:58:10 -0700436 "src/core",
benjaminwagner787ca872015-08-17 12:58:10 -0700437 "src/gpu",
438 "src/image",
439 "src/lazy",
440 "src/opts",
benjaminwagner2211a7b2015-12-01 11:12:05 -0800441 "src/ports",
benjaminwagner787ca872015-08-17 12:58:10 -0700442 "src/pdf",
benjaminwagner787ca872015-08-17 12:58:10 -0700443 "src/sfnt",
benjaminwagnerc8962512016-09-30 12:06:27 -0700444 "src/sksl",
benjaminwagner787ca872015-08-17 12:58:10 -0700445 "src/utils",
446 "third_party/etc1",
Ben Wagnerd0a3b062016-10-24 14:11:12 -0400447 "third_party/gif",
benjaminwagner56f6d062016-01-13 10:45:19 -0800448]
benjaminwagner787ca872015-08-17 12:58:10 -0700449
benjaminwagner56f6d062016-01-13 10:45:19 -0800450################################################################################
451## DM_SRCS
452################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700453
benjaminwagner56f6d062016-01-13 10:45:19 -0800454DM_SRCS_ALL = struct(
455 include = [
benjaminwagner6f6bef82015-10-15 08:09:44 -0700456 "dm/*.cpp",
457 "dm/*.h",
458 "gm/*.c",
459 "gm/*.cpp",
460 "gm/*.h",
461 "tests/*.cpp",
462 "tests/*.h",
benjaminwagner99fb6702016-07-28 15:12:21 -0700463 "tools/BigPathBench.inc",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700464 "tools/CrashHandler.cpp",
465 "tools/CrashHandler.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700466 "tools/ProcStats.cpp",
467 "tools/ProcStats.h",
468 "tools/Resources.cpp",
469 "tools/Resources.h",
benjaminwagner99fb6702016-07-28 15:12:21 -0700470 "tools/SkJSONCPP.h",
471 "tools/UrlDataManager.cpp",
472 "tools/UrlDataManager.h",
473 "tools/debugger/*.cpp",
474 "tools/debugger/*.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700475 "tools/flags/*.cpp",
476 "tools/flags/*.h",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700477 "tools/gpu/**/*.cpp",
478 "tools/gpu/**/*.h",
brianosman6d3119c2016-04-19 19:41:54 -0700479 "tools/picture_utils.cpp",
benjaminwagner99fb6702016-07-28 15:12:21 -0700480 "tools/picture_utils.h",
mtkleine1fc4522016-02-09 12:32:52 -0800481 "tools/random_parse_path.cpp",
482 "tools/random_parse_path.h",
benjaminwagner32885142015-10-24 07:55:31 -0700483 "tools/sk_tool_utils.cpp",
484 "tools/sk_tool_utils.h",
benjaminwagner99fb6702016-07-28 15:12:21 -0700485 "tools/sk_tool_utils_flags.h",
benjaminwagner32885142015-10-24 07:55:31 -0700486 "tools/sk_tool_utils_font.cpp",
benjaminwagner99fb6702016-07-28 15:12:21 -0700487 "tools/test_font_monospace.inc",
488 "tools/test_font_sans_serif.inc",
489 "tools/test_font_serif.inc",
490 "tools/test_font_index.inc",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700491 "tools/timer/*.cpp",
492 "tools/timer/*.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700493 ],
494 exclude = [
benjaminwagner86ea33e2015-10-26 10:46:25 -0700495 "tests/FontMgrAndroidParserTest.cpp", # Android-only.
benjaminwagner6f6bef82015-10-15 08:09:44 -0700496 "tests/skia_test.cpp", # Old main.
497 "tests/SkpSkGrTest.cpp", # Alternate main.
benjaminwagner921e48b2016-07-15 11:27:27 -0700498 "tests/SVGDeviceTest.cpp",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700499 "tools/gpu/gl/angle/*",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700500 "tools/gpu/gl/egl/*",
501 "tools/gpu/gl/glx/*",
502 "tools/gpu/gl/iOS/*",
503 "tools/gpu/gl/mac/*",
504 "tools/gpu/gl/mesa/*",
505 "tools/gpu/gl/win/*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700506 "tools/timer/SysTimer_mach.cpp",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700507 "tools/timer/SysTimer_windows.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700508 ],
509)
510
Ben Wagnerdea74282017-03-16 19:15:09 -0400511################################################################################
512## dm_srcs()
513################################################################################
514# SKIA_OS_* definitions can be found above.
benjaminwagner86ea33e2015-10-26 10:46:25 -0700515
Ben Wagnerdea74282017-03-16 19:15:09 -0400516def dm_srcs(os):
517 """Sources for the dm binary for the specified os."""
518 srcs = skia_glob(DM_SRCS_ALL)
519 # TODO(benjaminwagner): None of the CreatePlatformGLContext_*.cpp files exist.
520 # TODO(jwg): Remove the globs if possible, they only select single files.
521 if os == SKIA_OS_IOS:
522 srcs = srcs + native.glob(["tools/gpu/iOS/CreatePlatformGLContext_iOS.cpp"])
523 elif os == SKIA_OS_ANDROID:
524 srcs = srcs + native.glob([
benjaminwagner86ea33e2015-10-26 10:46:25 -0700525 "tests/FontMgrAndroidParserTest.cpp",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700526 # TODO(benjaminwagner): Figure out how to compile with EGL.
527 "tools/gpu/gl/CreatePlatformGLContext_none.cpp",
Ben Wagnerdea74282017-03-16 19:15:09 -0400528 ])
529 elif os == SKIA_OS_UNIX:
530 srcs = srcs + native.glob(["tools/gpu/gl/CreatePlatformGLContext_none.cpp"])
531 else:
532 fail("dm_srcs parameter 'os' must be one of SKIA_OS_{UNIX,ANDROID,IOS}.")
533 return srcs
benjaminwagner56f6d062016-01-13 10:45:19 -0800534
535################################################################################
536## DM_INCLUDES
537################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700538
benjaminwagner6f6bef82015-10-15 08:09:44 -0700539DM_INCLUDES = [
benjaminwagnerb1fe8f62016-02-01 09:05:08 -0800540 "dm",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700541 "gm",
Mike Reed7f302c42017-02-18 14:12:08 -0500542 "experimental/svg/model",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700543 "src/codec",
Mike Reedaab8ce42017-02-18 12:57:09 -0500544 "src/core",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700545 "src/effects",
benjaminwagnerbc9a9b42016-02-22 13:30:39 -0800546 "src/effects/gradients",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700547 "src/fonts",
Hal Canarydb683012016-11-23 08:55:18 -0700548 "src/images",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700549 "src/pathops",
550 "src/pipe/utils",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700551 "src/ports",
Mike Reedf71828f2017-02-18 09:51:33 -0500552 "src/xml",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700553 "tests",
554 "tools",
benjaminwagner99fb6702016-07-28 15:12:21 -0700555 "tools/debugger",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700556 "tools/flags",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700557 "tools/gpu",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700558 "tools/timer",
559]
560
benjaminwagner56f6d062016-01-13 10:45:19 -0800561################################################################################
562## DM_ARGS
563################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700564
Ben Wagner59f9edb2016-11-28 15:30:37 -0500565def DM_ARGS(asan):
benjaminwagner83906ae2016-05-01 15:02:25 -0700566 source = ["tests", "gm", "image"]
567 # TODO(benjaminwagner): f16 and serialize-8888 fail.
568 config = ["565", "8888", "pdf", "srgb", "tiles_rt", "pic"]
569 # TODO(mtklein): maybe investigate why these fail?
570 match = [
571 "~Canvas",
572 "~Codec",
573 "~Codec_Dimensions",
574 "~Codec_stripes",
575 "~FontMgr",
576 "~PaintBreakText",
577 "~RecordDraw_TextBounds",
578 "~Scalar",
579 "~skps",
580 "~Stream",
581 ]
582 if asan:
Ben Wagner59f9edb2016-11-28 15:30:37 -0500583 # The ASAN we use with Bazel has some strict checks, so omit tests that
584 # trigger them.
benjaminwagner83906ae2016-05-01 15:02:25 -0700585 match += [
586 "~clippedcubic2",
587 "~conicpaths",
Ben Wagner59f9edb2016-11-28 15:30:37 -0500588 "~^gradients",
benjaminwagner83906ae2016-05-01 15:02:25 -0700589 "~Math",
590 "~Matrix",
Ben Wagner55b72532017-01-29 21:50:51 -0500591 "~PathBigCubic",
benjaminwagner83906ae2016-05-01 15:02:25 -0700592 "~PathOpsCubic",
benjaminwagnerb5188622016-06-29 10:26:44 -0700593 "~PathOpsFailOp",
caryclark523e76d2016-07-19 12:27:32 -0700594 "~PathOpsOpCubicsThreaded",
benjaminwagner83906ae2016-05-01 15:02:25 -0700595 "~PathOpsOpLoopsThreaded",
596 "~PathOpsSimplify",
597 "~PathOpsTightBoundsQuads",
598 "~Point",
benjaminwagner1d352312016-07-25 06:32:13 -0700599 "~sk_linear_to_srgb",
Ben Wagner59f9edb2016-11-28 15:30:37 -0500600 "~small_color_stop",
benjaminwagner56f6d062016-01-13 10:45:19 -0800601 ]
Ben Wagner59f9edb2016-11-28 15:30:37 -0500602 return ["--src"] + source + ["--config"] + config + ["--match"] + match
benjaminwagner56f6d062016-01-13 10:45:19 -0800603
604################################################################################
605## COPTS
606################################################################################
iroth8b99ef42015-11-02 11:11:21 -0800607
benjaminwagner86ea33e2015-10-26 10:46:25 -0700608COPTS_UNIX = [
benjaminwagner787ca872015-08-17 12:58:10 -0700609 "-Wno-implicit-fallthrough", # Some intentional fallthrough.
benjaminwagner7d974f52015-10-19 13:55:55 -0700610 "-Wno-deprecated-declarations", # Internal use of deprecated methods. :(
benjaminwagner787ca872015-08-17 12:58:10 -0700611]
612
benjaminwagner56f6d062016-01-13 10:45:19 -0800613COPTS_ANDROID = ["-mfpu=neon"]
614
615COPTS_IOS = []
616
617COPTS_ALL = []
618
619################################################################################
620## DEFINES
621################################################################################
622
623DEFINES_UNIX = [
scroggo7732c0c2016-06-22 07:25:16 -0700624 "PNG_SKIP_SETJMP_CHECK",
benjaminwagner56f6d062016-01-13 10:45:19 -0800625 "SK_BUILD_FOR_UNIX",
626 "SK_SAMPLES_FOR_X",
halcanary650e20d2016-08-25 09:07:02 -0700627 "SK_PDF_USE_SFNTLY",
benjaminwagner186e0b92016-02-11 16:00:24 -0800628 "SK_CODEC_DECODES_RAW",
msarettad3a5c62016-05-06 07:21:26 -0700629 "SK_HAS_JPEG_LIBRARY",
scroggoe6939c12016-06-21 14:13:40 -0700630 "SK_HAS_PNG_LIBRARY",
scroggo7732c0c2016-06-22 07:25:16 -0700631 "SK_HAS_WEBP_LIBRARY",
benjaminwagner56f6d062016-01-13 10:45:19 -0800632]
benjaminwagner86ea33e2015-10-26 10:46:25 -0700633
634DEFINES_ANDROID = [
635 "SK_BUILD_FOR_ANDROID",
benjaminwagner186e0b92016-02-11 16:00:24 -0800636 "SK_CODEC_DECODES_RAW",
msarettad3a5c62016-05-06 07:21:26 -0700637 "SK_HAS_JPEG_LIBRARY",
scroggoe6939c12016-06-21 14:13:40 -0700638 "SK_HAS_PNG_LIBRARY",
scroggo7732c0c2016-06-22 07:25:16 -0700639 "SK_HAS_WEBP_LIBRARY",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700640]
641
iroth8b99ef42015-11-02 11:11:21 -0800642DEFINES_IOS = [
643 "SK_BUILD_FOR_IOS",
sdefresnee3fa8112016-06-01 07:08:56 -0700644 "SK_BUILD_NO_OPTS",
Matt Sarett2d4fc272017-02-10 09:42:54 -0500645 "SK_HAS_JPEG_LIBRARY",
irothd2ccc772016-01-25 11:24:57 -0800646 "SKNX_NO_SIMD",
iroth8b99ef42015-11-02 11:11:21 -0800647]
648
benjaminwagner86ea33e2015-10-26 10:46:25 -0700649DEFINES_ALL = [
benjaminwagner787ca872015-08-17 12:58:10 -0700650 # Chrome DEFINES.
651 "SK_USE_FLOATBITS",
652 "SK_USE_FREETYPE_EMBOLDEN",
653 # Turn on a few Google3-specific build fixes.
654 "GOOGLE3",
reedd053ce92016-03-22 10:17:23 -0700655 # Staging flags for API changes
Yuqian Li8622b722016-11-14 15:42:58 -0500656 # Temporarily Disable analytic AA for Google3
657 "SK_NO_ANALYTIC_AA",
benjaminwagner787ca872015-08-17 12:58:10 -0700658]
659
benjaminwagner56f6d062016-01-13 10:45:19 -0800660################################################################################
661## LINKOPTS
662################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700663
benjaminwagner56f6d062016-01-13 10:45:19 -0800664LINKOPTS_UNIX = []
benjaminwagner6f6bef82015-10-15 08:09:44 -0700665
benjaminwagner56f6d062016-01-13 10:45:19 -0800666LINKOPTS_ANDROID = [
667 "-lEGL",
668]
benjaminwagner6f6bef82015-10-15 08:09:44 -0700669
benjaminwagner56f6d062016-01-13 10:45:19 -0800670LINKOPTS_IOS = []
benjaminwagner6f6bef82015-10-15 08:09:44 -0700671
benjaminwagner56f6d062016-01-13 10:45:19 -0800672LINKOPTS_ALL = [
673 "-ldl",
674]