mirror of
https://github.com/Neargye/magic_enum.git
synced 2026-01-08 23:24:20 +00:00
add bzlmod support (#254)
This commit is contained in:
parent
fc88b4936a
commit
48054f64ab
18 changed files with 134 additions and 63 deletions
19
.bazelrc
Normal file
19
.bazelrc
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
common --enable_bzlmod
|
||||
build --enable_platform_specific_config
|
||||
build --incompatible_use_platforms_repo_for_constraints
|
||||
build --enable_runfiles
|
||||
build --incompatible_strict_action_env
|
||||
|
||||
build:linux --host_platform=@magic_enum//bazel/platforms:linux
|
||||
build:linux --platforms=@magic_enum//bazel/platforms:linux
|
||||
|
||||
build:macos --host_platform=@magic_enum//bazel/platforms:macos
|
||||
build:macos --platforms=@magic_enum//bazel/platforms:macos
|
||||
|
||||
build:windows --host_platform=@magic_enum//bazel/platforms:windows
|
||||
build:windows --platforms=@magic_enum//bazel/platforms:windows
|
||||
|
||||
common:ci --announce_rc
|
||||
test:ci --test_output=errors
|
||||
build:ci --curses=no
|
||||
|
||||
1
.bazelversion
Normal file
1
.bazelversion
Normal file
|
|
@ -0,0 +1 @@
|
|||
6.1.2
|
||||
3
.github/workflows/macos.yml
vendored
3
.github/workflows/macos.yml
vendored
|
|
@ -35,3 +35,6 @@ jobs:
|
|||
cmake .. -DCMAKE_BUILD_TYPE=Debug
|
||||
cmake --build . --config Debug
|
||||
ctest --output-on-failure -C Debug
|
||||
|
||||
- name: Bazel Test
|
||||
run: bazelisk test //... --config=ci
|
||||
|
|
|
|||
12
.github/workflows/ubuntu.yml
vendored
12
.github/workflows/ubuntu.yml
vendored
|
|
@ -52,13 +52,6 @@ jobs:
|
|||
sudo apt install ${{matrix.compiler.cxx}} -y
|
||||
fi
|
||||
|
||||
- name: Configure bazel
|
||||
run: |
|
||||
wget -O - https://bazel.build/bazel-release.pub.gpg|sudo apt-key add -
|
||||
sudo apt-add-repository "deb https://storage.googleapis.com/bazel-apt stable jdk1.8"
|
||||
sudo apt update
|
||||
sudo apt install bazel -y
|
||||
|
||||
- name: Build Release
|
||||
run: |
|
||||
rm -rf build
|
||||
|
|
@ -76,5 +69,6 @@ jobs:
|
|||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
|
||||
cmake --build . --config Debug
|
||||
ctest --output-on-failure -C Debug
|
||||
cd ..
|
||||
bazel test //... --curses no
|
||||
|
||||
- name: Bazel Test
|
||||
run: bazelisk test //... --config=ci
|
||||
|
|
|
|||
2
.github/workflows/windows.yml
vendored
2
.github/workflows/windows.yml
vendored
|
|
@ -42,3 +42,5 @@ jobs:
|
|||
cmake --build . --config Debug
|
||||
ctest --output-on-failure -C Debug
|
||||
|
||||
- name: Bazel Test
|
||||
run: bazelisk test //... --config=ci
|
||||
|
|
|
|||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -51,3 +51,4 @@ _deps
|
|||
|
||||
### Bazel build artifacts ###
|
||||
/bazel-*
|
||||
/test/bazel-*
|
||||
|
|
|
|||
58
BUILD.bazel
58
BUILD.bazel
|
|
@ -1,3 +1,6 @@
|
|||
load("@rules_cc//cc:defs.bzl", "cc_library")
|
||||
load("//bazel:copts.bzl", "COPTS")
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
exports_files(["LICENSE"])
|
||||
|
|
@ -6,58 +9,7 @@ package(default_visibility = ["//visibility:public"])
|
|||
|
||||
cc_library(
|
||||
name = "magic_enum",
|
||||
hdrs = ["include/magic_enum.hpp", "include/magic_enum_format.hpp", "include/magic_enum_fuse.hpp", "include/magic_enum_switch.hpp"],
|
||||
hdrs = glob(["include/*.hpp"]),
|
||||
copts = COPTS,
|
||||
includes = ["include"],
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "example",
|
||||
srcs = ["example/example.cpp"],
|
||||
copts = ["-std=c++17"],
|
||||
deps = [":magic_enum"],
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "enum_flag_example",
|
||||
srcs = ["example/enum_flag_example.cpp"],
|
||||
copts = ["-std=c++17"],
|
||||
deps = [":magic_enum"],
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "example_custom_name",
|
||||
srcs = ["example/example_custom_name.cpp"],
|
||||
copts = ["-std=c++17"],
|
||||
deps = [":magic_enum"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "catch",
|
||||
srcs = [],
|
||||
hdrs = ["test/3rdparty/Catch2/include/catch2/catch.hpp"],
|
||||
strip_include_prefix = "test/3rdparty/Catch2/include",
|
||||
)
|
||||
|
||||
cc_test(
|
||||
name = "test",
|
||||
srcs = [
|
||||
"test/test.cpp",
|
||||
],
|
||||
copts = ["-std=c++17"],
|
||||
deps = [
|
||||
":catch",
|
||||
":magic_enum",
|
||||
],
|
||||
)
|
||||
|
||||
cc_test(
|
||||
name = "test_flags",
|
||||
srcs = [
|
||||
"test/test_flags.cpp",
|
||||
],
|
||||
copts = ["-std=c++17"],
|
||||
deps = [
|
||||
":catch",
|
||||
":magic_enum",
|
||||
],
|
||||
)
|
||||
|
|
|
|||
8
MODULE.bazel
Normal file
8
MODULE.bazel
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
module(
|
||||
name = "magic_enum",
|
||||
version = "0.8.2",
|
||||
compatibility_level = 0,
|
||||
)
|
||||
|
||||
bazel_dep(name = "platforms", version = "0.0.6")
|
||||
bazel_dep(name = "rules_cc", version = "0.0.6")
|
||||
|
|
@ -301,7 +301,7 @@ Header-only C++17 library provides static reflection for enums, work with any en
|
|||
```
|
||||
bazel build //...
|
||||
bazel test //...
|
||||
bazel run //:example
|
||||
bazel run //example
|
||||
```
|
||||
|
||||
(Note that you must use a supported compiler or specify it with `export CC= <compiler>`.)
|
||||
|
|
|
|||
0
bazel/BUILD.bazel
Normal file
0
bazel/BUILD.bazel
Normal file
4
bazel/copts.bzl
Normal file
4
bazel/copts.bzl
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
COPTS = select({
|
||||
"@bazel_tools//tools/cpp:msvc": ["/std:c++17", "/permissive-"],
|
||||
"//conditions:default": ["-std=c++17"],
|
||||
})
|
||||
25
bazel/platforms/BUILD.bazel
Normal file
25
bazel/platforms/BUILD.bazel
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package(default_visibility = ["//:__subpackages__"])
|
||||
|
||||
platform(
|
||||
name = "linux",
|
||||
constraint_values = [
|
||||
"@platforms//os:linux",
|
||||
"@bazel_tools//tools/cpp:clang",
|
||||
],
|
||||
)
|
||||
|
||||
platform(
|
||||
name = "macos",
|
||||
constraint_values = [
|
||||
"@platforms//os:macos",
|
||||
"@bazel_tools//tools/cpp:clang",
|
||||
],
|
||||
)
|
||||
|
||||
platform(
|
||||
name = "windows",
|
||||
constraint_values = [
|
||||
"@platforms//os:windows",
|
||||
"@bazel_tools//tools/cpp:msvc",
|
||||
],
|
||||
)
|
||||
28
example/BUILD.bazel
Normal file
28
example/BUILD.bazel
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
load("@rules_cc//cc:defs.bzl", "cc_binary")
|
||||
load("@magic_enum//bazel:copts.bzl", "COPTS")
|
||||
|
||||
_EXAMPLES = [
|
||||
"enum_flag_example",
|
||||
"example",
|
||||
"example_containers_array",
|
||||
"example_containers_bitset",
|
||||
"example_containers_set",
|
||||
"example_custom_name",
|
||||
"example_switch",
|
||||
]
|
||||
|
||||
[cc_binary(
|
||||
name = example,
|
||||
srcs = ["{}.cpp".format(example)],
|
||||
deps = ["@magic_enum"],
|
||||
copts = COPTS,
|
||||
) for example in _EXAMPLES]
|
||||
|
||||
cc_binary(
|
||||
name = "example_nonascii_name",
|
||||
srcs = ["example_nonascii_name.cpp"],
|
||||
deps = ["@magic_enum"],
|
||||
copts = COPTS,
|
||||
defines = ["MAGIC_ENUM_ENABLE_NONASCII"],
|
||||
tags = ["manual"],
|
||||
)
|
||||
2
test/.bazelrc
Normal file
2
test/.bazelrc
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
import %workspace%/../.bazelrc
|
||||
|
||||
25
test/BUILD.bazel
Normal file
25
test/BUILD.bazel
Normal file
|
|
@ -0,0 +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_aliases",
|
||||
"test_containers",
|
||||
"test_flags",
|
||||
]
|
||||
|
||||
[cc_test(
|
||||
name = test,
|
||||
srcs = ["{}.cpp".format(test)],
|
||||
deps = ["@magic_enum", ":catch2"],
|
||||
copts = COPTS,
|
||||
) for test in _TESTS]
|
||||
7
test/MODULE.bazel
Normal file
7
test/MODULE.bazel
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
module(name = "magic_enum_tests")
|
||||
|
||||
bazel_dep(name = "magic_enum")
|
||||
bazel_dep(name = "platforms", version = "0.0.6")
|
||||
bazel_dep(name = "rules_cc", version = "0.0.6")
|
||||
|
||||
local_path_override(module_name = "magic_enum", path = "..")
|
||||
0
test/WORKSPACE.bazel
Normal file
0
test/WORKSPACE.bazel
Normal file
Loading…
Add table
Add a link
Reference in a new issue