Code Monkey home page Code Monkey logo

bazel-training's Introduction

Bazel Training

Prerequisite

bazel installed

bazel --version
bazel 6.0.0

Basics

  1. bazel concept and terminology

    1. Workspace: a directory on your filesystem that contains the source files for the software you want to build. Each workspace directory has a text file named WORKSPACE.
    2. Repository: The directory containing the WORKSPACE file is the root of the main repository, also called @.
    3. Package: The primary unit of code organization in a repository. A package is defined as a directory containing a file named BUILD or BUILD.bazel.
    4. Target: A package is a container. The elements of a package are called targets.
    5. Labels:
      • @myrepo//my/app/main:app_binary = //my/app/main:app_binary inside @myrepo
      • my/app/main: un-qualified package name
      • @myrepo//my/app/main: full-qualified package name
      • app_binary or :app_binary inside @myrepo//my/app/main
  2. Repository rules (WORKSPACE):

    1. Git git_repository
    2. Http http_archive
    3. util maybe

Contents

  1. Build Go with Gazelle (v0.1.0)
  2. Build Protobuf (v0.2.0)
  3. Build Python (v0.3.0)
  4. Build Java (v0.4.0)
  5. Build Python with Poetry (v0.5.0)
  6. Build Python with Proto (v0.6.0)

Cheatsheet

  1. Bazel
    1. bazel clean: clean up the cache.
  2. Java:
    1. build: bazel build //java:App
    2. run: bazel run //java:App
    3. check dep: bazel query --notool_deps --noimplicit_deps "deps(//java:App)" --output graph
  3. Python: bazel run //python:main
  4. Go:
    1. build: bazel build //go/cmd: Build a package cmd.
    2. run: bazel run //go/cmd: Run a package cmd.
    3. bazel run //:gazelle: Generate build file.
    4. bazel run //:gazelle -- update-repos -from_file=go.mod: Update go_repository in WORKSPACE from go.mod.

FAQ

  1. How to upgrade http_archive version?

References

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.