Support Bazel builds on Apple silicon (#978)

* Support Bazel builds on Apple silicon

* Add sha_mac_arm64 hash for 3.1.3

* Configure node_repositories in emscripten_deps.bzl

* Add mac arm64 to bazel workspace update script

Co-authored-by: Matthew Soulanille <matthew@guppy.home>
This commit is contained in:
Matthew Soulanille
2022-02-11 11:18:16 -08:00
committed by GitHub
parent c33c7be17f
commit bc6209b6dc
5 changed files with 49 additions and 10 deletions

View File

@@ -1,5 +1,5 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@build_bazel_rules_nodejs//:index.bzl", "npm_install")
load("@build_bazel_rules_nodejs//:index.bzl", "npm_install", "node_repositories")
load(":revisions.bzl", "EMSCRIPTEN_TAGS")
def _parse_version(v):
@@ -19,16 +19,22 @@ def emscripten_deps(emscripten_version = "latest"):
revision = EMSCRIPTEN_TAGS[version]
emscripten_url = "https://storage.googleapis.com/webassembly/emscripten-releases-builds/{}/{}/wasm-binaries.{}"
emscripten_url = "https://storage.googleapis.com/webassembly/emscripten-releases-builds/{}/{}/wasm-binaries{}.{}"
# This could potentially backfire for projects with multiple emscripten
# dependencies that use different emscripten versions
excludes = native.existing_rules().keys()
if "nodejs_toolchains" not in excludes:
# Node 16 is the first version that supports darwin_arm64
node_repositories(
node_version = "16.6.2",
)
if "emscripten_bin_linux" not in excludes:
http_archive(
name = "emscripten_bin_linux",
strip_prefix = "install",
url = emscripten_url.format("linux", revision.hash, "tbz2"),
url = emscripten_url.format("linux", revision.hash, "", "tbz2"),
sha256 = revision.sha_linux,
build_file = "@emsdk//emscripten_toolchain:emscripten.BUILD",
type = "tar.bz2",
@@ -38,17 +44,27 @@ def emscripten_deps(emscripten_version = "latest"):
http_archive(
name = "emscripten_bin_mac",
strip_prefix = "install",
url = emscripten_url.format("mac", revision.hash, "tbz2"),
url = emscripten_url.format("mac", revision.hash, "", "tbz2"),
sha256 = revision.sha_mac,
build_file = "@emsdk//emscripten_toolchain:emscripten.BUILD",
type = "tar.bz2",
)
if "emscripten_bin_mac_arm64" not in excludes:
http_archive(
name = "emscripten_bin_mac_arm64",
strip_prefix = "install",
url = emscripten_url.format("mac", revision.hash, "-arm64", "tbz2"),
sha256 = revision.sha_mac_arm64,
build_file = "@emsdk//emscripten_toolchain:emscripten.BUILD",
type = "tar.bz2",
)
if "emscripten_bin_win" not in excludes:
http_archive(
name = "emscripten_bin_win",
strip_prefix = "install",
url = emscripten_url.format("win", revision.hash, "zip"),
url = emscripten_url.format("win", revision.hash, "", "zip"),
sha256 = revision.sha_win,
build_file = "@emsdk//emscripten_toolchain:emscripten.BUILD",
type = "zip",
@@ -68,6 +84,13 @@ def emscripten_deps(emscripten_version = "latest"):
package_lock_json = "@emscripten_bin_mac//:emscripten/package-lock.json",
)
if "emscripten_npm_mac_arm64" not in excludes:
npm_install(
name = "emscripten_npm_mac",
package_json = "@emscripten_bin_mac_arm64//:emscripten/package.json",
package_lock_json = "@emscripten_bin_mac_arm64//:emscripten/package-lock.json",
)
if "emscripten_npm_win" not in excludes:
npm_install(
name = "emscripten_npm_win",