is_mac is a superset of is_ios, correct?

13 views
Skip to first unread message

Scott Nichols

unread,
Oct 11, 2016, 1:28:56 PM10/11/16
to gn-dev, Zeke Chin
Hello GN folks! 

I am working on getting the CRD iOS app to play nice in chromium and in that work the question of is_mac vs is_ios came up in this CL: https://codereview.webrtc.org/2393133007/

From what I understand, is_ios is a subset of is_mac, if you are building on a mac is_mac is set to true, and if you have target_os set to ios, you get is_mac and is_ios both true. This leads to gn build files with if (is_mac && !is_ios) for things that need to build for only mac and not iOS, and if the development of that build file did not think to make itself iOS compatible there tend to be cases where they attempt to include a framework that is not available for iOS, leading to more special casing.

This understanding is correct? Was this done for backwards compatibility or is there some other reason why is_mac and is_ios have this confusion? Perhaps there is a good reason for this? Inquiring minds would like to know :o)

Thanks!
-Scott

Ken Rockot

unread,
Oct 11, 2016, 1:30:22 PM10/11/16
to Scott Nichols, gn-dev, Zeke Chin
is_ios is not a subset of is_mac. is_ios && is_mac is never true.

Ken Rockot

unread,
Oct 11, 2016, 1:30:43 PM10/11/16
to Scott Nichols, gn-dev, Zeke Chin

Scott Nichols

unread,
Oct 11, 2016, 1:41:41 PM10/11/16
to Ken Rockot, gn-dev, Zeke Chin
Well I stand corrected! Thanks for the clarification. I must have misunderstood what I was testing when I thought I discovered this. Sorry for the confusion. 

Sylvain Defresne

unread,
Oct 11, 2016, 5:30:56 PM10/11/16
to Scott Nichols, Ken Rockot, gn-dev, Zeke Chin
Note that when building Chromium, OS_IOS is a superset of OS_MACOSX. Yes, it is confusing.
-- Sylvain

Zeke Chin

unread,
Oct 11, 2016, 6:09:25 PM10/11/16
to Sylvain Defresne, Scott Nichols, Ken Rockot, gn-dev, Kári Helgason

Kári Helgason

unread,
Oct 11, 2016, 6:11:10 PM10/11/16
to Zeke Chin, Sylvain Defresne, Scott Nichols, Ken Rockot, gn-dev
Superset? Shouldn't that be subset?

Sylvain Defresne

unread,
Oct 11, 2016, 6:11:57 PM10/11/16
to Kári Helgason, Zeke Chin, Scott Nichols, Ken Rockot, gn-dev
By superset I meant that OS_MACOSX is defined when OS_IOS is defined.
-- Sylvain

Kári Helgason

unread,
Oct 11, 2016, 6:22:48 PM10/11/16
to Sylvain Defresne, Zeke Chin, Scott Nichols, Ken Rockot, gn-dev
Right, ok, thanks. Just for legacy reasons or is there a better explanation?

Sylvain Defresne

unread,
Oct 13, 2016, 2:07:38 PM10/13/16
to Kári Helgason, Zeke Chin, Scott Nichols, Ken Rockot, gn-dev
This is historical and to follow Apple where TARGET_OS_MAC is always defined when TARGET_OS_IOS is (see https://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/TargetConditionals.h).
-- Sylvain

Kári Helgason

unread,
Oct 14, 2016, 10:43:14 AM10/14/16
to Sylvain Defresne, Zeke Chin, Scott Nichols, Ken Rockot, gn-dev
Thanks for the clarification Sylvain. Any opinions on how we proceed? Is there any value in following what Chrome does, even though it may be confusing? 
I think that consistency with GN is more important personally.

Sylvain Defresne

unread,
Oct 14, 2016, 11:57:26 AM10/14/16
to Kári Helgason, Zeke Chin, Scott Nichols, Ken Rockot, gn-dev
Chromium automatically defines OS_MACOSX, OS_IOS, OS_WIN, ... by using testing preprocessor macros automatically defined by the compiler (like __APPLE__ or _WIN32) and system headers (like TARGET_OS_IPHONE). See https://cs.chromium.org/chromium/src/build/build_config.h?sq=package:chromium&l=32

I think that Chromium decided to have OS_IOS be a superset of OS_MACOSX because most of the code written for Apple platform already does this assumption (due to how TARGET_OS_MAC and TARGET_OS_IPHONE are related in Apple system headers). But for all conditions that are outside of source file (which files to build in gn or previously gyp files, which resources to compile in grit files, ...) the condition to test which OS is targeted where made disjoint (as you say it is easier to understand).

For CRD, if you do not depends on //base nor //build/build_config.h from Chromium, you are free to use whatever macro you want to make the distinction between mac and ios in code and gn. If you depends on //base or //build/build_config.h, it may be easier to just reuse the macro for consistency with Chromium.
-- Sylvain

Kári Helgason

unread,
Oct 17, 2016, 3:50:40 AM10/17/16
to Sylvain Defresne, Zeke Chin, Scott Nichols, Ken Rockot, gn-dev
Thanks for the clarification. I think we should discuss this a bit before deciding on a direction. There is definitely value in being consistent with Chromium, but I don't want to keep around confusing conventions just for that reason.
Reply all
Reply to author
Forward
0 new messages