Skip to content

Commit

Permalink
Merge pull request #20913 from pulkomandy/master
Browse files Browse the repository at this point in the history
Rebase patches for fixing haiku build.
  • Loading branch information
akien-mga authored Aug 13, 2018
2 parents 369e546 + a294a84 commit 139e621
Show file tree
Hide file tree
Showing 18 changed files with 273 additions and 302 deletions.
165 changes: 83 additions & 82 deletions modules/websocket/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -7,87 +7,88 @@ Import('env_modules')

env_lws = env_modules.Clone()

thirdparty_dir = "#thirdparty/libwebsockets/"
helper_dir = "win32helpers/"
thirdparty_sources = [

"core/alloc.c",
"core/context.c",
"core/libwebsockets.c",
"core/output.c",
"core/pollfd.c",
"core/service.c",

"event-libs/poll/poll.c",

"misc/base64-decode.c",
"misc/lejp.c",
"misc/sha-1.c",

"roles/h1/ops-h1.c",
"roles/http/header.c",
"roles/http/client/client.c",
"roles/http/client/client-handshake.c",
"roles/http/server/fops-zip.c",
"roles/http/server/lejp-conf.c",
"roles/http/server/parsers.c",
"roles/http/server/server.c",
"roles/listen/ops-listen.c",
"roles/pipe/ops-pipe.c",
"roles/raw/ops-raw.c",

"roles/ws/client-ws.c",
"roles/ws/client-parser-ws.c",
"roles/ws/ops-ws.c",
"roles/ws/server-ws.c",

"tls/tls.c",
"tls/tls-client.c",
"tls/tls-server.c",

"tls/mbedtls/wrapper/library/ssl_cert.c",
"tls/mbedtls/wrapper/library/ssl_pkey.c",
"tls/mbedtls/wrapper/library/ssl_stack.c",
"tls/mbedtls/wrapper/library/ssl_methods.c",
"tls/mbedtls/wrapper/library/ssl_lib.c",
"tls/mbedtls/wrapper/library/ssl_x509.c",
"tls/mbedtls/wrapper/platform/ssl_port.c",
"tls/mbedtls/wrapper/platform/ssl_pm.c",
"tls/mbedtls/lws-genhash.c",
"tls/mbedtls/mbedtls-client.c",
"tls/mbedtls/lws-genrsa.c",
"tls/mbedtls/ssl.c",
"tls/mbedtls/mbedtls-server.c"
]

if env_lws["platform"] == "android": # Builtin getifaddrs
thirdparty_sources += ["misc/getifaddrs.c"]

if env_lws["platform"] == "windows" or env_lws["platform"] == "uwp": # Winsock
thirdparty_sources += ["plat/lws-plat-win.c", helper_dir + "getopt.c", helper_dir + "getopt_long.c", helper_dir + "gettimeofday.c"]
else: # Unix socket
thirdparty_sources += ["plat/lws-plat-unix.c"]


thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]

if env_lws["platform"] == "javascript": # No need to add third party libraries at all
pass
else:
env_lws.add_source_files(env.modules_sources, thirdparty_sources)
env_lws.Append(CPPPATH=[thirdparty_dir])

wrapper_includes = ["#thirdparty/libwebsockets/tls/mbedtls/wrapper/include/" + inc for inc in ["internal", "openssl", "platform", ""]]
env_lws.Prepend(CPPPATH=wrapper_includes)

if env['builtin_mbedtls']:
mbedtls_includes = "#thirdparty/mbedtls/include"
env_lws.Prepend(CPPPATH=[mbedtls_includes])

if env_lws["platform"] == "windows" or env_lws["platform"] == "uwp":
env_lws.Append(CPPPATH=[thirdparty_dir + helper_dir])

