blob: 1813af0cb74c88df16270156208b98b6c6c05c3b [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",
Matt Sarettd7093c22017-05-09 15:28:32 -0400424 "include/encode",
benjaminwagner787ca872015-08-17 12:58:10 -0700425 "include/gpu",
426 "include/images",
427 "include/pathops",
benjaminwagner787ca872015-08-17 12:58:10 -0700428 "include/pipe",
429 "include/ports",
430 "include/private",
431 "include/utils",
iroth8b99ef42015-11-02 11:11:21 -0800432 "include/utils/mac",
433 "include/utils/win",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700434 "include/svg",
benjaminwagner787ca872015-08-17 12:58:10 -0700435 "include/xml",
benjaminwagnerfa7e1a02015-11-13 12:27:08 -0800436 "src/codec",
benjaminwagner787ca872015-08-17 12:58:10 -0700437 "src/core",
benjaminwagner787ca872015-08-17 12:58:10 -0700438 "src/gpu",
439 "src/image",
440 "src/lazy",
441 "src/opts",
benjaminwagner2211a7b2015-12-01 11:12:05 -0800442 "src/ports",
benjaminwagner787ca872015-08-17 12:58:10 -0700443 "src/pdf",
benjaminwagner787ca872015-08-17 12:58:10 -0700444 "src/sfnt",
benjaminwagnerc8962512016-09-30 12:06:27 -0700445 "src/sksl",
benjaminwagner787ca872015-08-17 12:58:10 -0700446 "src/utils",
447 "third_party/etc1",
Ben Wagnerd0a3b062016-10-24 14:11:12 -0400448 "third_party/gif",
benjaminwagner56f6d062016-01-13 10:45:19 -0800449]
benjaminwagner787ca872015-08-17 12:58:10 -0700450
benjaminwagner56f6d062016-01-13 10:45:19 -0800451################################################################################
452## DM_SRCS
453################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700454
benjaminwagner56f6d062016-01-13 10:45:19 -0800455DM_SRCS_ALL = struct(
456 include = [
benjaminwagner6f6bef82015-10-15 08:09:44 -0700457 "dm/*.cpp",
458 "dm/*.h",
459 "gm/*.c",
460 "gm/*.cpp",
461 "gm/*.h",
462 "tests/*.cpp",
463 "tests/*.h",
benjaminwagner99fb6702016-07-28 15:12:21 -0700464 "tools/BigPathBench.inc",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700465 "tools/CrashHandler.cpp",
466 "tools/CrashHandler.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700467 "tools/ProcStats.cpp",
468 "tools/ProcStats.h",
469 "tools/Resources.cpp",
470 "tools/Resources.h",
benjaminwagner99fb6702016-07-28 15:12:21 -0700471 "tools/SkJSONCPP.h",
472 "tools/UrlDataManager.cpp",
473 "tools/UrlDataManager.h",
474 "tools/debugger/*.cpp",
475 "tools/debugger/*.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700476 "tools/flags/*.cpp",
477 "tools/flags/*.h",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700478 "tools/gpu/**/*.cpp",
479 "tools/gpu/**/*.h",
brianosman6d3119c2016-04-19 19:41:54 -0700480 "tools/picture_utils.cpp",
benjaminwagner99fb6702016-07-28 15:12:21 -0700481 "tools/picture_utils.h",
mtkleine1fc4522016-02-09 12:32:52 -0800482 "tools/random_parse_path.cpp",
483 "tools/random_parse_path.h",
benjaminwagner32885142015-10-24 07:55:31 -0700484 "tools/sk_tool_utils.cpp",
485 "tools/sk_tool_utils.h",
benjaminwagner99fb6702016-07-28 15:12:21 -0700486 "tools/sk_tool_utils_flags.h",
benjaminwagner32885142015-10-24 07:55:31 -0700487 "tools/sk_tool_utils_font.cpp",
benjaminwagner99fb6702016-07-28 15:12:21 -0700488 "tools/test_font_monospace.inc",
489 "tools/test_font_sans_serif.inc",
490 "tools/test_font_serif.inc",
491 "tools/test_font_index.inc",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700492 "tools/timer/*.cpp",
493 "tools/timer/*.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700494 ],
495 exclude = [
benjaminwagner86ea33e2015-10-26 10:46:25 -0700496 "tests/FontMgrAndroidParserTest.cpp", # Android-only.
benjaminwagner6f6bef82015-10-15 08:09:44 -0700497 "tests/skia_test.cpp", # Old main.
498 "tests/SkpSkGrTest.cpp", # Alternate main.
benjaminwagner921e48b2016-07-15 11:27:27 -0700499 "tests/SVGDeviceTest.cpp",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700500 "tools/gpu/gl/angle/*",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700501 "tools/gpu/gl/egl/*",
502 "tools/gpu/gl/glx/*",
503 "tools/gpu/gl/iOS/*",
504 "tools/gpu/gl/mac/*",
505 "tools/gpu/gl/mesa/*",
506 "tools/gpu/gl/win/*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700507 "tools/timer/SysTimer_mach.cpp",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700508 "tools/timer/SysTimer_windows.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700509 ],
510)
511
Ben Wagnerdea74282017-03-16 19:15:09 -0400512################################################################################
513## dm_srcs()
514################################################################################
515# SKIA_OS_* definitions can be found above.
benjaminwagner86ea33e2015-10-26 10:46:25 -0700516
Ben Wagnerdea74282017-03-16 19:15:09 -0400517def dm_srcs(os):
518 """Sources for the dm binary for the specified os."""
519 srcs = skia_glob(DM_SRCS_ALL)
520 # TODO(benjaminwagner): None of the CreatePlatformGLContext_*.cpp files exist.
521 # TODO(jwg): Remove the globs if possible, they only select single files.
522 if os == SKIA_OS_IOS:
523 srcs = srcs + native.glob(["tools/gpu/iOS/CreatePlatformGLContext_iOS.cpp"])
524 elif os == SKIA_OS_ANDROID:
525 srcs = srcs + native.glob([
benjaminwagner86ea33e2015-10-26 10:46:25 -0700526 "tests/FontMgrAndroidParserTest.cpp",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700527 # TODO(benjaminwagner): Figure out how to compile with EGL.
528 "tools/gpu/gl/CreatePlatformGLContext_none.cpp",
Ben Wagnerdea74282017-03-16 19:15:09 -0400529 ])
530 elif os == SKIA_OS_UNIX:
531 srcs = srcs + native.glob(["tools/gpu/gl/CreatePlatformGLContext_none.cpp"])
532 else:
533 fail("dm_srcs parameter 'os' must be one of SKIA_OS_{UNIX,ANDROID,IOS}.")
534 return srcs
benjaminwagner56f6d062016-01-13 10:45:19 -0800535
536################################################################################
537## DM_INCLUDES
538################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700539
benjaminwagner6f6bef82015-10-15 08:09:44 -0700540DM_INCLUDES = [
benjaminwagnerb1fe8f62016-02-01 09:05:08 -0800541 "dm",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700542 "gm",
Mike Reed7f302c42017-02-18 14:12:08 -0500543 "experimental/svg/model",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700544 "src/codec",
Mike Reedaab8ce42017-02-18 12:57:09 -0500545 "src/core",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700546 "src/effects",
benjaminwagnerbc9a9b42016-02-22 13:30:39 -0800547 "src/effects/gradients",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700548 "src/fonts",
Hal Canarydb683012016-11-23 08:55:18 -0700549 "src/images",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700550 "src/pathops",
551 "src/pipe/utils",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700552 "src/ports",
Mike Reedf71828f2017-02-18 09:51:33 -0500553 "src/xml",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700554 "tests",
555 "tools",
benjaminwagner99fb6702016-07-28 15:12:21 -0700556 "tools/debugger",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700557 "tools/flags",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700558 "tools/gpu",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700559 "tools/timer",
560]
561
benjaminwagner56f6d062016-01-13 10:45:19 -0800562################################################################################
563## DM_ARGS
564################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700565
Ben Wagner59f9edb2016-11-28 15:30:37 -0500566def DM_ARGS(asan):
benjaminwagner83906ae2016-05-01 15:02:25 -0700567 source = ["tests", "gm", "image"]
568 # TODO(benjaminwagner): f16 and serialize-8888 fail.
569 config = ["565", "8888", "pdf", "srgb", "tiles_rt", "pic"]
570 # TODO(mtklein): maybe investigate why these fail?
571 match = [
572 "~Canvas",
573 "~Codec",
574 "~Codec_Dimensions",
575 "~Codec_stripes",
576 "~FontMgr",
577 "~PaintBreakText",
578 "~RecordDraw_TextBounds",
579 "~Scalar",
580 "~skps",
581 "~Stream",
582 ]
583 if asan:
Ben Wagner59f9edb2016-11-28 15:30:37 -0500584 # The ASAN we use with Bazel has some strict checks, so omit tests that
585 # trigger them.
benjaminwagner83906ae2016-05-01 15:02:25 -0700586 match += [
Ben Wagneraf6522a2017-05-08 11:40:29 -0400587 "~bigrect",
benjaminwagner83906ae2016-05-01 15:02:25 -0700588 "~clippedcubic2",
589 "~conicpaths",
Ben Wagner59f9edb2016-11-28 15:30:37 -0500590 "~^gradients",
benjaminwagner83906ae2016-05-01 15:02:25 -0700591 "~Math",
592 "~Matrix",
Ben Wagner55b72532017-01-29 21:50:51 -0500593 "~PathBigCubic",
benjaminwagner83906ae2016-05-01 15:02:25 -0700594 "~PathOpsCubic",
benjaminwagnerb5188622016-06-29 10:26:44 -0700595 "~PathOpsFailOp",
caryclark523e76d2016-07-19 12:27:32 -0700596 "~PathOpsOpCubicsThreaded",
benjaminwagner83906ae2016-05-01 15:02:25 -0700597 "~PathOpsOpLoopsThreaded",
598 "~PathOpsSimplify",
599 "~PathOpsTightBoundsQuads",
600 "~Point",
benjaminwagner1d352312016-07-25 06:32:13 -0700601 "~sk_linear_to_srgb",
Ben Wagner59f9edb2016-11-28 15:30:37 -0500602 "~small_color_stop",
benjaminwagner56f6d062016-01-13 10:45:19 -0800603 ]
Ben Wagner59f9edb2016-11-28 15:30:37 -0500604 return ["--src"] + source + ["--config"] + config + ["--match"] + match
benjaminwagner56f6d062016-01-13 10:45:19 -0800605
606################################################################################
607## COPTS
608################################################################################
iroth8b99ef42015-11-02 11:11:21 -0800609
benjaminwagner86ea33e2015-10-26 10:46:25 -0700610COPTS_UNIX = [
benjaminwagner787ca872015-08-17 12:58:10 -0700611 "-Wno-implicit-fallthrough", # Some intentional fallthrough.
benjaminwagner7d974f52015-10-19 13:55:55 -0700612 "-Wno-deprecated-declarations", # Internal use of deprecated methods. :(
benjaminwagner787ca872015-08-17 12:58:10 -0700613]
614
Mike Klein452f9202017-05-05 09:16:00 -0400615COPTS_ANDROID = [
616 "-mfpu=neon",
617 "-Wno-error=attributes", # 'GrResourceCache' declared with greater visibility than the
618 # type of its field 'GrResourceCache::fPurgeableQueue'... bogus.
619]
benjaminwagner56f6d062016-01-13 10:45:19 -0800620
621COPTS_IOS = []
622
623COPTS_ALL = []
624
625################################################################################
626## DEFINES
627################################################################################
628
629DEFINES_UNIX = [
scroggo7732c0c2016-06-22 07:25:16 -0700630 "PNG_SKIP_SETJMP_CHECK",
benjaminwagner56f6d062016-01-13 10:45:19 -0800631 "SK_BUILD_FOR_UNIX",
632 "SK_SAMPLES_FOR_X",
halcanary650e20d2016-08-25 09:07:02 -0700633 "SK_PDF_USE_SFNTLY",
benjaminwagner186e0b92016-02-11 16:00:24 -0800634 "SK_CODEC_DECODES_RAW",
msarettad3a5c62016-05-06 07:21:26 -0700635 "SK_HAS_JPEG_LIBRARY",
scroggoe6939c12016-06-21 14:13:40 -0700636 "SK_HAS_PNG_LIBRARY",
scroggo7732c0c2016-06-22 07:25:16 -0700637 "SK_HAS_WEBP_LIBRARY",
benjaminwagner56f6d062016-01-13 10:45:19 -0800638]
benjaminwagner86ea33e2015-10-26 10:46:25 -0700639
640DEFINES_ANDROID = [
641 "SK_BUILD_FOR_ANDROID",
benjaminwagner186e0b92016-02-11 16:00:24 -0800642 "SK_CODEC_DECODES_RAW",
msarettad3a5c62016-05-06 07:21:26 -0700643 "SK_HAS_JPEG_LIBRARY",
scroggoe6939c12016-06-21 14:13:40 -0700644 "SK_HAS_PNG_LIBRARY",
scroggo7732c0c2016-06-22 07:25:16 -0700645 "SK_HAS_WEBP_LIBRARY",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700646]
647
iroth8b99ef42015-11-02 11:11:21 -0800648DEFINES_IOS = [
649 "SK_BUILD_FOR_IOS",
sdefresnee3fa8112016-06-01 07:08:56 -0700650 "SK_BUILD_NO_OPTS",
Matt Sarett2d4fc272017-02-10 09:42:54 -0500651 "SK_HAS_JPEG_LIBRARY",
irothd2ccc772016-01-25 11:24:57 -0800652 "SKNX_NO_SIMD",
iroth8b99ef42015-11-02 11:11:21 -0800653]
654
benjaminwagner86ea33e2015-10-26 10:46:25 -0700655DEFINES_ALL = [
benjaminwagner787ca872015-08-17 12:58:10 -0700656 # Chrome DEFINES.
657 "SK_USE_FLOATBITS",
658 "SK_USE_FREETYPE_EMBOLDEN",
659 # Turn on a few Google3-specific build fixes.
660 "GOOGLE3",
reedd053ce92016-03-22 10:17:23 -0700661 # Staging flags for API changes
Yuqian Li8622b722016-11-14 15:42:58 -0500662 # Temporarily Disable analytic AA for Google3
663 "SK_NO_ANALYTIC_AA",
benjaminwagner787ca872015-08-17 12:58:10 -0700664]
665
benjaminwagner56f6d062016-01-13 10:45:19 -0800666################################################################################
667## LINKOPTS
668################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700669
benjaminwagner56f6d062016-01-13 10:45:19 -0800670LINKOPTS_UNIX = []
benjaminwagner6f6bef82015-10-15 08:09:44 -0700671
benjaminwagner56f6d062016-01-13 10:45:19 -0800672LINKOPTS_ANDROID = [
673 "-lEGL",
674]
benjaminwagner6f6bef82015-10-15 08:09:44 -0700675
benjaminwagner56f6d062016-01-13 10:45:19 -0800676LINKOPTS_IOS = []
benjaminwagner6f6bef82015-10-15 08:09:44 -0700677
benjaminwagner56f6d062016-01-13 10:45:19 -0800678LINKOPTS_ALL = [
679 "-ldl",
680]