1 ################################################################################
3 ################################################################################
5 is_bazel = not hasattr(native, "genmpm")
7 def portable_select(select_dict, bazel_condition, default_condition):
8 """Replaces select() with a Bazel-friendly wrapper.
11 select_dict: Dictionary in the same format as select().
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.
18 return select_dict.get(bazel_condition, select_dict[default_condition])
20 return select(select_dict)
22 def skia_select(conditions, results):
23 """Replaces select() for conditions [UNIX, ANDROID, IOS]
26 conditions: [CONDITION_UNIX, CONDITION_ANDROID, CONDITION_IOS]
27 results: [RESULT_UNIX, RESULT_ANDROID, RESULT_IOS]
29 The result matching the platform condition.
31 if len(conditions) != 3 or len(results) != 3:
32 fail("Must provide exactly 3 conditions and 3 results")
36 selector[conditions[i]] = results[i]
37 return portable_select(selector, conditions[2], conditions[0])
40 """Replaces glob() with a version that accepts a struct.
43 srcs: struct(include=[], exclude=[])
45 Equivalent of glob(srcs.include, exclude=srcs.exclude)
47 if hasattr(srcs, 'include'):
48 if hasattr(srcs, 'exclude'):
49 return native.glob(srcs.include, exclude=srcs.exclude)
51 return native.glob(srcs.include)
54 ################################################################################
56 ################################################################################
58 # All platform-independent SRCS.
59 BASE_SRCS_ALL = struct(
61 "include/private/**/*.h",
65 "src/jumper/SkJumper_generated.S",
68 "third_party/etc1/*.cpp",
69 "third_party/etc1/*.h",
70 "third_party/gif/*.cpp",
71 "third_party/gif/*.h",
74 # Exclude platform-dependent files.
77 "src/device/xps/*", # Windows-only. Move to ports?
78 "src/doc/*_XPS.cpp", # Windows-only. Move to ports?
79 "src/gpu/gl/android/*",
89 "src/utils/android/**/*",
91 "src/utils/SkThreadUtils_win.cpp", # Windows-only. Move to ports?
97 # Exclude multiple definitions.
98 # TODO(mtklein): Move to opts?
99 "src/pdf/SkDocument_PDF_None.cpp", # We use src/pdf/SkPDFDocument.cpp.
100 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
101 "src/gpu/gl/GrGLDefaultInterface_native.cpp",
102 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
104 # Exclude files that don't compile with the current DEFINES.
105 "src/gpu/gl/mesa/*", # Requires SK_MESA define.
106 "src/svg/**/*", # Depends on XML.
109 # Conflicting dependencies among Lua versions. See cl/107087297.
115 # Currently exclude all vulkan specific files
119 "src/sksl/SkSLMain.cpp",
123 # Platform-dependent SRCS for google3-default platform.
124 BASE_SRCS_UNIX = struct(
128 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
132 "src/ports/**/*.cpp",
136 "src/opts/opts_check_x86.cpp",
141 # Included in :opts_sse2 library.
144 # Included in :opts_ssse3 library.
147 # Included in :opts_sse4 library.
150 # Included in :opts_avx or :opts_hsw
153 "src/opts/SkBitmapProcState_opts_none.cpp",
154 "src/opts/SkBlitMask_opts_none.cpp",
155 "src/opts/SkBlitRow_opts_none.cpp",
158 "src/ports/*android*",
159 "src/ports/*chromium*",
161 "src/ports/*mozalloc*",
164 "src/ports/SkFontMgr_custom_directory_factory.cpp",
165 "src/ports/SkFontMgr_custom_embedded_factory.cpp",
166 "src/ports/SkFontMgr_custom_empty_factory.cpp",
167 "src/ports/SkFontMgr_empty_factory.cpp",
168 "src/ports/SkFontMgr_fontconfig.cpp",
169 "src/ports/SkFontMgr_fontconfig_factory.cpp",
170 "src/ports/SkGlobalInitialization_none.cpp",
171 "src/ports/SkImageEncoder_none.cpp",
172 "src/ports/SkImageGenerator_none.cpp",
173 "src/ports/SkTLS_none.cpp",
177 # Platform-dependent SRCS for google3-default Android.
178 BASE_SRCS_ANDROID = struct(
182 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
184 # TODO(benjaminwagner): Figure out how to compile with EGL.
187 "src/ports/**/*.cpp",
200 "src/opts/SkBlitMask_opts_none.cpp",
201 "src/opts/SkBlitRow_opts_none.cpp",
203 "src/ports/*FontConfig*",
205 "src/ports/*chromium*",
206 "src/ports/*fontconfig*",
208 "src/ports/*mozalloc*",
211 "src/ports/SkDebug_stdio.cpp",
212 "src/ports/SkFontMgr_custom_directory_factory.cpp",
213 "src/ports/SkFontMgr_custom_embedded_factory.cpp",
214 "src/ports/SkFontMgr_custom_empty_factory.cpp",
215 "src/ports/SkFontMgr_empty_factory.cpp",
216 "src/ports/SkGlobalInitialization_none.cpp",
217 "src/ports/SkImageEncoder_none.cpp",
218 "src/ports/SkImageGenerator_none.cpp",
219 "src/ports/SkTLS_none.cpp",
223 # Platform-dependent SRCS for google3-default iOS.
224 BASE_SRCS_IOS = struct(
228 "src/gpu/gl/GrGLDefaultInterface_native.cpp",
229 "src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp",
232 "src/ports/**/*.cpp",
234 "src/utils/mac/*.cpp",
237 "src/codec/*Ico*.cpp",
238 "src/codec/*Webp*.cpp",
240 "src/codec/*Raw*.cpp",
252 "src/opts/SkBlitMask_opts_arm*.cpp",
253 "src/opts/SkBlitRow_opts_arm*.cpp",
255 "src/ports/*FontConfig*",
256 "src/ports/*FreeType*",
258 "src/ports/*android*",
259 "src/ports/*chromium*",
260 "src/ports/*fontconfig*",
261 "src/ports/*mozalloc*",
264 "src/ports/SkFontMgr_custom.cpp",
265 "src/ports/SkFontMgr_custom_directory.cpp",
266 "src/ports/SkFontMgr_custom_embedded.cpp",
267 "src/ports/SkFontMgr_custom_empty.cpp",
268 "src/ports/SkFontMgr_custom_directory_factory.cpp",
269 "src/ports/SkFontMgr_custom_embedded_factory.cpp",
270 "src/ports/SkFontMgr_custom_empty_factory.cpp",
271 "src/ports/SkFontMgr_empty_factory.cpp",
272 "src/ports/SkGlobalInitialization_none.cpp",
273 "src/ports/SkImageGenerator_none.cpp",
274 "src/ports/SkTLS_none.cpp",
278 ################################################################################
279 ## skia_{all,public}_hdrs()
280 ################################################################################
282 return native.glob(["src/**/*.h", "include/**/*.h"])
284 def skia_public_hdrs():
285 return native.glob(["include/**/*.h"],
287 "include/private/**/*.h",
288 "include/views/**/*", # Not used.
291 ################################################################################
293 ################################################################################
295 SKIA_OPTS_SSE2 = "SSE2"
297 SKIA_OPTS_SSSE3 = "SSSE3"
299 SKIA_OPTS_SSE4 = "SSE4"
301 SKIA_OPTS_AVX = "AVX"
303 SKIA_OPTS_HSW = "HSW"
306 SKIA_OPTS_ARMV7 = "ARMV7"
308 SKIA_OPTS_NEON = "NEON"
310 SKIA_OPTS_ARM64 = "ARM64"
312 SKIA_OPTS_CRC32 = "CRC32" # arm64
315 SKIA_OPTS_NONE = "NONE" # not x86, arm, or arm64
317 def skia_opts_srcs(opts):
318 if opts == SKIA_OPTS_SSE2:
320 "src/opts/*SSE2*.cpp",
321 "src/opts/*sse2*.cpp",
323 elif opts == SKIA_OPTS_SSSE3:
325 "src/opts/*SSSE3*.cpp",
326 "src/opts/*ssse3*.cpp",
328 elif opts == SKIA_OPTS_SSE4:
330 "src/opts/*SSE4*.cpp",
331 "src/opts/*sse4*.cpp",
333 elif opts == SKIA_OPTS_AVX:
335 "src/opts/*_avx.cpp",
337 elif opts == SKIA_OPTS_HSW:
339 "src/opts/*_hsw.cpp",
341 elif opts == SKIA_OPTS_ARMV7:
343 "src/opts/*_arm.cpp",
345 elif opts == SKIA_OPTS_NEON:
347 "src/opts/*_neon.cpp",
349 elif opts == SKIA_OPTS_CRC32:
351 "src/opts/*_crc32.cpp",
353 elif opts == SKIA_OPTS_NONE:
355 "src/opts/*_none.cpp",
358 fail("skia_opts_srcs parameter 'opts' must be one of SKIA_OPTS_*.")
360 def skia_opts_cflags(opts):
361 if opts == SKIA_OPTS_SSE2:
363 elif opts == SKIA_OPTS_SSSE3:
365 elif opts == SKIA_OPTS_SSE4:
367 elif opts == SKIA_OPTS_AVX:
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"]
376 ################################################################################
378 ################################################################################
379 SKIA_OS_UNIX = "UNIX"
381 SKIA_OS_ANDROID = "ANDROID"
385 SKIA_CPU_UNSPECIFIED = "UNSPECIFIED"
389 def 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)
406 fail("cpu must be one of SKIA_CPU_*")
408 fail("skia_srcs parameter 'os' must be one of SKIA_OS_{UNIX,ANDROID,IOS}.")
411 ################################################################################
413 ################################################################################
415 # Includes needed by Skia implementation. Not public includes.
419 "include/client/android",
450 ################################################################################
452 ################################################################################
454 DM_SRCS_ALL = struct(
463 "tools/BigPathBench.inc",
464 "tools/CrashHandler.cpp",
465 "tools/CrashHandler.h",
466 "tools/ProcStats.cpp",
468 "tools/Resources.cpp",
471 "tools/UrlDataManager.cpp",
472 "tools/UrlDataManager.h",
473 "tools/debugger/*.cpp",
474 "tools/debugger/*.h",
477 "tools/gpu/**/*.cpp",
479 "tools/picture_utils.cpp",
480 "tools/picture_utils.h",
481 "tools/random_parse_path.cpp",
482 "tools/random_parse_path.h",
483 "tools/sk_tool_utils.cpp",
484 "tools/sk_tool_utils.h",
485 "tools/sk_tool_utils_flags.h",
486 "tools/sk_tool_utils_font.cpp",
487 "tools/test_font_monospace.inc",
488 "tools/test_font_sans_serif.inc",
489 "tools/test_font_serif.inc",
490 "tools/test_font_index.inc",
495 "tests/FontMgrAndroidParserTest.cpp", # Android-only.
496 "tests/skia_test.cpp", # Old main.
497 "tests/SkpSkGrTest.cpp", # Alternate main.
498 "tests/SVGDeviceTest.cpp",
499 "tools/gpu/gl/angle/*",
500 "tools/gpu/gl/egl/*",
501 "tools/gpu/gl/glx/*",
502 "tools/gpu/gl/iOS/*",
503 "tools/gpu/gl/mac/*",
504 "tools/gpu/gl/mesa/*",
505 "tools/gpu/gl/win/*",
506 "tools/timer/SysTimer_mach.cpp",
507 "tools/timer/SysTimer_windows.cpp",
511 ################################################################################
513 ################################################################################
514 # SKIA_OS_* definitions can be found above.
517 """Sources for the dm binary for the specified os."""
518 srcs = skia_glob(DM_SRCS_ALL)
519 # TODO(benjaminwagner): None of the CreatePlatformGLContext_*.cpp files exist.
520 # TODO(jwg): Remove the globs if possible, they only select single files.
521 if os == SKIA_OS_IOS:
522 srcs = srcs + native.glob(["tools/gpu/iOS/CreatePlatformGLContext_iOS.cpp"])
523 elif os == SKIA_OS_ANDROID:
524 srcs = srcs + native.glob([
525 "tests/FontMgrAndroidParserTest.cpp",
526 # TODO(benjaminwagner): Figure out how to compile with EGL.
527 "tools/gpu/gl/CreatePlatformGLContext_none.cpp",
529 elif os == SKIA_OS_UNIX:
530 srcs = srcs + native.glob(["tools/gpu/gl/CreatePlatformGLContext_none.cpp"])
532 fail("dm_srcs parameter 'os' must be one of SKIA_OS_{UNIX,ANDROID,IOS}.")
535 ################################################################################
537 ################################################################################
542 "experimental/svg/model",
546 "src/effects/gradients",
561 ################################################################################
563 ################################################################################
566 source = ["tests", "gm", "image"]
567 # TODO(benjaminwagner): f16 and serialize-8888 fail.
568 config = ["565", "8888", "pdf", "srgb", "tiles_rt", "pic"]
569 # TODO(mtklein): maybe investigate why these fail?
577 "~RecordDraw_TextBounds",
583 # The ASAN we use with Bazel has some strict checks, so omit tests that
594 "~PathOpsOpCubicsThreaded",
595 "~PathOpsOpLoopsThreaded",
597 "~PathOpsTightBoundsQuads",
599 "~sk_linear_to_srgb",
602 return ["--src"] + source + ["--config"] + config + ["--match"] + match
604 ################################################################################
606 ################################################################################
609 "-Wno-implicit-fallthrough", # Some intentional fallthrough.
610 "-Wno-deprecated-declarations", # Internal use of deprecated methods. :(
613 COPTS_ANDROID = ["-mfpu=neon"]
619 ################################################################################
621 ################################################################################
624 "PNG_SKIP_SETJMP_CHECK",
628 "SK_CODEC_DECODES_RAW",
629 "SK_HAS_JPEG_LIBRARY",
630 "SK_HAS_PNG_LIBRARY",
631 "SK_HAS_WEBP_LIBRARY",
635 "SK_BUILD_FOR_ANDROID",
636 "SK_CODEC_DECODES_RAW",
637 "SK_HAS_JPEG_LIBRARY",
638 "SK_HAS_PNG_LIBRARY",
639 "SK_HAS_WEBP_LIBRARY",
645 "SK_HAS_JPEG_LIBRARY",
646 "SK_IGNORE_ETC1_SUPPORT",
653 "SK_USE_FREETYPE_EMBOLDEN",
654 # Turn on a few Google3-specific build fixes.
656 # Staging flags for API changes
657 # Temporarily Disable analytic AA for Google3
659 "SK_SUPPORT_LEGACY_BITMAP_SETPIXELREF",
662 ################################################################################
664 ################################################################################