diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 36a681b8..cf78f0b7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,49 +11,56 @@ concurrency: jobs: build: + name: ${{ matrix.name }} + runs-on: ${{ matrix.runner }} strategy: fail-fast: false matrix: include: - - identifier: linux-release - name: 🐧 Linux - build_type: Release + - name: 🐧 Linux + identifier: linux-release + runner: ubuntu-20.04 + platform: linux + arch: x86_64 + precision: single + + - name: 🐧 Linux (Double Precision) + identifier: linux-double-release runner: ubuntu-20.04 - target: template_release platform: linux arch: x86_64 + precision: double - - identifier: windows-release - name: 🪟 Windows - build_type: Release + - name: 🪟 Windows + identifier: windows-release runner: windows-latest - target: template_release platform: windows arch: x86_64 + precision: single - - identifier: macos-release - name: 🍎 MacOS - build_type: Release + - name: 🍎 MacOS + identifier: macos-release runner: macos-latest - target: template_release platform: macos + precision: single - - identifier: android-arm64 - name: 🤖 Android (arm64) - build_type: Release + - name: 🤖 Android (arm64) + identifier: android-arm64 runner: ubuntu-20.04 platform: arm64-v8a arch: arm64-v8a + precision: single - - identifier: android-arm32 - name: 🤖 Android (arm32) - build_type: Release + - name: 🤖 Android (arm32) + identifier: android-arm32 runner: ubuntu-20.04 platform: armeabi-v7a arch: armeabi-v7a + precision: single - runs-on: ${{ matrix.runner }} - name: ${{ matrix.name }} + env: + SCONS_CACHE: ${{ github.workspace }}/.scons-cache/ + BUILD_NAME: official steps: @@ -86,10 +93,50 @@ jobs: with: key: ccache-${{ matrix.identifier }} + - name: Restore scons cache + if: ${{ matrix.precision == 'double' }} + uses: actions/cache/restore@v4 + with: + path: ${{ github.workspace }}/.scons-cache/ + key: ${{ matrix.identifier }}-scons-${{ github.ref }}-${{ github.sha }} + restore-keys: | + ${{ matrix.identifier }}-scons-${{ github.ref }}-${{ github.sha }} + ${{ matrix.identifier }}-scons-${{ github.ref }} + ${{ matrix.identifier }}-scons + + - name: Compile Godot (Double Precision) + if: ${{ matrix.precision == 'double' }} + shell: sh + working-directory: ./extern/godot-engine + run: | + scons precision=double + + - name: Save scons cache + if: ${{ matrix.precision == 'double' }} + uses: actions/cache/save@v4 + with: + path: ${{ github.workspace }}/.scons-cache/ + key: ${{ matrix.identifier }}-scons-${{ github.ref }}-${{ github.sha }} + + - name: Dump API + if: ${{ matrix.precision == 'double' }} + shell: sh + working-directory: ./extern/godot-engine/bin + run: | + ./godot.linuxbsd.editor.double.x86_64 --headless --dump-gdextension-interface + ./godot.linuxbsd.editor.double.x86_64 --headless --dump-extension-api + + - name: Prepare double precision + if: ${{ matrix.precision == 'double' }} + shell: sh + run: | + cp 'extern/godot-engine/bin/extension_api.json' 'extern/godot-cpp/gdextension/extension_api.json' + cp 'extern/godot-engine/bin/gdextension_interface.h' 'extern/godot-cpp/gdextension/gdextension_interface.h' + - name: Generate Build Files (${{ matrix.identifier }}) shell: sh run: | - cmake -B '${{ github.workspace }}/.out-${{ matrix.identifier }}' --preset ${{ matrix.platform }} -S '${{ github.workspace }}' + cmake -B '${{ github.workspace }}/.out-${{ matrix.identifier }}' --preset ${{ matrix.platform }} -S '${{ github.workspace }}' -DFLOAT_PRECISION=${{ matrix.precision }} - name: Build Orchestrator (${{ matrix.identifier }}) shell: sh diff --git a/CMakeLists.txt b/CMakeLists.txt index c49da96b..d82fd2d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,8 @@ SET(GDEXTENSION_LIB_PATH "${CMAKE_CURRENT_SOURCE_DIR}/project/addons/orchestrato # ADD_COMPILE_DEFINITIONS(HOT_RELOAD_ENABLED) add_compile_definitions(TOOLS_ENABLED) +set(FLOAT_PRECISION "single" CACHE STRING "") + OPTION( AUTOFORMAT_SRC_ON_CONFIGURE "If enabled, clang-format will be used to format all sources in src/ during configuration" @@ -93,6 +95,10 @@ FILE(GLOB_RECURSE gdext_sources "${CMAKE_BINARY_DIR}/_generated/*.cpp" ) +if ("${FLOAT_PRECISION}" STREQUAL "double") + add_compile_definitions(REAL_T_IS_DOUBLE) +endif() + # GDExtension library ADD_LIBRARY(${PROJECT_NAME} SHARED ${gdext_sources}) @@ -104,6 +110,7 @@ TARGET_COMPILE_OPTIONS(${PROJECT_NAME} PUBLIC $<${compiler_is_msvc}: /EHsc /utf-8 + $<$:/DREAL_T_IS_DOUBLE> /Zc:preprocessor /wd5054 # operator '|' deprecated between enumerations of different types $<$: @@ -186,7 +193,11 @@ ELSE () ENDIF () ENDIF () -STRING(TOLOWER "${PROJECT_NAME}.${CMAKE_SYSTEM_NAME}.${system_bits}.${CMAKE_BUILD_TYPE}" gde_lib_name) +if ("${FLOAT_PRECISION}" STREQUAL "double") + STRING(TOLOWER "${PROJECT_NAME}.${CMAKE_SYSTEM_NAME}.${system_bits}.double.${CMAKE_BUILD_TYPE}" gde_lib_name) +ELSE () + STRING(TOLOWER "${PROJECT_NAME}.${CMAKE_SYSTEM_NAME}.${system_bits}.${CMAKE_BUILD_TYPE}" gde_lib_name) +ENDIF () # Generate library resource IF(WIN32)