diff options
-rw-r--r-- | .github/workflows/build_release.yml | 54 | ||||
-rw-r--r-- | SConstruct | 18 | ||||
-rw-r--r-- | misc/patches/gdnantive_arm_warnings.diff | 34 | ||||
-rwxr-xr-x | misc/scripts/file_format.sh | 2 | ||||
-rw-r--r-- | misc/webrtc.tres | 12 | ||||
-rw-r--r-- | tools/cmake.py | 2 |
6 files changed, 98 insertions, 24 deletions
diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml index 43538b1..01589aa 100644 --- a/.github/workflows/build_release.yml +++ b/.github/workflows/build_release.yml @@ -76,18 +76,32 @@ jobs: # Linux - platform: linux arch: 'x86_32' - buildroot: 'i686' + buildroot: 'i686-godot-linux-gnu_sdk-buildroot' gdnative_flags: 'bits=32' sconsflags: '' os: 'ubuntu-20.04' cache-name: linux-x86_32 - platform: linux arch: 'x86_64' - buildroot: 'x86_64' + buildroot: 'x86_64-godot-linux-gnu_sdk-buildroot' gdnative_flags: 'bits=64' sconsflags: '' os: 'ubuntu-20.04' cache-name: linux-x86_64 + - platform: linux + arch: 'arm32' + buildroot: 'arm-godot-linux-gnueabihf_sdk-buildroot' + gdnative_flags: 'bits=32' + sconsflags: '' + os: 'ubuntu-20.04' + cache-name: linux-arm32 + - platform: linux + arch: 'arm64' + buildroot: 'aarch64-godot-linux-gnu_sdk-buildroot' + gdnative_flags: 'bits=64' + sconsflags: '' + os: 'ubuntu-20.04' + cache-name: linux-arm64 # macOS - platform: macos @@ -144,26 +158,20 @@ jobs: dpkg -l | grep ii | grep mingw update-alternatives --get-selections | grep mingw + - name: Install Linux build dependencies + if: ${{ matrix.platform == 'linux' }} + run: | + sudo apt-get update + sudo apt-get install build-essential gcc-multilib g++-multilib wget + - name: Setup Linux buildroot toolchain cache if: ${{ matrix.platform == 'linux' }} uses: actions/cache@v4 with: path: | - ${{ matrix.buildroot }}-godot-linux-gnu_sdk-buildroot.tar.bz2 + ${{ matrix.buildroot }}.tar.bz2 key: linux-${{ matrix.buildroot }}-buildroot - - name: Install Linux build dependencies - if: ${{ matrix.platform == 'linux' }} - run: | - sudo apt-get update - sudo apt-get install build-essential gcc-multilib g++-multilib wget - if [ ! -f ${{ matrix.buildroot }}-godot-linux-gnu_sdk-buildroot.tar.bz2 ]; then - wget https://downloads.tuxfamily.org/godotengine/toolchains/linux/${{ matrix.buildroot }}-godot-linux-gnu_sdk-buildroot.tar.bz2 - fi - tar -xjf ${{ matrix.buildroot }}-godot-linux-gnu_sdk-buildroot.tar.bz2 - echo "$GITHUB_WORKSPACE/${{ matrix.buildroot }}-godot-linux-gnu_sdk-buildroot/bin" >> $GITHUB_PATH - patch -p1 < misc/patches/scons_path.diff - - name: Set up Python 3.x uses: actions/setup-python@v5 with: @@ -174,6 +182,22 @@ jobs: run: | python -c "import sys; print(sys.version)" python -m pip install scons + + - name: Setup Linux toolchains + if: ${{ matrix.platform == 'linux' }} + run: | + if [ ! -f ${{ matrix.buildroot }}.tar.bz2 ]; then + wget https://downloads.tuxfamily.org/godotengine/toolchains/linux/${{ matrix.buildroot }}.tar.bz2 + fi + tar -xjf ${{ matrix.buildroot }}.tar.bz2 + ${{ matrix.buildroot }}/relocate-sdk.sh + echo "$GITHUB_WORKSPACE/${{ matrix.buildroot }}/bin" >> $GITHUB_PATH + echo "PKG_CONFIG=$GITHUB_WORKSPACE/${{ matrix.buildroot }}/share/pkgconfig/" >> $GITHUB_ENV + patch -p1 < misc/patches/scons_path.diff + patch -p1 < misc/patches/gdnantive_arm_warnings.diff + + - name: Print tools versions + run: | python --version scons --version cmake --version @@ -12,7 +12,11 @@ def add_sources(sources, dirpath, extension): def replace_flags(flags, replaces): for k, v in replaces.items(): - if k in flags: + if k not in flags: + continue + if v is None: + flags.remove(k) + else: flags[flags.index(k)] = v @@ -33,11 +37,11 @@ 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") + cpp_env = SConscript("godot-cpp-3.x/SConstruct") # Patch base env replace_flags( - env["CCFLAGS"], + cpp_env["CCFLAGS"], { "-mios-simulator-version-min=10.0": "-mios-simulator-version-min=11.0", "-miphoneos-version-min=10.0": "-miphoneos-version-min=11.0", @@ -46,7 +50,7 @@ if env["godot_version"] == "3": }, ) - env = env.Clone() + env = cpp_env.Clone() if env["target"] == "debug": env.Append(CPPDEFINES=["DEBUG_ENABLED"]) @@ -64,7 +68,7 @@ if env["godot_version"] == "3": # Normalize suffix if env["platform"] in ["windows", "linux"]: - env["arch"] = "x86_32" if env["bits"] == "32" else "x86_64" + env["arch"] = ARGUMENTS.get("arch", "x86_32" if env["bits"] == "32" else "x86_64") env["arch_suffix"] = env["arch"] elif env["platform"] == "macos": env["arch"] = env["macos_arch"] @@ -96,6 +100,10 @@ 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 + # Some linux specific hacks to allow cross-compiling for non-x86 machines. + if env["platform"] == "linux" and env["arch"] not in ("x86_32", "x86_64"): + for flags in (env["CCFLAGS"], env["LINKFLAGS"], cpp_env["CCFLAGS"], cpp_env["LINKFLAGS"]): + replace_flags(flags, {"-m32": None, "-m64": None}) elif env["godot_version"] == "4.0": env = SConscript("godot-cpp-4.0/SConstruct").Clone() else: diff --git a/misc/patches/gdnantive_arm_warnings.diff b/misc/patches/gdnantive_arm_warnings.diff new file mode 100644 index 0000000..4f1f085 --- /dev/null +++ b/misc/patches/gdnantive_arm_warnings.diff @@ -0,0 +1,34 @@ +diff --git a/godot-cpp-3.x/godot-headers/gdnative/gdnative.h b/godot-cpp-3.x/godot-headers/gdnative/gdnative.h +index c0573d21b5d7a..ec95c4c4ebfcc 100644 +--- a/godot-cpp-3.x/godot-headers/gdnative/gdnative.h ++++ b/godot-cpp-3.x/godot-headers/gdnative/gdnative.h +@@ -37,20 +37,24 @@ extern "C" { + + #if defined(_WIN32) || defined(__ANDROID__) + #define GDCALLINGCONV +-#define GDAPI GDCALLINGCONV ++ + #elif defined(__APPLE__) + #include "TargetConditionals.h" + #if TARGET_OS_IPHONE + #define GDCALLINGCONV __attribute__((visibility("default"))) +-#define GDAPI GDCALLINGCONV + #elif TARGET_OS_MAC + #define GDCALLINGCONV __attribute__((sysv_abi)) +-#define GDAPI GDCALLINGCONV + #endif +-#else // !_WIN32 && !__APPLE__ ++ ++#else // Linux/BSD/Web ++#if defined(__aarch64__) || defined(__arm__) ++#define GDCALLINGCONV ++#else + #define GDCALLINGCONV __attribute__((sysv_abi)) +-#define GDAPI GDCALLINGCONV + #endif ++#endif ++ ++#define GDAPI GDCALLINGCONV + + // This is for libraries *using* the header, NOT GODOT EXPOSING STUFF!! + #if !defined(GDN_EXPORT) diff --git a/misc/scripts/file_format.sh b/misc/scripts/file_format.sh index 94a3aff..f89e534 100755 --- a/misc/scripts/file_format.sh +++ b/misc/scripts/file_format.sh @@ -39,6 +39,8 @@ for f in "${files[@]}"; do continue elif [[ "$f" == "thirdparty/"* ]]; then continue + elif [[ "$f" == "misc/patches/"* ]]; then + continue elif [[ "$f" == *"/thirdparty/"* ]]; then continue elif [[ "$f" == "platform/android/java/lib/src/com/google"* ]]; then diff --git a/misc/webrtc.tres b/misc/webrtc.tres index bdcb80f..2b682ae 100644 --- a/misc/webrtc.tres +++ b/misc/webrtc.tres @@ -6,10 +6,14 @@ reloadable = false entry/OSX.64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.macos.{TARGET}.universal.dylib" entry/Windows.64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.windows.{TARGET}.x86_64.dll" entry/Windows.32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.windows.{TARGET}.x86_32.dll" -entry/X11.64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.x86_64.so" -entry/X11.32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.x86_32.so" -entry/Server.64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.x86_64.so" -entry/Server.32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.x86_32.so" +entry/X11.64.x86_64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.x86_64.so" +entry/X11.32.x86_32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.x86_32.so" +entry/X11.64.arm64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.arm64.so" +entry/X11.32.arm32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.arm32.so" +entry/Server.64.x86_64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.x86_64.so" +entry/Server.32.x86_32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.x86_32.so" +entry/Server.64.arm64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.arm64.so" +entry/Server.32.arm32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.arm32.so" entry/Android.arm64-v8a = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.arm64.so" entry/Android.x64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.x86_64.so" entry/iOS.armv7 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.ios.{TARGET}.armv32.dylib" diff --git a/tools/cmake.py b/tools/cmake.py index 39957d8..2911011 100644 --- a/tools/cmake.py +++ b/tools/cmake.py @@ -37,6 +37,8 @@ def cmake_default_flags(env): linux_flags = { "x86_64": "-m64", "x86_32": "-m32", + "arm32": "-march=armv7-a", + "arm64": "-march=armv8-a", }.get(env["arch"], "") if linux_flags: config["CMAKE_C_FLAGS"] = linux_flags |