Ninja——小而快的构建系统

介绍

Ninja 是Google的一名程序员推出的注重速度的构建工具,一般在Unix/Linux上的程序通过make/makefile来构建编译,而Ninja通过将编译任务并行组织,大大提高了构建速度。

安装

目前最新版本是17年9月11日推出的v1.8.2,可以直接在github上下载其二进制文件,链接

或者通过你所使用的系统的包管理器,比如apt、pacman、yum、dnf等。

这里介绍使用Ubuntu 18.04安装的方法,

# 查看信息
apt show ninja-build
# 输出如下
Package: ninja-build
Version: 1.8.2-1
Priority: optional
Section: universe/devel
Origin: Ubuntu
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Felix Geyer <[email protected]>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 296 kB
Depends: libc6 (>= 2.15), libstdc++6 (>= 5.2)
Conflicts: ninja
Homepage: https://ninja-build.org/
Download-Size: 93.3 kB
APT-Sources: https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic/universe amd64 Packages
Description: small build system closest in spirit to Make
 Ninja is yet another build system. It takes as input the interdependencies of
 files (typically source code and output executables) and orchestrates
 building them, quickly.
 .
 Ninja joins a sea of other build systems. Its distinguishing goal is to be
 fast. It is born from the Chromium browser project, which has over 30,000
 source files and whose other build systems can take ten seconds to start
 building after changing one file. Ninja is under a second.

# 安装
sudo apt install ninja-build

使用

我一般是通过cmake来生成ninja的配置,进而进行编译。

# 示例
cmake -G "Ninja" 
ninja 

编译llvm+clang时用到了ninja,速度还不错。

详细使用方法可以参考man手册。

猜你喜欢

转载自blog.csdn.net/weixin_34311757/article/details/86821368