@@ -10,25 +10,50 @@ def add_sources(sources, dirpath, extension):
10
10
11
11
12
12
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
+
13
24
host_platform = platform .system ()
14
25
target_platform = ARGUMENTS .get ('p' , ARGUMENTS .get ('platform' , 'linux' ))
15
26
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' )
18
27
# Local dependency paths, adapt them to your setup
19
28
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' )
21
31
result_path = 'bin'
22
32
result_name = 'webrtc_native'
23
33
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
+
24
38
if target_platform == 'linux' :
25
39
result_name += '.linux.' + target + '.' + target_arch
26
40
27
41
env ['CXX' ]= 'g++'
28
- if ARGUMENTS .get ('use_llvm' , 'no' ) == 'yes' :
29
- env ['CXX' ] = 'clang++'
30
42
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' ])
32
57
33
58
if target_arch == '32' :
34
59
env .Append (CCFLAGS = [ '-m32' ])
@@ -65,7 +90,7 @@ elif target_platform == 'windows':
65
90
env .Append (LINKFLAGS = [ '--static' , '-Wl,--no-undefined' , '-static-libgcc' , '-static-libstdc++' ])
66
91
67
92
elif target_platform == 'osx' :
68
- if ARGUMENTS . get ( 'use_llvm' , 'no' ) == 'yes' :
93
+ if env [ 'use_llvm' ] :
69
94
env ['CXX' ] = 'clang++'
70
95
71
96
# Only 64-bits is supported for OS X
@@ -81,14 +106,14 @@ else:
81
106
82
107
# Godot CPP bindings
83
108
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 ])
86
111
env .Append (LIBS = ['godot-cpp' ])
87
112
88
113
# WebRTC stuff
89
- webrtc_dir = "webrtc"
114
+ webrtc_dir = "lib/ webrtc"
90
115
lib_name = 'libwebrtc_full'
91
- lib_path = webrtc_dir + '/lib'
116
+ lib_path = webrtc_dir + '/lib/' + target_platform
92
117
93
118
if target_arch == '64' :
94
119
lib_path += '/x64'
@@ -101,7 +126,6 @@ else:
101
126
lib_path += '/Release'
102
127
103
128
env .Append (CPPPATH = [webrtc_dir + "/include" ])
104
- #env.Append(CPPPATH=[lib_path])
105
129
106
130
if target_platform == "linux" :
107
131
env .Append (LIBS = [lib_name ])
@@ -126,12 +150,6 @@ elif target_platform == "osx":
126
150
env .Append (LIBS = [lib_name ])
127
151
env .Append (LIBPATH = [lib_path ])
128
152
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
-
135
153
# Our includes and sources
136
154
env .Append (CPPPATH = ['src/' ])
137
155
sources = []
0 commit comments