Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
99 changes: 85 additions & 14 deletions .github/workflows/compilation-rtype.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: Compilation
on:
push:
branches: ["dev", "devops"]
tags:
- "*"
pull_request:
branches: ["main", "dev"]

Expand All @@ -11,8 +13,7 @@ jobs:
runs-on: ${{ matrix.os }}

strategy:
#TODO Consider changing this to true when your workflow is stable.
fail-fast: false
fail-fast: true

matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
Expand All @@ -25,9 +26,6 @@ jobs:
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
- os: macos-latest
c_compiler: clang
cpp_compiler: clang++
Expand All @@ -36,6 +34,8 @@ jobs:
c_compiler: gcc
- os: windows-latest
c_compiler: clang
- os: ubuntu-latest
c_compiler: clang
- os: ubuntu-latest
c_compiler: cl
- os: macos-latest
Expand All @@ -54,35 +54,81 @@ jobs:
if: matrix.os == 'ubuntu-latest'
run: sudo apt install libxinerama-dev libxcursor-dev xorg-dev libglu1-mesa-dev pkg-config -y

- name: Install vcpkg and dependencies for Windows
if: matrix.os == 'windows-latest'
run: |
git clone https://github.com/microsoft/vcpkg.git
.\vcpkg\bootstrap-vcpkg.bat
.\vcpkg\vcpkg install glfw3:x64-windows

- name: Set reusable strings
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"

- name: Cache build directory
id: cache-build
uses: actions/cache@v4
with:
path: build
key: ${{ runner.os }}-build-${{ hashFiles('CMakeLists.txt', 'overlay-ports/gengine/portfile.cmake') }}
restore-keys: |
${{ runner.os }}-build-

- name: Configure CMake
if: steps.cache-build.outputs.cache-hit != 'true'
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCMAKE_CXX_FLAGS="-std=c++20"
-S ${{ github.workspace }}

# Since metadata is not cached, we need to reconfigure cmake but without triggering a vcpkg pull
- name: Configure CMake CACHED
if: steps.cache-build.outputs.cache-hit == 'true'
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DVCPKG_SHOULD_NOT_UPDATE=TRUE
-S ${{ github.workspace }}

- name: Build
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --parallel 8

- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: ctest --build-config ${{ matrix.build_type }}

- name: Build with CPack
if: (github.ref == 'refs/heads/devops') || startsWith(github.ref, 'refs/tags/')
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --target package

