Skip to content

Commit

Permalink
Build release archives with CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
sturnclaw committed Sep 8, 2023
1 parent b4c047f commit 228d7e9
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 19 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/build-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ concurrency:
cancel-in-progress: ${{ github.ref == 'refs/heads/master' }}

env:
RELEASE_TAG: ${{ github.ref_name }}
packages: >
mesa-common-dev
libfreeimage-dev
Expand Down Expand Up @@ -123,6 +124,54 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build-cmake:
runs-on: ubuntu-20.04

steps:
# Checkout the repository as $GITHUB_WORKSPACE
- uses: actions/checkout@v3

- name: Install Dependencies
run: |
sudo apt-fast update
sudo apt-fast install -y ${{ env.packages }}
- name: Setup CMake
run: |
cp scripts/CMakeBuildPresetsCI.json CMakeUserPresets.json
cmake --list-presets
cmake --preset linux-x64-release
- name: Build GCC
run: cmake --build ./build --target all

- name: Build Pioneer Data
run: cmake --build ./build --target build-data

- name: Run Tests
run: ./build/unittest

- name: Build Release
run: |
cmake --build ./build --target install
mkdir release && cd release
mv out/install/linux-x64-release "pioneer-linux-x64-$RELEASE_TAG"
tar -czf "pioneer-linux-x64-$RELEASE_TAG.tar.gz" "pioneer-linux-x64-$RELEASE_TAG"
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: Linux-Artifacts
path: release/pioneer-linux-x64-release-$RELEASE_TAG.tar.gz

- name: Upload Release Files
uses: softprops/action-gh-release@v1
if: ${{ github.event_name == 'release' }}
with:
files: release/pioneer-*.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build-clang:
runs-on: ubuntu-20.04

Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ codedoc/
nd/Data/
doxygen/html
doxygen/latex
/release
/out

.deps
*.swp
Expand Down Expand Up @@ -80,12 +82,12 @@ pioneer-*.tar.*
# meta-build tooling products etc. shouldn't be tracked
Makefile
Makefile.in
/release
Debug/
PreRelease/
Profile/
Release/
cmake-*
CMakeUserPresets.json
compile

# IDEs make their local configurations shouldn't be tracked
Expand Down
35 changes: 18 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,13 @@ if(POLICY CMP0072)
endif()

include(GNUInstallDirs)
include(cmake/InstallPioneer.cmake)

if (MINGW)
# Fix build errors on AppVeyor with MinGW due to a broken GLEW config script
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake/Modules)
endif (MINGW)

# We don't want a 'bin' folder on Windows
if (WIN32)
set(CMAKE_INSTALL_BINDIR ${CMAKE_INSTALL_PREFIX})
endif (WIN32)

# Put the output into the root dir so it can be run from Visual Studio
if (MSVC)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR})
Expand Down Expand Up @@ -107,13 +103,6 @@ endif()

string(TIMESTAMP PROJECT_VERSION "%Y%m%d")

if (NOT PIONEER_DATA_DIR)
set(PIONEER_DATA_DIR ${CMAKE_INSTALL_FULL_DATADIR}/pioneer/data CACHE PATH
"Path where game data will be installed" FORCE)
endif (NOT PIONEER_DATA_DIR)

file(TO_NATIVE_PATH ${PIONEER_DATA_DIR} _PIONEER_DATA_DIR)

if (MINGW)
# Enable PRIxYY macros on MinGW
add_definitions(-D__STDC_FORMAT_MACROS)
Expand Down Expand Up @@ -415,20 +404,32 @@ else (MODELCOMPILER)
endif(MODELCOMPILER)

install(TARGETS ${PROJECT_NAME} editor modelcompiler savegamedump
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
RUNTIME DESTINATION ${PIONEER_INSTALL_BINDIR}
)
install(DIRECTORY data/
DESTINATION ${PIONEER_DATA_DIR}
DESTINATION ${PIONEER_INSTALL_DATADIR}/data
REGEX "/models" EXCLUDE
PATTERN ".gitignore" EXCLUDE
PATTERN "listdata.*" EXCLUDE
PATTERN "Makefile.am" EXCLUDE
)
install(DIRECTORY data/models/
DESTINATION ${PIONEER_DATA_DIR}/models
DESTINATION ${PIONEER_INSTALL_DATADIR}/data/models
FILES_MATCHING PATTERN "*.sgm" PATTERN "*.dds" PATTERN "*.png"
)

list(APPEND install_txt
"AUTHORS.txt"
"Changelog.txt"
"Modelviewer.txt"
"Quickstart.txt"
"README.md")

install(FILES ${install_txt} DESTINATION ${PIONEER_INSTALL_DATADIR})

