From 4b22741255652d90a6d6c2a4e0c5e248112e5e72 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Thu, 13 Jun 2019 16:44:06 +0200 Subject: Build script also create gdnlib --- SConstruct | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) (limited to 'SConstruct') diff --git a/SConstruct b/SConstruct index cc5807d..5877ae9 100644 --- a/SConstruct +++ b/SConstruct @@ -16,7 +16,26 @@ def get_arch_dir(name): 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 +48,17 @@ 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' +result_path = os.path.join('bin', 'webrtc' if env['target'] == 'release' else 'webrtc_debug', 'lib') # 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,17 +84,7 @@ 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' env.Append(LINKFLAGS = [ '/WX' ]) if target == 'debug': @@ -102,7 +106,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' ]) @@ -168,5 +171,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'])) -- cgit v1.2.3 From 20f8f89c2cbe1e95a93fc89894324ccbbbf54c4b Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Thu, 13 Jun 2019 18:05:48 +0200 Subject: Use submodule for godot-cpp --- .gitmodules | 3 +++ SConstruct | 19 +++++++------------ godot-cpp | 1 + lib/godot-cpp/debug/x64/.gitignore | 2 -- lib/godot-cpp/debug/x86/.gitignore | 2 -- lib/godot-cpp/release/x64/.gitignore | 2 -- lib/godot-cpp/release/x86/.gitignore | 2 -- 7 files changed, 11 insertions(+), 20 deletions(-) create mode 100644 .gitmodules create mode 160000 godot-cpp delete mode 100644 lib/godot-cpp/debug/x64/.gitignore delete mode 100644 lib/godot-cpp/debug/x86/.gitignore delete mode 100644 lib/godot-cpp/release/x64/.gitignore delete mode 100644 lib/godot-cpp/release/x86/.gitignore (limited to 'SConstruct') diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..64fc4d4 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "godot-cpp"] + path = godot-cpp + url = https://github.com/GodotNativeTools/godot-cpp diff --git a/SConstruct b/SConstruct index 5877ae9..0fff964 100644 --- a/SConstruct +++ b/SConstruct @@ -9,13 +9,6 @@ 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: @@ -49,10 +42,11 @@ target = env['target'] host_platform = platform.system() # 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') +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']): @@ -86,6 +80,7 @@ if target_platform == 'linux': elif target_platform == 'windows': if host_platform == 'Windows': + lib_prefix = "lib" env.Append(LINKFLAGS = [ '/WX' ]) if target == 'debug': env.Append(CCFLAGS = ['/EHsc', '/D_DEBUG', '/MDd' ]) @@ -117,8 +112,8 @@ 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" diff --git a/godot-cpp b/godot-cpp new file mode 160000 index 0000000..7cbb846 --- /dev/null +++ b/godot-cpp @@ -0,0 +1 @@ +Subproject commit 7cbb846417acf0154a786bcaee8a5b1d7b40df57 diff --git a/lib/godot-cpp/debug/x64/.gitignore b/lib/godot-cpp/debug/x64/.gitignore deleted file mode 100644 index d6b7ef3..0000000 --- a/lib/godot-cpp/debug/x64/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/lib/godot-cpp/debug/x86/.gitignore b/lib/godot-cpp/debug/x86/.gitignore deleted file mode 100644 index d6b7ef3..0000000 --- a/lib/godot-cpp/debug/x86/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/lib/godot-cpp/release/x64/.gitignore b/lib/godot-cpp/release/x64/.gitignore deleted file mode 100644 index d6b7ef3..0000000 --- a/lib/godot-cpp/release/x64/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/lib/godot-cpp/release/x86/.gitignore b/lib/godot-cpp/release/x86/.gitignore deleted file mode 100644 index d6b7ef3..0000000 --- a/lib/godot-cpp/release/x86/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore -- cgit v1.2.3 From 54cbe83c56f13783c59abee302d4f0bbe005cbd7 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Thu, 13 Jun 2019 16:54:12 +0200 Subject: Simplify webrtc lib folder structure --- SConstruct | 4 ++-- lib/webrtc/.gitignore | 1 - lib/webrtc/lib/linux/.gitignore | 2 -- lib/webrtc/lib/windows/.gitignore | 2 -- webrtc/.gitignore | 1 + webrtc/linux/.gitignore | 2 ++ webrtc/windows/.gitignore | 2 ++ 7 files changed, 7 insertions(+), 7 deletions(-) delete mode 100644 lib/webrtc/.gitignore delete mode 100644 lib/webrtc/lib/linux/.gitignore delete mode 100644 lib/webrtc/lib/windows/.gitignore create mode 100644 webrtc/.gitignore create mode 100644 webrtc/linux/.gitignore create mode 100644 webrtc/windows/.gitignore (limited to 'SConstruct') diff --git a/SConstruct b/SConstruct index 0fff964..6819640 100644 --- a/SConstruct +++ b/SConstruct @@ -116,9 +116,9 @@ 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' diff --git a/lib/webrtc/.gitignore b/lib/webrtc/.gitignore deleted file mode 100644 index 08f514e..0000000 --- a/lib/webrtc/.gitignore +++ /dev/null @@ -1 +0,0 @@ -include/ diff --git a/lib/webrtc/lib/linux/.gitignore b/lib/webrtc/lib/linux/.gitignore deleted file mode 100644 index d6b7ef3..0000000 --- a/lib/webrtc/lib/linux/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/lib/webrtc/lib/windows/.gitignore b/lib/webrtc/lib/windows/.gitignore deleted file mode 100644 index d6b7ef3..0000000 --- a/lib/webrtc/lib/windows/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/webrtc/.gitignore b/webrtc/.gitignore new file mode 100644 index 0000000..08f514e --- /dev/null +++ b/webrtc/.gitignore @@ -0,0 +1 @@ +include/ diff --git a/webrtc/linux/.gitignore b/webrtc/linux/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/webrtc/linux/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/webrtc/windows/.gitignore b/webrtc/windows/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/webrtc/windows/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore -- cgit v1.2.3