Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge commit godotengine/godot-cpp@47f11bc #15

Merged
merged 31 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7f02301
Don't print an error when decoding a null Ref<T>
dsnopek Oct 7, 2024
450c3d6
Use namespace in defs.hpp
zhehangd Oct 7, 2024
8534e21
Modernise Existing CMakeLists.txt
enetheru Nov 21, 2024
a42b363
Merge pull request #1598 from enetheru/modernise
dsnopek Nov 22, 2024
597055d
CMake: re-add the godot::cpp alias pointing to template_debug
enetheru Nov 23, 2024
ac466e4
Add `print_line` for compatibility with engine modules
aaronfranke Nov 26, 2024
f174b4a
Update gdextension_interface.h. Add metadata to GetTypeInfo of char16…
Ivorforce Nov 26, 2024
b7dbd26
Align MSVC runtime (MD[d], MT) options to engine #1647
enetheru Nov 27, 2024
bc6f79c
Merge pull request #1617 from zhehangd/fix_def_hpp_namespace
dsnopek Nov 28, 2024
3a8d7a2
Merge pull request #1647 from enetheru/fix#1459
dsnopek Nov 28, 2024
af4eaa7
Merge pull request #1649 from enetheru/fix-backward-break
dsnopek Nov 28, 2024
b378d8c
Merge pull request #1654 from Ivorforce/gdextension-interface-update
dsnopek Nov 28, 2024
5255034
Merge pull request #1653 from aaronfranke/print
dsnopek Nov 28, 2024
daef7d4
Add variant_internal.hpp.
Ivorforce Nov 26, 2024
bb56706
Merge pull request #1616 from dsnopek/ptrtoarg-no-error-for-null-ref
dsnopek Dec 2, 2024
732df06
CMake: Fix selection of MSVC Runtime compile flags
enetheru Nov 30, 2024
9df3a66
Replace empty EXCLUDE variable with EXCLUDE_FROM_ALL
enetheru Nov 28, 2024
72aeb35
Merge pull request #1655 from Ivorforce/variant-internal
dsnopek Dec 6, 2024
4eaef4c
Merge pull request #1663 from enetheru/fix_crt_debug
dsnopek Dec 6, 2024
163189f
Merge pull request #1660 from enetheru/exclude_typo
dsnopek Dec 6, 2024
542ab19
CMake: Handle GODOT_DEV_BUILD flag correctly
enetheru Nov 26, 2024
ce66e6b
Merge pull request #1648 from enetheru/dev_tag
dsnopek Dec 8, 2024
ef9778a
CMake: Enable using clang-cl on windows
enetheru Dec 4, 2024
38056d1
Merge pull request #1651 from enetheru/clang-cl
dsnopek Dec 9, 2024
9943675
Add a separate setup-godot-cpp github action.
Ivorforce Nov 26, 2024
97c16d3
Merge pull request #1656 from Ivorforce/gh-action-setup-godot-cpp
dsnopek Dec 9, 2024
47d9cb9
Fix `print_verbose()` macro conflicting with `UtilityFunctions::print…
dsnopek Dec 9, 2024
27ffd8c
Merge pull request #1668 from dsnopek/print-verbose-conflict
dsnopek Dec 10, 2024
2fd3a80
Add icon path to class creation info
raulsntos Oct 12, 2024
47f11bc
Merge pull request #1666 from raulsntos/set_class_icon
dsnopek Dec 21, 2024
14a856d
Merge commit godotengine/godot-cpp@47f11bc5c79b78c453805bcdd506d47ce1…
Spartan322 Dec 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/actions/setup-godot-cpp/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Setup godot-cpp
description: Setup build dependencies for godot-cpp.

inputs:
platform:
required: true
description: Target platform.
em-version:
default: 3.1.62
description: Emscripten version.
windows-compiler:
required: true
description: The compiler toolchain to use on Windows ('mingw' or 'msvc').
type: choice
options:
- mingw
- msvc
default: mingw
mingw-version:
default: 12.2.0
description: MinGW version.
ndk-version:
default: r23c
description: Android NDK version.
scons-version:
default: 4.4.0
description: SCons version.

runs:
using: composite
steps:
- name: Setup Python (for SCons)
uses: actions/setup-python@v5
with:
python-version: 3.x

- name: Setup Android dependencies
if: inputs.platform == 'android'
uses: nttld/setup-ndk@v1
with:
ndk-version: ${{ inputs.ndk-version }}
link-to-sdk: true

- name: Setup Web dependencies
if: inputs.platform == 'web'
uses: mymindstorm/setup-emsdk@v14
with:
version: ${{ inputs.em-version }}
no-cache: true

- name: Setup MinGW for Windows/MinGW build
if: inputs.platform == 'windows' && inputs.windows-compiler == 'mingw'
uses: egor-tensin/setup-mingw@v2
with:
version: ${{ inputs.mingw-version }}

- name: Setup SCons
shell: bash
run: |
python -c "import sys; print(sys.version)"
python -m pip install scons==${{ inputs.scons-version }}
scons --version
77 changes: 12 additions & 65 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,34 +108,11 @@ jobs:
cache-name: ${{ matrix.cache-name }}
continue-on-error: true

- name: Set up Python (for SCons)
uses: actions/setup-python@v5
- name: Setup godot-cpp
uses: ./.github/actions/setup-godot-cpp
with:
python-version: 3.x

- name: Android dependencies
if: matrix.platform == 'android'
uses: nttld/setup-ndk@v1
with:
ndk-version: r23c
link-to-sdk: true

- name: Web dependencies
if: matrix.platform == 'web'
uses: mymindstorm/setup-emsdk@v14
with:
version: ${{ env.EM_VERSION }}
no-cache: true

- name: Setup MinGW for Windows/MinGW build
if: matrix.platform == 'windows' && matrix.flags == 'use_mingw=yes'
uses: egor-tensin/setup-mingw@v2
with:
version: 12.2.0

- name: Install scons
run: |
python -m pip install scons==4.0.0
platform: ${{ matrix.platform }}
windows-compiler: ${{ contains(matrix.flags, 'use_mingw=yes') && 'mingw' || 'msvc' }}

- name: Generate redot-cpp sources only
run: |
Expand Down Expand Up @@ -207,30 +184,6 @@ jobs:
path: ${{ matrix.artifact-path }}
if-no-files-found: error

linux-cmake:
name: 🐧 Build (Linux, GCC, CMake)
runs-on: ubuntu-22.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 redot-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="../redot-headers" -DCPP_BINDINGS_PATH=".." .
make -j $(nproc) VERBOSE=1

linux-cmake-ninja:
name: 🐧 Build (Linux, GCC, CMake Ninja)
runs-on: ubuntu-22.04
Expand All @@ -245,15 +198,12 @@ jobs:
sudo apt-get update -qq
sudo apt-get install -qqq build-essential pkg-config cmake ninja-build

- name: Build redot-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="../redot-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 @@ -264,12 +214,9 @@ jobs:
with:
submodules: recursive

- name: Build redot-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="../redot-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
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
65 changes: 49 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,57 @@
cmake_minimum_required(VERSION 3.13)
project(godot-cpp LANGUAGES CXX)
cmake_minimum_required(VERSION 3.17)

# 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 ()
#[=======================================================================[.rst:

include( ${PROJECT_SOURCE_DIR}/cmake/godotcpp.cmake )
CMake Version requirements
--------------------------

# 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.
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

# The typical target definitions are in ${PROJECT_SOURCE_DIR}/cmake/godotcpp.cmake
Scons Compatibility
-------------------

There is an understandable conflict between build systems as they define
similar concepts in different ways. When there isn't a 1:1 relationship,
compromises need to be made to resolve those differences.

As we are attempting to maintain feature parity, and ease of maintenance, these
CMake scripts are built to resemble the SCons build system wherever possible.

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.

Where the SCons additional scripts in the tools directory, The CMake scripts
are in the cmake directory.

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()

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

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

compiler_detection()
godotcpp_generate()

# Test Example
add_subdirectory( test )
41 changes: 41 additions & 0 deletions cmake/android.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#[=======================================================================[.rst:
Android
-------

This file contains functions for options and configuration for targeting the
Android platform

Configuration of the Android toolchain is done using toolchain files,
CMakePresets, or variables on the command line.

The `Android SDK`_ provides toolchain files to help with configuration.

CMake has its own `built-in support`_ for cross compiling to the
Android platforms.

.. warning::

Android does not support or test the CMake built-in workflow, recommend
using their toolchain file.

.. _Android SDK:https://developer.android.com/ndk/guides/cmake

.. _built-in support:https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-android

There is further information and examples in the doc/cmake.rst file.

]=======================================================================]
function( android_options )
# Android Options
endfunction()

function( android_generate TARGET_NAME )

target_compile_definitions(${TARGET_NAME}
PUBLIC
ANDROID_ENABLED
UNIX_ENABLED
)

common_compiler_flags( ${TARGET_NAME} )
endfunction()
Loading