From 66565607b788604063496550e35ddf2d2c166d71 Mon Sep 17 00:00:00 2001 From: Vertexwahn Date: Tue, 20 Jan 2026 22:24:37 +0100 Subject: [PATCH 1/2] Applying buildifier -lint=fix -r . --- bazel/emscripten_toolchain/BUILD.bazel | 28 +++++++++++++++---- bazel/emscripten_toolchain/toolchain.bzl | 3 +- bazel/remote_emscripten_repository.bzl | 18 ++++++------ bazel/test_external/BUILD | 6 ++-- .../long_command_line/BUILD.bazel | 6 ++-- bazel/test_secondary_lto_cache/BUILD | 1 + 6 files changed, 40 insertions(+), 22 deletions(-) diff --git a/bazel/emscripten_toolchain/BUILD.bazel b/bazel/emscripten_toolchain/BUILD.bazel index ebbc2e996f..f8569d1106 100644 --- a/bazel/emscripten_toolchain/BUILD.bazel +++ b/bazel/emscripten_toolchain/BUILD.bazel @@ -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"]) @@ -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( diff --git a/bazel/emscripten_toolchain/toolchain.bzl b/bazel/emscripten_toolchain/toolchain.bzl index 80f55f6a49..a1f57fab17 100644 --- a/bazel/emscripten_toolchain/toolchain.bzl +++ b/bazel/emscripten_toolchain/toolchain.bzl @@ -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", @@ -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. diff --git a/bazel/remote_emscripten_repository.bzl b/bazel/remote_emscripten_repository.bzl index 819a048080..52dfc1f828 100644 --- a/bazel/remote_emscripten_repository.bzl +++ b/bazel/remote_emscripten_repository.bzl @@ -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: @@ -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, @@ -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, diff --git a/bazel/test_external/BUILD b/bazel/test_external/BUILD index e3a8e9e645..b0dcf5d155 100644 --- a/bazel/test_external/BUILD +++ b/bazel/test_external/BUILD @@ -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", @@ -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 = [ @@ -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, @@ -63,4 +64,3 @@ wasm_cc_binary( name = "hello-embind-wasm", cc_target = ":hello-embind", ) - diff --git a/bazel/test_external/long_command_line/BUILD.bazel b/bazel/test_external/long_command_line/BUILD.bazel index 4ffe247604..7b1be11937 100644 --- a/bazel/test_external/long_command_line/BUILD.bazel +++ b/bazel/test_external/long_command_line/BUILD.bazel @@ -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", @@ -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], ) diff --git a/bazel/test_secondary_lto_cache/BUILD b/bazel/test_secondary_lto_cache/BUILD index f364f3778f..bcc79b7cbc 100644 --- a/bazel/test_secondary_lto_cache/BUILD +++ b/bazel/test_secondary_lto_cache/BUILD @@ -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", From 8f19ed9bdf98573ee93a6f686f64133d5606ae42 Mon Sep 17 00:00:00 2001 From: Vertexwahn Date: Tue, 20 Jan 2026 22:27:18 +0100 Subject: [PATCH 2/2] Bump rules_cc --- bazel/MODULE.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bazel/MODULE.bazel b/bazel/MODULE.bazel index e5ea27d66d..a64c855eb6 100644 --- a/bazel/MODULE.bazel +++ b/bazel/MODULE.bazel @@ -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")