install(DIRECTORY ${CMAKE_SOURCE_DIR}/licenses
DESTINATION ${PIONEER_INSTALL_DATADIR})

if (WIN32)
configure_file(pioneer.iss.cmakein pioneer.iss @ONLY)
configure_file(CI/appveyor/msvc/publish.cmd.cmakein publish.cmd @ONLY)
Expand All @@ -440,7 +441,7 @@ if (WIN32)
add_custom_target(win-installer COMMAND ${ISCC} /Q pioneer.iss)
endif (WIN32)

if (UNIX)
if (UNIX AND NOT PIONEER_INSTALL_INPLACE)
set(PIONEER_DESKTOP_FILE ${CMAKE_BINARY_DIR}/metadata/net.pioneerspacesim.Pioneer.desktop)
configure_file(metadata/net.pioneerspacesim.Pioneer.desktop.cmakein ${PIONEER_DESKTOP_FILE} @ONLY)
install(FILES ${PIONEER_DESKTOP_FILE}
Expand All @@ -456,4 +457,4 @@ if (UNIX)
RENAME net.pioneerspacesim.Pioneer.png
)
endforeach()
endif (UNIX)
endif (UNIX AND NOT PIONEER_INSTALL_INPLACE)
2 changes: 1 addition & 1 deletion buildopts.h.cmakein
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#define PIONEER_EXTRAVERSION "@PROJECT_VERSION_GIT@"
#define PIONEER_VERSION "@PROJECT_VERSION@"
#define PIONEER_DATA_DIR "@_PIONEER_DATA_DIR@"
#define PIONEER_DATA_DIR "@PIONEER_DATA_RUNTIME_DIR@"
#define REMOTE_LUA_REPL_PORT @REMOTE_LUA_REPL_PORT@

#cmakedefine01 WITH_OBJECTVIEWER
Expand Down
34 changes: 34 additions & 0 deletions cmake/InstallPioneer.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Setup script for Pioneer installation paths

option(PIONEER_INSTALL_INPLACE "Should an in-place install be generated" OFF)

if (NOT PIONEER_INSTALL_DATADIR)
set(PIONEER_INSTALL_DATADIR ${CMAKE_INSTALL_DATADIR}/pioneer CACHE PATH
"Path where pioneer's data/ folder will be installed" FORCE)
endif (NOT PIONEER_INSTALL_DATADIR)

if (NOT PIONEER_INSTALL_BINDIR)
set(PIONEER_INSTALL_BINDIR ${CMAKE_INSTALL_BINDIR} CACHE PATH
"Path where Pioneer's executables will be installed" FORCE)
endif (NOT PIONEER_INSTALL_BINDIR)

# We don't want a 'bin' folder on Windows
if (WIN32)
set(CMAKE_INSTALL_BINDIR ${CMAKE_INSTALL_PREFIX})
endif (WIN32)

# If doing an in-place installation, everything is installed in the root of the prefix
if (PIONEER_INSTALL_INPLACE)
set(PIONEER_INSTALL_BINDIR ${CMAKE_INSTALL_PREFIX})
set(PIONEER_INSTALL_DATADIR ${CMAKE_INSTALL_PREFIX})
# don't load data from system-wide install
set(PIONEER_DATA_DIR "data")
endif (PIONEER_INSTALL_INPLACE)

# Expected location of game data
if (NOT PIONEER_DATA_DIR)
set(PIONEER_DATA_DIR ${CMAKE_INSTALL_FULL_DATADIR}/pioneer/data CACHE PATH
"Runtime path to load game data from" FORCE)
endif (NOT PIONEER_DATA_DIR)

file(TO_NATIVE_PATH ${PIONEER_DATA_DIR} PIONEER_DATA_RUNTIME_DIR)
42 changes: 42 additions & 0 deletions scripts/CMakeBuildPresetsCI.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"version": 2,
"configurePresets": [
{
"name": "linux-x64-release",
"displayName": "Linux x64 Release",
"description": "in-place installation target; Opt=yes; Profiler=no",
"binaryDir": "${sourceDir}/build/",
"generator": "Unix Makefiles",
"cacheVariables": {
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
"PIONEER_INSTALL_INPLACE": "1",
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
},
"vendor": {
"microsoft.com/VisualStudioSettings/CMake/1.0": {
"hostOS": [
"Linux"
]
}
}
},
{
"name": "linux-x64-release-global",
"displayName": "Linux x64 Release",
"description": "global installation target; Opt=yes; Profiler=no",
"binaryDir": "${sourceDir}/build/",
"generator": "Unix Makefiles",
"cacheVariables": {
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
},
"vendor": {
"microsoft.com/VisualStudioSettings/CMake/1.0": {
"hostOS": [
"Linux"
]
}
}
}
]
}

0 comments on commit 228d7e9

Please sign in to comment.