diff options
author | Ben Wagner <benjaminwagner@google.com> | 2017-10-17 10:57:34 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-10-17 15:37:12 +0000 |
commit | 9eca72b57bdf2fc008006b43fd8bf37efbfa7517 (patch) | |
tree | 8e7ff0969b7ba234b5468e1a3252db2610629fc4 | |
parent | 84be3ad50193a1d165246f2a9ecdb4e3fcdf9fc4 (diff) |
[Bazel] Separate OS and CPU dimensions in Skia sources.
Patching from internal cl/171888276.
No-Try: true
Change-Id: I6919769ad4e367ded394f1094944cea2b3901fd0
Reviewed-on: https://skia-review.googlesource.com/60583
Reviewed-by: Ben Wagner <benjaminwagner@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Ben Wagner <benjaminwagner@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
-rw-r--r-- | public.bzl | 531 |
1 files changed, 252 insertions, 279 deletions
diff --git a/public.bzl b/public.bzl index e8325500a0..628301d3d9 100644 --- a/public.bzl +++ b/public.bzl @@ -52,6 +52,143 @@ def skia_glob(srcs): return [] ################################################################################ +## skia_{all,public}_hdrs() +################################################################################ +def skia_all_hdrs(): + return native.glob(["src/**/*.h", "include/**/*.h"]) + +def skia_public_hdrs(): + return native.glob(["include/**/*.h"], + exclude=[ + "include/private/**/*", + "include/views/**/*", # Not used. + ]) + +################################################################################ +## skia_opts_srcs() +################################################################################ +# Intel +SKIA_OPTS_SSE2 = "SSE2" + +SKIA_OPTS_SSSE3 = "SSSE3" + +SKIA_OPTS_SSE41 = "SSE41" + +SKIA_OPTS_SSE42 = "SSE42" + +SKIA_OPTS_AVX = "AVX" + +# Arm +SKIA_OPTS_NEON = "NEON" + +SKIA_OPTS_CRC32 = "CRC32" # arm64 + +def opts_srcs(opts): + if opts == SKIA_OPTS_SSE2: + return native.glob([ + "src/opts/*_SSE2.cpp", + "src/opts/*_sse2.cpp", # No matches currently. + ]) + elif opts == SKIA_OPTS_SSSE3: + return native.glob([ + "src/opts/*_SSSE3.cpp", + "src/opts/*_ssse3.cpp", + ]) + elif opts == SKIA_OPTS_SSE41: + return native.glob([ + "src/opts/*_sse41.cpp", + ]) + elif opts == SKIA_OPTS_SSE42: + return native.glob([ + "src/opts/*_sse42.cpp", + ]) + elif opts == SKIA_OPTS_AVX: + return native.glob([ + "src/opts/*_avx.cpp", + ]) + elif opts == SKIA_OPTS_NEON: + return native.glob([ + "src/opts/*_neon.cpp", + ]) + elif opts == SKIA_OPTS_CRC32: + return native.glob([ + "src/opts/*_crc32.cpp", + ]) + else: + fail("skia_opts_srcs parameter 'opts' must be one of SKIA_OPTS_*.") + +def opts_cflags(opts): + if opts == SKIA_OPTS_SSE2: + return ["-msse2"] + elif opts == SKIA_OPTS_SSSE3: + return ["-mssse3"] + elif opts == SKIA_OPTS_SSE41: + return ["-msse4.1"] + elif opts == SKIA_OPTS_SSE42: + return ["-msse4.2"] + elif opts == SKIA_OPTS_AVX: + return ["-mavx"] + elif opts == SKIA_OPTS_NEON: + return ["-mfpu=neon"] + elif opts == SKIA_OPTS_CRC32: + return ["-march=armv8-a+crc"] + else: + return [] + +SKIA_CPU_ARM = "ARM" + +SKIA_CPU_ARM64 = "ARM64" + +SKIA_CPU_X86 = "X86" + +SKIA_CPU_OTHER = "OTHER" + +def opts_rest_srcs(cpu): + srcs = [] + if cpu == SKIA_CPU_ARM or cpu == SKIA_CPU_ARM64: + srcs += native.glob([ + "src/opts/*_arm.cpp", + "src/opts/SkBitmapProcState_opts_none.cpp", + ]) + if cpu == SKIA_CPU_ARM64: + # NEON doesn't need special flags to compile on ARM64. + srcs += native.glob([ + "src/opts/*_neon.cpp", + ]) + elif cpu == SKIA_CPU_X86: + srcs += native.glob([ + "src/opts/*_x86.cpp", + ]) + elif cpu == SKIA_CPU_OTHER: + srcs += native.glob([ + "src/opts/*_none.cpp", + ]) + else: + fail("opts_rest_srcs parameter 'cpu' must be one of " + + "SKIA_CPU_{ARM,ARM64,X86,OTHER}.") + return srcs + +def skia_opts_deps(cpu): + res = [":opts_rest"] + + if cpu == SKIA_CPU_ARM: + res += [":opts_neon"] + + if cpu == SKIA_CPU_ARM64: + res += [":opts_crc32"] + + if cpu == SKIA_CPU_X86: + res += [ + ":opts_sse2", + ":opts_ssse3", + ":opts_sse41", + ":opts_sse42", + ":opts_avx", + ] + + return res + +################################################################################ ## BASE_SRCS ################################################################################ @@ -72,7 +209,6 @@ BASE_SRCS_ALL = struct( ], exclude = [ # Exclude platform-dependent files. - "src/android/*", "src/codec/*", "src/device/xps/*", # Windows-only. Move to ports? "src/doc/*_XPS.cpp", # Windows-only. Move to ports? @@ -122,38 +258,26 @@ BASE_SRCS_ALL = struct( ], ) +def codec_srcs(limited): + """Sources for the codecs. Excludes Ico, Webp, Png, and Raw if limited.""" + exclude = [] + if limited: + exclude += [ + "src/codec/*Ico*.cpp", + "src/codec/*Webp*.cpp", + "src/codec/*Png*", + "src/codec/*Raw*.cpp", + ] + return native.glob(["src/codec/*.cpp"], exclude = exclude) + # Platform-dependent SRCS for google3-default platform. BASE_SRCS_UNIX = struct( include = [ - "src/android/*", - "src/codec/*", "src/gpu/gl/GrGLDefaultInterface_none.cpp", - "src/opts/**/*.cpp", - "src/opts/**/*.h", "src/ports/**/*.cpp", "src/ports/**/*.h", ], exclude = [ - "src/opts/opts_check_x86.cpp", - "src/opts/*arm*", - "src/opts/*mips*", - "src/opts/*NEON*", - "src/opts/*neon*", - # Included in :opts_sse2 library. - "src/opts/*SSE2*", - "src/opts/*sse2*", - # Included in :opts_ssse3 library. - "src/opts/*SSSE3*", - "src/opts/*ssse3*", - # Included in :opts_sse4 library. - "src/opts/*SSE4*", - "src/opts/*sse4*", - # Included in :opts_avx or :opts_hsw - "src/opts/*avx*", - "src/opts/*hsw*", - "src/opts/SkBitmapProcState_opts_none.cpp", - "src/opts/SkBlitMask_opts_none.cpp", - "src/opts/SkBlitRow_opts_none.cpp", "src/ports/*CG*", "src/ports/*WIC*", "src/ports/*android*", @@ -177,27 +301,12 @@ BASE_SRCS_UNIX = struct( # Platform-dependent SRCS for google3-default Android. BASE_SRCS_ANDROID = struct( include = [ - "src/android/*", - "src/codec/*", "src/gpu/gl/GrGLDefaultInterface_none.cpp", # TODO(benjaminwagner): Figure out how to compile with EGL. - "src/opts/**/*.cpp", - "src/opts/**/*.h", "src/ports/**/*.cpp", "src/ports/**/*.h", ], exclude = [ - "src/opts/*mips*", - "src/opts/*SSE2*", - "src/opts/*SSSE3*", - "src/opts/*ssse3*", - "src/opts/*SSE4*", - "src/opts/*sse4*", - "src/opts/*avx*", - "src/opts/*hsw*", - "src/opts/*x86*", - "src/opts/SkBlitMask_opts_none.cpp", - "src/opts/SkBlitRow_opts_none.cpp", "src/ports/*CG*", "src/ports/*FontConfig*", "src/ports/*WIC*", @@ -221,34 +330,13 @@ BASE_SRCS_ANDROID = struct( # Platform-dependent SRCS for google3-default iOS. BASE_SRCS_IOS = struct( include = [ - "src/android/*", - "src/codec/*", "src/gpu/gl/GrGLDefaultInterface_native.cpp", "src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp", - "src/opts/**/*.cpp", - "src/opts/**/*.h", "src/ports/**/*.cpp", "src/ports/**/*.h", "src/utils/mac/*.cpp", ], exclude = [ - "src/codec/*Ico*.cpp", - "src/codec/*Webp*.cpp", - "src/codec/*Png*", - "src/codec/*Raw*.cpp", - "src/opts/*mips*", - "src/opts/*NEON*", - "src/opts/*neon*", - "src/opts/*SSE2*", - "src/opts/*SSSE3*", - "src/opts/*ssse3*", - "src/opts/*SSE4*", - "src/opts/*sse4*", - "src/opts/*avx*", - "src/opts/*hsw*", - "src/opts/*x86*", - "src/opts/SkBlitMask_opts_arm*.cpp", - "src/opts/SkBlitRow_opts_arm*.cpp", "src/ports/*FontConfig*", "src/ports/*FreeType*", "src/ports/*WIC*", @@ -273,139 +361,18 @@ BASE_SRCS_IOS = struct( ) ################################################################################ -## skia_{all,public}_hdrs() -################################################################################ -def skia_all_hdrs(): - return native.glob(["src/**/*.h", "include/**/*.h"]) - -def skia_public_hdrs(): - return native.glob(["include/**/*.h"], - exclude=[ - "include/private/**/*.h", - "include/views/**/*", # Not used. - ]) - -################################################################################ -## skia_opts_srcs() -################################################################################ -# Intel -SKIA_OPTS_SSE2 = "SSE2" - -SKIA_OPTS_SSSE3 = "SSSE3" - -SKIA_OPTS_SSE4 = "SSE4" - -SKIA_OPTS_AVX = "AVX" - -SKIA_OPTS_HSW = "HSW" - -# Arm -SKIA_OPTS_ARMV7 = "ARMV7" - -SKIA_OPTS_NEON = "NEON" - -SKIA_OPTS_ARM64 = "ARM64" - -SKIA_OPTS_CRC32 = "CRC32" # arm64 - -# Other -SKIA_OPTS_NONE = "NONE" # not x86, arm, or arm64 - -def skia_opts_srcs(opts): - if opts == SKIA_OPTS_SSE2: - return native.glob([ - "src/opts/*SSE2*.cpp", - "src/opts/*sse2*.cpp", - ]) - elif opts == SKIA_OPTS_SSSE3: - return native.glob([ - "src/opts/*SSSE3*.cpp", - "src/opts/*ssse3*.cpp", - ]) - elif opts == SKIA_OPTS_SSE4: - return native.glob([ - "src/opts/*SSE4*.cpp", - "src/opts/*sse4*.cpp", - ]) - elif opts == SKIA_OPTS_AVX: - return native.glob([ - "src/opts/*_avx.cpp", - ]) - elif opts == SKIA_OPTS_HSW: - return native.glob([ - "src/opts/*_hsw.cpp", - ]) - elif opts == SKIA_OPTS_ARMV7: - return native.glob([ - "src/opts/*_arm.cpp", - ]) - elif opts == SKIA_OPTS_NEON: - return native.glob([ - "src/opts/*_neon.cpp", - ]) - elif opts == SKIA_OPTS_CRC32: - return native.glob([ - "src/opts/*_crc32.cpp", - ]) - elif opts == SKIA_OPTS_NONE: - return native.glob([ - "src/opts/*_none.cpp", - ]) - else: - fail("skia_opts_srcs parameter 'opts' must be one of SKIA_OPTS_*.") - -def skia_opts_cflags(opts): - if opts == SKIA_OPTS_SSE2: - return ["-msse2"] - elif opts == SKIA_OPTS_SSSE3: - return ["-mssse3"] - elif opts == SKIA_OPTS_SSE4: - return ["-msse4"] - elif opts == SKIA_OPTS_AVX: - return ["-mavx"] - elif opts == SKIA_OPTS_HSW: - return ["-mavx2", "-mbmi", "-mbmi2", "-mf16c", "-mfma"] - elif opts == SKIA_OPTS_CRC32: - return ["-march=armv8-a+crc"] - else: - return [] - -################################################################################ ## skia_srcs() ################################################################################ -SKIA_OS_UNIX = "UNIX" - -SKIA_OS_ANDROID = "ANDROID" - -SKIA_OS_IOS = "IOS" - -SKIA_CPU_UNSPECIFIED = "UNSPECIFIED" - -SKIA_CPU_ARM = "ARM" - -SKIA_CPU_PPC = "PPC" - -def skia_srcs(os=SKIA_OS_UNIX, cpu=SKIA_CPU_UNSPECIFIED): +def skia_srcs(os_conditions): """Sources to be compiled into the skia library.""" - srcs = skia_glob(BASE_SRCS_ALL) - if os == SKIA_OS_IOS: - if cpu != SKIA_CPU_UNSPECIFIED: - fail("Do not specify IOS and a cpu.") - srcs = srcs + skia_glob(BASE_SRCS_IOS) - elif os == SKIA_OS_ANDROID: - if cpu != SKIA_CPU_UNSPECIFIED: - fail("Do not specify ANDROID and a cpu.") - srcs = srcs + skia_glob(BASE_SRCS_ANDROID) - elif os == SKIA_OS_UNIX: - if cpu == SKIA_CPU_UNSPECIFIED: - srcs = srcs + ["src/opts/opts_check_x86.cpp"] + skia_glob(BASE_SRCS_UNIX) - elif cpu == SKIA_CPU_PPC or cpu == SKIA_CPU_ARM: - srcs = srcs + skia_glob(BASE_SRCS_UNIX) - else: - fail("cpu must be one of SKIA_CPU_*") - else: - fail("skia_srcs parameter 'os' must be one of SKIA_OS_{UNIX,ANDROID,IOS}.") - return srcs + return skia_glob(BASE_SRCS_ALL) + skia_select( + os_conditions, + [ + skia_glob(BASE_SRCS_UNIX), + skia_glob(BASE_SRCS_ANDROID), + skia_glob(BASE_SRCS_IOS), + ], + ) ################################################################################ ## INCLUDES @@ -515,26 +482,17 @@ DM_SRCS_ALL = struct( ################################################################################ ## dm_srcs() ################################################################################ -# SKIA_OS_* definitions can be found above. -def dm_srcs(os): +def dm_srcs(os_conditions): """Sources for the dm binary for the specified os.""" - srcs = skia_glob(DM_SRCS_ALL) - # TODO(benjaminwagner): None of the CreatePlatformGLContext_*.cpp files exist. - # TODO(jwg): Remove the globs if possible, they only select single files. - if os == SKIA_OS_IOS: - srcs = srcs + native.glob(["tools/gpu/iOS/CreatePlatformGLContext_iOS.cpp"]) - elif os == SKIA_OS_ANDROID: - srcs = srcs + native.glob([ - "tests/FontMgrAndroidParserTest.cpp", - # TODO(benjaminwagner): Figure out how to compile with EGL. - "tools/gpu/gl/CreatePlatformGLContext_none.cpp", - ]) - elif os == SKIA_OS_UNIX: - srcs = srcs + native.glob(["tools/gpu/gl/CreatePlatformGLContext_none.cpp"]) - else: - fail("dm_srcs parameter 'os' must be one of SKIA_OS_{UNIX,ANDROID,IOS}.") - return srcs + return skia_glob(DM_SRCS_ALL) + skia_select( + os_conditions, + [ + [], + ["tests/FontMgrAndroidParserTest.cpp"], + [], + ], + ) ################################################################################ ## DM_INCLUDES @@ -603,83 +561,98 @@ def DM_ARGS(asan): ## COPTS ################################################################################ -COPTS_UNIX = [ - "-Wno-implicit-fallthrough", # Some intentional fallthrough. - "-Wno-deprecated-declarations", # Internal use of deprecated methods. :( -] - -COPTS_ANDROID = [ - "-mfpu=neon", - "-Wno-error=attributes", # 'GrResourceCache' declared with greater visibility than the - # type of its field 'GrResourceCache::fPurgeableQueue'... bogus. -] - -COPTS_IOS = [] - -COPTS_ALL = [] +def base_copts(os_conditions): + return skia_select( + os_conditions, + [ + # UNIX + [ + "-Wno-implicit-fallthrough", # Some intentional fallthrough. + # Internal use of deprecated methods. :( + "-Wno-deprecated-declarations", + ], + # ANDROID + [ + # 'GrResourceCache' declared with greater visibility than the + # type of its field 'GrResourceCache::fPurgeableQueue'... bogus. + "-Wno-error=attributes", + ], + # IOS + [], + ], + ) ################################################################################ ## DEFINES ################################################################################ -DEFINES_UNIX = [ - "PNG_SKIP_SETJMP_CHECK", - "SK_BUILD_FOR_UNIX", - "SK_SAMPLES_FOR_X", - "SK_PDF_USE_SFNTLY", - "SK_CODEC_DECODES_RAW", - "SK_HAS_JPEG_LIBRARY", - "SK_HAS_PNG_LIBRARY", - "SK_HAS_WEBP_LIBRARY", -] - -DEFINES_ANDROID = [ - "SK_BUILD_FOR_ANDROID", - "SK_CODEC_DECODES_RAW", - "SK_HAS_JPEG_LIBRARY", - "SK_HAS_PNG_LIBRARY", - "SK_HAS_WEBP_LIBRARY", -] - -DEFINES_IOS = [ - "SK_BUILD_FOR_IOS", - "SK_BUILD_NO_OPTS", - "SK_HAS_JPEG_LIBRARY", - "SKNX_NO_SIMD", -] - -DEFINES_ALL = [ - # Chrome DEFINES. - "SK_USE_FREETYPE_EMBOLDEN", - # Turn on a few Google3-specific build fixes. - "GOOGLE3", - # Required for building dm. - "GR_TEST_UTILS", - # Staging flags for API changes - # Should remove after we update golden images - "SK_WEBP_ENCODER_USE_DEFAULT_METHOD", - # Experiment to diagnose image diffs in Google3 - "SK_JUMPER_DISABLE_8BIT", -] +def base_defines(os_conditions): + return [ + # Chrome DEFINES. + "SK_USE_FREETYPE_EMBOLDEN", + # Turn on a few Google3-specific build fixes. + "GOOGLE3", + # Required for building dm. + "GR_TEST_UTILS", + # Staging flags for API changes + # Should remove after we update golden images + "SK_WEBP_ENCODER_USE_DEFAULT_METHOD", + # Experiment to diagnose image diffs in Google3 + "SK_JUMPER_DISABLE_8BIT", + # JPEG is in codec_limited + "SK_HAS_JPEG_LIBRARY", + ] + skia_select( + os_conditions, + [ + # UNIX + [ + "PNG_SKIP_SETJMP_CHECK", + "SK_BUILD_FOR_UNIX", + "SK_SAMPLES_FOR_X", + "SK_PDF_USE_SFNTLY", + "SK_CODEC_DECODES_RAW", + "SK_HAS_PNG_LIBRARY", + "SK_HAS_WEBP_LIBRARY", + ], + # ANDROID + [ + "SK_BUILD_FOR_ANDROID", + "SK_CODEC_DECODES_RAW", + "SK_HAS_PNG_LIBRARY", + "SK_HAS_WEBP_LIBRARY", + ], + # IOS + [ + "SK_BUILD_FOR_IOS", + "SK_BUILD_NO_OPTS", + "SKNX_NO_SIMD", + ], + ], + ) ################################################################################ ## LINKOPTS ################################################################################ -LINKOPTS_UNIX = [] - -LINKOPTS_ANDROID = [ - "-lEGL", -] - -LINKOPTS_IOS = [ - "-framework CoreFoundation", - "-framework CoreGraphics", - "-framework CoreText", - "-framework ImageIO", - "-framework MobileCoreServices", -] - -LINKOPTS_ALL = [ - "-ldl", -] +def base_linkopts(os_conditions): + return [ + "-ldl", + ] + skia_select( + os_conditions, + [ + # UNIX + [], + # ANDROID + [ + "-lEGL", + ], + # IOS + [ + "-framework CoreFoundation", + "-framework CoreGraphics", + "-framework CoreText", + "-framework ImageIO", + "-framework MobileCoreServices", + ], + ] + ) |