-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Bazel as an Alternative Build System and Package Manager (#18)
- Loading branch information
1 parent
11ab23b
commit 03a27bc
Showing
13 changed files
with
981 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# .bazelrc | ||
|
||
# Set the C++ standard to C++17 | ||
build --cxxopt='-std=c++17' | ||
|
||
# Enable warnings | ||
build --cxxopt='-Wall' | ||
build --cxxopt='-Wextra' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"""This is the MODULE.bazel file for the jsonrpc module.""" | ||
|
||
module( | ||
name = "jsonrpc", | ||
version = "1.0.0", | ||
) | ||
|
||
# Register the rules_foreign_cc and rules_cc dependencies | ||
bazel_dep(name = "rules_foreign_cc", version = "0.11.1") | ||
bazel_dep(name = "rules_cc", version = "0.0.9") | ||
|
||
# Register the nlohmann_json dependency | ||
bazel_dep(name = "nlohmann_json", version = "3.11.3") | ||
|
||
# Register the spdlog dependency | ||
bazel_dep(name = "spdlog", version = "1.14.1") | ||
|
||
# Register the catch2 dependency | ||
bazel_dep(name = "catch2", version = "3.6.0") |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
|
||
http_archive( | ||
name = "thread_pool", | ||
build_file = "//third_party/thread_pool:BUILD.bazel", | ||
sha256 = "be7abecbc420bb87919eeef729b13ff7c29d5ce547bdae284923296c695415bd", | ||
strip_prefix = "thread-pool-4.1.0", | ||
urls = ["https://github.com/bshoshany/thread-pool/archive/refs/tags/v4.1.0.tar.gz"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# examples/BUILD | ||
|
||
cc_binary( | ||
name = "stdio_client", | ||
srcs = ["stdio_client.cpp"], | ||
deps = ["//src:jsonrpc_lib"], | ||
) | ||
|
||
cc_binary( | ||
name = "stdio_server", | ||
srcs = [ | ||
"calculator.hpp", | ||
"stdio_server.cpp", | ||
], | ||
deps = ["//src:jsonrpc_lib"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
filegroup( | ||
name = "jsonrpc_headers", | ||
srcs = glob(["jsonrpc/**/*.hpp"]), | ||
visibility = ["//visibility:public"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
cc_library( | ||
name = "jsonrpc_lib", | ||
srcs = glob(["**/*.cpp"]), | ||
hdrs = ["//include:jsonrpc_headers"], | ||
includes = ["../include"], | ||
linkopts = ["-pthread"], | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"@nlohmann_json//:json", | ||
"@spdlog", | ||
"@thread_pool", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# tests/BUILD | ||
|
||
cc_test( | ||
name = "test_client", | ||
size = "small", | ||
srcs = ["client/test_client.cpp"], | ||
deps = [ | ||
"//src:jsonrpc_lib", | ||
"@catch2//:catch2_main", | ||
], | ||
) | ||
|
||
cc_test( | ||
name = "test_stdio_client_transport", | ||
size = "small", | ||
srcs = [ | ||
"client/transports/test_stdio_client_transport.cpp", | ||
"common/test_utilities.hpp", | ||
], | ||
deps = [ | ||
"//src:jsonrpc_lib", | ||
"@catch2//:catch2_main", | ||
], | ||
) | ||
|
||
cc_test( | ||
name = "test_dispatcher", | ||
size = "small", | ||
srcs = ["server/test_dispatcher.cpp"], | ||
deps = [ | ||
"//src:jsonrpc_lib", | ||
"@catch2//:catch2_main", | ||
], | ||
) | ||
|
||
cc_test( | ||
name = "test_request", | ||
size = "small", | ||
srcs = ["server/test_request.cpp"], | ||
deps = [ | ||
"//src:jsonrpc_lib", | ||
"@catch2//:catch2_main", | ||
], | ||
) | ||
|
||
cc_test( | ||
name = "test_response", | ||
size = "small", | ||
srcs = ["server/test_response.cpp"], | ||
deps = [ | ||
"//src:jsonrpc_lib", | ||
"@catch2//:catch2_main", | ||
], | ||
) | ||
|
||
cc_test( | ||
name = "test_server", | ||
size = "small", | ||
srcs = ["server/test_server.cpp"], | ||
deps = [ | ||
"//src:jsonrpc_lib", | ||
"@catch2//:catch2_main", | ||
], | ||
) | ||
|
||
cc_test( | ||
name = "test_framed_transport", | ||
size = "small", | ||
srcs = ["common/transports/test_framed_transport.cpp"], | ||
deps = [ | ||
"//src:jsonrpc_lib", | ||
"@catch2//:catch2_main", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
cc_library( | ||
name = "thread_pool", | ||
hdrs = glob(["include/*.hpp"]), | ||
includes = ["include"], | ||
visibility = ["//visibility:public"], | ||
) |