Skip to content

Commit

Permalink
Add comprehensive Msys2 and CI support
Browse files Browse the repository at this point in the history
  • Loading branch information
arsdragonfly committed May 17, 2018
1 parent fd38941 commit 4f06b67
Show file tree
Hide file tree
Showing 44 changed files with 8,052 additions and 320 deletions.
73 changes: 73 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
environment:
matrix:
- GENERATOR: "MinGW Makefiles"
HUNTER: "ON"

- GENERATOR: "MSYS Makefiles"
HUNTER: "OFF"
MSYS2_ARCH: x86_64
MSYSTEM: MINGW64

- GENERATOR: "MSYS Makefiles"
HUNTER: "OFF"
MSYS2_ARCH: i686
MSYSTEM: MINGW32

- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
GENERATOR: "Visual Studio 15 2017 Win64"
HUNTER: "ON"

- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
GENERATOR: "Visual Studio 14 2015 Win64"
HUNTER: "ON"

before_build:
# Stupid cmd always fails me!!!!!!!!!!
- ps: $env:CMAKE_SCRIPT = "cmake -G \`"$env:GENERATOR\`" -DHUNTER_ENABLED=$env:HUNTER . && cmake --build . --target iceball && cmake --build . --target iceball-dedi";

# Workaround for CMake complaining about sh.exe being in PATH
- ps: $env:PATH = ($env:PATH.Split(";") | Where-Object { $_ -ne "C:\Program Files\Git\usr\bin" }) -join ";";
- ps: $env:PATH = "C:\MinGW\bin;$env:PATH";
# Set up MSYS2
# Unused toolchains are removed to speed up update.
- ps: |
if ($env:GENERATOR -eq "MSYS Makefiles")
{
$env:PATH = "C:\msys64\$env:MSYSTEM\bin;C:\msys64\usr\bin;$env:PATH";
$env:PACMAN = "pacman --noconfirm --noprogressbar";
$env:MINGW_PACKAGE_PREFIX = "mingw-w64-$env:MSYS2_ARCH";
if ($env:MSYS2_ARCH -eq "x86_64")
{
bash -lc "$env:PACMAN -Rs mingw-w64-i686-toolchain";
}
if ($env:MSYS2_ARCH -eq "i686")
{
bash -lc "$env:PACMAN -Rs mingw-w64-x86_64-toolchain";
}
bash -lc "$env:PACMAN -Syu";
bash -lc "$env:PACMAN -Su";
bash -lc "$env:PACMAN -S $env:MINGW_PACKAGE_PREFIX-cmake";
bash -lc "$env:PACMAN -S $env:MINGW_PACKAGE_PREFIX-SDL2";
bash -lc "$env:PACMAN -S $env:MINGW_PACKAGE_PREFIX-luajit-git";
bash -lc "$env:PACMAN -S $env:MINGW_PACKAGE_PREFIX-enet";
}
build_script:
#Use a seperate script file so that warnings on stderr won't fail the build
- powershell .\appveyor_build.ps1
- ps: |
if ($env:GENERATOR -eq "MinGW Makefiles")
{
$env:ICEBALL_ZIP_FILENAME = "iceball-$env:APPVEYOR_REPO_COMMIT.zip";
7z a $env:ICEBALL_ZIP_FILENAME `@listfile.txt;
Push-AppveyorArtifact $env:ICEBALL_ZIP_FILENAME;
}
deploy:
description: $(APPVEYOR_REPO_COMMIT)
provider: GitHub
auth_token:
secure: tMJF/Nc5vz1iNTuX94v3fdoToy+RDykn8cfehVok1el8s2ZgD9GSi/fLfbVsSv5M
force_update: true
on:
appveyor_repo_tag: true
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,8 @@ ZERO_CHECK.vcproj
# vim stuff
.vimrc

# clsave/vol/fastload.tmp
# fastload cache
clsave/vol/fastload.tmp

