Follow this to install bazel - https://bazel.build/install
- BUILD file - Contains the build instructions for the targets.
- MODULE.bazel file - Contains the module name and the dependencies.
To compile BOOTSTRAP, PROVIDER and REQUESTER, run the following commands:
bazel build //...
To compile BOOTSTRAP, PROVIDER and REQUESTER locally, run the following commands:
bazel build //... --define local=true
To execute, run the following commands:
./bazel-bin/bootstrap
(8080 is reserved for bootstrap port so peers know where to connect)
./bazel-bin/provider [8080]
(8080 is the default port, optional parameter)
./bazel-bin/requester [8080 [r | c]]
8080
is the default port, optional parameter
r
is an optional parameter to request to receive the result of the computation (use same port as original request execution)
c
is an optional parameter to request to provide the computation
bazel clean
Add the external dependency in MODULE.bazel file. This will now be visible to all the targets in the module.
For example:
http_archive(
name = "com_github_nlohmann_json",
urls = ["https://github.com/nlohmann/json/archive/v3.11.3.tar.gz"],
sha256 = "0d8ef5af7f9794e3263480193c491549b2ba6cc74bb018906202ada498a79406",
strip_prefix = "json-3.11.3",
)
To include the dependency build files in VSCode, add the following to the includePath for Cpp:
"C_Cpp.default.includePath": [
"${workspaceFolder}/bazel-PeerToPeer/external/{your_target_directory}"
]