Bazel Fundamentals Training
Master Bazel build system basics in 2 days. Hands-on training covering BUILD files, core commands, hermeticity, and multi-language builds.
Start your Bazel journey with this comprehensive 2-day training covering the build system that powers Google's entire codebase. Learn how Bazel's hermetic execution model, fine-grained dependency graph, and multi-language support deliver fast, correct, and reproducible builds at any scale.
Training Details
| Duration | 2 days (16 hours) |
| Level | Beginner |
| Delivery | In-person, Live online, Hybrid |
| Certification | N/A |
Who Is This For?
- Software engineers adopting Bazel for the first time
- Build engineers evaluating Bazel as a replacement for Make, Maven, or Gradle
- DevOps engineers responsible for build infrastructure
- Tech leads planning a migration to Bazel-based builds
- Developers working in multi-language repositories
Learning Outcomes
After completing this training, participants will be able to:
- Explain Bazel's architecture, hermeticity model, and advantages over traditional build systems
- Write BUILD files with correct target definitions, labels, and visibility declarations
- Build, test, and run targets in C++, Java, and Python using native Bazel rules
- Navigate the dependency graph using bazel query expressions
- Configure .bazelrc for project-specific and user-specific settings
- Structure a Bazel project with proper package boundaries and naming conventions
Detailed Agenda
Day 1: Bazel Core Concepts
Module 1: Bazel Overview and Philosophy
- What is Bazel: origin from Google Blaze, open-source release history
- Positioning vs Make, Maven, Gradle, Buck, Pants, and Turborepo
- Hermeticity and reproducibility: sandboxed actions, declared inputs/outputs
- The Bazel execution model: loading, analysis, and execution phases
- Artifact-based vs task-based build systems
- Hands-on: Install Bazel via Bazelisk, verify installation, explore Bazel version management
Module 2: Core Concepts and BUILD Files
- WORKSPACE vs MODULE.bazel: repository root markers
- BUILD files: packages, targets, rules, and labels (//pkg:target syntax)
- Visibility system: default_visibility, package_group, __pkg__ and __subpackages__
- Dependencies: deps, srcs, data attributes
- Label syntax: @repo//package:target, relative labels, implicit targets
- Hands-on: Create a multi-package project with BUILD files, visibility rules, and inter-package dependencies
Module 3: First Builds in C++ and Java
- cc_binary, cc_library, cc_test: compiling C++ with Bazel
- java_binary, java_library, java_test: building Java targets
- Header includes, copts, and linkopts for C++ targets
- Java runtime configuration and javacopts
- Understanding the output directory structure: bazel-bin, bazel-out, bazel-testlogs
- Hands-on: Build a C++ hello world binary and a Java command-line application with library dependencies
Module 4: Bazel Commands Deep Dive
- bazel build: target patterns, output groups, --config flags
- bazel run: executing binaries, passing arguments with --
- bazel test: test execution, --test_output, --test_filter, --test_timeout
- bazel clean: expunge mode, output base management
- bazel info: workspace, output_base, execution_root, bazel-bin
- Hands-on: Execute builds with various flags, inspect output directories, run tests with filtering
Day 2: Testing, Configuration, and Querying
Module 5: Python Rules and Multi-Language Patterns
- py_binary, py_library, py_test: Python target definitions
- Python runtime selection and interpreter paths
- Mixing languages: depending on cc_library from py_binary via Python C extensions
- filegroup and genrule for language-agnostic operations
- glob() function: include/exclude patterns for source file selection
- Hands-on: Build a Python CLI application with library dependencies and file-based test data
Module 6: Testing Fundamentals
- Test rules: cc_test, java_test, py_test, sh_test
- Test size declarations: small, medium, large, enormous
- Test tags: manual, exclusive, no-sandbox, local
- Test sharding with --test_sharding_strategy and shard_count
- Flaky test handling: --flaky_test_attempts, flaky attribute
- Hands-on: Write and execute test suites across languages, configure test timeouts and sizes
Module 7: Project Configuration with .bazelrc
- .bazelrc syntax: command-specific flags, config groups, imports
- User .bazelrc vs project .bazelrc vs system .bazelrc (load order)
- Common configurations: --disk_cache, --jobs, --verbose_failures
- try-import for optional local overrides
- Startup options vs command options
- Hands-on: Configure a .bazelrc with build/test profiles, set up local disk caching
Module 8: Bazel Query Basics and Capstone
- bazel query language: deps(), rdeps(), allpaths(), somepath()
- Output formats: --output label, --output graph, --output minrank
- Querying for build targets: kind(), attr(), filter()
- Visualizing dependency graphs with Graphviz dot format
- Combining query functions for complex dependency analysis
- Hands-on: Capstone project — structure a multi-language workspace with C++, Java, and Python packages, enforce visibility boundaries, and use query to verify the dependency graph
Prerequisites
- Command-line proficiency (terminal, shell basics)
- Basic programming experience in at least one language (C++, Java, or Python)
- Familiarity with compilation and linking concepts
- No prior Bazel experience required
Delivery Formats
| Format | Description |
|---|---|
| In-Person | On-site at your company's location, hands-on with direct interaction |
| Live Online | Interactive virtual sessions with screen sharing and real-time labs |
| Hybrid | Combination of on-site and remote sessions, flexible scheduling |
All formats include hands-on labs, course materials, and post-training support.
Ready to get started?
Request a training quote for your team — in-person, live-online, or hybrid.