[webkit-dev] Removing BUILDING_ON / TARGETING macros in favor of system availability macros

Adam Barth abarth at webkit.org
Tue Jul 10 16:37:42 PDT 2012


Tony and Mark (Mentovai) would know more, but I believe the Chromium port
uses these macros in order to build against a specific SDK.  For example,
the Chromium port currently builds against the 10.5 SDK.  (This is slated
to change shortly as the Chromium project has dropped support for 10.5.)

Adam


On Tue, Jul 10, 2012 at 4:24 PM, Mark Rowe <mrowe at apple.com> wrote:

> I would like to propose removing the BUILDING_ON and TARGETING family of
> macros that are used to build code conditionally for different versions of
> OS X. I propose this in order to address several problems:
>
>
>    - The checks are verbose, and getting worse.
>
>
> For instance, in order to write code targeting OS X 10.8 and newer I have
> to enumerate all other supported OS versions:
>
> #if !defined(TARGETING_LEOPARD) && !defined(TARGETING_SNOW_LEOPARD) &&
> !defined(TARGETING_LION)
>> #endif
>
>
> This problem has become worse over time as the number of supported OS X
> versions in the WebKit code base has increased.
>
>
>
>    - The nature of the version checks are often not obvious at first
>    glance.
>
>
> In order to understand the checks you have to first remember the marketing
> names of the various OS X releases. You must then reason about the
> conditional logic of the check itself, which will often contains multiple
> negated clauses.
>
>
>
>    - Almost all current uses are incorrect in the context of SDKs.
>
>
> The vast majority of the checks in WebKit use the BUILDING_ON macros where
> the TARGETING macros would be more appropriate. This hasn't cause many
> problems to date since builds of WebKit on OS X for the most part do not
> use SDKs. This means that they build with __MAC_OS_X_VERSION_MIN_REQUIRED
> == __MAC_OS_X_VERSION_MAX_ALLOWED, resulting in the BUILDING_ON and
> TARGETING macros being equivalent. However, when building with a deployment
> target of an older OS release than the SDK you're building against, the
> BUILDING_ON and TARGETING macros will have different behavior. The result
> is that WebKit fails to build against an SDK when targeting an older OS
> release.
>
>
> My proposed solution to these problems is to remove the BUILDING_ON and
> TARGETING macros. The vast majority of the BUILDING_ON uses and all of the
> TARGETING uses would be replaced with tests against
> __MAC_OS_X_VERSION_MIN_REQUIRED. The small number of uses of BUILDING_ON
> that are being used correctly would be replaced with tests against
> __MAC_OS_X_VERSION_MAX_ALLOWED.
>
> The example above of code targeting OS X 10.8 and newer would become:
>
> #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
>> #endif
>
> Code that wishes to target only OS X 10.6 and older would become:
>
> #if __MAC_OS_X_VERSION_MIN_REQUIRED <= 1060
>> #endif
>
> This is much more concise and understandable than the current approach.
>
>
> I'm open to feedback on this proposal, but I'd like to move forward with
> this change in the next day or two if no one objects.
>
> - Mark
>
>
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo/webkit-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20120710/92bf9bef/attachment.html>


More information about the webkit-dev mailing list