Skip to content

Commit

Permalink
TEST
Browse files Browse the repository at this point in the history
  • Loading branch information
WhalesState committed Feb 2, 2025
1 parent 56571dc commit ee1c38e
Show file tree
Hide file tree
Showing 25 changed files with 1,074 additions and 533 deletions.
17 changes: 9 additions & 8 deletions .github/actions/godot-cache-restore/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ inputs:
description: The cache base name (job name by default).
default: "${{github.job}}"
scons-cache:
description: The scons cache path.
description: The SCons cache path.
default: "${{github.workspace}}/.scons-cache/"
runs:
using: "composite"
using: composite
steps:
- name: Restore .scons_cache directory
uses: actions/cache/restore@v3
- name: Restore SCons cache directory
uses: actions/cache/restore@v4
with:
path: ${{inputs.scons-cache}}
key: ${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}
key: ${{inputs.cache-name}}-${{env.BLAZIUM_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}
restore-keys: |
${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}
${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}
${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}
${{inputs.cache-name}}-${{env.BLAZIUM_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}
${{inputs.cache-name}}-${{env.BLAZIUM_BASE_BRANCH}}-${{github.ref}}
${{inputs.cache-name}}-${{env.BLAZIUM_BASE_BRANCH}}-refs/heads/${{env.BLAZIUM_BASE_BRANCH}}
${{inputs.cache-name}}-${{env.BLAZIUM_BASE_BRANCH}}
4 changes: 2 additions & 2 deletions .github/actions/godot-cache-save/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ inputs:
description: The SCons cache path.
default: "${{github.workspace}}/.scons-cache/"
runs:
using: "composite"
using: composite
steps:
- name: Save SCons cache directory
uses: actions/cache/save@v4
with:
path: ${{inputs.scons-cache}}
key: ${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}
key: ${{inputs.cache-name}}-${{env.BLAZIUM_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}
88 changes: 30 additions & 58 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ on: [push, pull_request]

env:
# Only used for the cache key. Increment version to force clean build.
GODOT_BASE_BRANCH: master
BLAZIUM_BASE_BRANCH: blazium-dev
# Used to select the version of Godot to run the tests with.
GODOT_TEST_VERSION: master
BLAZIUM_TEST_VERSION: 0.1.184
# Use UTF-8 on Linux.
LANG: en_US.UTF-8
LC_ALL: en_US.UTF-8

concurrency:
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}
Expand Down Expand Up @@ -91,7 +94,6 @@ jobs:
env:
SCONS_CACHE: ${{ github.workspace }}/.scons-cache/
EM_VERSION: 3.1.39
EM_CACHE_FOLDER: "emsdk-cache"

steps:
- name: Checkout
Expand All @@ -108,10 +110,10 @@ jobs:
- name: Set up Python (for SCons)
uses: actions/setup-python@v5
with:
python-version: '3.x'
python-version: 3.x

- name: Android dependencies
if: ${{ matrix.platform == 'android' }}
if: matrix.platform == 'android'
uses: nttld/setup-ndk@v1
with:
ndk-version: r23c
Expand All @@ -122,7 +124,7 @@ jobs:
uses: mymindstorm/setup-emsdk@v14
with:
version: ${{env.EM_VERSION}}
actions-cache-folder: ${{env.EM_CACHE_FOLDER}}
no-cache: true

- name: Setup MinGW for Windows/MinGW build
if: ${{ matrix.platform == 'windows' && matrix.flags == 'use_mingw=yes' }}
Expand Down Expand Up @@ -161,10 +163,10 @@ jobs:

- name: Download latest Godot artifacts
uses: dsnopek/action-download-artifact@1322f74e2dac9feed2ee76a32d9ae1ca3b4cf4e9
if: ${{ matrix.run-tests && env.GODOT_TEST_VERSION == 'master' }}
if: matrix.run-tests && env.BLAZIUM_TEST_VERSION == 'blazium-dev'
with:
repo: godotengine/godot
branch: master
repo: blazium-engine/blazium
branch: blazium-dev
event: push
workflow: linux_builds.yml
workflow_conclusion: success
Expand All @@ -175,59 +177,35 @@ jobs:
path: godot-artifacts

- name: Prepare Godot artifacts for testing
if: ${{ matrix.run-tests && env.GODOT_TEST_VERSION == 'master' }}
if: matrix.run-tests && env.BLAZIUM_TEST_VERSION == 'blazium-dev'
run: |
chmod +x ./godot-artifacts/godot.linuxbsd.editor.x86_64.mono
echo "GODOT=$(pwd)/godot-artifacts/godot.linuxbsd.editor.x86_64.mono" >> $GITHUB_ENV
echo "BLAZIUM=$(pwd)/godot-artifacts/godot.linuxbsd.editor.x86_64.mono" >> $GITHUB_ENV
- name: Download requested Godot version for testing
if: ${{ matrix.run-tests && env.GODOT_TEST_VERSION != 'master' }}
if: matrix.run-tests && env.BLAZIUM_TEST_VERSION != 'blazium-dev'
run: |
wget "https://github.com/godotengine/godot-builds/releases/download/${GODOT_TEST_VERSION}/Godot_v${GODOT_TEST_VERSION}_linux.x86_64.zip" -O Godot.zip
unzip -a Godot.zip
chmod +x "Godot_v${GODOT_TEST_VERSION}_linux.x86_64"
echo "GODOT=$(pwd)/Godot_v${GODOT_TEST_VERSION}_linux.x86_64" >> $GITHUB_ENV
wget "https://cdn.blazium.app/nightly/${BLAZIUM_TEST_VERSION}/BlaziumEditor_v${BLAZIUM_TEST_VERSION}_linux.x86_64.zip" -O Blazium.zip
unzip -a Blazium.zip
chmod +x "BlaziumEditor_v${BLAZIUM_TEST_VERSION}_linux.x86_64"
echo "BLAZIUM=$(pwd)/BlaziumEditor_v${BLAZIUM_TEST_VERSION}_linux.x86_64" >> $GITHUB_ENV
- name: Run tests
if: ${{ matrix.run-tests }}
if: matrix.run-tests
run: |
$GODOT --headless --version
$BLAZIUM --headless --version
cd test
# Need to run the editor so .godot is generated... but it crashes! Ignore that :-)
(cd project && (timeout 30 $GODOT --import --headless >/dev/null 2>&1 || true))
(cd project && (timeout 30 $BLAZIUM --import --headless >/dev/null 2>&1 || true))
./run-tests.sh
- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact-name }}
path: ${{ matrix.artifact-path }}
if-no-files-found: error

