1
0
Fork 0
mirror of https://github.com/Neargye/magic_enum.git synced 2026-01-08 23:24:20 +00:00

Simplify Bazel (#312)

This commit is contained in:
Chris Sauer 2023-11-15 02:17:08 -08:00 committed by GitHub
parent 3437129f30
commit 016883d29a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 35 deletions

View file

@ -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/magic_enum"],
)

View file

@ -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")

View file

View file

@ -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-",
],
})

View file

@ -1,5 +1,20 @@
load("@rules_cc//cc:defs.bzl", "cc_test")
load("@magic_enum//bazel:copts.bzl", "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,
) for test in _TESTS]
# bazel central registry has a catch2 module, but is newer than the one included
# in this repository
@ -7,17 +22,4 @@ cc_library(
name = "catch2",
includes = ["3rdparty/Catch2/include"],
hdrs = ["3rdparty/Catch2/include/catch2/catch.hpp"],
copts = COPTS,
)
_TESTS = [
"test",
"test_flags",
]
[cc_test(
name = test,
srcs = ["{}.cpp".format(test)],
deps = ["@magic_enum", ":catch2"],
copts = COPTS,
) for test in _TESTS]

View file

@ -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")