diff --git a/.bazelrc b/.bazelrc index c90086e..7cddb69 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,12 +1,3 @@ -build --enable_platform_specific_config -build --incompatible_use_platforms_repo_for_constraints -build --incompatible_enable_cc_toolchain_resolution -build --incompatible_strict_action_env +import %workspace%/bazel/common.bazelrc -build:windows --platforms=//bazel/platforms:windows - -build:linux --platforms=//bazel/platforms:linux -build:linux --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux - -common:ci --announce_rc -common:ci --disk_cache=~/.cache/bazel-disk-cache +try-import %workspace%/user.bazelrc diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000..3611e31 --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,8 @@ +module( + name = "bazel_sundry", + version = "0.1.0", + compatibility_level = 1, +) + +bazel_dep(name = "rules_cc", version = "0.0.8") +bazel_dep(name = "googletest", version = "1.14.0") diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index f3bb726..5b08bbe 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -1,14 +1,5 @@ -workspace(name = "bazel_sundry") - load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -http_archive( - name = "com_google_googletest", - sha256 = "6398970cac9b3ff8e8acef5bc1f6d624da633e0236a65825c95f98fbc8c5d6b5", - strip_prefix = "googletest-d1467f5813f4d363cfd11aba99c4e9fe47a85e99", - url = "https://github.com/google/googletest/archive/d1467f5813f4d363cfd11aba99c4e9fe47a85e99.zip", -) - http_archive( name = "hedron_compile_commands", sha256 = "ed5aea1dc87856aa2029cb6940a51511557c5cac3dbbcb05a4abd989862c36b4", diff --git a/bazel/common.bazelrc b/bazel/common.bazelrc new file mode 100644 index 0000000..0b43bbe --- /dev/null +++ b/bazel/common.bazelrc @@ -0,0 +1,17 @@ +startup --windows_enable_symlinks +common --enable_bzlmod +build --enable_platform_specific_config +build --incompatible_use_platforms_repo_for_constraints +build --incompatible_enable_cc_toolchain_resolution +build --incompatible_strict_action_env +build --enable_runfiles +build --noincompatible_remove_rule_name_parameter +query --noincompatible_remove_rule_name_parameter + +# Temporary until https://github.com/grailbio/bazel-toolchain/pull/198 is merged +build:linux --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux + +common:ci --announce_rc +common:ci --verbose_failures +common:ci --keep_going +common:ci --disk_cache=~/.cache/bazel-disk-cache diff --git a/bazel/copts.bzl b/bazel/copts.bzl index dd69eb0..4e8f9c4 100644 --- a/bazel/copts.bzl +++ b/bazel/copts.bzl @@ -1,4 +1,13 @@ -copts = select({ - "@bazel_tools//tools/cpp:msvc": ["/std:c++latest"], - "//conditions:default": ["-std=c++20"], +load("@bazel_skylib//lib:selects.bzl", "selects") + +copts = selects.with_or({ + ("@rules_cc//cc/compiler:clang"): [ + "-std=c++2b", + "-fexperimental-library", + ], + ("@rules_cc//cc/compiler:msvc-cl", "@rules_cc//cc/compiler:clang-cl"): [ + "/std:c++latest", + "/permissive-", + "/Zc:preprocessor", + ], }) diff --git a/bazel/platforms/BUILD.bazel b/bazel/platforms/BUILD.bazel deleted file mode 100644 index dae4bb2..0000000 --- a/bazel/platforms/BUILD.bazel +++ /dev/null @@ -1,19 +0,0 @@ -package(default_visibility = ["//:__subpackages__"]) - -platform( - name = "windows", - constraint_values = [ - "@platforms//cpu:x86_64", - "@platforms//os:windows", - "@bazel_tools//tools/cpp:msvc", - ], -) - -platform( - name = "linux", - constraint_values = [ - "@platforms//cpu:x86_64", - "@platforms//os:linux", - "@bazel_tools//tools/cpp:clang", - ], -) diff --git a/test/BUILD.bazel b/test/BUILD.bazel index a7757f2..140d11c 100644 --- a/test/BUILD.bazel +++ b/test/BUILD.bazel @@ -7,7 +7,7 @@ cc_test( copts = copts, deps = [ "//bazel_sundry:runfiles", - "@com_google_googletest//:gtest", - "@com_google_googletest//:gtest_main", + "@googletest//:gtest", + "@googletest//:gtest_main", ], )