linux-cmake:
name: 🐧 Build (Linux, GCC, CMake)
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -qqq build-essential pkg-config cmake
- name: Build godot-cpp
run: |
cmake -DCMAKE_BUILD_TYPE=Release .
make -j $(nproc) VERBOSE=1
- name: Build test GDExtension library
run: |
cd test && cmake -DCMAKE_BUILD_TYPE=Release -DGODOT_HEADERS_PATH="../godot-headers" -DCPP_BINDINGS_PATH=".." .
make -j $(nproc) VERBOSE=1
linux-cmake-ninja:
name: 🐧 Build (Linux, GCC, CMake Ninja)
runs-on: ubuntu-20.04
Expand All @@ -242,15 +220,12 @@ jobs:
sudo apt-get update -qq
sudo apt-get install -qqq build-essential pkg-config cmake ninja-build
- name: Build godot-cpp
run: |
cmake -DCMAKE_BUILD_TYPE=Release -GNinja .
cmake --build . -j $(nproc) --verbose
- name: Build test GDExtension library
run: |
cd test && cmake -DCMAKE_BUILD_TYPE=Release -DGODOT_HEADERS_PATH="../godot-headers" -DCPP_BINDINGS_PATH=".." -GNinja .
cmake --build . -j $(nproc) --verbose
mkdir cmake-build
cd cmake-build
cmake ../ -DTEST_TARGET=template_release
cmake --build . --verbose -j $(nproc) -t godot-cpp-test --config Release
windows-msvc-cmake:
name: 🏁 Build (Windows, MSVC, CMake)
Expand All @@ -261,12 +236,9 @@ jobs:
with:
submodules: recursive

- name: Build godot-cpp
run: |
cmake -DCMAKE_BUILD_TYPE=Release -G"Visual Studio 16 2019" .
cmake --build . --verbose --config Release
- name: Build test GDExtension library
run: |
cd test && cmake -DCMAKE_BUILD_TYPE=Release -DGODOT_HEADERS_PATH="../godot-headers" -DCPP_BINDINGS_PATH=".." -G"Visual Studio 16 2019" .
cmake --build . --verbose --config Release
mkdir cmake-build
cd cmake-build
cmake ../ -DTEST_TARGET=template_release
cmake --build . --verbose -t godot-cpp-test --config Release
21 changes: 21 additions & 0 deletions .github/workflows/runner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: 🔗 GHA
on: [push, pull_request, merge_group]

