我为我正在研究的C ++项目编写了一个build.ninja文件。没什么好看的,只有一堆C ++源文件被编译并链接成可执行文件(见下文)
我想添加一个安装目标,只需将可执行文件复制到/ usr / local / games中。我如何实现这一目标?
cflags = -DSYZYGY -Wall -Wcast-qual -fno-exceptions -fno-rtti -ansi -pedantic -Wno-long-long $
-Wextra -Wshadow -DNDEBUG -O3 -DIS_64BIT -msse -DUSE_BSFQ -msse3 -mpopcnt -DUSE_POPCNT -flto
lflags = -lpthread $cflags
rule compile
command = c++ -MMD -MT $out -MF $out.d $cflags -c $in -o $out
description = Compiling $in
depfile = $out.d
deps = gcc
rule link
command = c++ -o $out $in $lflags && strip $out
description = Linking $out
build src/benchmark.o: compile src/benchmark.cpp
build src/bitbase.o: compile src/bitbase.cpp
build src/bitboard.o: compile src/bitboard.cpp
build src/endgame.o: compile src/endgame.cpp
build src/evaluate.o: compile src/evaluate.cpp
build src/main.o: compile src/main.cpp
build src/material.o: compile src/material.cpp
build src/misc.o: compile src/misc.cpp
build src/movegen.o: compile src/movegen.cpp
build src/movepick.o: compile src/movepick.cpp
build src/pawns.o: compile src/pawns.cpp
build src/position.o: compile src/position.cpp
build src/search.o: compile src/search.cpp
build src/thread.o: compile src/thread.cpp
build src/timeman.o: compile src/timeman.cpp
build src/tt.o: compile src/tt.cpp
build src/uci.o: compile src/uci.cpp
build src/ucioption.o: compile src/ucioption.cpp
build src/syzygy/tbprobe.o: compile src/syzygy/tbprobe.cpp
build stockfish: link src/benchmark.o src/bitbase.o src/bitboard.o src/endgame.o src/evaluate.o $
src/main.o src/material.o src/misc.o src/movegen.o src/movepick.o src/pawns.o src/position.o $
src/search.o src/thread.o src/timeman.o src/tt.o src/uci.o src/ucioption.o src/syzygy/tbprobe.o
default stockfish
答案 0 :(得分:0)
也许这可以解决问题(未经测试):
rule copy
command = cp $in $out
build /usr/local/games/stockfish: copy stockfish
build install: phony /usr/local/games/stockfish