Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:SeleniumHQ Selenium Bazel Build And Go Wrapper

From Leeroopedia
Knowledge Sources
Domains Build_Systems, Continuous_Integration, Quality_Assurance
Last Updated 2026-02-11 00:00 GMT

Overview

External tool documentation for building Selenium using Bazel and the ./go Rake wrapper.

Description

Direct bazel build commands compile specific targets. Each buildable module is defined in a BUILD.bazel file and referenced by the label format //relative/path:target_name. Bazel supports wildcard patterns such as //java/... to build everything under a directory.

The ./go wrapper invokes Rake tasks that call Bazel.execute() (defined in rake_tasks/bazel.rb), which uses Ruby's Open3.popen2e for process execution on Unix and backtick shell execution on Windows. The Bazel.execute method takes a kind (build/test/run), args, and target, constructs the full bazel command, executes it, and extracts output artifact paths matching bazel-bin/ from the output. If the target ends with :run, it automatically switches the kind to run and strips the suffix.

Usage

Use bazel build directly or ./go <lang>:build via the Rake wrapper. Prefer targeted builds for the specific package you changed. Use bazel query to discover available targets before building.

Code Reference

Source Location

  • Repository: Selenium
  • File: README.md (L139-180)
  • File: rake_tasks/bazel.rb (L1-66)

Signature

# Direct Bazel - build a specific language
bazel build //java/...
bazel build //py/...
bazel build //rb/...
bazel build //dotnet/...
bazel build //javascript/selenium-webdriver/...
bazel build //rust/...

# Build Grid (alias)
bazel build grid

# Build specific target
bazel build //java/src/org/openqa/selenium/grid:executable-grid

# Query build graph to discover targets
bazel query 'kind(rule, //java/src/org/openqa/selenium/chrome/...)'

# Via ./go wrapper (Rake tasks)
./go java:build
./go py:build
./go rb:build

# Local install commands
./go java:install     # Deploy to ~/.m2/repository
./go py:install       # Build and install wheel
./go py:local_dev     # Build generated files for source-tree use

Internal Implementation (rake_tasks/bazel.rb)

module Bazel
  def self.execute(kind, args, target, &block)
    # If target ends with ':run', switch kind to 'run'
    if target.end_with?(':run')
      kind = 'run'
      target = target[0, target.length - 4]
    end

    cmd = %w[bazel] + [kind, target] + (args || [])
    # Executes via Open3.popen2e (Unix) or backtick (Windows)
    # Raises on non-zero exit code
    # Extracts bazel-bin/ artifact path from output
  end
end

Import

N/A - External build tool commands

I/O Contract

Inputs

Name Type Required Description
target Bazel label Yes Build target (e.g., //java/..., grid, //java/src/.../chrome:ChromeDriver)
--config String No Build configuration (e.g., --config=rbe for remote build execution)
--stamp Flag No Include build metadata (used for release builds)

Outputs

Name Type Description
Artifacts Files Compiled artifacts in bazel-bin/
Exit code int 0 on success, non-zero on build failure

Usage Examples

Build Java Bindings

# Build all Java code
bazel build //java/...

# Build only Chrome driver module
bazel build //java/src/org/openqa/selenium/chrome/...

# Build Grid server (shortcut alias)
bazel build grid
# Output: bazel-bin/java/src/org/openqa/selenium/grid/executable-grid.jar

Using ./go Wrapper

# Build Java
./go java:build

# Install Java to local Maven repo
./go java:install

# Build Python and install locally
./go py:install

# Build Python generated files for local development
./go py:local_dev

Remote Build Execution (EngFlow)

# Build remotely (requires EngFlow access)
bazel build --config=rbe grid
bazel test --config=rbe java/test/...

Dependency Updates

# Java: Update dependency in MODULE.bazel, then repin
REPIN=1 bazel run @maven//:pin

# Or use the wrapper
./go java:update

# Rust: Sync Cargo.Bazel.lock with Cargo.lock
CARGO_BAZEL_REPIN=true bazel run @crates//:all

Related Pages

Implements Principle

Requires Environment

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment