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会更加方便的管理大型工程.

你可能感兴趣的:(构建,软件构建,跨平台,gn,ninja)