Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bazel/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ 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_cc", version = "0.2.16")
bazel_dep(name = "rules_python", version = "1.3.0")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
Expand Down
28 changes: 22 additions & 6 deletions bazel/emscripten_toolchain/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_python//python:py_binary.bzl", "py_binary")
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"])

Expand All @@ -9,32 +10,47 @@ cc_library(name = "malloc")

create_toolchains(
name = emscripten_toolchain_name("linux"),
exec_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
],
repo_name = emscripten_repo_name("linux"),
exec_compatible_with = [ "@platforms//os:linux", "@platforms//cpu:x86_64"],
)

create_toolchains(
name = emscripten_toolchain_name("linux_arm64"),
exec_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:arm64",
],
repo_name = emscripten_repo_name("linux_arm64"),
exec_compatible_with = ["@platforms//os:linux", "@platforms//cpu:arm64"],
)

create_toolchains(
name = emscripten_toolchain_name("mac"),
exec_compatible_with = [
"@platforms//os:macos",
"@platforms//cpu:x86_64",
],
repo_name = emscripten_repo_name("mac"),
exec_compatible_with = ["@platforms//os:macos", "@platforms//cpu:x86_64"],
)

create_toolchains(
name = emscripten_toolchain_name("mac_arm64"),
exec_compatible_with = [
"@platforms//os:macos",
"@platforms//cpu:arm64",
],
repo_name = emscripten_repo_name("mac_arm64"),
exec_compatible_with = ["@platforms//os:macos", "@platforms//cpu:arm64"],
)

create_toolchains(
name = emscripten_toolchain_name("win"),
exec_compatible_with = [
"@platforms//os:windows",
"@platforms//cpu:x86_64",
],
repo_name = emscripten_repo_name("win"),
exec_compatible_with = ["@platforms//os:windows", "@platforms//cpu:x86_64"],
)

py_binary(
Expand Down
3 changes: 2 additions & 1 deletion bazel/emscripten_toolchain/toolchain.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""This module encapsulates logic to create emscripten_cc_toolchain_config rule."""

load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
load(
"@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl",
"action_config",
Expand All @@ -14,7 +15,7 @@ load(
"with_feature_set",
_flag_set = "flag_set",
)
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")

def flag_set(flags = None, features = None, not_features = None, **kwargs):
"""Extension to flag_set which allows for a "simple" form.
Expand Down
18 changes: 8 additions & 10 deletions bazel/remote_emscripten_repository.bzl
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
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("@rules_cc//cc/toolchains:cc_toolchain.bzl", "cc_toolchain")
load("@rules_cc//cc/toolchains:cc_toolchain_suite.bzl", "cc_toolchain_suite")
load("//emscripten_toolchain:toolchain.bzl", "emscripten_cc_toolchain_config_rule")
load(":emscripten_build_file.bzl", "EMSCRIPTEN_BUILD_FILE_CONTENT_TEMPLATE")

def remote_emscripten_repository(
name,
bin_extension,
**kwargs,
):
name,
bin_extension,
**kwargs):
"""Imports an Emscripten from an http archive

Args:
Expand Down Expand Up @@ -116,8 +116,7 @@ def create_toolchains(name, repo_name, exec_compatible_with):
"//conditions:default": "sh",
}),
)

native.cc_toolchain(
cc_toolchain(
name = cc_wasm_name,
all_files = all_files_target,
ar_files = ar_files_target,
Expand All @@ -138,8 +137,7 @@ def create_toolchains(name, repo_name, exec_compatible_with):
toolchain = cc_wasm_target,
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)

native.cc_toolchain_suite(
cc_toolchain_suite(
name = "everything-" + name,
toolchains = {
"wasm": cc_wasm_target,
Expand Down
6 changes: 3 additions & 3 deletions bazel/test_external/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@emsdk//emscripten_toolchain:wasm_rules.bzl", "wasm_cc_binary")
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")

cc_binary(
name = "hello-world",
Expand All @@ -24,7 +25,7 @@ BASE_LINKOPTS = [
RELEASE_OPTS = [
"--closure=1", # Run the closure compiler
# Tell closure about the externs file, so as not to minify our JS public API.
"--closure-args=--externs=$(location hello-embind-externs.js)"
"--closure-args=--externs=$(location hello-embind-externs.js)",
]

DEBUG_OPTS = [
Expand All @@ -44,11 +45,11 @@ config_setting(
cc_binary(
name = "hello-embind",
srcs = ["hello-embind.cc"],
features = ["emcc_debug_link"],
additional_linker_inputs = [
"hello-embind-externs.js",
"hello-embind-interface.js",
],
features = ["emcc_debug_link"],
linkopts = select({
":debug_opts": BASE_LINKOPTS + DEBUG_OPTS,
":release_opts": BASE_LINKOPTS + RELEASE_OPTS,
Expand All @@ -63,4 +64,3 @@ wasm_cc_binary(
name = "hello-embind-wasm",
cc_target = ":hello-embind",
)

6 changes: 4 additions & 2 deletions bazel/test_external/long_command_line/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
load("@emsdk//emscripten_toolchain:wasm_rules.bzl", "wasm_cc_binary")
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
load("@rules_cc//cc:cc_library.bzl", "cc_library")

_TEST_TARGETS = [
"long_command_line_file01",
Expand Down Expand Up @@ -38,16 +40,16 @@ _TEST_TARGET_SUFFIXES = [

[cc_library(
name = "{}_{}".format(target, suffix),
srcs = ["{}.cc".format(target)],
hdrs = ["include/{}.hh".format(target)],
# stripping include prefix to create more flags passed to emcc
strip_include_prefix = "include",
srcs = ["{}.cc".format(target)],
) for target in _TEST_TARGETS for suffix in _TEST_TARGET_SUFFIXES]

cc_binary(
name = "long_command_line",
linkshared = True,
srcs = ["long_command_line.cc"],
linkshared = True,
deps = [":{}_{}".format(target, suffix) for target in _TEST_TARGETS for suffix in _TEST_TARGET_SUFFIXES],
)

Expand Down
1 change: 1 addition & 0 deletions bazel/test_secondary_lto_cache/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@emsdk//emscripten_toolchain:wasm_rules.bzl", "wasm_cc_binary")
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")

cc_binary(
name = "hello-world",
Expand Down