GN+NINJA环境搭建(MacOS Windows)

什么是ninja

科学上网速度快

Ninja is a small build system with a focus on speed. It differs from other build systems in two major respects: it is designed to have its input files generated by a higher-level build system, and it is designed to run builds as fast as possible.

什么是gn

科学上网速度快

GN is a meta-build system that generates build files for Ninja.

安装 ninja

You can download the Ninja binary or find it in your system’s package manager.

推荐使用包管理器安装省心又省力.

安装 gn

You can download the latest version of GN binary for Linux, macOS and Windows from Google’s build infrastructure (see “Versioning and distribution” below for how this is expected to work).

Alternatively, you can build GN from source with a C++17 compiler:

git clone https://gn.googlesource.com/gn
cd gn
python build/gen.py # --allow-warning if you want to build with warnings.
ninja -C out

推荐自行编译后把生成的二进制文件添加到系统变量中.

第一次

There is a simple example in examples/simple_build directory that is a good place to get started with the minimal configuration.

To build and run the simple example with the default gcc compiler:

cd examples/simple_build
../../out/gn gen -C out
ninja -C out
./out/hello
Hello, world

总结

gn对于ninja相当于cmake对于make.
利用ninja编译需要.ninja文件,直接编写也是可以的,但工具gn会更加方便的管理大型工程.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值