Merge pull request #113 from Faless/spike/4.1

Support building for Godot 4.1 (new default).
This commit is contained in:
Fabio Alessandrelli
2023-07-01 19:43:42 +02:00
committed by GitHub
12 changed files with 73 additions and 25 deletions

View File

@@ -177,15 +177,23 @@ jobs:
scons --version
cmake --version
- name: Compile Extension - template_debug - ${{ matrix.platform }} - ${{ matrix.arch }}
- name: Compile Extension (4.1+) - template_debug - ${{ matrix.platform }} - ${{ matrix.arch }}
run: |
scons target=template_debug
scons target=template_debug godot_version=4.1
- name: Compile Extension - template_release - ${{ matrix.platform }} - ${{ matrix.arch }}
- name: Compile Extension (4.1+) - template_release - ${{ matrix.platform }} - ${{ matrix.arch }}
run: |
scons target=template_release
scons target=template_release godot_version=4.1
- name: Compile GDNative - release ${{ matrix.platform }} - ${{ matrix.arch }}
- name: Compile Extension (4.0) - template_debug - ${{ matrix.platform }} - ${{ matrix.arch }}
run: |
scons target=template_debug godot_version=4.0
- name: Compile Extension (4.0) - template_release - ${{ matrix.platform }} - ${{ matrix.arch }}
run: |
scons target=template_release godot_version=4.0
- name: Compile GDNative (3.5+) - release ${{ matrix.platform }} - ${{ matrix.arch }}
run: |
scons target=release generate_bindings=yes ${{ matrix.gdnative_flags }} godot_version=3
@@ -226,15 +234,21 @@ jobs:
run: |
mkdir release
VERSION="extension" TYPE="webrtc" ./misc/scripts/package_release.sh
VERSION="extension-4.1" TYPE="webrtc" ./misc/scripts/package_release.sh
VERSION="extension-4.0" TYPE="webrtc" ./misc/scripts/package_release.sh
VERSION="gdnative" TYPE="webrtc" ./misc/scripts/package_release.sh
ls -R release
- uses: actions/upload-artifact@v3
with:
name: godot-webrtc-extension
path: release/*-extension-*.zip
name: godot-webrtc-extension-4.1
path: release/*-extension-4.1-*.zip
- uses: actions/upload-artifact@v3
with:
name: godot-webrtc-extension-4.0
path: release/*-extension-4.0-*.zip
- uses: actions/upload-artifact@v3
with:

9
.gitmodules vendored
View File

@@ -1,9 +1,12 @@
[submodule "godot-cpp-3.x"]
path = godot-cpp-3.x
url = https://github.com/godotengine/godot-cpp.git
[submodule "godot-cpp"]
path = godot-cpp
url = https://github.com/godotengine/godot-cpp.git
[submodule "godot-cpp-4.0"]
path = godot-cpp-4.0
url = https://github.com/godotengine/godot-cpp.git
[submodule "godot-cpp-3.x"]
path = godot-cpp-3.x
url = https://github.com/godotengine/godot-cpp.git
[submodule "libdatachannel"]
path = thirdparty/libdatachannel
url = https://github.com/paullouisageneau/libdatachannel.git

View File

@@ -21,7 +21,7 @@ $ git submodule update --init --recursive
### Compiling the extension.
To build the GDExtension version of the plugin (Godot 4.0) run the following command from the `webrtc-native` folder:
To build the GDExtension version of the plugin (Godot 4.1+) run the following command from the `webrtc-native` folder:
```
$ scons platform=<your platform>
@@ -29,6 +29,12 @@ $ scons platform=<your platform>
This will build all the required dependencies into a single shared library.
To build the "legacy" GDExtension version of the plugin (Godot 4.0) run the following command instead:
```
$ scons platform=<your platform> godot_version=4.0
```
To build the GDNative version of the plugin (Godot 3.x) run the following command instead:
```

View File

@@ -18,7 +18,7 @@ def replace_flags(flags, replaces):
env = Environment()
opts = Variables(["customs.py"], ARGUMENTS)
opts.Add(EnumVariable("godot_version", "The Godot target version", "4", ["3", "4"]))
opts.Add(EnumVariable("godot_version", "The Godot target version", "4.1", ["3", "4.0", "4.1"]))
opts.Update(env)
# Minimum target platform versions.
@@ -96,6 +96,8 @@ if env["godot_version"] == "3":
elif not env["use_mingw"]:
# Mark as MSVC build (would have failed to build the library otherwise).
env["is_msvc"] = True
elif env["godot_version"] == "4.0":
env = SConscript("godot-cpp-4.0/SConstruct").Clone()
else:
env = SConscript("godot-cpp/SConstruct").Clone()
@@ -135,8 +137,10 @@ opts.Update(env)
target = env["target"]
if env["godot_version"] == "3":
result_path = os.path.join("bin", "gdnative", "webrtc" if env["target"] == "release" else "webrtc_debug")
elif env["godot_version"] == "4.0":
result_path = os.path.join("bin", "extension-4.0", "webrtc")
else:
result_path = os.path.join("bin", "extension", "webrtc")
result_path = os.path.join("bin", "extension-4.1", "webrtc")
# Our includes and sources
env.Append(CPPPATH=["src/"])
@@ -148,12 +152,14 @@ sources.append(
"src/WebRTCLibPeerConnection.cpp",
]
)
if env["godot_version"] == "4":
sources.append("src/init_gdextension.cpp")
else:
if env["godot_version"] == "3":
env.Append(CPPDEFINES=["GDNATIVE_WEBRTC"])
sources.append("src/init_gdnative.cpp")
add_sources(sources, "src/net/", "cpp")
else:
sources.append("src/init_gdextension.cpp")
if env["godot_version"] == "4.0":
env.Append(CPPDEFINES=["GDEXTENSION_WEBRTC_40"])
# Add our build tools
for tool in ["openssl", "cmake", "rtc"]:
@@ -187,6 +193,10 @@ if env["godot_version"] == "3":
},
)
else:
extfile = env.InstallAs(os.path.join(result_path, "webrtc.gdextension"), "misc/webrtc.gdextension")
extfile = env.Substfile(
os.path.join(result_path, "webrtc.gdextension"),
"misc/webrtc.gdextension",
SUBST_DICT={"{GODOT_VERSION}": env["godot_version"]},
)
Default(extfile)

1
godot-cpp-4.0 Submodule

Submodule godot-cpp-4.0 added at 9d1c396c54

View File

@@ -1,7 +1,7 @@
diff --git a/godot-cpp/SConstruct b/godot-cpp/SConstruct
diff --git a/godot-cpp-4.0/SConstruct b/godot-cpp-4.0/SConstruct
index 27ee137..32b425e 100644
--- a/godot-cpp/SConstruct
+++ b/godot-cpp/SConstruct
--- a/godot-cpp-4.0/SConstruct
+++ b/godot-cpp-4.0/SConstruct
@@ -54,6 +54,8 @@ else:
# Default tools with no platform defaults to gnu toolchain.
# We apply platform specific toolchains via our custom tools.

View File

@@ -10,6 +10,7 @@ TYPE=${TYPE:-"webrtc"}
mkdir -p ${DESTINATION}
ls -R ${DESTINATION}
ls -R ${ARTIFACTS}
DESTDIR="${DESTINATION}/${VERSION}/${TYPE}"
@@ -18,10 +19,10 @@ mkdir -p ${DESTDIR}/lib
find "${ARTIFACTS}" -wholename "*/${VERSION}/${TYPE}/lib/*" | xargs cp -t "${DESTDIR}/lib/"
find "${ARTIFACTS}" -wholename "*/LICENSE*" | xargs cp -t "${DESTDIR}/"
if [ $VERSION = "extension" ]; then
find "${ARTIFACTS}" -wholename "*/${VERSION}/${TYPE}/${TYPE}.gdextension" | head -n 1 | xargs cp -t "${DESTDIR}/"
else
if [ $VERSION = "gdnative" ]; then
find "${ARTIFACTS}" -wholename "*/${VERSION}/${TYPE}/${TYPE}.tres" | head -n 1 | xargs cp -t "${DESTDIR}/"
else
find "${ARTIFACTS}" -wholename "*/${VERSION}/${TYPE}/${TYPE}.gdextension" | head -n 1 | xargs cp -t "${DESTDIR}/"
fi
CURDIR=$(pwd)

