Site icon WebKu

How to install Bazel on CentOS 8 Linux or Redhat 8/7

Bazel is a build tool, a tool that can run, compile and test to assemble software, just like Make, Ant, Gradle, Buck, Pants, and Maven. Here we will see how to install Bazel open-source software building and testing tool on CentOS 8 Linux / Stream / RHEL 8. 

What is Bazel?

Bazel is a compilation tool developed by Google’s under its open-source initiative, and Bazel uses distributed caching and incremental build methods to make compilation faster. It natively supports the Java and C++ languages, and currently has open-source related rules for compiling Golang projects.

Install Bazel on CentOS or Redhat for building and testing of software

    1. Open Command terminal on CentOS or RHEL. If you are on the CLI server then you already on that, however, for GUI, go to Activities, and from the menu, click on Terminal icon.
    2. Login as Root or standard user with sudo access.
    3. Add Bazel repository on CentOS 8/7. And same for the Redhat.For CentOS 7 or Redhat 7:
      yum config-manager --add-repo https://copr.fedorainfracloud.org/coprs/vbatts/bazel/repo/epel-7/vbatts-bazel-epel-7.repo

      For CentOS 8 Linux or RHEL 8:

      dnf config-manager --add-repo https://copr.fedorainfracloud.org/coprs/vbatts/bazel/repo/epel-8/vbatts-bazel-epel-8.repo
    4. Command to install Bazel on CentOS
      dnf install bazel

      or

      yum install bazel

      Output for the command:

      [root@localhost ~]# dnf install bazel
      Last metadata expiration check: 0:00:57 ago on Sat 05 Oct 2019 09:49:22 AM EDT.
      Dependencies resolved.
      ===============================================================================================================
      Package Arch Version Repository Size
      ===============================================================================================================
      Installing:
      bazel x86_64 0.29.1-0.el8 copr:copr.fedorainfracloud.org:vbatts:bazel 24 M
      Installing dependencies:
      copy-jdk-configs noarch 3.7-1.el8 AppStream 27 k
      java-11-openjdk x86_64 1:11.0.4.11-0.el8_0 AppStream 227 k
      java-11-openjdk-devel x86_64 1:11.0.4.11-0.el8_0 AppStream 3.3 M
      java-11-openjdk-headless x86_64 1:11.0.4.11-0.el8_0 AppStream 39 M
      javapackages-filesystem noarch 5.3.0-1.module_el8.0.0+11+5b8c10bd
      AppStream 30 k
      ttmkfdir x86_64 3.0.9-54.el8 AppStream 62 k
      tzdata-java noarch 2019a-1.el8 AppStream 188 k
      xorg-x11-fonts-Type1 noarch 7.5-19.el8 AppStream 522 k
      lksctp-tools x86_64 1.0.18-3.el8 BaseOS 100 k
      Enabling module streams:
      javapackages-runtime 201801
      
      Transaction Summary
      ===============================================================================================================
      Install 10 Packages
      
      Total download size: 67 M
      Installed size: 205 M
      Is this ok [y/N]:
    5. Accept the Importing of Fedora COPR GPG key. Press Y key to accept it and continue the Bazel installation process.Output:
      warning: /var/cache/dnf/copr:copr.fedorainfracloud.org:vbatts:bazel-df36dce8e0c0e1d6/packages/bazel-0.29.1-0.el8.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID eb2be214: NOKEY
      Copr repo for bazel owned by vbatts 285 B/s | 961 B 00:03
      Importing GPG key 0xEB2BE214:
      Userid : "vbatts_bazel (None) <vbatts#bazel@copr.fedorahosted.org>"
      Fingerprint: 090F 9C8B BDB6 3200 807E 16C2 978A 4B98 EB2B E214
      From : https://copr-be.cloud.fedoraproject.org/results/vbatts/bazel/pubkey.gpg
      Is this ok [y/N]: y
      Key imported successfully
      Running transaction check
      Transaction check succeeded.
      Running transaction test
      Transaction test succeeded.
      Running transaction
      Running scriptlet: copy-jdk-configs-3.7-1.el8.noarch 1/1
      Running scriptlet: java-11-openjdk-headless-1:11.0.4.11-0.el8_0.x86_64 1/1
      Preparing : 1/1
      Installing : lksctp-tools-1.0.18-3.el8.x86_64 1/10
      Running scriptlet: lksctp-tools-1.0.18-3.el8.x86_64 1/10
      Installing : tzdata-java-2019a-1.el8.noarch 2/10
      Installing : ttmkfdir-3.0.9-54.el8.x86_64 3/10
      Installing : xorg-x11-fonts-Type1-7.5-19.el8.noarch 4/10
      Running scriptlet: xorg-x11-fonts-Type1-7.5-19.el8.noarch 4/10
      Installing : javapackages-filesystem-5.3.0-1.module_el8.0.0+11+5b8c10bd.noarch 5/10
      Installing : copy-jdk-configs-3.7-1.el8.noarch 6/10
      Installing : java-11-openjdk-headless-1:11.0.4.11-0.el8_0.x86_64 7/10
      Running scriptlet: java-11-openjdk-headless-1:11.0.4.11-0.el8_0.x86_64 7/10
      Installing : java-11-openjdk-1:11.0.4.11-0.el8_0.x86_64 8/10
      Running scriptlet: java-11-openjdk-1:11.0.4.11-0.el8_0.x86_64 8/10
      Installing : java-11-openjdk-devel-1:11.0.4.11-0.el8_0.x86_64 9/10
      Running scriptlet: java-11-openjdk-devel-1:11.0.4.11-0.el8_0.x86_64 9/10
      Installing : bazel-0.29.1-0.el8.x86_64 10/10
      Running scriptlet: copy-jdk-configs-3.7-1.el8.noarch 10/10
      Running scriptlet: java-11-openjdk-1:11.0.4.11-0.el8_0.x86_64 10/10
      Running scriptlet: java-11-openjdk-devel-1:11.0.4.11-0.el8_0.x86_64 10/10
      Running scriptlet: bazel-0.29.1-0.el8.x86_64 10/10
      Verifying : copy-jdk-configs-3.7-1.el8.noarch 1/10
      Verifying : java-11-openjdk-1:11.0.4.11-0.el8_0.x86_64 2/10
      Verifying : java-11-openjdk-devel-1:11.0.4.11-0.el8_0.x86_64 3/10
      Verifying : java-11-openjdk-headless-1:11.0.4.11-0.el8_0.x86_64 4/10
      Verifying : javapackages-filesystem-5.3.0-1.module_el8.0.0+11+5b8c10bd.noarch 5/10
      Verifying : ttmkfdir-3.0.9-54.el8.x86_64 6/10
      Verifying : tzdata-java-2019a-1.el8.noarch 7/10
      Verifying : xorg-x11-fonts-Type1-7.5-19.el8.noarch 8/10
      Verifying : lksctp-tools-1.0.18-3.el8.x86_64 9/10
      Verifying : bazel-0.29.1-0.el8.x86_64 10/10
      
      Installed:
      bazel-0.29.1-0.el8.x86_64
      copy-jdk-configs-3.7-1.el8.noarch
      java-11-openjdk-1:11.0.4.11-0.el8_0.x86_64
      java-11-openjdk-devel-1:11.0.4.11-0.el8_0.x86_64
      java-11-openjdk-headless-1:11.0.4.11-0.el8_0.x86_64
      javapackages-filesystem-5.3.0-1.module_el8.0.0+11+5b8c10bd.noarch
      ttmkfdir-3.0.9-54.el8.x86_64
      tzdata-java-2019a-1.el8.noarch
      xorg-x11-fonts-Type1-7.5-19.el8.noarch
      lksctp-tools-1.0.18-3.el8.x86_64
      
      Complete!
    6. Check Bazel installed Version
      bazel --version

      OutPut

      bazel 0.29.1
    7. The installation is successful. To start building some basic project, you can see the official tutorial page.

