diff --git a/CMakeLists.txt b/CMakeLists.txt index e7151026..e069342e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,140 +1,89 @@ -# cmake arguments -# CMAKE_BUILD_TYPE: Compilation target (Debug or Release defaults to Debug) +# Configuration for building godot-cpp only +# See `tests/CMakeLists.txt` for example configuration # -# godot-cpp cmake arguments -# GODOT_GDEXTENSION_DIR: Path to the directory containing GDExtension interface header and API JSON file -# GODOT_CPP_SYSTEM_HEADERS Mark the header files as SYSTEM. This may be useful to supress warnings in projects including this one. -# GODOT_CPP_WARNING_AS_ERROR Treat any warnings as errors -# GODOT_CUSTOM_API_FILE: Path to a custom GDExtension API JSON file (takes precedence over `gdextension_dir`) -# FLOAT_PRECISION: Floating-point precision level ("single", "double") +# Main cmake arguments # -# Android cmake arguments -# CMAKE_TOOLCHAIN_FILE: The path to the android cmake toolchain ($ANDROID_NDK/build/cmake/android.toolchain.cmake) -# ANDROID_NDK: The path to the android ndk root folder -# ANDROID_TOOLCHAIN_NAME: The android toolchain (arm-linux-androideabi-4.9 or aarch64-linux-android-4.9 or x86-4.9 or x86_64-4.9) -# ANDROID_PLATFORM: The android platform version (android-23) -# More info here: https://godot.readthedocs.io/en/latest/development/compiling/compiling_for_android.html +# CMAKE_BUILD_TYPE Compilation target (Debug, Release, RelWithDebInfo, MinSizeRel) +# +# CMAKE_CONFIGURATION_TYPES Set to "Debug;Release;RelWithDebInfo;MinSizeRel" +# in top project config or via cmdline (see `test/CMakeLists.txt`) +# +# TARGET Godot build target (EDITOR, TEMPLATE_DEBUG, TEMPLATE_RELEASE) +# +# PLATFORM: Platform type (LINUX, MACOS, WINDOWS, ANDROID, IOS, WEB) +# Auto-detected by default depending on current OS or chosen toolchain +# +# other global and chosen platform-specific options: +# +# cmake -LH +# +# Note: use `-B ` option to build in separate directories +# for different configurations +# +# cmake -B build && cmake --build build # # Examples # -# Builds a debug version: -# cmake . -# cmake --build . +# Builds default configuration: +# cmake . -Bbuild +# cmake --build build +# +# Builds template_release version +# +# cmake -DTARGET=TEMPLATE_RELEASE -Bbuild +# cmake --build build +# +# Creates multi-config setup and builds Release version +# +# cmake -G "Ninja Multi-Config" -Bbuild # For Linux/non-MSVC +# OR +# cmake -G "Visual Studio 16 2019" -A x64 -Bbuild # For Windows/MSVC +# cmake --build build --config Release +# +# Builds web version, using Emscripten toolchain +# +# cmake --toolchain /usr/lib/emscripten/cmake/Modules/Platform/Emscripten.cmake -Bbuild +# cmake --build build # -# Builds a release version with clang -# CC=/usr/bin/clang CXX=/usr/bin/clang++ cmake -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" . -# cmake --build . # # Builds an android armeabi-v7a debug version: -# cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake -DANDROID_NDK=$ANDROID_NDK \ -# -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.9 -DANDROID_PLATFORM=android-23 -DCMAKE_BUILD_TYPE=Debug . -# cmake --build . +# cmake --toolchain $ANDROID_NDK/build/cmake/android.toolchain.cmake \ +# -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.9 -DANDROID_TOOLCHAIN=clang -DANDROID_PLATFORM=21 -Bbuild +# cmake --build build # -# Protip -# Generate the buildfiles in a sub directory to not clutter the root directory with build files: -# mkdir build && cd build && cmake -G "Unix Makefiles" .. && cmake --build . # -# Todo -# Test build for Windows, Mac and mingw. +# TODO: +# Test builds for MacOS/IOS cmake_minimum_required(VERSION 3.12) project(godot-cpp LANGUAGES CXX) -option(GENERATE_TEMPLATE_GET_NODE "Generate a template version of the Node class's get_node." ON) -option(GODOT_CPP_SYSTEM_HEADERS "Expose headers as SYSTEM." ON) -option(GODOT_CPP_WARNING_AS_ERROR "Treat warnings as errors" OFF) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/") -# Add path to modules -list( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) - -# Set some helper variables for readability -set( compiler_is_clang "$,$>" ) -set( compiler_is_gnu "$" ) -set( compiler_is_msvc "$" ) - -# Default build type is Debug in the SConstruct -if("${CMAKE_BUILD_TYPE}" STREQUAL "") - set(CMAKE_BUILD_TYPE Debug) -endif() - -if(NOT DEFINED BITS) - set(BITS 32) - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(BITS 64) - endif(CMAKE_SIZEOF_VOID_P EQUAL 8) -endif() - -# Input from user for GDExtension interface header and the API JSON file -set(GODOT_GDEXTENSION_DIR "gdextension" CACHE STRING "") -set(GODOT_CUSTOM_API_FILE "" CACHE STRING "") - -set(GODOT_GDEXTENSION_API_FILE "${GODOT_GDEXTENSION_DIR}/extension_api.json") -if (NOT "${GODOT_CUSTOM_API_FILE}" STREQUAL "") # User-defined override. - set(GODOT_GDEXTENSION_API_FILE "${GODOT_CUSTOM_API_FILE}") -endif() - -set(FLOAT_PRECISION "single" CACHE STRING "") -if ("${FLOAT_PRECISION}" STREQUAL "double") - add_definitions(-DREAL_T_IS_DOUBLE) -endif() - -set(GODOT_COMPILE_FLAGS ) - -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - # using Visual Studio C++ - set(GODOT_COMPILE_FLAGS "/utf-8") # /GF /MP - - if(CMAKE_BUILD_TYPE MATCHES Debug) - set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /MDd") # /Od /RTC1 /Zi - else() - set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /MD /O2") # /Oy /GL /Gy - STRING(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) - endif(CMAKE_BUILD_TYPE MATCHES Debug) - - add_definitions(-DNOMINMAX) -else() # GCC/Clang - if(CMAKE_BUILD_TYPE MATCHES Debug) - set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -fno-omit-frame-pointer -O0 -g") - else() - set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -O3") - endif(CMAKE_BUILD_TYPE MATCHES Debug) -endif() - -# Disable exception handling. Godot doesn't use exceptions anywhere, and this -# saves around 20% of binary size and very significant build time (GH-80513). -option(GODOT_DISABLE_EXCEPTIONS ON "Force disabling exception handling code") -if (GODOT_DISABLE_EXCEPTIONS) - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -D_HAS_EXCEPTIONS=0") - else() - set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -fno-exceptions") - endif() -else() - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /EHsc") - endif() -endif() +# Handles all global and platform-specific variables +include(godotcpp) # Generate source from the bindings file find_package(Python3 3.4 REQUIRED) # pathlib should be present + +execute_process(COMMAND "${Python3_EXECUTABLE}" "-c" "import binding_generator; binding_generator.print_file_list(\"${GDEXTENSION_API_FILE}\", \"${CMAKE_CURRENT_BINARY_DIR}\", headers=True, sources=True)" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_VARIABLE GENERATED_FILES_LIST + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +string(TOLOWER ${FLOAT_PRECISION} FLOAT_PRECISION_ARG) if(GENERATE_TEMPLATE_GET_NODE) set(GENERATE_BINDING_PARAMETERS "True") else() set(GENERATE_BINDING_PARAMETERS "False") endif() -execute_process(COMMAND "${Python3_EXECUTABLE}" "-c" "import binding_generator; binding_generator.print_file_list(\"${GODOT_GDEXTENSION_API_FILE}\", \"${CMAKE_CURRENT_BINARY_DIR}\", headers=True, sources=True)" - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - OUTPUT_VARIABLE GENERATED_FILES_LIST - OUTPUT_STRIP_TRAILING_WHITESPACE -) - add_custom_command(OUTPUT ${GENERATED_FILES_LIST} - COMMAND "${Python3_EXECUTABLE}" "-c" "import binding_generator; binding_generator.generate_bindings(\"${GODOT_GDEXTENSION_API_FILE}\", \"${GENERATE_BINDING_PARAMETERS}\", \"${BITS}\", \"${FLOAT_PRECISION}\", \"${CMAKE_CURRENT_BINARY_DIR}\")" + COMMAND "${Python3_EXECUTABLE}" "-c" "import binding_generator; binding_generator.generate_bindings(\"${GDEXTENSION_API_FILE}\", \"${GENERATE_BINDING_PARAMETERS}\", \"${BITS}\", \"${FLOAT_PRECISION_ARG}\", \"${CMAKE_CURRENT_BINARY_DIR}\")" VERBATIM WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - MAIN_DEPENDENCY ${GODOT_GDEXTENSION_API_FILE} + MAIN_DEPENDENCY ${GDEXTENSION_API_FILE} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/binding_generator.py COMMENT "Generating bindings" ) @@ -144,66 +93,32 @@ file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS src/*.c**) file(GLOB_RECURSE HEADERS CONFIGURE_DEPENDS include/*.h**) # Define our godot-cpp library -add_library(${PROJECT_NAME} STATIC +add_library(${PROJECT_NAME} ${GODOT_CPP_LIBRARY_TYPE} ${SOURCES} ${HEADERS} ${GENERATED_FILES_LIST} ) add_library(godot::cpp ALIAS ${PROJECT_NAME}) -include(GodotCompilerWarnings) - -target_compile_features(${PROJECT_NAME} - PRIVATE - cxx_std_17 -) - -target_compile_definitions(${PROJECT_NAME} PUBLIC - $<$: - DEBUG_ENABLED - DEBUG_METHODS_ENABLED - > - $<${compiler_is_msvc}: - TYPED_METHOD_BIND - > -) - -target_link_options(${PROJECT_NAME} PRIVATE - $<$: - -static-libgcc - -static-libstdc++ - -Wl,-R,'$$ORIGIN' - > -) - -# Optionally mark headers as SYSTEM -set(GODOT_CPP_SYSTEM_HEADERS_ATTRIBUTE "") -if (GODOT_CPP_SYSTEM_HEADERS) - set(GODOT_CPP_SYSTEM_HEADERS_ATTRIBUTE SYSTEM) -endif () - target_include_directories(${PROJECT_NAME} ${GODOT_CPP_SYSTEM_HEADERS_ATTRIBUTE} PUBLIC include ${CMAKE_CURRENT_BINARY_DIR}/gen/include - ${GODOT_GDEXTENSION_DIR} + ${GDEXTENSION_DIR} ) -# Add the compile flags -set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY COMPILE_FLAGS ${GODOT_COMPILE_FLAGS}) +target_compile_features(${PROJECT_NAME} PUBLIC + cxx_std_17 +) -# Create the correct name (godot.os.build_type.system_bits) -string(TOLOWER "${CMAKE_SYSTEM_NAME}" SYSTEM_NAME) -string(TOLOWER "${CMAKE_BUILD_TYPE}" BUILD_TYPE) +target_compile_options(${PROJECT_NAME} PRIVATE + ${GODOT_CC_FLAGS} + ${GODOT_CXX_FLAGS} + ${GODOT_COMPILE_WARNING_FLAGS} +) -if(ANDROID) - # Added the android abi after system name - set(SYSTEM_NAME ${SYSTEM_NAME}.${ANDROID_ABI}) +target_link_options(${PROJECT_NAME} PRIVATE ${GODOT_LINK_FLAGS}) - # Android does not have the bits at the end if you look at the main godot repo build - set(OUTPUT_NAME "godot-cpp.${SYSTEM_NAME}.${BUILD_TYPE}") -else() - set(OUTPUT_NAME "godot-cpp.${SYSTEM_NAME}.${BUILD_TYPE}.${BITS}") -endif() +target_compile_definitions(${PROJECT_NAME} PUBLIC ${GODOT_DEFINITIONS}) set_target_properties(${PROJECT_NAME} PROPERTIES @@ -212,5 +127,8 @@ set_target_properties(${PROJECT_NAME} ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin" - OUTPUT_NAME "${OUTPUT_NAME}" + OUTPUT_NAME "${PROJECT_NAME}${LIBRARY_SUFFIX}" ) +if(${GODOT_CPP_WARNING_AS_ERROR}) + set_warning_as_error(${PROJECT_NAME}) +endif() diff --git a/cmake/GodotCompilerWarnings.cmake b/cmake/GodotCompilerWarnings.cmake index 423e6366..6b1c6a64 100644 --- a/cmake/GodotCompilerWarnings.cmake +++ b/cmake/GodotCompilerWarnings.cmake @@ -1,13 +1,18 @@ +# Set some helper variables for readability +set(compiler_is_clang "$,$>") +set(compiler_is_gnu "$") +set(compiler_is_msvc "$") + # Add warnings based on compiler & version # Set some helper variables for readability -set( compiler_less_than_v8 "$,8>" ) -set( compiler_greater_than_or_equal_v9 "$,9>" ) -set( compiler_greater_than_or_equal_v11 "$,11>" ) -set( compiler_less_than_v11 "$,11>" ) -set( compiler_greater_than_or_equal_v12 "$,12>" ) +set(compiler_less_than_v8 "$,8>") +set(compiler_greater_than_or_equal_v9 "$,9>") +set(compiler_greater_than_or_equal_v11 "$,11>") +set(compiler_less_than_v11 "$,11>") +set(compiler_greater_than_or_equal_v12 "$,12>") # These compiler options reflect what is in godot/SConstruct. -target_compile_options( ${PROJECT_NAME} PRIVATE +list(APPEND GODOT_COMPILE_WARNING_FLAGS # MSVC only $<${compiler_is_msvc}: /W4 @@ -73,22 +78,18 @@ target_compile_options( ${PROJECT_NAME} PRIVATE ) # Treat warnings as errors -function( set_warning_as_error ) - message( STATUS "[${PROJECT_NAME}] Treating warnings as errors") - if ( CMAKE_VERSION VERSION_GREATER_EQUAL "3.24" ) - set_target_properties( ${PROJECT_NAME} +function(set_warning_as_error TARGET_NAME) + message(STATUS "[${TARGET_NAME}] Treating warnings as errors") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24") + set_target_properties(${TARGET_NAME} PROPERTIES COMPILE_WARNING_AS_ERROR ON ) else() - target_compile_options( ${PROJECT_NAME} + target_compile_options(${TARGET_NAME} PRIVATE $<${compiler_is_msvc}:/WX> $<$:-Werror> ) endif() endfunction() - -if ( GODOT_CPP_WARNING_AS_ERROR ) - set_warning_as_error() -endif() diff --git a/cmake/android.cmake b/cmake/android.cmake new file mode 100644 index 00000000..cf8ae87a --- /dev/null +++ b/cmake/android.cmake @@ -0,0 +1,65 @@ +# Used with android toolchain at $ANDROID_NDK/build/cmake/android.toolchain.cmake + +set(ARCH "arm64" CACHE STRING "Target architecture (arm64, x86_64, arm32, x86_32, CUSTOM") + +if(${ANDROID_PLATFORM} VERSION_LESS 21) + message(FATAL_ERROR "Minimum supported API level is 21 (-DANDROID_PLATFORM=21)") +endif() + +# This must be kept in sync with the value in https://github.com/godotengine/godot/blob/master/platform/android/detect.py#L58. +set(ANDROID_NDK_VERSION_EXPECTED "23.2.8568313") +if(NOT "${ANDROID_NDK_REVISION}" STREQUAL "${ANDROID_NDK_VERSION_EXPECTED}") + message(FATAL_ERROR "Android NDK version '${ANDROID_NDK_VERSION_EXPECTED}' expected, got '${ANDROID_NDK_REVISION}'") +endif() + +string(REGEX MATCH "32$|64$" DEFAULT_BITS "${ARCH}") +set(BITS "${DEFAULT_BITS}" CACHE STRING "Architecture bits. Needs to be set manually for custom architecture") + + +list(APPEND GODOT_DEFINITIONS + ANDROID_ENABLED + UNIX_ENABLED +) + +list(APPEND GODOT_CC_FLAGS + $<$: + --target=armv7a-linux-androideabi${ANDROID_PLATFORM} + -march=armv7-a + + -mfpu=neon + > + $<$: + --target=aarch64-linux-android${ANDROID_PLATFORM} + -march=armv8-a + > + $<$: + --target=i686-linux-android${ANDROID_PLATFORM} + -march=i686 + + -mstackrealign + > + $<$: + --target=x86_64-linux-android${ANDROID_PLATFORM} + -march=x86-64 + > +) + +list(APPEND GODOT_LINK_FLAGS + $<$: + --target=armv7a-linux-androideabi${ANDROID_PLATFORM} + -march=armv7-a + > + $<$: + --target=aarch64-linux-android${ANDROID_PLATFORM} + -march=armv8-a + > + $<$: + --target=i686-linux-android${ANDROID_PLATFORM} + -march=i686 + > + $<$: + --target=x86_64-linux-android${ANDROID_PLATFORM} + -march=x86-64 + > +) + diff --git a/cmake/godotcpp.cmake b/cmake/godotcpp.cmake new file mode 100644 index 00000000..288d7adf --- /dev/null +++ b/cmake/godotcpp.cmake @@ -0,0 +1,299 @@ +# This file contains variables needed by all platforms + +### Options + +set(CONFIGS_WITH_DEBUG "Debug;RelWithDebInfo" CACHE STRING "Configurations that should have debug symbols (Modify if support for custom configurations is needed)") + +# Default config +if("${CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_BUILD_TYPE "Debug") +endif() + +set(TARGET "TEMPLATE_DEBUG" CACHE STRING "Target platform (EDITOR, TEMPLATE_DEBUG, TEMPLATE_RELEASE)") +# Auto-detect platform +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(DEFAULT_PLATFORM "LINUX") +elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") + set(DEFAULT_PLATFORM "WINDOWS") +elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set(DEFAULT_PLATFORM "MACOS") +elseif(CMAKE_SYSTEM_NAME STREQUAL "Emscripten") # Set by providing Emscripten toolchain + set(DEFAULT_PLATFORM "WEB") +elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") # Set by providing Android toolchain + set(DEFAULT_PLATFORM "ANDROID") +else() + message(FATAL_ERROR "Could not auto-detect platform for \"${CMAKE_SYSTEM_NAME}\" automatically, please specify with -DPLATFORM=") +endif() +set(PLATFORM "${DEFAULT_PLATFORM}" CACHE STRING "[Auto-detected] Target platform (LINUX, MACOS, WINDOWS, ANDROID, IOS, WEB)") + +set(GDEXTENSION_DIR "${CMAKE_CURRENT_SOURCE_DIR}/gdextension" CACHE FILEPATH "Path to a directory containing GDExtension interface header") + +set(GDEXTENSION_API_FILE "${CMAKE_CURRENT_SOURCE_DIR}/gdextension/extension_api.json" CACHE FILEPATH "Path to GDExtension API JSON file") + +set(FLOAT_PRECISION "SINGLE" CACHE STRING "Floating-point precision level (SINGLE, DOUBLE)") + +set(OPTIMIZE "AUTO" CACHE STRING "The desired optimization flags (NONE, CUSTOM, DEBUG, SPEED, SPEED_TRACE, SIZE)") + +set(SYMBOLS_VISIBILITY "AUTO" CACHE STRING "Symbols visibility on GNU platforms (AUTO, VISIBLE, HIDDEN)") + +#TODO: custom .gdextension template file to add shared library as dependency +set(GODOT_CPP_LIBRARY_TYPE "STATIC" CACHE STRING "[Experimental] Library type (STATIC, SHARED)") + + +option(DEV_BUILD "Developer build with dev-only debugging code" OFF) + +option(DEBUG_SYMBOLS "Force build with debugging symbols" OFF) + +option(USE_HOT_RELOAD "Enable the extra accounting required to support hot reload" ON) + +# Disable exception handling. Godot doesn't use exceptions anywhere, and this +# saves around 20% of binary size and very significant build time (GH-80513). +option(GODOT_DISABLE_EXCEPTIONS "Force disabling exception handling code" ON) + +# Optionally mark headers as SYSTEM +option(GODOT_CPP_SYSTEM_HEADERS "Mark the header files as SYSTEM. This may be useful to supress warnings in projects including this one" OFF) +set(GODOT_CPP_SYSTEM_HEADERS_ATTRIBUTE "") +if(GODOT_CPP_SYSTEM_HEADERS) + set(GODOT_CPP_SYSTEM_HEADERS_ATTRIBUTE SYSTEM) +endif() + +# Enable by default when building godot-cpp only +set(DEFAULT_WARNING_AS_ERROR OFF) +if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME}) + set(DEFAULT_WARNING_AS_ERROR ON) +endif() +set(GODOT_CPP_WARNING_AS_ERROR ${DEFAULT_WARNING_AS_ERROR} CACHE BOOL "Treat warnings as errors") + +option(GENERATE_TEMPLATE_GET_NODE "Generate a template version of the Node class's get_node" ON) + +### + +# Compiler warnings and compiler check generators +include(GodotCompilerWarnings) + +# Create the correct name (godot-cpp.platform.target) +# See more prefix appends in platform-specific configs +if(${DEV_BUILD}) + string(APPEND LIBRARY_SUFFIX ".dev") +endif() + +if(${FLOAT_PRECISION} STREQUAL "DOUBLE") + string(APPEND LIBRARY_SUFFIX ".double") +endif() + +# Workaround of $ expanding to "" when default build set +set(CONFIG "$>,${CMAKE_BUILD_TYPE},$>") + +string(TOLOWER ".${PLATFORM}.${TARGET}" platform_target) +string(PREPEND LIBRARY_SUFFIX ${platform_target}) + +# Default optimization levels if OPTIMIZE=AUTO, for multi-config support +set(DEFAULT_OPTIMIZATION_DEBUG_FEATURES "$,$>") +set(DEFAULT_OPTIMIZATION "$") + +set(DEBUG_SYMBOLS_ENABLED "$,$>") + +# Clean default options +set(CMAKE_CXX_FLAGS_DEBUG "") +set(CMAKE_CXX_FLAGS_RELEASE "") +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "") +set(CMAKE_CXX_FLAGS_MINSIZEREL "") + +list(APPEND GODOT_DEFINITIONS + GDEXTENSION + + $<${compiler_is_msvc}: + $<$: + _HAS_EXCEPTIONS=0 + > + > + + $<$: + REAL_T_IS_DOUBLE + > + $<$>,$>: + HOT_RELOAD_ENABLED + > + $<$: + TOOLS_ENABLED + > + + $<$: + DEV_ENABLED + > + $<$>: + NDEBUG + > + + $<$>: + DEBUG_ENABLED + DEBUG_METHODS_ENABLED + > +) + +list(APPEND GODOT_CC_FLAGS + $<${compiler_is_msvc}: + $<${DEBUG_SYMBOLS_ENABLED}: + /Zi + /FS + > + + $<$: + $<$: + $<${DEFAULT_OPTIMIZATION}: + /O2 + > + $<${DEFAULT_OPTIMIZATION_DEBUG_FEATURES}: + /O2 + > + > + $<$: + /O1 + > + $<$: + /Od + > + > + $<$>: + $<$:/O2> + $<$:/O2> + $<$:/O1> + $<$:/Od> + $<$:/Od> + > + + > + $<$: + $<${DEBUG_SYMBOLS_ENABLED}: + -gdwarf-4 + + $<$: + -g3 + > + $<$>: + -g2 + > + > + + $<$: + -fvisibility=default + > + $<$: + -fvisibility=hidden + > + + $<$: + $<$: + $<${DEFAULT_OPTIMIZATION}: + -O3 + > + $<${DEFAULT_OPTIMIZATION_DEBUG_FEATURES}: + -O2 + > + > + $<$: + -Os + > + $<$: + -Og + > + > + $<$>: + $<$:-O3> + $<$:-O2> + $<$:-Os> + $<$:-Og> + $<$:-O0> + > + > +) + +list(APPEND GODOT_CXX_FLAGS + $<${compiler_is_msvc}: + $<$>: + /EHsc + > + > + $<$: + $<$: + -fno-exceptions + > + > +) + +list(APPEND GODOT_LINK_FLAGS + $<${compiler_is_msvc}: + $<${DEBUG_SYMBOLS_ENABLED}: + /DEBUG:FULL + > + + $<$: + $<$: + $<${DEFAULT_OPTIMIZATION}: + /OPT:REF + > + $<${DEFAULT_OPTIMIZATION_DEBUG_FEATURES}: + /OPT:REF + /OPT:NOICF + > + > + $<$: + /OPT:REF + > + > + $<$>: + $<$:/OPT:REF> + $<$:/OPT:REF /OPT:NOICF> + $<$:/OPT:REF> + > + > + $<$: + $<$: + -fvisibility=default + > + $<$: + -fvisibility=hidden + > + + $<$: + $<$: # SCons: not is_vanilla_clang(env) + "-Wl,-S" + "-Wl,-x" + "-Wl,-dead_strip" + > + $<$>: + "-s" + > + > + > +) + +# Platform-specific options +if("${PLATFORM}" STREQUAL "LINUX") + include(linux) +elseif("${PLATFORM}" STREQUAL "MACOS") + include(macos) +elseif("${PLATFORM}" STREQUAL "WINDOWS") + include(windows) +elseif("${PLATFORM}" STREQUAL "ANDROID") + include(android) +elseif("${PLATFORM}" STREQUAL "IOS") + include(ios) +elseif("${PLATFORM}" STREQUAL "WEB") + include(web) +else() + message(FATAL_ERROR "Platform not supported: ${PLATFORM}") +endif() + +string(APPEND LIBRARY_SUFFIX ".${ARCH}") + +if(${IOS_SIMULATOR}) + string(APPEND LIBRARY_SUFFIX ".simulator") +endif() + +# Write all flags to file for cmake configuration debug +file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/flags-${CONFIG}.txt" + CONTENT + "C_FLAGS '${GODOT_CC_FLAGS}'\nCXX_FLAGS '${GODOT_CXX_FLAGS}'\nLINK_FLAGS '${GODOT_LINK_FLAGS}'\nCOMPILE_WARNING_FLAGS '${GODOT_COMPILE_WARNING_FLAGS}'\nDEFINITIONS '${GODOT_DEFINITIONS}'" + TARGET ${PROJECT_NAME} +) diff --git a/cmake/ios.cmake b/cmake/ios.cmake new file mode 100644 index 00000000..41831420 --- /dev/null +++ b/cmake/ios.cmake @@ -0,0 +1,62 @@ +message(WARNING "IOS configuration is not tested and may not work.") + +set(ARCH "universal" CACHE STRING "Target architecture (universal, arm64, x86_64, CUSTOM)") + +set(IOS_MIN_VERSION "12.0" CACHE STRING "Target minimum iphoneos/iphonesimulator version") + +option(IOS_SIMULATOR "Target iOS Simulator" OFF) + +if (${ARCH} STREQUAL "universal") + set(DEFAULT_BITS 64) +else() + string(REGEX MATCH "32$|64$" DEFAULT_BITS "${ARCH}") +endif() +set(BITS "${DEFAULT_BITS}" CACHE STRING "Architecture bits. Needs to be set manually for custom architecture") + + +list(APPEND GODOT_DEFINITIONS + IOS_ENABLED + UNIX_ENABLED +) + +list(APPEND GODOT_CC_FLAGS + $<$: + -stdlib=libc++ + > + + $<$: + -mios-simulator-version-min=${IOS_MIN_VERSION} + > + $<$>: + -miphoneos-version-min=${IOS_MIN_VERSION} + > + + $<$: + $<$: + "SHELL:-arch x86_64" + "SHELL:-arch arm64" + > + $<$>: + "SHELL:-arch arm64" + > + > + $<$>: + "-arch ${ARCH}" + > +) + +list(APPEND GODOT_LINK_FLAGS + $<$: + $<$: + "SHELL:-arch x86_64" + "SHELL:-arch arm64" + > + $<$>: + "SHELL:-arch arm64" + > + > + $<$>: + "SHELL:-arch ${ARCH}" + > +) + diff --git a/cmake/linux.cmake b/cmake/linux.cmake new file mode 100644 index 00000000..48e9ff47 --- /dev/null +++ b/cmake/linux.cmake @@ -0,0 +1,59 @@ +set(ARCH "x86_64" CACHE STRING "Target architecture (x86_32, x86_64, arm64, rv64, CUSTOM)") + +string(REGEX MATCH "32$|64$" DEFAULT_BITS "${ARCH}") +set(BITS "${DEFAULT_BITS}" CACHE STRING "Architecture bits. Needs to be set manually for custom architecture") + + +list(APPEND GODOT_DEFINITIONS + LINUX_ENABLED + UNIX_ENABLED +) + +list(APPEND GODOT_CC_FLAGS + # -fPIC is controlled by POSITION_INDEPENDENT_CODE property + + $<$: + -m64 + -march=x86-64 + > + $<$: + -m32 + -march=i686 + > + $<$: + -march=armv8-a + > + $<$: + -march=rv64gc + > +) + +list(APPEND GODOT_CXX_FLAGS + $<$,${compiler_is_gnu}>: + -fno-gnu-unique + > +) + +list(APPEND GODOT_LINK_FLAGS + -Wl,-R,'$$ORIGIN' + + $<$: + -m64 + -march=x86-64 + > + $<$: + -m32 + -march=i686 + > + $<$: + -march=armv8-a + > + $<$: + -march=rv64gc + > +) + +list(APPEND GODOT_COMPILE_WARNING_FLAGS + -Wwrite-strings +) + diff --git a/cmake/macos.cmake b/cmake/macos.cmake new file mode 100644 index 00000000..29c02719 --- /dev/null +++ b/cmake/macos.cmake @@ -0,0 +1,51 @@ +message(WARNING "MacOS configuration is not tested and may not work.") + +set(ARCH "universal" CACHE STRING "Target architecture (universal, arm64, x86_64, CUSTOM)") + +set(MACOS_DEPLOYMENT_TARGET "DEFAULT" CACHE STRING "") + +if (${ARCH} STREQUAL "universal") + set(DEFAULT_BITS 64) +else() + string(REGEX MATCH "32$|64$" DEFAULT_BITS "${ARCH}") +endif() +set(BITS "${DEFAULT_BITS}" CACHE STRING "Architecture bits. Needs to be set manually for custom architecture") + + +list(APPEND GODOT_DEFINITIONS + MACOS_ENABLED + UNIX_ENABLED +) + +list(APPEND GODOT_CC_FLAGS + $<$: + "SHELL:-arch x86_64" + "SHELL:-arch arm64" + > + $<$>: + "SHELL:-arch ${ARCH}" + > + + $<$>: + -mmacosx-version-min=${MACOS_DEPLOYMENT_TARGET} + > +) + +list(APPEND GODOT_LINK_FLAGS + -framework + Cocoa + -Wl,-undefined,dynamic_lookup + + $<$: + "SHELL:-arch x86_64" + "SHELL:-arch arm64" + > + $<$>: + "SHELL:-arch ${ARCH}" + > + + $<$>: + -mmacosx-version-min=${MACOS_DEPLOYMENT_TARGET} + > +) + diff --git a/cmake/web.cmake b/cmake/web.cmake new file mode 100644 index 00000000..7148a952 --- /dev/null +++ b/cmake/web.cmake @@ -0,0 +1,26 @@ +# Used with Emscripted toolchain at *toolchain_dir*/cmake/Modules/Platform/Emscripten.cmake + +set(ARCH "wasm32" CACHE STRING "Target architecture (wasm32, CUSTOM)") + +string(REGEX MATCH "32$|64$" DEFAULT_BITS "${ARCH}") +set(BITS "${DEFAULT_BITS}" CACHE STRING "Architecture bits. Needs to be set manually for custom architecture") + + +list(APPEND GODOT_DEFINITIONS + WEB_ENABLED + UNIX_ENABLED +) + +list(APPEND GODOT_CC_FLAGS + -sUSE_PTHREADS=1 +) + +list(APPEND GODOT_CXX_FLAGS + -sSIDE_MODULE=1 +) + +list(APPEND GODOT_LINK_FLAGS + -sUSE_PTHREADS=1 + -sSIDE_MODULE=1 +) + diff --git a/cmake/windows.cmake b/cmake/windows.cmake new file mode 100644 index 00000000..05883460 --- /dev/null +++ b/cmake/windows.cmake @@ -0,0 +1,51 @@ +set(ARCH "x86_64" CACHE STRING "Target architecture (x86_32, x86_64, CUSTOM)") + +option(USE_STATIC_CPP "Link MinGW/MSVC C++ runtime libraries statically" ON) + +string(REGEX MATCH "32$|64$" DEFAULT_BITS "${ARCH}") +set(BITS "${DEFAULT_BITS}" CACHE STRING "Architecture bits. Needs to be set manually for custom architecture") + + +list(APPEND GODOT_DEFINITIONS + WINDOWS_ENABLED + + $<${compiler_is_msvc}: + TYPED_METHOD_BIND + NOMINMAX + > +) + +list(APPEND GODOT_CC_FLAGS + $<${compiler_is_msvc}: + /utf-8 + + $<$: + /MT + > + $<$>: + /MD + > + > +) + +list(APPEND GODOT_LINK_FLAGS + $<${compiler_is_msvc}: + /WX + > + $<$: + -Wl,--no-undefined + + $<$: + -static + -static-libgcc + -static-libstdc++ + > + > +) + +list(APPEND GODOT_COMPILE_WARNING_FLAGS + $<$: + -Wwrite-strings + > +) + diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 67f3c5c8..97e9bcd8 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,143 +1,74 @@ -project(godot-cpp-test) +# Configuration can be used as a template for custom project, read comments cmake_minimum_required(VERSION 3.6) +project(gdexample LANGUAGES CXX) -set(GODOT_GDEXTENSION_DIR ../gdextension/ CACHE STRING "Path to GDExtension interface header directory") -set(CPP_BINDINGS_PATH ../ CACHE STRING "Path to C++ bindings") +set(CMAKE_CONFIGURATION_TYPES "Debug;Release;RelWithDebInfo;MinSizeRel") +set(GODOT_CPP_PATH ../) # path to godot-cpp repository -if(CMAKE_SYSTEM_NAME STREQUAL "Linux") - set(TARGET_PATH x11) -elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") - set(TARGET_PATH win64) -elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - set(TARGET_PATH macos) -else() - message(FATAL_ERROR "Not implemented support for ${CMAKE_SYSTEM_NAME}") -endif() - -# Change the output directory to the bin directory -set(BUILD_PATH ${CMAKE_SOURCE_DIR}/bin/${TARGET_PATH}) -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${BUILD_PATH}") -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${BUILD_PATH}") -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${BUILD_PATH}") -SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${BUILD_PATH}") -SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${BUILD_PATH}") -SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${BUILD_PATH}") -SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${BUILD_PATH}") -SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${BUILD_PATH}") -SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${BUILD_PATH}") - -# Set the c++ standard to c++17 -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) - -set(GODOT_COMPILE_FLAGS ) -set(GODOT_LINKER_FLAGS ) - -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - # using Visual Studio C++ - set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /WX") # /GF /MP - set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /DTYPED_METHOD_BIND") - - if(CMAKE_BUILD_TYPE MATCHES Debug) - set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /MDd") # /Od /RTC1 /Zi - else() - set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /MD /O2") # /Oy /GL /Gy - STRING(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) - endif(CMAKE_BUILD_TYPE MATCHES Debug) - - # Disable conversion warning, truncation, unreferenced var, signed mismatch - set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /wd4244 /wd4305 /wd4101 /wd4018 /wd4267") - - add_definitions(-DNOMINMAX) - - # Unkomment for warning level 4 - #if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") - # string(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - #endif() - -else() - - set(GODOT_LINKER_FLAGS "-static-libgcc -static-libstdc++ -Wl,-R,'$$ORIGIN'") - - set(GODOT_COMPILE_FLAGS "-fPIC -g -Wwrite-strings") - - if(CMAKE_BUILD_TYPE MATCHES Debug) - set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -fno-omit-frame-pointer -O0") - else() - set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -O3") - endif(CMAKE_BUILD_TYPE MATCHES Debug) -endif() - -# Disable exception handling. Godot doesn't use exceptions anywhere, and this -# saves around 20% of binary size and very significant build time (GH-80513). -option(GODOT_DISABLE_EXCEPTIONS ON "Force disabling exception handling code") -if (GODOT_DISABLE_EXCEPTIONS) - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -D_HAS_EXCEPTIONS=0") - else() - set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -fno-exceptions") - endif() -else() - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /EHsc") - endif() -endif() +add_subdirectory( + ${GODOT_CPP_PATH} + ${CMAKE_CURRENT_BINARY_DIR}/godot-cpp # needed because godot-cpp is top directory +) # Get Sources file(GLOB_RECURSE SOURCES src/*.c**) -file(GLOB_RECURSE HEADERS include/*.h**) +file(GLOB_RECURSE HEADERS src/*.h**) # Define our godot-cpp library -add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADERS}) +if(${PLATFORM} STREQUAL "WEB") + # wasm libraries loaded with dlopen() are created like this in cmake + add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS}) + set_target_properties(${PROJECT_NAME} + PROPERTIES + PREFIX "lib" + SUFFIX ".wasm" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/project/bin" + RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/project/bin" + RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/project/bin" + RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/project/bin" + RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/project/bin" -target_include_directories(${PROJECT_NAME} SYSTEM - PRIVATE - ${CPP_BINDINGS_PATH}/include - ${CPP_BINDINGS_PATH}/gen/include - ${GODOT_GDEXTENSION_DIR} + ) +elseif(${PLATFORM} STREQUAL "MACOS") + # TODO: create framework with cmake FRAMEWORK property + # or with template file + message(WARNING "Mac/IOS framework configuration is not tested and may not work.") + + add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADERS}) + set_target_properties(${PROJECT_NAME} PROPERTIES + FRAMEWORK TRUE + MACOSX_FRAMEWORK_IDENTIFIER com.godotengine.${PROJECT_NAME} + MACOSX_FRAMEWORK_INFO_PLIST Info.plist + ) +else() + add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADERS}) +endif() + +target_link_libraries(${PROJECT_NAME} PUBLIC godot-cpp) + +get_directory_property(GODOT_CC_FLAGS DIRECTORY ${GODOT_CPP_PATH} DEFINITION GODOT_CC_FLAGS) +get_directory_property(GODOT_CXX_FLAGS DIRECTORY ${GODOT_CPP_PATH} DEFINITION GODOT_CXX_FLAGS) +target_compile_options(${PROJECT_NAME} PRIVATE + ${GODOT_CC_FLAGS} + ${GODOT_CXX_FLAGS} ) -# Create the correct name (godot.os.build_type.system_bits) -# Synchronized with godot-cpp's CMakeLists.txt +get_directory_property(GODOT_LINK_FLAGS DIRECTORY ${GODOT_CPP_PATH} DEFINITION GODOT_LINK_FLAGS) +target_link_options(${PROJECT_NAME} PRIVATE ${GODOT_LINK_FLAGS}) -set(BITS 32) -if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(BITS 64) -endif(CMAKE_SIZEOF_VOID_P EQUAL 8) -if(CMAKE_BUILD_TYPE MATCHES Debug) - set(GODOT_CPP_BUILD_TYPE Debug) -else() - set(GODOT_CPP_BUILD_TYPE Release) +get_directory_property(LIBRARY_SUFFIX DIRECTORY ${GODOT_CPP_PATH} DEFINITION LIBRARY_SUFFIX) +set_target_properties(${PROJECT_NAME} + PROPERTIES + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/project/bin" + LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/project/bin" + LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/project/bin" + LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/project/bin" + LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/project/bin" + + OUTPUT_NAME "${PROJECT_NAME}${LIBRARY_SUFFIX}" +) +if(${GODOT_CPP_WARNING_AS_ERROR}) + set_warning_as_error(${PROJECT_NAME}) endif() -string(TOLOWER ${CMAKE_SYSTEM_NAME} SYSTEM_NAME) -string(TOLOWER ${GODOT_CPP_BUILD_TYPE} BUILD_TYPE) - -if(ANDROID) - # Added the android abi after system name - set(SYSTEM_NAME ${SYSTEM_NAME}.${ANDROID_ABI}) -endif() - -if(CMAKE_VERSION VERSION_GREATER "3.13") - target_link_directories(${PROJECT_NAME} - PRIVATE - ${CPP_BINDINGS_PATH}/bin/ - ) - - target_link_libraries(${PROJECT_NAME} - godot-cpp.${SYSTEM_NAME}.${BUILD_TYPE}$<$>:.${BITS}> - ) -else() - target_link_libraries(${PROJECT_NAME} - ${CPP_BINDINGS_PATH}/bin/libgodot-cpp.${SYSTEM_NAME}.${BUILD_TYPE}$<$>:.${BITS}>.a - ) -endif() - -# Add the compile flags -set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY COMPILE_FLAGS ${GODOT_COMPILE_FLAGS}) -set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS ${GODOT_LINKER_FLAGS}) - -set_property(TARGET ${PROJECT_NAME} PROPERTY OUTPUT_NAME "gdexample") diff --git a/test/project/export_presets.cfg b/test/project/export_presets.cfg new file mode 100644 index 00000000..1e672b73 --- /dev/null +++ b/test/project/export_presets.cfg @@ -0,0 +1,39 @@ +[preset.0] + +name="" +platform="Linux/X11" +runnable=false +dedicated_server=false +custom_features="" +export_filter="all_resources" +include_filter="" +exclude_filter="" +export_path="" +encryption_include_filters="" +encryption_exclude_filters="" +encrypt_pck=false +encrypt_directory=false + +[preset.0.options] + +custom_template/debug="" +custom_template/release="" +debug/export_console_wrapper=1 +binary_format/embed_pck=false +texture_format/bptc=true +texture_format/s3tc=true +texture_format/etc=false +texture_format/etc2=false +binary_format/architecture="x86_64" +ssh_remote_deploy/enabled=false +ssh_remote_deploy/host="user@host_ip" +ssh_remote_deploy/port="22" +ssh_remote_deploy/extra_args_ssh="" +ssh_remote_deploy/extra_args_scp="" +ssh_remote_deploy/run_script="#!/usr/bin/env bash +export DISPLAY=:0 +unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\" +\"{temp_dir}/{exe_name}\" {cmd_args}" +ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash +kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\") +rm -rf \"{temp_dir}\"" diff --git a/test/run-tests.sh b/test/run-tests.sh index 728f6d4c..cb13c133 100755 --- a/test/run-tests.sh +++ b/test/run-tests.sh @@ -5,6 +5,9 @@ GODOT=${GODOT:-godot} END_STRING="==== TESTS FINISHED ====" FAILURE_STRING="******** FAILED ********" +# Import to get GDExtension library working +$GODOT --headless --path project --export-pack '' /dev/null + OUTPUT=$($GODOT --path project --debug --headless --quit) ERRCODE=$?