Skip to content

Commit f2cf2e5

Browse files
authored
Merge pull request #2 from Faless/build/refactor
Refactor Scons build script
2 parents c30ddd9 + 1763d27 commit f2cf2e5

File tree

6 files changed

+41
-18
lines changed

6 files changed

+41
-18
lines changed

SConstruct

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,50 @@ def add_sources(sources, dirpath, extension):
1010

1111

1212
env = Environment()
13+
customs = ['custom.py']
14+
opts = Variables(customs, ARGUMENTS)
15+
16+
opts.Add(BoolVariable('use_llvm', 'Use the LLVM compiler', False))
17+
opts.Add(EnumVariable('target', "Compilation target", 'debug', ('debug', 'release')))
18+
19+
# Update environment (parse options)
20+
opts.Update(env)
21+
22+
target = env['target']
23+
1324
host_platform = platform.system()
1425
target_platform = ARGUMENTS.get('p', ARGUMENTS.get('platform', 'linux'))
1526
target_arch = ARGUMENTS.get('a', ARGUMENTS.get('arch', '64'))
16-
# default to debug build, must be same setting as used for cpp_bindings
17-
target = ARGUMENTS.get('target', 'debug')
1827
# Local dependency paths, adapt them to your setup
1928
godot_headers = ARGUMENTS.get('headers', '../godot_headers')
20-
godot_cpp = ARGUMENTS.get('godot-cpp', '../godot-cpp')
29+
godot_cpp_headers = ARGUMENTS.get('godot_cpp_headers', '../godot-cpp/include')
30+
godot_cpp_lib_dir = ARGUMENTS.get('godot_cpp_lib_dir', 'lib/godot-cpp')
2131
result_path = 'bin'
2232
result_name = 'webrtc_native'
2333

34+
# Convenience check to enforce the use_llvm overrides when CXX is clang(++)
35+
if 'CXX' in env and 'clang' in os.path.basename(env['CXX']):
36+
env['use_llvm'] = True
37+
2438
if target_platform == 'linux':
2539
result_name += '.linux.' + target + '.' + target_arch
2640

2741
env['CXX']='g++'
28-
if ARGUMENTS.get('use_llvm', 'no') == 'yes':
29-
env['CXX'] = 'clang++'
3042

31-
env.Append(CCFLAGS = [ '-fPIC', '-g', '-O3', '-std=c++14', '-Wwrite-strings' ])
43+
# LLVM
44+
if env['use_llvm']:
45+
if ('clang++' not in os.path.basename(env['CXX'])):
46+
env['CC'] = 'clang'
47+
env["CXX"] = "clang++"
48+
env["LINK"] = "clang++"
49+
50+
if (env["target"] == "debug"):
51+
env.Prepend(CCFLAGS=['-g3'])
52+
env.Append(LINKFLAGS=['-rdynamic'])
53+
else:
54+
env.Prepend(CCFLAGS=['-O3'])
55+
56+
env.Append(CCFLAGS=['-fPIC', '-std=c++11'])
3257

3358
if target_arch == '32':
3459
env.Append(CCFLAGS = [ '-m32' ])
@@ -65,7 +90,7 @@ elif target_platform == 'windows':
6590
env.Append(LINKFLAGS = [ '--static', '-Wl,--no-undefined', '-static-libgcc', '-static-libstdc++' ])
6691

6792
elif target_platform == 'osx':
68-
if ARGUMENTS.get('use_llvm', 'no') == 'yes':
93+
if env['use_llvm']:
6994
env['CXX'] = 'clang++'
7095

7196
# Only 64-bits is supported for OS X
@@ -81,14 +106,14 @@ else:
81106

82107
# Godot CPP bindings
83108
env.Append(CPPPATH=[godot_headers])
84-
env.Append(CPPPATH=[godot_cpp + '/include', godot_cpp + '/include/core', godot_cpp + '/include/gen'])
85-
env.Append(LIBPATH=[godot_cpp + '/bin'])
109+
env.Append(CPPPATH=[godot_cpp_headers, godot_cpp_headers + '/core', godot_cpp_headers + '/gen'])
110+
env.Append(LIBPATH=[godot_cpp_lib_dir + '/' + target])
86111
env.Append(LIBS=['godot-cpp'])
87112

88113
# WebRTC stuff
89-
webrtc_dir = "webrtc"
114+
webrtc_dir = "lib/webrtc"
90115
lib_name = 'libwebrtc_full'
91-
lib_path = webrtc_dir + '/lib'
116+
lib_path = webrtc_dir + '/lib/' + target_platform
92117

93118
if target_arch == '64':
94119
lib_path += '/x64'
@@ -101,7 +126,6 @@ else:
101126
lib_path += '/Release'
102127

103128
env.Append(CPPPATH=[webrtc_dir + "/include"])
104-
#env.Append(CPPPATH=[lib_path])
105129

106130
if target_platform == "linux":
107131
env.Append(LIBS=[lib_name])
@@ -126,12 +150,6 @@ elif target_platform == "osx":
126150
env.Append(LIBS=[lib_name])
127151
env.Append(LIBPATH=[lib_path])
128152

129-
# Godot CPP bindings
130-
env.Append(CPPPATH=[godot_headers])
131-
env.Append(CPPPATH=[godot_cpp + '/include', godot_cpp + '/include/core', godot_cpp + '/include/gen'])
132-
env.Append(LIBPATH=[godot_cpp + '/bin'])
133-
env.Append(LIBS=['godot-cpp'])
134-
135153
# Our includes and sources
136154
env.Append(CPPPATH=['src/'])
137155
sources = []
File renamed without changes.
File renamed without changes.

lib/webrtc/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include/

lib/webrtc/lib/linux/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

lib/webrtc/lib/windows/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

0 commit comments

Comments
 (0)