Follow this to install bazel - https://bazel.build/install Follow this to clone and install the protobuf library - https://github.com/protocolbuffers/protobuf/tree/main/src
- BUILDfile - Contains the build instructions for the target.
- MODULE.bazelfile - Contains the module name and the dependencies.
This flag is necessary --experimental_google_legacy_api to use the protobuf library.
To build all targets, use the following command -
bazel build //... --experimental_google_legacy_api
To run the target, use the following command -
./bazel-bin/target_name
For granular build control, use the following commands -
bazel build //target_directory:target_name --experimental_google_legacy_api
Build using bazel build command -
- If in target directory and only one target is there, then use bazel build
- If in target directory and multiple targets are there, then use bazel build //target_name
- If outside target directory, then use bazel build //target_directory:target_name
Execute using ./bazel-bin/target_name command.
bazel clean