我有一个主要的premake4.lua脚本:
solution "MySolution"
language "c++"
newoption = {
trigger = "my-option",
description = "This is an option"
}
include "../my_library"
我想根据_OPTIONS的内容在包含的脚本(../my_library/premake4.lua)中转动逻辑:
if _OPTIONS["my-option"] then
project "myStaticLibrary"
kind "StaticLib"
else
project "mySharedLibrary"
kind "SharedLib"
end
files "foo.cpp"
如何在所包含的premake4脚本的范围内获取_OPTIONS?
答案 0 :(得分:0)
你不需要做任何事情。 _OPTIONS
是一个全局变量,可以自动访问所有脚本。你看到了吗?
答案 1 :(得分:0)
我回答我自己的问题,以防万一其他人想以同样的方式解决问题。我做错了。经过努力,我的最终解决方案定义了多个配置:
-- the main script
solution "MySolution"
language "c++"
configurations { "Release", "Debug", "ReleaseDLL", "DebugDLL" }
configuration { "Release", "ReleaseDLL" }
flags { "Optimize" }
configuration { "Debug", "DebugDLL" }
flags { }
defines {"_DEBUG=1"}
configuration {}
include "../my_library"
附带的脚本根据配置指定种类:
-- the included script
project "myStaticLibrary"
configuration { "*" }
kind "StaticLib"
configuration { "*DLL" }
kind "SharedLib"
configuration {}
files "foo.cpp"
要构建正确的目标,制作指定配置:
premake4 gmake
cd gmake
make config=release
make config=debug
make config=releasedll
make config=debugdll