0
点赞
收藏
分享

微信扫一扫

Windows 10 x64下编译安装ninja

小禹说财 2022-03-15 阅读 88
windows

1. 准备工作
S1. 安装git for Windows,下载地址:https://git-scm.com/download/win

S2. 安装Visual Studio 2015

S3. 安装Python 3.x


2. Clone ninja库
打开git bash,分别运行如下两行命令:

git clone git://github.com/ninja-build/ninja.git && cd ninja
git checkout release
1
2

3. 编译ninja
S1. 在Windows目录中找到上述clone到本地ninja库的文件夹,通常位于C:\users\<XXXX>,这里的XXXX就是当前自己的用户。

S2. 启动Windows CMD,cd到上述ninja库的文件夹内部。

S3. 在CMD中分别运行如下两行命令:

"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64
python configure.py --bootstrap
1
2
会有如下输出(中间省略了大量形如“包含文件”的内容):

bootstrapping ninja...
warning: A compatible version of re2c (>= 0.11.3) was not found; changes to src/*.in.cc will not affect your build.
build.cc
build_log.cc
clean.cc
clparser.cc
debug_flags.cc
depfile_parser.cc
deps_log.cc
disk_interface.cc
edit_distance.cc
eval_env.cc
graph.cc
graphviz.cc
lexer.cc
line_printer.cc
manifest_parser.cc
metrics.cc
state.cc
string_piece_util.cc
util.cc
version.cc
subprocess-win32.cc
includes_normalize-win32.cc
msvc_helper-win32.cc
msvc_helper_main-win32.cc
minidump-win32.cc
getopt.c
ninja.cc
正在生成代码
已完成代码的生成
wrote build.ninja.
bootstrap complete.  rebuilding...
[2/29] CXX build\depfile_parser.obj
注意: 包含文件:  c:\users\yafux\ninja\src\depfile_parser.h
注意: 包含文件:   C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\string
注意: 包含文件:    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\istream
注意: 包含文件:     C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\ostream
注意: 包含文件:      C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\ios
注意: 包含文件:       C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\xlocnum
注意: 包含文件:        C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\climits
...
注意: 包含文件:  c:\users\yafux\ninja\src\graphviz.h
注意: 包含文件:  c:\users\yafux\ninja\src\manifest_parser.h
注意: 包含文件:   c:\users\yafux\ninja\src\lexer.h
注意: 包含文件:  c:\users\yafux\ninja\src\state.h
注意: 包含文件:  c:\users\yafux\ninja\src\version.h
[29/29] LINK ninja.exe
正在生成代码
已完成代码的生成

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
S4. 在上述ninja库的文件夹内部,可以看到编译后生成的ninja.exe文件。

4. 安装ninja
S1. 在系统分区下创建一个文件夹local。

S2. 在上述local文件夹中创建一个文件夹Ninja。

S3. 将生成的ninja.exe文件拷贝到S2创建的文件夹Ninja中,如下图所示。


S4. 将目录C:\local\Ninja添加到系统的Path环境变量中,如下图所示:

S5. 启动一个新的Windows CMD窗口,并运行如下命令进行验证:

ninja --help
1
运行后会有如下输出:

usage: ninja [options] [targets...]

if targets are unspecified, builds the 'default' target (see manual).

options:
  --version      print ninja version ("1.9.0")
  -v, --verbose  show all command lines while building

  -C DIR   change to DIR before doing anything else
  -f FILE  specify input build file [default=build.ninja]

  -j N     run N jobs in parallel (0 means infinity) [default=6 on this system]
  -k N     keep going until N jobs fail (0 means infinity) [default=1]
  -l N     do not start new jobs if the load average is greater than N
  -n       dry run (don't run commands but act like they succeeded)

  -d MODE  enable debugging (use '-d list' to list modes)
  -t TOOL  run a subtool (use '-t list' to list subtools)
    terminates toplevel options; further flags are passed to the tool
  -w FLAG  adjust warnings (use '-w list' to list warnings)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
S6. 至此,ninja在Windows 10下的编译安装就完成了。


————————————————

举报

相关推荐

0 条评论