<pre style='margin:0'>
Christopher Nielsen (mascguy) pushed a commit to branch master
in repository macports-legacy-support.
</pre>
<p><a href="https://github.com/macports/macports-legacy-support/commit/22d4b01ae9263880c47cd578a937d31f6f723a40">https://github.com/macports/macports-legacy-support/commit/22d4b01ae9263880c47cd578a937d31f6f723a40</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 22d4b01ae9263880c47cd578a937d31f6f723a40
</span>Author: Fred Wright <fw@fwright.net>
AuthorDate: Sat Jul 6 19:15:14 2024 -0700
<span style='display:block; white-space:pre;color:#404040;'> sdkversion.h: Respect SDK 11.x+ version non-definitions.
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Also adds a tool to extract the macro list from an SDK.
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Closes: https://trac.macports.org/ticket/69867
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> TESTED:
</span><span style='display:block; white-space:pre;color:#404040;'> Builds and passes tests on all platforms.
</span><span style='display:block; white-space:pre;color:#404040;'> Version macros are absent where appropriate in the darwin_c tests.
</span>---
include/_macports_extras/sdkversion.h | 58 ++++++++++++++++++++++++++++++++---
tools/getversionmacros.sh | 6 ++++
2 files changed, 59 insertions(+), 5 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/include/_macports_extras/sdkversion.h b/include/_macports_extras/sdkversion.h
</span><span style='display:block; white-space:pre;color:#808080;'>index 2a45ade..5bf0ca6 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/include/_macports_extras/sdkversion.h
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/include/_macports_extras/sdkversion.h
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -64,13 +64,15 @@
</span> * suppressed in some configurations in 11.x+ SDKs. In such cases it's
* impossible to detect the correct SDK version, with or without the
* "earlier SDK" hack. To suppress that behavior, we define _DARWIN_C_SOURCE
<span style='display:block; white-space:pre;background:#ffe0e0;'>- * before #including AvailabilityMacros.h, and restore its definedness
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * afterward. That may result in a small amount of additional namespace
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * pollution, but no worse than is always the case with pre-11.x SDKs.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * before #including AvailabilityMacros.h, restore its definedness
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * afterward, and add another step:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * 5) Undefine any version macros whose definition would have been suppressed.
</span> *
* It would be maximally flexible if we could directly derive an SDK version
* parameter from the "honest" ...MAX_ALLOWED, but cpp has no way to do that
<span style='display:block; white-space:pre;background:#ffe0e0;'>- * and survive the possible redefinition of ...MAX_ALLOWED in step 4. Hence,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * and survive the possible redefinition of ...MAX_ALLOWED in step 4, or
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * the possible removal of the relevant version macro in step 5. Hence,
</span> * all decisions related to the SDK version need to be made in step 3. The
* #if/#elif chain derives an SDK version number, but only with respect to
* the "major" version (ignoring the least significant digit). Hence, it's
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -111,10 +113,14 @@
</span> #endif
/* Make sure version macros get defined in 11.x+ SDKs. */
<span style='display:block; white-space:pre;background:#e0ffe0;'>+#if !((!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ || defined(_DARWIN_C_SOURCE))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define __MPLS_SDK11_BLOCKS_VERSION_MACROS
</span> #ifndef _DARWIN_C_SOURCE
#define _DARWIN_C_SOURCE 1
#define __MPLS_DARWIN_C_UNDEF
#endif
<span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif /* 11.x+ SDK would block version macros */
</span>
#include <AvailabilityMacros.h>
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -170,6 +176,7 @@
</span>
/* Then correct our munging, if necessary. */
<span style='display:block; white-space:pre;background:#e0ffe0;'>+/* First the ...MIN_REQUIRED hack. */
</span> #ifdef __MPLS_NEED_MIN_REQUIRED_FIXUP
#undef MAC_OS_X_VERSION_MIN_REQUIRED
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -186,9 +193,50 @@
</span> #endif
#undef __MPLS_NEED_MIN_REQUIRED_FIXUP
<span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span> #endif /* __MPLS_NEED_MIN_REQUIRED_FIXUP */
<span style='display:block; white-space:pre;background:#e0ffe0;'>+/* Then the version macro undisabled definition hack. */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#ifdef __MPLS_SDK11_BLOCKS_VERSION_MACROS
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#if __MPLS_SDK_MAJOR >= 110000
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* Version macros conditionally provided by 11.x+ SDKs. */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* Add new entries as needed, lest unwanted defs linger. */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef MAC_OS_VERSION_11_0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef MAC_OS_VERSION_11_1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef MAC_OS_VERSION_11_3
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef MAC_OS_VERSION_11_4
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef MAC_OS_VERSION_11_5
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef MAC_OS_VERSION_11_6
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef MAC_OS_VERSION_12_0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef MAC_OS_VERSION_12_1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef MAC_OS_VERSION_12_2
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef MAC_OS_VERSION_12_3
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef MAC_OS_VERSION_12_4
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef MAC_OS_VERSION_12_5
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef MAC_OS_VERSION_12_6
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef MAC_OS_VERSION_12_7
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef MAC_OS_VERSION_13_0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef MAC_OS_VERSION_13_1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef MAC_OS_VERSION_13_1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef MAC_OS_VERSION_13_2
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef MAC_OS_VERSION_13_3
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef MAC_OS_VERSION_13_4
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef MAC_OS_VERSION_13_5
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef MAC_OS_VERSION_13_6
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef MAC_OS_VERSION_14_0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef MAC_OS_VERSION_14_1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef MAC_OS_VERSION_14_2
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef MAC_OS_VERSION_14_3
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef MAC_OS_VERSION_14_4
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef MAC_OS_VERSION_14_5
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef MAC_OS_VERSION_15_0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif /* __MPLS_SDK_MAJOR >= 110000 */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef __MPLS_SDK11_BLOCKS_VERSION_MACROS
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif /* __MPLS_SDK11_BLOCKS_VERSION_MACROS */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> #else /* !__APPLE__ */
/* If non-Apple, just assume an "infinitely late" SDK. */
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/tools/getversionmacros.sh b/tools/getversionmacros.sh
</span>new file mode 100755
<span style='display:block; white-space:pre;color:#808080;'>index 0000000..fe3d331
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/tools/getversionmacros.sh
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -0,0 +1,6 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#! /bin/sh
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# Script to extract list of version macros from SDK, and convert to #undefs
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+SDKROOT="$1"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+grep MAC_OS_VERSION_ $SDKROOT/usr/include/AvailabilityVersions.h | sed -E 's/^#define +MAC_OS_VERSION_([0-9_]+).*/#undef MAC_OS_VERSION_\1/'
</span></pre><pre style='margin:0'>
</pre>