From 6c0831b6c6594c55cdc9f2fd819cce44287a454b Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Tue, 16 Apr 2019 17:35:53 +0200 Subject: Refactor SCons build script --- SConstruct | 44 ++++++++++++++++++++++++++++---------------- lib/godot-cpp/.gitignore | 2 ++ lib/webrtc/.gitignore | 2 ++ webrtc/include/.gitignore | 2 -- webrtc/lib/.gitignore | 2 -- 5 files changed, 32 insertions(+), 20 deletions(-) create mode 100644 lib/godot-cpp/.gitignore create mode 100644 lib/webrtc/.gitignore delete mode 100644 webrtc/include/.gitignore delete mode 100644 webrtc/lib/.gitignore diff --git a/SConstruct b/SConstruct index 355f6d9..53ee7bf 100644 --- a/SConstruct +++ b/SConstruct @@ -10,23 +10,42 @@ 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++' + + # LLVM + if env['use_llvm']: + if ('clang++' not in os.path.basename(env['CXX'])): + env['CC'] = 'clang' + env["CXX"] = "clang++" + env["LINK"] = "clang++" env.Append(CCFLAGS = [ '-fPIC', '-g', '-O3', '-std=c++14', '-Wwrite-strings' ]) @@ -81,14 +100,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 +120,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 +144,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 = [] diff --git a/lib/godot-cpp/.gitignore b/lib/godot-cpp/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/lib/godot-cpp/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/lib/webrtc/.gitignore b/lib/webrtc/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/lib/webrtc/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/webrtc/include/.gitignore b/webrtc/include/.gitignore deleted file mode 100644 index d6b7ef3..0000000 --- a/webrtc/include/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/webrtc/lib/.gitignore b/webrtc/lib/.gitignore deleted file mode 100644 index d6b7ef3..0000000 --- a/webrtc/lib/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore -- cgit v1.2.3