summaryrefslogtreecommitdiff
path: root/SConstruct
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2020-01-03 19:43:01 +0100
committerGitHub <noreply@github.com>2020-01-03 19:43:01 +0100
commit61e45cb083a2879bed238f3052f7c12bd230da16 (patch)
tree8a8f727a8d79342f2bd5df79bc58fc32b964b821 /SConstruct
parent423454086e21d40a545f9e46d6e35c1b3c557d77 (diff)
parent6983019cab6acc39d3e4157f7e03aafadb2291df (diff)
downloadfork-godot-webrtc-native-61e45cb083a2879bed238f3052f7c12bd230da16.tar.gz
fork-godot-webrtc-native-61e45cb083a2879bed238f3052f7c12bd230da16.tar.bz2
fork-godot-webrtc-native-61e45cb083a2879bed238f3052f7c12bd230da16.zip
Merge pull request #10 from Faless/refactor/better-scons
Better build script, readme
Diffstat (limited to 'SConstruct')
-rw-r--r--SConstruct65
1 files changed, 35 insertions, 30 deletions
diff --git a/SConstruct b/SConstruct
index cc5807d..6819640 100644
--- a/SConstruct
+++ b/SConstruct
@@ -9,14 +9,26 @@ def add_sources(sources, dirpath, extension):
sources.append(dirpath + '/' + f)
-def get_arch_dir(name):
- if name == '32':
- return 'x86'
- elif name == '64':
- return 'x64'
- return name
+def gen_gdnative_lib(target, source, env):
+ for t in target:
+ with open(t.srcnode().path, 'w') as w:
+ w.write(source[0].get_contents().replace('{GDNATIVE_PATH}', os.path.splitext(t.name)[0]).replace('{TARGET}', env['target']))
+
env = Environment()
+
+target_arch = ARGUMENTS.get('b', ARGUMENTS.get('bits', '64'))
+target_platform = ARGUMENTS.get('p', ARGUMENTS.get('platform', 'linux'))
+if target_platform == 'windows':
+ # This makes sure to keep the session environment variables on windows,
+ # that way you can run scons in a vs 2017 prompt and it will find all the required tools
+ if (target_arch == '64'):
+ env = Environment(ENV = os.environ, TARGET_ARCH='amd64')
+ else:
+ env = Environment(ENV = os.environ, TARGET_ARCH='x86')
+
+env.Append(BUILDERS={'GDNativeLibBuilder': Builder(action=gen_gdnative_lib)})
+
customs = ['custom.py']
opts = Variables(customs, ARGUMENTS)
@@ -29,22 +41,18 @@ 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'))
# Local dependency paths, adapt them to your setup
-godot_headers = ARGUMENTS.get('headers', '../godot_headers')
-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'
+godot_headers = ARGUMENTS.get('headers', 'godot-cpp/godot_headers')
+godot_cpp_headers = ARGUMENTS.get('godot_cpp_headers', 'godot-cpp/include')
+godot_cpp_lib_dir = ARGUMENTS.get('godot_cpp_lib_dir', 'godot-cpp/bin')
+result_path = os.path.join('bin', 'webrtc' if env['target'] == 'release' else 'webrtc_debug', 'lib')
+lib_prefix = ""
# 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++'
# LLVM
@@ -70,18 +78,9 @@ if target_platform == 'linux':
env.Append(LINKFLAGS = [ '-m64' ])
elif target_platform == 'windows':
- # This makes sure to keep the session environment variables on windows,
- # that way you can run scons in a vs 2017 prompt and it will find all the required tools
- if (target_arch == '64'):
- env = Environment(ENV = os.environ, TARGET_ARCH='amd64')
- else:
- env = Environment(ENV = os.environ, TARGET_ARCH='x86')
-
- result_name += '.windows.' + target + '.' + target_arch
-
if host_platform == 'Windows':
- #result_name += '.lib'
+ lib_prefix = "lib"
env.Append(LINKFLAGS = [ '/WX' ])
if target == 'debug':
env.Append(CCFLAGS = ['/EHsc', '/D_DEBUG', '/MDd' ])
@@ -102,7 +101,6 @@ elif target_platform == 'osx':
# Only 64-bits is supported for OS X
target_arch = '64'
- result_name += '.osx.' + target + '.' + target_arch
env.Append(CCFLAGS = [ '-g','-O3', '-std=c++14', '-arch', 'x86_64' ])
env.Append(LINKFLAGS = [ '-arch', 'x86_64', '-framework', 'Cocoa', '-Wl,-undefined,dynamic_lookup' ])
@@ -114,13 +112,13 @@ else:
# Godot CPP bindings
env.Append(CPPPATH=[godot_headers])
env.Append(CPPPATH=[godot_cpp_headers, godot_cpp_headers + '/core', godot_cpp_headers + '/gen'])
-env.Append(LIBPATH=[godot_cpp_lib_dir + '/' + target + '/' + get_arch_dir(target_arch)])
-env.Append(LIBS=['godot-cpp'])
+env.Append(LIBPATH=[godot_cpp_lib_dir])
+env.Append(LIBS=['%sgodot-cpp.%s.%s.%s' % (lib_prefix, target_platform, target, target_arch)])
# WebRTC stuff
-webrtc_dir = "lib/webrtc"
+webrtc_dir = "webrtc"
lib_name = 'libwebrtc_full'
-lib_path = webrtc_dir + '/lib/' + target_platform
+lib_path = os.path.join(webrtc_dir, target_platform)
if target_arch == '64':
lib_path += '/x64'
@@ -168,5 +166,12 @@ suffix = '.%s.%s' % (target, target_arch)
env["SHOBJSUFFIX"] = suffix + env["SHOBJSUFFIX"]
# Make the shared library
+result_name = 'webrtc_native.%s.%s.%s' % (target_platform, target, target_arch)
library = env.SharedLibrary(target=os.path.join(result_path, result_name), source=sources)
Default(library)
+
+# GDNativeLibrary
+gdnlib = 'webrtc'
+if target != 'release':
+ gdnlib += '_debug'
+Default(env.GDNativeLibBuilder([os.path.join('bin', gdnlib, gdnlib + '.gdns')], ['misc/gdnlib.tres']))