From 9b0a5d8b4677e6e10d7fb7f96ba469738add47e9 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Sun, 9 Oct 2022 20:07:36 +0200 Subject: [CI] Update actions, add cache for faster builds. --- .github/workflows/build_release.yml | 30 +++++++++++++++++++++++++----- SConstruct | 5 +++++ 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml index 202807e..73e604e 100644 --- a/.github/workflows/build_release.yml +++ b/.github/workflows/build_release.yml @@ -1,13 +1,17 @@ name: 🔧 Build -> Package 📦 on: [push, pull_request] +env: + # Only used for the cache key. Increment version to force clean build. + GODOT_BASE_BRANCH: master + jobs: static-checks: name: 📊 Static Checks (clang-format, black format, file format) runs-on: ubuntu-20.04 steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install dependencies run: | @@ -42,11 +46,13 @@ jobs: gdnative_flags: 'android_arch=x86_64' sconsflags: '' os: 'ubuntu-20.04' + cache-name: android-x86_64 - platform: android arch: 'arm64' gdnative_flags: 'android_arch=arm64v8' sconsflags: '' os: 'ubuntu-20.04' + cache-name: android-arm64 # iOS - platform: ios @@ -54,12 +60,13 @@ jobs: gdnative_flags: 'ios_arch=x86_64' sconsflags: 'ios_simulator=true' os: 'macos-latest' + cache-name: ios-x86_64-simulator - platform: ios arch: 'arm64' gdnative_flags: 'ios_arch=arm64' sconsflags: '' os: 'macos-11' - + cache-name: ios-arm64 # Linux - platform: linux @@ -67,11 +74,13 @@ jobs: gdnative_flags: 'bits=32' sconsflags: '' os: 'ubuntu-20.04' + cache-name: linux-x86_32 - platform: linux arch: 'x86_64' gdnative_flags: 'bits=64' sconsflags: '' os: 'ubuntu-20.04' + cache-name: linux-x86_64 # macOS - platform: macos @@ -79,11 +88,13 @@ jobs: gdnative_flags: 'macos_arch=x86_64 bits=64' sconsflags: '' os: 'macos-11' + cache-name: macos-x86_64 - platform: macos gdnative_flags: 'macos_arch=arm64 bits=64' arch: 'arm64' sconsflags: '' os: 'macos-11' + cache-name: macos-arm64 # Windows - platform: windows @@ -92,14 +103,17 @@ jobs: sconsflags: 'use_mingw=yes' os: 'ubuntu-20.04' msvc_arch: amd64_x86 + cache-name: win-x86_32 - platform: windows arch: 'x86_64' gdnative_flags: 'bits=64' sconsflags: 'use_mingw=yes' os: 'ubuntu-20.04' msvc_arch: amd64 + cache-name: win-x86_64 env: + SCONS_CACHE: ${{ github.workspace }}/.scons-cache/ SCONSFLAGS: ${{ matrix.sconsflags }} platform=${{ matrix.platform }} arch=${{ matrix.arch }} --jobs=2 defaults: @@ -107,10 +121,16 @@ jobs: shell: bash steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive + - name: Setup Godot build cache + uses: ./godot-cpp/.github/actions/godot-cache + with: + cache-name: ${{ matrix.cache-name }} + continue-on-error: true + - name: Install Windows build dependencies if: ${{ matrix.platform == 'windows' }} run: | @@ -129,7 +149,7 @@ jobs: sudo apt-get install build-essential gcc-multilib g++-multilib - name: Set up Python 3.x - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: '3.x' architecture: 'x64' @@ -168,7 +188,7 @@ jobs: needs: build runs-on: "ubuntu-latest" steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive diff --git a/SConstruct b/SConstruct index 66c6177..c10c492 100644 --- a/SConstruct +++ b/SConstruct @@ -28,6 +28,11 @@ if env["godot_version"] == "3": env = SConscript("godot-cpp-3.x/SConstruct") + scons_cache_path = os.environ.get("SCONS_CACHE") + if scons_cache_path is not None: + CacheDir(scons_cache_path) + Decider("MD5") + # Patch base env replace_flags(env["CCFLAGS"], { "-mios-simulator-version-min=10.0": "-mios-simulator-version-min=11.0", -- cgit v1.2.3 From 690b31e7dd8d4583c50c1f5c60fde3c6888ff7bf Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Mon, 17 Oct 2022 00:51:32 +0200 Subject: [Upstream] Update to Godot beta 3. Update build targets. Move release script out of CI yaml. Disable debug CI builds for Godot 3.x since they are mostly used for debugging the extension itself. --- .github/workflows/build_release.yml | 43 +++++++++++-------------------------- SConstruct | 36 ++++++++++++++++++++----------- builders.py | 6 +++--- godot-cpp | 2 +- misc/scripts/package_release.sh | 32 +++++++++++++++++++++++++++ misc/webrtc.gdextension | 31 +++++++++++++++++--------- src/WebRTCLibDataChannel.hpp | 2 ++ src/WebRTCLibPeerConnection.hpp | 2 ++ 8 files changed, 97 insertions(+), 57 deletions(-) create mode 100755 misc/scripts/package_release.sh diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml index 73e604e..ab7ee01 100644 --- a/.github/workflows/build_release.yml +++ b/.github/workflows/build_release.yml @@ -59,7 +59,7 @@ jobs: arch: 'x86_64' gdnative_flags: 'ios_arch=x86_64' sconsflags: 'ios_simulator=true' - os: 'macos-latest' + os: 'macos-11' cache-name: ios-x86_64-simulator - platform: ios arch: 'arm64' @@ -162,21 +162,17 @@ jobs: scons --version cmake --version - - name: Compile Extension - debug - ${{ matrix.platform }} - ${{ matrix.arch }} - run: | - scons target=debug generate_bindings=yes - - - name: Compile GDNative - debug - ${{ matrix.platform }} - ${{ matrix.arch }} + - name: Compile Extension - template_debug - ${{ matrix.platform }} - ${{ matrix.arch }} run: | - scons target=debug generate_bindings=yes ${{ matrix.gdnative_flags }} godot_version=3 + scons target=template_debug generate_bindings=yes - - name: Compile Extension - release - ${{ matrix.platform }} - ${{ matrix.arch }} + - name: Compile Extension - template_release - ${{ matrix.platform }} - ${{ matrix.arch }} run: | - scons target=release + scons target=template_release - name: Compile GDNative - release ${{ matrix.platform }} - ${{ matrix.arch }} run: | - scons target=release ${{ matrix.gdnative_flags }} godot_version=3 + scons target=release generate_bindings=yes ${{ matrix.gdnative_flags }} godot_version=3 - uses: actions/upload-artifact@v3 with: @@ -208,28 +204,15 @@ jobs: cp deps/libdatachannel/deps/plog/LICENSE artifacts/LICENSE.plog - name: Package artifacts for release + env: + DESTINATION: "release" run: | mkdir release - cd release - - ls -R - - for version in extension gdnative - do - for name in webrtc webrtc_debug - do - destdir="${version}/${name}" - mkdir -p ${destdir}/lib - find ../artifacts -wholename "*/${destdir}/lib/*" | xargs cp -t ${destdir}/lib/ - find ../artifacts -wholename "*/${destdir}/${name}.tres" -or -wholename "*/${destdir}/${name}.gdextension" | head -n 1 | xargs cp -t ${destdir}/ - find ../artifacts -wholename "*/LICENSE*" | xargs cp -t ${destdir}/ - cd ${version} - zip -r ../godot-${version}-${name}.zip ${name} - cd .. - done - done - - ls -R + + VERSION="extension" 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: diff --git a/SConstruct b/SConstruct index c10c492..f041ce5 100644 --- a/SConstruct +++ b/SConstruct @@ -26,13 +26,13 @@ if env["godot_version"] == "3": if "platform" in ARGUMENTS and ARGUMENTS["platform"] == "macos": ARGUMENTS["platform"] = "osx" # compatibility with old osx name - env = SConscript("godot-cpp-3.x/SConstruct") - scons_cache_path = os.environ.get("SCONS_CACHE") if scons_cache_path is not None: CacheDir(scons_cache_path) Decider("MD5") + env = SConscript("godot-cpp-3.x/SConstruct") + # Patch base env replace_flags(env["CCFLAGS"], { "-mios-simulator-version-min=10.0": "-mios-simulator-version-min=11.0", @@ -57,7 +57,7 @@ if env["godot_version"] == "3": if env["platform"] in ["windows", "linux"]: env["arch"] = "x86_32" if env["bits"] == "32" else "x86_64" env["arch_suffix"] = env["arch"] - elif env["platform"] == "osx": + elif env["platform"] == "macos": env["arch"] = env["macos_arch"] env["arch_suffix"] = env["arch"] elif env["platform"] == "ios": @@ -71,6 +71,10 @@ if env["godot_version"] == "3": "x86_64": "x86_64", }[env["android_arch"]] env["arch_suffix"] = env["arch"] + + target_compat = "template_" + env["target"] + env["suffix"] = ".{}.{}.{}".format(env["platform"], target_compat, env["arch_suffix"]) + env["debug_symbols"] = False else: ARGUMENTS["ios_min_version"] = "11.0" env = SConscript("godot-cpp/SConstruct").Clone() @@ -82,7 +86,10 @@ if env["platform"] == "windows" and env["use_mingw"]: opts.Update(env) target = env["target"] -result_path = os.path.join("bin", "gdnative" if env["godot_version"] == "3" else "extension", "webrtc" if env["target"] == "release" else "webrtc_debug") +if env["godot_version"] == "3": + result_path = os.path.join("bin", "gdnative", "webrtc" if env["target"] == "release" else "webrtc_debug") +else: + result_path = os.path.join("bin", "extension", "webrtc") # Dependencies deps_source_dir = "deps" @@ -93,6 +100,7 @@ env.Append(BUILDERS={ # SSL ssl = env.BuildOpenSSL(env.Dir(builders.get_ssl_build_dir(env)), env.Dir(builders.get_ssl_source_dir(env))) +env.Depends(ssl, env.File("builders.py")) env.Prepend(CPPPATH=[builders.get_ssl_include_dir(env)]) env.Prepend(LIBPATH=[builders.get_ssl_build_dir(env)]) @@ -100,6 +108,7 @@ env.Append(LIBS=[ssl]) # RTC rtc = env.BuildLibDataChannel(env.Dir(builders.get_rtc_build_dir(env)), [env.Dir(builders.get_rtc_source_dir(env))] + ssl) +env.Depends(rtc, env.File("builders.py")) env.Append(LIBPATH=[builders.get_rtc_build_dir(env)]) env.Append(CPPPATH=[builders.get_rtc_include_dir(env)]) @@ -124,7 +133,7 @@ else: env.Depends(sources, [ssl, rtc]) # Make the shared library -result_name = "webrtc_native.{}.{}.{}{}".format(env["platform"], env["target"], env["arch_suffix"], env["SHLIBSUFFIX"]) +result_name = "webrtc_native{}{}".format(env["suffix"], env["SHLIBSUFFIX"]) env.Depends(sources, ssl) if env["platform"] == "windows" and env["use_mingw"]: @@ -134,12 +143,13 @@ library = env.SharedLibrary(target=os.path.join(result_path, "lib", result_name) Default(library) # GDNativeLibrary -gdnlib = "webrtc" -if target != "release": - gdnlib += "_debug" -ext = ".tres" if env["godot_version"] == "3" else ".gdextension" -extfile = env.Substfile(os.path.join(result_path, gdnlib + ext), "misc/webrtc" + ext, SUBST_DICT={ - "{GDNATIVE_PATH}": gdnlib, - "{TARGET}": env["target"], -}) +if env["godot_version"] == "3": + gdnlib = "webrtc" if target != "debug" else "webrtc_debug" + ext = ".tres" + extfile = env.Substfile(os.path.join(result_path, gdnlib + ext), "misc/webrtc" + ext, SUBST_DICT={ + "{GDNATIVE_PATH}": gdnlib, + "{TARGET}": "template_" + env["target"], + }) +else: + extfile = env.InstallAs(os.path.join(result_path, "webrtc.gdextension"), "misc/webrtc.gdextension") Default(extfile) diff --git a/builders.py b/builders.py index 8f85cd3..284ac1e 100644 --- a/builders.py +++ b/builders.py @@ -11,7 +11,7 @@ def get_deps_dir(env): def get_deps_build_dir(env): - return get_deps_dir(env) + "/build/{}.{}.{}.dir".format(env["platform"], env["target"], env["arch_suffix"]) + return get_deps_dir(env) + "/build/build{}.{}.dir".format(env["suffix"], "RelWithDebInfo" if env["debug_symbols"] else "Release") def get_rtc_source_dir(env): @@ -63,7 +63,7 @@ def ssl_action(target, source, env): "--prefix=%s" % install_dir, "--openssldir=%s" % install_dir, ] - if env["target"] == "debug": + if env["debug_symbols"]: args.append("-d") if env["platform"] != "windows": @@ -163,7 +163,7 @@ def rtc_action(target, source, env): "-DOPENSSL_INCLUDE_DIR=%s" % get_ssl_include_dir(env), "-DOPENSSL_SSL_LIBRARY=%s/libssl.a" % get_ssl_build_dir(env), "-DOPENSSL_CRYPTO_LIBRARY=%s/libcrypto.a" % get_ssl_build_dir(env), - "-DCMAKE_BUILD_TYPE=%s" % ("Release" if env["target"] == "release" else "Debug"), + "-DCMAKE_BUILD_TYPE=%s" % ("RelWithDebInfo" if env["debug_symbols"] else "Release"), ] if env["platform"] == "android": abi = { diff --git a/godot-cpp b/godot-cpp index fa4d18f..1044251 160000 --- a/godot-cpp +++ b/godot-cpp @@ -1 +1 @@ -Subproject commit fa4d18f21cfae319b8f16a1604742cfec6022079 +Subproject commit 1044251a9e85e4c5cb484466c50f6cc309a1bfbe diff --git a/misc/scripts/package_release.sh b/misc/scripts/package_release.sh new file mode 100755 index 0000000..a08f441 --- /dev/null +++ b/misc/scripts/package_release.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +set -e +set -x + +ARTIFACTS=${ARTIFACTS:-"artifacts"} +DESTINATION=${DESTIONATION:-"release"} +VERSION=${VERSION:-"extension"} +TYPE=${TYPE:-"webrtc"} + +mkdir -p ${DESTINATION} +ls -R ${DESTINATION} + +DESTDIR="${DESTINATION}/${VERSION}/${TYPE}" + +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 + find "${ARTIFACTS}" -wholename "*/${VERSION}/${TYPE}/${TYPE}.tres" | head -n 1 | xargs cp -t "${DESTDIR}/" +fi + +CURDIR=$(pwd) +cd "${DESTINATION}/${VERSION}" +zip -r ../godot-${VERSION}-${TYPE}.zip ${TYPE} +cd "$CURDIR" + +ls -R ${DESTINATION} diff --git a/misc/webrtc.gdextension b/misc/webrtc.gdextension index d8db63f..886cf86 100644 --- a/misc/webrtc.gdextension +++ b/misc/webrtc.gdextension @@ -4,13 +4,24 @@ entry_symbol = "webrtc_extension_init" [libraries] -linux.x86_64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.x86_64.so" -linux.x86_32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.x86_32.so" -osx.x86_64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.osx.{TARGET}.x86_64.dylib" -osx.arm64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.osx.{TARGET}.arm64.dylib" -windows.x86_64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.windows.{TARGET}.x86_64.dll" -windows.x86_32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.windows.{TARGET}.x86_32.dll" -android.arm64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.arm64.so" -android.x86_64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.x86_64.so" -ios.arm64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.ios.{TARGET}.arm64.dylib" -ios.x86_64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.ios.{TARGET}.x86_64.simulator.dylib" +linux.debug.x86_64 = "res://webrtc/lib/libwebrtc_native.linux.template_debug.x86_64.so" +linux.debug.x86_32 = "res://webrtc/lib/libwebrtc_native.linux.template_debug.x86_32.so" +osx.debug.x86_64 = "res://webrtc/lib/libwebrtc_native.osx.template_debug.x86_64.dylib" +osx.debug.arm64 = "res://webrtc/lib/libwebrtc_native.osx.template_debug.arm64.dylib" +windows.debug.x86_64 = "res://webrtc/lib/libwebrtc_native.windows.template_debug.x86_64.dll" +windows.debug.x86_32 = "res://webrtc/lib/libwebrtc_native.windows.template_debug.x86_32.dll" +android.debug.arm64 = "res://webrtc/lib/libwebrtc_native.android.template_debug.arm64.so" +android.debug.x86_64 = "res://webrtc/lib/libwebrtc_native.android.template_debug.x86_64.so" +ios.debug.arm64 = "res://webrtc/lib/libwebrtc_native.ios.template_debug.arm64.dylib" +ios.debug.x86_64 = "res://webrtc/lib/libwebrtc_native.ios.template_debug.x86_64.simulator.dylib" + +linux.release.x86_64 = "res://webrtc/lib/libwebrtc_native.linux.template_release.x86_64.so" +linux.release.x86_32 = "res://webrtc/lib/libwebrtc_native.linux.template_release.x86_32.so" +osx.release.x86_64 = "res://webrtc/lib/libwebrtc_native.osx.template_release.x86_64.dylib" +osx.release.arm64 = "res://webrtc/lib/libwebrtc_native.osx.template_release.arm64.dylib" +windows.release.x86_64 = "res://webrtc/lib/libwebrtc_native.windows.template_release.x86_64.dll" +windows.release.x86_32 = "res://webrtc/lib/libwebrtc_native.windows.template_release.x86_32.dll" +android.release.arm64 = "res://webrtc/lib/libwebrtc_native.android.template_release.arm64.so" +android.release.x86_64 = "res://webrtc/lib/libwebrtc_native.android.template_release.x86_64.so" +ios.release.arm64 = "res://webrtc/lib/libwebrtc_native.ios.template_release.arm64.dylib" +ios.release.x86_64 = "res://webrtc/lib/libwebrtc_native.ios.template_release.x86_64.simulator.dylib" diff --git a/src/WebRTCLibDataChannel.hpp b/src/WebRTCLibDataChannel.hpp index 758e018..2525002 100644 --- a/src/WebRTCLibDataChannel.hpp +++ b/src/WebRTCLibDataChannel.hpp @@ -40,6 +40,8 @@ #define GDCLASS(arg1, arg2) GODOT_CLASS(arg1, arg2) #endif #else +#include + #include #include #endif diff --git a/src/WebRTCLibPeerConnection.hpp b/src/WebRTCLibPeerConnection.hpp index 5709996..703a59c 100644 --- a/src/WebRTCLibPeerConnection.hpp +++ b/src/WebRTCLibPeerConnection.hpp @@ -40,6 +40,8 @@ #define GDCLASS(arg1, arg2) GODOT_CLASS(arg1, arg2) #endif #else +#include + #include #include #endif -- cgit v1.2.3