skia2/bazel/common_config_settings/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

150 lines
3.6 KiB
Python

load(":defs.bzl", "bool_flag", "string_flag_with_values")
# @platforms is found at https://github.com/bazelbuild/platforms
package(default_visibility = ["//:__subpackages__"])
config_setting(
name = "linux_x64",
constraint_values = [
"@platforms//cpu:x86_64",
"@platforms//os:linux",
],
)
config_setting(
name = "windows_x64",
constraint_values = [
"@platforms//cpu:x86_64",
"@platforms//os:windows",
],
)
config_setting(
name = "linux_arm64",
constraint_values = [
"@platforms//cpu:arm64",
"@platforms//os:linux",
],
)
config_setting(
name = "debug_build",
values = {"compilation_mode": "dbg"},
)
config_setting(
name = "release_build",
values = {"compilation_mode": "opt"},
)
constraint_value(
name = "fuchsia",
constraint_setting = "@platforms//os:os",
)
config_setting(
name = "fuchsia_arm64",
constraint_values = [
"@platforms//cpu:arm64",
":fuchsia",
],
)
# We define this here because the emscripten toolchain calls the cpu wasm, whereas the
# bazelbuild/platforms call it wasm32. https://github.com/emscripten-core/emsdk/issues/919
config_setting(
name = "cpu_wasm",
values = {
"cpu": "wasm",
},
)
# =============================================================================
# Configurable Skia Features
# =============================================================================
# These are flags that we can specify when invoking bazel build to turn on and
# off certain features, such as GPU backend, or codec support.
# https://docs.bazel.build/versions/4.2.1/skylark/config.html#using-build-settings-on-the-command-line
# For example, to use the GL backend with the WebGL flavor, one would run
# bazel build //:skia-core --//bazel/common_config_settings:gpu_backend=gl_backend \
# --//bazel/common_config_settings:with_gl_standard=webgl_standard
# This is a bit wordy, so we define aliases in the //.bazelrc file that condense this to
# bazel build //:skia-core --gpu_backend=gl_backend --with_gl_standard=webgl_standard
#
# Developers can specify their own short-hands by making a .bazelrc file in their home
# directory. https://docs.bazel.build/versions/main/guide.html#where-are-the-bazelrc-files
#
string_flag_with_values(
flag_name = "gpu_backend",
multiple = True,
values = [
"gl_backend",
"vulkan_backend",
],
)
string_flag_with_values(
flag_name = "with_gl_standard",
values = [
"gles_standard",
"gl_standard",
"webgl_standard",
],
)
string_flag_with_values(
default = "empty_fontmgr_factory",
flag_name = "fontmgr_factory",
values = [
"empty_fontmgr_factory",
"custom_embedded_fontmgr_factory",
],
)
string_flag_with_values(
flag_name = "include_fontmgr",
multiple = True,
values = [
"custom_directory_fontmgr",
"custom_embedded_fontmgr",
"custom_empty_fontmgr",
],
)
string_flag_with_values(
flag_name = "include_decoder",
multiple = True,
values = [
"gif_decode_codec",
"jpeg_decode_codec",
"png_decode_codec",
"raw_decode_codec",
"webp_decode_codec",
],
)
string_flag_with_values(
flag_name = "include_encoder",
multiple = True,
values = [
"jpeg_encode_codec",
"png_encode_codec",
"webp_encode_codec",
],
)
string_flag_with_values(
flag_name = "shaper_backend",
multiple = True,
values = [
"harfbuzz_shaper",
"coretext_shaper",
],
)
bool_flag(
default = False,
flag_name = "use_icu",
)