Ninja——小而快的构建系统

Ninja是一款由Google程序员开发的构建工具,旨在提高构建速度。通过并行组织编译任务,Ninja在大型项目中展现出卓越的性能,如Chromium浏览器项目。它可在Unix/Linux环境下运行,并可通过CMake生成配置进行编译。Ninja的安装简单,支持多种系统,如Ubuntu18.04。使用Ninja进行编译,不仅速度快,还能有效管理复杂的项目依赖。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

介绍

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 <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Felix Geyer <fgeyer@debian.org>
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手册。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值