blob: ea247a6e91a11f6834f2bc57050180f7efb195be [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/*",
86 "src/opts/**/*",
87 "src/ports/**/*",
Matt Sarettba832332017-06-06 14:36:18 -040088 "src/ports/SkImageEncoder_none.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -070089 "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",
Mike Klein330e93b2017-06-05 11:18:17 -0400120
121 # Only pre-compiled into SkJumper_generated.S.
122 "src/jumper/SkJumper_stages_lowp.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700123 ],
124)
125
126# Platform-dependent SRCS for google3-default platform.
benjaminwagner56f6d062016-01-13 10:45:19 -0800127BASE_SRCS_UNIX = struct(
128 include = [
irothd2ccc772016-01-25 11:24:57 -0800129 "src/android/*",
iroth76a12252016-01-07 07:11:39 -0800130 "src/codec/*",
iroth5f0de062016-02-17 12:47:27 -0800131 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700132 "src/opts/**/*.cpp",
133 "src/opts/**/*.h",
134 "src/ports/**/*.cpp",
135 "src/ports/**/*.h",
136 ],
137 exclude = [
Ben Wagnerdea74282017-03-16 19:15:09 -0400138 "src/opts/opts_check_x86.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700139 "src/opts/*arm*",
140 "src/opts/*mips*",
141 "src/opts/*NEON*",
142 "src/opts/*neon*",
Ben Wagnerdea74282017-03-16 19:15:09 -0400143 # Included in :opts_sse2 library.
144 "src/opts/*SSE2*",
145 "src/opts/*sse2*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700146 # Included in :opts_ssse3 library.
benjaminwagner6f6bef82015-10-15 08:09:44 -0700147 "src/opts/*SSSE3*",
148 "src/opts/*ssse3*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700149 # Included in :opts_sse4 library.
benjaminwagner6f6bef82015-10-15 08:09:44 -0700150 "src/opts/*SSE4*",
151 "src/opts/*sse4*",
Mike Klein71475052016-09-30 11:34:54 -0400152 # Included in :opts_avx or :opts_hsw
mtkleinf6d8d282015-12-17 10:18:04 -0800153 "src/opts/*avx*",
Mike Klein71475052016-09-30 11:34:54 -0400154 "src/opts/*hsw*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700155 "src/opts/SkBitmapProcState_opts_none.cpp",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700156 "src/opts/SkBlitMask_opts_none.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700157 "src/opts/SkBlitRow_opts_none.cpp",
msarett6b4985c2016-03-10 07:15:59 -0800158 "src/ports/*CG*",
msarettfc0b6d12016-03-17 13:50:17 -0700159 "src/ports/*WIC*",
mtklein3f193a92016-03-10 08:52:05 -0800160 "src/ports/*android*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700161 "src/ports/*chromium*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700162 "src/ports/*mac*",
163 "src/ports/*mozalloc*",
164 "src/ports/*nacl*",
165 "src/ports/*win*",
benjaminwagner2211a7b2015-12-01 11:12:05 -0800166 "src/ports/SkFontMgr_custom_directory_factory.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700167 "src/ports/SkFontMgr_custom_embedded_factory.cpp",
benjaminwagnerd9dd5812016-03-21 10:45:01 -0700168 "src/ports/SkFontMgr_custom_empty_factory.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700169 "src/ports/SkFontMgr_empty_factory.cpp",
benjaminwagner404816e2015-12-03 05:04:03 -0800170 "src/ports/SkFontMgr_fontconfig.cpp",
benjaminwagner2211a7b2015-12-01 11:12:05 -0800171 "src/ports/SkFontMgr_fontconfig_factory.cpp",
Mike Klein4b698cb2017-02-09 15:28:53 -0500172 "src/ports/SkGlobalInitialization_none.cpp",
Mike Klein5355d872017-06-06 15:42:47 -0400173 "src/ports/SkImageEncoder_none.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700174 "src/ports/SkImageGenerator_none.cpp",
175 "src/ports/SkTLS_none.cpp",
mtkleind55d13a2015-08-18 08:51:49 -0700176 ],
177)
178
benjaminwagner86ea33e2015-10-26 10:46:25 -0700179# Platform-dependent SRCS for google3-default Android.
benjaminwagner56f6d062016-01-13 10:45:19 -0800180BASE_SRCS_ANDROID = struct(
181 include = [
irothd2ccc772016-01-25 11:24:57 -0800182 "src/android/*",
iroth76a12252016-01-07 07:11:39 -0800183 "src/codec/*",
iroth5f0de062016-02-17 12:47:27 -0800184 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700185 # TODO(benjaminwagner): Figure out how to compile with EGL.
benjaminwagner86ea33e2015-10-26 10:46:25 -0700186 "src/opts/**/*.cpp",
187 "src/opts/**/*.h",
188 "src/ports/**/*.cpp",
189 "src/ports/**/*.h",
190 ],
191 exclude = [
192 "src/opts/*mips*",
193 "src/opts/*SSE2*",
194 "src/opts/*SSSE3*",
195 "src/opts/*ssse3*",
196 "src/opts/*SSE4*",
197 "src/opts/*sse4*",
mtkleinf6d8d282015-12-17 10:18:04 -0800198 "src/opts/*avx*",
Mike Kleinfb2c6332017-01-26 14:40:53 -0500199 "src/opts/*hsw*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700200 "src/opts/*x86*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700201 "src/opts/SkBlitMask_opts_none.cpp",
202 "src/opts/SkBlitRow_opts_none.cpp",
msarett6b4985c2016-03-10 07:15:59 -0800203 "src/ports/*CG*",
mtklein3f193a92016-03-10 08:52:05 -0800204 "src/ports/*FontConfig*",
msarettfc0b6d12016-03-17 13:50:17 -0700205 "src/ports/*WIC*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700206 "src/ports/*chromium*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700207 "src/ports/*fontconfig*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700208 "src/ports/*mac*",
209 "src/ports/*mozalloc*",
210 "src/ports/*nacl*",
211 "src/ports/*win*",
212 "src/ports/SkDebug_stdio.cpp",
213 "src/ports/SkFontMgr_custom_directory_factory.cpp",
214 "src/ports/SkFontMgr_custom_embedded_factory.cpp",
benjaminwagnerd9dd5812016-03-21 10:45:01 -0700215 "src/ports/SkFontMgr_custom_empty_factory.cpp",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700216 "src/ports/SkFontMgr_empty_factory.cpp",
Mike Klein4b698cb2017-02-09 15:28:53 -0500217 "src/ports/SkGlobalInitialization_none.cpp",
Mike Klein5355d872017-06-06 15:42:47 -0400218 "src/ports/SkImageEncoder_none.cpp",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700219 "src/ports/SkImageGenerator_none.cpp",
220 "src/ports/SkTLS_none.cpp",
221 ],
222)
223
iroth8b99ef42015-11-02 11:11:21 -0800224# Platform-dependent SRCS for google3-default iOS.
benjaminwagner56f6d062016-01-13 10:45:19 -0800225BASE_SRCS_IOS = struct(
226 include = [
msarett2775cf52016-02-17 14:14:25 -0800227 "src/android/*",
228 "src/codec/*",
iroth5f0de062016-02-17 12:47:27 -0800229 "src/gpu/gl/GrGLDefaultInterface_native.cpp",
230 "src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800231 "src/opts/**/*.cpp",
232 "src/opts/**/*.h",
233 "src/ports/**/*.cpp",
234 "src/ports/**/*.h",
irothab669de2016-02-16 19:17:01 -0800235 "src/utils/mac/*.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800236 ],
237 exclude = [
msarett2775cf52016-02-17 14:14:25 -0800238 "src/codec/*Ico*.cpp",
msarett2775cf52016-02-17 14:14:25 -0800239 "src/codec/*Webp*.cpp",
240 "src/codec/*Png*",
241 "src/codec/*Raw*.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800242 "src/opts/*mips*",
243 "src/opts/*NEON*",
244 "src/opts/*neon*",
245 "src/opts/*SSE2*",
246 "src/opts/*SSSE3*",
247 "src/opts/*ssse3*",
248 "src/opts/*SSE4*",
249 "src/opts/*sse4*",
mtkleinf6d8d282015-12-17 10:18:04 -0800250 "src/opts/*avx*",
Mike Kleinfb2c6332017-01-26 14:40:53 -0500251 "src/opts/*hsw*",
iroth8b99ef42015-11-02 11:11:21 -0800252 "src/opts/*x86*",
irothd2ccc772016-01-25 11:24:57 -0800253 "src/opts/SkBlitMask_opts_arm*.cpp",
254 "src/opts/SkBlitRow_opts_arm*.cpp",
mtklein3f193a92016-03-10 08:52:05 -0800255 "src/ports/*CG*",
256 "src/ports/*FontConfig*",
257 "src/ports/*FreeType*",
msarettfc0b6d12016-03-17 13:50:17 -0700258 "src/ports/*WIC*",
iroth8b99ef42015-11-02 11:11:21 -0800259 "src/ports/*android*",
260 "src/ports/*chromium*",
261 "src/ports/*fontconfig*",
iroth8b99ef42015-11-02 11:11:21 -0800262 "src/ports/*mozalloc*",
263 "src/ports/*nacl*",
264 "src/ports/*win*",
iroth8b99ef42015-11-02 11:11:21 -0800265 "src/ports/SkFontMgr_custom.cpp",
Ben Wagner8ab590f2017-02-08 17:29:33 -0500266 "src/ports/SkFontMgr_custom_directory.cpp",
267 "src/ports/SkFontMgr_custom_embedded.cpp",
268 "src/ports/SkFontMgr_custom_empty.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800269 "src/ports/SkFontMgr_custom_directory_factory.cpp",
270 "src/ports/SkFontMgr_custom_embedded_factory.cpp",
benjaminwagnerd9dd5812016-03-21 10:45:01 -0700271 "src/ports/SkFontMgr_custom_empty_factory.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800272 "src/ports/SkFontMgr_empty_factory.cpp",
Mike Klein4b698cb2017-02-09 15:28:53 -0500273 "src/ports/SkGlobalInitialization_none.cpp",
Mike Klein5355d872017-06-06 15:42:47 -0400274 "src/ports/SkImageEncoder_none.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800275 "src/ports/SkImageGenerator_none.cpp",
276 "src/ports/SkTLS_none.cpp",
277 ],
278)
279
benjaminwagner56f6d062016-01-13 10:45:19 -0800280################################################################################
Ben Wagnerdea74282017-03-16 19:15:09 -0400281## skia_{all,public}_hdrs()
benjaminwagner56f6d062016-01-13 10:45:19 -0800282################################################################################
Ben Wagnerdea74282017-03-16 19:15:09 -0400283def skia_all_hdrs():
284 return native.glob(["src/**/*.h", "include/**/*.h"])
benjaminwagner86ea33e2015-10-26 10:46:25 -0700285
Ben Wagnerdea74282017-03-16 19:15:09 -0400286def skia_public_hdrs():
287 return native.glob(["include/**/*.h"],
288 exclude=[
289 "include/private/**/*.h",
290 "include/views/**/*", # Not used.
291 ])
292
293################################################################################
294## skia_opts_srcs()
295################################################################################
296# Intel
297SKIA_OPTS_SSE2 = "SSE2"
298
299SKIA_OPTS_SSSE3 = "SSSE3"
300
301SKIA_OPTS_SSE4 = "SSE4"
302
303SKIA_OPTS_AVX = "AVX"
304
305SKIA_OPTS_HSW = "HSW"
306
307# Arm
308SKIA_OPTS_ARMV7 = "ARMV7"
309
310SKIA_OPTS_NEON = "NEON"
311
312SKIA_OPTS_ARM64 = "ARM64"
313
314SKIA_OPTS_CRC32 = "CRC32" # arm64
315
316# Other
317SKIA_OPTS_NONE = "NONE" # not x86, arm, or arm64
318
319def skia_opts_srcs(opts):
320 if opts == SKIA_OPTS_SSE2:
321 return native.glob([
322 "src/opts/*SSE2*.cpp",
323 "src/opts/*sse2*.cpp",
324 ])
325 elif opts == SKIA_OPTS_SSSE3:
326 return native.glob([
mtkleind55d13a2015-08-18 08:51:49 -0700327 "src/opts/*SSSE3*.cpp",
328 "src/opts/*ssse3*.cpp",
Ben Wagnerdea74282017-03-16 19:15:09 -0400329 ])
330 elif opts == SKIA_OPTS_SSE4:
331 return native.glob([
mtkleind55d13a2015-08-18 08:51:49 -0700332 "src/opts/*SSE4*.cpp",
333 "src/opts/*sse4*.cpp",
Ben Wagnerdea74282017-03-16 19:15:09 -0400334 ])
335 elif opts == SKIA_OPTS_AVX:
336 return native.glob([
mtkleinf6d8d282015-12-17 10:18:04 -0800337 "src/opts/*_avx.cpp",
Ben Wagnerdea74282017-03-16 19:15:09 -0400338 ])
339 elif opts == SKIA_OPTS_HSW:
340 return native.glob([
Mike Klein78d5a3b2016-09-30 10:48:01 -0400341 "src/opts/*_hsw.cpp",
Ben Wagnerdea74282017-03-16 19:15:09 -0400342 ])
343 elif opts == SKIA_OPTS_ARMV7:
344 return native.glob([
345 "src/opts/*_arm.cpp",
346 ])
347 elif opts == SKIA_OPTS_NEON:
348 return native.glob([
349 "src/opts/*_neon.cpp",
350 ])
351 elif opts == SKIA_OPTS_CRC32:
352 return native.glob([
353 "src/opts/*_crc32.cpp",
354 ])
355 elif opts == SKIA_OPTS_NONE:
356 return native.glob([
357 "src/opts/*_none.cpp",
358 ])
359 else:
360 fail("skia_opts_srcs parameter 'opts' must be one of SKIA_OPTS_*.")
361
362def skia_opts_cflags(opts):
363 if opts == SKIA_OPTS_SSE2:
364 return ["-msse2"]
365 elif opts == SKIA_OPTS_SSSE3:
366 return ["-mssse3"]
367 elif opts == SKIA_OPTS_SSE4:
368 return ["-msse4"]
369 elif opts == SKIA_OPTS_AVX:
370 return ["-mavx"]
371 elif opts == SKIA_OPTS_HSW:
372 return ["-mavx2", "-mbmi", "-mbmi2", "-mf16c", "-mfma"]
373 elif opts == SKIA_OPTS_CRC32:
374 return ["-march=armv8-a+crc"]
375 else:
376 return []
Mike Klein78d5a3b2016-09-30 10:48:01 -0400377
benjaminwagner56f6d062016-01-13 10:45:19 -0800378################################################################################
Ben Wagnerdea74282017-03-16 19:15:09 -0400379## skia_srcs()
benjaminwagner56f6d062016-01-13 10:45:19 -0800380################################################################################
Ben Wagnerdea74282017-03-16 19:15:09 -0400381SKIA_OS_UNIX = "UNIX"
benjaminwagner56f6d062016-01-13 10:45:19 -0800382
Ben Wagnerdea74282017-03-16 19:15:09 -0400383SKIA_OS_ANDROID = "ANDROID"
benjaminwagner787ca872015-08-17 12:58:10 -0700384
Ben Wagnerdea74282017-03-16 19:15:09 -0400385SKIA_OS_IOS = "IOS"
benjaminwagner56f6d062016-01-13 10:45:19 -0800386
Ben Wagnerdea74282017-03-16 19:15:09 -0400387SKIA_CPU_UNSPECIFIED = "UNSPECIFIED"
benjaminwagner56f6d062016-01-13 10:45:19 -0800388
Neal Norwitzca9fb3b2017-06-06 10:01:43 -0700389SKIA_CPU_ARM = "ARM"
390
Ben Wagnerdea74282017-03-16 19:15:09 -0400391SKIA_CPU_PPC = "PPC"
benjaminwagner39e7aa42015-11-18 13:26:10 -0800392
Ben Wagnerdea74282017-03-16 19:15:09 -0400393def skia_srcs(os=SKIA_OS_UNIX, cpu=SKIA_CPU_UNSPECIFIED):
394 """Sources to be compiled into the skia library."""
395 srcs = skia_glob(BASE_SRCS_ALL)
396 if os == SKIA_OS_IOS:
397 if cpu != SKIA_CPU_UNSPECIFIED:
398 fail("Do not specify IOS and a cpu.")
399 srcs = srcs + skia_glob(BASE_SRCS_IOS)
400 elif os == SKIA_OS_ANDROID:
401 if cpu != SKIA_CPU_UNSPECIFIED:
402 fail("Do not specify ANDROID and a cpu.")
403 srcs = srcs + skia_glob(BASE_SRCS_ANDROID)
404 elif os == SKIA_OS_UNIX:
405 if cpu == SKIA_CPU_UNSPECIFIED:
406 srcs = srcs + ["src/opts/opts_check_x86.cpp"] + skia_glob(BASE_SRCS_UNIX)
Neal Norwitzca9fb3b2017-06-06 10:01:43 -0700407 elif cpu == SKIA_CPU_PPC or cpu == SKIA_CPU_ARM:
Ben Wagnerdea74282017-03-16 19:15:09 -0400408 srcs = srcs + skia_glob(BASE_SRCS_UNIX)
409 else:
410 fail("cpu must be one of SKIA_CPU_*")
411 else:
412 fail("skia_srcs parameter 'os' must be one of SKIA_OS_{UNIX,ANDROID,IOS}.")
413 return srcs
benjaminwagner39e7aa42015-11-18 13:26:10 -0800414
benjaminwagner56f6d062016-01-13 10:45:19 -0800415################################################################################
416## INCLUDES
417################################################################################
benjaminwagner39e7aa42015-11-18 13:26:10 -0800418
benjaminwagner787ca872015-08-17 12:58:10 -0700419# Includes needed by Skia implementation. Not public includes.
420INCLUDES = [
benjaminwagnerfa7e1a02015-11-13 12:27:08 -0800421 "include/android",
benjaminwagner787ca872015-08-17 12:58:10 -0700422 "include/c",
robertphillips188d44c2016-02-01 04:54:14 -0800423 "include/client/android",
benjaminwagner787ca872015-08-17 12:58:10 -0700424 "include/codec",
425 "include/config",
426 "include/core",
benjaminwagner787ca872015-08-17 12:58:10 -0700427 "include/effects",
Matt Sarettd7093c22017-05-09 15:28:32 -0400428 "include/encode",
benjaminwagner787ca872015-08-17 12:58:10 -0700429 "include/gpu",
430 "include/images",
431 "include/pathops",
benjaminwagner787ca872015-08-17 12:58:10 -0700432 "include/pipe",
433 "include/ports",
434 "include/private",
435 "include/utils",
iroth8b99ef42015-11-02 11:11:21 -0800436 "include/utils/mac",
437 "include/utils/win",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700438 "include/svg",
benjaminwagner787ca872015-08-17 12:58:10 -0700439 "include/xml",
benjaminwagnerfa7e1a02015-11-13 12:27:08 -0800440 "src/codec",
benjaminwagner787ca872015-08-17 12:58:10 -0700441 "src/core",
benjaminwagner787ca872015-08-17 12:58:10 -0700442 "src/gpu",
443 "src/image",
444 "src/lazy",
445 "src/opts",
benjaminwagner2211a7b2015-12-01 11:12:05 -0800446 "src/ports",
benjaminwagner787ca872015-08-17 12:58:10 -0700447 "src/pdf",
benjaminwagner787ca872015-08-17 12:58:10 -0700448 "src/sfnt",
Florin Malita5edba452017-05-30 16:39:47 -0400449 "src/shaders",
benjaminwagnerc8962512016-09-30 12:06:27 -0700450 "src/sksl",
benjaminwagner787ca872015-08-17 12:58:10 -0700451 "src/utils",
452 "third_party/etc1",
Ben Wagnerd0a3b062016-10-24 14:11:12 -0400453 "third_party/gif",
benjaminwagner56f6d062016-01-13 10:45:19 -0800454]
benjaminwagner787ca872015-08-17 12:58:10 -0700455
benjaminwagner56f6d062016-01-13 10:45:19 -0800456################################################################################
457## DM_SRCS
458################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700459
benjaminwagner56f6d062016-01-13 10:45:19 -0800460DM_SRCS_ALL = struct(
461 include = [
benjaminwagner6f6bef82015-10-15 08:09:44 -0700462 "dm/*.cpp",
463 "dm/*.h",
464 "gm/*.c",
465 "gm/*.cpp",
466 "gm/*.h",
467 "tests/*.cpp",
468 "tests/*.h",
benjaminwagner99fb6702016-07-28 15:12:21 -0700469 "tools/BigPathBench.inc",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700470 "tools/CrashHandler.cpp",
471 "tools/CrashHandler.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700472 "tools/ProcStats.cpp",
473 "tools/ProcStats.h",
474 "tools/Resources.cpp",
475 "tools/Resources.h",
benjaminwagner99fb6702016-07-28 15:12:21 -0700476 "tools/SkJSONCPP.h",
477 "tools/UrlDataManager.cpp",
478 "tools/UrlDataManager.h",
479 "tools/debugger/*.cpp",
480 "tools/debugger/*.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700481 "tools/flags/*.cpp",
482 "tools/flags/*.h",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700483 "tools/gpu/**/*.cpp",
484 "tools/gpu/**/*.h",
brianosman6d3119c2016-04-19 19:41:54 -0700485 "tools/picture_utils.cpp",
benjaminwagner99fb6702016-07-28 15:12:21 -0700486 "tools/picture_utils.h",
mtkleine1fc4522016-02-09 12:32:52 -0800487 "tools/random_parse_path.cpp",
488 "tools/random_parse_path.h",
benjaminwagner32885142015-10-24 07:55:31 -0700489 "tools/sk_tool_utils.cpp",
490 "tools/sk_tool_utils.h",
benjaminwagner99fb6702016-07-28 15:12:21 -0700491 "tools/sk_tool_utils_flags.h",
benjaminwagner32885142015-10-24 07:55:31 -0700492 "tools/sk_tool_utils_font.cpp",
benjaminwagner99fb6702016-07-28 15:12:21 -0700493 "tools/test_font_monospace.inc",
494 "tools/test_font_sans_serif.inc",
495 "tools/test_font_serif.inc",
496 "tools/test_font_index.inc",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700497 "tools/timer/*.cpp",
498 "tools/timer/*.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700499 ],
500 exclude = [
benjaminwagner86ea33e2015-10-26 10:46:25 -0700501 "tests/FontMgrAndroidParserTest.cpp", # Android-only.
benjaminwagner6f6bef82015-10-15 08:09:44 -0700502 "tests/skia_test.cpp", # Old main.
503 "tests/SkpSkGrTest.cpp", # Alternate main.
benjaminwagner921e48b2016-07-15 11:27:27 -0700504 "tests/SVGDeviceTest.cpp",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700505 "tools/gpu/gl/angle/*",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700506 "tools/gpu/gl/egl/*",
507 "tools/gpu/gl/glx/*",
508 "tools/gpu/gl/iOS/*",
509 "tools/gpu/gl/mac/*",
510 "tools/gpu/gl/mesa/*",
511 "tools/gpu/gl/win/*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700512 "tools/timer/SysTimer_mach.cpp",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700513 "tools/timer/SysTimer_windows.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700514 ],
515)
516
Ben Wagnerdea74282017-03-16 19:15:09 -0400517################################################################################
518## dm_srcs()
519################################################################################
520# SKIA_OS_* definitions can be found above.
benjaminwagner86ea33e2015-10-26 10:46:25 -0700521
Ben Wagnerdea74282017-03-16 19:15:09 -0400522def dm_srcs(os):
523 """Sources for the dm binary for the specified os."""
524 srcs = skia_glob(DM_SRCS_ALL)
525 # TODO(benjaminwagner): None of the CreatePlatformGLContext_*.cpp files exist.
526 # TODO(jwg): Remove the globs if possible, they only select single files.
527 if os == SKIA_OS_IOS:
528 srcs = srcs + native.glob(["tools/gpu/iOS/CreatePlatformGLContext_iOS.cpp"])
529 elif os == SKIA_OS_ANDROID:
530 srcs = srcs + native.glob([
benjaminwagner86ea33e2015-10-26 10:46:25 -0700531 "tests/FontMgrAndroidParserTest.cpp",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700532 # TODO(benjaminwagner): Figure out how to compile with EGL.
533 "tools/gpu/gl/CreatePlatformGLContext_none.cpp",
Ben Wagnerdea74282017-03-16 19:15:09 -0400534 ])
535 elif os == SKIA_OS_UNIX:
536 srcs = srcs + native.glob(["tools/gpu/gl/CreatePlatformGLContext_none.cpp"])
537 else:
538 fail("dm_srcs parameter 'os' must be one of SKIA_OS_{UNIX,ANDROID,IOS}.")
539 return srcs
benjaminwagner56f6d062016-01-13 10:45:19 -0800540
541################################################################################
542## DM_INCLUDES
543################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700544
benjaminwagner6f6bef82015-10-15 08:09:44 -0700545DM_INCLUDES = [
benjaminwagnerb1fe8f62016-02-01 09:05:08 -0800546 "dm",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700547 "gm",
Mike Reed7f302c42017-02-18 14:12:08 -0500548 "experimental/svg/model",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700549 "src/codec",
Mike Reedaab8ce42017-02-18 12:57:09 -0500550 "src/core",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700551 "src/effects",
552 "src/fonts",
Hal Canarydb683012016-11-23 08:55:18 -0700553 "src/images",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700554 "src/pathops",
555 "src/pipe/utils",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700556 "src/ports",
Florin Malita5edba452017-05-30 16:39:47 -0400557 "src/shaders",
558 "src/shaders/gradients",
Mike Reedf71828f2017-02-18 09:51:33 -0500559 "src/xml",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700560 "tests",
561 "tools",
benjaminwagner99fb6702016-07-28 15:12:21 -0700562 "tools/debugger",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700563 "tools/flags",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700564 "tools/gpu",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700565 "tools/timer",
566]
567
benjaminwagner56f6d062016-01-13 10:45:19 -0800568################################################################################
569## DM_ARGS
570################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700571
Ben Wagner59f9edb2016-11-28 15:30:37 -0500572def DM_ARGS(asan):
benjaminwagner83906ae2016-05-01 15:02:25 -0700573 source = ["tests", "gm", "image"]
574 # TODO(benjaminwagner): f16 and serialize-8888 fail.
575 config = ["565", "8888", "pdf", "srgb", "tiles_rt", "pic"]
576 # TODO(mtklein): maybe investigate why these fail?
577 match = [
578 "~Canvas",
579 "~Codec",
580 "~Codec_Dimensions",
581 "~Codec_stripes",
582 "~FontMgr",
583 "~PaintBreakText",
584 "~RecordDraw_TextBounds",
585 "~Scalar",
586 "~skps",
587 "~Stream",
588 ]
589 if asan:
Ben Wagner59f9edb2016-11-28 15:30:37 -0500590 # The ASAN we use with Bazel has some strict checks, so omit tests that
591 # trigger them.
benjaminwagner83906ae2016-05-01 15:02:25 -0700592 match += [
Ben Wagneraf6522a2017-05-08 11:40:29 -0400593 "~bigrect",
benjaminwagner83906ae2016-05-01 15:02:25 -0700594 "~clippedcubic2",
595 "~conicpaths",
Ben Wagner59f9edb2016-11-28 15:30:37 -0500596 "~^gradients",
benjaminwagner83906ae2016-05-01 15:02:25 -0700597 "~Math",
598 "~Matrix",
Ben Wagner55b72532017-01-29 21:50:51 -0500599 "~PathBigCubic",
benjaminwagner83906ae2016-05-01 15:02:25 -0700600 "~PathOpsCubic",
benjaminwagnerb5188622016-06-29 10:26:44 -0700601 "~PathOpsFailOp",
caryclark523e76d2016-07-19 12:27:32 -0700602 "~PathOpsOpCubicsThreaded",
benjaminwagner83906ae2016-05-01 15:02:25 -0700603 "~PathOpsOpLoopsThreaded",
604 "~PathOpsSimplify",
605 "~PathOpsTightBoundsQuads",
606 "~Point",
benjaminwagner1d352312016-07-25 06:32:13 -0700607 "~sk_linear_to_srgb",
Ben Wagner59f9edb2016-11-28 15:30:37 -0500608 "~small_color_stop",
benjaminwagner56f6d062016-01-13 10:45:19 -0800609 ]
Ben Wagner59f9edb2016-11-28 15:30:37 -0500610 return ["--src"] + source + ["--config"] + config + ["--match"] + match
benjaminwagner56f6d062016-01-13 10:45:19 -0800611
612################################################################################
613## COPTS
614################################################################################
iroth8b99ef42015-11-02 11:11:21 -0800615
benjaminwagner86ea33e2015-10-26 10:46:25 -0700616COPTS_UNIX = [
benjaminwagner787ca872015-08-17 12:58:10 -0700617 "-Wno-implicit-fallthrough", # Some intentional fallthrough.
benjaminwagner7d974f52015-10-19 13:55:55 -0700618 "-Wno-deprecated-declarations", # Internal use of deprecated methods. :(
benjaminwagner787ca872015-08-17 12:58:10 -0700619]
620
Mike Klein452f9202017-05-05 09:16:00 -0400621COPTS_ANDROID = [
622 "-mfpu=neon",
623 "-Wno-error=attributes", # 'GrResourceCache' declared with greater visibility than the
624 # type of its field 'GrResourceCache::fPurgeableQueue'... bogus.
625]
benjaminwagner56f6d062016-01-13 10:45:19 -0800626
627COPTS_IOS = []
628
629COPTS_ALL = []
630
631################################################################################
632## DEFINES
633################################################################################
634
635DEFINES_UNIX = [
scroggo7732c0c2016-06-22 07:25:16 -0700636 "PNG_SKIP_SETJMP_CHECK",
benjaminwagner56f6d062016-01-13 10:45:19 -0800637 "SK_BUILD_FOR_UNIX",
638 "SK_SAMPLES_FOR_X",
halcanary650e20d2016-08-25 09:07:02 -0700639 "SK_PDF_USE_SFNTLY",
benjaminwagner186e0b92016-02-11 16:00:24 -0800640 "SK_CODEC_DECODES_RAW",
msarettad3a5c62016-05-06 07:21:26 -0700641 "SK_HAS_JPEG_LIBRARY",
scroggoe6939c12016-06-21 14:13:40 -0700642 "SK_HAS_PNG_LIBRARY",
scroggo7732c0c2016-06-22 07:25:16 -0700643 "SK_HAS_WEBP_LIBRARY",
benjaminwagner56f6d062016-01-13 10:45:19 -0800644]
benjaminwagner86ea33e2015-10-26 10:46:25 -0700645
646DEFINES_ANDROID = [
647 "SK_BUILD_FOR_ANDROID",
benjaminwagner186e0b92016-02-11 16:00:24 -0800648 "SK_CODEC_DECODES_RAW",
msarettad3a5c62016-05-06 07:21:26 -0700649 "SK_HAS_JPEG_LIBRARY",
scroggoe6939c12016-06-21 14:13:40 -0700650 "SK_HAS_PNG_LIBRARY",
scroggo7732c0c2016-06-22 07:25:16 -0700651 "SK_HAS_WEBP_LIBRARY",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700652]
653
iroth8b99ef42015-11-02 11:11:21 -0800654DEFINES_IOS = [
655 "SK_BUILD_FOR_IOS",
sdefresnee3fa8112016-06-01 07:08:56 -0700656 "SK_BUILD_NO_OPTS",
Matt Sarett2d4fc272017-02-10 09:42:54 -0500657 "SK_HAS_JPEG_LIBRARY",
irothd2ccc772016-01-25 11:24:57 -0800658 "SKNX_NO_SIMD",
iroth8b99ef42015-11-02 11:11:21 -0800659]
660
benjaminwagner86ea33e2015-10-26 10:46:25 -0700661DEFINES_ALL = [
benjaminwagner787ca872015-08-17 12:58:10 -0700662 # Chrome DEFINES.
663 "SK_USE_FLOATBITS",
664 "SK_USE_FREETYPE_EMBOLDEN",
665 # Turn on a few Google3-specific build fixes.
666 "GOOGLE3",
reedd053ce92016-03-22 10:17:23 -0700667 # Staging flags for API changes
Matt Sarett09e9f682017-05-19 12:57:03 -0400668 # Should remove after we update golden images
669 "SK_WEBP_ENCODER_USE_DEFAULT_METHOD",
Yuqian Li8622b722016-11-14 15:42:58 -0500670 # Temporarily Disable analytic AA for Google3
671 "SK_NO_ANALYTIC_AA",
Mike Reed7c14d272017-06-08 14:16:03 -0400672 # Experiment to diagnose image diffs in Google3
673 "SK_DISABLE_SSSE3_RUNTIME_CHECK_FOR_LOWP_STAGES",
benjaminwagner787ca872015-08-17 12:58:10 -0700674]
675
benjaminwagner56f6d062016-01-13 10:45:19 -0800676################################################################################
677## LINKOPTS
678################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700679
benjaminwagner56f6d062016-01-13 10:45:19 -0800680LINKOPTS_UNIX = []
benjaminwagner6f6bef82015-10-15 08:09:44 -0700681
benjaminwagner56f6d062016-01-13 10:45:19 -0800682LINKOPTS_ANDROID = [
683 "-lEGL",
684]
benjaminwagner6f6bef82015-10-15 08:09:44 -0700685
benjaminwagner56f6d062016-01-13 10:45:19 -0800686LINKOPTS_IOS = []
benjaminwagner6f6bef82015-10-15 08:09:44 -0700687
benjaminwagner56f6d062016-01-13 10:45:19 -0800688LINKOPTS_ALL = [
689 "-ldl",
690]