premake / premake-core

Premake
https://premake.github.io/
BSD 3-Clause "New" or "Revised" License
3.22k stars 620 forks source link

Warning deprecated when using os.getenv() in user module #963

Closed AtomikPunk closed 6 years ago

AtomikPunk commented 6 years ago

Hi, I'm writing a module for a small project where I want to access an environment variable. However, when using os.getenv() from that module and then calling premake to generate my vs2015 solution, I get a warning: ** Warning: _OS is deprecated, use '_TARGET_OS'.

I just upgraded from premake alpha 7 to alpha 12 and the same module code would not generate that warning in alpha 7. I suspect this may be due to changes in premake-core/src/base/os.lua around line 200. The solution and project files seem to be generated fine though.

tvandijck commented 6 years ago

The warning is emitted on line 200 indeed... however that is a warning indicating that someone is using _OS, which is been deprecated, so the warning is correct..

os.getenv() itself is implemented like this:

static int os_getenv (lua_State *L) {
  lua_pushstring(L, getenv(luaL_checkstring(L, 1)));  /* if NULL push nil */
  return 1;
}

which makes no reference to _OS, so I'm not sure where the error/warning comes from. But it is more likely that your project or premake scripts are somewhere using this property.

It still works fine, but just emits a warning, and you should upgrade to using _OS_TARGET instead, or preferably the os.istarget('...') function.

starkos commented 6 years ago

I'm going to go ahead and close this one—if you find out that it really is os.getenv() causing the error (which I am unable to reproduce here), can you provide a small script that demonstrates the problem so we have something to work with? Thanks!

AtomikPunk commented 6 years ago

I finally found out that the warning was caused by an old version of the QT module and not by my call to os.getenv(). Thanks to you both for having a look at the error and giving me hints on where to find this one.

(For the record, it was fixed by commit c87883c in premake-qt repository)