【发布时间】:2017-03-15 00:43:30
【问题描述】:
我已经使用 premake 有一段时间了。当我必须运行小脚本或似乎与构建阶段无关的东西时(例如调试、打包、构建外部库等...),我只是使用 Makefile 项目,如下所示
-- [[ X. External Makefile libraries ]]
project "external"
kind "Makefile"
location "build"
buildcommands {
"cd ..; make -f Makefile"
}
cleancommands {
"cd ..; make -f Makefile clean"
}
-- [[ X+1. Integration ]]
project "integration"
kind "Makefile"
location "build"
buildcommands {
-- PacketNgin Application Library
"ar x ../libc.a",
"ar x ../libm.a",
"ar x ../libtlsf.a",
"ar x ../libcore.a",
"ar x ../libexpat.a",
"ar rcs ../libpacketngin.a *.o",
"cp -rL ../core/include/* ../../include",
"cp -rL ../expat/include/* ../../include",
"cp -rL ../openssl/include/* ../../include",
"cp -rL ../zlib/*.h ../../include",
"rm ./*.o -rf",
-- Linux Application library
"ar x ../libtlsf.a ", -- Blank is added at the end on purpose
"ar x ../libcore_linux.a",
"ar rcs ../libumpn.a *.o",
"rm ./*.o -rf ", -- Blank is added at the end on purpose
}
cleancommands {
"rm *.o -rf",
"rm ../*.a -rf"
}
我意识到这种做法很混乱,因为它没有将真正的构建 Makefile 与虚假目标分开,甚至为构建制作不必要的 Makefile。所以,我想弄清楚通过预制生成虚假目标。
我考虑过 newaction 语法,但我发现它只是为 premake 脚本制作目标而不是 Makefile 目标。
是否有任何最佳实践或方法可以通过 premake 生成虚假目标?
【问题讨论】: