blob: 80042730c97ca3b4e69e6ed0e37725504f87f05d [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/**/*",
88 "src/utils/android/**/*",
89 "src/utils/mac/**/*",
benjaminwagner6f6bef82015-10-15 08:09:44 -070090 "src/utils/SkThreadUtils_win.cpp", # Windows-only. Move to ports?
91 "src/utils/win/**/*",
92 "src/views/sdl/*",
93 "src/views/win/*",
94 "src/views/unix/*",
95
96 # Exclude multiple definitions.
97 # TODO(mtklein): Move to opts?
benjaminwagnerca26a182016-03-14 15:21:12 -070098 "src/pdf/SkDocument_PDF_None.cpp", # We use src/pdf/SkPDFDocument.cpp.
benjaminwagner86ea33e2015-10-26 10:46:25 -070099 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
100 "src/gpu/gl/GrGLDefaultInterface_native.cpp",
iroth5f0de062016-02-17 12:47:27 -0800101 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700102
103 # Exclude files that don't compile with the current DEFINES.
benjaminwagner6f6bef82015-10-15 08:09:44 -0700104 "src/gpu/gl/mesa/*", # Requires SK_MESA define.
benjaminwagner921e48b2016-07-15 11:27:27 -0700105 "src/svg/**/*", # Depends on XML.
106 "src/xml/**/*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700107
benjaminwagner39e7aa42015-11-18 13:26:10 -0800108 # Conflicting dependencies among Lua versions. See cl/107087297.
109 "src/utils/SkLua*",
110
benjaminwagner6f6bef82015-10-15 08:09:44 -0700111 # Not used.
benjaminwagner6f6bef82015-10-15 08:09:44 -0700112 "src/views/**/*",
egdaniel32119f12016-02-22 10:07:54 -0800113
114 # Currently exclude all vulkan specific files
115 "src/gpu/vk/*",
benjaminwagnerc8962512016-09-30 12:06:27 -0700116
117 # Defines main.
118 "src/sksl/SkSLMain.cpp",
Mike Klein330e93b2017-06-05 11:18:17 -0400119
120 # Only pre-compiled into SkJumper_generated.S.
Mike Kleinfba26ea2017-08-03 00:37:28 -0400121 "src/jumper/SkJumper_stages_8bit.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700122 ],
123)
124
125# Platform-dependent SRCS for google3-default platform.
benjaminwagner56f6d062016-01-13 10:45:19 -0800126BASE_SRCS_UNIX = struct(
127 include = [
irothd2ccc772016-01-25 11:24:57 -0800128 "src/android/*",
iroth76a12252016-01-07 07:11:39 -0800129 "src/codec/*",
iroth5f0de062016-02-17 12:47:27 -0800130 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700131 "src/opts/**/*.cpp",
132 "src/opts/**/*.h",
133 "src/ports/**/*.cpp",
134 "src/ports/**/*.h",
135 ],
136 exclude = [
Ben Wagnerdea74282017-03-16 19:15:09 -0400137 "src/opts/opts_check_x86.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700138 "src/opts/*arm*",
139 "src/opts/*mips*",
140 "src/opts/*NEON*",
141 "src/opts/*neon*",
Ben Wagnerdea74282017-03-16 19:15:09 -0400142 # Included in :opts_sse2 library.
143 "src/opts/*SSE2*",
144 "src/opts/*sse2*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700145 # Included in :opts_ssse3 library.
benjaminwagner6f6bef82015-10-15 08:09:44 -0700146 "src/opts/*SSSE3*",
147 "src/opts/*ssse3*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700148 # Included in :opts_sse4 library.
benjaminwagner6f6bef82015-10-15 08:09:44 -0700149 "src/opts/*SSE4*",
150 "src/opts/*sse4*",
Mike Klein71475052016-09-30 11:34:54 -0400151 # Included in :opts_avx or :opts_hsw
mtkleinf6d8d282015-12-17 10:18:04 -0800152 "src/opts/*avx*",
Mike Klein71475052016-09-30 11:34:54 -0400153 "src/opts/*hsw*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700154 "src/opts/SkBitmapProcState_opts_none.cpp",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700155 "src/opts/SkBlitMask_opts_none.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700156 "src/opts/SkBlitRow_opts_none.cpp",
msarett6b4985c2016-03-10 07:15:59 -0800157 "src/ports/*CG*",
msarettfc0b6d12016-03-17 13:50:17 -0700158 "src/ports/*WIC*",
mtklein3f193a92016-03-10 08:52:05 -0800159 "src/ports/*android*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700160 "src/ports/*chromium*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700161 "src/ports/*mac*",
162 "src/ports/*mozalloc*",
163 "src/ports/*nacl*",
164 "src/ports/*win*",
benjaminwagner2211a7b2015-12-01 11:12:05 -0800165 "src/ports/SkFontMgr_custom_directory_factory.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700166 "src/ports/SkFontMgr_custom_embedded_factory.cpp",
benjaminwagnerd9dd5812016-03-21 10:45:01 -0700167 "src/ports/SkFontMgr_custom_empty_factory.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700168 "src/ports/SkFontMgr_empty_factory.cpp",
benjaminwagner404816e2015-12-03 05:04:03 -0800169 "src/ports/SkFontMgr_fontconfig.cpp",
benjaminwagner2211a7b2015-12-01 11:12:05 -0800170 "src/ports/SkFontMgr_fontconfig_factory.cpp",
Mike Klein4b698cb2017-02-09 15:28:53 -0500171 "src/ports/SkGlobalInitialization_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",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700183 # TODO(benjaminwagner): Figure out how to compile with EGL.
benjaminwagner86ea33e2015-10-26 10:46:25 -0700184 "src/opts/**/*.cpp",
185 "src/opts/**/*.h",
186 "src/ports/**/*.cpp",
187 "src/ports/**/*.h",
188 ],
189 exclude = [
190 "src/opts/*mips*",
191 "src/opts/*SSE2*",
192 "src/opts/*SSSE3*",
193 "src/opts/*ssse3*",
194 "src/opts/*SSE4*",
195 "src/opts/*sse4*",
mtkleinf6d8d282015-12-17 10:18:04 -0800196 "src/opts/*avx*",
Mike Kleinfb2c6332017-01-26 14:40:53 -0500197 "src/opts/*hsw*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700198 "src/opts/*x86*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700199 "src/opts/SkBlitMask_opts_none.cpp",
200 "src/opts/SkBlitRow_opts_none.cpp",
msarett6b4985c2016-03-10 07:15:59 -0800201 "src/ports/*CG*",
mtklein3f193a92016-03-10 08:52:05 -0800202 "src/ports/*FontConfig*",
msarettfc0b6d12016-03-17 13:50:17 -0700203 "src/ports/*WIC*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700204 "src/ports/*chromium*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700205 "src/ports/*fontconfig*",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700206 "src/ports/*mac*",
207 "src/ports/*mozalloc*",
208 "src/ports/*nacl*",
209 "src/ports/*win*",
210 "src/ports/SkDebug_stdio.cpp",
211 "src/ports/SkFontMgr_custom_directory_factory.cpp",
212 "src/ports/SkFontMgr_custom_embedded_factory.cpp",
benjaminwagnerd9dd5812016-03-21 10:45:01 -0700213 "src/ports/SkFontMgr_custom_empty_factory.cpp",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700214 "src/ports/SkFontMgr_empty_factory.cpp",
Mike Klein4b698cb2017-02-09 15:28:53 -0500215 "src/ports/SkGlobalInitialization_none.cpp",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700216 "src/ports/SkImageGenerator_none.cpp",
217 "src/ports/SkTLS_none.cpp",
218 ],
219)
220
iroth8b99ef42015-11-02 11:11:21 -0800221# Platform-dependent SRCS for google3-default iOS.
benjaminwagner56f6d062016-01-13 10:45:19 -0800222BASE_SRCS_IOS = struct(
223 include = [
msarett2775cf52016-02-17 14:14:25 -0800224 "src/android/*",
225 "src/codec/*",
iroth5f0de062016-02-17 12:47:27 -0800226 "src/gpu/gl/GrGLDefaultInterface_native.cpp",
227 "src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800228 "src/opts/**/*.cpp",
229 "src/opts/**/*.h",
230 "src/ports/**/*.cpp",
231 "src/ports/**/*.h",
irothab669de2016-02-16 19:17:01 -0800232 "src/utils/mac/*.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800233 ],
234 exclude = [
msarett2775cf52016-02-17 14:14:25 -0800235 "src/codec/*Ico*.cpp",
msarett2775cf52016-02-17 14:14:25 -0800236 "src/codec/*Webp*.cpp",
237 "src/codec/*Png*",
238 "src/codec/*Raw*.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800239 "src/opts/*mips*",
240 "src/opts/*NEON*",
241 "src/opts/*neon*",
242 "src/opts/*SSE2*",
243 "src/opts/*SSSE3*",
244 "src/opts/*ssse3*",
245 "src/opts/*SSE4*",
246 "src/opts/*sse4*",
mtkleinf6d8d282015-12-17 10:18:04 -0800247 "src/opts/*avx*",
Mike Kleinfb2c6332017-01-26 14:40:53 -0500248 "src/opts/*hsw*",
iroth8b99ef42015-11-02 11:11:21 -0800249 "src/opts/*x86*",
irothd2ccc772016-01-25 11:24:57 -0800250 "src/opts/SkBlitMask_opts_arm*.cpp",
251 "src/opts/SkBlitRow_opts_arm*.cpp",
mtklein3f193a92016-03-10 08:52:05 -0800252 "src/ports/*FontConfig*",
253 "src/ports/*FreeType*",
msarettfc0b6d12016-03-17 13:50:17 -0700254 "src/ports/*WIC*",
iroth8b99ef42015-11-02 11:11:21 -0800255 "src/ports/*android*",
256 "src/ports/*chromium*",
257 "src/ports/*fontconfig*",
iroth8b99ef42015-11-02 11:11:21 -0800258 "src/ports/*mozalloc*",
259 "src/ports/*nacl*",
260 "src/ports/*win*",
iroth8b99ef42015-11-02 11:11:21 -0800261 "src/ports/SkFontMgr_custom.cpp",
Ben Wagner8ab590f2017-02-08 17:29:33 -0500262 "src/ports/SkFontMgr_custom_directory.cpp",
263 "src/ports/SkFontMgr_custom_embedded.cpp",
264 "src/ports/SkFontMgr_custom_empty.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800265 "src/ports/SkFontMgr_custom_directory_factory.cpp",
266 "src/ports/SkFontMgr_custom_embedded_factory.cpp",
benjaminwagnerd9dd5812016-03-21 10:45:01 -0700267 "src/ports/SkFontMgr_custom_empty_factory.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800268 "src/ports/SkFontMgr_empty_factory.cpp",
Mike Klein4b698cb2017-02-09 15:28:53 -0500269 "src/ports/SkGlobalInitialization_none.cpp",
iroth8b99ef42015-11-02 11:11:21 -0800270 "src/ports/SkImageGenerator_none.cpp",
271 "src/ports/SkTLS_none.cpp",
272 ],
273)
274
benjaminwagner56f6d062016-01-13 10:45:19 -0800275################################################################################
Ben Wagnerdea74282017-03-16 19:15:09 -0400276## skia_{all,public}_hdrs()
benjaminwagner56f6d062016-01-13 10:45:19 -0800277################################################################################
Ben Wagnerdea74282017-03-16 19:15:09 -0400278def skia_all_hdrs():
279 return native.glob(["src/**/*.h", "include/**/*.h"])
benjaminwagner86ea33e2015-10-26 10:46:25 -0700280
Ben Wagnerdea74282017-03-16 19:15:09 -0400281def skia_public_hdrs():
282 return native.glob(["include/**/*.h"],
283 exclude=[
284 "include/private/**/*.h",
285 "include/views/**/*", # Not used.
286 ])
287
288################################################################################
289## skia_opts_srcs()
290################################################################################
291# Intel
292SKIA_OPTS_SSE2 = "SSE2"
293
294SKIA_OPTS_SSSE3 = "SSSE3"
295
296SKIA_OPTS_SSE4 = "SSE4"
297
298SKIA_OPTS_AVX = "AVX"
299
300SKIA_OPTS_HSW = "HSW"
301
302# Arm
303SKIA_OPTS_ARMV7 = "ARMV7"
304
305SKIA_OPTS_NEON = "NEON"
306
307SKIA_OPTS_ARM64 = "ARM64"
308
309SKIA_OPTS_CRC32 = "CRC32" # arm64
310
311# Other
312SKIA_OPTS_NONE = "NONE" # not x86, arm, or arm64
313
314def skia_opts_srcs(opts):
315 if opts == SKIA_OPTS_SSE2:
316 return native.glob([
317 "src/opts/*SSE2*.cpp",
318 "src/opts/*sse2*.cpp",
319 ])
320 elif opts == SKIA_OPTS_SSSE3:
321 return native.glob([
mtkleind55d13a2015-08-18 08:51:49 -0700322 "src/opts/*SSSE3*.cpp",
323 "src/opts/*ssse3*.cpp",
Ben Wagnerdea74282017-03-16 19:15:09 -0400324 ])
325 elif opts == SKIA_OPTS_SSE4:
326 return native.glob([
mtkleind55d13a2015-08-18 08:51:49 -0700327 "src/opts/*SSE4*.cpp",
328 "src/opts/*sse4*.cpp",
Ben Wagnerdea74282017-03-16 19:15:09 -0400329 ])
330 elif opts == SKIA_OPTS_AVX:
331 return native.glob([
mtkleinf6d8d282015-12-17 10:18:04 -0800332 "src/opts/*_avx.cpp",
Ben Wagnerdea74282017-03-16 19:15:09 -0400333 ])
334 elif opts == SKIA_OPTS_HSW:
335 return native.glob([
Mike Klein78d5a3b2016-09-30 10:48:01 -0400336 "src/opts/*_hsw.cpp",
Ben Wagnerdea74282017-03-16 19:15:09 -0400337 ])
338 elif opts == SKIA_OPTS_ARMV7:
339 return native.glob([
340 "src/opts/*_arm.cpp",
341 ])
342 elif opts == SKIA_OPTS_NEON:
343 return native.glob([
344 "src/opts/*_neon.cpp",
345 ])
346 elif opts == SKIA_OPTS_CRC32:
347 return native.glob([
348 "src/opts/*_crc32.cpp",
349 ])
350 elif opts == SKIA_OPTS_NONE:
351 return native.glob([
352 "src/opts/*_none.cpp",
353 ])
354 else:
355 fail("skia_opts_srcs parameter 'opts' must be one of SKIA_OPTS_*.")
356
357def skia_opts_cflags(opts):
358 if opts == SKIA_OPTS_SSE2:
359 return ["-msse2"]
360 elif opts == SKIA_OPTS_SSSE3:
361 return ["-mssse3"]
362 elif opts == SKIA_OPTS_SSE4:
363 return ["-msse4"]
364 elif opts == SKIA_OPTS_AVX:
365 return ["-mavx"]
366 elif opts == SKIA_OPTS_HSW:
367 return ["-mavx2", "-mbmi", "-mbmi2", "-mf16c", "-mfma"]
368 elif opts == SKIA_OPTS_CRC32:
369 return ["-march=armv8-a+crc"]
370 else:
371 return []
Mike Klein78d5a3b2016-09-30 10:48:01 -0400372
benjaminwagner56f6d062016-01-13 10:45:19 -0800373################################################################################
Ben Wagnerdea74282017-03-16 19:15:09 -0400374## skia_srcs()
benjaminwagner56f6d062016-01-13 10:45:19 -0800375################################################################################
Ben Wagnerdea74282017-03-16 19:15:09 -0400376SKIA_OS_UNIX = "UNIX"
benjaminwagner56f6d062016-01-13 10:45:19 -0800377
Ben Wagnerdea74282017-03-16 19:15:09 -0400378SKIA_OS_ANDROID = "ANDROID"
benjaminwagner787ca872015-08-17 12:58:10 -0700379
Ben Wagnerdea74282017-03-16 19:15:09 -0400380SKIA_OS_IOS = "IOS"
benjaminwagner56f6d062016-01-13 10:45:19 -0800381
Ben Wagnerdea74282017-03-16 19:15:09 -0400382SKIA_CPU_UNSPECIFIED = "UNSPECIFIED"
benjaminwagner56f6d062016-01-13 10:45:19 -0800383
Neal Norwitzca9fb3b2017-06-06 10:01:43 -0700384SKIA_CPU_ARM = "ARM"
385
Ben Wagnerdea74282017-03-16 19:15:09 -0400386SKIA_CPU_PPC = "PPC"
benjaminwagner39e7aa42015-11-18 13:26:10 -0800387
Ben Wagnerdea74282017-03-16 19:15:09 -0400388def skia_srcs(os=SKIA_OS_UNIX, cpu=SKIA_CPU_UNSPECIFIED):
389 """Sources to be compiled into the skia library."""
390 srcs = skia_glob(BASE_SRCS_ALL)
391 if os == SKIA_OS_IOS:
392 if cpu != SKIA_CPU_UNSPECIFIED:
393 fail("Do not specify IOS and a cpu.")
394 srcs = srcs + skia_glob(BASE_SRCS_IOS)
395 elif os == SKIA_OS_ANDROID:
396 if cpu != SKIA_CPU_UNSPECIFIED:
397 fail("Do not specify ANDROID and a cpu.")
398 srcs = srcs + skia_glob(BASE_SRCS_ANDROID)
399 elif os == SKIA_OS_UNIX:
400 if cpu == SKIA_CPU_UNSPECIFIED:
401 srcs = srcs + ["src/opts/opts_check_x86.cpp"] + skia_glob(BASE_SRCS_UNIX)
Neal Norwitzca9fb3b2017-06-06 10:01:43 -0700402 elif cpu == SKIA_CPU_PPC or cpu == SKIA_CPU_ARM:
Ben Wagnerdea74282017-03-16 19:15:09 -0400403 srcs = srcs + skia_glob(BASE_SRCS_UNIX)
404 else:
405 fail("cpu must be one of SKIA_CPU_*")
406 else:
407 fail("skia_srcs parameter 'os' must be one of SKIA_OS_{UNIX,ANDROID,IOS}.")
408 return srcs
benjaminwagner39e7aa42015-11-18 13:26:10 -0800409
benjaminwagner56f6d062016-01-13 10:45:19 -0800410################################################################################
411## INCLUDES
412################################################################################
benjaminwagner39e7aa42015-11-18 13:26:10 -0800413
benjaminwagner787ca872015-08-17 12:58:10 -0700414# Includes needed by Skia implementation. Not public includes.
415INCLUDES = [
benjaminwagnerfa7e1a02015-11-13 12:27:08 -0800416 "include/android",
benjaminwagner787ca872015-08-17 12:58:10 -0700417 "include/c",
robertphillips188d44c2016-02-01 04:54:14 -0800418 "include/client/android",
benjaminwagner787ca872015-08-17 12:58:10 -0700419 "include/codec",
420 "include/config",
421 "include/core",
benjaminwagner787ca872015-08-17 12:58:10 -0700422 "include/effects",
Matt Sarettd7093c22017-05-09 15:28:32 -0400423 "include/encode",
benjaminwagner787ca872015-08-17 12:58:10 -0700424 "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",
Mike Klein135a1b12017-08-15 13:13:59 -0400439 "src/images",
benjaminwagner787ca872015-08-17 12:58:10 -0700440 "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",
Florin Malita5edba452017-05-30 16:39:47 -0400445 "src/shaders",
benjaminwagnerc8962512016-09-30 12:06:27 -0700446 "src/sksl",
benjaminwagner787ca872015-08-17 12:58:10 -0700447 "src/utils",
448 "third_party/etc1",
Ben Wagnerd0a3b062016-10-24 14:11:12 -0400449 "third_party/gif",
benjaminwagner56f6d062016-01-13 10:45:19 -0800450]
benjaminwagner787ca872015-08-17 12:58:10 -0700451
benjaminwagner56f6d062016-01-13 10:45:19 -0800452################################################################################
453## DM_SRCS
454################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700455
benjaminwagner56f6d062016-01-13 10:45:19 -0800456DM_SRCS_ALL = struct(
457 include = [
benjaminwagner6f6bef82015-10-15 08:09:44 -0700458 "dm/*.cpp",
459 "dm/*.h",
460 "gm/*.c",
461 "gm/*.cpp",
462 "gm/*.h",
463 "tests/*.cpp",
464 "tests/*.h",
benjaminwagner99fb6702016-07-28 15:12:21 -0700465 "tools/BigPathBench.inc",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700466 "tools/CrashHandler.cpp",
467 "tools/CrashHandler.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700468 "tools/ProcStats.cpp",
469 "tools/ProcStats.h",
470 "tools/Resources.cpp",
471 "tools/Resources.h",
benjaminwagner99fb6702016-07-28 15:12:21 -0700472 "tools/SkJSONCPP.h",
473 "tools/UrlDataManager.cpp",
474 "tools/UrlDataManager.h",
475 "tools/debugger/*.cpp",
476 "tools/debugger/*.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700477 "tools/flags/*.cpp",
478 "tools/flags/*.h",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700479 "tools/gpu/**/*.cpp",
480 "tools/gpu/**/*.h",
brianosman6d3119c2016-04-19 19:41:54 -0700481 "tools/picture_utils.cpp",
benjaminwagner99fb6702016-07-28 15:12:21 -0700482 "tools/picture_utils.h",
mtkleine1fc4522016-02-09 12:32:52 -0800483 "tools/random_parse_path.cpp",
484 "tools/random_parse_path.h",
benjaminwagner32885142015-10-24 07:55:31 -0700485 "tools/sk_tool_utils.cpp",
486 "tools/sk_tool_utils.h",
benjaminwagner99fb6702016-07-28 15:12:21 -0700487 "tools/sk_tool_utils_flags.h",
benjaminwagner32885142015-10-24 07:55:31 -0700488 "tools/sk_tool_utils_font.cpp",
benjaminwagner99fb6702016-07-28 15:12:21 -0700489 "tools/test_font_monospace.inc",
490 "tools/test_font_sans_serif.inc",
491 "tools/test_font_serif.inc",
492 "tools/test_font_index.inc",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700493 "tools/timer/*.cpp",
494 "tools/timer/*.h",
Brian Salomon40d01192017-07-19 13:05:11 -0400495 "tools/trace/*.cpp",
496 "tools/trace/*.h",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700497 ],
498 exclude = [
benjaminwagner86ea33e2015-10-26 10:46:25 -0700499 "tests/FontMgrAndroidParserTest.cpp", # Android-only.
benjaminwagner6f6bef82015-10-15 08:09:44 -0700500 "tests/skia_test.cpp", # Old main.
501 "tests/SkpSkGrTest.cpp", # Alternate main.
benjaminwagner921e48b2016-07-15 11:27:27 -0700502 "tests/SVGDeviceTest.cpp",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700503 "tools/gpu/gl/angle/*",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700504 "tools/gpu/gl/egl/*",
505 "tools/gpu/gl/glx/*",
506 "tools/gpu/gl/iOS/*",
507 "tools/gpu/gl/mac/*",
508 "tools/gpu/gl/mesa/*",
509 "tools/gpu/gl/win/*",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700510 "tools/timer/SysTimer_mach.cpp",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700511 "tools/timer/SysTimer_windows.cpp",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700512 ],
513)
514
Ben Wagnerdea74282017-03-16 19:15:09 -0400515################################################################################
516## dm_srcs()
517################################################################################
518# SKIA_OS_* definitions can be found above.
benjaminwagner86ea33e2015-10-26 10:46:25 -0700519
Ben Wagnerdea74282017-03-16 19:15:09 -0400520def dm_srcs(os):
521 """Sources for the dm binary for the specified os."""
522 srcs = skia_glob(DM_SRCS_ALL)
523 # TODO(benjaminwagner): None of the CreatePlatformGLContext_*.cpp files exist.
524 # TODO(jwg): Remove the globs if possible, they only select single files.
525 if os == SKIA_OS_IOS:
526 srcs = srcs + native.glob(["tools/gpu/iOS/CreatePlatformGLContext_iOS.cpp"])
527 elif os == SKIA_OS_ANDROID:
528 srcs = srcs + native.glob([
benjaminwagner86ea33e2015-10-26 10:46:25 -0700529 "tests/FontMgrAndroidParserTest.cpp",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700530 # TODO(benjaminwagner): Figure out how to compile with EGL.
531 "tools/gpu/gl/CreatePlatformGLContext_none.cpp",
Ben Wagnerdea74282017-03-16 19:15:09 -0400532 ])
533 elif os == SKIA_OS_UNIX:
534 srcs = srcs + native.glob(["tools/gpu/gl/CreatePlatformGLContext_none.cpp"])
535 else:
536 fail("dm_srcs parameter 'os' must be one of SKIA_OS_{UNIX,ANDROID,IOS}.")
537 return srcs
benjaminwagner56f6d062016-01-13 10:45:19 -0800538
539################################################################################
540## DM_INCLUDES
541################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700542
benjaminwagner6f6bef82015-10-15 08:09:44 -0700543DM_INCLUDES = [
benjaminwagnerb1fe8f62016-02-01 09:05:08 -0800544 "dm",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700545 "gm",
Mike Reed7f302c42017-02-18 14:12:08 -0500546 "experimental/svg/model",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700547 "src/codec",
Mike Reedaab8ce42017-02-18 12:57:09 -0500548 "src/core",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700549 "src/effects",
550 "src/fonts",
Hal Canarydb683012016-11-23 08:55:18 -0700551 "src/images",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700552 "src/pathops",
553 "src/pipe/utils",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700554 "src/ports",
Florin Malita5edba452017-05-30 16:39:47 -0400555 "src/shaders",
556 "src/shaders/gradients",
Mike Reedf71828f2017-02-18 09:51:33 -0500557 "src/xml",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700558 "tests",
559 "tools",
benjaminwagner99fb6702016-07-28 15:12:21 -0700560 "tools/debugger",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700561 "tools/flags",
benjaminwagner38d68bc2016-04-01 05:00:51 -0700562 "tools/gpu",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700563 "tools/timer",
Brian Salomon40d01192017-07-19 13:05:11 -0400564 "tools/trace",
benjaminwagner6f6bef82015-10-15 08:09:44 -0700565]
566
benjaminwagner56f6d062016-01-13 10:45:19 -0800567################################################################################
568## DM_ARGS
569################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700570
Ben Wagner59f9edb2016-11-28 15:30:37 -0500571def DM_ARGS(asan):
benjaminwagner83906ae2016-05-01 15:02:25 -0700572 source = ["tests", "gm", "image"]
Ben Wagnere2cbd042017-08-11 09:39:04 -0400573 # TODO(benjaminwagner): f16, pic-8888, serialize-8888, and tiles_rt-8888 fail.
574 config = ["565", "8888", "pdf", "srgb"]
benjaminwagner83906ae2016-05-01 15:02:25 -0700575 # TODO(mtklein): maybe investigate why these fail?
576 match = [
577 "~Canvas",
578 "~Codec",
579 "~Codec_Dimensions",
580 "~Codec_stripes",
581 "~FontMgr",
582 "~PaintBreakText",
583 "~RecordDraw_TextBounds",
584 "~Scalar",
585 "~skps",
586 "~Stream",
587 ]
588 if asan:
Ben Wagner59f9edb2016-11-28 15:30:37 -0500589 # The ASAN we use with Bazel has some strict checks, so omit tests that
590 # trigger them.
benjaminwagner83906ae2016-05-01 15:02:25 -0700591 match += [
Ben Wagneraf6522a2017-05-08 11:40:29 -0400592 "~bigrect",
benjaminwagner83906ae2016-05-01 15:02:25 -0700593 "~clippedcubic2",
594 "~conicpaths",
Ben Wagner59f9edb2016-11-28 15:30:37 -0500595 "~^gradients",
benjaminwagner83906ae2016-05-01 15:02:25 -0700596 "~Math",
597 "~Matrix",
Ben Wagner55b72532017-01-29 21:50:51 -0500598 "~PathBigCubic",
benjaminwagner83906ae2016-05-01 15:02:25 -0700599 "~PathOpsCubic",
benjaminwagnerb5188622016-06-29 10:26:44 -0700600 "~PathOpsFailOp",
caryclark523e76d2016-07-19 12:27:32 -0700601 "~PathOpsOpCubicsThreaded",
benjaminwagner83906ae2016-05-01 15:02:25 -0700602 "~PathOpsOpLoopsThreaded",
603 "~PathOpsSimplify",
604 "~PathOpsTightBoundsQuads",
605 "~Point",
benjaminwagner1d352312016-07-25 06:32:13 -0700606 "~sk_linear_to_srgb",
Ben Wagner59f9edb2016-11-28 15:30:37 -0500607 "~small_color_stop",
benjaminwagner56f6d062016-01-13 10:45:19 -0800608 ]
Ben Wagner59f9edb2016-11-28 15:30:37 -0500609 return ["--src"] + source + ["--config"] + config + ["--match"] + match
benjaminwagner56f6d062016-01-13 10:45:19 -0800610
611################################################################################
612## COPTS
613################################################################################
iroth8b99ef42015-11-02 11:11:21 -0800614
benjaminwagner86ea33e2015-10-26 10:46:25 -0700615COPTS_UNIX = [
benjaminwagner787ca872015-08-17 12:58:10 -0700616 "-Wno-implicit-fallthrough", # Some intentional fallthrough.
benjaminwagner7d974f52015-10-19 13:55:55 -0700617 "-Wno-deprecated-declarations", # Internal use of deprecated methods. :(
benjaminwagner787ca872015-08-17 12:58:10 -0700618]
619
Mike Klein452f9202017-05-05 09:16:00 -0400620COPTS_ANDROID = [
621 "-mfpu=neon",
622 "-Wno-error=attributes", # 'GrResourceCache' declared with greater visibility than the
623 # type of its field 'GrResourceCache::fPurgeableQueue'... bogus.
624]
benjaminwagner56f6d062016-01-13 10:45:19 -0800625
626COPTS_IOS = []
627
628COPTS_ALL = []
629
630################################################################################
631## DEFINES
632################################################################################
633
634DEFINES_UNIX = [
scroggo7732c0c2016-06-22 07:25:16 -0700635 "PNG_SKIP_SETJMP_CHECK",
benjaminwagner56f6d062016-01-13 10:45:19 -0800636 "SK_BUILD_FOR_UNIX",
637 "SK_SAMPLES_FOR_X",
halcanary650e20d2016-08-25 09:07:02 -0700638 "SK_PDF_USE_SFNTLY",
benjaminwagner186e0b92016-02-11 16:00:24 -0800639 "SK_CODEC_DECODES_RAW",
msarettad3a5c62016-05-06 07:21:26 -0700640 "SK_HAS_JPEG_LIBRARY",
scroggoe6939c12016-06-21 14:13:40 -0700641 "SK_HAS_PNG_LIBRARY",
scroggo7732c0c2016-06-22 07:25:16 -0700642 "SK_HAS_WEBP_LIBRARY",
benjaminwagner56f6d062016-01-13 10:45:19 -0800643]
benjaminwagner86ea33e2015-10-26 10:46:25 -0700644
645DEFINES_ANDROID = [
646 "SK_BUILD_FOR_ANDROID",
benjaminwagner186e0b92016-02-11 16:00:24 -0800647 "SK_CODEC_DECODES_RAW",
msarettad3a5c62016-05-06 07:21:26 -0700648 "SK_HAS_JPEG_LIBRARY",
scroggoe6939c12016-06-21 14:13:40 -0700649 "SK_HAS_PNG_LIBRARY",
scroggo7732c0c2016-06-22 07:25:16 -0700650 "SK_HAS_WEBP_LIBRARY",
benjaminwagner86ea33e2015-10-26 10:46:25 -0700651]
652
iroth8b99ef42015-11-02 11:11:21 -0800653DEFINES_IOS = [
654 "SK_BUILD_FOR_IOS",
sdefresnee3fa8112016-06-01 07:08:56 -0700655 "SK_BUILD_NO_OPTS",
Matt Sarett2d4fc272017-02-10 09:42:54 -0500656 "SK_HAS_JPEG_LIBRARY",
irothd2ccc772016-01-25 11:24:57 -0800657 "SKNX_NO_SIMD",
iroth8b99ef42015-11-02 11:11:21 -0800658]
659
benjaminwagner86ea33e2015-10-26 10:46:25 -0700660DEFINES_ALL = [
benjaminwagner787ca872015-08-17 12:58:10 -0700661 # Chrome DEFINES.
benjaminwagner787ca872015-08-17 12:58:10 -0700662 "SK_USE_FREETYPE_EMBOLDEN",
663 # Turn on a few Google3-specific build fixes.
664 "GOOGLE3",
Ben Wagnera3659de2017-07-10 14:47:09 -0400665 # Required for building dm.
666 "GR_TEST_UTILS",
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",
Mike Reed7c14d272017-06-08 14:16:03 -0400670 # Experiment to diagnose image diffs in Google3
Mike Klein5b117ea2017-08-15 09:01:22 -0400671 "SK_JUMPER_DISABLE_8BIT",
benjaminwagner787ca872015-08-17 12:58:10 -0700672]
673
benjaminwagner56f6d062016-01-13 10:45:19 -0800674################################################################################
675## LINKOPTS
676################################################################################
benjaminwagner86ea33e2015-10-26 10:46:25 -0700677
benjaminwagner56f6d062016-01-13 10:45:19 -0800678LINKOPTS_UNIX = []
benjaminwagner6f6bef82015-10-15 08:09:44 -0700679
benjaminwagner56f6d062016-01-13 10:45:19 -0800680LINKOPTS_ANDROID = [
681 "-lEGL",
682]
benjaminwagner6f6bef82015-10-15 08:09:44 -0700683
Mike Klein135a1b12017-08-15 13:13:59 -0400684LINKOPTS_IOS = [
685 "-framework CoreFoundation",
686 "-framework CoreGraphics",
687 "-framework CoreText",
688 "-framework ImageIO",
689 "-framework MobileCoreServices",
690]
benjaminwagner6f6bef82015-10-15 08:09:44 -0700691
benjaminwagner56f6d062016-01-13 10:45:19 -0800692LINKOPTS_ALL = [
693 "-ldl",
694]