summaryrefslogtreecommitdiff
blob: d703b60737062bd11302fdd3d838097ccda09471 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
From 9563fb5e73425a2ee0370162178964cceb559d5d Mon Sep 17 00:00:00 2001
From: David Runge <dave@sleepmap.de>
Date: Mon, 16 Nov 2020 12:00:22 +0100
Subject: [PATCH] Backport #5014 for 3.11.2

Backport the linker error patches
(https://github.com/supercollider/supercollider/pull/5014) for 3.11.2.
---
 common/SC_Apple.hpp             | 14 ------
 common/SC_Apple.mm              | 60 -------------------------
 common/SC_AppleEventLoop.hpp    | 34 ++++++++++++++
 common/SC_AppleEventLoop.mm     | 80 +++++++++++++++++++++++++++++++++
 common/SC_EventLoop.hpp         |  3 +-
 server/scsynth/CMakeLists.txt   |  8 +++-
 server/supernova/CMakeLists.txt |  9 +++-
 7 files changed, 131 insertions(+), 77 deletions(-)
 create mode 100644 common/SC_AppleEventLoop.hpp
 create mode 100644 common/SC_AppleEventLoop.mm

diff --git a/common/SC_Apple.hpp b/common/SC_Apple.hpp
index 958d097f36..c7e53e9fcc 100644
--- a/common/SC_Apple.hpp
+++ b/common/SC_Apple.hpp
@@ -23,19 +23,5 @@ namespace SC { namespace Apple {
 
 void disableAppNap();
 
-namespace EventLoop {
-
-// Setup the main application. This function must be called in the
-// main thread and before any other calls to Cocoa methods.
-void setup();
-// Run the event loop. This function must be called in the main thread.
-// It blocks until the event loop finishes.
-void run();
-// Ask the event loop to stop and terminate the program.
-// This function can be called from any thread.
-void quit();
-
-} // EventLoop
-
 } // namespace Apple
 } // namespace SC
diff --git a/common/SC_Apple.mm b/common/SC_Apple.mm
index a4e10a66cd..dbb7ddbb7d 100644
--- a/common/SC_Apple.mm
+++ b/common/SC_Apple.mm
@@ -42,65 +42,5 @@ void disableAppNap() {
     }
 }
 
-namespace EventLoop {
-
-static std::atomic_bool g_running;
-
-void setup() {
-    // The following code would transform the process into a foreground application.
-    // For now it's the plugin's responsibility to do this (early or lazily)
-    // because we don't want to always show an icon in the docker.
-    // ProcessSerialNumber psn = { 0, kCurrentProcess };
-    // TransformProcessType(&psn, kProcessTransformToForegroundApplication);
-
-    // Create NSApplication
-    [NSApplication sharedApplication];
-}
-
-void run() {
-#if 0
-    // this doesn't work...
-    [NSApp run];
-#else
-    // Kudos to https://www.cocoawithlove.com/2009/01/demystifying-nsapplication-by.html
-    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
-
-    [NSApp finishLaunching];
-    g_running = true;
-
-    while (g_running) {
-        [pool release];
-        pool = [[NSAutoreleasePool alloc] init];
-        NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
-                                            untilDate:[NSDate distantFuture]
-                                               inMode:NSDefaultRunLoopMode
-                                              dequeue:YES];
-        if (event) {
-            [NSApp sendEvent:event];
-            [NSApp updateWindows];
-        }
-    }
-    [pool release];
-#endif
-}
-
-void quit() {
-    // break from event loop instead of [NSApp terminate:nil]
-    g_running = false;
-    // send dummy event to wake up event loop
-    NSEvent* event = [NSEvent otherEventWithType:NSApplicationDefined
-                                        location:NSMakePoint(0, 0)
-                                   modifierFlags:0
-                                       timestamp:0
-                                    windowNumber:0
-                                         context:nil
-                                         subtype:0
-                                           data1:0
-                                           data2:0];
-    [NSApp postEvent:event atStart:NO];
-}
-
-} // EventLoop
-
 } // namespace Apple
 } // namespace SC