# Makefiles are now generated by cmake
Makefile*
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ addons:
liblua5.1-0-dev
libenet-dev
libluajit-5.1-dev
script: cmake . && cmake --build .
script: cmake . && make iceball iceball-dedi
114 changes: 79 additions & 35 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
cmake_minimum_required (VERSION 2.8.4)
cmake_minimum_required (VERSION 3.0)
# "MSYS2 and *nix are first class citizens." the holy arsdragonfly decided.
option(HUNTER_ENABLED "Enable Hunter to grab dependencies on Windows for mingw32-make and MSVC" OFF)
SET(HUNTER_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/hunter")
SET(HUNTER_CONFIGURATION_TYPES Debug)
include("cmake/HunterGate.cmake")
HunterGate(
URL "https://github.com/ruslo/hunter/archive/v0.20.70.tar.gz"
SHA1 "95fb7d11f0828746e2983b5f06ff7981a676da3f"
LOCAL
)
project (iceball)

set(CMAKE_SOURCE_DIR src)

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
add_definitions(-fno-strict-aliasing -Wall -Wextra -g) # keep debugging symbols even in Release builds
add_definitions(-fno-strict-aliasing -Wall -Wextra -Og) # keep debugging symbols even in Release builds
endif ()

include_directories(include)
Expand All @@ -16,32 +26,56 @@ if (WIN32)
endif (MSVC)
endif (WIN32)

if (MINGW)
set(CMAKE_PREFIX_PATH "dist/mingw/enet;dist/mingw/sdl2;dist/mingw/lua51;dist/mingw/sackit;dist/mingw/zlib" CACHE PATH "" FORCE)
elseif (MSVC)
set(CMAKE_PREFIX_PATH "dist/msvc/enet;dist/msvc/sdl2;dist/msvc/lua51;dist/msvc/sackit;dist/msvc/zlib" CACHE PATH "" FORCE)

if (MSYS) #MINGW is true on MSYS2, but we do not use hunter
elseif (MINGW OR MSVC) #Use hunter to grab and build dependencies
hunter_add_package(enet)
find_package(enet CONFIG REQUIRED)
hunter_add_package(Lua)
find_package(Lua CONFIG REQUIRED)
hunter_add_package(ZLIB)
find_package(ZLIB CONFIG REQUIRED)
hunter_add_package(SDL2)
find_package(SDL2 CONFIG REQUIRED)
endif ()

find_package(ENet REQUIRED)
find_package(SDL2 REQUIRED)
find_package(ZLIB REQUIRED)
find_package(LuaJIT)
if (LUAJIT_FOUND)
add_definitions(-DUSE_LUAJIT)
set(LUA_LIBRARIES ${LUA_LIBRARY} m)
else ()
find_package(Lua REQUIRED)
if (MSYS OR (NOT (MINGW OR MSVC)))
#Default on MSYS, *nix and OSX
find_package(ENet REQUIRED)
find_package(SDL2 REQUIRED)
find_package(ZLIB REQUIRED)
find_package(LuaJIT)
if (LUAJIT_FOUND)
add_definitions(-DUSE_LUAJIT)
set(LUA_LIBRARIES ${LUA_LIBRARY} m)
else ()
find_package(Lua REQUIRED)
endif ()
endif ()

find_package(sackit REQUIRED)
find_package(OpenGL REQUIRED)

include_directories(
${ENet_INCLUDE_DIRS}
${sackit_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
${SDL2_INCLUDE_DIR}
${LUA_INCLUDE_DIR}
)

if (MSYS OR (NOT (MINGW OR MSVC)))
#Stupid naming inconsistency
include_directories(
${ENet_INCLUDE_DIRS}
${sackit_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
${SDL2_INCLUDE_DIR}
${LUA_INCLUDE_DIR}
)
else ()
include_directories(
"${ENET_ROOT}/include"
${sackit_INCLUDE_DIRS}
"${ZLIB_ROOT}/include"
"${SDL2_ROOT}/include/SDL2"
"${LUA_ROOT}/include"
)
endif ()


file(GLOB LUA_FILES src/lua* src/external/bit.c)
set(MAIN_FILES
Expand Down Expand Up @@ -71,28 +105,38 @@ source_group(lua FILES ${LUA_FILES})

# iceball target
add_executable(iceball ${MAIN_FILES} ${LUA_FILES} ${GL_FILES})
target_link_libraries(iceball ${CMAKE_DL_LIBS} ${ENet_LIBRARIES} ${ZLIB_LIBRARIES} ${sackit_LIBRARY} ${LUA_LIBRARIES} ${SDL2_LIBRARIES} ${OPENGL_LIBRARIES})
if (MSYS OR (NOT (MINGW OR MSVC)))
target_link_libraries(iceball ${CMAKE_DL_LIBS} ${ENet_LIBRARIES} ${ZLIB_LIBRARIES} ${sackit_LIBRARY} ${LUA_LIBRARIES} ${SDL2_LIBRARIES} ${OPENGL_LIBRARIES})
if (MSYS)
set_target_properties(iceball PROPERTIES LINK_FLAGS "-mwindows") # Get rid of console
endif ()
else ()
if (MINGW)
set_target_properties(iceball PROPERTIES LINK_FLAGS "-lmingw32")
endif ()
target_link_libraries(iceball ${CMAKE_DL_LIBS} ${sackit_LIBRARY} ${OPENGL_LIBRARIES} enet::enet Lua::lua_lib ZLIB::zlib SDL2::SDL2main SDL2::SDL2)
endif ()
set_target_properties(iceball PROPERTIES C_STANDARD 99)

# iceball-dedi target
add_executable(iceball-dedi EXCLUDE_FROM_ALL ${MAIN_FILES} ${LUA_FILES})
target_link_libraries(iceball-dedi ${CMAKE_DL_LIBS} ${ENet_LIBRARIES} ${ZLIB_LIBRARIES} ${LUA_LIBRARIES} ${SDL_LIBRARY})
if (MSYS OR (NOT (MINGW OR MSVC)))
target_link_libraries(iceball-dedi ${CMAKE_DL_LIBS} ${ENet_LIBRARIES} ${ZLIB_LIBRARIES} ${LUA_LIBRARIES})
else ()
target_link_libraries(iceball-dedi ${CMAKE_DL_LIBS} enet::enet Lua::lua_lib ZLIB::zlib)
endif ()
set_target_properties(iceball-dedi PROPERTIES C_STANDARD 99)
set_target_properties(iceball-dedi PROPERTIES COMPILE_DEFINITIONS "DEDI")

function(copy_run_dep arg1)
add_custom_command(TARGET iceball POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${PROJECT_SOURCE_DIR}/${arg1}"
"${arg1}"
$<TARGET_FILE_DIR:iceball>)
endfunction()

if (MINGW)
copy_run_dep(dist/mingw/sdl2/bin/libSDL2.dll)
copy_run_dep(dist/mingw/lua51/bin/liblua.dll)
copy_run_dep(dist/mingw/zlib/bin/libzlib.dll)
elseif (MSVC)
copy_run_dep(dist/msvc/sdl2/bin/SDL2.dll)
copy_run_dep(dist/msvc/lua51/bin/lua.dll)
copy_run_dep(dist/msvc/zlib/bin/zlib.dll)
if (MSYS)
copy_run_dep($ENV{MSYSTEM_PREFIX}/bin/SDL2.dll)
copy_run_dep($ENV{MSYSTEM_PREFIX}/bin/lua51.dll)
copy_run_dep($ENV{MSYSTEM_PREFIX}/bin/zlib1.dll)
copy_run_dep($ENV{MSYSTEM_PREFIX}/bin/libenet-7.dll)
endif ()
31 changes: 0 additions & 31 deletions Makefile

This file was deleted.

Loading

0 comments on commit 4f06b67

Please sign in to comment.