diff --git a/.github/workflows/main-build.yml b/.github/workflows/main-build.yml new file mode 100644 index 000000000..e27422951 --- /dev/null +++ b/.github/workflows/main-build.yml @@ -0,0 +1,86 @@ +name: Main Build +on: + push: + pull_request: +permissions: + contents: read +jobs: + build: + name: ${{matrix.os}} - ${{matrix.arch}} + runs-on: ${{matrix.runner}} + strategy: + fail-fast: false + matrix: + include: + # Linux builds + - os: linux + arch: x86-64 + runner: ubuntu-22.04 + toolchain_file: 'x86-64-gcc.cmake' + extra_packages: 'gcc g++ mesa-utils mesa-common-dev xorg-dev libxrandr-dev' + + - os: linux + arch: i686 + runner: ubuntu-22.04 + toolchain_file: 'i686-gcc.cmake' + extra_packages: 'gcc-multilib g++-multilib mesa-utils mesa-common-dev:i386 xorg-dev libxrandr-dev' + + # Windows builds + - os: mswin + arch: x86-64 + runner: ubuntu-22.04 + toolchain_file: 'x86-64-w64-mingw32.cmake' + extra_packages: 'gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64' + + - os: mswin + arch: i686 + runner: ubuntu-22.04 + toolchain_file: 'i686-w64-mingw32.cmake' + extra_packages: 'gcc-mingw-w64-i686 g++-mingw-w64-i686' + + # macOS builds (native compilation) + # Disabled build because of alignment issues during linking. + #- os: macos + # arch: arm64 + # runner: macos-14 + steps: + - uses: actions/checkout@v7 + + - name: Install build dependencies (Linux) + if: runner.os == 'linux' + run: | + sudo dpkg --add-architecture i386 + sudo apt-get update + sudo apt-get install -y cmake ${{ matrix.extra_packages }} + + - name: Install build dependencies (macOS) + if: runner.os == 'macos' + run: | + brew uninstall cmake + wget -q https://github.com/Kitware/CMake/releases/download/v3.31.12/cmake-3.31.12-macos-universal.tar.gz + tar -xzf cmake-3.31.12-macos-universal.tar.gz + sudo cp -r cmake-3.31.12-macos-universal/CMake.app /Applications/ + echo "/Applications/CMake.app/Contents/bin" >> $GITHUB_PATH + brew install ninja + + - name: Generate build files + run: > + cmake + -B build + -S . + -G Ninja + -DCMAKE_BUILD_TYPE=RelWithDebInfo + ${{ matrix.toolchain_file && format('-DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/{0}', matrix.toolchain_file) || '' }} + + - name: Build + run: cmake --build build -j $(sysctl -n hw.logicalcpu || nproc) + + - name: Prepare distribution package + run: cmake --install build --prefix dist + + - name: Upload Build Artifacts + uses: actions/upload-artifact@v7 + with: + name: systemshock-${{ matrix.os }}-${{ matrix.arch }} + path: dist/ + if-no-files-found: warn diff --git a/.gitignore b/.gitignore index 75db28936..b36829c79 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,7 @@ savgam*.dat .project .cproject .DS_Store + +# CLion +cmake-build-* +.idea diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8f5cd7a08..000000000 --- a/.travis.yml +++ /dev/null @@ -1,83 +0,0 @@ -language: c - -notifications: - email: false - -matrix: - include: - - os: linux - dist: bionic - sudo: required - env: - - SDL2_LIB=BUNDLED - - SDL2_MIXER_LIB=BUNDLED - - FLUIDSYNTH_LIB=BUNDLED - - BITS=64 - addons: - apt: - packages: - - cmake-data cmake libglu1-mesa-dev libgl1-mesa-dev # libfluidsynth-dev libsdl2-dev libsdl2-mixer-dev - compiler: gcc - - os: linux - dist: trusty - sudo: required - env: - - SDL2_LIB=BUNDLED - - SDL2_MIXER_LIB=BUNDLED - - FLUIDSYNTH_LIB=BUNDLED - - CMAKE_LIBRARY_PATH=/usr/lib/i386-linux-gnu - - BITS=32 - before_script: - - cp ./CMakeLists.32bit.txt ./CMakeLists.txt - addons: - apt: - packages: - - cmake-data cmake libx32gcc-4.8-dev libc6-dev-i386 gcc-multilib g++-multilib libglu1-mesa-dev:i386 libgl1-mesa-dev:i386 - compiler: gcc - - os: osx - compiler: clang - env: - - SDL2_LIB=BUNDLED - - SDL2_MIXER_LIB=BUNDLED - - FLUIDSYNTH_LIB=OFF # Bundled lib failed to compile - - BITS=64 - - os: osx - compiler: gcc - env: - - SDL2_LIB=BUNDLED - - SDL2_MIXER_LIB=BUNDLED - - FLUIDSYNTH_LIB=OFF # Bundled lib failed to compile - - BITS=64 - -script: - - chmod a+rx ./osx-linux/*.sh - - sudo TRAVIS=$TRAVIS ./osx-linux/install_${BITS}bit_sdl.sh - - cmake -DENABLE_SDL2=${SDL2_LIB} -DENABLE_SOUND=${SDL2_MIXER_LIB} -DENABLE_FLUIDSYNTH=${FLUIDSYNTH_LIB} . - - make -j2 systemshock - -before_deploy: - - mkdir -p shockolate - - cp systemshock shockolate - - cp osx-linux/install_${BITS}bit_sdl.sh shockolate/install_sdl.sh - - cp osx-linux/readme_osx_linux.md shockolate - - cp osx-linux/run_$TRAVIS_OS_NAME.sh shockolate/run.sh - - cp -r shaders shockolate/ - - cp -r res shockolate/ - - export PACKAGE_NAME="shockolate-$TRAVIS_OS_NAME-${BITS}bit.tgz" - - tar zcfv $PACKAGE_NAME shockolate - - rm -r shockolate - - mkdir -p shockolate-source - - cp -r systemshock/* shockolate-source/ - - tar zcvf shockolate-source-$TRAVIS_TAG.tar.gz shockolate-source - - rm -r shockolate-source - -deploy: - provider: releases - skip_cleanup: true - overwrite: true - api_key: - secure: "M8fgLU06LQHZS7cf98dHi8bl0BPsyvQHHDWqBaiWqnOoC4XET4fYibFf9B9Ba64RYw5DqPCGbf2onYcDrrUq0cZBwbJsJoVmajKOsWiPzddAtJrk2/nle0MWtjt6OdwbHtg0dNs36QmQ7oRxrEmQaodMmnQW0PKCZOhMmT2zdU73r9ZJ0g4kkkmAAHgfLWYPkfSb9gMj0bn5BLwwGPXv9+NeDFxVG4DY4qjEqQES9tjabVSbVNHretkFCLr0rCpGDQnEZHCP3Wt5c6MoSRunZbRg0X+IwiI1xCEchw2VQFBQiKZ3D4nJIyrZ96iijUQRnnKz5aoMZXQJZQEsnTaZLM+ZbYnK6iA5KWorILdh1odFhNfUJsvWEmEGlrrIQ9qzcAJaIFFch0HRY1S8+gGOy9tEoIpr0VWNZLg8lJvkiQgQmARrt9O+4wIzXZmQnNQcU/N3nWakI68CND4UWk4xAfA6k/Mq2IWyVu477lYxEN+FcqT7EbpowovOOn7e1rutwKDUtb3jWBHZBESF5TCL/hdwdOGNITaV+ENTHbHbWvK6J+3+sCK62xG0/pqzJk3+j7R9zoDvz+htwse/hhk/F3Sa+MpaJQVqtKVD4nBlY/E7+qd3yCyXQm916V+04evjoKOqXXnOOe5d+a87OquLJ6UaynjRsq6lJY2kZ2/Irmc=" - file: "$PACKAGE_NAME" - on: - tags: true - repo: Interrupt/systemshock diff --git a/CMakeLists.32bit.txt b/CMakeLists.32bit.txt deleted file mode 100644 index 8c76b7f30..000000000 --- a/CMakeLists.32bit.txt +++ /dev/null @@ -1,423 +0,0 @@ -cmake_minimum_required(VERSION 3.1) - -project(shockolate VERSION 0.7.8) - -include(FeatureSummary) - -set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS OFF) -set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS ON) - -# Required for stdbool.h -set(CMAKE_C_STANDARD 99) -# For nullptr in C++ -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -m32 ") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -m32 -D__STDC_LIMIT_MACROS") - -option(ENABLE_EXAMPLES "Enable example applications" OFF) -add_feature_info(ENABLE_EXAMPLES ENABLE_EXAMPLES "Enable example application (can be broken!)") -option(ENABLE_DEBUG_BLIT "Enable debugging blitter" OFF) -add_feature_info(ENABLE_DEBUG_BLIT ENABLE_DEBUG_BLIT "Enable debugging blitter") -option(ENABLE_OPENGL "Enable OpenGL support" ON) -add_feature_info(ENABLE_OPENGL ENABLE_OPENGL "Enable OpenGL support") - -set(ENABLE_SDL2 "BUNDLED" CACHE STRING "Enable SDL2 (ON/BUNDLED, default BUNDLED)") -set_property(CACHE ENABLE_SDL2 PROPERTY STRINGS "ON" "BUNDLED") -add_feature_info(ENABLE_SDL2 ENABLE_SOUND "Enable SDL2 support") - -set(ENABLE_SOUND "BUNDLED" CACHE STRING "Enable sound support (requires SDL2_mixer) (ON/BUNDLED/OFF, default BUNDLED)") -set_property(CACHE ENABLE_SOUND PROPERTY STRINGS "ON" "BUNDLED" "OFF") -add_feature_info(ENABLE_SOUND ENABLE_SOUND "Enable sound support (requires SDL2_mixer)") - -set(ENABLE_FLUIDSYNTH "BUNDLED" CACHE STRING "Enable FluidSynth MIDI support (ON/BUNDLED/OFF, default BUNDLED)") -set_property(CACHE ENABLE_FLUIDSYNTH PROPERTY STRINGS "ON" "BUNDLED" "OFF") -add_feature_info(ENABLE_FLUIDSYNTH ENABLE_FLUIDSYNTH "Enable FluidSynth MIDI support") - -# HAAAAX!! -add_definitions(-DSVGA_SUPPORT) - -if(ENABLE_DEBUG_BLIT) - add_definitions(-DDEBUGGING_BLIT) -endif() - -add_compile_options(-fsigned-char -fno-strict-aliasing) - -# Find OpenGL -if(ENABLE_OPENGL) - find_package(OpenGL REQUIRED) - add_definitions(-DUSE_OPENGL) - if(WIN32) - list(APPEND OPENGL_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/build_ext/built_glew/include) - list(APPEND OPENGL_LIBRARIES ${CMAKE_SOURCE_DIR}/build_ext/built_glew/lib/libglew32.dll.a winmm) - endif(WIN32) -endif(ENABLE_OPENGL) - -if(ENABLE_SDL2 MATCHES "ON") - find_package(SDL2 REQUIRED) - if(SDL2_FOUND) - message(STATUS "SDL2 found: ${SDL2_INCLUDE_DIRS} ${SDL2_LIBRARIES}") - endif(SDL2_FOUND) -endif(ENABLE_SDL2 MATCHES "ON") -if(ENABLE_SDL2 MATCHES "BUNDLED") - set(SDL2_DIR ${CMAKE_SOURCE_DIR}/build_ext/built_sdl) - find_library(SDL2_LIBRARY SDL2 PATHS ${SDL2_DIR}/lib NO_DEFAULT_PATH) - find_library(SDL2MAIN_LIBRARY SDL2main PATHS ${SDL2_DIR}/lib NO_DEFAULT_PATH) - set(SDL2_INCLUDE_DIRS ${SDL2_DIR}/include/SDL2) - set(SDL2_LIBRARIES "${SDL2MAIN_LIBRARY};${SDL2_LIBRARY}") -endif(ENABLE_SDL2 MATCHES "BUNDLED") - -if(ENABLE_SOUND MATCHES "ON") - # FIXME applies only for *nix systems - find_package(PkgConfig) - pkg_check_modules(SDL2_MIXER REQUIRED SDL2_mixer>=2.0.4) - add_definitions(-DUSE_SDL_MIXER=1) -endif(ENABLE_SOUND MATCHES "ON") -if(ENABLE_SOUND MATCHES "BUNDLED") - set(SDL2_MIXER_DIR ${CMAKE_SOURCE_DIR}/build_ext/built_sdl_mixer) - set(SDL2_MIXER_INCLUDE_DIRS ${SDL2_MIXER_DIR}/include/SDL2) - find_library(SDL2_MIXER_LIBRARY SDL2_mixer PATHS ${SDL2_MIXER_DIR}/lib) - set(SDL2_MIXER_LIBRARIES ${SDL2_MIXER_LIBRARY}) - add_definitions(-DUSE_SDL_MIXER=1) -endif(ENABLE_SOUND MATCHES "BUNDLED") - -if(ENABLE_FLUIDSYNTH MATCHES "ON") - find_package(PkgConfig) - pkg_check_modules(FLUIDSYNTH REQUIRED fluidsynth) - add_definitions("-DUSE_FLUIDSYNTH=1") -endif(ENABLE_FLUIDSYNTH MATCHES "ON") -if(ENABLE_FLUIDSYNTH MATCHES "BUNDLED") - find_library(FLUIDSYNTH_LIBRARY fluidsynth PATHS ${CMAKE_SOURCE_DIR}/build_ext/fluidsynth-lite/src) - set(FLUIDSYNTH_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/build_ext/fluidsynth-lite/include) - set(FLUIDSYNTH_LIBRARIES ${FLUIDSYNTH_LIBRARY}) - add_definitions("-DUSE_FLUIDSYNTH=1") -endif(ENABLE_FLUIDSYNTH MATCHES "BUNDLED") - -include_directories( - ${SDL2_INCLUDE_DIRS} - ${SDL2_MIXER_INCLUDE_DIRS} - ${FLUIDSYNTH_INCLUDE_DIRS} - ${OPENGL_INCLUDE_DIRS} -) - -if(NOT WIN32) - # Find ALSA for Linux native MIDI - # NOTE: this seems to require having 64-bit dev pacakges installed when building - # on 64-bit OS, even when building a 32-bit binary - find_package(ALSA) - if(ALSA_FOUND) - message(STATUS "ALSA found") - include_directories(${ALSA_INCLUDE_DIRS}) - add_definitions(-DUSE_ALSA=1) - endif(ALSA_FOUND) -endif(NOT WIN32) - -# Generate version based on project version -set(PROJECT_REVERSION_STRING "") -find_package(Git) -if(GIT_FOUND) - execute_process(COMMAND ${GIT_EXECUTABLE} describe --dirty - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE git_describe_out - ERROR_VARIABLE git_describe_error - RESULT_VARIABLE git_describe_result - ) - string(REGEX MATCH "[a-z|0-9|.]*-[0-9]*-g([a-z|0-9]*)([-|a-z]*)" git_commit "${git_describe_out}") - set(git_commit ${CMAKE_MATCH_1}) - set(git_dirty ${CMAKE_MATCH_2}) - set(PROJECT_REVERSION_STRING "-g${git_commit}${git_dirty}") -endif(GIT_FOUND) - -message(STATUS "Version is ${PROJECT_VERSION}${PROJECT_REVERSION_STRING}") -configure_file("${CMAKE_SOURCE_DIR}/src/GameSrc/Headers/shockolate_version.h.in" - "${CMAKE_BINARY_DIR}/src/GameSrc/Headers/shockolate_version.h" ) - -# Configuration done. Print features -feature_summary(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:") -feature_summary(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:") - -# Sources configuration -add_subdirectory(src/Libraries/) - -set(MAC_SRC - src/MacSrc/ShockBitmap.c - src/MacSrc/InitMac.c - src/MacSrc/Shock.c - src/MacSrc/Prefs.c - src/MacSrc/MacTune.c - src/MacSrc/SDLSound.c - src/MacSrc/Modding.c - src/MacSrc/OpenGL.cc - src/MacSrc/Xmi.c - src/MusicSrc/MusicDevice.c -) - -set(GAME_SRC - src/GameSrc/ai.c - src/GameSrc/airupt.c - src/GameSrc/amap.c - src/GameSrc/amaploop.c - src/GameSrc/ammomfd.c - src/GameSrc/anim.c - src/GameSrc/archiveformat.c - src/GameSrc/audiolog.c - src/GameSrc/automap.c - src/GameSrc/bark.c - src/GameSrc/biohelp.c - src/GameSrc/cardmfd.c - src/GameSrc/citres.c - src/GameSrc/combat.c - src/GameSrc/cone.c - src/GameSrc/criterr.c - src/GameSrc/cyber.c - src/GameSrc/cybermfd.c - src/GameSrc/cybmem.c - src/GameSrc/cybrnd.c - src/GameSrc/cutsloop.c - src/GameSrc/damage.c - src/GameSrc/digifx.c - src/GameSrc/drugs.c - src/GameSrc/effect.c - src/GameSrc/email.c - src/GameSrc/faceobj.c - src/GameSrc/fixtrmfd.c - src/GameSrc/frcamera.c - src/GameSrc/frclip.c - src/GameSrc/frcompil.c - src/GameSrc/frmain.c - src/GameSrc/frobj.c - src/GameSrc/froslew.c - src/GameSrc/frpipe.c - src/GameSrc/frpts.c - src/GameSrc/frsetup.c - src/GameSrc/frtables.c - src/GameSrc/frterr.c - src/GameSrc/frutil.c - src/GameSrc/FrUtils.c - src/GameSrc/fullamap.c - src/GameSrc/fullscrn.c - src/GameSrc/gameloop.c - src/GameSrc/gameobj.c - src/GameSrc/gamesort.c - src/GameSrc/gamestrn.c - src/GameSrc/gamesys.c - src/GameSrc/gametime.c - src/GameSrc/gamewrap.c - src/GameSrc/gearmfd.c - src/GameSrc/gr2ss.c - src/GameSrc/grenades.c - src/GameSrc/hand.c - src/GameSrc/hflip.c - src/GameSrc/hkeyfunc.c - src/GameSrc/hud.c - src/GameSrc/hudobj.c - src/GameSrc/init.c - src/GameSrc/input.c - src/GameSrc/invent.c - src/GameSrc/leanmetr.c - src/GameSrc/mainloop.c - src/GameSrc/map.c - src/GameSrc/mfdfunc.c - src/GameSrc/mfdgadg.c - src/GameSrc/mfdgames.c - src/GameSrc/mfdgump.c - src/GameSrc/mfdpanel.c - src/GameSrc/minimax.c - src/GameSrc/mlimbs.c - src/GameSrc/movekeys.c - src/GameSrc/musicai.c - src/GameSrc/newai.c - src/GameSrc/newmfd.c - src/GameSrc/objapp.c - src/GameSrc/objects.c - src/GameSrc/objload.c - src/GameSrc/objprop.c - src/GameSrc/objsim.c - src/GameSrc/objuse.c - src/GameSrc/olh.c - src/GameSrc/olhscan.c - src/GameSrc/palfx.c - src/GameSrc/pathfind.c - src/GameSrc/physics.c - src/GameSrc/player.c - src/GameSrc/plotware.c - src/GameSrc/popups.c - src/GameSrc/render.c - src/GameSrc/rendtool.c - src/GameSrc/saveload.c - src/GameSrc/schedule.c - src/GameSrc/screen.c - src/GameSrc/setup.c - src/GameSrc/shodan.c - src/GameSrc/sideicon.c - src/GameSrc/sndcall.c - src/GameSrc/star.c - src/GameSrc/statics.c - src/GameSrc/status.c - src/GameSrc/target.c - src/GameSrc/textmaps.c - src/GameSrc/tickcount.c - src/GameSrc/tfdirect.c - src/GameSrc/tfutil.c - src/GameSrc/tools.c - src/GameSrc/trigger.c - src/GameSrc/view360.c - src/GameSrc/viewhelp.c - src/GameSrc/vitals.c - src/GameSrc/vmail.c - src/GameSrc/wares.c - src/GameSrc/weapons.c - src/GameSrc/wrapper.c - src/GameSrc/gamerend.c - src/GameSrc/mouselook.c -) - -include_directories( - BEFORE - src/Libraries/2D/Source - src/Libraries/3D/Source - src/Libraries/AFILE/Source - src/Libraries/DSTRUCT/Source - src/Libraries/EDMS/Source - src/Libraries/FIXPP/Source - src/Libraries/INPUT/Source - src/Libraries/PALETTE/Source - src/Libraries/RES/Source - src/Libraries/UI/Source - src/Libraries/RND/Source - src/Libraries/VOX/Source - src/Libraries/FIX/Source - src/Libraries/SND/Source - src/Libraries/H - src/Libraries/LG/Source - src/Libraries/LG/Source/LOG/src - src/Libraries/adlmidi/include - src/GameSrc/Headers - src/MacSrc - src/MusicSrc - ${CMAKE_BINARY_DIR}/src/GameSrc/Headers -) - -if(ENABLE_EXAMPLES) - -add_executable(playmov - src/Libraries/AFILE/Tests/playmov.c -) -add_executable(movinfo - src/Libraries/AFILE/Tests/movinfo.c -) - -target_link_libraries(playmov - AFILE_LIB - FIX_LIB - ${SDL2_LIBRARIES} - ${SDL2_MIXER_LIBRARIES} -) - -target_link_libraries(movinfo - AFILE_LIB - FIX_LIB -) - -add_executable(TestSimpleMain - src/Libraries/2D/TestSource/SimpleMain.c -) - -target_link_libraries(TestSimpleMain - 2D_LIB - GR_LIB - 3D_LIB - RES_LIB - FIX_LIB - LG_LIB - ${SDL2_LIBRARIES} -) - -add_executable(BoxTest - src/Libraries/3D/Tests/BoxTest.c -) - -target_link_libraries(BoxTest - 2D_LIB - GR_LIB - 3D_LIB - RES_LIB - FIX_LIB - LG_LIB - ${SDL2_LIBRARIES} -) - -add_executable(BitmapTest - src/Libraries/3D/Tests/BitmapTest.c -) - -target_link_libraries(BitmapTest - 2D_LIB - GR_LIB - 3D_LIB - RES_LIB - FIX_LIB - LG_LIB - ${SDL2_LIBRARIES} -) - -add_executable(FixTest - src/Libraries/FIX/Tests/FixTest/fixtest.c -) - -target_link_libraries(FixTest - FIX_LIB - LG_LIB -) - -endif() - -# Include magic header file, set struct packing size -add_definitions( - -include precompiled.h -) - -add_executable(systemshock - ${MAC_SRC} -) - -add_library(GAME_LIB ${GAME_SRC}) - -# MINGW additional linker options -if(MINGW) - set(WINDOWS_LIBRARIES "mingw32 -mwindows") -endif(MINGW) - -target_link_libraries(systemshock - ${WINDOWS_LIBRARIES} # Set it before any linker options! Beware WinMain@16 error!! - GAME_LIB - UI_LIB - 2D_LIB - LG_LIB - GR_LIB - 3D_LIB - RND_LIB - AFILE_LIB - DSTRUCT_LIB - FIX_LIB - INPUT_LIB - PALETTE_LIB - RES_LIB -# SND_LIB - VOX_LIB - EDMS_LIB - FIXPP_LIB - ADLMIDI_LIB - ${SDL2_LIBRARIES} - ${SDL2_MIXER_LIBRARIES} - ${FLUIDSYNTH_LIBRARIES} - ${OPENGL_LIBRARIES} - ${ALSA_LIBRARIES} -) - -# Turn on address sanitizing if wanted -set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/externals/sanitizers/cmake" ${CMAKE_MODULE_PATH}) -find_package(Sanitizers) -add_sanitizers(systemshock) - diff --git a/CMakeLists.txt b/CMakeLists.txt index f240aa819..45ee5990d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,12 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.28) project(shockolate VERSION 0.7.8) -include(FeatureSummary) +cmake_policy(SET CMP0072 NEW) # Prefer new GLVND library interface +cmake_policy(SET CMP0077 NEW) # Abort if variables are not clearly set -#set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS OFF) -#set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS ON) -set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS OFF) -set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON) +include(FeatureSummary) +include(FetchContent) # Required for stdbool.h set(CMAKE_C_STANDARD 99) @@ -37,6 +36,9 @@ set(ENABLE_FLUIDSYNTH "BUNDLED" CACHE STRING "Enable FluidSynth MIDI support (ON set_property(CACHE ENABLE_FLUIDSYNTH PROPERTY STRINGS "ON" "BUNDLED" "OFF") add_feature_info(ENABLE_FLUIDSYNTH ENABLE_FLUIDSYNTH "Enable FluidSynth MIDI support") +# To keep a minimum dependency list, any created library should be static, even third-party dependencies. +set(BUILD_SHARED_LIBS FALSE CACHE BOOL "Force creation of static libraries, globally" FORCE) + # HAAAAX!! add_definitions(-DSVGA_SUPPORT) @@ -51,8 +53,20 @@ if(ENABLE_OPENGL) find_package(OpenGL REQUIRED) add_definitions(-DUSE_OPENGL) if(WIN32) - list(APPEND OPENGL_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/build_ext/built_glew/include) - list(APPEND OPENGL_LIBRARIES ${CMAKE_SOURCE_DIR}/build_ext/built_glew/lib/libglew32.dll.a winmm) + SET(GLEW_version 2.1.0) + FetchContent_Declare( + glew + URL https://sourceforge.net/projects/glew/files/glew/${GLEW_version}/glew-${GLEW_version}.tgz + SOURCE_SUBDIR build/cmake + EXCLUDE_FROM_ALL + ) + FetchContent_MakeAvailable(GLEW) + + message("GLEW src-dir '${glew_SOURCE_DIR}'") + message("GLEW bin-dir '${glew_BINARY_DIR}'") + + list(APPEND OPENGL_INCLUDE_DIRS ${glew_SOURCE_DIR}/include) + list(APPEND OPENGL_LIBRARIES glew_s winmm) endif(WIN32) endif(ENABLE_OPENGL) @@ -63,11 +77,21 @@ if(ENABLE_SDL2 MATCHES "ON") endif(SDL2_FOUND) endif(ENABLE_SDL2 MATCHES "ON") if(ENABLE_SDL2 MATCHES "BUNDLED") - set(SDL2_DIR ${CMAKE_SOURCE_DIR}/build_ext/built_sdl) - find_library(SDL2_LIBRARY SDL2 PATHS ${SDL2_DIR}/lib NO_DEFAULT_PATH) - find_library(SDL2MAIN_LIBRARY SDL2main PATHS ${SDL2_DIR}/lib NO_DEFAULT_PATH) - set(SDL2_INCLUDE_DIRS ${SDL2_DIR}/include/SDL2) - set(SDL2_LIBRARIES "${SDL2MAIN_LIBRARY};${SDL2_LIBRARY}") + set(SDL_VERSION 2.32.10) + FetchContent_Declare( + SDL2 + GIT_REPOSITORY https://github.com/libsdl-org/SDL + GIT_TAG "release-${SDL_VERSION}" + EXCLUDE_FROM_ALL + ) + + set(SDL_SHARED OFF CACHE BOOL "Disabled SDL shared lib" FORCE) + set(SDL_TEST OFF CACHE BOOL "Disable SDL Test" FORCE) + set(SDL_INSTALL OFF CACHE BOOL "Disable SDL installation" FORCE) + + FetchContent_MakeAvailable(SDL2) + set(SDL2_INCLUDE_DIRS ${SDL2_SOURCE_DIR}/include) + set(SDL2_LIBRARIES SDL2::SDL2main SDL2::SDL2-static) endif(ENABLE_SDL2 MATCHES "BUNDLED") if(ENABLE_SOUND MATCHES "ON") @@ -77,10 +101,25 @@ if(ENABLE_SOUND MATCHES "ON") add_definitions(-DUSE_SDL_MIXER=1) endif(ENABLE_SOUND MATCHES "ON") if(ENABLE_SOUND MATCHES "BUNDLED") - set(SDL2_MIXER_DIR ${CMAKE_SOURCE_DIR}/build_ext/built_sdl_mixer) - set(SDL2_MIXER_INCLUDE_DIRS ${SDL2_MIXER_DIR}/include/SDL2) - find_library(SDL2_MIXER_LIBRARY SDL2_mixer PATHS ${SDL2_MIXER_DIR}/lib) - set(SDL2_MIXER_LIBRARIES ${SDL2_MIXER_LIBRARY}) + SET(SDL_MIXER_VERSION 2.8.2) + FetchContent_Declare( + SDL2_mixer + GIT_REPOSITORY https://github.com/libsdl-org/SDL_mixer.git + GIT_TAG release-${SDL_MIXER_VERSION} + EXCLUDE_FROM_ALL + ) + + set(SDL2MIXER_OPUS OFF CACHE BOOL "Disable Opus" FORCE) + set(SDL2MIXER_MOD OFF CACHE BOOL "Disable MOD" FORCE) + set(SDL2MIXER_MP3 OFF CACHE BOOL "Disable MP3" FORCE) + set(SDL2MIXER_MIDI_FLUIDSYNTH OFF CACHE BOOL "Disable FluidSynth" FORCE) + set(SDL2MIXER_WAVPACK OFF CACHE BOOL "Disable WavPack" FORCE) + set(SDL2MIXER_INSTALL OFF CACHE BOOL "Disable SDL_mixer installation" FORCE) + + FetchContent_MakeAvailable(SDL2_mixer) + set(SDL2_MIXER_INCLUDE_DIRS ${SDL2_mixer_SOURCE_DIR}/include) + set(SDL2_MIXER_LIBRARIES SDL2_mixer::SDL2_mixer-static) + add_definitions(-DUSE_SDL_MIXER=1) endif(ENABLE_SOUND MATCHES "BUNDLED") @@ -90,9 +129,35 @@ if(ENABLE_FLUIDSYNTH MATCHES "ON") add_definitions("-DUSE_FLUIDSYNTH=1") endif(ENABLE_FLUIDSYNTH MATCHES "ON") if(ENABLE_FLUIDSYNTH MATCHES "BUNDLED") - find_library(FLUIDSYNTH_LIBRARY fluidsynth PATHS ${CMAKE_SOURCE_DIR}/build_ext/fluidsynth-lite/src) - set(FLUIDSYNTH_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/build_ext/fluidsynth-lite/include) - set(FLUIDSYNTH_LIBRARIES ${FLUIDSYNTH_LIBRARY}) + SET(FLUIDSYNTH_REVISION c539a8d9270ba5a3f7d6e460606483fc2ab1eb61) + FetchContent_Declare( + FluidSynth + GIT_REPOSITORY https://github.com/EtherTyper/fluidsynth-lite.git + GIT_TAG ${FLUIDSYNTH_REVISION} + EXCLUDE_FROM_ALL + ) + + if ( WIN32 ) + # Sadly, FluidSynth-Lite has its CMakeLists.txt hardcoded to make its functions as exports. + # Idea: Modify CMakeLists.txt as part of this block here? + set(BUILD_SHARED_LIBS TRUE CACHE BOOL "Force shared libs for FluidSynth on Windows" FORCE) + endif ( WIN32 ) + FetchContent_MakeAvailable(FluidSynth) + message("FluidSynth src-dir '${FluidSynth_SOURCE_DIR}'") + message("FluidSynth bin-dir '${FluidSynth_BINARY_DIR}'") + if(APPLE) + # This is a necessary hack; compiler errors for various things. + target_compile_options(libfluidsynth PRIVATE -Wno-error=single-bit-bitfield-constant-conversion -Wno-unused-but-set-variable) + endif() + if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 15) + # This is a necessary hack; gcc-15 warns (errors) if a static array is initialized + # with a string that exceeds its storage. This is the case for fluid_defsfont.c, + # where it initializes idlist. + target_compile_options(libfluidsynth PRIVATE -Wno-error=unterminated-string-initialization) + endif() + set(FLUIDSYNTH_INCLUDE_DIRS ${FLUIDSYNTH_INCLUDE_DIR}) + + set(BUILD_SHARED_LIBS FALSE CACHE BOOL "Restore creation of static libraries" FORCE) add_definitions("-DUSE_FLUIDSYNTH=1") endif(ENABLE_FLUIDSYNTH MATCHES "BUNDLED") @@ -142,6 +207,32 @@ feature_summary(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:") # Sources configuration add_subdirectory(src/Libraries/) +include_directories( + BEFORE + src/Libraries/2D/Source + src/Libraries/3D/Source + src/Libraries/AFILE/Source + src/Libraries/DSTRUCT/Source + src/Libraries/EDMS/Source + src/Libraries/FIXPP/Source + src/Libraries/INPUT/Source + src/Libraries/PALETTE/Source + src/Libraries/RES/Source + src/Libraries/UI/Source + src/Libraries/RND/Source + src/Libraries/VOX/Source + src/Libraries/FIX/Source + src/Libraries/SND/Source + src/Libraries/H + src/Libraries/LG/Source + src/Libraries/LG/Source/LOG/src + src/Libraries/adlmidi/include + src/GameSrc/Headers + src/MacSrc + src/MusicSrc + ${CMAKE_BINARY_DIR}/src/GameSrc/Headers +) + set(MAC_SRC src/MacSrc/ShockBitmap.c src/MacSrc/InitMac.c @@ -275,32 +366,6 @@ set(GAME_SRC src/GameSrc/mouselook.c ) -include_directories( - BEFORE - src/Libraries/2D/Source - src/Libraries/3D/Source - src/Libraries/AFILE/Source - src/Libraries/DSTRUCT/Source - src/Libraries/EDMS/Source - src/Libraries/FIXPP/Source - src/Libraries/INPUT/Source - src/Libraries/PALETTE/Source - src/Libraries/RES/Source - src/Libraries/UI/Source - src/Libraries/RND/Source - src/Libraries/VOX/Source - src/Libraries/FIX/Source - src/Libraries/SND/Source - src/Libraries/H - src/Libraries/LG/Source - src/Libraries/LG/Source/LOG/src - src/Libraries/adlmidi/include - src/GameSrc/Headers - src/MacSrc - src/MusicSrc - ${CMAKE_BINARY_DIR}/src/GameSrc/Headers -) - if(ENABLE_EXAMPLES) add_executable(playmov @@ -375,16 +440,14 @@ target_link_libraries(FixTest endif() -# Include magic header file, set struct packing size -add_definitions( - -include precompiled.h -) - add_executable(systemshock ${MAC_SRC} ) +target_precompile_headers(systemshock PUBLIC src/GameSrc/Headers/precompiled.h) add_library(GAME_LIB ${GAME_SRC}) +# Include magic header file, set struct packing size +target_precompile_headers(GAME_LIB PUBLIC src/GameSrc/Headers/precompiled.h) # MINGW additional linker options if(MINGW) @@ -422,3 +485,37 @@ target_link_libraries(systemshock set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/externals/sanitizers/cmake" ${CMAKE_MODULE_PATH}) find_package(Sanitizers) add_sanitizers(systemshock) + +# --- Installation Rules --- + +install(TARGETS systemshock + RUNTIME DESTINATION . +) +if(WIN32) + if(ENABLE_FLUIDSYNTH MATCHES "BUNDLED") + install(FILES $ DESTINATION .) + endif() +endif() + +# Toolchains may define extra libraries that should be included in the distribution. +# This is primarily for MinGW, which needs some runtime libraries along with it. +if(DEFINED TOOLCHAIN_DLL_DEPENDENCIES) + foreach(DLL ${TOOLCHAIN_DLL_DEPENDENCIES}) + execute_process( + COMMAND ${CMAKE_C_COMPILER} -print-file-name=${DLL} + OUTPUT_VARIABLE DLL_PATH + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(EXISTS "${DLL_PATH}" AND NOT "${DLL_PATH}" STREQUAL "${DLL}") + install(FILES "${DLL_PATH}" DESTINATION .) + else() + message(WARNING "DLL '${DLL}' not resolved - it will be missing in the package") + endif() + endforeach() +endif() + +install(DIRECTORY ${CMAKE_SOURCE_DIR}/shaders DESTINATION .) +install(FILES + ${CMAKE_SOURCE_DIR}/README.md + DESTINATION . +) diff --git a/COMPILING.md b/COMPILING.md new file mode 100644 index 000000000..1d51e6c5d --- /dev/null +++ b/COMPILING.md @@ -0,0 +1,85 @@ +# Building instructions + +## What do you want to achieve? + +When you want to build the binary yourself, you typically fall into one of the following categories: +* a) You want to develop/build on your local machine, to run it on that machine. +* b) You want to cross-compile on your local machine, to run it on another architecture. +* c) You want to build all the supported formats. + +The necessary tasks of the respective categories are explained below. First, some general information. + +## General information + +### Supported environments + +The project is set up to officially support common **desktop** environments: +* Linux (32bit, 64bit) +* MS Windows (32bit, 64bit) +* ~~MacOS~~ (should be, but currently not working after the switch to Apple Silicon) + +> The emphasis on *desktop*, above, is deliberate. Only what builds by the automated build jobs +> of this project is supported. If there is a permutation of another system that isn't ensured by a +> build job, it may not work. +> +> The following describes the ideal working setup. + +### Dependencies + +* [CMake](https://cmake.org/) 3.x, with a minimum version according to `CMakeLists.txt` + > CMake 4 is no longer supporting various constructs found in some library dependencies. +* GNU compiler suite (either that from Linux or MinGW; use WSL or [MSYS2](https://www.msys2.org/)) +* Internet connection (for downloading library dependencies for bundled library dependencies) + +## How to build? + +### You want to develop/build on your local machine and run it on that machine. + +#### Simple case +``` +# 1) Download library dependencies and prepare build scripts (once, unless project structure is changed): +cmake -B build -S . +# 2) Build binary: +cmake --build build +# 3) Find the executable in the created build/ directory. +``` + +#### CMake build options + +The following CMake options can be used to customize the build process: + +| Option | Possible Values | Description | +|---------------------|------------------------|----------------------------------------------------------------------------------------------------------------------| +| `ENABLE_EXAMPLES` | **OFF** / ON | Enable example applications (can be broken!) | +| `ENABLE_DEBUG_BLIT` | **OFF** / ON | Enable debugging blitter | +| `ENABLE_OPENGL` | **ON** / OFF | Enable OpenGL support for improved graphics rendering | +| `ENABLE_SDL2` | **BUNDLED** / ON | Use system-installed SDL2 or bundled version | +| `ENABLE_SOUND` | **BUNDLED** / ON / OFF | Enable sound support (requires SDL2_mixer); ON uses system library, BUNDLED uses bundled version, OFF disables sound | +| `ENABLE_FLUIDSYNTH` | **BUNDLED** / ON / OFF | Enable FluidSynth MIDI support; ON uses system library, BUNDLED uses bundled version, OFF disables MIDI support | + +To use these options, pass them to CMake with the `-D` flag: + +```bash +cmake -B build -S . -DENABLE_OPENGL=OFF -DENABLE_SOUND=OFF +``` + +> Note that the support for system-provided libraries may be removed at a future point. +> The bundled versions are downloaded and handled by CMake in a defined version. + +### You want to cross-compile on your local machine for a different target. + +Cross-compilation is considered to be a build that targets a different architecture than what is default for your machine. +This also includes building a 32-bit variant on your 64-bit machine! + +For such cases, use and provide a [CMake toolchain file](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html): +``` +cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE= +``` +Refer to `cmake/toolchains` subdirectory for the ones this project uses. + +### You want to build all the supported formats. + +This is essentially the work of the build pipeline. See `.github/workflows/main-build.yml` that combines all the information above. + +On a Linux system, or an MS Windows one with WSL2, you can cover at least the Linux and MS Windows binaries, +using GCC and MinGW. diff --git a/README.md b/README.md index 59b2ba0ef..fe1036e93 100644 --- a/README.md +++ b/README.md @@ -1,67 +1,61 @@ -Shockolate - System Shock, but cross platform! +Shockolate - System Shock, but cross-platform! ============================ Based on the source code for PowerPC released by Night Dive Studios, Incorporated. -[![Build Status TravisCI](https://travis-ci.org/Interrupt/systemshock.svg?branch=master)](https://travis-ci.org/Interrupt/systemshock) [![Build Status AppVeyor](https://ci.appveyor.com/api/projects/status/5fmcswq8n7ni0o9j/branch/master?svg=true)](https://ci.appveyor.com/project/Interrupt/systemshock) - GENERAL NOTES ============= -Shockolate is a cross platform source port of System Shock, using SDL2. This runs well on OSX, Linux, and Windows right now, with some missing features that need reviving due to not being included in the source code that was released. +Shockolate is a cross-platform source port of System Shock, using SDL2. This runs well on Linux and Windows right now, +with some missing features that need reviving due to not being included in the source code that was released. -The end goal for this project is something like what Chocolate Doom is for Doom: an experience that closely mimics the original, but portable and with some quality of life improvements including an OpenGL renderer and mod support! +The end goal for this project is something like what Chocolate Doom is for Doom: +an experience that closely mimics the original, but portable and with some quality-of-life improvements, +including an OpenGL renderer and mod support! Join our Discord to follow along with development: https://discord.gg/m45xPan ![work so far](https://i.imgur.com/kbVWQj4.gif) -Prerequisites +Running ======= - - Original cd-rom or SS:EE assets in a `res/data` folder next to the executable - - Floppy disk assets are an older version that we can't load currently +## 1) Acquire binary +### From a prebuilt package -Running -======= +Find a list of [downloadable packages](https://github.com/Interrupt/systemshock/releases/) for Linux and Windows. +32- and 64-bit versions are available for Linux and Windows. + +### From source code + +See [COMPILING.md](COMPILING.md) in the repository. -## From a prebuilt package +## 2) Provide resources -Find a list of [downloadable packages](https://github.com/Interrupt/systemshock/releases/) for Linux, Mac and Windows. 32 and 64 bit versions are available for Linux and Windows. +### 2a) Game data +Original cd-rom or SS:EE assets in a `res/data` folder need to be next to the executable. +> Floppy disk assets are an older version that we can't load currently. -## From source code +### 2b) Music sound font (optional) +In the `res` folder, add a `.sf2` sound font file that should be used for playback. -Prerequisites: -- [CMake](https://cmake.org/download/) installed +> There is a file on the internet that's close to the Windows default everyone knows: http://rancid.kapsi.fi/windows.sf2 +> Please note that this is a file of unknown provenance. -Step 1. Build the dependencies: -* Windows: `build_win32.sh` or `build_win64.sh` (Git Bash and MinGW recommended) -* Linux/Mac: `build_deps.sh` or the CI build scripts in `osx-linux` -* Other: `build_deps.sh` +## 3) Execute binary -Step 2. Build and run the game itself ``` -cmake . -make systemshock ./systemshock ``` -The following CMake options are supported in the build process: -* `ENABLE_SDL2` - use system or bundled SDL2 (ON/BUNDLED, default BUNDLED) -* `ENABLE_SOUND` - enable sound support (requires SDL2_mixer, ON/BUNDLED/OFF, default is BUNDLED) -* `ENABLE_FLUIDSYNTH` - enable FluidSynth MIDI support (ON/BUNDLED/OFF, default is BUNDLED) -* `ENABLE_OPENGL` - enable OpenGL support (ON/OFF, default ON) - -If you find yourself needing to modify the build script for Shockolate itself, `CMakeLists.txt` is the place to look into. - - -Command line parameters -============ +### Command line parameters `-nosplash` Disables the splash screens, causes the game to start straight to the main menu Modding Support ============ -Shockolate supports loading mods and full on fan missions. Just point the executable at a mod file or folder and the game will load it in. So far mod loading supports additional `.res` and `.dat` files for resources and missions respectively. +Shockolate supports loading mods and full on fan missions. +Point the executable at a mod file or folder and the game will load it in. +So far mod loading supports additional `.res` and `.dat` files for resources and missions respectively. Run a fan mission from a folder: ``` @@ -85,4 +79,3 @@ Shockolate replaces the original game's movement with WASD controls, and uses `F * `Ctrl+G` cycles between graphics rendering modes * `Ctrl+F` to enable full screen mode * `Ctrl+D` to disable full screen mode - diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index cd8d0c92e..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,94 +0,0 @@ -# Shockolate AppVeyor configuration -# YAML format reference: https://www.appveyor.com/docs/appveyor-yml/ - -# This determines the disk image AppVeyor uses while building -# Despite its name, this image actually contains all sorts of non-VC goodies -# See https://www.appveyor.com/docs/build-environment/ for all the details -image: Visual Studio 2015 - -# Tell build_windows.sh that we're building for AppVeyor -environment: - APPVEYOR: TRUE - -platform: - - x64 - - x86 - -# Avoid rebuilding external dependencies (ie. SDL and SDL_mixer) -# Uncache build_ext if external deps change -cache: - - res/music.sf2 - - build_ext - -# Set up environment variable values for 32 and 64 bit builds - -for: - - - matrix: - only: - - platform: x86 - before_build: - - set BUILD_SCRIPT=build_win32.sh - - set ARTIFACT=systemshock-x86.zip - - set MINGW_PATH=C:\mingw-w64\i686-6.3.0-posix-dwarf-rt_v5-rev1\mingw32\bin\ - - copy CMakeLists.32bit.txt CMakeLists.txt - - - matrix: - only: - - platform: x64 - before_build: - - set BUILD_SCRIPT=build_win64.sh - - set ARTIFACT=systemshock-x64.zip - - set MINGW_PATH=C:\mingw-w64\x86_64-7.3.0-posix-seh-rt_v5-rev0\mingw64\bin\ - -# Actual build script.. -# Step 1: Git has to reside in a path without spaces because the SDL build script is weird like that. -# So we create a symlink to the real Git, remove it from PATH and add our own. -# Step 2: We need to use our own make.exe to build stuff, so we add that -# Step 3: Do the actual building - -build_script: - - mklink /D c:\git "C:\Program Files\Git" - - set PATH=%PATH:C:\Program Files (x86)\Git\bin;=% - - set PATH=c:\git\usr\bin;%PATH%;%MINGW_PATH% - - copy windows\make.exe \git\usr\bin - - set CMAKE_MAKE_PROGRAM=c:\git\usr\bin\make.exe - - sh %BUILD_SCRIPT% - - build.bat - - -# For now, we don't have any automatic tests to run -test: off - -# Once building is done, we gather all the necessary DLL files and build our ZIP file. -after_build: - - copy %MINGW_PATH%\libgcc*.dll . - - copy %MINGW_PATH%\libstd*.dll . - - copy %MINGW_PATH%\libwinpthread-1.dll . - - copy build_ext\built_sdl\bin\SDL*.dll . - - copy build_ext\built_sdl_mixer\bin\SDL*.dll . - - copy build_ext\built_glew\lib\glew32.dll . - - copy build_ext\fluidsynth-lite\src\libfluidsynth.dll . - - 7z a %ARTIFACT% systemshock.exe *.dll shaders/ res/ - -artifacts: - - path: systemshock-x86.zip - name: Shockolate (32bit) - - path: systemshock-x64.zip - name: Shockolate (64bit) - -version: '0.5.{build}' - -# Finally, we deploy the ZIP file as a GitHub release -# FIXME: How do we want to be building releases? Seems like this would be better as a manual process -# TODO: invent a better versioning scheme for the tag name - -deploy: - - provider: GitHub - release: $(appveyor_repo_tag_name) - description: 'Latest release build of Shockolate' - artifact: systemshock-x86.zip, systemshock-x64.zip - auth_token: - secure: P1kIk8rRxKAYHqDrOWf0Zf5spfR+N86E0lO8VBu99vHtECJgPLn/Z6tBmL9cxPah - on: - APPVEYOR_REPO_TAG: true diff --git a/build.bat b/build.bat deleted file mode 100644 index 5877fc9b9..000000000 --- a/build.bat +++ /dev/null @@ -1,4 +0,0 @@ -@REM Initial build.bat for Appveyor - -cmake -G "Unix Makefiles" . -make -j2 systemshock diff --git a/build_deps.sh b/build_deps.sh deleted file mode 100755 index df5d12801..000000000 --- a/build_deps.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -set -e - -SDL_version=2.0.9 -SDL2_mixer_version=2.0.4 - -if [ -d ./build_ext/ ]; then - echo A directory named build_ext already exists. - echo Please remove it if you want to recompile. - exit -fi - -if [ ! -d ./res/ ]; then - mkdir ./res/ -fi - -mkdir ./build_ext/ -cd ./build_ext/ - -install_dir=$(pwd) - -function build_sdl { - curl -O https://www.libsdl.org/release/SDL2-${SDL_version}.tar.gz - tar xvf SDL2-${SDL_version}.tar.gz - pushd SDL2-${SDL_version} - - ./configure --prefix=${install_dir}/built_sdl - make - make install - - popd -} - -function build_sdl_mixer { - curl -O https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-${SDL2_mixer_version}.tar.gz - tar xvf SDL2_mixer-${SDL2_mixer_version}.tar.gz - pushd SDL2_mixer-${SDL2_mixer_version} - - export SDL2_CONFIG="${install_dir}/built_sdl/bin/sdl2-config" - ./configure --prefix=${install_dir}/built_sdl_mixer - make - make install - - popd -} - -function build_fluidsynth { - git clone https://github.com/EtherTyper/fluidsynth-lite.git - pushd fluidsynth-lite - sed -i 's/DLL"\ off/DLL"\ on/' CMakeLists.txt - # if building fluidsynth fails, move on without it - set +e - - #export CFLAGS="-m32" - #export CXXFLAGS="-m32" - - cmake . - cmake --build . - - # download a soundfont that's close to the Windows default everyone knows - curl -o music.sf2 http://rancid.kapsi.fi/windows.sf2 - set -e - popd -} - - -build_sdl -build_sdl_mixer -build_fluidsynth - -cd .. -mv build_ext/fluidsynth-lite/*.sf2 ./res diff --git a/build_win32.sh b/build_win32.sh deleted file mode 100644 index 568faad2a..000000000 --- a/build_win32.sh +++ /dev/null @@ -1,124 +0,0 @@ -#!/bin/bash -set -e - -SDL_version=2.0.10 -SDL2_mixer_version=2.0.4 -GLEW_version=2.1.0 -CMAKE_target=Unix\ Makefiles - -# Removing the mwindows linker option lets us get console output -function remove_mwindows { - sed -i -e "s/ \-mwindows//g" Makefile -} - -function build_sdl { - curl -O https://www.libsdl.org/release/SDL2-${SDL_version}.tar.gz - tar xvf SDL2-${SDL_version}.tar.gz - pushd SDL2-${SDL_version} - - ./configure --host=x86_64-w64-mingw32 --prefix=${install_dir}/built_sdl - remove_mwindows - make - make install - - popd -} - -function build_sdl_mixer { - curl -O https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-${SDL2_mixer_version}.tar.gz - # Do not extract the Xcode subdirectory because it contains symlinks. - # They cannot be extracted on Windows because the files in the archive are in the wrong order so - # the target of the link cannot be found at the time of the extraction. - tar xf SDL2_mixer-${SDL2_mixer_version}.tar.gz --exclude=Xcode - pushd SDL2_mixer-${SDL2_mixer_version} - - ./configure --host=x86_64-w64-mingw32 --disable-sdltest --with-sdl-prefix=${install_dir}/built_sdl --prefix=${install_dir}/built_sdl_mixer - - remove_mwindows - make - make install - - popd -} - -function build_glew { - curl -O https://netcologne.dl.sourceforge.net/project/glew/glew/${GLEW_version}/glew-${GLEW_version}.tgz - tar xvf glew-${GLEW_version}.tgz - mv glew-${GLEW_version}/ built_glew/ - pushd built_glew - mingw32-make glew.lib - popd -} - -function build_fluidsynth { - git clone https://github.com/EtherTyper/fluidsynth-lite.git - pushd fluidsynth-lite - sed -i 's/DLL"\ off/DLL"\ on/' CMakeLists.txt - # if building fluidsynth fails, move on without it - set +e - cmake -G "${CMAKE_target}" . - cmake --build . - - # download a soundfont that's close to the Windows default everyone knows - curl -o music.sf2 http://rancid.kapsi.fi/windows.sf2 - set -e - popd -} - -## Actual building starts here - -if [ -d ./build_ext/ ]; then - echo A directory named build_ext already exists. - echo Please remove it if you want to recompile. - exit -fi - -if ! [ -x "$(command -v cmake)" ]; then - echo CMake is needed to install Shockolate. - echo Please download CMake from https://cmake.org/download/, - echo install it and try again in a new Git Bash window. - exit -fi - -rm -rf CMakeFiles/ -rm -rf CMakeCache.txt - -cp windows/make.exe /usr/bin/ - -if [ ! -d ./res/ ]; then -mkdir ./res/ -fi - -mkdir ./build_ext/ -cd ./build_ext/ -install_dir=`pwd -W` - -build_sdl -build_sdl_mixer -build_glew -build_fluidsynth - - -# Back to the root directory, copy required DLL files for the executable -cd .. -cp build_ext/built_sdl/bin/SDL*.dll . -cp build_ext/built_sdl_mixer/bin/SDL*.dll . -cp build_ext/built_glew/lib/*.dll . -cp build_ext/fluidsynth-lite/src/*.dll . - -# move the soundfont to the correct place if we successfully built fluidsynth -mv build_ext/fluidsynth-lite/*.sf2 ./res - -# Set up build.bat -if [[ -z "${APPVEYOR}" ]]; then - echo "Normal build" - echo "@echo off - cmake -G \"${CMAKE_target}\" . - mingw32-make systemshock" >build.bat -else - echo "Appveyor" - echo "cmake -G \"${CMAKE_target}\" . - make systemshock" >build.bat -fi - -echo "Our work here is done. Run BUILD.BAT in a Windows shell to build the actual source." diff --git a/build_win64.sh b/build_win64.sh deleted file mode 100644 index 6c6ae4738..000000000 --- a/build_win64.sh +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/bash -set -e - -SDL_version=2.0.10 -SDL2_mixer_version=2.0.4 -GLEW_version=2.1.0 -CMAKE_target=Unix\ Makefiles - -# Removing the mwindows linker option lets us get console output -function remove_mwindows { - sed -i -e "s/ \-mwindows//g" Makefile -} - -function build_sdl { - curl -O https://www.libsdl.org/release/SDL2-devel-${SDL_version}-mingw.tar.gz - tar xvf SDL2-devel-${SDL_version}-mingw.tar.gz - cp -r SDL2-${SDL_version}/x86_64-w64-mingw32/ built_sdl/ -} - -function build_sdl_mixer { - curl -O https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-devel-${SDL2_mixer_version}-mingw.tar.gz - tar xf SDL2_mixer-devel-${SDL2_mixer_version}-mingw.tar.gz --exclude=Xcode - cp -r SDL2_mixer-${SDL2_mixer_version}/x86_64-w64-mingw32/ built_sdl_mixer/ -} - -function build_glew { - curl -O https://netcologne.dl.sourceforge.net/project/glew/glew/${GLEW_version}/glew-${GLEW_version}.tgz - tar xvf glew-${GLEW_version}.tgz - mv glew-${GLEW_version}/ built_glew/ - pushd built_glew - mingw32-make glew.lib - popd -} - -function build_fluidsynth { - git clone https://github.com/EtherTyper/fluidsynth-lite.git - pushd fluidsynth-lite - sed -i 's/DLL"\ off/DLL"\ on/' CMakeLists.txt - # if building fluidsynth fails, move on without it - set +e - cmake -G "${CMAKE_target}" . - cmake --build . - - # download a soundfont that's close to the Windows default everyone knows - curl -o music.sf2 http://rancid.kapsi.fi/windows.sf2 - set -e - popd -} - -## Actual building starts here - -if [ -d ./build_ext/ ]; then - echo A directory named build_ext already exists. - echo Please remove it if you want to recompile. - exit -fi - -if ! [ -x "$(command -v cmake)" ]; then - echo CMake is needed to install Shockolate. - echo Please download CMake from https://cmake.org/download/, - echo install it and try again in a new Git Bash window. - exit -fi - -rm -rf CMakeFiles/ -rm -rf CMakeCache.txt - -cp windows/make.exe /usr/bin/ - -if [ ! -d ./res/ ]; then -mkdir ./res/ -fi - -mkdir ./build_ext/ -cd ./build_ext/ -install_dir=`pwd -W` - - -build_sdl -build_sdl_mixer -build_glew -build_fluidsynth - - -# Back to the root directory, copy required DLL files for the executable -cd .. -cp build_ext/built_sdl/bin/SDL*.dll . -cp build_ext/built_sdl_mixer/bin/SDL*.dll . -cp build_ext/built_glew/lib/*.dll . -cp build_ext/fluidsynth-lite/src/*.dll . - -# move the soundfont to the correct place if we successfully built fluidsynth -mv build_ext/fluidsynth-lite/*.sf2 ./res - -# Set up build.bat -if [[ -z "${APPVEYOR}" ]]; then - echo "Normal build" - echo "@echo off - cmake -G \"${CMAKE_target}\" . - mingw32-make systemshock" >build.bat -else - echo "Appveyor" - echo "cmake -G \"${CMAKE_target}\" . - make systemshock" >build.bat -fi - -echo "Our work here is done. Run BUILD.BAT in a Windows shell to build the actual source." diff --git a/cmake/toolchains/i686-gcc.cmake b/cmake/toolchains/i686-gcc.cmake new file mode 100644 index 000000000..0cd1b5812 --- /dev/null +++ b/cmake/toolchains/i686-gcc.cmake @@ -0,0 +1,17 @@ + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR i686) + +# specify the regular compiler +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_COMPILER g++) + +set(CMAKE_C_FLAGS -m32) +set(CMAKE_CXX_FLAGS -m32) +set(CMAKE_EXE_LINKER_FLAGS_INIT "-m32") + +# search for programs in the build host directories +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +# for libraries and headers in the target directories +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/cmake/toolchains/i686-w64-mingw32.cmake b/cmake/toolchains/i686-w64-mingw32.cmake new file mode 100644 index 000000000..9d3e528f8 --- /dev/null +++ b/cmake/toolchains/i686-w64-mingw32.cmake @@ -0,0 +1,27 @@ + +set(CMAKE_SYSTEM_NAME Windows) +set(CMAKE_SYSTEM_PROCESSOR i686) + +# specify the cross compiler +set(CMAKE_C_COMPILER i686-w64-mingw32-gcc) +set(CMAKE_CXX_COMPILER i686-w64-mingw32-g++) +set(CMAKE_RC_COMPILER i686-w64-mingw32-windres) + +set(CMAKE_C_FLAGS -m32) +set(CMAKE_CXX_FLAGS -m32) +set(CMAKE_EXE_LINKER_FLAGS_INIT "-m32") + +# where is the target environment +set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32 /usr/i686-w64-mingw32/sys-root/mingw) + +# search for programs in the build host directories +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +# for libraries and headers in the target directories +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +# CMake determines how to examine dependencies based on the *host* system, leading to +# a `file unknown error` unless the target platform is explicitly specified. +set(CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM "windows+pe") + +set(TOOLCHAIN_DLL_DEPENDENCIES libgcc_s_dw2-1.dll libstdc++-6.dll) diff --git a/cmake/toolchains/x86-64-gcc.cmake b/cmake/toolchains/x86-64-gcc.cmake new file mode 100644 index 000000000..5e5fdda8a --- /dev/null +++ b/cmake/toolchains/x86-64-gcc.cmake @@ -0,0 +1,17 @@ + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR i686) + +# specify the regular compiler +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_COMPILER g++) + +set(CMAKE_C_FLAGS -m64) +set(CMAKE_CXX_FLAGS -m64) + + +# search for programs in the build host directories +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +# for libraries and headers in the target directories +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/cmake/toolchains/x86-64-w64-mingw32.cmake b/cmake/toolchains/x86-64-w64-mingw32.cmake new file mode 100644 index 000000000..a0f50622d --- /dev/null +++ b/cmake/toolchains/x86-64-w64-mingw32.cmake @@ -0,0 +1,27 @@ +# From https://www.mingw-w64.org/build-systems/cmake/ +set(CMAKE_SYSTEM_NAME Windows) +set(CMAKE_SYSTEM_PROCESSOR x86_64) + +# specify the cross compiler +set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) +set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) +set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) + +set(CMAKE_C_FLAGS -m64) +set(CMAKE_CXX_FLAGS -m64) + + +# where is the target environment +set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32) + +# search for programs in the build host directories +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +# for libraries and headers in the target directories +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +# CMake determines how to examine dependencies based on the *host* system, leading to +# a `file unknown error` unless the target platform is explicitly specified. +set(CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM "windows+pe") + +set(TOOLCHAIN_DLL_DEPENDENCIES libgcc_s_seh-1.dll libstdc++-6.dll) diff --git a/osx-linux/install_32bit_sdl.sh b/osx-linux/install_32bit_sdl.sh deleted file mode 100755 index a036a22b3..000000000 --- a/osx-linux/install_32bit_sdl.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env bash - -# Setting up - -set -euo pipefail - -SDL_version=2.0.9 -SDL2_mixer_version=2.0.4 - -function build_sdl { - curl -O https://www.libsdl.org/release/SDL2-${SDL_version}.tar.gz - tar xf SDL2-${SDL_version}.tar.gz - pushd SDL2-${SDL_version} - - ./configure "CFLAGS=-m32" "CXXFLAGS=-m32" "LDFLAGS=-m32" --prefix=${install_dir}/built_sdl - make -j2 - make install - - popd -} - -function build_sdl_mixer { - curl -O https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-${SDL2_mixer_version}.tar.gz - tar xf SDL2_mixer-${SDL2_mixer_version}.tar.gz - pushd SDL2_mixer-${SDL2_mixer_version} - - export SDL2_CONFIG="${install_dir}/built_sdl/bin/sdl2-config" - ./configure "CFLAGS=-m32" "CXXFLAGS=-m32" "LDFLAGS=-m32" --prefix=${install_dir}/built_sdl_mixer - make -j2 - make install - - popd -} - -function build_fluidsynth { - git clone https://github.com/EtherTyper/fluidsynth-lite.git - pushd fluidsynth-lite - - # force compilation of dynamic library - sed -i'' -e 's/DLL\"\ off/DLL\"\ on/' CMakeLists.txt - - # force 32bit compilation - sed -i'' -e 's/\${GNUCC_WARNING_FLAGS}/-m32 \${GNUCC_WARNING_FLAGS}/' CMakeLists.txt - - # if building fluidsynth fails, move on without it - set +e - cmake . - cmake --build . - - # download a soundfont that's close to the Windows default everyone knows - curl -o music.sf2 http://rancid.kapsi.fi/windows.sf2 - set -e - popd -} - - -# Actual script starts here - -if [ -d ./build_ext/ ]; then - echo A directory named build_ext already exists. - echo Please remove it if you want to recompile. - exit -fi - -mkdir ./build_ext/ -cd ./build_ext/ - -install_dir=$(pwd) - -build_fluidsynth -build_sdl -build_sdl_mixer - -cd .. - -mkdir -p ./res/ - -# move the soundfont to the correct place if we successfully built fluidsynth -for i in build_ext/fluidsynth-lite/*.sf2; do [ -f "$i" ] || break; mv $i res/; done; - diff --git a/osx-linux/install_64bit_sdl.sh b/osx-linux/install_64bit_sdl.sh deleted file mode 100644 index a0afbe780..000000000 --- a/osx-linux/install_64bit_sdl.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env bash - -# Setting up - -set -euo pipefail - -SDL_version=2.0.9 -SDL2_mixer_version=2.0.4 - -function build_sdl { - curl -O https://www.libsdl.org/release/SDL2-${SDL_version}.tar.gz - tar xf SDL2-${SDL_version}.tar.gz - pushd SDL2-${SDL_version} - - ./configure --prefix=${install_dir}/built_sdl - make -j2 - make install - - popd -} - -function build_sdl_mixer { - curl -O https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-${SDL2_mixer_version}.tar.gz - tar xf SDL2_mixer-${SDL2_mixer_version}.tar.gz - pushd SDL2_mixer-${SDL2_mixer_version} - - export SDL2_CONFIG="${install_dir}/built_sdl/bin/sdl2-config" - ./configure --prefix=${install_dir}/built_sdl_mixer - make -j2 - make install - - popd -} - -function build_fluidsynth { - git clone https://github.com/EtherTyper/fluidsynth-lite.git - pushd fluidsynth-lite - - # force compilation of dynamic library - sed -i'' -e 's/DLL\"\ off/DLL\"\ on/' CMakeLists.txt - - # force 32bit compilation - # sed -i'' -e 's/\${GNUCC_WARNING_FLAGS}/-m32 \${GNUCC_WARNING_FLAGS}/' CMakeLists.txt - - # if building fluidsynth fails, move on without it - set +e - cmake . - cmake --build . - - # download a soundfont that's close to the Windows default everyone knows - curl -o music.sf2 http://rancid.kapsi.fi/windows.sf2 - set -e - popd -} - - -# Actual script starts here - -if [ -d ./build_ext/ ]; then - echo A directory named build_ext already exists. - echo Please remove it if you want to recompile. - exit -fi - -mkdir ./build_ext/ -cd ./build_ext/ - -install_dir=$(pwd) - -build_fluidsynth -build_sdl -build_sdl_mixer - -cd .. - -mkdir -p ./res/ - -# move the soundfont to the correct place if we successfully built fluidsynth -for i in build_ext/fluidsynth-lite/*.sf2; do [ -f "$i" ] || break; mv $i res/; done; - diff --git a/osx-linux/readme_osx_linux.md b/osx-linux/readme_osx_linux.md deleted file mode 100644 index 03ec735ff..000000000 --- a/osx-linux/readme_osx_linux.md +++ /dev/null @@ -1,6 +0,0 @@ -Shockolate - Portable System Shock -============ - -1. Copy `res/` folder of original System Shock to this directory -2. Install SDL2, SDL2_mixer and Fluidsynth by running `./install_bit_sdl.sh` where `` is 32 or 64, depending on your system capabilities. Linux needs `sudo` for this script. -3. Run Shockolate `./run.sh` diff --git a/osx-linux/run_linux.sh b/osx-linux/run_linux.sh deleted file mode 100644 index 926fc95f9..000000000 --- a/osx-linux/run_linux.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -export LD_LIBRARY_PATH="$(pwd)/lib" -./systemshock "$@" diff --git a/osx-linux/run_osx.sh b/osx-linux/run_osx.sh deleted file mode 100644 index 310c8cbc5..000000000 --- a/osx-linux/run_osx.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -export DYLD_LIBRARY_PATH="$(pwd)/lib" -./systemshock "$@" diff --git a/src/Libraries/INPUT/Source/sdl_events.c b/src/Libraries/INPUT/Source/sdl_events.c index 3907b6cb2..2a808f5a5 100644 --- a/src/Libraries/INPUT/Source/sdl_events.c +++ b/src/Libraries/INPUT/Source/sdl_events.c @@ -25,6 +25,7 @@ along with this program. If not, see . #include "lg.h" #include "kb.h" #include "mouse.h" +#include #include #include #include diff --git a/windows/make.exe b/windows/make.exe deleted file mode 100644 index fdaef6ce0..000000000 Binary files a/windows/make.exe and /dev/null differ