if env_lws["platform"] == "uwp":
env_lws.Append(CCFLAGS=["/DLWS_MINGW_SUPPORT"])
if env['builtin_libwebsockets']:
thirdparty_dir = "#thirdparty/libwebsockets/"
helper_dir = "win32helpers/"
thirdparty_sources = [

"core/alloc.c",
"core/context.c",
"core/libwebsockets.c",
"core/output.c",
"core/pollfd.c",
"core/service.c",

"event-libs/poll/poll.c",

"misc/base64-decode.c",
"misc/lejp.c",
"misc/sha-1.c",

"roles/h1/ops-h1.c",
"roles/http/header.c",
"roles/http/client/client.c",
"roles/http/client/client-handshake.c",
"roles/http/server/fops-zip.c",
"roles/http/server/lejp-conf.c",
"roles/http/server/parsers.c",
"roles/http/server/server.c",
"roles/listen/ops-listen.c",
"roles/pipe/ops-pipe.c",
"roles/raw/ops-raw.c",

"roles/ws/client-ws.c",
"roles/ws/client-parser-ws.c",
"roles/ws/ops-ws.c",
"roles/ws/server-ws.c",

"tls/tls.c",
"tls/tls-client.c",
"tls/tls-server.c",

"tls/mbedtls/wrapper/library/ssl_cert.c",
"tls/mbedtls/wrapper/library/ssl_pkey.c",
"tls/mbedtls/wrapper/library/ssl_stack.c",
"tls/mbedtls/wrapper/library/ssl_methods.c",
"tls/mbedtls/wrapper/library/ssl_lib.c",
"tls/mbedtls/wrapper/library/ssl_x509.c",
"tls/mbedtls/wrapper/platform/ssl_port.c",
"tls/mbedtls/wrapper/platform/ssl_pm.c",
"tls/mbedtls/lws-genhash.c",
"tls/mbedtls/mbedtls-client.c",
"tls/mbedtls/lws-genrsa.c",
"tls/mbedtls/ssl.c",
"tls/mbedtls/mbedtls-server.c"
]

if env_lws["platform"] == "android": # Builtin getifaddrs
thirdparty_sources += ["misc/getifaddrs.c"]

if env_lws["platform"] == "windows" or env_lws["platform"] == "uwp": # Winsock
thirdparty_sources += ["plat/lws-plat-win.c", helper_dir + "getopt.c", helper_dir + "getopt_long.c", helper_dir + "gettimeofday.c"]
else: # Unix socket
thirdparty_sources += ["plat/lws-plat-unix.c"]


thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]

if env_lws["platform"] == "javascript": # No need to add third party libraries at all
pass
else:
env_lws.add_source_files(env.modules_sources, thirdparty_sources)
env_lws.Append(CPPPATH=[thirdparty_dir])

wrapper_includes = ["#thirdparty/libwebsockets/tls/mbedtls/wrapper/include/" + inc for inc in ["internal", "openssl", "platform", ""]]
env_lws.Prepend(CPPPATH=wrapper_includes)

if env['builtin_mbedtls']:
mbedtls_includes = "#thirdparty/mbedtls/include"
env_lws.Prepend(CPPPATH=[mbedtls_includes])

if env_lws["platform"] == "windows" or env_lws["platform"] == "uwp":
env_lws.Append(CPPPATH=[thirdparty_dir + helper_dir])

if env_lws["platform"] == "uwp":
env_lws.Append(CCFLAGS=["/DLWS_MINGW_SUPPORT"])

env_lws.add_source_files(env.modules_sources, "*.cpp")
2 changes: 1 addition & 1 deletion platform/haiku/audio_driver_media_kit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ int AudioDriverMediaKit::get_mix_rate() const {
return mix_rate;
}