concurrency:
group: ci-${{ github.actor }}-${{ github.head_ref || github.run_number }}-${{ github.ref }}-runner
cancel-in-progress: true

jobs:
# First stage: Only static checks, fast and prevent expensive builds from running.

static-checks:
if: '!vars.DISABLE_GODOT_CI'
name: 📊 Static Checks
uses: ./.github/workflows/static_checks.yml

# Second stage: Run all the builds and some of the tests.

ci:
name: 🛠️ Continuous Integration
needs: static-checks
uses: ./.github/workflows/ci.yml
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,7 @@ venv

# Clion Configuration
.idea/
cmake-build-*
cmake-build*/

# CMake related
CMakeUserPresets.json
108 changes: 91 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,98 @@
cmake_minimum_required(VERSION 3.13)
project(godot-cpp LANGUAGES CXX)

# Configure CMake
# https://discourse.cmake.org/t/how-do-i-remove-compile-options-from-target/5965
# https://stackoverflow.com/questions/74426638/how-to-remove-rtc1-from-specific-target-or-file-in-cmake
if(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
if(NOT CMAKE_BUILD_TYPE MATCHES Debug)
STRING(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
endif ()
endif ()
cmake_minimum_required(VERSION 3.17)

#[=======================================================================[.rst:
CMake Version requirements
--------------------------
To enable use of the emscripten emsdk hack for pseudo shared library support
without polluting options for consumers we need to use the
CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE which was introduced in version 3.17
Scons Compatibility
-------------------
As we are attempting to maintain feature parity, and ease of maintenance, these
CMake scripts are built to resemble the SCons build system.
include( ${PROJECT_SOURCE_DIR}/cmake/godotcpp.cmake )
The file structure and file content are made to match, if not in content then
in spirit. The closer the two build systems look the easier they will be to
maintain.
# I know this doesn't look like a typical CMakeLists.txt, but as we are
# attempting mostly feature parity with SCons, and easy maintenance, the closer
# the two build systems look the easier they will be to keep in lockstep.
Where the SCons additional scripts in the tools directory, The CMake scripts
are in the cmake directory.
# The typical target definitions are in ${PROJECT_SOURCE_DIR}/cmake/godotcpp.cmake
For example, the tools/godotcpp.py is sourced into SCons, and the 'options'
function is run.
.. highlight:: python
cpp_tool = Tool("godotcpp", toolpath=["tools"])
cpp_tool.options(opts, env)
The CMake equivalent is below.
]=======================================================================]

include( cmake/godotcpp.cmake )
godotcpp_options()

#[=======================================================================[.rst:
Configurations
--------------
There are two build main configurations, 'Debug' and 'Release', these are not
related to godot's DEBUG_FEATURES flag. Build configurations change the default
compiler and linker flags present when building the library, things like debug
symbols, optimization.
The Scons build scripts don't have this concept, you can think of it like the
SCons solution has a single default configuration. In both cases overriding the
defaults is controlled by options on the command line, or in preset files.
Because of this added configuration and that it can be undefined, it becomes
important to set a default, considering the SCons solution that does not enable
debug symbols by default, it seemed appropriate to set the default to 'Release'
if unspecified. This can always be overridden like below.
.. highlight:: shell
cmake <source> -DCMAKE_BUILD_TYPE:STRING=Debug
.. caution::
A complication arises from `Multi-Config Generators`_ that cannot have
their configuration set at configure time. This means that the configuration
must be set on the build command. This is especially important for Visual
Studio Generators which default to 'Debug'
.. highlight:: shell
cmake --build . --config Release
.. _Multi-Config Generators:https://cmake.org/cmake/help/latest/prop_gbl/GENERATOR_IS_MULTI_CONFIG.html
]=======================================================================]
get_property( IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG )
if( NOT IS_MULTI_CONFIG AND NOT CMAKE_BUILD_TYPE )
if( GODOT_DEV_BUILD )
set( CMAKE_BUILD_TYPE Debug )
else ()
set( CMAKE_BUILD_TYPE Release )
endif ()
endif ()

#[[ Python is required for code generation ]]
find_package(Python3 3.4 REQUIRED) # pathlib should be present

# Define our project.
project( godot-cpp
VERSION 4.3
DESCRIPTION "C++ bindings for the Godot Engine's GDExtensions API."
HOMEPAGE_URL "https://github.com/blazium-engine/godot-cpp"
LANGUAGES CXX)

godotcpp_generate()

# Test Example
add_subdirectory( test )
Loading

0 comments on commit ee1c38e

Please sign in to comment.