如何通过预制产生假目标?
我曾用过一段时间的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。 所以,我想通过premake来找出假目标。
我认为新的动作语法,但我发现它只是制作预制脚本的目标而不是Makefile目标。
Premake有什么最佳实践或方法来产生假目标?
Premake目前不支持创建任意虚假目标(尽管您可以提交功能请求或自行处理并创建拉取请求)。
但是您可以使用Premake自己为您运行命令。 下面是一个简单的例子,它创建了一个名为“集成”的新操作:
function executeAll(commands)
for _, command in ipairs(commands) do
os.execute(command)
end
end
newaction
{
trigger = "integrate",
description = "Run integration steps",
execute = function ()
executeAll {
"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",
-- and so on...
}
end
}
一旦添加到您的项目脚本中,您可以像这样调用它:
$ premake5 integrate
链接地址: http://www.djcxy.com/p/64127.html