View File

@@ -1,6 +1,7 @@
[configuration]
entry_symbol = "webrtc_extension_init"
compatibility_minimum = {GODOT_VERSION}
[libraries]

View File

@@ -180,7 +180,11 @@ Error WebRTCLibPeerConnection::_initialize(const Dictionary &p_config) {
return _create_pc(config);
}
#if defined(GDNATIVE_WEBRTC) || defined(GDEXTENSION_WEBRTC_40)
Object *WebRTCLibPeerConnection::_create_data_channel(const String &p_channel, const Dictionary &p_channel_config) try {
#else
Ref<WebRTCDataChannel> WebRTCLibPeerConnection::_create_data_channel(const String &p_channel, const Dictionary &p_channel_config) try {
#endif
ERR_FAIL_COND_V(!peer_connection, nullptr);
// Read config from dictionary

View File

@@ -79,7 +79,11 @@ public:
SignalingState _get_signaling_state() const override;
godot::Error _initialize(const godot::Dictionary &p_config) override;
#if defined(GDNATIVE_WEBRTC) || defined(GDEXTENSION_WEBRTC_40)
godot::Object *_create_data_channel(const godot::String &p_channel, const godot::Dictionary &p_channel_config) override;
#else
godot::Ref<godot::WebRTCDataChannel> _create_data_channel(const godot::String &p_channel, const godot::Dictionary &p_channel_config) override;
#endif
godot::Error _create_offer() override;
godot::Error _set_remote_description(const godot::String &type, const godot::String &sdp) override;
godot::Error _set_local_description(const godot::String &type, const godot::String &sdp) override;

View File

@@ -66,7 +66,11 @@ void unregister_webrtc_extension_types(ModuleInitializationLevel p_level) {
}
extern "C" {
#ifdef GDEXTENSION_WEBRTC_40
GDExtensionBool GDE_EXPORT webrtc_extension_init(const GDExtensionInterface *p_interface, const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) {
#else
GDExtensionBool GDE_EXPORT webrtc_extension_init(const GDExtensionInterfaceGetProcAddress p_interface, const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) {
#endif
GDExtensionBinding::InitObject init_obj(p_interface, p_library, r_initialization);
init_obj.register_initializer(register_webrtc_extension_types);