2

对于我正在处理的项目,我需要针对不同编译器的不同构建选项。我正在考虑使用 dofile 关键字来包含基于使用 premake5 时选择的编译器的不同构建配置。我如何指示 premake5 做类似的事情(在伪代码中)

if gcc 
 dofile gcc.lua
else if vs2008
 dofile vs2008.lua
else if vs2010
 dofile vs2010.lua
else if vs2012
 dofile vs2012.lua
else if vs2013
 dofile vs2013.lua
else if vs2015
 dofile vs2015.lua

等等

4

1 回答 1

3

你可以像这样做你建议的事情:

if _ACTION == "gmake" then
    dofile "gcc.lua"
elseif _ACTION == "vs2008" then
    dofile "vs2008.lua"
elseif ...

或者像这样:

dofile(_ACTION .. ".lua")

但您可能想要这样做:

filter { "action:gmake" }
    define { "SOME_GMAKE_SYMBOLS" }
    -- put your gmake configuration here

filter { "action:vs*" }
    -- put your common VS configuration here

filter { "action:vs2008" }
    define { "SOME_VS2008_SYMBOLS" }
    -- put your VS2008 specific configuration here


filter { "action:vs*" }
    -- put your common VS configuration here

-- and so on...
于 2016-02-20T15:19:08.273 回答