如何在一个premake5.lua中根据不同的操作系统获得不同的环境值?

时间:2018-10-30 02:55:33

标签: premake

在我的项目中,我想根据不同的操作系统获得不同的环境值,就像从Windows获取A和从Linux获取B一样,我尝试使用过滤器功能,如下所示:

filter {"system:windows"} local value = os.getenv("A") filter {"system:linux"} local value = os.getenv("B")

或使用类似的配置:

configuration {"windows"} local value = os.getenv("A") configuration {"linux"} local value = os.getenv("B")

当我运行premake5.lua时,它将返回错误:试图连接一个nil值

我有什么误会吗?如何正确实施?

2 个答案:

答案 0 :(得分:0)

使用os.get确定您当前在哪个平台上运行。

if os.get() == "windows" then
...
end

答案 1 :(得分:0)

另一个选择:

if os.is("windows") then
  ...
else if os.is("macosx") then
  ...
else if os.is("linux") then
  ...
end
end
end
相关问题