mirror of
https://github.com/godotengine/webrtc-native.git
synced 2026-01-01 05:48:15 +03:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f2cf2e5340 | ||
|
|
1763d278e0 | ||
|
|
8e46eed9e8 | ||
|
|
6c0831b6c6 | ||
|
|
c30ddd9b22 |
54
SConstruct
54
SConstruct
@@ -10,25 +10,50 @@ def add_sources(sources, dirpath, extension):
|
||||
|
||||
|
||||
env = Environment()
|
||||
customs = ['custom.py']
|
||||
opts = Variables(customs, ARGUMENTS)
|
||||
|
||||
opts.Add(BoolVariable('use_llvm', 'Use the LLVM compiler', False))
|
||||
opts.Add(EnumVariable('target', "Compilation target", 'debug', ('debug', 'release')))
|
||||
|
||||
# Update environment (parse options)
|
||||
opts.Update(env)
|
||||
|
||||
target = env['target']
|
||||
|
||||
host_platform = platform.system()
|
||||
target_platform = ARGUMENTS.get('p', ARGUMENTS.get('platform', 'linux'))
|
||||
target_arch = ARGUMENTS.get('a', ARGUMENTS.get('arch', '64'))
|
||||
# default to debug build, must be same setting as used for cpp_bindings
|
||||
target = ARGUMENTS.get('target', 'debug')
|
||||
# Local dependency paths, adapt them to your setup
|
||||
godot_headers = ARGUMENTS.get('headers', '../godot_headers')
|
||||
godot_cpp = ARGUMENTS.get('godot-cpp', '../godot-cpp')
|
||||
godot_cpp_headers = ARGUMENTS.get('godot_cpp_headers', '../godot-cpp/include')
|
||||
godot_cpp_lib_dir = ARGUMENTS.get('godot_cpp_lib_dir', 'lib/godot-cpp')
|
||||
result_path = 'bin'
|
||||
result_name = 'webrtc_native'
|
||||
|
||||
# Convenience check to enforce the use_llvm overrides when CXX is clang(++)
|
||||
if 'CXX' in env and 'clang' in os.path.basename(env['CXX']):
|
||||
env['use_llvm'] = True
|
||||
|
||||
if target_platform == 'linux':
|
||||
result_name += '.linux.' + target + '.' + target_arch
|
||||
|
||||
env['CXX']='g++'
|
||||
if ARGUMENTS.get('use_llvm', 'no') == 'yes':
|
||||
env['CXX'] = 'clang++'
|
||||
|
||||
env.Append(CCFLAGS = [ '-fPIC', '-g', '-O3', '-std=c++14', '-Wwrite-strings' ])
|
||||
# LLVM
|
||||
if env['use_llvm']:
|
||||
if ('clang++' not in os.path.basename(env['CXX'])):
|
||||
env['CC'] = 'clang'
|
||||
env["CXX"] = "clang++"
|
||||
env["LINK"] = "clang++"
|
||||
|
||||
if (env["target"] == "debug"):
|
||||
env.Prepend(CCFLAGS=['-g3'])
|
||||
env.Append(LINKFLAGS=['-rdynamic'])
|
||||
else:
|
||||
env.Prepend(CCFLAGS=['-O3'])
|
||||
|
||||
env.Append(CCFLAGS=['-fPIC', '-std=c++11'])
|
||||
|
||||
if target_arch == '32':
|
||||
env.Append(CCFLAGS = [ '-m32' ])
|
||||
@@ -65,7 +90,7 @@ elif target_platform == 'windows':
|
||||
env.Append(LINKFLAGS = [ '--static', '-Wl,--no-undefined', '-static-libgcc', '-static-libstdc++' ])
|
||||
|
||||
elif target_platform == 'osx':
|
||||
if ARGUMENTS.get('use_llvm', 'no') == 'yes':
|
||||
if env['use_llvm']:
|
||||
env['CXX'] = 'clang++'
|
||||
|
||||
# Only 64-bits is supported for OS X
|
||||
@@ -81,14 +106,14 @@ else:
|
||||
|
||||
# Godot CPP bindings
|
||||
env.Append(CPPPATH=[godot_headers])
|
||||
env.Append(CPPPATH=[godot_cpp + '/include', godot_cpp + '/include/core', godot_cpp + '/include/gen'])
|
||||
env.Append(LIBPATH=[godot_cpp + '/bin'])
|
||||
env.Append(CPPPATH=[godot_cpp_headers, godot_cpp_headers + '/core', godot_cpp_headers + '/gen'])
|
||||
env.Append(LIBPATH=[godot_cpp_lib_dir + '/' + target])
|
||||
env.Append(LIBS=['godot-cpp'])
|
||||
|
||||
# WebRTC stuff
|
||||
webrtc_dir = "webrtc"
|
||||
webrtc_dir = "lib/webrtc"
|
||||
lib_name = 'libwebrtc_full'
|
||||
lib_path = webrtc_dir + '/lib'
|
||||
lib_path = webrtc_dir + '/lib/' + target_platform
|
||||
|
||||
if target_arch == '64':
|
||||
lib_path += '/x64'
|
||||
@@ -101,7 +126,6 @@ else:
|
||||
lib_path += '/Release'
|
||||
|
||||
env.Append(CPPPATH=[webrtc_dir + "/include"])
|
||||
#env.Append(CPPPATH=[lib_path])
|
||||
|
||||
if target_platform == "linux":
|
||||
env.Append(LIBS=[lib_name])
|
||||
@@ -126,12 +150,6 @@ elif target_platform == "osx":
|
||||
env.Append(LIBS=[lib_name])
|
||||
env.Append(LIBPATH=[lib_path])
|
||||
|
||||
# Godot CPP bindings
|
||||
env.Append(CPPPATH=[godot_headers])
|
||||
env.Append(CPPPATH=[godot_cpp + '/include', godot_cpp + '/include/core', godot_cpp + '/include/gen'])
|
||||
env.Append(LIBPATH=[godot_cpp + '/bin'])
|
||||
env.Append(LIBS=['godot-cpp'])
|
||||
|
||||
# Our includes and sources
|
||||
env.Append(CPPPATH=['src/'])
|
||||
sources = []
|
||||
|
||||
1
lib/webrtc/.gitignore
vendored
Normal file
1
lib/webrtc/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
include/
|
||||
2
lib/webrtc/lib/linux/.gitignore
vendored
Normal file
2
lib/webrtc/lib/linux/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
2
lib/webrtc/lib/windows/.gitignore
vendored
Normal file
2
lib/webrtc/lib/windows/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
13
src/init.cpp
13
src/init.cpp
@@ -6,8 +6,17 @@
|
||||
extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) {
|
||||
const godot_gdnative_core_api_struct *api = o->api_struct;
|
||||
for (int i = 0; i < api->num_extensions; i++) {
|
||||
if (api->extensions[i]->type == GDNATIVE_EXT_NET) {
|
||||
WebRTCPeerNative::_net_api = (godot_gdnative_ext_net_api_struct *)api->extensions[i];
|
||||
|
||||
if (api->extensions[i]->type != GDNATIVE_EXT_NET)
|
||||
continue;
|
||||
|
||||
const godot_gdnative_ext_net_api_struct *net_api = (godot_gdnative_ext_net_api_struct *)api->extensions[i];
|
||||
|
||||
if (!net_api->next)
|
||||
break;
|
||||
|
||||
if (net_api->next->version.major == 3 && net_api->next->version.minor == 2) {
|
||||
WebRTCPeerNative::_net_api = (const godot_gdnative_ext_net_3_2_api_struct *)net_api->next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "WebRTCPeerNative.hpp"
|
||||
|
||||
const godot_gdnative_ext_net_api_struct *WebRTCPeerNative::_net_api = NULL;
|
||||
const godot_gdnative_ext_net_3_2_api_struct *WebRTCPeerNative::_net_api = NULL;
|
||||
|
||||
void WebRTCPeerNative::register_interface(const godot_net_webrtc_peer *p_interface) {
|
||||
ERR_FAIL_COND(!_net_api);
|
||||
|
||||
@@ -52,7 +52,7 @@ protected:
|
||||
|
||||
public:
|
||||
static void _register_methods();
|
||||
static const godot_gdnative_ext_net_api_struct *_net_api;
|
||||
static const godot_gdnative_ext_net_3_2_api_struct *_net_api;
|
||||
|
||||
void _init();
|
||||
void register_interface(const godot_net_webrtc_peer *interface);
|
||||
|
||||
Reference in New Issue
Block a user