From 7eaed871a6b5aaa5bda7ddcbeb30e05486c4a4eb Mon Sep 17 00:00:00 2001 From: h67ma Date: Thu, 7 Dec 2023 19:58:05 +0100 Subject: [PATCH 1/9] build: Hide console window on Windows Add the WIN32 executable flag and link to sfml-main on Windows, in order to prevent console window from appearing in addition to the regular (graphical) window. Signed-off-by: h67ma --- src/CMakeLists.txt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index faa0a84..e5a3a5c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,10 +1,16 @@ # SPDX-License-Identifier: GPL-3.0-only # -# (c) 2022 h67ma +# (c) 2022-2023 h67ma file(GLOB_RECURSE SOURCES *.cpp) -add_executable(foerr ${SOURCES}) +if(WIN32) + # WIN32 flag prevents the console window from showing up alongside graphical window + # see https://www.sfml-dev.org/faq.php#tr-win-console + add_executable(foerr WIN32 ${SOURCES}) +else() + add_executable(foerr ${SOURCES}) +endif() if(WIN32) # set a tolerable warning level @@ -16,6 +22,11 @@ else() endif() target_link_libraries(foerr PRIVATE sfml-graphics sfml-window sfml-system sfml-audio nlohmann_json) +if(WIN32) + # needed for the WIN32 flag + # see https://www.sfml-dev.org/faq.php#tr-win-console + target_link_libraries(foerr PRIVATE sfml-main) +endif() install(TARGETS foerr DESTINATION foerr) install(DIRECTORY "${PROJECT_BINARY_DIR}/../res" DESTINATION foerr) From 4198c52bd441f1f3e20f9b7ab47a18f7db75a165 Mon Sep 17 00:00:00 2001 From: h67ma Date: Thu, 7 Dec 2023 22:42:50 +0100 Subject: [PATCH 2/9] toolz: Add make_icons script Create a script for converting .svg files into .ico files. This will be useful for Windows bin and installer icon. Signed-off-by: h67ma --- toolz/make_icons.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 toolz/make_icons.sh diff --git a/toolz/make_icons.sh b/toolz/make_icons.sh new file mode 100755 index 0000000..349fe08 --- /dev/null +++ b/toolz/make_icons.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-3.0-only +# +# (c) 2023 h67ma + +# generates ico files from svgs +# run from toolz dir +# svgs must be in res/ico dir + +for FILE in ../res/ico/*.svg; do + NAME="$(basename $FILE .svg)" + + for SIZE in 16 32 48 64; do + inkscape -w $SIZE -h $SIZE -o "${NAME}_${SIZE}.png" $FILE + done + + icotool -c -o "../res/ico/${NAME}.ico" "${NAME}"_{16,32,48,64}.png + rm -f "${NAME}"_{16,32,48,64}.png +done From c4fc17be93c22b8c8e8cbce44467d1840ea230c6 Mon Sep 17 00:00:00 2001 From: h67ma Date: Thu, 7 Dec 2023 22:48:04 +0100 Subject: [PATCH 3/9] build: Add icon for Windows binary Create a simple vector image to use as icon, based on the one used by Remains (but flat). Generate .ico file from it. Remove *.svg from .gitignore to track the newly created svg file. Finally, hook up the icon to CMake so it attaches the icon to foerr.exe. Signed-off-by: h67ma --- .gitignore | 1 - res/ico/foerr.ico | Bin 0 -> 32038 bytes res/ico/foerr.svg | 90 +++++++++++++++++++++++++++++++++++++++++++++ src/CMakeLists.txt | 2 +- src/exe_icon.rc | 1 + 5 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 res/ico/foerr.ico create mode 100644 res/ico/foerr.svg create mode 100644 src/exe_icon.rc diff --git a/.gitignore b/.gitignore index 1f32428..1011558 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,4 @@ build/ *.gch *.log *.o -*.svg *.tmp diff --git a/res/ico/foerr.ico b/res/ico/foerr.ico new file mode 100644 index 0000000000000000000000000000000000000000..4e50eb821ae13f51134d23c126dfec6de081e5c4 GIT binary patch literal 32038 zcmeHw30PCt)@b-`Yj6L)+S}XP796l@M|*qiwUdGpra&e@ATlV5Oah8B1VtQ(0)oth z83#ZCm0E{7Fo-~FYilo60hv@3+uGq)Esg~VS#Rx=oNyA75EXCzzW2`e?X11`*?X_G z_H_2J)(VSd#Cn4D{PQe?6Ip>zuvi=xi#2h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|=`hq!^d@cXEqAMUSL%wP?c?Qi86ru=v&eT1lXpt* zmQKKc$UF6)Im|kkI(NnIBg4P+HUrf|duNDd`~~$c>oj>+hSBaW+sz?*^UJ7Te~Q7o zN^e&i0myeFlXv2OXYR^jZ6h04Ki9S4e9$=jUz^!FcvtAp+OzNRf@6PV@UEu!s|_!n z9dFU(AOGVS9rPM z5H_r>t^dXm*k2i@4$cyN`XQOMMBw_rgzo$1-ul;mWG@&NlL#JRu^VUa6GNepm%g25BhAf(Q0!7Q$59J-#3MQzVJAQ63yz1)>QEG{r?O7==T{ekG}VLd3i4(|CC<8 zmEYP9Ri7vAj*jq0^x)rI<^g`i?$mv#SqdNCTqW$9>_5MJyz}yOlx3+vd4?Q)ct-La z*%Kn)7l;n}NR&(dg9Gc}P_QInil$r!%|Ge$A8!;=vJvxk+MSzKWwO+wa_kJ$)qS3Y z_VTFz#ktS_vKR^4N4yMTw@4Tfg>8RZ(HF4)<6QTu?;?0B$`N=uLRr90XZgQUEYG|r zof$C;_1j1CUUbCydB6fG`7~j~I;?|JCQf1ZCb$Q}Ya#Ca@5I@5dzCu;?ou)9uz8h< zr#b3qPpugKzqB5ZjK?Dz_HTCm-=CdT`^wwIHUQ`F>l=Od@LEtN#%K0X>pwOukepGYc#!)^(4FA-aEuZ@ zHChqR8ZD#Vv&Nv!hZr + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e5a3a5c..0be7d34 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,7 +7,7 @@ file(GLOB_RECURSE SOURCES *.cpp) if(WIN32) # WIN32 flag prevents the console window from showing up alongside graphical window # see https://www.sfml-dev.org/faq.php#tr-win-console - add_executable(foerr WIN32 ${SOURCES}) + add_executable(foerr WIN32 ${SOURCES} exe_icon.rc) else() add_executable(foerr ${SOURCES}) endif() diff --git a/src/exe_icon.rc b/src/exe_icon.rc new file mode 100644 index 0000000..279ac78 --- /dev/null +++ b/src/exe_icon.rc @@ -0,0 +1 @@ +IDI_ICON1 ICON DISCARDABLE "../res/ico/foerr.ico" From ca53e7f99949fda0169814c42f5217e7b1054eff Mon Sep 17 00:00:00 2001 From: h67ma Date: Thu, 7 Dec 2023 22:51:46 +0100 Subject: [PATCH 4/9] docs: Add res files info Add recommendations for adding new resources to CONTRIBUTING.md. Signed-off-by: h67ma --- CONTRIBUTING.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0171308..c07e391 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -58,6 +58,13 @@ run Installed hook can be skipped with `git commit --no-verify`. +# Resources +All resources (images, audio, json, etc.) must be located in the `res` directory. Note that everything inside `res` +is distributed under a different license than code (see `res/LICENSE.txt`). + +In case of files that can be compressed/optimized without sacrificing quality, it is recommended to do so. For example, +for `.svg` files it is recommended to run them through `scour`. + # Commits Commits should be atomic. Whenever possible, don't mix two new features in one commit. When renaming/refactoring a large chunk of code, don't do it alongside other changes - rather split it off into From 71feb894ac71d138bcdefc15839bf8ef59d4c8c4 Mon Sep 17 00:00:00 2001 From: h67ma Date: Thu, 7 Dec 2023 23:05:26 +0100 Subject: [PATCH 5/9] build: Polish cmake install Add missing install() commands for everything actually required to run the game. This includes the binary, res and fonts directories, license file, and (only on Windows) openal dll. Improve documentation regarding building and installing. Also remove the -j flag from build instructions to make it OS-agnostic. Signed-off-by: h67ma --- CMakeLists.txt | 17 +++++++++++++++-- README.md | 9 ++++++--- deps/sfml/CMakeLists.txt | 2 -- src/CMakeLists.txt | 4 +--- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bf14b51..a4e2eae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-3.0-only # -# (c) 2022 h67ma +# (c) 2022-2023 h67ma cmake_minimum_required(VERSION 3.15) set(CMAKE_CXX_STANDARD 17) @@ -15,6 +15,19 @@ if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") cmake_policy(SET CMP0135 NEW) endif() -add_subdirectory(deps/sfml) +# EXCLUDE_FROM_ALL skips SFML's files from being installed. +# we don't need them, also some of them want to install to system paths and require superuser privileges to do so +add_subdirectory(deps/sfml EXCLUDE_FROM_ALL) + add_subdirectory(deps/nlohmann_json) add_subdirectory(src) + +install(DIRECTORY res DESTINATION ".") +install(DIRECTORY fonts DESTINATION ".") +install(FILES LICENSE DESTINATION ".") + +if(WIN32) + # seems a bit hacky but I guess it works? + # TODO detect x86/x64 and select dll from proper path + install(FILES "${PROJECT_BINARY_DIR}/_deps/sfml-src/extlibs/bin/x64/openal32.dll" DESTINATION ".") +endif() diff --git a/README.md b/README.md index 6a2901c..7a815de 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ sudo apt install -y \ ``` cd $PROJECT_ROOT cmake -DCMAKE_BUILD_TYPE=$TYPE -B build -cmake --build . -j`nproc` --config $TYPE +cmake --build build --config $TYPE ``` Where `TYPE` can be either `Debug` or `Release`. @@ -98,6 +98,9 @@ cmake --build . --target clean # Install ``` -cd build -cmake --install . --config Release --prefix $PATH_TO_INSTALL +cd $PROJECT_ROOT +cmake -DCMAKE_BUILD_TYPE=Release -B build +cmake --build build --config Release +cmake --install build --config Release --prefix $PATH_TO_INSTALL ``` +**Warning**: files will be installed **directly** to the specified path, i.e. without creating a subdirectory. diff --git a/deps/sfml/CMakeLists.txt b/deps/sfml/CMakeLists.txt index 34e0952..f371265 100644 --- a/deps/sfml/CMakeLists.txt +++ b/deps/sfml/CMakeLists.txt @@ -26,5 +26,3 @@ if(WIN32) target_compile_options(sfml-system PRIVATE /EHsc) target_compile_options(sfml-window PRIVATE /EHsc) endif() - -# TODO copy openal.dll from sfml-src/extlibs/bin/{x64/x86} to root dir or somehow add it to PATH diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0be7d34..5e99594 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -28,9 +28,7 @@ if(WIN32) target_link_libraries(foerr PRIVATE sfml-main) endif() -install(TARGETS foerr DESTINATION foerr) -install(DIRECTORY "${PROJECT_BINARY_DIR}/../res" DESTINATION foerr) -# TODO? on binbows also copy openal to install dir +install(TARGETS foerr DESTINATION ".") # add version from git-describe # based on https://github.com/nocnokneo/cmake-git-versioning-example From acaad650bda3448831d3503fdb2e921ade2355d4 Mon Sep 17 00:00:00 2001 From: h67ma Date: Thu, 7 Dec 2023 23:16:09 +0100 Subject: [PATCH 6/9] build: Make git version script more generic Put the bulk of git version script into a reusable function (will be useful e.g. for packaging). To use this function, include CMakeGitVersion.cmake. Output will be in the $GIT_VERSION variable. "gitversion" target doesn't require any changes. Signed-off-by: h67ma --- CMakeGitVersion.cmake | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/CMakeGitVersion.cmake b/CMakeGitVersion.cmake index 37ba202..53aeb48 100644 --- a/CMakeGitVersion.cmake +++ b/CMakeGitVersion.cmake @@ -1,21 +1,28 @@ # based on https://github.com/nocnokneo/cmake-git-versioning-example -if(GIT_EXECUTABLE) - get_filename_component(SRC_DIR ${SRC} DIRECTORY) - execute_process( - COMMAND ${GIT_EXECUTABLE} describe --tags --dirty --match "v*" - WORKING_DIRECTORY ${SRC_DIR} - OUTPUT_VARIABLE GIT_DESCRIBE_VERSION - RESULT_VARIABLE GIT_DESCRIBE_ERROR_CODE - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - if(NOT GIT_DESCRIBE_ERROR_CODE) - set(GIT_VERSION ${GIT_DESCRIBE_VERSION}) +function(get_git_version GIT_EXECUTABLE SRC_DIR) + if(GIT_EXECUTABLE) + execute_process( + COMMAND ${GIT_EXECUTABLE} describe --tags --dirty --match "v*" + WORKING_DIRECTORY ${SRC_DIR} + OUTPUT_VARIABLE GIT_DESCRIBE_VERSION + RESULT_VARIABLE GIT_DESCRIBE_ERROR_CODE + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(NOT GIT_DESCRIBE_ERROR_CODE) + set(_GIT_VERSION ${GIT_DESCRIBE_VERSION}) + endif() endif() -endif() -if(NOT DEFINED GIT_VERSION) - set(GIT_VERSION v0.0.0-unknown) - message(WARNING "Failed to determine GIT_VERSION. Using default version: \"${GIT_VERSION}\".") -endif() + if(NOT DEFINED _GIT_VERSION) + set(_GIT_VERSION v0.0.0-unknown) + message(WARNING "Failed to determine GIT_VERSION. Using default version: \"${_GIT_VERSION}\".") + endif() -configure_file(${SRC} ${DST} @ONLY) + set(GIT_VERSION ${_GIT_VERSION} PARENT_SCOPE) +endfunction() + +if(DEFINED SRC) + get_filename_component(SRC_DIR ${SRC} DIRECTORY) + get_git_version(${GIT_EXECUTABLE} ${SRC_DIR}) + configure_file(${SRC} ${DST} @ONLY) +endif() From 42c6c6c16a4972ff92ed2020e4a9f3135a47cbe9 Mon Sep 17 00:00:00 2001 From: h67ma Date: Thu, 7 Dec 2023 23:26:48 +0100 Subject: [PATCH 7/9] docs: Add Windows requirements for running Add Visual C++ Redistributable dependency for running the game on Windows. Add headers to discern dependencies for building or just running. Signed-off-by: h67ma --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 7a815de..212c918 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ Features currently **outside** project scope: # Installing dependencies ## GNU/Linux +### Building Refer to [SFML documentation](https://www.sfml-dev.org/tutorials/2.6/compile-with-cmake.php#installing-dependencies) for satisfying SFML dependencies. On most Debian-based systems the following should be enough: ``` @@ -63,6 +64,11 @@ sudo apt install -y \ ``` ## Windows +### Running +Download and install latest +[Microsoft Visual C++ Redistributable](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist). + +### Building 1. Download Visual Studio Community installer 2. Select individual components to install (minimal): * Compilers, build tools, and runtimes -> MSVC [...] C++ x64/86 build tools (latest) From 845ff4dc2dd7d722676fd8f87ae9688aa6d3ff65 Mon Sep 17 00:00:00 2001 From: h67ma Date: Thu, 7 Dec 2023 23:31:35 +0100 Subject: [PATCH 8/9] build: Create CPack configuration Set CPack variables and include CPack to enable packaging - currently tgz (GNU/Linux) and NSIS (Windows) are enabled. Update .gitignore to include CPack work directory and generated packages. Add packaging instructions and dependencies to README. Signed-off-by: h67ma --- .gitignore | 4 +++- CMakeLists.txt | 30 +++++++++++++++++++++++++++++- README.md | 12 ++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 1011558..e43e0dc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -foerr .cache/ .vscode/ build/ @@ -7,3 +6,6 @@ build/ *.log *.o *.tmp +_CPack_Packages/ +foerr-*.tar.gz +foerr-*.exe diff --git a/CMakeLists.txt b/CMakeLists.txt index a4e2eae..48eea19 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,8 +5,9 @@ cmake_minimum_required(VERSION 3.15) set(CMAKE_CXX_STANDARD 17) set(CXX_STANDARD_REQUIRED ON) +include(CMakeGitVersion.cmake) -project(foerr_game +project(foerr LANGUAGES CXX ) @@ -31,3 +32,30 @@ if(WIN32) # TODO detect x86/x64 and select dll from proper path install(FILES "${PROJECT_BINARY_DIR}/_deps/sfml-src/extlibs/bin/x64/openal32.dll" DESTINATION ".") endif() + +set(CPACK_BINARY_STGZ "OFF") +set(CPACK_BINARY_TZ "OFF") + +if(WIN32) + set(CPACK_BINARY_NSIS "ON") + set(CPACK_NSIS_MUI_ICON "${CMAKE_SOURCE_DIR}/res/ico/foerr.ico") + set(CPACK_NSIS_INSTALLED_ICON_NAME "foerr.exe") + set(CPACK_NSIS_PACKAGE_NAME "FoE: Remains of Remains") + set(CPACK_NSIS_EXECUTABLES_DIRECTORY ".") + set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON") +elseif(UNIX) + set(CPACK_BINARY_TGZ "ON") +endif() + +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE") +set(CPACK_PACKAGE_INSTALL_DIRECTORY "foerr") +set(CPACK_MONOLITHIC_INSTALL "ON") + +# ':' not allowed in shortcut name as it will be a file name. +# for some reason these shortcuts remain in "Start Menu" after uninstall +set(CPACK_PACKAGE_EXECUTABLES "foerr" "FoE Remains of Remains") + +get_git_version(${GIT_EXECUTABLE} ${CMAKE_SOURCE_DIR}) +set(CPACK_PACKAGE_VERSION ${GIT_VERSION}) + +include(CPack) diff --git a/README.md b/README.md index 212c918..d9eaf9b 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,9 @@ Download and install latest * Compilers, build tools, and runtimes -> MSVC [...] C++ x64/86 build tools (latest) * SDKs, libraries, and frameworks -> Windows [...] SDK (latest one) +### Packaging +Download and install [NSIS](https://nsis.sourceforge.io). + # Build ``` cd $PROJECT_ROOT @@ -110,3 +113,12 @@ cmake --build build --config Release cmake --install build --config Release --prefix $PATH_TO_INSTALL ``` **Warning**: files will be installed **directly** to the specified path, i.e. without creating a subdirectory. + +# Package +``` +cd $PROJECT_ROOT +cmake -DCMAKE_BUILD_TYPE=Release -B build +cmake --build build --config Release +cpack --config build/CPackConfig.cmake +``` +This will generate a tarball on GNU/Linux and NSIS installer on Windows. From 2f959e032fcd6cf2ca6d94c7c8eeb793f01abbb6 Mon Sep 17 00:00:00 2001 From: h67ma Date: Fri, 8 Dec 2023 00:17:29 +0100 Subject: [PATCH 9/9] github: Create CPack action Create an action which builds, packages, and uploads packages so they can be (manually) attached to a release. NSIS dependency installation based on [1]. [1] https://github.com/NSIS-Dev/ci-examples/blob/main/.github/workflows/windows-latest.yml Signed-off-by: h67ma --- .github/workflows/package.yml | 64 +++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .github/workflows/package.yml diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml new file mode 100644 index 0000000..78d4c43 --- /dev/null +++ b/.github/workflows/package.yml @@ -0,0 +1,64 @@ +name: CPack and upload + +on: + workflow_dispatch: + +jobs: + build: + runs-on: ${{matrix.os}} + + strategy: + fail-fast: true + + matrix: + os: [ubuntu-latest, windows-latest] + build_type: [Release] + include: + - os: windows-latest + c_compiler: cl + cpp_compiler: cl + - os: ubuntu-latest + c_compiler: gcc + cpp_compiler: g++ + + steps: + - name: Install Linux dependencies + if: ${{ matrix.os == 'ubuntu-latest' }} + run: | + sudo apt update + sudo apt install -y libfreetype-dev libx11-dev libxrandr-dev libudev-dev libgl-dev libflac-dev libvorbis-dev libopenal-dev libxcursor-dev + + - name: Install Windows dependencies + if: ${{ matrix.os == 'windows-latest' }} + run: | + iwr -useb get.scoop.sh -outfile 'install.ps1' + .\install.ps1 -RunAsAdmin + scoop update + scoop bucket add extras + scoop install nsis + + - name: Checkout + uses: actions/checkout@v4 + + - name: Configure + run: > + cmake -B ${{github.workspace}}/build + -DCMAKE_CXX_COMPILER=${{matrix.cpp_compiler}} + -DCMAKE_C_COMPILER=${{matrix.c_compiler}} + -DCMAKE_BUILD_TYPE=${{matrix.build_type}} + -S ${{github.workspace}} + + - name: Build + run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} + + - name: Package + run: cpack --config ${{github.workspace}}/build/CPackConfig.cmake + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: cpacked + path: | + ${{github.workspace}}/foerr-*.tar.gz + ${{github.workspace}}/foerr-*.exe + if-no-files-found: ignore