Add a bazel build.

This commit is contained in:
Tommy Nguyen 2019-07-26 17:40:44 -04:00
parent 65e4b973bd
commit fc3cd7aa7f
No known key found for this signature in database
GPG Key ID: 8E347123F020B734
6 changed files with 97 additions and 0 deletions

2
.gitignore vendored
View File

@ -23,3 +23,5 @@ cmake-build-debug
test/test-*
/.vs
bazel-*

View File

@ -39,6 +39,19 @@ matrix:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.9', 'valgrind', 'ninja-build']
# Bazel
- os: linux
compiler: gcc
before_install:
- sudo apt-get install -y pkg-config zip g++ zlib1g-dev unzip python3 wget
- wget -q https://github.com/bazelbuild/bazel/releases/download/0.28.1/bazel-0.28.1-installer-linux-x86_64.sh
- chmod +x bazel-0.28.1-installer-linux-x86_64.sh
- ./bazel-0.28.1-installer-linux-x86_64.sh --user
script: $HOME/bin/bazel build --test_output=errors --verbose_failures=true --keep_going -- //...:all
addons:
apt:
update: true
# clang sanitizer
- os: linux
compiler: clang

14
BUILD Normal file
View File

@ -0,0 +1,14 @@
package(default_visibility = ["//visibility:public"])
exports_files([
"LICENSE.MIT"
])
load(":nlohmann_json.bzl", "nlohmann_json_hdrs", "nlohmann_json_srcs")
cc_library(
name = "nlohmann_json",
srcs = nlohmann_json_srcs,
hdrs = nlohmann_json_hdrs,
deps = [],
)

View File

@ -148,6 +148,34 @@ endif()
`thirdparty/nlohmann_json` is then a complete copy of this source tree.
### Bazel
In order to use this project in Bazel, the simplest approach is to download the
single header release in your `bzl` or `BUILD` file:
```
http_file(
name = "com_github_nlohmann_json_single_header",
urls = [
"https://github.com/nlohmann/json/releases/download/v3.4.0/json.hpp",
],
sha256 = "63da6d1f22b2a7bb9e4ff7d6b255cf691a161ff49532dcc45d398a53e295835f",
)
```
Then include it as a dependency:
```
cc_library(
name = "foo",
srcs = foo_srcs,
hdrs = foo_hdrs,
deps = [
"@com_github_nlohmann_json_single_header//file"
],
)
```
### Package Managers
:beer: If you are using OS X and [Homebrew](http://brew.sh), just type `brew tap nlohmann/json` and `brew install nlohmann-json` and you're set. If you want the bleeding edge rather than the latest release, use `brew install nlohmann-json --HEAD`.

1
WORKSPACE Normal file
View File

@ -0,0 +1 @@
workspace(name = "com_github_nlohmann_json")

39
nlohmann_json.bzl Normal file
View File

@ -0,0 +1,39 @@
nlohmann_json_hdrs = [
"nlohmann/adl_serializer.hpp",
"nlohmann/json_fwd.hpp",
"nlohmann/thirdparty/hedley/hedley_undef.hpp",
"nlohmann/thirdparty/hedley/hedley.hpp",
"nlohmann/json.hpp",
"nlohmann/detail/json_pointer.hpp",
"nlohmann/detail/value_t.hpp",
"nlohmann/detail/input/json_sax.hpp",
"nlohmann/detail/input/lexer.hpp",
"nlohmann/detail/input/input_adapters.hpp",
"nlohmann/detail/input/position_t.hpp",
"nlohmann/detail/input/binary_reader.hpp",
"nlohmann/detail/input/parser.hpp",
"nlohmann/detail/iterators/internal_iterator.hpp",
"nlohmann/detail/iterators/iteration_proxy.hpp",
"nlohmann/detail/iterators/json_reverse_iterator.hpp",
"nlohmann/detail/iterators/iterator_traits.hpp",
"nlohmann/detail/iterators/iter_impl.hpp",
"nlohmann/detail/iterators/primitive_iterator.hpp",
"nlohmann/detail/json_ref.hpp",
"nlohmann/detail/macro_scope.hpp",
"nlohmann/detail/macro_unscope.hpp",
"nlohmann/detail/exceptions.hpp",
"nlohmann/detail/output/output_adapters.hpp",
"nlohmann/detail/output/serializer.hpp",
"nlohmann/detail/output/binary_writer.hpp",
"nlohmann/detail/conversions/from_json.hpp",
"nlohmann/detail/conversions/to_chars.hpp",
"nlohmann/detail/conversions/to_json.hpp",
"nlohmann/detail/meta/void_t.hpp",
"nlohmann/detail/meta/cpp_future.hpp",
"nlohmann/detail/meta/detected.hpp",
"nlohmann/detail/meta/is_sax.hpp",
"nlohmann/detail/meta/type_traits.hpp",
]
nlohmann_json_srcs = [
]