Bazel Build for C++ Software Application
bazel for c++ Application

Bazel Build for C++ Software Application

Bazel Tool is developed by google to automate the build process. Now It's an open source and it can be used by anyone. Many companies are using it for their day-to-day build automation. It is very helpful to integrate with CI/CD pipeline. GoogleTest framework can be integrated easily for the Unit Testing of an application.

Features of Bazel

  • Speedup Build and Test: It has very good features for rebuilding the application in an optimized way with local and distributed cache techniques. Optimized dependency analysis and concurrent execution of builds. This feature boosts regular builds and provides the build results in well defined time.
  • Multiple Language and Multi-Platform Support: It can build Java, Go, C++, and many more languages on different platforms like Windows, Linux, and Mac
  • Scalable: Bazel helps you scale your organization, codebase, and continuous integration solution. It handles codebases of any size, in multiple repositories or a huge mono repo.

Advantages from bazel in the modern build process

  1. The build completely depends on the input which is provided. Your input can decide which part of the code needs to rebuild and produce constant output.?

No alt text provided for this image

2. Easy to integrate with Docker and Kubernetes. If you have mono repo and multiple microservices, then It can build each container and host it for the test environment. Further, it can provide incremental build and perform deployment by using any orchestration tools like AWS and Kubernetes.

No alt text provided for this image

3. Bazel can handle large projects. Bazel provides a uniform interface for building and testing across projects and programming languages, which is beneficial to CI/CD Process.

4. Bazel used an internal caching mechanism. It caches the builds and rebuilds the content only when the developer made the changes. It compares the previous build which is cached and newly built content and produces the final binary. This caching technique speed up the build process.

Bazel Build Structure:

  • workspace:

No alt text provided for this image

  1. A workspace is a directory tree on your filesystem that contains the source files for the software you want to build. Each workspace has a text file named WORKSPACE which may be empty or may contain references to external dependencies required to build the outputs.
  2. Directories containing a file called WORKSPACE are considered the root of a workspace. Therefore, Bazel ignores any directory trees in a workspace rooted at a subdirectory containing a WORKSPACE file, as they form another workspace.
  3. Bazel also supports the WORKSPACE.bazel file as an alias of the WORKSPACE file. If both files exist, WORKSPACE.bazel is used.

  • Package:

  1. 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.
  2. This folder will contain the BUILD and BUILD.bazel files. It holds all other folders required for the build.

  • Target:

  1. 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.
  2. Files are further divided into two kinds. Source files are usually written by the efforts of people, and checked into the repository. Generated files, sometimes called derived files or output files, are not checked in, but are generated from source files.?

No alt text provided for this image

Labels:

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 this:

@myrepo//my/app/main:app_binary        
No alt text provided for this image

Dependencies:

A target A depends upon a target B if B is needed by A at build or execution time. The depends upon relation induces a Directed Acyclic Graph (DAG) over targets, and it is called a dependency graph.

No alt text provided for this image

code and compilation process will be updated soon.

要查看或添加评论,请登录

Shrikant Badiger的更多文章

  • NVMe Over TCP

    NVMe Over TCP

    NVMe over TCP is enhanced feature of NVMe over Fabrics. It used the standard network stack(Ethernet) without any…

    1 条评论
  • C++ Class Layout

    C++ Class Layout

    Class Layout: Only non-static data members will contribute to the size of the class object. If we have static and…

    1 条评论
  • High-performance Computing in C++ : Open Muti Processing(OpenMP)

    High-performance Computing in C++ : Open Muti Processing(OpenMP)

    Open Multi-Processing: Let's consider the parallelization approaches, basically, we can think of imperative…

  • High-performance Computing in C++

    High-performance Computing in C++

    Single Instruction Multiple Data (SIMD) Multiple core CPUs and Multithreading: Declarative(OpenMP), imperative…

  • vSocket Interface - Guest to Host Communication

    vSocket Interface - Guest to Host Communication

    vSocket: VMware vSocket provides a very similar API to the Unix Socker interface for communication. vSocket library is…

  • Custom Memory Management in C++

    Custom Memory Management in C++

    Memory Management: Process in which memory allocation and de-allocation to the variable in running program and handle…

  • Pointers in C

    Pointers in C

    Pointers in C: Pointers are fundamental parts of C Programming. Pointers provide the lots of power and flexibility in C…

  • CMake and Useful Info

    CMake and Useful Info

    CMake is an open-source tool to build, test, and package software applications. CMake provides control over the…

    1 条评论
  • Interrupt !!

    Interrupt !!

    Processors need to detect hardware activities. There are multiple solutions to detect hardware activities.

  • PXE: Preboot Execution Environment

    PXE: Preboot Execution Environment

    PXE: Preboot Execution Environment. Technology helps computers to boot up remotely through a network interface.