flolu / bazel

๐ŸŒฟ Getting started with Bazel for absolute beginners

Home Page:https://www.youtube.com/watch?v=6MXjAZWmn4Y

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

๐ŸŒฟ Bazel for beginners

Getting started with Bazel for absolute beginners

About Bazel

  • Bazel is a tool to build and test software at any scale
  • It's extremely fast and makes builds reproducible
  • It's able to build any language
  • It's used by many big companies

Bazel Basics

  • The WORKSPACE file marks the root of a Bazel workspace
  • BUILD files mark a directory as a package
  • Build targets are defined insideBUILD files
  • Targets are defined by rules
  • Rules are written in Starlark (But most end users won't rules themselves)

Usage

Installation

  • Install Bazelisk to manage different version of Bazel
    • With NPM: npm i -g @bazel/bazelisk (requires Node.js)
    • On macOS: brew install bazelisk

Commands

  • bazel version (Get version of Bazel)
  • bazel build //... (Build everything)
  • bazel clean (Clean Bazel outputs)
  • bazel build //files/... (Build everything inside the files package)
  • bazel build //:bazel_slogan (Only build the bazel_slogan target)
  • bazel test //... (Test everything)
  • bazel query ... (List all targets)
  • bazel query --noimplicit_deps 'deps(:bazel_slogan_test)' --output graph | dot -Tpng > graph.png (Generate a graph dependency graph of the :bazel_slogan_test target)

๐Ÿ’ก You can also omit the //

Development Environment

  • Install the official Bazel extensions
  • Install Buildifier for formatting
    • With NPM: npm i -g @bazel/buildifier (requires Node.js)
    • On macOS: brew install buildifier

About

๐ŸŒฟ Getting started with Bazel for absolute beginners

https://www.youtube.com/watch?v=6MXjAZWmn4Y


Languages

Language:Starlark 94.1%Language:Shell 5.9%