summaryrefslogtreecommitdiff
path: root/platform/server
diff options
context:
space:
mode:
Diffstat (limited to 'platform/server')
-rw-r--r--platform/server/SCsub15
-rw-r--r--platform/server/detect.py18
-rw-r--r--platform/server/os_server.cpp12
-rw-r--r--platform/server/os_server.h10
-rw-r--r--platform/server/platform_config.h5
5 files changed, 49 insertions, 11 deletions
diff --git a/platform/server/SCsub b/platform/server/SCsub
index 0788ad75ae..51fd05a87e 100644
--- a/platform/server/SCsub
+++ b/platform/server/SCsub
@@ -1,12 +1,21 @@
#!/usr/bin/env python
-Import('env')
+import os
+import platform
+import sys
+Import('env')
common_server = [\
"os_server.cpp",\
- "#platform/x11/crash_handler_x11.cpp",
- "#platform/x11/power_x11.cpp",
]
+if sys.platform == "darwin":
+ common_server.append("#platform/osx/crash_handler_osx.mm")
+ common_server.append("#platform/osx/power_osx.cpp")
+ common_server.append("#platform/osx/sem_osx.cpp")
+else:
+ common_server.append("#platform/x11/crash_handler_x11.cpp")
+ common_server.append("#platform/x11/power_x11.cpp")
+
prog = env.add_program('#bin/godot_server', ['godot_server.cpp'] + common_server)
diff --git a/platform/server/detect.py b/platform/server/detect.py
index 266b0c5cc9..0b23e9c649 100644
--- a/platform/server/detect.py
+++ b/platform/server/detect.py
@@ -11,9 +11,15 @@ def get_name():
return "Server"
+def get_program_suffix():
+ if (sys.platform == "darwin"):
+ return "osx"
+ return "x11"
+
+
def can_build():
- if (os.name != "posix" or sys.platform == "darwin"):
+ if (os.name != "posix"):
return False
return True
@@ -29,9 +35,7 @@ def get_opts():
def get_flags():
- return [
- ("module_mobile_vr_enabled", False),
- ]
+ return []
def configure(env):
@@ -56,7 +60,7 @@ def configure(env):
## Compiler configuration
if env['use_llvm']:
- if ('clang++' not in env['CXX']):
+ if ('clang++' not in os.path.basename(env['CXX'])):
env["CC"] = "clang"
env["CXX"] = "clang++"
env["LINK"] = "clang++"
@@ -149,6 +153,10 @@ def configure(env):
env.Append(CPPPATH=['#platform/server'])
env.Append(CPPFLAGS=['-DSERVER_ENABLED', '-DUNIX_ENABLED'])
+
+ if (platform.system() == "Darwin"):
+ env.Append(LINKFLAGS=['-framework', 'Cocoa', '-framework', 'Carbon', '-lz', '-framework', 'IOKit'])
+
env.Append(LIBS=['pthread'])
if (platform.system() == "Linux"):
diff --git a/platform/server/os_server.cpp b/platform/server/os_server.cpp
index 1c17780ad7..60f20d6009 100644
--- a/platform/server/os_server.cpp
+++ b/platform/server/os_server.cpp
@@ -29,10 +29,10 @@
/*************************************************************************/
#include "os_server.h"
+#include "core/print_string.h"
#include "drivers/dummy/audio_driver_dummy.h"
#include "drivers/dummy/rasterizer_dummy.h"
#include "drivers/dummy/texture_loader_dummy.h"
-#include "print_string.h"
#include "servers/visual/visual_server_raster.h"
#include "main/main.h"
@@ -68,6 +68,10 @@ void OS_Server::initialize_core() {
crash_handler.initialize();
OS_Unix::initialize_core();
+
+#ifdef __APPLE__
+ SemaphoreOSX::make_default();
+#endif
}
Error OS_Server::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
@@ -87,7 +91,11 @@ Error OS_Server::initialize(const VideoMode &p_desired, int p_video_driver, int
input = memnew(InputDefault);
+#ifdef __APPLE__
+ power_manager = memnew(power_osx);
+#else
power_manager = memnew(PowerX11);
+#endif
_ensure_user_data_dir();
@@ -221,7 +229,7 @@ void OS_Server::run() {
while (!force_quit) {
- if (Main::iteration() == true)
+ if (Main::iteration())
break;
};
diff --git a/platform/server/os_server.h b/platform/server/os_server.h
index 07d70e5236..0367ec3db9 100644
--- a/platform/server/os_server.h
+++ b/platform/server/os_server.h
@@ -34,8 +34,14 @@
#include "drivers/rtaudio/audio_driver_rtaudio.h"
#include "drivers/unix/os_unix.h"
#include "main/input_default.h"
+#ifdef __APPLE__
+#include "platform/osx/crash_handler_osx.h"
+#include "platform/osx/power_osx.h"
+#include "platform/osx/sem_osx.h"
+#else
#include "platform/x11/crash_handler_x11.h"
#include "platform/x11/power_x11.h"
+#endif
#include "servers/audio_server.h"
#include "servers/visual/rasterizer.h"
#include "servers/visual_server.h"
@@ -61,7 +67,11 @@ class OS_Server : public OS_Unix {
InputDefault *input;
+#ifdef __APPLE__
+ power_osx *power_manager;
+#else
PowerX11 *power_manager;
+#endif
CrashHandler crash_handler;
diff --git a/platform/server/platform_config.h b/platform/server/platform_config.h
index 2fa8eda337..26ba8f26c6 100644
--- a/platform/server/platform_config.h
+++ b/platform/server/platform_config.h
@@ -28,10 +28,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifdef __linux__
+#if defined(__linux__) || defined(__APPLE__)
#include <alloca.h>
#endif
#if defined(__FreeBSD__) || defined(__OpenBSD__)
#include <stdlib.h>
#define PTHREAD_BSD_SET_NAME
#endif
+#ifdef __APPLE__
+#define PTHREAD_RENAME_SELF
+#endif