diff --git a/common/SC_AppleEventLoop.hpp b/common/SC_AppleEventLoop.hpp
new file mode 100644
index 0000000000..6f19bb2818
--- /dev/null
+++ b/common/SC_AppleEventLoop.hpp
@@ -0,0 +1,34 @@
+/************************************************************************
+ *
+ * Copyright 2019 Christof Ressi <info@christofressi.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ ************************************************************************/
+
+#pragma once
+
+namespace SC { namespace Apple { namespace EventLoop {
+
+// Setup the main application. This function must be called in the
+// main thread and before any other calls to Cocoa methods.
+void setup();
+// Run the event loop. This function must be called in the main thread.
+// It blocks until the event loop finishes.
+void run();
+// Ask the event loop to stop and terminate the program.
+// This function can be called from any thread.
+void quit();
+
+}}} // namespace SC::Apple::EventLoop
diff --git a/common/SC_AppleEventLoop.mm b/common/SC_AppleEventLoop.mm
new file mode 100644
index 0000000000..cfcf42ddfe
--- /dev/null
+++ b/common/SC_AppleEventLoop.mm
@@ -0,0 +1,80 @@
+/************************************************************************
+ *
+ * Copyright 2019 Christof Ressi <info@christofressi.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ ************************************************************************/
+
+#include "SC_AppleEventLoop.hpp"
+#include <atomic>
+
+#import <Cocoa/Cocoa.h>
+
+namespace SC { namespace Apple { namespace EventLoop {
+
+static std::atomic_bool g_running;
+
+void setup() {
+    // The following code would transform the process into a foreground application.
+    // For now it's the plugin's responsibility to do this (early or lazily)
+    // because we don't want to always show an icon in the docker.
+    // ProcessSerialNumber psn = { 0, kCurrentProcess };
+    // TransformProcessType(&psn, kProcessTransformToForegroundApplication);
+
+    // Create NSApplication
+    [NSApplication sharedApplication];
+}
+
+void run() {
+    // this doesn't work...
+    // [NSApp run];
+    // Kudos to https://www.cocoawithlove.com/2009/01/demystifying-nsapplication-by.html
+    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+
+    [NSApp finishLaunching];
+    g_running = true;
+
+    while (g_running) {
+        [pool release];
+        pool = [[NSAutoreleasePool alloc] init];
+        NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
+                                            untilDate:[NSDate distantFuture]
+                                               inMode:NSDefaultRunLoopMode
+                                              dequeue:YES];
+        if (event) {
+            [NSApp sendEvent:event];
+            [NSApp updateWindows];
+        }
+    }
+    [pool release];
+}
+
+void quit() {
+    // break from event loop instead of [NSApp terminate:nil]
+    g_running = false;
+    // send dummy event to wake up event loop
+    NSEvent* event = [NSEvent otherEventWithType:NSApplicationDefined
+                                        location:NSMakePoint(0, 0)
+                                   modifierFlags:0
+                                       timestamp:0
+                                    windowNumber:0
+                                         context:nil
+                                         subtype:0
+                                           data1:0
+                                           data2:0];
+    [NSApp postEvent:event atStart:NO];
+}
+
+}}} // namespace SC::Apple::EventLoop
diff --git a/common/SC_EventLoop.hpp b/common/SC_EventLoop.hpp
index 1d62b4de89..6e58208cc0 100644
--- a/common/SC_EventLoop.hpp
+++ b/common/SC_EventLoop.hpp
@@ -2,7 +2,7 @@
 
 #include <functional>
 #ifdef __APPLE__
-#    include "SC_Apple.hpp"
+#    include "SC_AppleEventLoop.hpp"
 #    include <thread>
 #endif
 
@@ -21,6 +21,7 @@ class EventLoop {
         SC::Apple::EventLoop::setup();
 #endif
     }
+
     // Run the event loop until 'waitFunction' returns.
     static void run(std::function<void()> waitFunction) {
 #ifdef __APPLE__
diff --git a/server/scsynth/CMakeLists.txt b/server/scsynth/CMakeLists.txt
index fa8daf12aa..c60ae72ffc 100644
--- a/server/scsynth/CMakeLists.txt
+++ b/server/scsynth/CMakeLists.txt
@@ -230,7 +230,13 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux")
 	target_link_libraries(libscsynth rt)
 endif()
 
-add_executable(scsynth scsynth_main.cpp)
+add_executable(scsynth
+    scsynth_main.cpp
+
+    # these files contain code only used in main()
+    ${CMAKE_SOURCE_DIR}/common/SC_ServerBootDelayWarning.cpp
+    $<$<BOOL:${APPLE}>: ${CMAKE_SOURCE_DIR}/common/SC_AppleEventLoop.mm >
+    )
 target_link_libraries(scsynth libscsynth)
 
 if (PTHREADS_FOUND)
diff --git a/server/supernova/CMakeLists.txt b/server/supernova/CMakeLists.txt
index 923a3aa4e4..ce8388e475 100644
--- a/server/supernova/CMakeLists.txt
+++ b/server/supernova/CMakeLists.txt
@@ -182,7 +182,14 @@ if(WIN32)
 endif()
 
 
-add_executable(supernova server/main.cpp ${supernova_headers})
+add_executable(supernova
+    server/main.cpp
+    ${supernova_headers}
+
+    # these files contain code only used in main()
+    ${CMAKE_SOURCE_DIR}/common/SC_ServerBootDelayWarning.cpp
+    $<$<BOOL:${APPLE}>: ${CMAKE_SOURCE_DIR}/common/SC_AppleEventLoop.mm >
+    )
 target_link_libraries(supernova libsupernova)
 
 if(WIN32)