forked from google/skia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WORKSPACE.bazel
483 lines (402 loc) · 18.4 KB
/
WORKSPACE.bazel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
workspace(name = "skia")
load("//toolchain:download_toolchains.bzl", "download_toolchains_for_skia")
download_toolchains_for_skia("clang_linux_amd64", "clang_mac", "ndk_linux_amd64")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# See https://github.com/emscripten-core/emsdk/tree/85d27a4a2a60d591613a305b14ae438c2bb3ce11/bazel#setup-instructions
http_archive(
name = "emsdk",
sha256 = "74c7c54b3544555ec38d1e9dcc7e90b9f49ed0e04f2cc3fd44663c598af24124",
strip_prefix = "emsdk-3.1.15/bazel",
urls = [
"https://github.com/emscripten-core/emsdk/archive/refs/tags/3.1.15.tar.gz",
"https://storage.googleapis.com/skia-world-readable/bazel/74c7c54b3544555ec38d1e9dcc7e90b9f49ed0e04f2cc3fd44663c598af24124.tar.gz",
],
)
load("@emsdk//:deps.bzl", emsdk_deps = "deps")
# One of the deps here is build_bazel_rules_nodejs, currently version 4.4.1
# If we try to install it ourselves after this, it won't work.
emsdk_deps()
load("@emsdk//:emscripten_deps.bzl", emsdk_emscripten_deps = "emscripten_deps")
emsdk_emscripten_deps(emscripten_version = "3.1.9")
http_archive(
name = "bazel_skylib",
sha256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
],
)
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
bazel_skylib_workspace()
http_archive(
name = "bazel_toolchains",
sha256 = "e52789d4e89c3e2dc0e3446a9684626a626b6bec3fde787d70bae37c6ebcc47f",
strip_prefix = "bazel-toolchains-5.1.1",
urls = [
"https://storage.googleapis.com/skia-world-readable/bazel/e52789d4e89c3e2dc0e3446a9684626a626b6bec3fde787d70bae37c6ebcc47f.tar.gz",
"https://github.com/bazelbuild/bazel-toolchains/archive/refs/tags/v5.1.1.tar.gz",
],
)
load("@bazel_toolchains//repositories:repositories.bzl", bazel_toolchains_repositories = "repositories")
bazel_toolchains_repositories()
#######################################################################################
# Python
#######################################################################################
# https://github.com/bazelbuild/rules_python
http_archive(
name = "rules_python",
sha256 = "5fa3c738d33acca3b97622a13a741129f67ef43f5fdfcec63b29374cc0574c29",
strip_prefix = "rules_python-0.9.0",
urls = [
"https://storage.googleapis.com/skia-world-readable/bazel/5fa3c738d33acca3b97622a13a741129f67ef43f5fdfcec63b29374cc0574c29.tar.gz",
"https://github.com/bazelbuild/rules_python/archive/refs/tags/0.9.0.tar.gz",
],
)
# This sets up a hermetic python3, rather than depending on what is installed.
load("@rules_python//python:repositories.bzl", "python_register_toolchains")
python_register_toolchains(
name = "python3_9",
# https://github.com/bazelbuild/rules_python/blob/main/python/versions.bzl
python_version = "3.9",
)
load("@python3_9//:defs.bzl", "interpreter")
load("@rules_python//python:pip.bzl", "pip_install")
pip_install(
name = "py_deps",
python_interpreter_target = interpreter,
requirements = "//:requirements.txt",
)
#######################################################################################
# Maven
#######################################################################################
# https://github.com/bazelbuild/rules_jvm_external
http_archive(
name = "rules_jvm_external",
sha256 = "cd1a77b7b02e8e008439ca76fd34f5b07aecb8c752961f9640dea15e9e5ba1ca",
strip_prefix = "rules_jvm_external-4.2",
urls = [
"https://storage.googleapis.com/skia-world-readable/bazel/cd1a77b7b02e8e008439ca76fd34f5b07aecb8c752961f9640dea15e9e5ba1ca.zip",
"https://github.com/bazelbuild/rules_jvm_external/archive/4.2.zip",
],
)
load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")
rules_jvm_external_deps()
load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")
rules_jvm_external_setup()
load("@rules_jvm_external//:defs.bzl", "maven_install")
maven_install(
artifacts = [
# The version released after this one (1.6.0-rc1) did not resolve unknown symbol errors when
# building.
# https://b.corp.google.com/issues/269331711
"androidx.annotation:annotation:1.5.0",
],
repositories = [
"https://maven.google.com",
"https://repo1.maven.org/maven2",
],
)
#######################################################################################
# Gazelle
#######################################################################################
http_archive(
name = "io_bazel_rules_go",
sha256 = "099a9fb96a376ccbbb7d291ed4ecbdfd42f6bc822ab77ae6f1b5cb9e914e94fa",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip",
],
)
http_archive(
name = "bazel_gazelle",
sha256 = "ecba0f04f96b4960a5b250c8e8eeec42281035970aa8852dda73098274d14a1d",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.29.0/bazel-gazelle-v0.29.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.29.0/bazel-gazelle-v0.29.0.tar.gz",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_download_sdk", "go_register_toolchains", "go_rules_dependencies")
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
load("//:go_repositories.bzl", "go_repositories")
# gazelle:repository_macro go_repositories.bzl%go_repositories
go_repositories()
go_rules_dependencies()
# For our Linux RBE pool
go_download_sdk(
name = "go_sdk_linux_amd64",
goarch = "amd64",
goos = "linux",
version = "1.18",
)
# For the host machine
go_download_sdk(
name = "go_sdk",
version = "1.18",
)
# Do not specify a version here or it will be an error (because we
# specified the version above when downloading SDKs)
go_register_toolchains()
gazelle_dependencies(
go_repository_default_config = "//:WORKSPACE.bazel",
go_sdk = "go_sdk",
)
# Because the skia infra repo has a dependency on google.golang.org/grpc (aka
# @org_golang_google_grpc), we need to have this library available to build protos.
# https://github.com/bazelbuild/rules_go#protobuf-and-grpc
http_archive(
name = "com_google_protobuf",
sha256 = "b8ab9bbdf0c6968cf20060794bc61e231fae82aaf69d6e3577c154181991f576",
strip_prefix = "protobuf-3.18.1",
urls = [
"https://storage.googleapis.com/skia-world-readable/bazel/b8ab9bbdf0c6968cf20060794bc61e231fae82aaf69d6e3577c154181991f576.tar.gz",
"https://github.com/protocolbuffers/protobuf/releases/download/v3.18.1/protobuf-all-3.18.1.tar.gz",
],
)
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()
###################################################
# JavaScript / TypeScript rules and dependencies. #
###################################################
# The npm_install rule runs anytime the package.json or package-lock.json file changes. It also
# extracts any Bazel rules distributed in an npm package.
load("@build_bazel_rules_nodejs//:index.bzl", "npm_install")
# Manages the node_modules directory.
npm_install(
name = "npm",
package_json = "//:package.json",
package_lock_json = "//:package-lock.json",
)
# io_bazel_rules_webtesting allows us to download browsers in a hermetic, repeatable way. This
# currently includes Chromium and Firefox. Note that the version on this does not necessarily
# match the version below of the browsers-X.Y.Z below that is available.
http_archive(
name = "io_bazel_rules_webtesting",
sha256 = "e9abb7658b6a129740c0b3ef6f5a2370864e102a5ba5ffca2cea565829ed825a",
urls = [
"https://github.com/bazelbuild/rules_webtesting/releases/download/0.3.5/rules_webtesting.tar.gz",
"https://storage.googleapis.com/skia-world-readable/bazel/e9abb7658b6a129740c0b3ef6f5a2370864e102a5ba5ffca2cea565829ed825a.tar.gz",
],
)
# https://github.com/bazelbuild/rules_webtesting/blob/e9cf17123068b1123c68219edf9b274bf057b9cc/web/versioned/browsers-0.3.3.bzl
load("@io_bazel_rules_webtesting//web/versioned:browsers-0.3.3.bzl", "browser_repositories")
browser_repositories(
chromium = True,
firefox = True,
)
###################################################
# Rust rules and dependencies. #
###################################################
http_archive(
name = "rules_rust",
sha256 = "950a3ad4166ae60c8ccd628d1a8e64396106e7f98361ebe91b0bcfe60d8e4b60",
urls = [
"https://github.com/bazelbuild/rules_rust/releases/download/0.20.0/rules_rust-v0.20.0.tar.gz",
"https://storage.googleapis.com/skia-world-readable/bazel/950a3ad4166ae60c8ccd628d1a8e64396106e7f98361ebe91b0bcfe60d8e4b60.tar.gz",
],
)
load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains")
# https://github.com/bazelbuild/rules_rust/blob/eaf51386596523af4d9d5b1b5d2dcc6fe39a8465/rust/repositories.bzl#L48
rules_rust_dependencies()
rust_register_toolchains(
edition = "2021",
versions = [
# supported versions from https://github.com/bazelbuild/rules_rust/blob/dab425760656c449d3a0f73c490be92c240b6ef2/util/fetch_shas_VERSIONS.txt
# The rust rules validate a toolchain by sha256 hash, as listed in https://github.com/bazelbuild/rules_rust/blob/dab425760656c449d3a0f73c490be92c240b6ef2/rust/known_shas.bzl
"1.68.2",
],
)
# https://bazelbuild.github.io/rules_rust/crate_universe.html
load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies")
crate_universe_dependencies()
# cxxbridge-cmd is a binary only Rust crate, so we follow these instructions for it
# http://bazelbuild.github.io/rules_rust/crate_universe.html#binary-dependencies
# If we need to update this, replace the Cargo.lock files with empty (existing) files and then
# CARGO_BAZEL_REPIN=1 bazel sync --only=crate_index
http_archive(
name = "cxxbridge_cmd",
build_file = "//bazel/external/cxxbridge_cmd:BUILD.bazel.skia",
sha256 = "b20c2a31fb5a2e2aeebced19e35d78a974301171391b39e36d5ebb00bea2aa93",
strip_prefix = "cxxbridge-cmd-1.0.94",
type = "tar.gz",
urls = [
"https://crates.io/api/v1/crates/cxxbridge-cmd/1.0.94/download",
"https://storage.googleapis.com/skia-world-readable/bazel/b20c2a31fb5a2e2aeebced19e35d78a974301171391b39e36d5ebb00bea2aa93.tar.gz",
],
)
load("@rules_rust//crate_universe:defs.bzl", "crates_repository")
# This finds all the dependencies needed to build cxxbridge_cmd...
crates_repository(
name = "cxxbridge_cmd_deps",
cargo_lockfile = "//bazel/external/cxxbridge_cmd:Cargo.lock",
manifests = ["@cxxbridge_cmd//:Cargo.toml"],
)
load("@cxxbridge_cmd_deps//:defs.bzl", cxxbridge_cmd_deps = "crate_repositories")
# ... and adds them to the workspace.
cxxbridge_cmd_deps()
# The cxx crate needs a custom BUILD.bazel file because the one that would be autogenerated
# by http://bazelbuild.github.io/rules_rust/crate_universe.html#direct-packages does not work.
# Thus, we download it ourselves, as if it were a binary-only package.
http_archive(
name = "cxx",
build_file = "//bazel/external/cxx:BUILD.bazel.skia",
sha256 = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93",
strip_prefix = "cxx-1.0.94",
type = "tar.gz",
urls = [
"https://crates.io/api/v1/crates/cxx/1.0.94/download",
"https://storage.googleapis.com/skia-world-readable/bazel/f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93.tar.gz",
],
)
# This finds all the dependencies needed to build cxx...
crates_repository(
name = "cxx_deps",
cargo_lockfile = "//bazel/external/cxx:Cargo.lock",
manifests = ["@cxx//:Cargo.toml"],
)
load("@cxx_deps//:defs.bzl", cxx_deps = "crate_repositories")
# ... and adds them to the workspace.
cxx_deps()
# The fontations repository consists of multiple crates. We download those
# listed in the external/fontations/Cargo.* files.
# Add this entry to have a root repository from which the individual
# fontations crates can be fetched.
# This allows them to be used as deps in other bazel targets.
crates_repository(
name = "fontations",
cargo_lockfile = "//bazel/external/fontations:Cargo.lock",
manifests = ["//bazel/external/fontations:Cargo.toml"],
)
load("@fontations//:defs.bzl", fontations_crates = "crate_repositories")
fontations_crates()
# Skia uses crates from the vello repository that are under development and have not been published
# to crates.io. Normally we could fetch them directly from the git mirror in the Cargo.lock file as
# Bazel supports compiling them without any custom build rules. However, since Bazel's repository
# rules don't play well with the vello_shader crate's build script, we compile the vello
# crates from source using the rules defined in bazel/external/vello/BUILD.bazel and the
# new_git_repository rule.
#
# vello_deps contains the dependencies of the two crates we build out of the vello repo (namely
# vello_shaders and vello_encoding).
#
# See comments in bazel/external/vello/BUILD.bazel for more information.
crates_repository(
name = "vello_deps",
cargo_lockfile = "//bazel/external/vello:Cargo.lock",
manifests = ["//bazel/external/vello:Cargo.toml"],
)
load("@vello_deps//:defs.bzl", vello_deps = "crate_repositories")
vello_deps()
###############################################################
# Bazel will look for env variables ANDROID_HOME and ANDROID_NDK_HOME.
# This is NOT hermetic as it requires the user to handle downloading the SDK and accepting the
# license independently.
android_sdk_repository(name = "androidsdk")
# TODO: skbug.com/14128
# Uncomment the following after setting ANDROID_NDK_HOME to build for Android:
# android_ndk_repository(name = "androidndk")
# Clients must specify their own version of skia_user_config to overwrite SkUserConfig.h
local_repository(
name = "skia_user_config",
path = "include/config",
)
load("//bazel:deps.bzl", "git_repos_from_deps")
# This are two lists of Bazel repository names, which is brought in by the following macro.
# It is here for easier grepping, i.e. someone trying to find where a label like @brotli//:brotlidec
# was defined. If a dep has its own BUILD rules, then one will need to go to its git repository
# to find the BUILD or BUILD.bazel file with the rule. If a dep does not have Bazel support, then
# that means someone on the Skia team wrote a BUILD.bazel file and put it in
# //bazel/external/<dep_name> and one can go find it there.
#
#### START GENERATED LIST OF THIRD_PARTY DEPS
# @abseil_cpp - https://skia.googlesource.com/external/github.com/abseil/abseil-cpp.git
# @brotli - https://skia.googlesource.com/external/github.com/google/brotli.git
# @highway - https://chromium.googlesource.com/external/github.com/google/highway.git
# @spirv_headers - https://skia.googlesource.com/external/github.com/KhronosGroup/SPIRV-Headers.git
# @spirv_tools - https://skia.googlesource.com/external/github.com/KhronosGroup/SPIRV-Tools.git
#
# @dawn - //bazel/external/dawn:BUILD.bazel
# @dng_sdk - //bazel/external/dng_sdk:BUILD.bazel
# @expat - //bazel/external/expat:BUILD.bazel
# @freetype - //bazel/external/freetype:BUILD.bazel
# @harfbuzz - //bazel/external/harfbuzz:BUILD.bazel
# @icu - //bazel/external/icu:BUILD.bazel
# @imgui - //bazel/external/imgui:BUILD.bazel
# @libavif - //bazel/external/libavif:BUILD.bazel
# @libgav1 - //bazel/external/libgav1:BUILD.bazel
# @libjpeg_turbo - //bazel/external/libjpeg_turbo:BUILD.bazel
# @libjxl - //bazel/external/libjxl:BUILD.bazel
# @libpng - //bazel/external/libpng:BUILD.bazel
# @libwebp - //bazel/external/libwebp:BUILD.bazel
# @libyuv - //bazel/external/libyuv:BUILD.bazel
# @perfetto - //bazel/external/perfetto:BUILD.bazel
# @piex - //bazel/external/piex:BUILD.bazel
# @spirv_cross - //bazel/external/spirv_cross:BUILD.bazel
# @vello - //bazel/external/vello:BUILD.bazel
# @vulkan_headers - //bazel/external/vulkan_headers:BUILD.bazel
# @vulkan_tools - //bazel/external/vulkan_tools:BUILD.bazel
# @vulkanmemoryallocator - //bazel/external/vulkanmemoryallocator:BUILD.bazel
# @wuffs - //bazel/external/wuffs:BUILD.bazel
# @zlib_skia - //bazel/external/zlib_skia:BUILD.bazel
#### END GENERATED LIST OF THIRD_PARTY DEPS
git_repos_from_deps()
# In order to copy the Freetype configurations into the checked out Freetype folder,
# it is easiest to treat them as a third-party dependency from the perspective of Freetype.
# To do that, we put them in their own Bazel workspace and then have our injected BUILD.bazel
# for Freetype reference this workspace.
# https://bazel.build/reference/be/workspace#new_local_repository
local_repository(
name = "freetype_config",
path = "bazel/external/freetype/config",
)
local_repository(
name = "harfbuzz_config",
path = "bazel/external/harfbuzz/config",
)
local_repository(
name = "icu_utils",
path = "bazel/external/icu/utils",
)
local_repository(
name = "expat_config",
path = "bazel/external/expat/config",
)
load("//bazel:cipd_install.bzl", "cipd_install")
cipd_install(
name = "gn_linux_amd64",
build_file_content = """
exports_files(
["gn"],
visibility = ["//visibility:public"]
)
""",
cipd_package = "gn/gn/linux-amd64",
# From https://chrome-infra-packages.appspot.com/p/gn/gn/linux-amd64/+/git_revision:1c4151ff5c1d6fbf7fa800b8d4bb34d3abc03a41
sha256 = "7195291488d08f3a10e85b85d8c4816e077015f1c5f196f770003a97aa42caf8",
tag = "git_revision:1c4151ff5c1d6fbf7fa800b8d4bb34d3abc03a41",
)
cipd_install(
name = "gn_mac_arm64",
build_file_content = """
exports_files(
["gn"],
visibility = ["//visibility:public"]
)
""",
cipd_package = "gn/gn/mac-arm64",
# From https://chrome-infra-packages.appspot.com/p/gn/gn/mac-arm64/+/git_revision:1c4151ff5c1d6fbf7fa800b8d4bb34d3abc03a41
sha256 = "1123907ac3317530e9dd537d50cd83fd83e852aacc07d286f45753c8fc5287ed",
tag = "git_revision:1c4151ff5c1d6fbf7fa800b8d4bb34d3abc03a41",
)
cipd_install(
name = "gn_mac_amd64",
build_file_content = """
exports_files(
["gn"],
visibility = ["//visibility:public"]
)
""",
cipd_package = "gn/gn/mac-amd64",
# From https://chrome-infra-packages.appspot.com/p/gn/gn/mac-amd64/+/git_revision:1c4151ff5c1d6fbf7fa800b8d4bb34d3abc03a41
sha256 = "ed96f7d2f49b83b016e4bdbed432e4734a5a133accb025d7c07685e01489ba93",
tag = "git_revision:1c4151ff5c1d6fbf7fa800b8d4bb34d3abc03a41",
)