skia2/bazel/BUILD.bazel
Kevin Lubick 4bd08c52c0 [infra] Add SkParagraph (harfbuzz, ICU) to Canvaskit Bazel build.
As a follow-up to https://skia-review.googlesource.com/c/skia/+/476219,
this sketches out how we can maybe use cc_library for the things
in //modules to make sure something in //src doesn't depend on
anything in //modules, for example.

The following succeeds:
bazel build //modules/skparagraph:skparagraph --config=clang \
  --shaper_backend=harfbuzz_shaper --with_icu

As does `make bazel_canvaskit_debug` in //modules/canvaskit

Suggested Review Order:
 - third_party/BUILD.bazel for ICU and harfbuzz rules. Pay
   special attention to the genrules used to call the python
   script for turning the icu .dat file into .S or .cpp.
 - bazelrc and bazel/ for new flags and defines that control
   use of ICU and harfbuzz. Unlike GN, with the public_defines
   that get added in automatically if icu or harfbuzz is
   depended upon, we need to set the defines at the top level.
   This necessity might go away if we change the atoms to
   depend on //modules/skshaper, which could define that flag.
 - Top level BUILD.bazel files in //modules/skparagraph,
   //modules/skshaper, //modules/skunicode, //modules/canvaskit
 - All other .bazel file changes are automatic.

Bug: skia:12541
Change-Id: I38a9e0a9261d7e142eeb271c2ddb23f362f91473
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/478116
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Leandro Lovisolo <lovisolo@google.com>
2021-11-30 21:01:06 +00:00

85 lines
2.5 KiB
Python

load("//bazel:macros.bzl", "select_multi")
GENERAL_DEFINES = ["SK_HAS_ANDROID_CODEC"] + select({
"//bazel/common_config_settings:debug_build": [
"SK_DEBUG",
],
"//bazel/common_config_settings:release_build": [
"SK_RELEASE",
],
"//conditions:default": [
"SK_RELEASE",
],
})
GPU_DEFINES = select({
"//bazel/common_config_settings:gl_backend": [
"SK_GL",
"SK_SUPPORT_GPU=1",
],
"//bazel/common_config_settings:vulkan_backend": [
"SK_VULKAN",
"SK_SUPPORT_GPU=1",
],
"//conditions:default": [
"SK_SUPPORT_GPU=0",
],
}) + select({
"//bazel/common_config_settings:gl_standard": [
"SK_ASSUME_GL=1",
],
"//bazel/common_config_settings:gles_standard": [
"SK_ASSUME_GL_ES=1",
],
"//bazel/common_config_settings:webgl_standard": [
"SK_ASSUME_WEBGL=1",
"SK_USE_WEBGL",
],
"//conditions:default": [],
})
CODEC_DEFINES = select_multi(
{
"//bazel/common_config_settings:gif_decode_codec": ["SK_HAS_WUFFS_LIBRARY"],
"//bazel/common_config_settings:jpeg_decode_codec": ["SK_CODEC_DECODES_JPEG"],
"//bazel/common_config_settings:jpeg_encode_codec": ["SK_ENCODE_JPEG"],
"//bazel/common_config_settings:png_decode_codec": ["SK_CODEC_DECODES_PNG"],
"//bazel/common_config_settings:png_encode_codec": ["SK_ENCODE_PNG"],
"//bazel/common_config_settings:raw_decode_codec": [
"SK_CODEC_DECODES_RAW",
"SK_CODEC_DECODES_JPEG",
],
"//bazel/common_config_settings:webp_decode_codec": ["SK_CODEC_DECODES_WEBP"],
},
default = [],
)
PLATFORM_DEFINES = select({
"//bazel/common_config_settings:cpu_wasm": [
# working around https://github.com/emscripten-core/emscripten/issues/10072
"SK_FORCE_8_BYTE_ALIGNMENT",
"SK_DISABLE_LEGACY_SHADERCONTEXT",
],
"//conditions:default": [],
})
SHAPER_DEFINES = select_multi(
{
"//bazel/common_config_settings:coretext_shaper": ["SK_SHAPER_CORETEXT_AVAILABLE"],
"//bazel/common_config_settings:harfbuzz_shaper": ["SK_SHAPER_HARFBUZZ_AVAILABLE"],
},
default = [],
)
UNICODE_DEFINES = select({
"//bazel/common_config_settings:use_icu_true": ["SK_UNICODE_AVAILABLE"],
"//conditions:default": [],
})
cc_library(
name = "defines_from_flags",
defines = GENERAL_DEFINES + GPU_DEFINES + CODEC_DEFINES + PLATFORM_DEFINES +
SHAPER_DEFINES + UNICODE_DEFINES,
visibility = ["//:__subpackages__"],
)