diff --git a/.travis.yml b/.travis.yml index 2685289d40..fae0c47d0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,33 @@ language: c + before_install: - - echo "yes" | sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu `lsb_release -sc` main universe restricted multiverse" - - echo "yes" | sudo apt-add-repository ppa:openmw/deps - - sudo apt-key update -qq - sudo apt-get update -qq - - sudo apt-get install -y --force-yes binutils-mingw-w64-i686 gcc-mingw-w64-i686 g++-mingw-w64-i686 libsdl2-static-dev libc6-dev-i386 - - ls -al /usr/bin - - ls -al /usr/include/SDL2 - - sudo mv /usr/include/SDL2 /usr/include/sdl2 + - sudo apt-get install -y --force-yes binutils-mingw-w64-i686 gcc-mingw-w64-i686 g++-mingw-w64-i686 + + # fetch precompiled SDL2 + headers for MinGW and push it into the expected directory + - export SDL2_PV=2.0.3 + - wget http://libsdl.org/release/SDL2-devel-${SDL2_PV}-mingw.tar.gz + - tar -xzvf SDL2-devel-${SDL2_PV}-mingw.tar.gz + + # but first fix SDL2 bug + - wget "https://github.com/anyc/anyc-overlay/raw/master/media-libs/libsdl2-mingw/files/libsdl2-mingw-2.0.3-fix-platform-detection-for-mingw.patch" + - pushd SDL2-${SDL2_PV}/i686-w64-mingw32/include/SDL2/ && patch -p2 < ../../../../libsdl2-mingw-2.0.3-fix-platform-detection-for-mingw.patch && popd + + - sudo mkdir -p /usr/local/cross-tools/ + - sudo mv SDL2-${SDL2_PV}/i686-w64-mingw32 /usr/local/cross-tools/ + + # build a wrapper that looks for the sdl2.pc file in the new directory + - echo -e "#! /bin/sh\\nexport PKG_CONFIG_LIBDIR=/usr/local/cross-tools/i686-w64-mingw32/lib/pkgconfig\\npkg-config \$@" > i686-w64-mingw32-pkg-config + - chmod +x i686-w64-mingw32-pkg-config + - sudo mv i686-w64-mingw32-pkg-config /usr/local/bin/ + script: - - sudo find / -name SDL2 2>>/dev/null || true - mkdir build - - pushd build && cmake -DCMAKE_TOOLCHAIN_FILE=../CMakeLists_mingw.txt -DCMAKE_BUILD_TYPE=Debug .. && popd - - sudo find / -name stubs-32.h 2>>/dev/null || true - - pushd build && C_INCLUDE_PATH=/usr/include/x86_64-linux-gnu/bits:/usr/include/sdl2:$C_INCLUDE_PATH make && popd + - pushd build + - cmake -DCMAKE_TOOLCHAIN_FILE=../CMakeLists_mingw.txt -DCMAKE_BUILD_TYPE=Debug .. + - make + #- make VERBOSE=1 + - popd + #notifications: - #irc: "irc.freenode.net#openrct2" + #irc: "irc.freenode.net#openrct2" \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ac432ad6a..5c911bb9fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,31 +25,33 @@ project(${PROJECT}) add_definitions(-DORCT2_RESOURCE_DIR="${ORCT2_RESOURCE_DIR}") -# include lodepng +# include lodepng header include_directories("lodepng/") +# add source files file(GLOB_RECURSE ORCT2_SOURCES "src/*.c" "lodepng/*.c") -# build as library for now, replace with add_executable -add_library(${PROJECT} SHARED ${ORCT2_SOURCES}) - -# install into ${CMAKE_INSTALL_PREFIX}/bin/ -install (TARGETS ${PROJECT} DESTINATION bin) - -# libopenrct2.dll -> openrct2.dll -set_target_properties(${PROJECT} PROPERTIES PREFIX "") - if (UNIX) # force 32bit build for now and set necessary flags to compile code as is - set(CMAKE_C_FLAGS "-m32 -masm=intel -std=c99") + set(CMAKE_C_FLAGS "-m32 -masm=intel -std=gnu99") set(CMAKE_LDFLAGS_FLAGS "-m32") # find and include SDL2 INCLUDE(FindPkgConfig) PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2) INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIRS}) - TARGET_LINK_LIBRARIES(${PROJECT} ${SDL2_LIBRARIES}) endif (UNIX) +LINK_DIRECTORIES(${SDL2_LIBRARY_DIRS}) + +# build as library for now, replace with add_executable +add_library(${PROJECT} SHARED ${ORCT2_SOURCES}) + +# install into ${CMAKE_INSTALL_PREFIX}/bin/ +#install (TARGETS ${PROJECT} DESTINATION bin) + +# libopenrct2.dll -> openrct2.dll +set_target_properties(${PROJECT} PROPERTIES PREFIX "") + TARGET_LINK_LIBRARIES(${PROJECT} ${SDL2_LIBRARIES}) if (WIN32) diff --git a/CMakeLists_mingw.txt b/CMakeLists_mingw.txt index 1f92220945..a891576ae6 100644 --- a/CMakeLists_mingw.txt +++ b/CMakeLists_mingw.txt @@ -16,14 +16,12 @@ set(CMAKE_SHARED_LINKER_FLAGS "-static-libgcc" CACHE STRING "" FORCE) include_directories("/usr/include/wine/windows/") # find and include SDL2 -# INCLUDE(FindPkgConfig) -# PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2) -INCLUDE_DIRECTORIES("/usr/include") -INCLUDE_DIRECTORIES("/usr/include/x86_64-linux-gnu") -INCLUDE_DIRECTORIES("/usr/include/sdl2") +INCLUDE(FindPkgConfig) +PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2) +INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIRS}) # here is the target environment located -SET(CMAKE_FIND_ROOT_PATH /usr/${COMPILER_PREFIX}) +#SET(CMAKE_FIND_ROOT_PATH /usr/${COMPILER_PREFIX}) # adjust the default behaviour of the FIND_XXX() commands: # search headers and libraries in the target environment, search diff --git a/src/rct2.h b/src/rct2.h index 64840b4816..1e81ac4d4b 100644 --- a/src/rct2.h +++ b/src/rct2.h @@ -52,6 +52,7 @@ typedef unsigned long long uint64; #else #define RCT2_ERROR(format,...) fprintf(stderr, "ERROR %s:%s():%d: " format "\n", __FILE__, __func__, __LINE__, __VA_ARGS__); #endif +#define RCT2_ERR(msg) RCT2_ERROR("%s",msg) #ifndef _MSC_VER // use similar struct packing as MSVC for our structs diff --git a/src/scenario_list.c b/src/scenario_list.c index c2e7a97df7..9d2ca8741d 100644 --- a/src/scenario_list.c +++ b/src/scenario_list.c @@ -169,7 +169,7 @@ static int scenario_scores_load() // Try and load the scores file file = fopen(get_file_path(PATH_ID_SCORES), "rb"); if (file == NULL) { - RCT2_ERROR("Unable to load scenario scores."); + RCT2_ERR("Unable to load scenario scores."); return 0; } @@ -177,7 +177,7 @@ static int scenario_scores_load() rct_scenario_scores_header header; if (fread(&header, 16, 1, file) != 1) { fclose(file); - RCT2_ERROR("Invalid header in scenario scores file."); + RCT2_ERR("Invalid header in scenario scores file."); return 0; } gScenarioListCount = header.scenario_count; @@ -210,7 +210,7 @@ int scenario_scores_save() file = fopen(get_file_path(PATH_ID_SCORES), "wb"); if (file == NULL) { - RCT2_ERROR("Unable to save scenario scores."); + RCT2_ERR("Unable to save scenario scores."); return 0; } diff --git a/src/window_map.c b/src/window_map.c index f56f9f5534..4c14fb8dd2 100644 --- a/src/window_map.c +++ b/src/window_map.c @@ -180,7 +180,11 @@ static void window_map_close() { rct_window *w; + #ifdef _MSC_VER __asm mov w, esi + #else + __asm__ ( "mov %[w], esi " : [w] "+m" (w) ); + #endif rct2_free(RCT2_GLOBAL(RCT2_ADDRESS_MAP_IMAGE_DATA, uint32*)); if ((RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) &&