@@ -18,7 +18,7 @@ def replace_flags(flags, replaces):
18
18
19
19
env = Environment ()
20
20
opts = Variables (["customs.py" ], ARGUMENTS )
21
- opts .Add (EnumVariable ("godot_version" , "The Godot target version" , "4" , ["3" , "4" ]))
21
+ opts .Add (EnumVariable ("godot_version" , "The Godot target version" , "4.1 " , ["3" , "4.0" , "4.1 " ]))
22
22
opts .Update (env )
23
23
24
24
# Minimum target platform versions.
@@ -96,6 +96,8 @@ if env["godot_version"] == "3":
96
96
elif not env ["use_mingw" ]:
97
97
# Mark as MSVC build (would have failed to build the library otherwise).
98
98
env ["is_msvc" ] = True
99
+ elif env ["godot_version" ] == "4.0" :
100
+ env = SConscript ("godot-cpp-4.0/SConstruct" ).Clone ()
99
101
else :
100
102
env = SConscript ("godot-cpp/SConstruct" ).Clone ()
101
103
@@ -135,8 +137,10 @@ opts.Update(env)
135
137
target = env ["target" ]
136
138
if env ["godot_version" ] == "3" :
137
139
result_path = os .path .join ("bin" , "gdnative" , "webrtc" if env ["target" ] == "release" else "webrtc_debug" )
140
+ elif env ["godot_version" ] == "4.0" :
141
+ result_path = os .path .join ("bin" , "extension-4.0" , "webrtc" )
138
142
else :
139
- result_path = os .path .join ("bin" , "extension" , "webrtc" )
143
+ result_path = os .path .join ("bin" , "extension-4.1 " , "webrtc" )
140
144
141
145
# Our includes and sources
142
146
env .Append (CPPPATH = ["src/" ])
@@ -148,12 +152,14 @@ sources.append(
148
152
"src/WebRTCLibPeerConnection.cpp" ,
149
153
]
150
154
)
151
- if env ["godot_version" ] == "4" :
152
- sources .append ("src/init_gdextension.cpp" )
153
- else :
155
+ if env ["godot_version" ] == "3" :
154
156
env .Append (CPPDEFINES = ["GDNATIVE_WEBRTC" ])
155
157
sources .append ("src/init_gdnative.cpp" )
156
158
add_sources (sources , "src/net/" , "cpp" )
159
+ else :
160
+ sources .append ("src/init_gdextension.cpp" )
161
+ if env ["godot_version" ] == "4.0" :
162
+ env .Append (CPPDEFINES = ["GDEXTENSION_WEBRTC_40" ])
157
163
158
164
# Add our build tools
159
165
for tool in ["openssl" , "cmake" , "rtc" ]:
@@ -187,6 +193,10 @@ if env["godot_version"] == "3":
187
193
},
188
194
)
189
195
else :
190
- extfile = env .InstallAs (os .path .join (result_path , "webrtc.gdextension" ), "misc/webrtc.gdextension" )
196
+ extfile = env .Substfile (
197
+ os .path .join (result_path , "webrtc.gdextension" ),
198
+ "misc/webrtc.gdextension" ,
199
+ SUBST_DICT = {"{GODOT_VERSION}" : env ["godot_version" ]},
200
+ )
191
201
192
202
Default (extfile )
0 commit comments