From 5dc059af80d5c4816d9620bcd894aebabe118ba8 Mon Sep 17 00:00:00 2001 From: Vivian Heyman Date: Fri, 10 May 2024 20:49:45 -0400 Subject: [PATCH] Add github extensions (from godot template) --- .github/actions/build/action.yml | 81 ++++++++++++++++++++++++++++++++ .github/workflows/builds.yml | 57 ++++++++++++++++++++++ 2 files changed, 138 insertions(+) create mode 100644 .github/actions/build/action.yml create mode 100644 .github/workflows/builds.yml diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml new file mode 100644 index 0000000..b0baf52 --- /dev/null +++ b/.github/actions/build/action.yml @@ -0,0 +1,81 @@ +name: GDExtension Build +description: Build GDExtension + +inputs: + platform: + required: true + description: Target platform. + arch: + required: true + description: Target architecture. + float-precision: + default: 'single' + description: Float precision (single or double). + build-target-type: + default: 'template_debug' + description: Build type (template_debug or template_release). + scons-cache: + default: .scons-cache/ + description: Scons cache location. + em_version: + default: 3.1.39 + description: Emscripten version. + em_cache_folder: + default: emsdk-cache + description: Emscripten cache folder. + +runs: + using: composite + steps: +# Linux only + - name: Linux - dependencies + if: ${{ inputs.platform == 'linux' }} + shell: sh + run: | + sudo apt-get update -qq + sudo apt-get install -qqq build-essential pkg-config +# Windows only + - name: Windows - Setup MinGW for Windows/MinGW build + uses: egor-tensin/setup-mingw@v2 + if: ${{ inputs.platform == 'windows' }} + with: + version: 12.2.0 +# Dependencies of godot + # Use python 3.x release (works cross platform) + - name: Set up Python 3.x + uses: actions/setup-python@v4 + with: + # Semantic version range syntax or exact version of a Python version + python-version: "3.x" + # Optional - x64 or x86 architecture, defaults to x64 + architecture: "x64" + - name: Setup scons + shell: bash + run: | + python -c "import sys; print(sys.version)" + python -m pip install scons==4.4.0 + scons --version +# Build + - name: Cache .scons_cache + uses: actions/cache@v3 + with: + path: | + ${{ github.workspace }}/${{ inputs.gdextension-location }}/${{ inputs.scons-cache }}/ + ${{ github.workspace }}/${{ inputs.godot-cpp }}/${{ inputs.scons-cache }}/ + key: ${{ inputs.platform }}_${{ inputs.arch }}_${{ inputs.float-precision }}_${{ inputs.build-target-type }}_cache +# Build godot-cpp + - name: Build godot-cpp Debug Build + shell: sh + env: + SCONS_CACHE: ${{ github.workspace }}/${{ inputs.godot-cpp }}/${{ inputs.scons-cache }}/ + run: | + scons target=${{ inputs.build-target-type }} platform=${{ inputs.platform }} arch=${{ inputs.arch }} generate_bindings=yes precision=${{ inputs.float-precision }} + working-directory: ${{ inputs.godot-cpp }} +# Build gdextension + - name: Build GDExtension Debug Build + shell: sh + env: + SCONS_CACHE: ${{ github.workspace }}/${{ inputs.gdextension-location }}/${{ inputs.scons-cache }}/ + run: | + scons target=${{ inputs.build-target-type }} platform=${{ inputs.platform }} arch=${{ inputs.arch }} precision=${{ inputs.float-precision }} production=yes + working-directory: ${{ inputs.gdextension-location }} diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml new file mode 100644 index 0000000..cd85f76 --- /dev/null +++ b/.github/workflows/builds.yml @@ -0,0 +1,57 @@ +name: Build GDExtension +on: + workflow_call: + push: + +env: + LIBNAME: example + +jobs: + build: + strategy: + fail-fast: false + matrix: + include: + - platform: linux + float-precision: double + arch: x86_64 + os: ubuntu-20.04 + - platform: windows + float-precision: double + arch: x86_64 + os: windows-latest + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: true + fetch-depth: 0 +# Lint + #- name: Setup clang-format + # shell: bash + # run: | + # python -m pip install clang-format + #- name: Run clang-format + # shell: bash + # run: | + # clang-format src/** --dry-run --Werror +# Build + - name: 🔗 GDExtension Build + uses: ./.github/actions/build + with: + platform: ${{ matrix.platform }} + arch: ${{ matrix.arch }} + float-precision: ${{ matrix.float-precision }} + build-target-type: template_release + - name: Windows - Delete compilation files + if: ${{ matrix.platform == 'windows' }} + shell: pwsh + run: | + Remove-Item bin/* -Include *.exp,*.lib,*.pdb -Force + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: godot-cpp-template + path: | + ${{ github.workspace }}/bin/**