Skip to content

Commit

Permalink
Move cc toolchains to rules_cc
Browse files Browse the repository at this point in the history
Fixes #23809
Closes #23891.

PiperOrigin-RevId: 683287734
Change-Id: I461eb49b58918cc174765af936f69de25406d8a2
  • Loading branch information
meteorcloudy authored and copybara-github committed Oct 7, 2024
1 parent 263ad1a commit 1c4e78a
Show file tree
Hide file tree
Showing 46 changed files with 358 additions and 8,757 deletions.
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ bazel_dep(name = "stardoc", version = "0.7.1", repo_name = "io_bazel_skydoc")
bazel_dep(name = "zstd-jni", version = "1.5.2-3.bcr.1")
bazel_dep(name = "blake3", version = "1.5.1.bcr.1")
bazel_dep(name = "zlib", version = "1.3.1.bcr.3")
bazel_dep(name = "rules_cc", version = "0.0.10")
bazel_dep(name = "rules_cc", version = "0.0.12")
bazel_dep(name = "rules_java", version = "8.0.1")
bazel_dep(name = "rules_graalvm", version = "0.11.1")
bazel_dep(name = "rules_proto", version = "6.0.2")
Expand Down
3 changes: 2 additions & 1 deletion MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions src/MODULE.tools
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ bazel_dep(name = "buildozer", version = "7.1.2")
bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "zlib", version = "1.3.1.bcr.3")

cc_configure = use_extension("//tools/cpp:cc_configure.bzl", "cc_configure_extension")
use_repo(cc_configure, "local_config_cc", "local_config_cc_toolchains")
register_toolchains("@local_config_cc_toolchains//:all")

xcode_configure = use_extension("//tools/osx:xcode_configure.bzl", "xcode_configure_extension")
use_repo(xcode_configure, "local_config_xcode")

Expand Down Expand Up @@ -42,7 +38,7 @@ use_repo(buildozer_binary, "buildozer_binary")
# Dependencies used to auto-load removed symbols and rules from Bazel (due to Starlarkification)
# See also: --incompatible_autoload_externally, AutoloadSymbols
bazel_dep(name = "rules_java", version = "8.0.1")
bazel_dep(name = "rules_cc", version = "0.0.10")
bazel_dep(name = "rules_cc", version = "0.0.12")
bazel_dep(name = "rules_python", version = "0.36.0")
bazel_dep(name = "rules_shell", version = "0.1.1")
# add rules_android
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ gen_workspace_stanza(
name = "workspace_with_rules_cc",
out = "cc_configure.WORKSPACE",
postamble = """
load("@bazel_tools//tools/cpp:cc_configure.bzl", "cc_configure")
cc_configure()
""",
preamble = """
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("@bazel_tools//tools/cpp:cc_configure.bzl", "cc_configure")
""",
repos = ["rules_cc"],
use_maybe = 1,
Expand Down
1 change: 1 addition & 0 deletions src/main/starlark/tests/builtins_bzl/cc_builtin_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ function test_starlark_cc() {
mkdir -p "src/conditions"
cp "$(rlocation "io_bazel/src/conditions/BUILD")" "src/conditions/BUILD"

add_rules_cc "MODULE.bazel"
cat >> MODULE.bazel<<EOF
bazel_dep(name = "test_repo", repo_name = "my_test_repo")
local_path_override(
Expand Down
3 changes: 2 additions & 1 deletion src/test/py/bazel/bazel_windows_cpp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ def createModuleDotBazel(self):
'MODULE.bazel',
[
'bazel_dep(name = "platforms", version = "0.0.9")',
'bazel_dep(name = "rules_cc", version = "0.0.12")',
(
'cc_configure ='
' use_extension("@bazel_tools//tools/cpp:cc_configure.bzl",'
' use_extension("@rules_cc//cc:extensions.bzl",'
' "cc_configure_extension")'
),
'use_repo(cc_configure, "local_config_cc")',
Expand Down
3 changes: 2 additions & 1 deletion src/test/py/bazel/bazel_windows_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ def createProjectFiles(self):
'MODULE.bazel',
[
'bazel_dep(name = "platforms", version = "0.0.9")',
'bazel_dep(name = "rules_cc", version = "0.0.12")',
(
'cc_configure ='
' use_extension("@bazel_tools//tools/cpp:cc_configure.bzl",'
' use_extension("@rules_cc//cc:extensions.bzl",'
' "cc_configure_extension")'
),
'use_repo(cc_configure, "local_config_cc")',
Expand Down
11 changes: 11 additions & 0 deletions src/test/shell/bazel/bazel_rules_cc_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ EOF
touch override/WORKSPACE || fail "couldn't touch override/WORKSPACE"
cat > override/BUILD <<EOF
filegroup(name = 'yolo')
EOF
mkdir -p override/cc/private/toolchain
touch override/cc/private/toolchain/BUILD
cat > override/cc/private/toolchain/cc_configure.bzl <<EOF
def cc_configure():
pass
EOF
mkdir -p override/cc/toolchains
touch override/cc/toolchains/BUILD
cat > override/cc/toolchains/toolchain_config_utils.bzl <<EOF
MSVC_ENVVARS = ""
EOF

cd rules_cc_can_be_overridden || fail "couldn't cd into workspace"
Expand Down
3 changes: 2 additions & 1 deletion src/test/shell/bazel/bazel_windows_example_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ platform(
)
EOF

add_rules_cc "MODULE.bazel"
cat >> MODULE.bazel <<EOF
cc_configure = use_extension("@bazel_tools//tools/cpp:cc_configure.bzl", "cc_configure_extension")
cc_configure = use_extension("@rules_cc//cc:extensions.bzl", "cc_configure_extension")
use_repo(cc_configure, "local_config_cc")
EOF
}
Expand Down
3 changes: 2 additions & 1 deletion src/test/shell/bazel/cc_integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -883,8 +883,9 @@ EOF
}

function test_disable_cc_toolchain_detection() {
add_rules_cc "MODULE.bazel"
cat >> MODULE.bazel <<'EOF'
cc_configure = use_extension("@bazel_tools//tools/cpp:cc_configure.bzl", "cc_configure_extension")
cc_configure = use_extension("@rules_cc//cc:extensions.bzl", "cc_configure_extension")
use_repo(cc_configure, "local_config_cc")
EOF

Expand Down
Loading

0 comments on commit 1c4e78a

Please sign in to comment.