Skip to content

Commit 29f552e

Browse files
committed
unix: patch tk to work around undefined symbol issue
This is extremely hacky and I don't like the solution. But the missing symbol is from libclang_rt and I don't file like going down that rabbit hole.
1 parent 613e46e commit 29f552e

File tree

1 file changed

+85
-1
lines changed

1 file changed

+85
-1
lines changed

cpython-unix/build-tk.sh

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,91 @@ export PATH=${TOOLS_PATH}/deps/bin:${TOOLS_PATH}/${TOOLCHAIN}/bin:${TOOLS_PATH}/
1111
export PKG_CONFIG_PATH=${TOOLS_PATH}/deps/share/pkgconfig:${TOOLS_PATH}/deps/lib/pkgconfig
1212

1313
tar -xf tk${TK_VERSION}-src.tar.gz
14-
pushd tk${TK_VERSION}/unix
14+
15+
pushd tk${TK_VERSION}
16+
17+
if [ "${PYBUILD_PLATFORM}" = "macos" ]; then
18+
# The @available annotations create missing symbol errors
19+
# for ___isOSVersionAtLeast. We work around this by removing
20+
# their use.
21+
#
22+
# This is not an ideal solution.
23+
patch -p1 << EOF
24+
diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c
25+
index 80b368f..b51796e 100644
26+
--- a/macosx/tkMacOSXColor.c
27+
+++ b/macosx/tkMacOSXColor.c
28+
@@ -278,11 +278,9 @@ SetCGColorComponents(
29+
OSStatus err = noErr;
30+
NSColor *bgColor, *color = nil;
31+
CGFloat rgba[4] = {0, 0, 0, 1};
32+
-#if MAC_OS_X_VERSION_MAX_ALLOWED < 101400
33+
NSInteger colorVariant;
34+
static CGFloat graphiteAccentRGBA[4] =
35+
{152.0 / 255, 152.0 / 255, 152.0 / 255, 1.0};
36+
-#endif
37+
38+
if (!deviceRGB) {
39+
deviceRGB = [NSColorSpace deviceRGBColorSpace];
40+
@@ -373,16 +371,6 @@ SetCGColorComponents(
41+
deviceRGB];
42+
break;
43+
case 8:
44+
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
45+
- if (@available(macOS 10.14, *)) {
46+
- color = [[NSColor controlAccentColor] colorUsingColorSpace:
47+
- deviceRGB];
48+
- } else {
49+
- color = [NSColor colorWithColorSpace: deviceRGB
50+
- components: blueAccentRGBA
51+
- count: 4];
52+
- }
53+
-#else
54+
colorVariant = [[NSUserDefaults standardUserDefaults]
55+
integerForKey:@"AppleAquaColorVariant"];
56+
if (colorVariant == 6) {
57+
@@ -394,7 +382,6 @@ SetCGColorComponents(
58+
components: blueAccentRGBA
59+
count: 4];
60+
}
61+
-#endif
62+
break;
63+
default:
64+
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
65+
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
66+
index ceb3f3f..5c04f17 100644
67+
--- a/macosx/tkMacOSXWm.c
68+
+++ b/macosx/tkMacOSXWm.c
69+
@@ -5928,12 +5928,6 @@ WmWinAppearance(
70+
resultString = appearanceStrings[APPEARANCE_AUTO];
71+
} else if (appearance == NSAppearanceNameAqua) {
72+
resultString = appearanceStrings[APPEARANCE_AQUA];
73+
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
74+
- } else if (@available(macOS 10.14, *)) {
75+
- if (appearance == NSAppearanceNameDarkAqua) {
76+
- resultString = appearanceStrings[APPEARANCE_DARKAQUA];
77+
- }
78+
-#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
79+
}
80+
result = Tcl_NewStringObj(resultString, strlen(resultString));
81+
}
82+
@@ -5953,12 +5947,6 @@ WmWinAppearance(
83+
NSAppearanceNameAqua];
84+
break;
85+
case APPEARANCE_DARKAQUA:
86+
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
87+
- if (@available(macOS 10.14, *)) {
88+
- win.appearance = [NSAppearance appearanceNamed:
89+
- NSAppearanceNameDarkAqua];
90+
- }
91+
-#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
92+
break;
93+
default:
94+
win.appearance = nil;
95+
EOF
96+
fi
97+
98+
pushd unix
1599

16100
CFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC"
17101
LDFLAGS=""

0 commit comments

Comments
 (0)