Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server platform works on OS X too #23279

Merged
merged 1 commit into from
Oct 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,10 @@ if selected_platform in platform_list:
else: # always enable those errors
env.Append(CCFLAGS=['-Werror=return-type'])

suffix = "." + selected_platform
if (hasattr(detect, 'get_program_suffix')):
akien-mga marked this conversation as resolved.
Show resolved Hide resolved
suffix = "." + detect.get_program_suffix()
else:
suffix = "." + selected_platform

if (env["target"] == "release"):
if env["tools"]:
Expand Down
2 changes: 1 addition & 1 deletion drivers/unix/net_socket_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

#include <netinet/tcp.h>

#if defined(OSX_ENABLED) || defined(IPHONE_ENABLED)
#if defined(__APPLE__)
#define MSG_NOSIGNAL SO_NOSIGPIPE
#endif

Expand Down
4 changes: 4 additions & 0 deletions platform/osx/os_osx.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,12 @@ class OS_OSX : public OS_Unix {

IP_Unix *ip_unix;

#ifdef COREAUDIO_ENABLED
AudioDriverCoreAudio audio_driver;
#endif
#ifdef COREMIDI_ENABLED
MIDIDriverCoreMidi midi_driver;
#endif

InputDefault *input;
JoypadOSX *joypad_osx;
Expand Down
4 changes: 4 additions & 0 deletions platform/osx/os_osx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,9 @@ static void displays_arrangement_changed(CGDirectDisplayID display_id, CGDisplay

void OS_OSX::finalize() {

#ifdef COREMIDI_ENABLED
midi_driver.close();
#endif

CFNotificationCenterRemoveObserver(CFNotificationCenterGetDistributedCenter(), NULL, kTISNotifySelectedKeyboardInputSourceChanged, NULL);
CGDisplayRemoveReconfigurationCallback(displays_arrangement_changed, NULL);
Expand Down Expand Up @@ -2725,7 +2727,9 @@ static int get_screen_index(NSScreen *screen) {
[NSApp sendEvent:event];
}

#ifdef COREAUDIO_ENABLED
AudioDriverManager::add_driver(&audio_driver);
#endif
}

bool OS_OSX::_check_internal_feature_support(const String &p_feature) {
Expand Down
15 changes: 13 additions & 2 deletions platform/server/SCsub
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
#!/usr/bin/env python

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)
12 changes: 11 additions & 1 deletion platform/server/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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" or sys.platform != "darwin"):
return False

return True
Expand Down Expand Up @@ -147,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"):
Expand Down
8 changes: 8 additions & 0 deletions platform/server/os_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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();

Expand Down
10 changes: 10 additions & 0 deletions platform/server/os_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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;

Expand Down
5 changes: 4 additions & 1 deletion platform/server/platform_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion thirdparty/libwebsockets/lws_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
#define LWS_HAVE_MALLOC_H
#endif

#if !defined(IPHONE_ENABLED) && !defined(OSX_ENABLED) && !defined(__HAIKU__)
#if !defined(__APPLE__) && !defined(__HAIKU__)
#define LWS_HAVE_PIPE2
#endif

Expand Down
2 changes: 1 addition & 1 deletion thirdparty/libwebsockets/lws_config_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@

/* Define to 1 if you have the <sys/prctl.h> header file. */
#define LWS_HAVE_SYS_PRCTL_H
#if defined(OSX_ENABLED) || defined(IPHONE_ENABLED) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__HAIKU__)
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__HAIKU__)
#undef LWS_HAVE_SYS_PRCTL_H
#endif

Expand Down