• Bazel 构建


    Reference

    Bazel is an open-source build and test tool similar to Make, Maven, and Gradle.
    It uses a human-readable, high-level build language. Bazel supports projects in
    multiple languages and builds outputs for multiple platforms. Bazel supports large
    codebases across multiple repositories, and large numbers of users.

    Advantage

    • High-level build language.
    • Bazel is fasst and reliable.
    • Bazel is muti-platform supported
    • Scales
    • Extensiable

    Usages

    1. Install Bazel

    sudo pacman -S bazel

    1. Set up a project
    • The WORKSPACE file, which identifies the directory and its contents as bazel workspace
      and lives at the root of the project's directory.
    • One or more BUILD files which tell Bazel how to build different parts of the project.
      (A directory within the workspace that contains a BUILD file is a package.)
      To designate a directory as a Bazel workspace, create an empty file named WORKSPACE in that directory.
    1. Write a BUILD file
      A BUILD file contains several different types of instructions for Bazel. The
      most important type is the build rule, which tells Bazel how to build the
      desired outputs, such as executable binaries or libraries. Each instance of a
      build rule in the BUILD file is called a target and points to a specific set
      of source files and dependencies. A target can also point to other targets.

    2. Run Bazel

    • Build the project

    bazel build //main:app-name
    Notice the target label - the //main: part is the location of our BUILD file
    relative to the root of the workspace.
    substitue app-name with your target name.

    • Test binary

    bazel-bin/main/app-name

    1. Review the dependency graph

    A successful build has all of its dependencies explicitly stated in the BUILD file.
    Bazel use those statements to create the project's dependency graph. which enables accurate
    incremental builds.

    bazel query --notool_deps --noimplicit_deps "deps(//main:hello-world)" --output graph

    Before visualization, you should make sure you have already got xdot and grahphviz installed.
    You can generate and view the graphy by piping the text output above straight to xdot:

    xdot <(bazel query --notool_deps --noimplicit_deps "deps(//main:hello-world)" 
      --output graph)
    
    1. Use labels to reference targets

    Bazel use labels to reference targets, like //main:hello-world and //lib:hello-time
    The syntax is :

    //path/to/package:target-name
    

    If the target is a rule target, then path/to/package is the path to the directory containing the
    BUILD file, and target-name is what you named the target in the BUILD file(the name attribute)
    If the target is a file target, then path/to/package is the path to the root of the package
    , and target-name is the name of the target file, including full path.

    When referencing targets at the repository root, the package path is empty, just use //:target-name.
    When referencing targets within the same BUILD file, you can even skip the // workspace root identifier and
    just use :target-name.

    to be finished

  • 相关阅读:
    UVa12093
    UVa1631
    vue路由跳转的三种方式
    vue中的钩子函数(判断是否跳转页面)beforeEach
    vue中子组件向父组件传值方法?
    vue中对数组,对象的操作如下
    vue-router的beforeEach的使用?
    vue拦截器使用?
    vue中父子组件以及兄弟组件的传值情况?
    前端模块化?
  • 原文地址:https://www.cnblogs.com/sonnet/p/15187904.html
Copyright © 2020-2023  润新知