Bazel: Migrate to bzlmod (#1530)

This migrates the bazel integration to the new Bazel dependency system
"bzlmod". bzlmod is becoming mandatory this year (see second sentence
here: https://bazel.build/external/migration).

This is a backwards incompatible migration, directly removing the old
WORKSPACE based approach. Users will have to change how they depend on
bzlmod, however I assume pretty much every user will be happy about it,
because they are forced to use bzlmod anyway or add extra flags to
continue to build with newer Bazel versions. Given that users normally
depend on specific git commits in the old system, they won't be hit with
this until they decide to upgrade emsdk.

The basic principle here is simple: I took everything that WORKSPACE did
and searched an alternative in bzlmod. Some interesting bits:

- We have less worries about multiple versions and people depending on
emscripten multiple times in different ways. This is resolved by the new
system: Bazel first iterates through the MODULE.bazel files recursively,
then finds the minimum version needed for each module and then executes
the module extensions that define repos exactly once at that version. So
no more ifs needed to detect multiple inclusions.
- A bunch of nodejs stuff moves to MODULE.bazel, because that is how the
nodejs module works now. As their module extension gets executed only
once you need to declare everything that you could need before that in
the MODULE.bazel file. A side effect of that is that we have to make a
fake repository when emscripten doesn't have an arm64 binary for linux,
because we can't actually figure that out in MODULE.bazel, so we have to
declare that it always exists and then create one in all cases.

There is a bunch of autoformatter changes in here as well, I could try
to revert them if you prefer.

Closes #1509
This commit is contained in:
Conrad Burchert
2025-04-09 23:38:12 +02:00
committed by GitHub
parent 24fc909c0d
commit ed2035a3cc
28 changed files with 11776 additions and 595 deletions

View File

@@ -38,6 +38,39 @@ commands:
command: | command: |
source emsdk_env.sh source emsdk_env.sh
test/test.py test/test.py
test-bazel-linux:
steps:
- checkout
- run:
name: install bazelisk
command: |
wget https://github.com/bazelbuild/bazelisk/releases/download/v1.25.0/bazelisk-linux-amd64
chmod +x bazelisk-linux-amd64
mv bazelisk-linux-amd64 /usr/local/bin/bazel
- run: test/test_bazel.sh
test-bazel-mac:
steps:
- checkout
- run:
name: install bazelisk
command: |
brew install bazelisk
- run: test/test_bazel_mac.sh
test-bazel-windows:
steps:
- checkout
- run:
name: Download Bazelisk
shell: powershell.exe
command: |
$ProgressPreference = "SilentlyContinue"
Invoke-WebRequest -Uri https://github.com/bazelbuild/bazelisk/releases/download/v1.10.1/bazelisk-windows-amd64.exe -OutFile ( New-Item -Path "temp\bazel\bazel.exe" -Force )
- run:
name: Run Tests
shell: powershell.exe
command: |
$env:Path += ";C:\Python27amd64;$pwd\temp\bazel"
.\test\test_bazel.ps1
jobs: jobs:
flake8: flake8:
@@ -223,60 +256,52 @@ jobs:
docker login -u "$DOCKER_USER" -p "$DOCKER_PASS" docker login -u "$DOCKER_USER" -p "$DOCKER_PASS"
make -C ./docker version=${CIRCLE_TAG} alias=${CIRCLE_TAG}-arm64 only_alias=true push make -C ./docker version=${CIRCLE_TAG} alias=${CIRCLE_TAG}-arm64 only_alias=true push
test-bazel-linux: test-bazel7-linux:
executor: ubuntu
environment:
USE_BAZEL_VERSION: "7.x"
steps:
- test-bazel-linux
test-bazel-latest-linux:
executor: ubuntu executor: ubuntu
steps: steps:
- checkout - test-bazel-linux
- run: apt-get install -q -y curl gnupg
- run: curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg
- run: mv bazel.gpg /etc/apt/trusted.gpg.d/
- run: echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list
- run:
name: install pip
command: |
apt-get update -q
apt-get install -q -y python3-pip
- run: pip3 install absl-py
- run:
name: install bazel
command: |
apt-get install -q -y bazel-7.4.1
- run: test/test_bazel.sh
test-bazel-mac-arm64: test-bazel7-mac-arm64:
executor: mac_arm64 executor: mac_arm64
environment: environment:
USE_BAZEL_VERSION: "7.4.1" USE_BAZEL_VERSION: "7.x"
steps: steps:
- checkout - test-bazel-mac
- run:
name: install bazelisk
command: |
brew install bazelisk
- run: test/test_bazel_mac.sh
test-bazel-windows: test-bazel-latest-mac-arm64:
executor: mac_arm64
steps:
- test-bazel-mac
test-bazel7-windows:
executor: executor:
name: win/server-2019 name: win/server-2019
shell: powershell.exe -ExecutionPolicy Bypass shell: powershell.exe -ExecutionPolicy Bypass
environment: environment:
PYTHONUNBUFFERED: "1" PYTHONUNBUFFERED: "1"
EMSDK_NOTTY: "1" EMSDK_NOTTY: "1"
USE_BAZEL_VERSION: "5.4.0" # For some reason version resolution with "7.x" does not work on Windows,
# so we have to specify a full version.
USE_BAZEL_VERSION: "7.6.1"
steps: steps:
- checkout - test-bazel-windows
- run:
name: Download Bazelisk test-bazel-latest-windows:
shell: powershell.exe executor:
command: | name: win/server-2019
$ProgressPreference = "SilentlyContinue" shell: powershell.exe -ExecutionPolicy Bypass
Invoke-WebRequest -Uri https://github.com/bazelbuild/bazelisk/releases/download/v1.10.1/bazelisk-windows-amd64.exe -OutFile ( New-Item -Path "temp\bazel\bazel.exe" -Force ) environment:
- run: PYTHONUNBUFFERED: "1"
name: Run Tests EMSDK_NOTTY: "1"
shell: powershell.exe steps:
command: | - test-bazel-windows
$env:Path += ";C:\Python27amd64;$pwd\temp\bazel"
.\test\test_bazel.ps1
workflows: workflows:
flake8: flake8:
@@ -309,12 +334,21 @@ workflows:
ignore: /.*/ ignore: /.*/
tags: tags:
only: /.*/ only: /.*/
test-bazel-linux: test-bazel7-linux:
jobs: jobs:
- test-bazel-linux - test-bazel7-linux
test-bazel-mac-arm64: test-bazel-latest-linux:
jobs: jobs:
- test-bazel-mac-arm64 - test-bazel-latest-linux
test-bazel-windows: test-bazel7-mac-arm64:
jobs: jobs:
- test-bazel-windows - test-bazel7-mac-arm64
test-bazel-latest-mac-arm64:
jobs:
- test-bazel-latest-mac-arm64
test-bazel7-windows:
jobs:
- test-bazel7-windows
test-bazel-latest-windows:
jobs:
- test-bazel-latest-windows

View File

@@ -1,83 +1,7 @@
package(default_visibility = ["//visibility:public"]) package(default_visibility = ["//visibility:public"])
config_setting(
name = "linux",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
],
)
config_setting(
name = "linux_arm64",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:arm64",
],
)
config_setting(
name = "macos",
constraint_values = [
"@platforms//os:macos",
"@platforms//cpu:x86_64",
],
)
config_setting(
name = "macos_arm64",
constraint_values = [
"@platforms//os:macos",
"@platforms//cpu:arm64",
],
)
config_setting(
name = "windows",
constraint_values = [
"@platforms//os:windows",
"@platforms//cpu:x86_64",
],
)
filegroup(name = "empty") filegroup(name = "empty")
alias(
name = "compiler_files",
actual = select({
":linux": "@emscripten_bin_linux//:compiler_files",
":linux_arm64": "@emscripten_bin_linux_arm64//:compiler_files",
":macos": "@emscripten_bin_mac//:compiler_files",
":macos_arm64": "@emscripten_bin_mac_arm64//:compiler_files",
":windows": "@emscripten_bin_win//:compiler_files",
"//conditions:default": ":empty",
}),
)
alias(
name = "linker_files",
actual = select({
":linux": "@emscripten_bin_linux//:linker_files",
":linux_arm64": "@emscripten_bin_linux_arm64//:linker_files",
":macos": "@emscripten_bin_mac//:linker_files",
":macos_arm64": "@emscripten_bin_mac_arm64//:linker_files",
":windows": "@emscripten_bin_win//:linker_files",
"//conditions:default": ":empty",
}),
)
alias(
name = "ar_files",
actual = select({
":linux": "@emscripten_bin_linux//:ar_files",
":linux_arm64": "@emscripten_bin_linux_arm64//:ar_files",
":macos": "@emscripten_bin_mac//:ar_files",
":macos_arm64": "@emscripten_bin_mac_arm64//:ar_files",
":windows": "@emscripten_bin_win//:ar_files",
"//conditions:default": ":empty",
}),
)
platform( platform(
name = "platform_wasm", name = "platform_wasm",
constraint_values = [ constraint_values = [

View File

@@ -1 +1,79 @@
bazel_dep(name = "platforms", version = "0.0.9") module(
name = "emsdk",
version = "4.0.6",
)
bazel_dep(name = "platforms", version = "0.0.11")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "aspect_rules_js", version = "1.42.0")
bazel_dep(name = "rules_nodejs", version = "6.3.2")
bazel_dep(name = "rules_cc", version = "0.1.1")
bazel_dep(name = "rules_python", version = "1.3.0")
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
python_version = "3.13",
)
node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node")
node.toolchain(node_version = "20.18.0")
use_repo(node, "nodejs")
emscripten_deps = use_extension(
"//:emscripten_deps.bzl",
"emscripten_deps",
)
use_repo(emscripten_deps, "emscripten_bin_linux")
use_repo(emscripten_deps, "emscripten_bin_linux_arm64")
use_repo(emscripten_deps, "emscripten_bin_mac")
use_repo(emscripten_deps, "emscripten_bin_mac_arm64")
use_repo(emscripten_deps, "emscripten_bin_win")
npm = use_extension(
"@aspect_rules_js//npm:extensions.bzl",
"npm",
)
npm.npm_translate_lock(
name = "emscripten_npm_linux",
data = ["@emscripten_bin_linux//:emscripten/package.json"],
npm_package_lock = "@emscripten_bin_linux//:emscripten/package-lock.json",
)
npm.npm_translate_lock(
name = "emscripten_npm_linux_arm64",
data = ["@emscripten_bin_linux_arm64//:emscripten/package.json"],
npm_package_lock = "@emscripten_bin_linux_arm64//:emscripten/package-lock.json",
)
npm.npm_translate_lock(
name = "emscripten_npm_mac",
data = ["@emscripten_bin_mac//:emscripten/package.json"],
npm_package_lock = "@emscripten_bin_mac//:emscripten/package-lock.json",
)
npm.npm_translate_lock(
name = "emscripten_npm_mac_arm64",
data = ["@emscripten_bin_mac_arm64//:emscripten/package.json"],
npm_package_lock = "@emscripten_bin_mac_arm64//:emscripten/package-lock.json",
)
npm.npm_translate_lock(
name = "emscripten_npm_win",
data = ["@emscripten_bin_win//:emscripten/package.json"],
npm_package_lock = "@emscripten_bin_win//:emscripten/package-lock.json",
)
use_repo(
npm,
"emscripten_npm_linux",
"emscripten_npm_linux_arm64",
"emscripten_npm_mac",
"emscripten_npm_mac_arm64",
"emscripten_npm_win",
)
emscripten_cache = use_extension("//:emscripten_cache.bzl", "emscripten_cache")
use_repo(emscripten_cache, "emscripten_cache")
register_toolchains(
"//emscripten_toolchain:cc-toolchain-wasm-emscripten_linux",
"//emscripten_toolchain:cc-toolchain-wasm-emscripten_linux_arm64",
"//emscripten_toolchain:cc-toolchain-wasm-emscripten_mac",
"//emscripten_toolchain:cc-toolchain-wasm-emscripten_mac_arm64",
"//emscripten_toolchain:cc-toolchain-wasm-emscripten_win",
)

3696
bazel/MODULE.bazel.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -2,35 +2,29 @@
## Setup Instructions ## Setup Instructions
In `WORKSPACE` file, put: Support for depending on emsdk with a WORKSPACE file was removed and last available in [emsdk version 4.0.6](https://github.com/emscripten-core/emsdk/tree/24fc909c0da13ef641d5ae75e89b5a97f25e37aa). Now we only support inclusion as a bzlmod module.
In your `MODULE.bazel` file, put:
```starlark ```starlark
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") emsdk_version = "4.0.6"
git_repository( bazel_dep(name = "emsdk", version = emsdk_version)
name = "emsdk", git_override(
module_name = "emsdk",
remote = "https://github.com/emscripten-core/emsdk.git", remote = "https://github.com/emscripten-core/emsdk.git",
tag = "3.1.64",
strip_prefix = "bazel", strip_prefix = "bazel",
tag = emsdk_version,
) )
load("@emsdk//:deps.bzl", emsdk_deps = "deps")
emsdk_deps()
load("@emsdk//:emscripten_deps.bzl", emsdk_emscripten_deps = "emscripten_deps")
emsdk_emscripten_deps(emscripten_version = "3.1.64")
load("@emsdk//:toolchains.bzl", "register_emscripten_toolchains")
register_emscripten_toolchains()
```
The `tag` and `emscripten_version` parameters correspond to the git revision of
[emsdk 3.1.64](https://github.com/emscripten-core/emsdk/releases/tag/3.1.64). To get access to
newer versions, you'll need to update those. To make use of older versions, change the
parameter of `git_repository` and `emsdk_emscripten_deps()`. Supported versions are listed in `revisions.bzl`
Bazel 7+ additionally requires `platforms` dependencies in the `MODULE.bazel` file.
```starlark
bazel_dep(name = "platforms", version = "0.0.9")
``` ```
You can use a different version of this SDK by changing it in your `MODULE.bazel` file. The Emscripten version is by default the same as the SDK version, but you can use a different one as well by adding to your `MODULE.bazel`:
```
emscripten_deps = use_extension(
"@emsdk//:emscripten_deps.bzl",
"emscripten_deps",
)
emscripten_deps.config(version = "4.0.1")
```
## Building ## Building
@@ -68,28 +62,29 @@ is the preferred way, since it also unpacks the resulting tarball.
The Emscripten cache shipped by default does not include LTO, 64-bit or PIC The Emscripten cache shipped by default does not include LTO, 64-bit or PIC
builds of the system libraries and ports. If you wish to use these features you builds of the system libraries and ports. If you wish to use these features you
will need to declare the cache when you register the toolchain as follows. Note will need to declare the cache in your `MODULE.bazel` as follows. Note
that the configuration consists of the same flags that can be passed to that the configuration consists of the same flags that can be passed to
embuilder. If `targets` is not provided, all system libraries and ports will be embuilder. If `targets` is not set, all system libraries and ports will be
built, i.e., the `ALL` option to embuilder. built, i.e., the `ALL` option to embuilder.
```starlark ```starlark
load("@emsdk//:toolchains.bzl", "register_emscripten_toolchains") emscripten_cache = use_extension(
register_emscripten_toolchains(cache = { "@emsdk//:emscripten_cache.bzl",
"configuration": ["--lto"], "emscripten_cache",
"targets": [ )
"crtbegin", emscripten_cache.configuration(flags = ["--lto"])
"libprintf_long_double-debug", emscripten_cache.targets(targets = [
"libstubs-debug", "crtbegin",
"libnoexit", "libprintf_long_double-debug",
"libc-debug", "libstubs-debug",
"libdlmalloc", "libnoexit",
"libcompiler_rt", "libc-debug",
"libc++-noexcept", "libdlmalloc",
"libc++abi-debug-noexcept", "libcompiler_rt",
"libsockets" "libc++-noexcept",
] "libc++abi-debug-noexcept",
}) "libsockets"
])
``` ```
See `test_external/` for an example using [embind](https://emscripten.org/docs/porting/connecting_cpp_and_javascript/embind.html). See `test_external/` for an example using [embind](https://emscripten.org/docs/porting/connecting_cpp_and_javascript/embind.html).

View File

@@ -1,13 +0,0 @@
workspace(name = "emsdk")
load(":deps.bzl", "deps")
deps()
load(":emscripten_deps.bzl", "emscripten_deps")
emscripten_deps()
load(":toolchains.bzl", "register_emscripten_toolchains")
register_emscripten_toolchains()

View File

@@ -1,52 +0,0 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
def deps():
maybe(
http_archive,
name = "platforms",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.9/platforms-0.0.9.tar.gz",
"https://github.com/bazelbuild/platforms/releases/download/0.0.9/platforms-0.0.9.tar.gz",
],
sha256 = "5eda539c841265031c2f82d8ae7a3a6490bd62176e0c038fc469eabf91f6149b",
)
maybe(
http_archive,
name = "bazel_skylib",
sha256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d",
urls = [
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
],
)
maybe(
http_archive,
name = "aspect_rules_js",
strip_prefix = "rules_js-1.42.0",
sha256 = "5a00869efaeb308245f8132a671fe86524bdfc4f8bfd1976d26f862b316dc3c9",
urls = ["https://github.com/aspect-build/rules_js/releases/download/v1.42.0/rules_js-v1.42.0.tar.gz"],
)
# Transitive dependencies of aspect_rules_js. We explicitly pull them here instead of calling their
# provided function to avoid requiring a call to rules_js_dependencies in WORKSPACE.
maybe(
http_archive,
name = "aspect_bazel_lib",
sha256 = "714cf8ce95a198bab0a6a3adaffea99e929d2f01bf6d4a59a2e6d6af72b4818c",
strip_prefix = "bazel-lib-2.7.8",
url = "https://github.com/aspect-build/bazel-lib/releases/download/v2.7.8/bazel-lib-v2.7.8.tar.gz",
)
maybe(
http_archive,
name = "rules_nodejs",
strip_prefix = "rules_nodejs-6.3.2",
sha256 = "158619723f1d8bd535dd6b93521f4e03cf24a5e107126d05685fbd9540ccad10",
urls = ["https://github.com/bazel-contrib/rules_nodejs/releases/download/v6.3.2/rules_nodejs-v6.3.2.tar.gz"],
)
http_archive(
name = "bazel_features",
sha256 = "f3082bfcdca73dc77dcd68faace806135a2e08c230b02b1d9fbdbd7db9d9c450",
strip_prefix = "bazel_features-0.1.0",
url = "https://github.com/bazel-contrib/bazel_features/releases/download/v0.1.0/bazel_features-v0.1.0.tar.gz",
)

View File

@@ -0,0 +1,93 @@
"""A templated build file for emscripten repositories"""
EMSCRIPTEN_BUILD_FILE_CONTENT_TEMPLATE = """
package(default_visibility = ['//visibility:public'])
filegroup(
name = "all",
srcs = glob(["**"]),
)
filegroup(
name = "includes",
srcs = glob([
"emscripten/cache/sysroot/include/c++/v1/**",
"emscripten/cache/sysroot/include/compat/**",
"emscripten/cache/sysroot/include/**",
"lib/clang/**/include/**",
]),
)
filegroup(
name = "emcc_common",
srcs = [
"emscripten/emcc.py",
"emscripten/embuilder.py",
"emscripten/emscripten-version.txt",
"emscripten/cache/sysroot_install.stamp",
"emscripten/src/settings.js",
"emscripten/src/settings_internal.js",
] + glob(
include = [
"emscripten/third_party/**",
"emscripten/tools/**",
],
exclude = [
"**/__pycache__/**",
],
),
)
filegroup(
name = "compiler_files",
srcs = [
"bin/clang{bin_extension}",
"bin/clang++{bin_extension}",
":emcc_common",
":includes",
],
)
filegroup(
name = "linker_files",
srcs = [
"bin/clang{bin_extension}",
"bin/llvm-ar{bin_extension}",
"bin/llvm-dwarfdump{bin_extension}",
"bin/llvm-nm{bin_extension}",
"bin/llvm-objcopy{bin_extension}",
"bin/wasm-ctor-eval{bin_extension}",
"bin/wasm-emscripten-finalize{bin_extension}",
"bin/wasm-ld{bin_extension}",
"bin/wasm-metadce{bin_extension}",
"bin/wasm-opt{bin_extension}",
"bin/wasm-split{bin_extension}",
"bin/wasm2js{bin_extension}",
":emcc_common",
] + glob(
include = [
"emscripten/cache/sysroot/lib/**",
"emscripten/node_modules/**",
"emscripten/src/**",
],
),
)
filegroup(
name = "ar_files",
srcs = [
"bin/llvm-ar{bin_extension}",
"emscripten/emar.py",
"emscripten/emscripten-version.txt",
"emscripten/src/settings.js",
"emscripten/src/settings_internal.js",
] + glob(
include = [
"emscripten/tools/**",
],
exclude = [
"**/__pycache__/**",
],
),
)
"""

View File

@@ -10,46 +10,48 @@ LLVM_ROOT = '{llvm_root}'
""" """
def get_root_and_script_ext(repository_ctx): def get_root_and_script_ext(repository_ctx):
if repository_ctx.os.name.startswith('linux'): if repository_ctx.os.name.startswith("linux"):
if 'amd64' in repository_ctx.os.arch or 'x86_64' in repository_ctx.os.arch: if "amd64" in repository_ctx.os.arch or "x86_64" in repository_ctx.os.arch:
return (repository_ctx.path(Label("@emscripten_bin_linux//:BUILD.bazel")).dirname, '') return (repository_ctx.path(Label("@emscripten_bin_linux//:BUILD.bazel")).dirname, "")
elif 'aarch64' in repository_ctx.os.arch: elif "aarch64" in repository_ctx.os.arch:
return (repository_ctx.path(Label("@emscripten_bin_linux_arm64//:BUILD.bazel")).dirname, '') return (repository_ctx.path(Label("@emscripten_bin_linux_arm64//:BUILD.bazel")).dirname, "")
else: else:
fail('Unsupported architecture for Linux') fail("Unsupported architecture for Linux")
elif repository_ctx.os.name.startswith('mac'): elif repository_ctx.os.name.startswith("mac"):
if 'amd64' in repository_ctx.os.arch or 'x86_64' in repository_ctx.os.arch: if "amd64" in repository_ctx.os.arch or "x86_64" in repository_ctx.os.arch:
return (repository_ctx.path(Label("@emscripten_bin_mac//:BUILD.bazel")).dirname, '') return (repository_ctx.path(Label("@emscripten_bin_mac//:BUILD.bazel")).dirname, "")
elif 'aarch64' in repository_ctx.os.arch: elif "aarch64" in repository_ctx.os.arch:
return (repository_ctx.path(Label("@emscripten_bin_mac_arm64//:BUILD.bazel")).dirname, '') return (repository_ctx.path(Label("@emscripten_bin_mac_arm64//:BUILD.bazel")).dirname, "")
else: else:
fail('Unsupported architecture for MacOS') fail("Unsupported architecture for MacOS")
elif repository_ctx.os.name.startswith('windows'): elif repository_ctx.os.name.startswith("windows"):
return (repository_ctx.path(Label("@emscripten_bin_win//:BUILD.bazel")).dirname, '.bat') return (repository_ctx.path(Label("@emscripten_bin_win//:BUILD.bazel")).dirname, ".bat")
else: else:
fail('Unsupported operating system') fail("Unsupported operating system")
def _emscripten_cache_impl(repository_ctx): def _emscripten_cache_repository_impl(repository_ctx):
# Read the default emscripten configuration file # Read the default emscripten configuration file
default_config = repository_ctx.read( default_config = repository_ctx.read(
repository_ctx.path( repository_ctx.path(
Label("@emsdk//emscripten_toolchain:default_config") Label("@emsdk//emscripten_toolchain:default_config"),
) ),
) )
if repository_ctx.attr.targets or repository_ctx.attr.configuration: if repository_ctx.attr.targets or repository_ctx.attr.configuration:
root, script_ext = get_root_and_script_ext(repository_ctx) root, script_ext = get_root_and_script_ext(repository_ctx)
llvm_root = root.get_child("bin") llvm_root = root.get_child("bin")
cache = repository_ctx.path("cache") cache = repository_ctx.path("cache")
# Create configuration file # Create configuration file
embuilder_config_content = EMBUILDER_CONFIG_TEMPLATE.format( embuilder_config_content = EMBUILDER_CONFIG_TEMPLATE.format(
cache=cache, cache = cache,
binaryen_root=root, binaryen_root = root,
llvm_root=llvm_root, llvm_root = llvm_root,
) )
repository_ctx.file("embuilder_config", embuilder_config_content) repository_ctx.file("embuilder_config", embuilder_config_content)
embuilder_config_path = repository_ctx.path("embuilder_config") embuilder_config_path = repository_ctx.path("embuilder_config")
embuilder_path = "{}{}".format(root.get_child("emscripten").get_child("embuilder"), script_ext) embuilder_path = "{}{}".format(root.get_child("emscripten").get_child("embuilder"), script_ext)
# Prepare the command line # Prepare the command line
if repository_ctx.attr.targets: if repository_ctx.attr.targets:
targets = repository_ctx.attr.targets targets = repository_ctx.attr.targets
@@ -58,38 +60,54 @@ def _emscripten_cache_impl(repository_ctx):
targets = ["ALL"] targets = ["ALL"]
flags = ["--em-config", embuilder_config_path] + repository_ctx.attr.configuration flags = ["--em-config", embuilder_config_path] + repository_ctx.attr.configuration
embuilder_args = [embuilder_path] + flags + ["build"] + targets embuilder_args = [embuilder_path] + flags + ["build"] + targets
# Run embuilder # Run embuilder
repository_ctx.report_progress("Building secondary cache") repository_ctx.report_progress("Building secondary cache")
result = repository_ctx.execute( result = repository_ctx.execute(
embuilder_args, embuilder_args,
quiet=True, quiet = True,
environment = { environment = {
"EM_IGNORE_SANITY": "1", "EM_IGNORE_SANITY": "1",
"EM_NODE_JS": "empty", "EM_NODE_JS": "empty",
} },
) )
if result.return_code != 0: if result.return_code != 0:
fail("Embuilder exited with a non-zero return code") fail("Embuilder exited with a non-zero return code")
# Override Emscripten's cache with the secondary cache # Override Emscripten's cache with the secondary cache
default_config += "CACHE = '{}'\n".format(cache) default_config += "CACHE = '{}'\n".format(cache)
# Create the configuration file for the toolchain and export # Create the configuration file for the toolchain and export
repository_ctx.file('emscripten_config', default_config) repository_ctx.file("emscripten_config", default_config)
repository_ctx.file('BUILD.bazel', BUILD_FILE_CONTENT_TEMPLATE) repository_ctx.file("BUILD.bazel", BUILD_FILE_CONTENT_TEMPLATE)
_emscripten_cache = repository_rule( _emscripten_cache_repository = repository_rule(
implementation = _emscripten_cache_impl, implementation = _emscripten_cache_repository_impl,
attrs = { attrs = {
"configuration": attr.string_list(), "configuration": attr.string_list(),
"targets": attr.string_list(), "targets": attr.string_list(),
}, },
) )
def register_emscripten_toolchains(cache = {}): def _emscripten_cache_impl(ctx):
_emscripten_cache( all_configuration = []
all_targets = []
for mod in ctx.modules:
for configuration in mod.tags.configuration:
all_configuration += configuration.flags
for targets in mod.tags.targets:
all_targets += targets.targets
_emscripten_cache_repository(
name = "emscripten_cache", name = "emscripten_cache",
configuration = cache["configuration"] if "configuration" in cache else [], configuration = all_configuration,
targets = cache["targets"] if "targets" in cache else [], targets = all_targets,
) )
native.register_toolchains(str(Label("//emscripten_toolchain:cc-toolchain-wasm"))) emscripten_cache = module_extension(
tag_classes = {
"configuration": tag_class(attrs = {"flags": attr.string_list()}),
"targets": tag_class(attrs = {"targets": attr.string_list()}),
},
implementation = _emscripten_cache_impl,
)

View File

@@ -1,210 +1,99 @@
load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") load(":remote_emscripten_repository.bzl", "remote_emscripten_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains")
load(":revisions.bzl", "EMSCRIPTEN_TAGS") load(":revisions.bzl", "EMSCRIPTEN_TAGS")
def _parse_version(v): def _parse_version(v):
return [int(u) for u in v.split(".")] return [int(u) for u in v.split(".")]
BUILD_FILE_CONTENT_TEMPLATE = """ def _empty_repository_impl(ctx):
package(default_visibility = ['//visibility:public']) ctx.file("MODULE.bazel", """module(name = "{}")""".format(ctx.name))
ctx.file("BUILD.bazel", "")
filegroup( _empty_repository = repository_rule(
name = "all", implementation = _empty_repository_impl,
srcs = glob(["**"]),
) )
filegroup( def emscripten_repo_name(name):
name = "includes", return "emscripten_bin_{}".format(name)
srcs = glob([
"emscripten/cache/sysroot/include/c++/v1/**",
"emscripten/cache/sysroot/include/compat/**",
"emscripten/cache/sysroot/include/**",
"lib/clang/**/include/**",
]),
)
filegroup( def _emscripten_deps_impl(ctx):
name = "emcc_common", version = None
srcs = [
"emscripten/emcc.py",
"emscripten/embuilder.py",
"emscripten/emscripten-version.txt",
"emscripten/cache/sysroot_install.stamp",
"emscripten/src/settings.js",
"emscripten/src/settings_internal.js",
] + glob(
include = [
"emscripten/third_party/**",
"emscripten/tools/**",
],
exclude = [
"**/__pycache__/**",
],
),
)
filegroup( for mod in ctx.modules:
name = "compiler_files", for config in mod.tags.config:
srcs = [ if config.version and version != None:
"bin/clang{bin_extension}", fail("More than one emscripten version specified!")
"bin/clang++{bin_extension}", version = config.version
":emcc_common", if version == None:
":includes", version = "latest"
],
)
filegroup(
name = "linker_files",
srcs = [
"bin/clang{bin_extension}",
"bin/llvm-ar{bin_extension}",
"bin/llvm-dwarfdump{bin_extension}",
"bin/llvm-nm{bin_extension}",
"bin/llvm-objcopy{bin_extension}",
"bin/wasm-ctor-eval{bin_extension}",
"bin/wasm-emscripten-finalize{bin_extension}",
"bin/wasm-ld{bin_extension}",
"bin/wasm-metadce{bin_extension}",
"bin/wasm-opt{bin_extension}",
"bin/wasm-split{bin_extension}",
"bin/wasm2js{bin_extension}",
":emcc_common",
] + glob(
include = [
"emscripten/cache/sysroot/lib/**",
"emscripten/node_modules/**",
"emscripten/src/**",
],
),
)
filegroup(
name = "ar_files",
srcs = [
"bin/llvm-ar{bin_extension}",
"emscripten/emar.py",
"emscripten/emscripten-version.txt",
"emscripten/src/settings.js",
"emscripten/src/settings_internal.js",
] + glob(
include = [
"emscripten/tools/**",
],
exclude = [
"**/__pycache__/**",
],
),
)
"""
def emscripten_deps(emscripten_version = "latest"):
version = emscripten_version
if version == "latest": if version == "latest":
version = reversed(sorted(EMSCRIPTEN_TAGS.keys(), key = _parse_version))[0] version = reversed(sorted(EMSCRIPTEN_TAGS.keys(), key = _parse_version))[0]
if version not in EMSCRIPTEN_TAGS.keys():
error_msg = "Emscripten version {} not found.".format(version)
error_msg += " Look at @emsdk//:revisions.bzl for the list "
error_msg += "of currently supported versions."
fail(error_msg)
revision = EMSCRIPTEN_TAGS[version] 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 remote_emscripten_repository(
# dependencies that use different emscripten versions name = emscripten_repo_name("linux"),
excludes = native.existing_rules().keys() bin_extension = "",
if "nodejs_toolchains" not in excludes: sha256 = revision.sha_linux,
# Node 16 is the first version that supports darwin_arm64 strip_prefix = "install",
nodejs_register_toolchains( type = "tar.xz",
node_version = "20.18.0", url = emscripten_url.format("linux", revision.hash, "", "tar.xz"),
) )
if "emscripten_bin_linux" not in excludes: # Not all versions have a linux/arm64 release: https://github.com/emscripten-core/emsdk/issues/547
http_archive( if hasattr(revision, "sha_linux_arm64"):
name = "emscripten_bin_linux", remote_emscripten_repository(
name = emscripten_repo_name("linux_arm64"),
bin_extension = "",
sha256 = revision.sha_linux_arm64,
strip_prefix = "install", strip_prefix = "install",
url = emscripten_url.format("linux", revision.hash, "", "tar.xz"),
sha256 = revision.sha_linux,
build_file_content = BUILD_FILE_CONTENT_TEMPLATE.format(bin_extension = ""),
type = "tar.xz", type = "tar.xz",
)
if "emscripten_bin_linux_arm64" not in excludes:
http_archive(
name = "emscripten_bin_linux_arm64",
strip_prefix = "install",
url = emscripten_url.format("linux", revision.hash, "-arm64", "tar.xz"), url = emscripten_url.format("linux", revision.hash, "-arm64", "tar.xz"),
# Not all versions have a linux/arm64 release: https://github.com/emscripten-core/emsdk/issues/547 )
sha256 = getattr(revision, "sha_linux_arm64", None), else:
build_file_content = BUILD_FILE_CONTENT_TEMPLATE.format(bin_extension = ""), _empty_repository(
type = "tar.xz", name = emscripten_repo_name("linux_arm64"),
) )
if "emscripten_bin_mac" not in excludes: remote_emscripten_repository(
http_archive( name = emscripten_repo_name("mac"),
name = "emscripten_bin_mac", bin_extension = "",
strip_prefix = "install", sha256 = revision.sha_mac,
url = emscripten_url.format("mac", revision.hash, "", "tar.xz"), strip_prefix = "install",
sha256 = revision.sha_mac, type = "tar.xz",
build_file_content = BUILD_FILE_CONTENT_TEMPLATE.format(bin_extension = ""), url = emscripten_url.format("mac", revision.hash, "", "tar.xz"),
type = "tar.xz", )
)
if "emscripten_bin_mac_arm64" not in excludes: remote_emscripten_repository(
http_archive( name = emscripten_repo_name("mac_arm64"),
name = "emscripten_bin_mac_arm64", bin_extension = "",
strip_prefix = "install", sha256 = revision.sha_mac_arm64,
url = emscripten_url.format("mac", revision.hash, "-arm64", "tar.xz"), strip_prefix = "install",
sha256 = revision.sha_mac_arm64, type = "tar.xz",
build_file_content = BUILD_FILE_CONTENT_TEMPLATE.format(bin_extension = ""), url = emscripten_url.format("mac", revision.hash, "-arm64", "tar.xz"),
type = "tar.xz", )
)
if "emscripten_bin_win" not in excludes: remote_emscripten_repository(
http_archive( name = emscripten_repo_name("win"),
name = "emscripten_bin_win", bin_extension = ".exe",
strip_prefix = "install", sha256 = revision.sha_win,
url = emscripten_url.format("win", revision.hash, "", "zip"), strip_prefix = "install",
sha256 = revision.sha_win, type = "zip",
build_file_content = BUILD_FILE_CONTENT_TEMPLATE.format(bin_extension = ".exe"), url = emscripten_url.format("win", revision.hash, "", "zip"),
type = "zip", )
)
if "emscripten_npm_linux" not in excludes: emscripten_deps = module_extension(
npm_translate_lock( tag_classes = {
name = "emscripten_npm_linux", "config": tag_class(
data = ["@emscripten_bin_linux//:emscripten/package.json"], attrs = {
npm_package_lock = "@emscripten_bin_linux//:emscripten/package-lock.json", "version": attr.string(
) doc = "Version to use. 'latest' to use latest.",
values = ["latest"] + EMSCRIPTEN_TAGS.keys(),
if "emscripten_npm_linux_arm64" not in excludes: ),
npm_translate_lock( },
name = "emscripten_npm_linux_arm64", ),
data = ["@emscripten_bin_linux_arm64//:emscripten/package.json"], },
npm_package_lock = "@emscripten_bin_linux_arm64//:emscripten/package-lock.json", implementation = _emscripten_deps_impl,
) )
if "emscripten_npm_mac" not in excludes:
npm_translate_lock(
name = "emscripten_npm_mac",
data = ["@emscripten_bin_mac//:emscripten/package.json"],
npm_package_lock = "@emscripten_bin_mac//:emscripten/package-lock.json",
)
if "emscripten_npm_mac_arm64" not in excludes:
npm_translate_lock(
name = "emscripten_npm_mac",
data = ["@emscripten_bin_mac_arm64//:emscripten/package.json"],
npm_package_lock = "@emscripten_bin_mac_arm64//:emscripten/package-lock.json",
)
if "emscripten_npm_win" not in excludes:
npm_translate_lock(
name = "emscripten_npm_win",
data = ["@emscripten_bin_win//:emscripten/package.json"],
npm_package_lock = "@emscripten_bin_win//:emscripten/package-lock.json",
)

View File

@@ -1,101 +1,40 @@
load(":toolchain.bzl", "emscripten_cc_toolchain_config_rule") load("//:emscripten_deps.bzl", "emscripten_repo_name")
load("//:remote_emscripten_repository.bzl", "create_toolchains", "emscripten_toolchain_name")
load("@rules_python//python:py_binary.bzl", "py_binary")
package(default_visibility = ["//visibility:public"]) package(default_visibility = ["//visibility:public"])
filegroup(
name = "common_files",
srcs = [
"@emscripten_cache//:emscripten_config",
"env.sh",
"env.bat",
"@nodejs//:node_files",
],
)
filegroup(
name = "compiler_files",
srcs = [
"emcc.sh",
"emcc.bat",
"@emsdk//:compiler_files",
":common_files",
],
)
filegroup(
name = "linker_files",
srcs = [
"emcc_link.sh",
"emcc_link.bat",
"link_wrapper.py",
"@emsdk//:linker_files",
":common_files",
],
)
filegroup(
name = "ar_files",
srcs = [
"emar.sh",
"emar.bat",
"@emsdk//:ar_files",
":common_files",
],
)
filegroup(
name = "all_files",
srcs = [
":ar_files",
":compiler_files",
":linker_files",
],
)
filegroup(name = "empty")
# dlmalloc.bc is implicitly added by the emscripten toolchain # dlmalloc.bc is implicitly added by the emscripten toolchain
cc_library(name = "malloc") cc_library(name = "malloc")
emscripten_cc_toolchain_config_rule( create_toolchains(
name = "wasm", name = emscripten_toolchain_name("linux"),
cpu = "wasm", repo_name = emscripten_repo_name("linux"),
em_config = "@emscripten_cache//:emscripten_config", exec_compatible_with = [ "@platforms//os:linux", "@platforms//cpu:x86_64"],
emscripten_binaries = "@emsdk//:compiler_files",
nodejs_bin = "@nodejs//:node",
script_extension = select({
"@bazel_tools//src/conditions:host_windows": "bat",
"//conditions:default": "sh",
}),
) )
cc_toolchain( create_toolchains(
name = "cc-compiler-wasm", name = emscripten_toolchain_name("linux_arm64"),
all_files = ":all_files", repo_name = emscripten_repo_name("linux_arm64"),
ar_files = ":ar_files", exec_compatible_with = ["@platforms//os:linux", "@platforms//cpu:arm64"],
as_files = ":empty",
compiler_files = ":compiler_files",
dwp_files = ":empty",
linker_files = ":linker_files",
objcopy_files = ":empty",
strip_files = ":empty",
toolchain_config = "wasm",
toolchain_identifier = "emscripten-wasm",
) )
cc_toolchain_suite( create_toolchains(
name = "everything", name = emscripten_toolchain_name("mac"),
toolchains = { repo_name = emscripten_repo_name("mac"),
"wasm": ":cc-compiler-wasm", exec_compatible_with = ["@platforms//os:macos", "@platforms//cpu:x86_64"],
"wasm|emscripten": ":cc-compiler-wasm",
},
) )
toolchain( create_toolchains(
name = "cc-toolchain-wasm", name = emscripten_toolchain_name("mac_arm64"),
target_compatible_with = ["@platforms//cpu:wasm32"], repo_name = emscripten_repo_name("mac_arm64"),
toolchain = ":cc-compiler-wasm", exec_compatible_with = ["@platforms//os:macos", "@platforms//cpu:arm64"],
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", )
create_toolchains(
name = emscripten_toolchain_name("win"),
repo_name = emscripten_repo_name("win"),
exec_compatible_with = ["@platforms//os:windows", "@platforms//cpu:x86_64"],
) )
py_binary( py_binary(

View File

@@ -1,5 +1,5 @@
@ECHO OFF @ECHO OFF
call external\emsdk\emscripten_toolchain\env.bat call %~dp0\env.bat
py -3 %EMSCRIPTEN%\emar.py %* py -3 %EMSCRIPTEN%\emar.py %*

View File

@@ -1,5 +1,5 @@
@ECHO OFF @ECHO OFF
call external\emsdk\emscripten_toolchain\env.bat call %~dp0\env.bat
py -3 %EMSCRIPTEN%\emcc.py %* py -3 %EMSCRIPTEN%\emcc.py %*

View File

@@ -1,5 +1,5 @@
@ECHO OFF @ECHO OFF
call external\emsdk\emscripten_toolchain\env.bat call %~dp0\env.bat
py -3 external\emsdk\emscripten_toolchain\link_wrapper.py %* py -3 %~dp0\link_wrapper.py %*

View File

@@ -1,5 +1,6 @@
@ECHO OFF @ECHO OFF
set ROOT_DIR=%CD% set ROOT_DIR=%EXT_BUILD_ROOT%
if "%ROOT_DIR%"=="" set ROOT_DIR=%CD%
set EMSCRIPTEN=%ROOT_DIR%\%EM_BIN_PATH%\emscripten set EMSCRIPTEN=%ROOT_DIR%\%EM_BIN_PATH%\emscripten
set EM_CONFIG=%ROOT_DIR%\%EM_CONFIG_PATH% set EM_CONFIG=%ROOT_DIR%\%EM_CONFIG_PATH%

View File

@@ -71,6 +71,7 @@ def _impl(ctx):
cc_target_os = "emscripten" cc_target_os = "emscripten"
emscripten_dir = ctx.attr.emscripten_binaries.label.workspace_root emscripten_dir = ctx.attr.emscripten_binaries.label.workspace_root
nodejs_path = ctx.file.nodejs_bin.path nodejs_path = ctx.file.nodejs_bin.path
builtin_sysroot = emscripten_dir + "/emscripten/cache/sysroot" builtin_sysroot = emscripten_dir + "/emscripten/cache/sysroot"

View File

@@ -32,12 +32,13 @@ def _wasm_transition_impl(settings, attr):
return { return {
"//command_line_option:compiler": "emscripten", "//command_line_option:compiler": "emscripten",
"//command_line_option:crosstool_top": "@emsdk//emscripten_toolchain:everything",
"//command_line_option:cpu": "wasm", "//command_line_option:cpu": "wasm",
"//command_line_option:features": features, "//command_line_option:features": features,
"//command_line_option:dynamic_mode": "off", "//command_line_option:dynamic_mode": "off",
"//command_line_option:linkopt": linkopts, "//command_line_option:linkopt": linkopts,
"//command_line_option:platforms": [platform], "//command_line_option:platforms": [platform],
# This is hardcoded to an empty cc_library because the malloc library
# is implicitly added by the emscripten toolchain
"//command_line_option:custom_malloc": "@emsdk//emscripten_toolchain:malloc", "//command_line_option:custom_malloc": "@emsdk//emscripten_toolchain:malloc",
} }
@@ -50,7 +51,6 @@ _wasm_transition = transition(
outputs = [ outputs = [
"//command_line_option:compiler", "//command_line_option:compiler",
"//command_line_option:cpu", "//command_line_option:cpu",
"//command_line_option:crosstool_top",
"//command_line_option:features", "//command_line_option:features",
"//command_line_option:dynamic_mode", "//command_line_option:dynamic_mode",
"//command_line_option:linkopt", "//command_line_option:linkopt",

View File

@@ -0,0 +1,148 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load(":emscripten_build_file.bzl", "EMSCRIPTEN_BUILD_FILE_CONTENT_TEMPLATE")
load(":revisions.bzl", "EMSCRIPTEN_TAGS")
load("//emscripten_toolchain:toolchain.bzl", "emscripten_cc_toolchain_config_rule")
def remote_emscripten_repository(
name,
bin_extension,
**kwargs,
):
"""Imports an Emscripten from an http archive
Args:
name: A unique name for this Emscripten repository.
bin_extension: Extension for the binaries in this Emscripten repository
**kwargs: Args for http_archive. Refer to http_archive documentation for more info.
"""
http_archive(
name = name,
build_file_content = EMSCRIPTEN_BUILD_FILE_CONTENT_TEMPLATE.format(bin_extension = bin_extension),
**kwargs
)
def emscripten_toolchain_name(name):
return "emscripten_{}".format(name)
def _get_name_and_target(name):
return name, ":" + name
def create_toolchains(name, repo_name, exec_compatible_with):
"""Creates toolchain definition for an Emscripten
Register the toolchains defined by this macro via
`register_toolchains("//<path-to-target>:cc-toolchain-wasm-<name>")`
Args:
name: A unique name for this Emscripten toolchain
repo_name: The name of the Emscripten repository for this toolchain
exec_compatible_with: Execute platform constraints for the Emscripten toolchain associated
with this repository.
**kwargs: Args for http_archive. Refer to http_archive documentation for more info.
"""
common_files_name, common_files_target = _get_name_and_target("common_files_" + name)
compiler_files_name, compiler_files_target = _get_name_and_target("compiler_files_" + name)
linker_files_name, linker_files_target = _get_name_and_target("linker_files_" + name)
ar_files_name, ar_files_target = _get_name_and_target("ar_files_" + name)
all_files_name, all_files_target = _get_name_and_target("all_files_" + name)
cc_wasm_name, cc_wasm_target = _get_name_and_target("cc-compiler-wasm-" + name)
wasm_name = "wasm-" + name
# These are file groups defined by the build_file_content on the Emscripten http_archive
remote_repo = "@{}//".format(repo_name)
repo_compiler_files_target = remote_repo + ":compiler_files"
repo_linker_files_target = remote_repo + ":linker_files"
repo_ar_files_target = remote_repo + ":ar_files"
native.filegroup(
name = common_files_name,
srcs = [
"@emscripten_cache//:emscripten_config",
"@emsdk//emscripten_toolchain:env.sh",
"@emsdk//emscripten_toolchain:env.bat",
"@nodejs//:node_files",
],
)
native.filegroup(
name = compiler_files_name,
srcs = [
"@emsdk//emscripten_toolchain:emcc.sh",
"@emsdk//emscripten_toolchain:emcc.bat",
repo_compiler_files_target,
common_files_target,
],
)
native.filegroup(
name = linker_files_name,
srcs = [
"@emsdk//emscripten_toolchain:emcc_link.sh",
"@emsdk//emscripten_toolchain:emcc_link.bat",
"link_wrapper.py",
repo_linker_files_target,
common_files_target,
],
)
native.filegroup(
name = ar_files_name,
srcs = [
"@emsdk//emscripten_toolchain:emar.sh",
"@emsdk//emscripten_toolchain:emar.bat",
repo_ar_files_target,
common_files_target,
],
)
native.filegroup(
name = all_files_name,
srcs = [
ar_files_target,
compiler_files_target,
linker_files_target,
],
)
emscripten_cc_toolchain_config_rule(
name = wasm_name,
cpu = "wasm",
em_config = "@emscripten_cache//:emscripten_config",
emscripten_binaries = repo_compiler_files_target,
nodejs_bin = "@nodejs//:node",
script_extension = select({
"@bazel_tools//src/conditions:host_windows": "bat",
"//conditions:default": "sh",
}),
)
native.cc_toolchain(
name = cc_wasm_name,
all_files = all_files_target,
ar_files = ar_files_target,
as_files = ":empty",
compiler_files = compiler_files_target,
dwp_files = ":empty",
linker_files = linker_files_target,
objcopy_files = ":empty",
strip_files = ":empty",
toolchain_config = wasm_name,
toolchain_identifier = "emscripten-wasm-" + name,
)
native.toolchain(
name = "cc-toolchain-wasm-" + name,
target_compatible_with = ["@platforms//cpu:wasm32"],
exec_compatible_with = exec_compatible_with,
toolchain = cc_wasm_target,
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)
native.cc_toolchain_suite(
name = "everything-" + name,
toolchains = {
"wasm": cc_wasm_target,
"wasm|emscripten": cc_wasm_target,
},
)

View File

@@ -5,6 +5,7 @@ EMSCRIPTEN_TAGS = {
"4.0.6": struct( "4.0.6": struct(
hash = "14767574a5c37ff9526a253a65ddbe0811cb3667", hash = "14767574a5c37ff9526a253a65ddbe0811cb3667",
sha_linux = "27fc220a9ad98d323cad73531ff563e9838c9e1205f51ee2a5632bb4266a35d2", sha_linux = "27fc220a9ad98d323cad73531ff563e9838c9e1205f51ee2a5632bb4266a35d2",
sha_linux_arm64 = "2d03f8eb3f81dd94821658eefbb442a92b0b7601f4cfb08590590fd7bc467ef8",
sha_mac = "c06048915595726fc2e2da6a8db3134581a6287645fb818802a9734ff9785e77", sha_mac = "c06048915595726fc2e2da6a8db3134581a6287645fb818802a9734ff9785e77",
sha_mac_arm64 = "35d743453d0f91857b09f00d721037bb46753aaeae373bd7f64746338db11770", sha_mac_arm64 = "35d743453d0f91857b09f00d721037bb46753aaeae373bd7f64746338db11770",
sha_win = "3b576e825b26426bb72854ed98752df3fcb58cc3ab1dc116566e328b79a8abb3", sha_win = "3b576e825b26426bb72854ed98752df3fcb58cc3ab1dc116566e328b79a8abb3",
@@ -12,6 +13,7 @@ EMSCRIPTEN_TAGS = {
"4.0.5": struct( "4.0.5": struct(
hash = "d7f8ff5e2ca3539c33fae81e98f7c56ef9fa1239", hash = "d7f8ff5e2ca3539c33fae81e98f7c56ef9fa1239",
sha_linux = "fdd4d9d6b37e845039b207baaef60cd98fb594ea13a3e6d622c2dcd8f2a48ac6", sha_linux = "fdd4d9d6b37e845039b207baaef60cd98fb594ea13a3e6d622c2dcd8f2a48ac6",
sha_linux_arm64 = "0007aec32eee609b91f35c32481ec060ea7dac7151e36344bbcae419907f9240",
sha_mac = "f4e5a6c57ad9de59bff73463972213a299af2bb419dafbdd3959947fa801a342", sha_mac = "f4e5a6c57ad9de59bff73463972213a299af2bb419dafbdd3959947fa801a342",
sha_mac_arm64 = "b8b93190fa17afe32a5eaa7120b807767b1c9d6e1d4ae6b9a2c6adb231758683", sha_mac_arm64 = "b8b93190fa17afe32a5eaa7120b807767b1c9d6e1d4ae6b9a2c6adb231758683",
sha_win = "3b8ed9e298a6d58fee841f5c3f1d3e7b2dff104cc7df314cd329f4c05d470be0", sha_win = "3b8ed9e298a6d58fee841f5c3f1d3e7b2dff104cc7df314cd329f4c05d470be0",
@@ -19,6 +21,7 @@ EMSCRIPTEN_TAGS = {
"4.0.4": struct( "4.0.4": struct(
hash = "ea71afcf5a172125179a07ff1731de6e81c92222", hash = "ea71afcf5a172125179a07ff1731de6e81c92222",
sha_linux = "f05dab4a6a13a5fe6972e95e918d1483e687faf468e1a653deaa8d7956a97a3a", sha_linux = "f05dab4a6a13a5fe6972e95e918d1483e687faf468e1a653deaa8d7956a97a3a",
sha_linux_arm64 = "95a421f304a7209c6f259754ad15aea5bbbbb1838139b51837aeb2c184fa4a89",
sha_mac = "d8b44aae37224ae76572ad84b60a2adaa126826332864fb689944d5130705d8d", sha_mac = "d8b44aae37224ae76572ad84b60a2adaa126826332864fb689944d5130705d8d",
sha_mac_arm64 = "ade1c1a0c2e5893c6f74079beeae8b7e2a0c3f3b7ae88891064104fd985dfc2b", sha_mac_arm64 = "ade1c1a0c2e5893c6f74079beeae8b7e2a0c3f3b7ae88891064104fd985dfc2b",
sha_win = "342cf9dfb83e95bf678d07e460e093ea61a609d34b4603d9be06d4f31784409d", sha_win = "342cf9dfb83e95bf678d07e460e093ea61a609d34b4603d9be06d4f31784409d",
@@ -26,6 +29,7 @@ EMSCRIPTEN_TAGS = {
"4.0.3": struct( "4.0.3": struct(
hash = "de2109f0e5e7278d470da11de526aed16c527722", hash = "de2109f0e5e7278d470da11de526aed16c527722",
sha_linux = "6480f51d0c24130424c696bf83e9774f42246a0109c8d48b59f4520fdfadb928", sha_linux = "6480f51d0c24130424c696bf83e9774f42246a0109c8d48b59f4520fdfadb928",
sha_linux_arm64 = "76b1511d550b4f47276b93581ae5122063acbca7c960703637657388cf178636",
sha_mac = "f40851b816b31b3ca3214ebf61cc152625a05c24f43e2b13c2ad9b9e5dca73c0", sha_mac = "f40851b816b31b3ca3214ebf61cc152625a05c24f43e2b13c2ad9b9e5dca73c0",
sha_mac_arm64 = "6d8ac5ad1f59f71de0927eb2c595dab2f21d9946ca293434359a6db2ab06a138", sha_mac_arm64 = "6d8ac5ad1f59f71de0927eb2c595dab2f21d9946ca293434359a6db2ab06a138",
sha_win = "3702e4a518057520d4ad9e7cd63a01a829770d090551e00f19f417f55b0170d3", sha_win = "3702e4a518057520d4ad9e7cd63a01a829770d090551e00f19f417f55b0170d3",
@@ -33,6 +37,7 @@ EMSCRIPTEN_TAGS = {
"4.0.2": struct( "4.0.2": struct(
hash = "cc8eba40de8235f9c33d92463018f87b3edaa09e", hash = "cc8eba40de8235f9c33d92463018f87b3edaa09e",
sha_linux = "3c0e3940240709388c24a4262680c18bb1d5979f2337abe53db00fb039606c44", sha_linux = "3c0e3940240709388c24a4262680c18bb1d5979f2337abe53db00fb039606c44",
sha_linux_arm64 = "21ed0c31c1fc972e3509fcb140e0323061b5f2b173fe56d1f8961df2a37e4c11",
sha_mac = "e1bd96ec790968adf583d348158375b76ee0287e348954c3393c82565475b07b", sha_mac = "e1bd96ec790968adf583d348158375b76ee0287e348954c3393c82565475b07b",
sha_mac_arm64 = "e5bf9a5efabc114b42636abcea07a1e02d3a9406cd399a29ccbc730586dce465", sha_mac_arm64 = "e5bf9a5efabc114b42636abcea07a1e02d3a9406cd399a29ccbc730586dce465",
sha_win = "78010f8e2f7bb6868bb20e3fc32e24d45e6fca749c388c2d25bea9845512338d", sha_win = "78010f8e2f7bb6868bb20e3fc32e24d45e6fca749c388c2d25bea9845512338d",
@@ -40,6 +45,7 @@ EMSCRIPTEN_TAGS = {
"4.0.1": struct( "4.0.1": struct(
hash = "5ff495a591978fdf8a16f2d172be3616f3150d1e", hash = "5ff495a591978fdf8a16f2d172be3616f3150d1e",
sha_linux = "7b2b64b1bc15555696f78cbcb54c8d75832222d1578270ff5f56a8024c9a0dbc", sha_linux = "7b2b64b1bc15555696f78cbcb54c8d75832222d1578270ff5f56a8024c9a0dbc",
sha_linux_arm64 = "5c046a22b933de14be6b2522b75796afffe3940a19422eee483b7f3f1a226d66",
sha_mac = "d089eba9c3cad675bbd7d3318aec166ebe5ba984a6c5291136c09c68324d9818", sha_mac = "d089eba9c3cad675bbd7d3318aec166ebe5ba984a6c5291136c09c68324d9818",
sha_mac_arm64 = "c8359b334bad71719e8d29e796ca7b63891e0305987b2572eb5a2f020e34f773", sha_mac_arm64 = "c8359b334bad71719e8d29e796ca7b63891e0305987b2572eb5a2f020e34f773",
sha_win = "9cf861339327f3657281c5c8c18aa723323acffe3b3d1c3807b9d4576d097e0e", sha_win = "9cf861339327f3657281c5c8c18aa723323acffe3b3d1c3807b9d4576d097e0e",
@@ -47,6 +53,7 @@ EMSCRIPTEN_TAGS = {
"4.0.0": struct( "4.0.0": struct(
hash = "3ebc04a3dab24522a5bf8ced3ce3caea816558f6", hash = "3ebc04a3dab24522a5bf8ced3ce3caea816558f6",
sha_linux = "6836988f0b7ee6ce3df5192dd4375b9eee55be78847ce31cf1d2abfb00f1e991", sha_linux = "6836988f0b7ee6ce3df5192dd4375b9eee55be78847ce31cf1d2abfb00f1e991",
sha_linux_arm64 = "d4e6e04b7e2fa1bdffc9c07ab4e0a3f66bde75adb06ebf9cc66a341907b17db4",
sha_mac = "4123e9ff6a699dac303c4fe22529ae0d618c118fcd8267df590363b0fc98c91d", sha_mac = "4123e9ff6a699dac303c4fe22529ae0d618c118fcd8267df590363b0fc98c91d",
sha_mac_arm64 = "4b5fb7cc4f5f8526aaa41c8560a00ad6782b97cd3894d856beb635f05a825613", sha_mac_arm64 = "4b5fb7cc4f5f8526aaa41c8560a00ad6782b97cd3894d856beb635f05a825613",
sha_win = "6b1e5aee4b4a4274712566c845888bdf4eced09a5aaa64c1796cda57cd2854c4", sha_win = "6b1e5aee4b4a4274712566c845888bdf4eced09a5aaa64c1796cda57cd2854c4",
@@ -54,6 +61,7 @@ EMSCRIPTEN_TAGS = {
"3.1.74": struct( "3.1.74": struct(
hash = "c2655005234810c7c42e02a18e4696554abe0352", hash = "c2655005234810c7c42e02a18e4696554abe0352",
sha_linux = "a987bb4cded4f29437e8589accac204ce3c134feaaaf251bb97d0fdf450dce65", sha_linux = "a987bb4cded4f29437e8589accac204ce3c134feaaaf251bb97d0fdf450dce65",
sha_linux_arm64 = "c7fcc532eb7ee1dc7df0eacb49128ded12e4d55a973b8a2a5215da8bb6c4027c",
sha_mac = "04f848f40bd19220a43abde2dd1012d95bf1f89c618c0f631b83d18357e2bb65", sha_mac = "04f848f40bd19220a43abde2dd1012d95bf1f89c618c0f631b83d18357e2bb65",
sha_mac_arm64 = "fc71758a5bfb02b8a5c2dd21d6bfc34aa3c64698f6105e204a1f4d11f6d67603", sha_mac_arm64 = "fc71758a5bfb02b8a5c2dd21d6bfc34aa3c64698f6105e204a1f4d11f6d67603",
sha_win = "603b0515e0367ee2718b2f360ef0194663d23a91236910d5f4a90ac4d745a4f2", sha_win = "603b0515e0367ee2718b2f360ef0194663d23a91236910d5f4a90ac4d745a4f2",
@@ -61,6 +69,7 @@ EMSCRIPTEN_TAGS = {
"3.1.73": struct( "3.1.73": struct(
hash = "b363a836e75a245c548b7a6a021822d8c9e4c6df", hash = "b363a836e75a245c548b7a6a021822d8c9e4c6df",
sha_linux = "4f3bc91cffec9096c3d3ccb11c222e1c2cb7734a0ff9a92d192e171849e68f28", sha_linux = "4f3bc91cffec9096c3d3ccb11c222e1c2cb7734a0ff9a92d192e171849e68f28",
sha_linux_arm64 = "e6fb8a32889d4e4a3ac3e45d8012641369251ddd1255ada132ff6c70ab62b932",
sha_mac = "8d52ec080834f49996534de26772800dee048ec9bf148bb508be95887e267735", sha_mac = "8d52ec080834f49996534de26772800dee048ec9bf148bb508be95887e267735",
sha_mac_arm64 = "58e6c984c5a1fb71e0871f0c3bb9e32d41e7553260c6eeb38800a4612623a99d", sha_mac_arm64 = "58e6c984c5a1fb71e0871f0c3bb9e32d41e7553260c6eeb38800a4612623a99d",
sha_win = "d76003fad2146ad1f2289e8b251fbc359406ced0857f141a41f15149c2138302", sha_win = "d76003fad2146ad1f2289e8b251fbc359406ced0857f141a41f15149c2138302",
@@ -68,6 +77,7 @@ EMSCRIPTEN_TAGS = {
"3.1.72": struct( "3.1.72": struct(
hash = "7a360458327cd24c2a7aab428bdbcb5bca8810e4", hash = "7a360458327cd24c2a7aab428bdbcb5bca8810e4",
sha_linux = "be094d6dd27c27a64116e9c0165d6cade5d329f5137e56696773e98e1df83fa7", sha_linux = "be094d6dd27c27a64116e9c0165d6cade5d329f5137e56696773e98e1df83fa7",
sha_linux_arm64 = "5dba64454809d72d53c432f3c91830d69d413ebd9dcd0ce18df5a79a3af235a6",
sha_mac = "52f713c118717814d2371912ab9019a3605b7d6acc627f3842e6aa7d3ffff7bf", sha_mac = "52f713c118717814d2371912ab9019a3605b7d6acc627f3842e6aa7d3ffff7bf",
sha_mac_arm64 = "644593539684f59c635c7eae2e743f5e4e27b1d665f9c71c23dcefd4c2448b3c", sha_mac_arm64 = "644593539684f59c635c7eae2e743f5e4e27b1d665f9c71c23dcefd4c2448b3c",
sha_win = "c72623fb68f109d8f122036f25b9fc75353bd1ce28995d9920277d4be4a1d99c", sha_win = "c72623fb68f109d8f122036f25b9fc75353bd1ce28995d9920277d4be4a1d99c",
@@ -75,6 +85,7 @@ EMSCRIPTEN_TAGS = {
"3.1.71": struct( "3.1.71": struct(
hash = "7ee0f9488f152e9e9cf0d4d243970e03742f1a5c", hash = "7ee0f9488f152e9e9cf0d4d243970e03742f1a5c",
sha_linux = "43f87aa84a73697b905d2a13c89d016af8ec66bed792f37dd5a0059529abee12", sha_linux = "43f87aa84a73697b905d2a13c89d016af8ec66bed792f37dd5a0059529abee12",
sha_linux_arm64 = "d25f5e57b2e7557df39cd9dec3b0283fb086f66c800af3d9a3f70f36c5fc6b14",
sha_mac = "8dac015c03c4f2e594d8bca25fe35d1e4d808aea81705121e852aff0464c4a9d", sha_mac = "8dac015c03c4f2e594d8bca25fe35d1e4d808aea81705121e852aff0464c4a9d",
sha_mac_arm64 = "a7797c3d210eda29f88eede261fc8f0aabf22c7b05214916b5b50a1271e9f0b8", sha_mac_arm64 = "a7797c3d210eda29f88eede261fc8f0aabf22c7b05214916b5b50a1271e9f0b8",
sha_win = "dfe77eaf22278ca975519f0497c8b336c86e52461c478060418fe67b39b6e87c", sha_win = "dfe77eaf22278ca975519f0497c8b336c86e52461c478060418fe67b39b6e87c",
@@ -82,6 +93,7 @@ EMSCRIPTEN_TAGS = {
"3.1.70": struct( "3.1.70": struct(
hash = "6fa6145af41e835f3d13edf7d308c08e4573357a", hash = "6fa6145af41e835f3d13edf7d308c08e4573357a",
sha_linux = "c29b4a2c6addd5aafa613768d34273a23d8fcd1753c685ff61099506710cd8d7", sha_linux = "c29b4a2c6addd5aafa613768d34273a23d8fcd1753c685ff61099506710cd8d7",
sha_linux_arm64 = "b13386975023a06f19057daef3896d480229b144d1e97f8764ed2f3e0fcb7d37",
sha_mac = "bc0edcaaaa19daeda9164d38d36c5f7d7b4b4e1eb7695ad58e776336c571fcc4", sha_mac = "bc0edcaaaa19daeda9164d38d36c5f7d7b4b4e1eb7695ad58e776336c571fcc4",
sha_mac_arm64 = "e470d5eeb570850d66a79bd4c06064b9b3a1e90c7c2101e1a444ebcd6466fe5a", sha_mac_arm64 = "e470d5eeb570850d66a79bd4c06064b9b3a1e90c7c2101e1a444ebcd6466fe5a",
sha_win = "f0118d71fd67583ddcfd39af2ed8bec3d18152fb6aadee085ebec5bcaf4ac4f5", sha_win = "f0118d71fd67583ddcfd39af2ed8bec3d18152fb6aadee085ebec5bcaf4ac4f5",
@@ -89,6 +101,7 @@ EMSCRIPTEN_TAGS = {
"3.1.69": struct( "3.1.69": struct(
hash = "8fe01288bc35668c13316324336ea00195dfb814", hash = "8fe01288bc35668c13316324336ea00195dfb814",
sha_linux = "24a786666e6f48ed3c3944b44df5cf146c45cf4faece4cb2686312a3d052a00c", sha_linux = "24a786666e6f48ed3c3944b44df5cf146c45cf4faece4cb2686312a3d052a00c",
sha_linux_arm64 = "48e670501d215ac5b6b2680c900c517d9028dbc4de43be5dd6f25211a3640f2b",
sha_mac = "8503fe87dd2f30abff2550e9d6eb8aadeaf30fd3c6972d635b31e67f82e155f7", sha_mac = "8503fe87dd2f30abff2550e9d6eb8aadeaf30fd3c6972d635b31e67f82e155f7",
sha_mac_arm64 = "995c7b3c84458edf6b8945e81405320c64a25dfe79eaa427fc1fe9a680f56b4f", sha_mac_arm64 = "995c7b3c84458edf6b8945e81405320c64a25dfe79eaa427fc1fe9a680f56b4f",
sha_win = "3839e0a581ae7b19156f004762a8221585e9a0d6237e468b13a878d1947636c5", sha_win = "3839e0a581ae7b19156f004762a8221585e9a0d6237e468b13a878d1947636c5",
@@ -96,6 +109,7 @@ EMSCRIPTEN_TAGS = {
"3.1.68": struct( "3.1.68": struct(
hash = "b52d8c9150dc7d4c8e4a7a08c7a9b4006c9abe49", hash = "b52d8c9150dc7d4c8e4a7a08c7a9b4006c9abe49",
sha_linux = "1f2bcb47d85eb31d90fa797b3513221adc50f0656bb37f0962a40fd0f49fcf6a", sha_linux = "1f2bcb47d85eb31d90fa797b3513221adc50f0656bb37f0962a40fd0f49fcf6a",
sha_linux_arm64 = "de346e7a489aa27a442215945d154d58a0d35c608b6150b2992af0e70c04e1c5",
sha_mac = "b180711544d783121370d2c894703f99d370a864ab147730f82fd59b88fa3481", sha_mac = "b180711544d783121370d2c894703f99d370a864ab147730f82fd59b88fa3481",
sha_mac_arm64 = "5e9b6242b56edc8cb404cbaf6c8bd7eb1f0f168b55b580bd92652f98c5d286f4", sha_mac_arm64 = "5e9b6242b56edc8cb404cbaf6c8bd7eb1f0f168b55b580bd92652f98c5d286f4",
sha_win = "824d37e8a0845f44e4c1111e8365640eea28944f1bdbd1e9e3fea0279b68baea", sha_win = "824d37e8a0845f44e4c1111e8365640eea28944f1bdbd1e9e3fea0279b68baea",
@@ -103,6 +117,7 @@ EMSCRIPTEN_TAGS = {
"3.1.67": struct( "3.1.67": struct(
hash = "4ae62984ea36ef0e5bfcbd0ed9b62f04bee6426a", hash = "4ae62984ea36ef0e5bfcbd0ed9b62f04bee6426a",
sha_linux = "535b64822916c80124363a5c7a5bd0cafd703f166d5155c0ad0e464e4a879091", sha_linux = "535b64822916c80124363a5c7a5bd0cafd703f166d5155c0ad0e464e4a879091",
sha_linux_arm64 = "04c5f959702d8c1e5c000752b562271c224dee593e81144280840fed06e36cd9",
sha_mac = "692b8fdc79a47332ba9881966c72517eedf15b2da7bed37a535dfec55e6bbd9c", sha_mac = "692b8fdc79a47332ba9881966c72517eedf15b2da7bed37a535dfec55e6bbd9c",
sha_mac_arm64 = "ac26753f59fa9c8e92be9c91666014ad9400c91fbd37064105d1b5fcae503985", sha_mac_arm64 = "ac26753f59fa9c8e92be9c91666014ad9400c91fbd37064105d1b5fcae503985",
sha_win = "8c6af8046ed47386018e42d18b53f57fad0926306dd4315d7f09dfae844b3dd3", sha_win = "8c6af8046ed47386018e42d18b53f57fad0926306dd4315d7f09dfae844b3dd3",
@@ -110,6 +125,7 @@ EMSCRIPTEN_TAGS = {
"3.1.66": struct( "3.1.66": struct(
hash = "243eae09cf5c20c4fde51a620b92f483255c8214", hash = "243eae09cf5c20c4fde51a620b92f483255c8214",
sha_linux = "b10eac37c978b28da2f1f34cdd8a7759c0ed5e5a2d8eb4f4e6790209de33dbf7", sha_linux = "b10eac37c978b28da2f1f34cdd8a7759c0ed5e5a2d8eb4f4e6790209de33dbf7",
sha_linux_arm64 = "9c78a470f74c24fc1fde2c8d86583ed98847b6cbdd87cd0b36ff2d6b4799d950",
sha_mac = "64fd0603ccbf949967cb0dfd8f1b0b25e018abf8bfe813b53596c4fc78751027", sha_mac = "64fd0603ccbf949967cb0dfd8f1b0b25e018abf8bfe813b53596c4fc78751027",
sha_mac_arm64 = "fd6250f25101957f56086d292263379880c4b3329819a021008b2058f92ef67b", sha_mac_arm64 = "fd6250f25101957f56086d292263379880c4b3329819a021008b2058f92ef67b",
sha_win = "b24f65a1a1111d8ace6ba47b55e07681cd0620f7bf711d1018ee262c9501defc", sha_win = "b24f65a1a1111d8ace6ba47b55e07681cd0620f7bf711d1018ee262c9501defc",
@@ -117,6 +133,7 @@ EMSCRIPTEN_TAGS = {
"3.1.65": struct( "3.1.65": struct(
hash = "fdcf56c75a1d27fdff6525a7e03423595485ca19", hash = "fdcf56c75a1d27fdff6525a7e03423595485ca19",
sha_linux = "b2b7de13d37c4c5126e6c6a077e6019ebacc78ef1fb1b35b9035f03975f5ffaa", sha_linux = "b2b7de13d37c4c5126e6c6a077e6019ebacc78ef1fb1b35b9035f03975f5ffaa",
sha_linux_arm64 = "f838af6495408f3c0a14d233171b4919b62e445c62805a22dea1875cb709a116",
sha_mac = "cc50b829a21a041979e0941cfd2047d30a06e3c4a8fd9f662ecdc12a0ab40535", sha_mac = "cc50b829a21a041979e0941cfd2047d30a06e3c4a8fd9f662ecdc12a0ab40535",
sha_mac_arm64 = "db4430db6a085d6ed5284917e632541dad3ce0a9464659fb674055247ad059d0", sha_mac_arm64 = "db4430db6a085d6ed5284917e632541dad3ce0a9464659fb674055247ad059d0",
sha_win = "e72ae4ec3231d9a492eadbf77ff28c13efd90307a69df04234792e67a001d05e", sha_win = "e72ae4ec3231d9a492eadbf77ff28c13efd90307a69df04234792e67a001d05e",
@@ -124,6 +141,7 @@ EMSCRIPTEN_TAGS = {
"3.1.64": struct( "3.1.64": struct(
hash = "fd61bacaf40131f74987e649a135f1dd559aff60", hash = "fd61bacaf40131f74987e649a135f1dd559aff60",
sha_linux = "c39de24beca60fd580f6dff0eca0e275016042a30234588b19eda82397e299f3", sha_linux = "c39de24beca60fd580f6dff0eca0e275016042a30234588b19eda82397e299f3",
sha_linux_arm64 = "61b412135630a60c5517278dc83930e06f80fa286fcc2bb6366c4f620c86e4e0",
sha_mac = "2644772be398c8095621b3d0fe9ff2d122b18b7b0963c0eb702639d94dfb8e90", sha_mac = "2644772be398c8095621b3d0fe9ff2d122b18b7b0963c0eb702639d94dfb8e90",
sha_mac_arm64 = "47449057c345a09aa8750be1a357c364ffea9f8a066066cb341a7a2a14bac96a", sha_mac_arm64 = "47449057c345a09aa8750be1a357c364ffea9f8a066066cb341a7a2a14bac96a",
sha_win = "eb5b59afb420915daab4c383e5f73d456cc14776dce02fdc852c46522cda5531", sha_win = "eb5b59afb420915daab4c383e5f73d456cc14776dce02fdc852c46522cda5531",
@@ -131,6 +149,7 @@ EMSCRIPTEN_TAGS = {
"3.1.63": struct( "3.1.63": struct(
hash = "aeb36a44b29e8ca9f4c7efbb4735b69003ac2bb9", hash = "aeb36a44b29e8ca9f4c7efbb4735b69003ac2bb9",
sha_linux = "2a38ac1ea2fe3b7169879f0f666ea278f344cbb5db6e34421b9554939559109c", sha_linux = "2a38ac1ea2fe3b7169879f0f666ea278f344cbb5db6e34421b9554939559109c",
sha_linux_arm64 = "f1dd5fe4cd22e89b1f5bfd216f1245f9f40f6ea76651a7f66e925a68ff6f18b8",
sha_mac = "7e192b84aecfade22817b5b38f0c69d1f795a9b990308188d39ed1d218692cd3", sha_mac = "7e192b84aecfade22817b5b38f0c69d1f795a9b990308188d39ed1d218692cd3",
sha_mac_arm64 = "751ef26a3682f5f23dfdc1c2f80cd0604a32cad61e6373c823de774722ecb9af", sha_mac_arm64 = "751ef26a3682f5f23dfdc1c2f80cd0604a32cad61e6373c823de774722ecb9af",
sha_win = "947f8e867e781750d374d659644897f2345a133ad3d0f9ade23afcb81eeaddd3", sha_win = "947f8e867e781750d374d659644897f2345a133ad3d0f9ade23afcb81eeaddd3",
@@ -138,6 +157,7 @@ EMSCRIPTEN_TAGS = {
"3.1.62": struct( "3.1.62": struct(
hash = "d52176ac8e07c47c1773bb2776ebd91e3886c3af", hash = "d52176ac8e07c47c1773bb2776ebd91e3886c3af",
sha_linux = "fd303a2b2a85c4b3ab8aa29595d70c5fde9df71c5254d56ed19d54e9ee98e881", sha_linux = "fd303a2b2a85c4b3ab8aa29595d70c5fde9df71c5254d56ed19d54e9ee98e881",
sha_linux_arm64 = "233c0df77644472cd322b45b2d7cf709e6c338799b46f6ec5d5f39ca4dbe8aef",
sha_mac = "d9cfef7ba8f44bf21be715244d0d5f909f1ccc2a481a301b3c01d12d1babc049", sha_mac = "d9cfef7ba8f44bf21be715244d0d5f909f1ccc2a481a301b3c01d12d1babc049",
sha_mac_arm64 = "de5484d60c858aaa8b93ba6485924adffe734cf4f8296765c089900cf9ce0701", sha_mac_arm64 = "de5484d60c858aaa8b93ba6485924adffe734cf4f8296765c089900cf9ce0701",
sha_win = "7455680bf9c19a26fe4868111ac01401023b0f92e862d3cabadf7950b87707fd", sha_win = "7455680bf9c19a26fe4868111ac01401023b0f92e862d3cabadf7950b87707fd",
@@ -145,6 +165,7 @@ EMSCRIPTEN_TAGS = {
"3.1.61": struct( "3.1.61": struct(
hash = "28e4a74b579b4157bda5fc34f23c7d3905a8bd6c", hash = "28e4a74b579b4157bda5fc34f23c7d3905a8bd6c",
sha_linux = "e3e20e09219fd47a0019bb3252e17db4a00ded39b39b41634bc73f840a8ff2be", sha_linux = "e3e20e09219fd47a0019bb3252e17db4a00ded39b39b41634bc73f840a8ff2be",
sha_linux_arm64 = "a6b858601ca09fb7bb6ddf1a5ffb1a4130454c936ad046d45fef183037828c46",
sha_mac = "1fe69a3c42fb2857b80c8e77bfab780cb212ed7cf81ae57c0c4d235504df5269", sha_mac = "1fe69a3c42fb2857b80c8e77bfab780cb212ed7cf81ae57c0c4d235504df5269",
sha_mac_arm64 = "4ba702eea409e2d4bfabc73a68919217d3993e7585d95734e3e40a3c9ce1bd21", sha_mac_arm64 = "4ba702eea409e2d4bfabc73a68919217d3993e7585d95734e3e40a3c9ce1bd21",
sha_win = "bbafba849ff072a61dd34a8ffc0c85eed20a417854a3ca751b092e3565a92581", sha_win = "bbafba849ff072a61dd34a8ffc0c85eed20a417854a3ca751b092e3565a92581",
@@ -152,6 +173,7 @@ EMSCRIPTEN_TAGS = {
"3.1.60": struct( "3.1.60": struct(
hash = "87709b5747de5b1993fe314285528bf4b65c23e1", hash = "87709b5747de5b1993fe314285528bf4b65c23e1",
sha_linux = "ff5eb062165920c7cb69935d396f13e9f8ca5b13f2d7f3af2759bcacb5e877e2", sha_linux = "ff5eb062165920c7cb69935d396f13e9f8ca5b13f2d7f3af2759bcacb5e877e2",
sha_linux_arm64 = "2c291942df4868d3f65b31dd964bda9736bfddcd6a7886158963f797d1b45cf5",
sha_mac = "45586fab1bad65a4293ea8939dafb5ec711ba92ae7b4d1edbaae3b4486f398b5", sha_mac = "45586fab1bad65a4293ea8939dafb5ec711ba92ae7b4d1edbaae3b4486f398b5",
sha_mac_arm64 = "8dc27416a378ad07285d380f68717cfe0db1ea6252fdb1ad012af95e4d3f342e", sha_mac_arm64 = "8dc27416a378ad07285d380f68717cfe0db1ea6252fdb1ad012af95e4d3f342e",
sha_win = "f3147ef2d4ca48ea2624039969fd0529d0bacb63bf49ee4809c681902768b973", sha_win = "f3147ef2d4ca48ea2624039969fd0529d0bacb63bf49ee4809c681902768b973",
@@ -159,6 +181,7 @@ EMSCRIPTEN_TAGS = {
"3.1.59": struct( "3.1.59": struct(
hash = "e20ee09a8a740544c4bc6de5d4ba5f81f74b74d6", hash = "e20ee09a8a740544c4bc6de5d4ba5f81f74b74d6",
sha_linux = "ae59d1946cb92e1651cbb904fe824b3f07b39f42fa25f582116b5aaa226fa239", sha_linux = "ae59d1946cb92e1651cbb904fe824b3f07b39f42fa25f582116b5aaa226fa239",
sha_linux_arm64 = "25b918d6d5ee2af7ef6b28e089dc21d2dc419dca76c8079bb638cb20459eb9e5",
sha_mac = "af175bd559cb80459749e504da314af0163291f195461bf4d376d6980c4c60c3", sha_mac = "af175bd559cb80459749e504da314af0163291f195461bf4d376d6980c4c60c3",
sha_mac_arm64 = "e17553bca5d00b30c920595e785281627e973f9e7e14c5dc0a73c355ccafe113", sha_mac_arm64 = "e17553bca5d00b30c920595e785281627e973f9e7e14c5dc0a73c355ccafe113",
sha_win = "bb54256fc3b7824cb75d5474f887d9bf8e1e63c15b351bdfbed898aa293ee4ab", sha_win = "bb54256fc3b7824cb75d5474f887d9bf8e1e63c15b351bdfbed898aa293ee4ab",
@@ -166,6 +189,7 @@ EMSCRIPTEN_TAGS = {
"3.1.58": struct( "3.1.58": struct(
hash = "a4d4afb626c5010f6ccda4638b8d77579a63782e", hash = "a4d4afb626c5010f6ccda4638b8d77579a63782e",
sha_linux = "b188249ecb939dadc679aaf2d3d9afd0fe19ab942f91b7bc926b4f252915dd1a", sha_linux = "b188249ecb939dadc679aaf2d3d9afd0fe19ab942f91b7bc926b4f252915dd1a",
sha_linux_arm64 = "4aedc8ca641b40d9bd82d85b1dc3458fe1afc9a132da06a09384a5f89c058969",
sha_mac = "2092aa4bef3b9f88d3f343b042a417ba617d4e04454656d8f2e101ba53f854e8", sha_mac = "2092aa4bef3b9f88d3f343b042a417ba617d4e04454656d8f2e101ba53f854e8",
sha_mac_arm64 = "7a9a15845257629b7602d15bdf7633a8e10472b0fa9b3d9ee7149938aa2f2039", sha_mac_arm64 = "7a9a15845257629b7602d15bdf7633a8e10472b0fa9b3d9ee7149938aa2f2039",
sha_win = "9fe76b6189566d56f0cf9aecbd23a006778530aa87184a900f5662e39ce7272a", sha_win = "9fe76b6189566d56f0cf9aecbd23a006778530aa87184a900f5662e39ce7272a",
@@ -173,6 +197,7 @@ EMSCRIPTEN_TAGS = {
"3.1.57": struct( "3.1.57": struct(
hash = "523b29e1b99a61069a2fa9f9d3cc9be1c4c53d4d", hash = "523b29e1b99a61069a2fa9f9d3cc9be1c4c53d4d",
sha_linux = "5bc444132258d4404d396f2044a4a334064ad0f1022555cad5ec72804a98ba5a", sha_linux = "5bc444132258d4404d396f2044a4a334064ad0f1022555cad5ec72804a98ba5a",
sha_linux_arm64 = "f0022413afcc1610deff10921b3f5938bf4d01eba46ce96655f2295bdd84bd6a",
sha_mac = "31ddccb68c86f0a45332982938c49505158860ed4f7e8ccef72a48382e0e3c96", sha_mac = "31ddccb68c86f0a45332982938c49505158860ed4f7e8ccef72a48382e0e3c96",
sha_mac_arm64 = "cc5fdb65b339464f99b9c731cc63c233ec9577268886a856fa49f227ca2a56d1", sha_mac_arm64 = "cc5fdb65b339464f99b9c731cc63c233ec9577268886a856fa49f227ca2a56d1",
sha_win = "b53555420bb9b6e31c153e4c59427000ec692be17ae900f659a9b774d1ecebed", sha_win = "b53555420bb9b6e31c153e4c59427000ec692be17ae900f659a9b774d1ecebed",

View File

@@ -1 +1,6 @@
bazel_dep(name = "platforms", version = "0.0.9") bazel_dep(name = "rules_cc", version = "0.1.1")
bazel_dep(name = "emsdk")
local_path_override(
module_name = "emsdk",
path = "..",
)

3696
bazel/test_external/MODULE.bazel.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,16 +0,0 @@
local_repository(
name = "emsdk",
path = "..",
)
load("@emsdk//:deps.bzl", "deps")
deps()
load("@emsdk//:emscripten_deps.bzl", "emscripten_deps")
emscripten_deps()
load("@emsdk//:toolchains.bzl", "register_emscripten_toolchains")
register_emscripten_toolchains()

View File

@@ -1 +1,25 @@
bazel_dep(name = "platforms", version = "0.0.9") bazel_dep(name = "rules_cc", version = "0.1.1")
bazel_dep(name = "emsdk")
local_path_override(
module_name = "emsdk",
path = "..",
)
emscripten_cache = use_extension(
"@emsdk//:emscripten_cache.bzl",
"emscripten_cache",
)
emscripten_cache.configuration(flags = ["--lto"])
emscripten_cache.targets(targets = [
"crtbegin",
"libprintf_long_double-debug",
"libstubs-debug",
"libnoexit",
"libc-debug",
"libdlmalloc",
"libcompiler_rt",
"libc++-noexcept",
"libc++abi-debug-noexcept",
"libsockets",
"libdlmalloc-debug",
])

File diff suppressed because it is too large Load Diff

View File

@@ -1,31 +0,0 @@
local_repository(
name = "emsdk",
path = "..",
)
load("@emsdk//:deps.bzl", "deps")
deps()
load("@emsdk//:emscripten_deps.bzl", "emscripten_deps")
emscripten_deps()
load("@emsdk//:toolchains.bzl", "register_emscripten_toolchains")
register_emscripten_toolchains(cache = {
"configuration": ["--lto"],
"targets": [
"crtbegin",
"libprintf_long_double-debug",
"libstubs-debug",
"libnoexit",
"libc-debug",
"libdlmalloc",
"libcompiler_rt",
"libc++-noexcept",
"libc++abi-debug-noexcept",
"libsockets",
"libdlmalloc-debug"
]
})

View File

@@ -8,6 +8,7 @@
import hashlib import hashlib
import json import json
import os import os
import re
import requests import requests
import sys import sys
@@ -16,6 +17,7 @@ STORAGE_URL = 'https://storage.googleapis.com/webassembly/emscripten-releases-bu
EMSDK_ROOT = os.path.dirname(os.path.dirname(__file__)) EMSDK_ROOT = os.path.dirname(os.path.dirname(__file__))
RELEASES_TAGS_FILE = EMSDK_ROOT + '/emscripten-releases-tags.json' RELEASES_TAGS_FILE = EMSDK_ROOT + '/emscripten-releases-tags.json'
BAZEL_REVISIONS_FILE = EMSDK_ROOT + '/bazel/revisions.bzl' BAZEL_REVISIONS_FILE = EMSDK_ROOT + '/bazel/revisions.bzl'
BAZEL_MODULE_FILE = EMSDK_ROOT + '/bazel/MODULE.bazel'
def get_latest_info(): def get_latest_info():
@@ -40,6 +42,7 @@ def revisions_item(version, latest_hash):
"{version}": struct( "{version}": struct(
hash = "{latest_hash}", hash = "{latest_hash}",
sha_linux = "{get_sha('linux', 'tar.xz', latest_hash)}", sha_linux = "{get_sha('linux', 'tar.xz', latest_hash)}",
sha_linux_arm64 = "{get_sha('linux', 'tar.xz', latest_hash, '-arm64')}",
sha_mac = "{get_sha('mac', 'tar.xz', latest_hash)}", sha_mac = "{get_sha('mac', 'tar.xz', latest_hash)}",
sha_mac_arm64 = "{get_sha('mac', 'tar.xz', latest_hash, '-arm64')}", sha_mac_arm64 = "{get_sha('mac', 'tar.xz', latest_hash, '-arm64')}",
sha_win = "{get_sha('win', 'zip', latest_hash)}", sha_win = "{get_sha('win', 'zip', latest_hash)}",
@@ -57,8 +60,22 @@ def insert_revision(item):
f.write(''.join(lines)) f.write(''.join(lines))
def update_module_version(version):
with open(BAZEL_MODULE_FILE, 'r') as f:
content = f.read()
content = re.sub(
r'module\(name = "emsdk", version = "\d+.\d+.\d+"\)',
f'module(name = "emsdk", version = "{version}")',
content)
with open(BAZEL_MODULE_FILE, 'w') as f:
f.write(content)
def main(argv): def main(argv):
version, latest_hash = get_latest_info() version, latest_hash = get_latest_info()
update_module_version(version)
item = revisions_item(version, latest_hash) item = revisions_item(version, latest_hash)
print('inserting item:') print('inserting item:')
print(item) print(item)

View File

@@ -16,22 +16,21 @@ FAILMSG="!!! scripts/update_bazel_workspace.py needs to be run !!!"
# Ensure the WORKSPACE file is up to date with the latest version. # Ensure the WORKSPACE file is up to date with the latest version.
grep ${VER} bazel/revisions.bzl || (echo ${FAILMSG} && false) grep ${VER} bazel/revisions.bzl || (echo ${FAILMSG} && false)
grep ${HASH} bazel/revisions.bzl || (echo ${FAILMSG} && false) grep ${HASH} bazel/revisions.bzl || (echo ${FAILMSG} && false)
grep ${VER} bazel/MODULE.bazel || (echo ${FAILMSG} && false)
BAZEL_CMD=$(which bazel || which bazel-7.4.1)
cd bazel cd bazel
$BAZEL_CMD build //hello-world:hello-world-wasm bazel build //hello-world:hello-world-wasm
$BAZEL_CMD build //hello-world:hello-world-wasm-simd bazel build //hello-world:hello-world-wasm-simd
cd test_external cd test_external
$BAZEL_CMD build //:hello-world-wasm bazel build //:hello-world-wasm
$BAZEL_CMD build //long_command_line:long_command_line_wasm bazel build //long_command_line:long_command_line_wasm
$BAZEL_CMD build //:hello-embind-wasm --compilation_mode dbg # debug bazel build //:hello-embind-wasm --compilation_mode dbg # debug
# Test use of the closure compiler # Test use of the closure compiler
$BAZEL_CMD build //:hello-embind-wasm --compilation_mode opt # release bazel build //:hello-embind-wasm --compilation_mode opt # release
# This function should not be minified if the externs file is loaded correctly. # This function should not be minified if the externs file is loaded correctly.
grep "customJSFunctionToTestClosure" bazel-bin/hello-embind-wasm/hello-embind.js grep "customJSFunctionToTestClosure" bazel-bin/hello-embind-wasm/hello-embind.js
cd ../test_secondary_lto_cache cd ../test_secondary_lto_cache
$BAZEL_CMD build //:hello-world-wasm bazel build //:hello-world-wasm

View File

@@ -16,6 +16,7 @@ FAILMSG="!!! scripts/update_bazel_workspace.py needs to be run !!!"
# Ensure the WORKSPACE file is up to date with the latest version. # Ensure the WORKSPACE file is up to date with the latest version.
grep ${VER} bazel/revisions.bzl || (echo ${FAILMSG} && false) grep ${VER} bazel/revisions.bzl || (echo ${FAILMSG} && false)
grep ${HASH} bazel/revisions.bzl || (echo ${FAILMSG} && false) grep ${HASH} bazel/revisions.bzl || (echo ${FAILMSG} && false)
grep ${VER} bazel/MODULE.bazel || (echo ${FAILMSG} && false)
cd bazel cd bazel
bazel build //hello-world:hello-world-wasm bazel build //hello-world:hello-world-wasm