From 6d8ef98c432903b26bfbecb784fc40417c5c2bc3 Mon Sep 17 00:00:00 2001 From: Chris Sauer Date: Mon, 13 Nov 2023 20:32:43 -0800 Subject: [PATCH] Simplify Bazel Please see #309 for context, but this sidesteps the bazel dependencies and cleans up the copts where they're not actually used. --- BUILD.bazel | 6 +----- MODULE.bazel | 3 --- bazel/BUILD.bazel | 0 bazel/copts.bzl | 11 ----------- test/BUILD.bazel | 28 +++++++++++++++------------- test/MODULE.bazel | 4 ++-- 6 files changed, 18 insertions(+), 34 deletions(-) delete mode 100644 bazel/BUILD.bazel delete mode 100644 bazel/copts.bzl diff --git a/BUILD.bazel b/BUILD.bazel index 53d6d8417..356c09d5f 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,6 +1,3 @@ -load("@rules_cc//cc:defs.bzl", "cc_library") -load("//bazel:copts.bzl", "COPTS") - licenses(["notice"]) exports_files(["LICENSE"]) @@ -10,6 +7,5 @@ package(default_visibility = ["//visibility:public"]) cc_library( name = "magic_enum", hdrs = glob(["include/magic_enum/*.hpp"]), - copts = COPTS, - includes = ["include"], + includes = ["include/magic_enum"], ) diff --git a/MODULE.bazel b/MODULE.bazel index c69634479..b1ae535db 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -3,6 +3,3 @@ module( version = "0.9.4", compatibility_level = 0, ) - -bazel_dep(name = "rules_cc", version = "0.0.8") -bazel_dep(name = "bazel_skylib", version = "1.4.2") diff --git a/bazel/BUILD.bazel b/bazel/BUILD.bazel deleted file mode 100644 index e69de29bb..000000000 diff --git a/bazel/copts.bzl b/bazel/copts.bzl deleted file mode 100644 index 96785cde5..000000000 --- a/bazel/copts.bzl +++ /dev/null @@ -1,11 +0,0 @@ -load("@bazel_skylib//lib:selects.bzl", "selects") - -COPTS = selects.with_or({ - ("//conditions:default", "@rules_cc//cc/compiler:clang", "@rules_cc//cc/compiler:gcc", "@rules_cc//cc/compiler:mingw-gcc"): [ - "-std=c++17", - ], - ("@rules_cc//cc/compiler:msvc-cl", "@rules_cc//cc/compiler:clang-cl"): [ - "/std:c++17", - "/permissive-", - ], -}) diff --git a/test/BUILD.bazel b/test/BUILD.bazel index a005bfea2..75768feb8 100644 --- a/test/BUILD.bazel +++ b/test/BUILD.bazel @@ -1,23 +1,25 @@ -load("@rules_cc//cc:defs.bzl", "cc_test") -load("@magic_enum//bazel:copts.bzl", "COPTS") - -# bazel central registry has a catch2 module, but is newer than the one included -# in this repository -cc_library( - name = "catch2", - includes = ["3rdparty/Catch2/include"], - hdrs = ["3rdparty/Catch2/include/catch2/catch.hpp"], - copts = COPTS, -) - _TESTS = [ "test", "test_flags", ] +_MSVC_FLAGS = ["/std:c++17", "/permissive-"] +_COPTS = select({ + "//conditions:default": ["-std=c++17"], + "@rules_cc//cc/compiler:msvc-cl": _MSVC_FLAGS, + "@rules_cc//cc/compiler:clang-cl": _MSVC_FLAGS, +}) [cc_test( name = test, srcs = ["{}.cpp".format(test)], deps = ["@magic_enum", ":catch2"], - copts = COPTS, + copts = _COPTS, ) for test in _TESTS] + +# bazel central registry has a catch2 module, but is newer than the one included +# in this repository +cc_library( + name = "catch2", + includes = ["3rdparty/Catch2/include"], + hdrs = ["3rdparty/Catch2/include/catch2/catch.hpp"], +) diff --git a/test/MODULE.bazel b/test/MODULE.bazel index 647799fbd..58bf66b91 100644 --- a/test/MODULE.bazel +++ b/test/MODULE.bazel @@ -1,6 +1,6 @@ module(name = "magic_enum_tests") bazel_dep(name = "magic_enum") -bazel_dep(name = "rules_cc", version = "0.0.8") - local_path_override(module_name = "magic_enum", path = "..") + +bazel_dep(name = "rules_cc", version = "0.0.8")