aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Ben Wagner <benjaminwagner@google.com>2018-07-31 10:31:06 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-07-31 17:10:00 +0000
commitb303a427c03d2c8f9039f859317498e1fb8a2ff7 (patch)
treef74f19635dc8b1b0efc3302d9d64452e97dbc2d8
parentae5f9534b11915c6b927df2a681d2782d83a1b2f (diff)
[Bazel] Reformat public.bzl with buildifier.
Bug: skia:8210 No-Try: true Change-Id: I259fa3ee0bccdfb8999366596a0b210626ee26aa Reviewed-on: https://skia-review.googlesource.com/144501 Commit-Queue: Mike Klein <mtklein@google.com> Auto-Submit: Ben Wagner <benjaminwagner@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
-rw-r--r--public.bzl531
1 files changed, 267 insertions, 264 deletions
diff --git a/public.bzl b/public.bzl
index aaf7555429..64a1d2f386 100644
--- a/public.bzl
+++ b/public.bzl
@@ -5,68 +5,70 @@
is_bazel = not hasattr(native, "genmpm")
def portable_select(select_dict, bazel_condition, default_condition):
- """Replaces select() with a Bazel-friendly wrapper.
-
- Args:
- select_dict: Dictionary in the same format as select().
- Returns:
- If Blaze platform, returns select() using select_dict.
- If Bazel platform, returns dependencies for condition
- bazel_condition, or empty list if none specified.
- """
- if is_bazel:
- return select_dict.get(bazel_condition, select_dict[default_condition])
- else:
- return select(select_dict)
+ """Replaces select() with a Bazel-friendly wrapper.
+
+ Args:
+ select_dict: Dictionary in the same format as select().
+ Returns:
+ If Blaze platform, returns select() using select_dict.
+ If Bazel platform, returns dependencies for condition
+ bazel_condition, or empty list if none specified.
+ """
+ if is_bazel:
+ return select_dict.get(bazel_condition, select_dict[default_condition])
+ else:
+ return select(select_dict)
def skia_select(conditions, results):
- """Replaces select() for conditions [UNIX, ANDROID, IOS]
-
- Args:
- conditions: [CONDITION_UNIX, CONDITION_ANDROID, CONDITION_IOS]
- results: [RESULT_UNIX, RESULT_ANDROID, RESULT_IOS]
- Returns:
- The result matching the platform condition.
- """
- if len(conditions) != 3 or len(results) != 3:
- fail("Must provide exactly 3 conditions and 3 results")
-
- selector = {}
- for i in range(3):
- selector[conditions[i]] = results[i]
- return portable_select(selector, conditions[2], conditions[0])
+ """Replaces select() for conditions [UNIX, ANDROID, IOS]
+
+ Args:
+ conditions: [CONDITION_UNIX, CONDITION_ANDROID, CONDITION_IOS]
+ results: [RESULT_UNIX, RESULT_ANDROID, RESULT_IOS]
+ Returns:
+ The result matching the platform condition.
+ """
+ if len(conditions) != 3 or len(results) != 3:
+ fail("Must provide exactly 3 conditions and 3 results")
+
+ selector = {}
+ for i in range(3):
+ selector[conditions[i]] = results[i]
+ return portable_select(selector, conditions[2], conditions[0])
def skia_glob(srcs):
- """Replaces glob() with a version that accepts a struct.
-
- Args:
- srcs: struct(include=[], exclude=[])
- Returns:
- Equivalent of glob(srcs.include, exclude=srcs.exclude)
- """
- if hasattr(srcs, 'include'):
- if hasattr(srcs, 'exclude'):
- return native.glob(srcs.include, exclude=srcs.exclude)
- else:
- return native.glob(srcs.include)
- return []
+ """Replaces glob() with a version that accepts a struct.
+
+ Args:
+ srcs: struct(include=[], exclude=[])
+ Returns:
+ Equivalent of glob(srcs.include, exclude=srcs.exclude)
+ """
+ if hasattr(srcs, "include"):
+ if hasattr(srcs, "exclude"):
+ return native.glob(srcs.include, exclude = srcs.exclude)
+ else:
+ return native.glob(srcs.include)
+ return []
################################################################################
## skia_{all,public}_hdrs()
################################################################################
def skia_all_hdrs():
- return native.glob([
- "src/**/*.h",
- "include/**/*.h",
- "third_party/**/*.h",
- ])
+ return native.glob([
+ "src/**/*.h",
+ "include/**/*.h",
+ "third_party/**/*.h",
+ ])
def skia_public_hdrs():
- return native.glob(["include/**/*.h"],
- exclude=[
- "include/private/**/*",
- "include/views/**/*", # Not used.
- ])
+ return native.glob(
+ ["include/**/*.h"],
+ exclude = [
+ "include/private/**/*",
+ "include/views/**/*", # Not used.
+ ],
+ )
################################################################################
## skia_opts_srcs()
@@ -90,64 +92,64 @@ 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_HSW:
- return native.glob([
- "src/opts/*_hsw.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_*.")
+ 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_HSW:
+ return native.glob([
+ "src/opts/*_hsw.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_HSW:
- return ["-mavx2", "-mf16c", "-mfma"]
- elif opts == SKIA_OPTS_NEON:
- return ["-mfpu=neon"]
- elif opts == SKIA_OPTS_CRC32:
- # NDK r11's Clang (3.8) doesn't pass along this -march setting correctly to an external
- # assembler, so we do it manually with -Wa. This is just a bug, fixed in later Clangs.
- return ["-march=armv8-a+crc", "-Wa,-march=armv8-a+crc"]
- else:
- return []
+ 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_HSW:
+ return ["-mavx2", "-mf16c", "-mfma"]
+ elif opts == SKIA_OPTS_NEON:
+ return ["-mfpu=neon"]
+ elif opts == SKIA_OPTS_CRC32:
+ # NDK r11's Clang (3.8) doesn't pass along this -march setting correctly to an external
+ # assembler, so we do it manually with -Wa. This is just a bug, fixed in later Clangs.
+ return ["-march=armv8-a+crc", "-Wa,-march=armv8-a+crc"]
+ else:
+ return []
SKIA_CPU_ARM = "ARM"
@@ -158,50 +160,50 @@ 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
+ 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"]
+ res = [":opts_rest"]
- if cpu == SKIA_CPU_ARM:
- res += [":opts_neon"]
+ if cpu == SKIA_CPU_ARM:
+ res += [":opts_neon"]
- if cpu == SKIA_CPU_ARM64:
- res += [":opts_crc32"]
+ if cpu == SKIA_CPU_ARM64:
+ res += [":opts_crc32"]
- if cpu == SKIA_CPU_X86:
- res += [
- ":opts_sse2",
- ":opts_ssse3",
- ":opts_sse41",
- ":opts_sse42",
- ":opts_avx",
- ":opts_hsw",
- ]
+ if cpu == SKIA_CPU_X86:
+ res += [
+ ":opts_sse2",
+ ":opts_ssse3",
+ ":opts_sse41",
+ ":opts_sse42",
+ ":opts_avx",
+ ":opts_hsw",
+ ]
- return res
+ return res
################################################################################
## BASE_SRCS
@@ -272,21 +274,21 @@ BASE_SRCS_ALL = struct(
"src/core/SkColorSpaceXform_skcms.cpp",
# Compute backend not yet even hooked into Skia.
- "src/compute/**/*",
+ "src/compute/**/*",
],
)
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)
+ """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(
@@ -384,15 +386,15 @@ BASE_SRCS_IOS = struct(
## skia_srcs()
################################################################################
def skia_srcs(os_conditions):
- """Sources to be compiled into the skia library."""
- 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),
- ],
- )
+ """Sources to be compiled into the skia library."""
+ 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,15 +517,15 @@ DM_SRCS_ALL = struct(
################################################################################
def dm_srcs(os_conditions):
- """Sources for the dm binary for the specified os."""
- return skia_glob(DM_SRCS_ALL) + skia_select(
- os_conditions,
- [
- [],
- ["tests/FontMgrAndroidParserTest.cpp"],
- [],
- ],
- )
+ """Sources for the dm binary for the specified os."""
+ return skia_glob(DM_SRCS_ALL) + skia_select(
+ os_conditions,
+ [
+ [],
+ ["tests/FontMgrAndroidParserTest.cpp"],
+ [],
+ ],
+ )
################################################################################
## DM_INCLUDES
@@ -559,111 +561,112 @@ DM_INCLUDES = [
################################################################################
def DM_ARGS(asan):
- source = ["tests", "gm", "image"]
- # TODO(benjaminwagner): f16, pic-8888, serialize-8888, and tiles_rt-8888 fail.
- config = ["565", "8888", "pdf"]
- match = ["~Codec_78329453"]
- return (["--src"] + source + ["--config"] + config + ["--nonativeFonts"] +
- ["--match"] + match)
+ source = ["tests", "gm", "image"]
+
+ # TODO(benjaminwagner): f16, pic-8888, serialize-8888, and tiles_rt-8888 fail.
+ config = ["565", "8888", "pdf"]
+ match = ["~Codec_78329453"]
+ return (["--src"] + source + ["--config"] + config + ["--nonativeFonts"] +
+ ["--match"] + match)
################################################################################
## COPTS
################################################################################
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",
- # TODO(kjlubick)
- "-Wno-self-assign", # Spurious warning in tests/PathOpsDVectorTest.cpp?
- ],
- # ANDROID
- [
- # 'GrResourceCache' declared with greater visibility than the
- # type of its field 'GrResourceCache::fPurgeableQueue'... bogus.
- "-Wno-error=attributes",
- ],
- # IOS
- [],
- ],
- )
+ return skia_select(
+ os_conditions,
+ [
+ # UNIX
+ [
+ "-Wno-implicit-fallthrough", # Some intentional fallthrough.
+ # Internal use of deprecated methods. :(
+ "-Wno-deprecated-declarations",
+ # TODO(kjlubick)
+ "-Wno-self-assign", # Spurious warning in tests/PathOpsDVectorTest.cpp?
+ ],
+ # ANDROID
+ [
+ # 'GrResourceCache' declared with greater visibility than the
+ # type of its field 'GrResourceCache::fPurgeableQueue'... bogus.
+ "-Wno-error=attributes",
+ ],
+ # IOS
+ [],
+ ],
+ )
################################################################################
## DEFINES
################################################################################
def base_defines(os_conditions):
- return [
- # Chrome DEFINES.
- "SK_USE_FREETYPE_EMBOLDEN",
- # Turn on a few Google3-specific build fixes.
- "SK_BUILD_FOR_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",
- ],
- ],
- )
+ return [
+ # Chrome DEFINES.
+ "SK_USE_FREETYPE_EMBOLDEN",
+ # Turn on a few Google3-specific build fixes.
+ "SK_BUILD_FOR_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
################################################################################
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",
- ],
- ]
- )
+ return [
+ "-ldl",
+ ] + skia_select(
+ os_conditions,
+ [
+ # UNIX
+ [],
+ # ANDROID
+ [
+ "-lEGL",
+ ],
+ # IOS
+ [
+ "-framework CoreFoundation",
+ "-framework CoreGraphics",
+ "-framework CoreText",
+ "-framework ImageIO",
+ "-framework MobileCoreServices",
+ ],
+ ],
+ )