diff options
Diffstat (limited to 'examples/bazel')
| -rw-r--r-- | examples/bazel/MODULE.bazel | 13 | ||||
| -rw-r--r-- | examples/bazel/WORKSPACE | 19 | ||||
| -rw-r--r-- | examples/bazel/src/BUILD | 10 | ||||
| -rw-r--r-- | examples/bazel/src/hello_test.cc | 10 | ||||
| -rw-r--r-- | examples/bazel/third_party/libcbor.BUILD | 21 | ||||
| -rw-r--r-- | examples/bazel/third_party/libcbor/cbor/configuration.h | 2 |
6 files changed, 26 insertions, 49 deletions
diff --git a/examples/bazel/MODULE.bazel b/examples/bazel/MODULE.bazel new file mode 100644 index 000000000000..5d14df5cf761 --- /dev/null +++ b/examples/bazel/MODULE.bazel @@ -0,0 +1,13 @@ +module( + name = "libcbor_bazel_example", + version = "0.1.0", +) + +bazel_dep(name = "rules_cc", version = "0.1.1") +bazel_dep(name = "googletest", version = "1.15.2") + +bazel_dep(name = "libcbor") +local_path_override( + module_name = "libcbor", + path = "../..", +) diff --git a/examples/bazel/WORKSPACE b/examples/bazel/WORKSPACE deleted file mode 100644 index c7601f3035ff..000000000000 --- a/examples/bazel/WORKSPACE +++ /dev/null @@ -1,19 +0,0 @@ -workspace(name = "libcbor_bazel_example") - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -# Google Test -http_archive( - name = "gtest", - sha256 = "94c634d499558a76fa649edb13721dce6e98fb1e7018dfaeba3cd7a083945e91", - strip_prefix = "googletest-release-1.10.0", - url = "https://github.com/google/googletest/archive/release-1.10.0.zip", -) - -# libcbor -new_local_repository( - name = "libcbor", - build_file = "//third_party:libcbor.BUILD", - path = "../../src", -) - diff --git a/examples/bazel/src/BUILD b/examples/bazel/src/BUILD index d3acb578398a..367094644a5f 100644 --- a/examples/bazel/src/BUILD +++ b/examples/bazel/src/BUILD @@ -2,7 +2,7 @@ load("@rules_cc//cc:defs.bzl", "cc_library") load("@rules_cc//cc:defs.bzl", "cc_binary") cc_library( - name = "src", + name = "hello_lib", srcs = [ "hello.cc", ], @@ -18,7 +18,7 @@ cc_library( ) cc_test( - name = "tests", + name = "hello_test", size = "small", srcs = [ "hello_test.cc", @@ -27,8 +27,8 @@ cc_test( "//visibility:private", ], deps = [ - ":src", - "@gtest//:gtest_main", + ":hello_lib", + "@googletest//:gtest_main", "@libcbor//:cbor", ], ) @@ -40,7 +40,7 @@ cc_binary( "main.cc", ], deps = [ - ":src", + ":hello_lib", ], ) diff --git a/examples/bazel/src/hello_test.cc b/examples/bazel/src/hello_test.cc index 68d8633c8772..7aa85e79fc5a 100644 --- a/examples/bazel/src/hello_test.cc +++ b/examples/bazel/src/hello_test.cc @@ -1,10 +1,14 @@ #include "src/hello.h" +#include "cbor.h" #include "gtest/gtest.h" -class HelloTest : public ::testing::Test {}; +class CborTest : public ::testing::Test {}; -TEST_F(HelloTest, CborVersion) { - EXPECT_EQ(cbor_version(), 0); +TEST_F(CborTest, IntegerItem) { + cbor_item_t * answer = cbor_build_uint8(42); + EXPECT_EQ(cbor_get_uint8(answer), 42); + cbor_decref(&answer); + EXPECT_EQ(answer, nullptr); } diff --git a/examples/bazel/third_party/libcbor.BUILD b/examples/bazel/third_party/libcbor.BUILD deleted file mode 100644 index 45f4975b4fc8..000000000000 --- a/examples/bazel/third_party/libcbor.BUILD +++ /dev/null @@ -1,21 +0,0 @@ -cc_library( - name = "cbor", - srcs = glob([ - "src/**/*.h", - "src/**/*.c", - ]), - hdrs = [ - "cbor.h", - ] + glob([ - "cbor/*.h", - ]), - includes = [ - "src", - "src/cbor", - "src/cbor/internal", - ], - visibility = ["//visibility:public"], - deps = [ - "@libcbor_bazel_example//third_party/libcbor:config", - ], -) diff --git a/examples/bazel/third_party/libcbor/cbor/configuration.h b/examples/bazel/third_party/libcbor/cbor/configuration.h index ddf6b9dc5f2b..070b54d9c2ae 100644 --- a/examples/bazel/third_party/libcbor/cbor/configuration.h +++ b/examples/bazel/third_party/libcbor/cbor/configuration.h @@ -2,7 +2,7 @@ #define LIBCBOR_CONFIGURATION_H #define CBOR_MAJOR_VERSION 0 -#define CBOR_MINOR_VERSION 11 +#define CBOR_MINOR_VERSION 12 #define CBOR_PATCH_VERSION 0 #define CBOR_BUFFER_GROWTH 2 |
