diff --git a/.gitignore b/.gitignore index 086e855c0..b4a1ee35c 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,5 @@ cmake-build-debug test/test-* /.vs + +bazel-* diff --git a/.travis.yml b/.travis.yml index 484c9350d..cb36cd784 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/BUILD b/BUILD new file mode 100644 index 000000000..7ee16fd52 --- /dev/null +++ b/BUILD @@ -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 = [], +) diff --git a/README.md b/README.md index 8d2bb3c99..a5a3278a0 100644 --- a/README.md +++ b/README.md @@ -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`. diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 000000000..86de2d6e9 --- /dev/null +++ b/WORKSPACE @@ -0,0 +1 @@ +workspace(name = "com_github_nlohmann_json") diff --git a/nlohmann_json.bzl b/nlohmann_json.bzl new file mode 100644 index 000000000..114956268 --- /dev/null +++ b/nlohmann_json.bzl @@ -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 = [ +]