diff --git a/.travis.yml b/.travis.yml index b37059433..f8eb5a2db 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,58 +1,52 @@ -language: c +language: python +python: "3.7" + +compiler: + - clang + - gcc notifications: email: false +dist: bionic +addons: + apt: + packages: + - cmake-data cmake libglu1-mesa-dev libgl1-mesa-dev libpulse-dev + +install: + - pip3 install --upgrade pip ; pip3 install conan + - conan user + - conan remote add bincrafters https://api.bintray.com/conan/bincrafters/public-conan + matrix: include: - os: linux - dist: bionic - sudo: required + compiler: clang 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 + - FLUIDSYNTH_LIB=BUNDLED - BITS=64 - os: osx - compiler: gcc + language: shell env: - SDL2_LIB=BUNDLED - SDL2_MIXER_LIB=BUNDLED - - FLUIDSYNTH_LIB=OFF # Bundled lib failed to compile + - FLUIDSYNTH_LIB=BUNDLED - 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} . + - mkdir build && cd build + - conan install .. --build=missing + - cmake .. -DENABLE_SDL2=${SDL2_LIB} -DENABLE_SOUND=${SDL2_MIXER_LIB} -DENABLE_FLUIDSYNTH=${FLUIDSYNTH_LIB} - make -j2 systemshock before_deploy: diff --git a/CMakeLists.txt b/CMakeLists.txt index 625694de0..8678090e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,10 +4,8 @@ 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) -set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS OFF) -set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON) +# Added for conan generator +set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR} ${CMAKE_MODULE_PATH}) # Required for stdbool.h set(CMAKE_C_STANDARD 99) @@ -15,9 +13,8 @@ set(CMAKE_C_STANDARD 99) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g ") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -D__STDC_LIMIT_MACROS") - +option(ENABLE_WIN32_CONSOLE "Enable log console in Windows" ON) +add_feature_info(ENABLE_WIN32_CONSOLE ENABLE_WIN32_CONSOLE "Enable log console in Windows") 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) @@ -38,7 +35,7 @@ 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) +add_definitions(-DSVGA_SUPPORT -D__STDC_LIMIT_MACROS) if(ENABLE_DEBUG_BLIT) add_definitions(-DDEBUGGING_BLIT) @@ -51,8 +48,9 @@ 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) + find_package(glew REQUIRED) + list(APPEND OPENGL_INCLUDE_DIRS ${glew_INCLUDE_DIRS}) + list(APPEND OPENGL_LIBRARIES glew::glew winmm) endif(WIN32) endif(ENABLE_OPENGL) @@ -63,11 +61,9 @@ 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}") + find_package(sdl2 REQUIRED) + set(SDL2_INCLUDE_DIRS ${sdl2_INCLUDE_DIRS}) + set(SDL2_LIBRARIES sdl2::sdl2) endif(ENABLE_SDL2 MATCHES "BUNDLED") if(ENABLE_SOUND MATCHES "ON") @@ -77,10 +73,9 @@ 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}) + find_package(sdl2_mixer REQUIRED) + set(SDL2_MIXER_INCLUDE_DIRS ${sdl2_mixer_INCLUDE_DIRS}) + set(SDL2_MIXER_LIBRARIES sdl2_mixer::sdl2_mixer) add_definitions(-DUSE_SDL_MIXER=1) endif(ENABLE_SOUND MATCHES "BUNDLED") @@ -90,9 +85,9 @@ 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}) + find_package(fluidsynth REQUIRED) + set(FLUIDSYNTH_INCLUDE_DIRS ${fluidsynth_INCLUDE_DIRS}) + set(FLUIDSYNTH_LIBRARIES fluidsynth::fluidsynth) add_definitions("-DUSE_FLUIDSYNTH=1") endif(ENABLE_FLUIDSYNTH MATCHES "BUNDLED") @@ -387,7 +382,11 @@ add_library(GAME_LIB ${GAME_SRC}) # MINGW additional linker options if(MINGW) - set(WINDOWS_LIBRARIES "mingw32 -mwindows") + set(WINDOWS_LIBRARIES mingw32) + if(NOT ENABLE_WIN32_CONSOLE) + list(APPEND WINDOWS_LIBRARIES "-mwindows") + endif(NOT ENABLE_WIN32_CONSOLE) + endif(MINGW) target_link_libraries(systemshock diff --git a/appveyor.yml b/appveyor.yml index f8a4eae44..3d5613375 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,66 +9,47 @@ image: Visual Studio 2015 # Tell build_windows.sh that we're building for AppVeyor environment: APPVEYOR: TRUE + PYTHON_HOME: "C:\\Python37" + matrix: + - COMPILER: mingw + ARCH: x86_64 + MINGW_DIR_BIN: C:\mingw-w64\x86_64-7.3.0-posix-seh-rt_v5-rev0\mingw64\bin + CMAKE_C_COMPILER: C:/mingw-w64/x86_64-7.3.0-posix-seh-rt_v5-rev0/mingw64/bin/gcc.exe + CMAKE_CXX_COMPILER: C:/mingw-w64/x86_64-7.3.0-posix-seh-rt_v5-rev0/mingw64/bin/g++.exe + - COMPILER: mingw + ARCH: i686 + MINGW_DIR_BIN: C:\mingw-w64\i686-7.3.0-posix-seh-rt_v5-rev0\mingw32\bin + CMAKE_C_COMPILER: C:/mingw-w64/i686-7.3.0-posix-seh-rt_v5-rev0/mingw32/bin/gcc.exe + CMAKE_CXX_COMPILER: C:/mingw-w64/i686-7.3.0-posix-seh-rt_v5-rev0/mingw32/bin/g++.exe -platform: - - x64 - - x86 - -# Avoid rebuilding external dependencies (ie. SDL and SDL_mixer) -# Uncache build_ext if external deps change +# Avoid rebuilding external dependencies 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 +install: + # Workaround for CMake not wanting sh.exe on PATH for MinGW + - set PATH=%PATH:C:\Program Files\Git\usr\bin;=% + - set PATH=%PYTHON_HOME%;%PYTHON_HOME%/Scripts/;%PATH% + - set PATH=%MINGW_DIR_BIN%;%PATH% + - pip.exe install conan + - conan user + - conan remote add bincrafters https://api.bintray.com/conan/bincrafters/public-conan + - conan --version + - mkdir %USERPROFILE%\.conan\profiles\ + - copy windows\mingw* %USERPROFILE%\.conan\profiles\ 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 + - mkdir build + - cd build + - conan install .. --build=missing --profile=mingw_%ARCH% + - cmake .. -DENABLE_SDL2=BUNDLED -DENABLE_SOUND=BUNDLED -DENABLE_FLUIDSYNTH=BUNDLED -G "Ninja" + - cmake --build . - # For now, we don't have any automatic tests to run -test: off +test: false # 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: diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 000000000..274ae0a12 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,29 @@ +from conans import ConanFile, CMake + +class SystemShockConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + # Comma-separated list of requirements + build_requires = [ + "glew/2.1.0@bincrafters/stable", + "sdl2_mixer/2.0.4@bincrafters/stable", + ] + generators = "cmake_find_package" + + def configure(self): + # Disable unused dependencies + if self.settings.os == "Linux": + self.options["sdl2"].jack = False + self.options["sdl2"].nas = False + self.options["sdl2_mixer"].tinymidi = False + if self.settings.os == "Windows": + self.options["sdl2_mixer"].flac = False + self.options["sdl2_mixer"].mad = False + self.options["sdl2_mixer"].modplug = False + self.options["sdl2_mixer"].mpg123 = False + self.options["sdl2_mixer"].ogg = False + self.options["sdl2_mixer"].opus = False + self.options["glew"].shared = True # Should be shared for MinGW + + def imports(self): + self.copy("*.dll", "", "bin") + diff --git a/src/MacSrc/OpenGL.cc b/src/MacSrc/OpenGL.cc index bcc4379c0..3d08862e4 100644 --- a/src/MacSrc/OpenGL.cc +++ b/src/MacSrc/OpenGL.cc @@ -1,47 +1,45 @@ #ifdef USE_OPENGL #include -#include "OpenGL.h" +#include +#include +#include #ifdef _WIN32 - #define GLEW_STATIC 1 - #include - #include +#include #else - #define GL_GLEXT_PROTOTYPES - #ifdef __APPLE__ - #include - #else - #include - #include - #endif - - #include - #include +#define GL_GLEXT_PROTOTYPES +#ifdef __APPLE__ +#include +#else +#include +#include +#endif + +#include #endif +#include "OpenGL.h" + extern "C" { - #include "mainloop.h" - #include "map.h" - #include "frintern.h" - #include "frflags.h" - #include "player.h" - #include "textmaps.h" - #include "star.h" - #include "tools.h" - #include "Prefs.h" - #include "Shock.h" - #include "faketime.h" - #include "render.h" - #include "wares.h" - - extern SDL_Renderer *renderer; - extern SDL_Palette *sdlPalette; +#include "mainloop.h" +#include "map.h" +#include "frintern.h" +#include "frflags.h" +#include "player.h" +#include "textmaps.h" +#include "star.h" +#include "tools.h" +#include "Prefs.h" +#include "Shock.h" +#include "faketime.h" +#include "render.h" +#include "wares.h" + +extern SDL_Renderer *renderer; +extern SDL_Palette *sdlPalette; } -#include -#include - struct CachedTexture { SDL_Surface *bitmap; SDL_Surface *converted; @@ -50,6 +48,7 @@ struct CachedTexture { bool locked; }; + struct Shader { GLuint shaderProgram; GLint uniView; diff --git a/windows/mingw_i686 b/windows/mingw_i686 new file mode 100644 index 000000000..a4c756dab --- /dev/null +++ b/windows/mingw_i686 @@ -0,0 +1,20 @@ +[settings] +os=Windows +os_build=Windows +arch=x86 +arch_build=x86 +compiler=gcc +compiler.version=8 +compiler.libcxx=libstdc++11 +build_type=Release +compiler.exception=seh +compiler.threads=posix +[options] + +[build_requires] +mingw_installer/1.0@conan/stable +ninja/1.9.0 + +[env] +CONAN_CMAKE_GENERATOR=Ninja + diff --git a/windows/mingw_x86_64 b/windows/mingw_x86_64 new file mode 100644 index 000000000..d6ec8871e --- /dev/null +++ b/windows/mingw_x86_64 @@ -0,0 +1,20 @@ +[settings] +os=Windows +os_build=Windows +arch=x86_64 +arch_build=x86_64 +compiler=gcc +compiler.version=8 +compiler.libcxx=libstdc++11 +build_type=Release +compiler.exception=seh +compiler.threads=posix +[options] + +[build_requires] +mingw_installer/1.0@conan/stable +ninja/1.9.0 + +[env] +CONAN_CMAKE_GENERATOR=Ninja +