-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from Spartan322/merge/47f11bc
Merge commit godotengine/godot-cpp@47f11bc
- Loading branch information
Showing
33 changed files
with
2,015 additions
and
528 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -198,4 +198,7 @@ venv | |
|
||
# Clion Configuration | ||
.idea/ | ||
cmake-build-* | ||
cmake-build*/ | ||
|
||
# CMake related | ||
CMakeUserPresets.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Oops, something went wrong.