Notes can be found here.
bazel --version # bazel 7.0.1
cd cpp-project
bazel run //greeting:helloworld
cd java-project
bazel run //:ProjectRunner
bazel run //:salutations
bazel run //:restclient
Queries:
cd java-project
bazel run //:runner
bazel query //src/main/java/com/query/dishes/...
bazel query --noimplicit_deps "deps(:runner)"
bazel query "rdeps(//... , //src/main/java/com/query/ingredients:salt)"
bazel query 'attr(tags, "hcp", //src/main/java/com/query/customers/...)'
cd py-project/app
bazel run //app:main
Gen Rules
cd rules/gen-rules
bazel build //:concat # See output (target) in bazel-bin/concat.txt
bazel build //:process_data # See output (target) in bazel-bin/output.txt
bazel build //:copy_files # See output (target) in bazel-bin/copy_file.txt
bazel build //:cat_files # See output (target) in bazel-bin/cat_files.txt
Custom Rules
name
in BUILD
is the target
cd rules/custom-rules
bazel build //:bin1 # See output (target) in bazel-bin/bin1
bazel build //:bin2 # See output (target) in bazel-bin/bin2
bazel build //:bin # See output (target) in bazel-bin/bin
bazel run //:say_hello_to_gaurav # This is equivalent to bazel build //:hello-gaurav; bazel run //:say_hello_to_gaurav
cd macros
bazel build //:hello_world_code_dive # See output in bazel-bin/hello_world_code_dive
bazel build //:hello_world_everyone # See output in bazel-bin/hello_world_everyone
bazel query --notool_deps --noimplicit_deps "deps(//:*)" --output graph
Sample here
cd rules/gen-rules
bazel aquery 'deps(//:concat)' # action query
bazel cquery 'deps(//:concat)' # configurable query
cd pythontoolchain
bazel run //:bin # It should print 3.10 (version mentioned in WORKSPACE) but in latest bazel version, it takes system version like 3.12.2 but you will see 3.10 version is being downloaded
- Hermetic Python Toolchain with Bazel.
- Writing custom Bazel C++ rules
- Writing Bazel rules: library rule, depsets, providers
- User-defined build settings for Bazel builds
For debugging,