premake-core icon indicating copy to clipboard operation
premake-core copied to clipboard

_TARGET_OS does not point to macosx when specifying --os macosx

Open SanderMertens opened this issue 7 years ago • 9 comments
trafficstars

I have a premake file in which I want to output to different directory based on the tool and operating system that I'm generating for. In my premake file I have the following line:

location (_ACTION .. "-" .. _TARGET_OS)

When I do premake5 gmake it outputs to gmake-linux. However, if I do premake5 gmake --os macosx it still outputs to gmake-linux.

I also tried setting the location under different configurations, but couldn't get that to work either.

I am using premake5 alpha 12.

SanderMertens avatar Dec 18 '17 05:12 SanderMertens

os.target() will get you what you're after. To my understanding, the os option isn't perfect, so please bug any issues you encounter when using it and os.target().

samsinsane avatar Dec 18 '17 09:12 samsinsane

Will give this a go. Thanks!

SanderMertens avatar Dec 19 '17 07:12 SanderMertens

Probably worth leaving this one open as a bug.

starkos avatar Dec 19 '17 11:12 starkos

Probably worth leaving this one open as a bug.

Just so I'm on the same page, is the bug that --os doesn't set _TARGET_OS?

samsinsane avatar Dec 19 '17 15:12 samsinsane

That's right.

starkos avatar Dec 20 '17 18:12 starkos

This is probably why, it's the only reference in the code where the variable is checked

_TARGET_OS is only set in premake.c via PLATFORM_STRING, but not trough the commandline

And the tests didn't catch this because they override _TARGET_OS and _OPTIONS.os before running the tests, always resulting in correct behaviour during testing. (the gmake2 test actually still overrides _OS instead, something one might need to fix as well)

Whether this is actual intended behaviour is up to debate, but as _OS was correctly adjusted before and the deprecate message states _TARGET_OS, not os.target(), there's at least a need for clarification here...

neico avatar Jan 20 '18 05:01 neico

I am running into this same issue with my project. The documentation seems to indicate that the intended behavior for the --os flag is to override _TARGET_OS so I am confident in saying that this is a bug.

liampace avatar Mar 14 '25 00:03 liampace

Correct, we should either adjust the documentation or adjust the behavior of --os and _TARGET_OS. I would recommend using target.os() for now.

nickclark2016 avatar Mar 14 '25 00:03 nickclark2016

I tested os.target() and it seems to have the correct behavior which is funny because the global variable named after it does not :/

I'm using a temporary fix where I have a lua module who's sole purpose is to set _TARGET_OS to os.target() lol

liampace avatar Mar 14 '25 00:03 liampace