0

我有一个主要的 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?

4

2 回答 2

0

你不需要做任何事情。_OPTIONS是一个全局变量,所有脚本都可以自动访问。你看到别的了吗?

于 2015-12-06T15:04:35.533 回答
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"

为了构建正确的目标,在make中指定了配置

premake4 gmake
cd gmake
make config=release
make config=debug
make config=releasedll
make config=debugdll
于 2015-12-06T16:34:12.827 回答