drogonframework / drogonframework/drogon
Support for bazel C++ - adding compilation rules (BUILD.bazel)
- Dominant language
- C++
- Stars
- 14.3k
- Forks
- 1.4k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 14
Description
I Would like to have an option for easy compilation of the Drogon in my Bazel project, something like:
**WORKSPACE.bazel**
```
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "drogon",
urls = ["https://github.com/drogonframework/drogon/archive/refs/heads/master.zip"],
strip_prefix = "drogon-master",
)
```
**BUILD.bazel**
```
load("@rules_cc//cc:defs.bzl", "cc_library")
cc_library(
name="drogon",
deps = [
"@drogon//:drogon"
]
)
```
An excellent example of this is in one of the Drogon dependencies (https://github.com/open-source-parsers/jsoncpp) which you can compile with Bazel via:
**WORKSPACE.bazel**
```
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name="jsoncpp",
urls=["https://github.com/open-source-parsers/jsoncpp/archive/refs/heads/master.zip"],
strip_prefix="jsoncpp-master"
)
```
**BUILD.bazel**
```
load("@rules_cc//cc:defs.bzl", "cc_library")
cc_library(
name = "jsoncpp",
deps = [
"@jsoncpp//:jsoncpp"
]
)
```
This is possible because in the repo **jsoncpp** there is a library target specified (BUILD.bazel): *jsoncpp**
If I want to use Drogon right now, I need to run `make` via Bazel which is not ideal and not straightforward.
This change would allow me to have very clear access to this library and my project would be less prone to linking
errors, because the whole process would be way easier to debug
For invoking bazel in all of this cases I am using `bazel build --config=gcc :all` command, where config is defined in **.bazelrc** file that contains:
```
build -c opt
build:gcc --cxxopt=-std=c++17 --color=auto
```
I am using GCC 9.4.0
Contributor guide
Assessment
This issue has not been assessed yet.