Add CI build testing JSON as a bazel dependency.
This commit is contained in:
parent
a015b78e81
commit
e73bd824fa
2
.gitignore
vendored
2
.gitignore
vendored
@ -23,3 +23,5 @@ cmake-build-debug
|
|||||||
|
|
||||||
test/test-*
|
test/test-*
|
||||||
/.vs
|
/.vs
|
||||||
|
|
||||||
|
bazel-*
|
||||||
|
|||||||
13
.travis.yml
13
.travis.yml
@ -39,6 +39,19 @@ matrix:
|
|||||||
sources: ['ubuntu-toolchain-r-test']
|
sources: ['ubuntu-toolchain-r-test']
|
||||||
packages: ['g++-4.9', 'valgrind', 'ninja-build']
|
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: cd test/bazel_dependency && $HOME/bin/bazel build --test_output=errors --verbose_failures=true --keep_going -- //...:all
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
update: true
|
||||||
|
|
||||||
# clang sanitizer
|
# clang sanitizer
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: clang
|
compiler: clang
|
||||||
|
|||||||
15
BUILD
Normal file
15
BUILD
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
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,
|
||||||
|
includes = ["include"],
|
||||||
|
deps = [],
|
||||||
|
)
|
||||||
28
README.md
28
README.md
@ -148,6 +148,34 @@ endif()
|
|||||||
|
|
||||||
`thirdparty/nlohmann_json` is then a complete copy of this source tree.
|
`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
|
### 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`.
|
: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`.
|
||||||
|
|||||||
39
nlohmann_json.bzl
Normal file
39
nlohmann_json.bzl
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
nlohmann_json_hdrs = [
|
||||||
|
"include/nlohmann/adl_serializer.hpp",
|
||||||
|
"include/nlohmann/json_fwd.hpp",
|
||||||
|
"include/nlohmann/thirdparty/hedley/hedley_undef.hpp",
|
||||||
|
"include/nlohmann/thirdparty/hedley/hedley.hpp",
|
||||||
|
"include/nlohmann/json.hpp",
|
||||||
|
"include/nlohmann/detail/json_pointer.hpp",
|
||||||
|
"include/nlohmann/detail/value_t.hpp",
|
||||||
|
"include/nlohmann/detail/input/json_sax.hpp",
|
||||||
|
"include/nlohmann/detail/input/lexer.hpp",
|
||||||
|
"include/nlohmann/detail/input/input_adapters.hpp",
|
||||||
|
"include/nlohmann/detail/input/position_t.hpp",
|
||||||
|
"include/nlohmann/detail/input/binary_reader.hpp",
|
||||||
|
"include/nlohmann/detail/input/parser.hpp",
|
||||||
|
"include/nlohmann/detail/iterators/internal_iterator.hpp",
|
||||||
|
"include/nlohmann/detail/iterators/iteration_proxy.hpp",
|
||||||
|
"include/nlohmann/detail/iterators/json_reverse_iterator.hpp",
|
||||||
|
"include/nlohmann/detail/iterators/iterator_traits.hpp",
|
||||||
|
"include/nlohmann/detail/iterators/iter_impl.hpp",
|
||||||
|
"include/nlohmann/detail/iterators/primitive_iterator.hpp",
|
||||||
|
"include/nlohmann/detail/json_ref.hpp",
|
||||||
|
"include/nlohmann/detail/macro_scope.hpp",
|
||||||
|
"include/nlohmann/detail/macro_unscope.hpp",
|
||||||
|
"include/nlohmann/detail/exceptions.hpp",
|
||||||
|
"include/nlohmann/detail/output/output_adapters.hpp",
|
||||||
|
"include/nlohmann/detail/output/serializer.hpp",
|
||||||
|
"include/nlohmann/detail/output/binary_writer.hpp",
|
||||||
|
"include/nlohmann/detail/conversions/from_json.hpp",
|
||||||
|
"include/nlohmann/detail/conversions/to_chars.hpp",
|
||||||
|
"include/nlohmann/detail/conversions/to_json.hpp",
|
||||||
|
"include/nlohmann/detail/meta/void_t.hpp",
|
||||||
|
"include/nlohmann/detail/meta/cpp_future.hpp",
|
||||||
|
"include/nlohmann/detail/meta/detected.hpp",
|
||||||
|
"include/nlohmann/detail/meta/is_sax.hpp",
|
||||||
|
"include/nlohmann/detail/meta/type_traits.hpp",
|
||||||
|
]
|
||||||
|
|
||||||
|
nlohmann_json_srcs = [
|
||||||
|
]
|
||||||
11
test/bazel_dependency/BUILD
Normal file
11
test/bazel_dependency/BUILD
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package(default_visibility = ["//visibility:public"])
|
||||||
|
|
||||||
|
cc_binary(
|
||||||
|
name = "nlohmann_json_test",
|
||||||
|
srcs = [
|
||||||
|
"main.cpp",
|
||||||
|
],
|
||||||
|
deps = [
|
||||||
|
"@com_github_nlohmann_json//:nlohmann_json",
|
||||||
|
],
|
||||||
|
)
|
||||||
18
test/bazel_dependency/WORKSPACE
Normal file
18
test/bazel_dependency/WORKSPACE
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
workspace(name = "com_github_nlohmann_json_bazel_dependency")
|
||||||
|
|
||||||
|
# Developers should use something like:
|
||||||
|
|
||||||
|
# http_file(
|
||||||
|
# name = "com_github_nlohmann_json_single_header",
|
||||||
|
# urls = [
|
||||||
|
# "https://github.com/nlohmann/json/releases/download/v3.4.0/json.hpp",
|
||||||
|
# ],
|
||||||
|
# sha256 = "63da6d1f22b2a7bb9e4ff7d6b255cf691a161ff49532dcc45d398a53e295835f",
|
||||||
|
# )
|
||||||
|
#
|
||||||
|
# But this tests the trunk of nlohmann_json.
|
||||||
|
|
||||||
|
local_repository(
|
||||||
|
name = "com_github_nlohmann_json",
|
||||||
|
path = "../..",
|
||||||
|
)
|
||||||
12
test/bazel_dependency/main.cpp
Normal file
12
test/bazel_dependency/main.cpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* We use quotes per the doc's recommendation:
|
||||||
|
* https://docs.bazel.build/versions/master/bazel-and-cpp.html#include-paths
|
||||||
|
*/
|
||||||
|
#include "nlohmann/json.hpp"
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
nlohmann::json j;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user