AudioDriverSW::SpeakerMode AudioDriverMediaKit::get_speaker_mode() const {
AudioDriverMediaKit::SpeakerMode AudioDriverMediaKit::get_speaker_mode() const {
return speaker_mode;
}

Expand Down
3 changes: 2 additions & 1 deletion platform/haiku/audio_driver_media_kit.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@
#include "core/os/mutex.h"
#include "core/os/thread.h"

#include <SoundPlayer.h>
#include <kernel/image.h> // needed for image_id

#include <SoundPlayer.h>

class AudioDriverMediaKit : public AudioDriver {
Mutex *mutex;

Expand Down
81 changes: 81 additions & 0 deletions platform/haiku/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,87 @@ def configure(env):
env["CC"] = "gcc-x86"
env["CXX"] = "g++-x86"

## Dependencies

if not env['builtin_libwebp']:
env.ParseConfig('pkg-config libwebp --cflags --libs')

# freetype depends on libpng and zlib, so bundling one of them while keeping others
# as shared libraries leads to weird issues
if env['builtin_freetype'] or env['builtin_libpng'] or env['builtin_zlib']:
env['builtin_freetype'] = True
env['builtin_libpng'] = True
env['builtin_zlib'] = True

if not env['builtin_freetype']:
env.ParseConfig('pkg-config freetype2 --cflags --libs')

if not env['builtin_libpng']:
env.ParseConfig('pkg-config libpng --cflags --libs')

if not env['builtin_bullet']:
# We need at least version 2.88
import subprocess
bullet_version = subprocess.check_output(['pkg-config', 'bullet', '--modversion']).strip()
if bullet_version < "2.88":
# Abort as system bullet was requested but too old
print("Bullet: System version {0} does not match minimal requirements ({1}). Aborting.".format(bullet_version, "2.88"))
sys.exit(255)
env.ParseConfig('pkg-config bullet --cflags --libs')

if not env['builtin_enet']:
env.ParseConfig('pkg-config libenet --cflags --libs')

if not env['builtin_squish'] and env['tools']:
env.ParseConfig('pkg-config libsquish --cflags --libs')

if not env['builtin_zstd']:
env.ParseConfig('pkg-config libzstd --cflags --libs')

# Sound and video libraries
# Keep the order as it triggers chained dependencies (ogg needed by others, etc.)

if not env['builtin_libtheora']:
env['builtin_libogg'] = False # Needed to link against system libtheora
env['builtin_libvorbis'] = False # Needed to link against system libtheora
env.ParseConfig('pkg-config theora theoradec --cflags --libs')

if not env['builtin_libvpx']:
env.ParseConfig('pkg-config vpx --cflags --libs')

if not env['builtin_libvorbis']:
env['builtin_libogg'] = False # Needed to link against system libvorbis
env.ParseConfig('pkg-config vorbis vorbisfile --cflags --libs')

if not env['builtin_opus']:
env['builtin_libogg'] = False # Needed to link against system opus
env.ParseConfig('pkg-config opus opusfile --cflags --libs')

if not env['builtin_libogg']:
env.ParseConfig('pkg-config ogg --cflags --libs')

if env['builtin_libtheora']:
list_of_x86 = ['x86_64', 'x86', 'i386', 'i586']
if any(platform.machine() in s for s in list_of_x86):
env["x86_libtheora_opt_gcc"] = True

if not env['builtin_libwebsockets']:
env.ParseConfig('pkg-config libwebsockets --cflags --libs')

if not env['builtin_mbedtls']:
# mbedTLS does not provide a pkgconfig config yet. See https://github.com/ARMmbed/mbedtls/issues/228
env.Append(LIBS=['mbedtls', 'mbedcrypto', 'mbedx509'])

if not env['builtin_miniupnpc']:
# No pkgconfig file so far, hardcode default paths.
env.Append(CPPPATH=["/system/develop/headers/x86/miniupnpc"])
env.Append(LIBS=["miniupnpc"])

# On Linux wchar_t should be 32-bits
# 16-bit library shouldn't be required due to compiler optimisations
if not env['builtin_pcre2']:
env.ParseConfig('pkg-config libpcre2-32 --cflags --libs')

## Flags

env.Append(CPPPATH=['#platform/haiku'])
Expand Down
3 changes: 2 additions & 1 deletion platform/haiku/haiku_application.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@
#ifndef HAIKU_APPLICATION_H
#define HAIKU_APPLICATION_H

#include <Application.h>
#include <kernel/image.h> // needed for image_id

#include <Application.h>

class HaikuApplication : public BApplication {
public:
HaikuApplication();
Expand Down
Loading

0 comments on commit 139e621

Please sign in to comment.