高效构建工具

MSVC

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

# ninja -t clean -----> 删除生成的目标文件仅 build 指定的目标。
# ninja clean -----> 显示调用 clean 目标,删除指定的文件。适用于 windows,基于 cmd.exe /c del 删除文件。

ninja_required_version = 1.10.2

CC = cl.exe
cflags = /w
builddir = Debug
standard = /std:c++latest

rule compile_HelloWorld
command = $CC $standard /EHsc /c $cflags -MD $in /Fo $out
description = --------> Compiling $in to $out
depfile = $out.d
deps = msvc

build TestFunc.obj : compile_HelloWorld HelloWorld/TestFunc.cpp
build HelloWorld.obj : compile_HelloWorld HelloWorld/HelloWorld.cpp

rule link_HelloWorld
command = $CC $DEFINES $INCLUDES $cflags $in
description = --------> Linking $in to $out

build HelloWorld.exe : link_HelloWorld HelloWorld.obj TestFunc.obj


rule clean_cmd
command = cmd.exe /c $
if exist HelloWorld.lib ( del /S HelloWorld.lib ) & $
if exist HelloWorld.exp ( del /S HelloWorld.exp )
description = --------> Deleting generated files

build clean: clean_cmd

default HelloWorld.exe

留言

2021-03-25