Repo for learning Bazel
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Drew Bednar 4d955389bc A working Flask app 3 years ago
c_project A working Flask app 3 years ago
gen_package A working Flask app 3 years ago
ignored_workspace A working Flask app 3 years ago
my_py_app A working Flask app 3 years ago
py_project A working Flask app 3 years ago
third_party_py A working Flask app 3 years ago
.bazelversion Most basic of setups 3 years ago
.gitignore Initial commit 3 years ago
LICENSE Initial commit 3 years ago
README.md A working Flask app 3 years ago
WORKSPACE.bazel A working Flask app 3 years ago

README.md

learn_bazel

Repo for learning Bazel

Basics

https://bazel.build/start/bazel-intro

Rules are defined in a DSL called Starlark

  • A WORKSPACE is a hierarchy of directories
    • Contains Packages
      • Contains source files
      • Denoted by a one BUILD file.
        • Build files contain Rules
        • Targets: Identified by labels.
          • Labels
      • Sub directories containing a BUILD file are different packages. A file can only belong to one package.
    • Ignores sub dirs that contain another workspace

Builds

https://bazel.build/concepts/build-ref

Workspaces

Alias @

Denoted by WORKSPACE or WORKSPACE.bazel file. Subdirectories under the Workspace that contain a WORKSPACE are ignored as they are considered different workspaces.

External repositoies are defined in the WORKSPACE using workspace rules

Packages

The primary unit of code organization in a repository is the package. A package is a collection of related files and a specification of how they can be used to produce output artifacts.

A package is defined as a directory containing a file named BUILD (or BUILD.bazel). A package includes all files in its directory, plus all subdirectories beneath it, except those which themselves contain a BUILD file. From this definition, no file or directory may be a part of two different packages.

Targets

A package is a container of targets, which are defined in the package's BUILD file. Most targets are one of two principal kinds, files and rules.

Files are further divided into two kinds. Source files are usually written by the efforts of people, and checked in to the repository. Generated files, sometimes called derived files or output files, are not checked in, but are generated from source files.

The second kind of target is declared with a rule. Each rule instance specifies the relationship between a set of input and a set of output files. The inputs to a rule may be source files, but they also may be the outputs of other rules.

All targets belong to exactly one package. The name of a target is called its label. Every label uniquely identifies a target. A typical label in canonical form looks like:

@myrepo//my/app/main:app_binary

Build rules

A build rule specifies the build tools Bazel will use, such as compilers and linkers, and their configurations. Bazel ships with a number of build rules covering the most common artifact types in the supported languages on supported platforms.

Commands

From top level dir

Build all packages(Denoted by BUILD.bazel files) in this project. ... refers to all targets

Targets all Build files:

bazel build //...

Building just the c_project but using it's package's label

bazel build //c_project/...

Python Builds

https://bazel.build/reference/be/python