Test Linux with CMake in CI
parent
bbcf901eab
commit
0ce1638296
|
@ -25,6 +25,17 @@ jobs:
|
||||||
godot_zip: Godot_v3.5-stable_linux_server.64.zip
|
godot_zip: Godot_v3.5-stable_linux_server.64.zip
|
||||||
executable: Godot_v3.5-stable_linux_server.64
|
executable: Godot_v3.5-stable_linux_server.64
|
||||||
cache-name: linux-x86_64
|
cache-name: linux-x86_64
|
||||||
|
build-system: scons
|
||||||
|
|
||||||
|
- name: 🐧 Linux (GCC, CMake)
|
||||||
|
os: ubuntu-20.04
|
||||||
|
platform: linux
|
||||||
|
artifact-name: godot-cpp-linux-glibc2.27-x86_64-release
|
||||||
|
artifact-path: bin/libgodot-cpp.linux.release.64.a
|
||||||
|
godot_zip: Godot_v3.5-stable_linux_server.64.zip
|
||||||
|
executable: Godot_v3.5-stable_linux_server.64
|
||||||
|
cache-name: linux-x86_64-cmake
|
||||||
|
build-system: cmake
|
||||||
|
|
||||||
- name: 🏁 Windows (x86_64, MSVC)
|
- name: 🏁 Windows (x86_64, MSVC)
|
||||||
os: windows-2019
|
os: windows-2019
|
||||||
|
@ -32,6 +43,7 @@ jobs:
|
||||||
artifact-name: godot-cpp-windows-msvc2019-x86_64-release
|
artifact-name: godot-cpp-windows-msvc2019-x86_64-release
|
||||||
artifact-path: bin/libgodot-cpp.windows.release.64.lib
|
artifact-path: bin/libgodot-cpp.windows.release.64.lib
|
||||||
cache-name: windows-x86_64-msvc
|
cache-name: windows-x86_64-msvc
|
||||||
|
build-system: scons
|
||||||
|
|
||||||
- name: 🏁 Windows (x86_64, MinGW)
|
- name: 🏁 Windows (x86_64, MinGW)
|
||||||
os: windows-2019
|
os: windows-2019
|
||||||
|
@ -40,6 +52,7 @@ jobs:
|
||||||
artifact-path: bin/libgodot-cpp.windows.release.64.a
|
artifact-path: bin/libgodot-cpp.windows.release.64.a
|
||||||
flags: use_mingw=yes
|
flags: use_mingw=yes
|
||||||
cache-name: windows-x86_64-mingw
|
cache-name: windows-x86_64-mingw
|
||||||
|
build-system: scons
|
||||||
|
|
||||||
- name: 🍎 macOS (universal)
|
- name: 🍎 macOS (universal)
|
||||||
os: macos-11
|
os: macos-11
|
||||||
|
@ -50,6 +63,7 @@ jobs:
|
||||||
godot_zip: Godot_v3.5-stable_osx.universal.zip
|
godot_zip: Godot_v3.5-stable_osx.universal.zip
|
||||||
executable: Godot.app/Contents/MacOS/Godot
|
executable: Godot.app/Contents/MacOS/Godot
|
||||||
cache-name: macos-unversal
|
cache-name: macos-unversal
|
||||||
|
build-system: scons
|
||||||
|
|
||||||
- name: 🤖 Android (arm64)
|
- name: 🤖 Android (arm64)
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
|
@ -58,6 +72,7 @@ jobs:
|
||||||
artifact-path: bin/libgodot-cpp.android.release.arm64v8.a
|
artifact-path: bin/libgodot-cpp.android.release.arm64v8.a
|
||||||
flags: ANDROID_NDK_ROOT=$ANDROID_NDK_LATEST_HOME android_arch=arm64v8
|
flags: ANDROID_NDK_ROOT=$ANDROID_NDK_LATEST_HOME android_arch=arm64v8
|
||||||
cache-name: android-arm64
|
cache-name: android-arm64
|
||||||
|
build-system: scons
|
||||||
|
|
||||||
- name: 🍏 iOS (arm64)
|
- name: 🍏 iOS (arm64)
|
||||||
os: macos-11
|
os: macos-11
|
||||||
|
@ -65,6 +80,7 @@ jobs:
|
||||||
artifact-name: godot-cpp-ios-arm64-release
|
artifact-name: godot-cpp-ios-arm64-release
|
||||||
artifact-path: bin/libgodot-cpp.ios.release.arm64.a
|
artifact-path: bin/libgodot-cpp.ios.release.arm64.a
|
||||||
cache-name: ios-arm64
|
cache-name: ios-arm64
|
||||||
|
build-system: scons
|
||||||
|
|
||||||
env:
|
env:
|
||||||
SCONS_CACHE: ${{ github.workspace }}/.scons-cache/
|
SCONS_CACHE: ${{ github.workspace }}/.scons-cache/
|
||||||
|
@ -81,7 +97,7 @@ jobs:
|
||||||
cache-name: ${{ matrix.cache-name }}
|
cache-name: ${{ matrix.cache-name }}
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
- name: Set up Python (for SCons)
|
- name: Set up Python (for SCons and binding generator)
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: '3.x'
|
python-version: '3.x'
|
||||||
|
@ -93,27 +109,57 @@ jobs:
|
||||||
sudo apt-get install -qqq build-essential pkg-config
|
sudo apt-get install -qqq build-essential pkg-config
|
||||||
|
|
||||||
- name: Install scons
|
- name: Install scons
|
||||||
|
if: ${{ matrix.build-system == 'scons' }}
|
||||||
run: |
|
run: |
|
||||||
python -m pip install scons
|
python -m pip install scons
|
||||||
|
|
||||||
|
- name: Install cmake
|
||||||
|
if: ${{ matrix.platform == 'linux' && matrix.build-system == 'cmake' }}
|
||||||
|
run: |
|
||||||
|
sudo apt-get install -qqq cmake
|
||||||
|
|
||||||
- name: Windows dependency (MinGW)
|
- name: Windows dependency (MinGW)
|
||||||
if: ${{ matrix.platform == 'windows' }}
|
if: ${{ matrix.platform == 'windows' }}
|
||||||
uses: egor-tensin/setup-mingw@v2
|
uses: egor-tensin/setup-mingw@v2
|
||||||
|
|
||||||
- name: Build godot-cpp (debug)
|
- name: Build godot-cpp (debug)
|
||||||
|
if: ${{ matrix.build-system == 'scons' }}
|
||||||
run: |
|
run: |
|
||||||
scons platform=${{ matrix.platform }} target=debug ${{ matrix.flags }}
|
scons platform=${{ matrix.platform }} target=debug ${{ matrix.flags }}
|
||||||
|
|
||||||
|
- name: Build godot-cpp (debug)
|
||||||
|
if: ${{ matrix.build-system == 'cmake' }}
|
||||||
|
run: |
|
||||||
|
cmake -DCMAKE_BUILD_TYPE=Debug .
|
||||||
|
make -j $(nproc)
|
||||||
|
|
||||||
- name: Build test without rebuilding godot-cpp (debug)
|
- name: Build test without rebuilding godot-cpp (debug)
|
||||||
|
if: ${{ matrix.build-system == 'scons' }}
|
||||||
run: |
|
run: |
|
||||||
cd test
|
cd test
|
||||||
scons platform=${{ matrix.platform }} target=debug ${{ matrix.flags }} build_library=no
|
scons platform=${{ matrix.platform }} target=debug ${{ matrix.flags }} build_library=no
|
||||||
|
|
||||||
|
- name: Build test without rebuilding godot-cpp (debug)
|
||||||
|
if: ${{ matrix.build-system == 'cmake' }}
|
||||||
|
run: |
|
||||||
|
cd test && cmake -DCMAKE_BUILD_TYPE=Debug .
|
||||||
|
make -j $(nproc)
|
||||||
|
|
||||||
- name: Build test and godot-cpp (release)
|
- name: Build test and godot-cpp (release)
|
||||||
|
if: ${{ matrix.build-system == 'scons' }}
|
||||||
run: |
|
run: |
|
||||||
cd test
|
cd test
|
||||||
scons platform=${{ matrix.platform }} target=release ${{ matrix.flags }}
|
scons platform=${{ matrix.platform }} target=release ${{ matrix.flags }}
|
||||||
|
|
||||||
|
- name: Build test and godot-cpp (release)
|
||||||
|
if: ${{ matrix.build-system == 'cmake' }}
|
||||||
|
run: |
|
||||||
|
cmake -DCMAKE_BUILD_TYPE=Release .
|
||||||
|
make -j $(nproc)
|
||||||
|
cd test
|
||||||
|
cmake -DCMAKE_BUILD_TYPE=Release .
|
||||||
|
make -j $(nproc)
|
||||||
|
|
||||||
- name: Run test GDNative library
|
- name: Run test GDNative library
|
||||||
if: ${{ matrix.platform == 'linux' || matrix.platform == 'osx' }}
|
if: ${{ matrix.platform == 'linux' || matrix.platform == 'osx' }}
|
||||||
run: |
|
run: |
|
||||||
|
|
|
@ -0,0 +1,152 @@
|
||||||
|
project(godot-cpp-test)
|
||||||
|
cmake_minimum_required(VERSION 3.6)
|
||||||
|
|
||||||
|
# Local dependency paths, adapt them to your setup
|
||||||
|
set(GODOT_HEADERS_PATH ../godot-headers/)
|
||||||
|
set(CPP_BINDINGS_PATH ../)
|
||||||
|
|
||||||
|
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
|
set(TARGET_SUFFIX linux)
|
||||||
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||||
|
set(TARGET_SUFFIX windown)
|
||||||
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||||
|
set(TARGET_SUFFIX osx)
|
||||||
|
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)
|
||||||
|
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++14
|
||||||
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
|
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 "/EHsc /WX") # /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)
|
||||||
|
|
||||||
|
# Disable conversion warning, trunkation, unreferenced var, signed missmatch
|
||||||
|
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /wd4244 /wd4305 /wd4101 /wd4018 /wd4267")
|
||||||
|
|
||||||
|
# Todo: Check if needed.
|
||||||
|
add_definitions(-DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_WARNINGS)
|
||||||
|
|
||||||
|
# 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()
|
||||||
|
|
||||||
|
#elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
|
# using Clang
|
||||||
|
#elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||||
|
# using GCC and maybe MinGW?
|
||||||
|
|
||||||
|
set(GODOT_LINKER_FLAGS "-static-libgcc -static-libstdc++ -Wl,-R,'$$ORIGIN'")
|
||||||
|
|
||||||
|
# Hmm.. maybe to strikt?
|
||||||
|
set(GODOT_COMPILE_FLAGS "-fPIC -g -Wwrite-strings")
|
||||||
|
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wchar-subscripts -Wcomment -Wdisabled-optimization")
|
||||||
|
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wformat -Wformat=2 -Wformat-security -Wformat-y2k")
|
||||||
|
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wimport -Winit-self -Winline -Winvalid-pch")
|
||||||
|
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wmissing-braces -Wmissing-format-attribute")
|
||||||
|
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wpointer-arith")
|
||||||
|
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wredundant-decls -Wreturn-type -Wsequence-point")
|
||||||
|
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wswitch -Wswitch-enum -Wtrigraphs")
|
||||||
|
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wuninitialized -Wunknown-pragmas -Wunreachable-code -Wunused-label")
|
||||||
|
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wunused-value -Wvariadic-macros -Wvolatile-register-var -Wno-error=attributes")
|
||||||
|
|
||||||
|
# -Wshadow -Wextra -Wall -Weffc++ -Wfloat-equal -Wstack-protector -Wunused-parameter -Wsign-compare -Wunused-variable -Wcast-align
|
||||||
|
# -Wunused-function -Wstrict-aliasing -Wstrict-aliasing=2 -Wmissing-field-initializers
|
||||||
|
|
||||||
|
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Android")
|
||||||
|
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wno-ignored-attributes")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
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()
|
||||||
|
|
||||||
|
# Get Sources
|
||||||
|
file(GLOB_RECURSE SOURCES src/*.c**)
|
||||||
|
file(GLOB_RECURSE HEADERS include/*.h**)
|
||||||
|
|
||||||
|
# Define our godot-cpp library
|
||||||
|
add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADERS})
|
||||||
|
|
||||||
|
target_include_directories(${PROJECT_NAME} SYSTEM
|
||||||
|
PRIVATE
|
||||||
|
${CPP_BINDINGS_PATH}/include
|
||||||
|
${CPP_BINDINGS_PATH}/include/core
|
||||||
|
${CPP_BINDINGS_PATH}/include/gen
|
||||||
|
${GODOT_HEADERS_PATH}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Create the correct name (godot.os.build_type.system_bits)
|
||||||
|
# Synchronized with godot-cpp's CMakeLists.txt
|
||||||
|
|
||||||
|
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)
|
||||||
|
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}$<$<NOT:$<PLATFORM_ID:Android>>:.${BITS}>
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
target_link_libraries(${PROJECT_NAME}
|
||||||
|
${CPP_BINDINGS_PATH}/bin/libgodot-cpp.${SYSTEM_NAME}.${BUILD_TYPE}$<$<NOT:$<PLATFORM_ID:Android>>:.${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.${TARGET_SUFFIX}.${BUILD_TYPE}$<$<NOT:$<PLATFORM_ID:Android>>:.${BITS}>")
|
||||||
|
|
Loading…
Reference in New Issue