diff --git a/.bazelrc b/.bazelrc index e1ea66ff..63ce8470 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,2 +1,2 @@ -build --copt='-std=c++17' --linkopt='-L/usr/local/lib' - +common --cxxopt=-std=c++17 +common --registry=file:///home/dev-user/code/bazel-central-registry diff --git a/.gitignore b/.gitignore index 0727dffc..509a2744 100755 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,7 @@ *.*~ build/ -install/ \ No newline at end of file +install/ + +bazel-* +MODULE.bazel.lock diff --git a/BUILD.bazel b/BUILD.bazel index 5e4db202..aa121484 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,12 +1,14 @@ cc_library( name = "modern-cpp-kafka-api", - - hdrs = glob(["include/kafka/*.h", "include/kafka/addons/*.h"]), - + hdrs = glob([ + "include/kafka/*.h", + "include/kafka/addons/*.h", + ]), includes = ["include"], - linkopts = ["-lpthread"], - visibility = ["//visibility:public"], + deps = [ + "@rapidjson", + "@librdkafka", + ], ) - diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 00000000..d474b8ea --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,8 @@ +module(name = "modern-cpp-kafka") + +bazel_dep(name = "boost.algorithm", version = "1.87.0") +bazel_dep(name = "googletest", version = "1.16.0", repo_name = "gtest") +bazel_dep(name = "librdkafka", version = "2.8.0.bcr.1") +bazel_dep(name = "rapidjson", version = "1.1.0.bcr.20241007") + +# USE_BAZEL_VERSION=7.x bazel shutdown && USE_BAZEL_VERSION=7.x bazel --nosystem_rc --nohome_rc test --announce_rc --verbose_failures --sandbox_debug --test_output=all -- //tests:kafka-unit-test diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel index 5e1ccfaf..fcb779e0 100644 --- a/tests/BUILD.bazel +++ b/tests/BUILD.bazel @@ -1,52 +1,47 @@ cc_test( name = "kafka-unit-test", - - srcs = glob(["unit/*.cc", "utils/*.h"]), - - deps = ["//:modern-cpp-kafka-api", - "@gtest//:gtest", - "@gtest//:gtest_main", - "@rapidjson//:rapidjson"], - - linkopts = ["-lrdkafka"], - - timeout = "short", - - tags = ["unit"], + srcs = glob([ + "unit/*.cc", + "utils/*.h", + ]), + deps = [ + "//:modern-cpp-kafka-api", + "@boost.algorithm", + "@gtest", + "@gtest//:gtest_main", + ], ) - cc_test( name = "kafka-integration-test", - - srcs = glob(["integration/*.cc", "utils/*.h"]), - - deps = ["//:modern-cpp-kafka-api", - "@gtest//:gtest", - "@gtest//:gtest_main"], - - linkopts = ["-lrdkafka"], - timeout = "long", + srcs = glob([ + "integration/*.cc", + "utils/*.h", + ]), + linkopts = ["-lrdkafka"], shard_count = 8, - tags = ["integration"], + deps = [ + "//:modern-cpp-kafka-api", + "@gtest", + "@gtest//:gtest_main", + ], ) cc_test( name = "kafka-robustness-test", - - srcs = glob(["robustness/*.cc", "utils/*.h"]), - - deps = ["//:modern-cpp-kafka-api", - "@gtest//:gtest", - "@gtest//:gtest_main"], - - linkopts = ["-lrdkafka"], - timeout = "long", + srcs = glob([ + "robustness/*.cc", + "utils/*.h", + ]), + linkopts = ["-lrdkafka"], shard_count = 1, - tags = ["robustness"], + deps = [ + "//:modern-cpp-kafka-api", + "@gtest", + "@gtest//:gtest_main", + ], ) -