-
Notifications
You must be signed in to change notification settings - Fork 452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for bazel #56
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,3 +48,6 @@ install_manifest.txt | |
compile_commands.json | ||
CTestTestfile.cmake | ||
_deps | ||
|
||
### Bazel build artifacts ### | ||
bazel-* | ||
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,56 @@ | ||||||
licenses(["notice"]) | ||||||
|
||||||
exports_files(["LICENSE"]) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAIK bazel only has plans to support license files as part of the build, but since the repo provides it I am following (what I believe to be) an accepted convention of exporting it. |
||||||
|
||||||
package(default_visibility = ["//visibility:public"]) | ||||||
|
||||||
cc_library( | ||||||
name = "magic_enum", | ||||||
hdrs = ["include/magic_enum.hpp"], | ||||||
strip_include_prefix = "include", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you tested actually consuming this as an external dependency? I ask because IIRC
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that's much nicer. Thanks for the suggestion, done. |
||||||
) | ||||||
|
||||||
cc_binary( | ||||||
name = "example", | ||||||
srcs = ["example/example.cpp"], | ||||||
deps = [":magic_enum"], | ||||||
copts = ["-std=c++17"], | ||||||
) | ||||||
|
||||||
cc_binary( | ||||||
name = "enum_flag_example", | ||||||
srcs = ["example/enum_flag_example.cpp"], | ||||||
deps = [":magic_enum"], | ||||||
copts = ["-std=c++17"], | ||||||
) | ||||||
|
||||||
cc_binary( | ||||||
name = "example_custom_name", | ||||||
srcs = ["example/example_custom_name.cpp"], | ||||||
deps = [":magic_enum"], | ||||||
copts = ["-std=c++17"], | ||||||
) | ||||||
|
||||||
cc_library( | ||||||
name = "catch", | ||||||
srcs = [], | ||||||
hdrs = ["test/3rdparty/Catch2/catch.hpp"], | ||||||
strip_include_prefix = "test/3rdparty/Catch2", | ||||||
) | ||||||
|
||||||
cc_test( | ||||||
name = "test", | ||||||
srcs = [ | ||||||
"test/test.cpp", | ||||||
], | ||||||
deps = [":magic_enum", ":catch"], | ||||||
copts = ["-std=c++17"], | ||||||
) | ||||||
cc_test( | ||||||
name = "test_flags", | ||||||
srcs = [ | ||||||
"test/test_flags.cpp", | ||||||
], | ||||||
deps = [":magic_enum", ":catch"], | ||||||
copts = ["-std=c++17"], | ||||||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -219,6 +219,17 @@ CPMAddPackage( | |
) | ||
``` | ||
|
||
Bazel is also supported, simply add to your WORKSPACE file: | ||
``` | ||
git_repository( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the suggestion, done. |
||
name = "magic_enum", | ||
commit = <>, | ||
remote = "https://github.com/Neargye/magic_enum", | ||
) | ||
``` | ||
To use bazel inside the repository it's possible to do: | ||
`export CC=clang ; bazel build //... ; bazel test //... ; bazel run //:example` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Specifying There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I updated the comment, please let me know what you think. |
||
|
||
## Compiler compatibility | ||
|
||
* Clang/LLVM >= 5 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Nit] This will ignore
bazel-*
in all directories, but you actually only care about the symlinks created at the root of the repo.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, thanks.