1workspace(name = "skia") 2 3load("//toolchain:download_toolchains.bzl", "download_toolchains_for_skia") 4 5download_toolchains_for_skia("clang_linux_amd64", "clang_mac") 6 7load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 8 9# See https://github.com/emscripten-core/emsdk/tree/85d27a4a2a60d591613a305b14ae438c2bb3ce11/bazel#setup-instructions 10http_archive( 11 name = "emsdk", 12 sha256 = "74c7c54b3544555ec38d1e9dcc7e90b9f49ed0e04f2cc3fd44663c598af24124", 13 strip_prefix = "emsdk-3.1.15/bazel", 14 urls = [ 15 "https://github.com/emscripten-core/emsdk/archive/refs/tags/3.1.15.tar.gz", 16 "https://storage.googleapis.com/skia-world-readable/bazel/74c7c54b3544555ec38d1e9dcc7e90b9f49ed0e04f2cc3fd44663c598af24124.tar.gz", 17 ], 18) 19 20load("@emsdk//:deps.bzl", emsdk_deps = "deps") 21 22# One of the deps here is build_bazel_rules_nodejs, currently version 4.4.1 23# If we try to install it ourselves after this, it won't work. 24emsdk_deps() 25 26load("@emsdk//:emscripten_deps.bzl", emsdk_emscripten_deps = "emscripten_deps") 27 28emsdk_emscripten_deps(emscripten_version = "3.1.9") 29 30http_archive( 31 name = "bazel_skylib", 32 sha256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d", 33 urls = [ 34 "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz", 35 "https://github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz", 36 ], 37) 38 39load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") 40 41bazel_skylib_workspace() 42 43http_archive( 44 name = "bazel_toolchains", 45 sha256 = "e52789d4e89c3e2dc0e3446a9684626a626b6bec3fde787d70bae37c6ebcc47f", 46 strip_prefix = "bazel-toolchains-5.1.1", 47 urls = [ 48 "https://storage.googleapis.com/skia-world-readable/bazel/e52789d4e89c3e2dc0e3446a9684626a626b6bec3fde787d70bae37c6ebcc47f.tar.gz", 49 "https://github.com/bazelbuild/bazel-toolchains/archive/refs/tags/v5.1.1.tar.gz", 50 ], 51) 52 53load("@bazel_toolchains//repositories:repositories.bzl", bazel_toolchains_repositories = "repositories") 54 55bazel_toolchains_repositories() 56 57####################################################################################### 58# Python 59####################################################################################### 60 61# https://github.com/bazelbuild/rules_python 62http_archive( 63 name = "rules_python", 64 sha256 = "5fa3c738d33acca3b97622a13a741129f67ef43f5fdfcec63b29374cc0574c29", 65 strip_prefix = "rules_python-0.9.0", 66 urls = [ 67 "https://storage.googleapis.com/skia-world-readable/bazel/5fa3c738d33acca3b97622a13a741129f67ef43f5fdfcec63b29374cc0574c29.tar.gz", 68 "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.9.0.tar.gz", 69 ], 70) 71 72# This sets up a hermetic python3, rather than depending on what is installed. 73load("@rules_python//python:repositories.bzl", "python_register_toolchains") 74 75python_register_toolchains( 76 name = "python3_9", 77 # https://github.com/bazelbuild/rules_python/blob/main/python/versions.bzl 78 python_version = "3.9", 79) 80 81load("@python3_9//:defs.bzl", "interpreter") 82load("@rules_python//python:pip.bzl", "pip_install") 83 84pip_install( 85 name = "py_deps", 86 python_interpreter_target = interpreter, 87 requirements = "//:requirements.txt", 88) 89 90####################################################################################### 91# Maven 92####################################################################################### 93 94# https://github.com/bazelbuild/rules_jvm_external 95http_archive( 96 name = "rules_jvm_external", 97 strip_prefix = "rules_jvm_external-4.2", 98 sha256 = "cd1a77b7b02e8e008439ca76fd34f5b07aecb8c752961f9640dea15e9e5ba1ca", 99 urls = [ 100 "https://storage.googleapis.com/skia-world-readable/bazel/cd1a77b7b02e8e008439ca76fd34f5b07aecb8c752961f9640dea15e9e5ba1ca.zip", 101 "https://github.com/bazelbuild/rules_jvm_external/archive/4.2.zip", 102 ], 103) 104 105load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps") 106 107rules_jvm_external_deps() 108 109load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup") 110 111rules_jvm_external_setup() 112 113load("@rules_jvm_external//:defs.bzl", "maven_install") 114 115maven_install( 116 artifacts = [ 117 # The version released after this one (1.6.0-rc1) did not resolve unknown symbol errors when 118 # building. 119 # https://b.corp.google.com/issues/269331711 120 "androidx.annotation:annotation:1.5.0", 121 ], 122 repositories = [ 123 "https://maven.google.com", 124 "https://repo1.maven.org/maven2", 125 ], 126) 127 128####################################################################################### 129# Gazelle 130####################################################################################### 131http_archive( 132 name = "io_bazel_rules_go", 133 sha256 = "099a9fb96a376ccbbb7d291ed4ecbdfd42f6bc822ab77ae6f1b5cb9e914e94fa", 134 urls = [ 135 "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip", 136 "https://github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip", 137 ], 138) 139 140http_archive( 141 name = "bazel_gazelle", 142 sha256 = "de69a09dc70417580aabf20a28619bb3ef60d038470c7cf8442fafcf627c21cb", 143 urls = [ 144 "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz", 145 "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz", 146 ], 147) 148 149load("@io_bazel_rules_go//go:deps.bzl", "go_download_sdk", "go_register_toolchains", "go_rules_dependencies") 150load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") 151load("//:go_repositories.bzl", "go_repositories") 152 153# gazelle:repository_macro go_repositories.bzl%go_repositories 154go_repositories() 155 156go_rules_dependencies() 157 158# For our Linux RBE pool 159go_download_sdk( 160 name = "go_sdk_linux_amd64", 161 goarch = "amd64", 162 goos = "linux", 163 version = "1.18", 164) 165 166# For the host machine 167go_download_sdk( 168 name = "go_sdk", 169 version = "1.18", 170) 171 172# Do not specify a version here or it will be an error (because we 173# specified the version above when downloading SDKs) 174go_register_toolchains() 175 176gazelle_dependencies( 177 go_repository_default_config = "//:WORKSPACE.bazel", 178 go_sdk = "go_sdk", 179) 180 181# Because the skia infra repo has a dependency on google.golang.org/grpc (aka 182# @org_golang_google_grpc), we need to have this library available to build protos. 183# https://github.com/bazelbuild/rules_go#protobuf-and-grpc 184http_archive( 185 name = "com_google_protobuf", 186 sha256 = "b8ab9bbdf0c6968cf20060794bc61e231fae82aaf69d6e3577c154181991f576", 187 strip_prefix = "protobuf-3.18.1", 188 urls = [ 189 "https://storage.googleapis.com/skia-world-readable/bazel/b8ab9bbdf0c6968cf20060794bc61e231fae82aaf69d6e3577c154181991f576.tar.gz", 190 "https://github.com/protocolbuffers/protobuf/releases/download/v3.18.1/protobuf-all-3.18.1.tar.gz", 191 ], 192) 193 194load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") 195 196protobuf_deps() 197 198################################################### 199# JavaScript / TypeScript rules and dependencies. # 200################################################### 201 202# The npm_install rule runs anytime the package.json or package-lock.json file changes. It also 203# extracts any Bazel rules distributed in an npm package. 204load("@build_bazel_rules_nodejs//:index.bzl", "npm_install") 205 206# Manages the node_modules directory. 207npm_install( 208 name = "npm", 209 package_json = "//:package.json", 210 package_lock_json = "//:package-lock.json", 211) 212 213# io_bazel_rules_webtesting allows us to download browsers in a hermetic, repeatable way. This 214# currently includes Chromium and Firefox. Note that the version on this does not necessarily 215# match the version below of the browsers-X.Y.Z below that is available. 216http_archive( 217 name = "io_bazel_rules_webtesting", 218 sha256 = "e9abb7658b6a129740c0b3ef6f5a2370864e102a5ba5ffca2cea565829ed825a", 219 urls = [ 220 "https://github.com/bazelbuild/rules_webtesting/releases/download/0.3.5/rules_webtesting.tar.gz", 221 "https://storage.googleapis.com/skia-world-readable/bazel/e9abb7658b6a129740c0b3ef6f5a2370864e102a5ba5ffca2cea565829ed825a.tar.gz", 222 ], 223) 224 225# https://github.com/bazelbuild/rules_webtesting/blob/e9cf17123068b1123c68219edf9b274bf057b9cc/web/versioned/browsers-0.3.3.bzl 226load("@io_bazel_rules_webtesting//web/versioned:browsers-0.3.3.bzl", "browser_repositories") 227 228browser_repositories( 229 chromium = True, 230 firefox = True, 231) 232 233# Clients must specify their own version of skia_user_config to overwrite SkUserConfig.h 234local_repository( 235 name="skia_user_config", 236 path="include/config", 237) 238 239# Bazel will look for env variables ANDROID_HOME and ANDROID_NDK_HOME. 240# This is NOT hermetic as it requires the user to handle downloading the SDK and accepting the 241# license independently. 242android_sdk_repository(name = "androidsdk") 243# TODO: skbug.com/14128 244# Uncomment the following after setting ANDROID_NDK_HOME to build for Android: 245# android_ndk_repository(name = "androidndk") 246 247load("//bazel:deps.bzl", "git_repos_from_deps") 248 249# This are two lists of Bazel repository names, which is brought in by the following macro. 250# It is here for easier grepping, i.e. someone trying to find where a label like @brotli//:brotlidec 251# was defined. If a dep has its own BUILD rules, then one will need to go to its git repository 252# to find the BUILD or BUILD.bazel file with the rule. If a dep does not have Bazel support, then 253# that means someone on the Skia team wrote a BUILD.bazel file and put it in 254# //bazel/external/<dep_name> and one can go find it there. 255# 256#### START GENERATED LIST OF THIRD_PARTY DEPS 257# @abseil_cpp - https://skia.googlesource.com/external/github.com/abseil/abseil-cpp.git 258# @brotli - https://skia.googlesource.com/external/github.com/google/brotli.git 259# @highway - https://chromium.googlesource.com/external/github.com/google/highway.git 260# @spirv_headers - https://skia.googlesource.com/external/github.com/KhronosGroup/SPIRV-Headers.git 261# @spirv_tools - https://skia.googlesource.com/external/github.com/KhronosGroup/SPIRV-Tools.git 262# 263# @dawn - //bazel/external/dawn:BUILD.bazel 264# @dng_sdk - //bazel/external/dng_sdk:BUILD.bazel 265# @expat - //bazel/external/expat:BUILD.bazel 266# @freetype - //bazel/external/freetype:BUILD.bazel 267# @harfbuzz - //bazel/external/harfbuzz:BUILD.bazel 268# @icu - //bazel/external/icu:BUILD.bazel 269# @libavif - //bazel/external/libavif:BUILD.bazel 270# @libgav1 - //bazel/external/libgav1:BUILD.bazel 271# @libjpeg_turbo - //bazel/external/libjpeg_turbo:BUILD.bazel 272# @libjxl - //bazel/external/libjxl:BUILD.bazel 273# @libpng - //bazel/external/libpng:BUILD.bazel 274# @libwebp - //bazel/external/libwebp:BUILD.bazel 275# @libyuv - //bazel/external/libyuv:BUILD.bazel 276# @perfetto - //bazel/external/perfetto:BUILD.bazel 277# @piex - //bazel/external/piex:BUILD.bazel 278# @spirv_cross - //bazel/external/spirv_cross:BUILD.bazel 279# @vulkan_headers - //bazel/external/vulkan_headers:BUILD.bazel 280# @vulkan_tools - //bazel/external/vulkan_tools:BUILD.bazel 281# @vulkanmemoryallocator - //bazel/external/vulkanmemoryallocator:BUILD.bazel 282# @wuffs - //bazel/external/wuffs:BUILD.bazel 283# @zlib_skia - //bazel/external/zlib_skia:BUILD.bazel 284#### END GENERATED LIST OF THIRD_PARTY DEPS 285git_repos_from_deps() 286 287# In order to copy the Freetype configurations into the checked out Freetype folder, 288# it is easiest to treat them as a third-party dependency from the perspective of Freetype. 289# To do that, we put them in their own Bazel workspace and then have our injected BUILD.bazel 290# for Freetype reference this workspace. 291# https://bazel.build/reference/be/workspace#new_local_repository 292local_repository( 293 name = "freetype_config", 294 path = "bazel/external/freetype/config", 295) 296 297local_repository( 298 name = "harfbuzz_config", 299 path = "bazel/external/harfbuzz/config", 300) 301 302local_repository( 303 name = "icu_utils", 304 path = "bazel/external/icu/utils", 305) 306 307local_repository( 308 name = "expat_config", 309 path = "bazel/external/expat/config", 310) 311 312load("//bazel:cipd_install.bzl", "cipd_install") 313 314cipd_install( 315 name = "gn_linux_amd64", 316 build_file_content = """ 317exports_files( 318 ["gn"], 319 visibility = ["//visibility:public"] 320) 321""", 322 cipd_package = "gn/gn/linux-amd64", 323 # From https://chrome-infra-packages.appspot.com/p/gn/gn/linux-amd64/+/git_revision:1c4151ff5c1d6fbf7fa800b8d4bb34d3abc03a41 324 sha256 = "7195291488d08f3a10e85b85d8c4816e077015f1c5f196f770003a97aa42caf8", 325 tag = "git_revision:1c4151ff5c1d6fbf7fa800b8d4bb34d3abc03a41", 326) 327 328cipd_install( 329 name = "gn_mac_arm64", 330 build_file_content = """ 331exports_files( 332 ["gn"], 333 visibility = ["//visibility:public"] 334) 335""", 336 cipd_package = "gn/gn/mac-arm64", 337 # From https://chrome-infra-packages.appspot.com/p/gn/gn/mac-arm64/+/git_revision:1c4151ff5c1d6fbf7fa800b8d4bb34d3abc03a41 338 sha256 = "1123907ac3317530e9dd537d50cd83fd83e852aacc07d286f45753c8fc5287ed", 339 tag = "git_revision:1c4151ff5c1d6fbf7fa800b8d4bb34d3abc03a41", 340) 341 342cipd_install( 343 name = "gn_mac_amd64", 344 build_file_content = """ 345exports_files( 346 ["gn"], 347 visibility = ["//visibility:public"] 348) 349""", 350 cipd_package = "gn/gn/mac-amd64", 351 # From https://chrome-infra-packages.appspot.com/p/gn/gn/mac-amd64/+/git_revision:1c4151ff5c1d6fbf7fa800b8d4bb34d3abc03a41 352 sha256 = "ed96f7d2f49b83b016e4bdbed432e4734a5a133accb025d7c07685e01489ba93", 353 tag = "git_revision:1c4151ff5c1d6fbf7fa800b8d4bb34d3abc03a41", 354) 355