Skip to content

Conan dep manager #320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 24 additions & 30 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
45 changes: 22 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,17 @@ 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)
# For nullptr in C++
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)
Expand All @@ -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)
Expand All @@ -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)

Expand All @@ -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")
Expand All @@ -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")

Expand All @@ -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")

Expand Down Expand Up @@ -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
Expand Down
79 changes: 30 additions & 49 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
29 changes: 29 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -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")

65 changes: 32 additions & 33 deletions src/MacSrc/OpenGL.cc
Original file line number Diff line number Diff line change
@@ -1,47 +1,45 @@
#ifdef USE_OPENGL

#include <cstdio>
#include "OpenGL.h"
#include <map>
#include <sstream>
#include <SDL.h>

#ifdef _WIN32
#define GLEW_STATIC 1
#include <SDL.h>
#include <GL/glew.h>
#include <GL/glew.h>
#else
#define GL_GLEXT_PROTOTYPES
#ifdef __APPLE__
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#include <GL/glext.h>
#endif

#include <SDL.h>
#include <SDL_opengl.h>
#define GL_GLEXT_PROTOTYPES
#ifdef __APPLE__
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#include <GL/glext.h>
#endif

#include <SDL_opengl.h>
#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 <map>
#include <sstream>

struct CachedTexture {
SDL_Surface *bitmap;
SDL_Surface *converted;
Expand All @@ -50,6 +48,7 @@ struct CachedTexture {
bool locked;
};


struct Shader {
GLuint shaderProgram;
GLint uniView;
Expand Down
Loading