What is special about Bazel?

Bazel is a software development model designed to work with Google.

Has the following characteristics:

Multi-language support: Bazel supports Java, Objective-C and C++, and can be extended to support any programming language.

High-level build language: Engineering is described by the BUILD language. The BUILD language describes a project consisting of multiple small interrelated libraries, binaries, and test programs in a concise text format. In contrast, tools like Make need to describe individual files and compiled commands.

Multi-platform support: The same set of tools and the same BUILD file can be used to build software for different architectures and platforms. At Google, we use Bazel to build server-side programs that run on our data centre systems and client applications that run on mobile phones.

Reproducibility: In a BUILD file, each library, test program, and binary must explicitly and explicitly specify direct dependencies. When the source code file is modified, Bazel uses this dependency information to know which ones must be rebuilt and which tasks can be executed in parallel. This means that all builds are incremental and can produce the same results each time.

Scalability: Bazel can handle huge builds; at Google, a server-side program with more than 100k of source code is a common thing. If no files are changed, the build process takes about 200ms.

Why should I use Bazel?

Bazel can double the build speed because it only recompiles files that need to be recompiled. Similarly, it skips tests that have not been changed.

It produces a determined result. This eliminates the difference in build results between incremental and clean builds, development machines, and continuous integration.

Bazel can use the same tools under the same project to build different client and server applications. For example, you can modify a client/server protocol in a commit and then test that the updated mobile and server-side programs work properly, using the same tools when building, using the Bazel mentioned above. characteristic.

Exit mobile version