• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1load(":defs.bzl", "bool_flag", "string_flag_with_values")
2
3# @platforms is found at https://github.com/bazelbuild/platforms
4package(default_visibility = ["//:__subpackages__"])
5
6config_setting(
7    name = "linux_x64",
8    constraint_values = [
9        "@platforms//cpu:x86_64",
10        "@platforms//os:linux",
11    ],
12)
13
14config_setting(
15    name = "windows_x64",
16    constraint_values = [
17        "@platforms//cpu:x86_64",
18        "@platforms//os:windows",
19    ],
20)
21
22config_setting(
23    name = "linux_arm64",
24    constraint_values = [
25        "@platforms//cpu:arm64",
26        "@platforms//os:linux",
27    ],
28)
29
30config_setting(
31    name = "debug_build",
32    values = {"compilation_mode": "dbg"},
33)
34
35config_setting(
36    name = "release_build",
37    values = {"compilation_mode": "opt"},
38)
39
40constraint_value(
41    name = "fuchsia",
42    constraint_setting = "@platforms//os:os",
43)
44
45config_setting(
46    name = "fuchsia_arm64",
47    constraint_values = [
48        "@platforms//cpu:arm64",
49        ":fuchsia",
50    ],
51)
52
53# We define this here because the emscripten toolchain calls the cpu wasm, whereas the
54# bazelbuild/platforms call it wasm32. https://github.com/emscripten-core/emsdk/issues/919
55config_setting(
56    name = "cpu_wasm",
57    values = {
58        "cpu": "wasm",
59    },
60)
61
62# =============================================================================
63#                     Configurable Skia Features
64# =============================================================================
65# These are flags that we can specify when invoking bazel build to turn on and
66# off certain features, such as GPU backend, or codec support.
67# https://docs.bazel.build/versions/4.2.1/skylark/config.html#using-build-settings-on-the-command-line
68# For example, to use the GL backend with the WebGL flavor, one would run
69# bazel build //:skia-core --//bazel/common_config_settings:gpu_backend=gl_backend \
70#             --//bazel/common_config_settings:with_gl_standard=webgl_standard
71# This is a bit wordy, so we define aliases in the //.bazelrc file that condense this to
72# bazel build //:skia-core --gpu_backend=gl_backend --with_gl_standard=webgl_standard
73#
74# Developers can specify their own short-hands by making a .bazelrc file in their home
75# directory. https://docs.bazel.build/versions/main/guide.html#where-are-the-bazelrc-files
76#
77
78string_flag_with_values(
79    flag_name = "gpu_backend",
80    multiple = True,
81    values = [
82        "gl_backend",
83        "vulkan_backend",
84    ],
85)
86
87string_flag_with_values(
88    flag_name = "with_gl_standard",
89    values = [
90        "gles_standard",
91        "gl_standard",
92        "webgl_standard",
93    ],
94)
95
96string_flag_with_values(
97    default = "empty_fontmgr_factory",
98    flag_name = "fontmgr_factory",
99    values = [
100        # Makes the default SkFontMgr load fonts from a hard-coded directory on disk.
101        "custom_directory_fontmgr_factory",
102        # Makes the default SkFontMgr load fonts from an SkEmbeddedResource that has been compiled
103        # into the binary, e.g. with //tools/embed_resources.py
104        "custom_embedded_fontmgr_factory",
105        # Makes the default SkFontMgr return empty fonts (e.g. SkTypeface_Empty). This is typically
106        # used when someone wants to make their own custom SkFontMgr objects, but does not want the
107        # default SkFontMgr to do anything (e.g. force usage of the custom one).
108        "custom_empty_fontmgr_factory",
109        # Makes the default SkFontMgr return null. Typically used when font support is not desired.
110        "empty_fontmgr_factory",
111    ],
112)
113
114# These flags need only be set if additional functionality beyond the fontmgr_factory flag is
115# required. For example, the setting fontmgr_factory to custom_embedded_fontmgr_factory does not
116# require setting include_fontmgr to custom_embedded_fontmgr, because those sources and settings
117# will already be compiled in due to the _factory flag.
118string_flag_with_values(
119    flag_name = "include_fontmgr",
120    multiple = True,
121    values = [
122        # Allows the construction of an SkFontMgr that loads files from a programmatically
123        # defined directory on disk.
124        "custom_directory_fontmgr",
125        # Allows the construction of an SkFontMgr which can load fonts from an SkEmbeddedResource
126        # or from another source of raw bytes.
127        "custom_embedded_fontmgr",
128        # Allows the construction of an SkFontMgr which returns empty fonts.
129        "custom_empty_fontmgr",
130    ],
131)
132
133string_flag_with_values(
134    flag_name = "include_decoder",
135    multiple = True,
136    values = [
137        "gif_decode_codec",
138        "jpeg_decode_codec",
139        "png_decode_codec",
140        "raw_decode_codec",
141        "webp_decode_codec",
142    ],
143)
144
145string_flag_with_values(
146    flag_name = "include_encoder",
147    multiple = True,
148    values = [
149        "jpeg_encode_codec",
150        "png_encode_codec",
151        "webp_encode_codec",
152    ],
153)
154
155string_flag_with_values(
156    flag_name = "shaper_backend",
157    multiple = True,
158    values = [
159        "harfbuzz_shaper",
160        "coretext_shaper",
161    ],
162)
163
164bool_flag(
165    default = False,
166    flag_name = "use_icu",
167)
168
169bool_flag(
170    default = False,
171    flag_name = "disable_tracing",
172)
173
174bool_flag(
175    default = False,
176    flag_name = "disable_effect_serialization",
177)
178
179bool_flag(
180    default = False,
181    flag_name = "is_skia_dev_build",
182)
183