Search code examples
premake

How can I get different environment values according to different OS in one premake5.lua?


In my project, I want to get different environment value according to different OS, just like get A from Windows and get B from Linux, I try to use filter function like the code shown below:

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

or use configuration like that:

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

When I run the premake5.lua, it will return an error: attempt to concatenate a nil value.

Is there anything I misunderstand? How can I implement it correctly?


Solution

  • Another option:

    if os.is("windows") then
      ...
    else if os.is("macosx") then
      ...
    else if os.is("linux") then
      ...
    end