如何在一个premake5.lua中根据不同的OS得到不同的环境值?
How can I get different environment values according to different OS in one premake5.lua?
在我的项目中,我想根据不同的OS获取不同的环境值,就像从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 时,它会 return 一个错误:attempt to concatenate a nil value.
我有什么误解吗?我怎样才能正确实施它?
使用 os.get 确定您当前 运行 所在的平台。
if os.get() == "windows" then
...
end
另一个选项:
if os.is("windows") then
...
else if os.is("macosx") then
...
else if os.is("linux") then
...
end
在我的项目中,我想根据不同的OS获取不同的环境值,就像从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 时,它会 return 一个错误:attempt to concatenate a nil value.
我有什么误解吗?我怎样才能正确实施它?
使用 os.get 确定您当前 运行 所在的平台。
if os.get() == "windows" then
...
end
另一个选项:
if os.is("windows") then
...
else if os.is("macosx") then
...
else if os.is("linux") then
...
end