- name: Upload CPack artifacts
if: (github.ref == 'refs/heads/devops') || startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-artifacts
path: |
${{ steps.strings.outputs.build-output-dir }}/*.tar.gz
${{ steps.strings.outputs.build-output-dir }}/*.exe
${{ steps.strings.outputs.build-output-dir }}/*.dmg

# the cache is mainly for cmake, and the timestamps don't match anyway. maybe next time we'll use another cache handler
- name: Clean the cmake build directory Windows
if: matrix.os == 'windows-latest' && steps.cache-build.outputs.cache-hit != 'true'
run: |
cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --target clean
Get-ChildItem -Path build/vcpkg/* -Exclude 'downloads', 'installed', 'scripts', 'triplets' | Remove-Item -Recurse -Force
Remove-Item -Recurse -Force build/*.exe
if (Test-Path build/_CPack_Packages) {
Remove-Item -Recurse -Force build/_CPack_Packages
}
Remove-Item -Recurse -Force build/Release/*.dll

- name: Clean the cmake build directory UNIX like
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' && steps.cache-build.outputs.cache-hit != 'true'
run: |
cmake --build ${{ steps.strings.outputs.build-output-dir }} --target clean
find build/.vcpkg -mindepth 1 -maxdepth 1 ! -name 'downloads' ! -name 'installed' ! -name 'scripts' ! -name 'triplets' -exec rm -rf {} +
rm -rf build/*.tar.gz build/*.dmg build/_CPack_Packages

cleanup:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -114,3 +160,28 @@ jobs:
clang-format --version
files=$(find . -name "*.hpp" -o -name "*.cpp" -o -name "*.inl")
clang-format -Werror -dry-run $files

publish:
if: (github.ref == 'refs/heads/devops') || startsWith(github.ref, 'refs/tags/')
needs: [build_rtype, beautify]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Create artifacts directory
run: mkdir -p artifacts

- name: Download all release artifacts
uses: actions/download-artifact@v4
with:
path: artifacts/
merge-multiple: true

- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: artifacts/*
tag: ${{ github.ref }}
overwrite: true
file_glob: true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ build_includes
r-type_client
r-type_server

## Score
score.txt

## Config
.editorconfig

Expand Down
36 changes: 33 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS NO)

include(cmake/automate-vcpkg-gengine.cmake)
vcpkg_bootstrap()
vcpkg_install_gengine()
if (DEFINED CMAKE_GENGINE_PATH)
include(cmake/custom-gengine.cmake)
else()
include(cmake/automate-vcpkg-gengine.cmake)
vcpkg_bootstrap()
if(NOT VCPKG_SHOULD_NOT_UPDATE)
vcpkg_install_gengine()
endif()
endif()

include_directories(include)

Expand All @@ -16,9 +22,33 @@ file(GLOB_RECURSE SOURCES source/*.cpp)
add_executable(r-type_server ${SOURCES})
add_executable(r-type_client ${SOURCES})

if (NOT DEFINED CMAKE_GENGINE_PATH)
find_package(GEngine CONFIG REQUIRED)
target_link_libraries(r-type_server PRIVATE GEngine)
target_link_libraries(r-type_client PRIVATE GEngine)
else()
target_link_libraries(r-type_server PRIVATE raylib nlohmann_json::nlohmann_json stduuid ${GEngine_LIB})
target_link_libraries(r-type_client PRIVATE raylib nlohmann_json::nlohmann_json stduuid ${GEngine_LIB})
endif()

target_compile_definitions(r-type_server PRIVATE GEngine_Server)
target_compile_definitions(r-type_client PRIVATE GEngine_Client)

# This is mostly for the CD pipeline, it uses the VCPKG installed Gengine
if (CMAKE_BUILD_TYPE STREQUAL "Release" AND NOT DEFINED CMAKE_GENGINE_PATH)
install(TARGETS r-type_server r-type_client
RUNTIME DESTINATION bin
LIBRARY DESTINATION bin
ARCHIVE DESTINATION bin
)

if(UNIX)
set_target_properties(r-type_server r-type_client PROPERTIES INSTALL_RPATH "$ORIGIN")
endif()

install(DIRECTORY assets/ DESTINATION assets)
install(DIRECTORY config/ DESTINATION config)
install(FILES r-type.json DESTINATION .)

include(cmake/pack.cmake)
endif()
80 changes: 0 additions & 80 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,61 +31,6 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "release_armv8",
"inherits": "release",
"architecture": {
"value": "armv8",
"strategy": "external"
},
"cacheVariables": {
"ARCHITECTURE": "arm64"
}
},
{
"name": "debug_armv8",
"inherits": "debug",
"architecture": {
"value": "armv8",
"strategy": "external"
},
"cacheVariables": {
"ARCHITECTURE": "arm64"
}
},
{
"name": "release_armv7",
"inherits": "release",
"architecture": {
"value": "armv7",
"strategy": "external"
},
"cacheVariables": {
"ARCHITECTURE": "arm32"
}
},
{
"name": "debug_armv7",
"inherits": "debug",
"architecture": {
"value": "armv7",
"strategy": "external"
},
"cacheVariables": {
"ARCHITECTURE": "arm32"
}
},
{
"name": "debug_x86",
"inherits": "default",
"architecture": {
"value": "x86",
"strategy": "external"
},
"cacheVariables": {
"ARCHITECTURE": "x86"
}
}
],
"buildPresets": [
Expand All @@ -103,31 +48,6 @@
"name": "debug",
"inherits": "default",
"configurePreset": "debug"
},
{
"name": "release_armv8",
"inherits": "default",
"configurePreset": "release_armv8"
},
{
"name": "debug_armv8",
"inherits": "default",
"configurePreset": "debug_armv8"
},
{
"name": "release_armv7",
"inherits": "default",
"configurePreset": "release_armv7"
},
{
"name": "debug_armv7",
"inherits": "default",
"configurePreset": "debug_armv7"
},
{
"name": "debug_x86",
"inherits": "default",
"configurePreset": "debug_x86"
}
]
}
28 changes: 28 additions & 0 deletions Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>R-Type</string>
<key>CFBundleIdentifier</key>
<string>com.ygnirtype.rtype</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>R-Type</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1.0.0</string>
<key>LSMinimumSystemVersion</key>
<string>10.10</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2024 YGNI-RType</string>
<key>CFBundleIconFile</key>
<string>icon.icns</string>
</dict>
</plist>
File renamed without changes.
Binary file added assets/icon.icns
Binary file not shown.
Binary file added assets/icon.ico
Binary file not shown.
16 changes: 0 additions & 16 deletions cmake/automate-vcpkg-gengine.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,6 @@ else()
set(VCPKG_FALLBACK_ROOT ${CMAKE_CURRENT_BINARY_DIR}/.vcpkg CACHE STRING "vcpkg configuration directory to use if vcpkg was not installed on the system before")
endif()

# On Windows, Vcpkg defaults to x86, even on x64 systems. If we're
# doing a 64-bit build, we need to fix that.
if (WIN32)
# Since the compiler checks haven't run yet, we need to figure
# out the value of CMAKE_SIZEOF_VOID_P ourselfs

include(CheckTypeSize)
enable_language(C)
check_type_size("void*" SIZEOF_VOID_P BUILTIN_TYPES_ONLY)

if (SIZEOF_VOID_P EQUAL 8)
message(STATUS "Using Vcpkg triplet 'x64-windows'")
set(VCPKG_TRIPLET x64-windows)
endif()
endif()

if(NOT DEFINED VCPKG_ROOT)
if(NOT DEFINED ENV{VCPKG_ROOT})
set(VCPKG_ROOT ${VCPKG_FALLBACK_ROOT})
Expand Down
Loading