From b036a51cfdaf3d8082c68cca0c966cc08647c763 Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Tue, 27 May 2014 02:06:57 +0900 Subject: [PATCH] Move build instructions from travis into shell scripts fix syntax use elif run it with bash fix directory incantations add missing build steps dont use colors if not terminal update install.sh add sanity check changes set verbose mode enable debug output changes to get it working on mac Platform specific cmakelists fix issue with intptr_t not being found/defined update build scripts see if it can find the pkg-config try running it outside of cmake check whether excho works way we expect try -e remove debug info --- .gitignore | 6 ++++ .travis.yml | 26 ++------------ CMakeLists_mingw.txt | 21 ++++++++---- build.sh | 19 +++++++++++ clean.sh | 10 ++++++ install.sh | 80 ++++++++++++++++++++++++++++++++++++++++++++ src/window_options.c | 4 ++- 7 files changed, 135 insertions(+), 31 deletions(-) create mode 100755 build.sh create mode 100644 clean.sh create mode 100755 install.sh diff --git a/.gitignore b/.gitignore index b7d9f54188..c159c2b889 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,12 @@ sdl +# Compiled dll +openrct2.dll + +# Build artifacts +.cache + ################# ## Eclipse ################# diff --git a/.travis.yml b/.travis.yml index 38bc2929ec..067ef67593 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,32 +1,10 @@ language: c before_install: - - 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 - - mkdir -p cache - - export SDL2_PV=2.0.3 - - if [[ ! -f cache/SDL2-devel-${SDL2_PV}-mingw.tar.gz ]]; then wget http://libsdl.org/release/SDL2-devel-${SDL2_PV}-mingw.tar.gz --output-document cache/SDL2-devel-${SDL2_PV}-mingw.tar.gz; fi - - pushd cache && tar -xzf SDL2-devel-${SDL2_PV}-mingw.tar.gz && popd - - # but first fix SDL2 bug - - if [[ ! -f cache/libsdl2-mingw-2.0.3-fix-platform-detection-for-mingw.patch ]]; then 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" --output-document cache/libsdl2-mingw-2.0.3-fix-platform-detection-for-mingw.patch; fi - - pushd cache/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 cp -r cache/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/ + - bash install.sh script: - - mkdir build - - pushd build - - cmake -DCMAKE_TOOLCHAIN_FILE=../CMakeLists_mingw.txt -DCMAKE_BUILD_TYPE=Debug .. - - make - - popd + - bash build.sh notifications: irc: "irc.freenode.net#openrct2-dev" diff --git a/CMakeLists_mingw.txt b/CMakeLists_mingw.txt index a891576ae6..df0bbfacd1 100644 --- a/CMakeLists_mingw.txt +++ b/CMakeLists_mingw.txt @@ -1,11 +1,20 @@ SET(CMAKE_SYSTEM_NAME Windows) -SET(COMPILER_PREFIX i686-w64-mingw32) -SET(CMAKE_C_COMPILER ${COMPILER_PREFIX}-gcc) -SET(CMAKE_CXX_COMPILER ${COMPILER_PREFIX}-c++) -SET(CMAKE_RC_COMPILER ${COMPILER_PREFIX}-windres) -SET(CMAKE_PKGCONFIG_EXECUTABLE ${COMPILER_PREFIX}-pkg-config) -SET(PKG_CONFIG_EXECUTABLE ${COMPILER_PREFIX}-pkg-config) +if (APPLE) + SET(COMPILER_PREFIX i586-mingw32) + SET(CMAKE_C_COMPILER ${COMPILER_PREFIX}-gcc) + SET(CMAKE_CXX_COMPILER ${COMPILER_PREFIX}-c++) + SET(CMAKE_RC_COMPILER ${COMPILER_PREFIX}-windres) + SET(CMAKE_PKGCONFIG_EXECUTABLE i686-w64-mingw32-pkg-config) + SET(PKG_CONFIG_EXECUTABLE i686-w64-mingw32-pkg-config) +else() + SET(COMPILER_PREFIX i686-w64-mingw32) + SET(CMAKE_C_COMPILER ${COMPILER_PREFIX}-gcc) + SET(CMAKE_CXX_COMPILER ${COMPILER_PREFIX}-c++) + SET(CMAKE_RC_COMPILER ${COMPILER_PREFIX}-windres) + SET(CMAKE_PKGCONFIG_EXECUTABLE ${COMPILER_PREFIX}-pkg-config) + SET(PKG_CONFIG_EXECUTABLE ${COMPILER_PREFIX}-pkg-config) +endif (APPLE) # potential flags to make code more similar to MSVC: # -fshort-wchar -fshort-enums -mms-bitfields -fpack-struct=1 diff --git a/build.sh b/build.sh new file mode 100755 index 0000000000..85da2f5efe --- /dev/null +++ b/build.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -e + +if [[ ! -d build ]]; then + mkdir -p build +fi + +pushd build + cmake -DCMAKE_TOOLCHAIN_FILE=../CMakeLists_mingw.txt -DCMAKE_BUILD_TYPE=Debug .. + make +popd + +if [[ -t 1 ]]; then + echo "\033[95mDone! Run OpenRCT2 by typing:\n\nwine openrct2.exe\n\033[0m" +else + echo "Done! Run OpenRCT2 by typing:\n\nwine openrct2.exe\n" +fi + diff --git a/clean.sh b/clean.sh new file mode 100644 index 0000000000..03b524eee0 --- /dev/null +++ b/clean.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -ev + +sudo rm -rf /usr/local/cross-tools/i686-w64-mingw32 +#rm -rf .cache +rm -rf .cache/*.patch +rm -rf .cache/SDL2-2.0.3 +rm -rf .cache/i686-w64-mingw32-pkg-config +rm -rf build diff --git a/install.sh b/install.sh new file mode 100755 index 0000000000..e5466b5f2c --- /dev/null +++ b/install.sh @@ -0,0 +1,80 @@ +#!/bin/bash + +set -e + +SDL2_PV=2.0.3 + +cachedir=.cache +mkdir -p $cachedir + +echo `uname` + +if [[ `uname` == "Darwin" ]]; then + echo "Installation of OpenRCT2 assumes you have homebrew and use it to install packages." + # Very possible I'm missing some dependencies here. + brew install cmake wine + + if [[ ! -d /usr/include/wine ]]; then + # This will almost certainly break as brew changes. Better ideas + # welcome. + sudo ln -s /usr/local/Cellar/wine/1.6.2/include/wine /usr/include + fi + + mingw_dmg=gcc-4.8.0-qt-4.8.4-for-mingw32.dmg + mingw_path=/usr/local/gcc-4.8.0-qt-4.8.4-for-mingw32/win32-gcc/bin + if [[ ! -f $cachedir/$mingw_dmg ]]; then + wget http://crossgcc.rts-software.org/download/gcc-4.8.0-qt-4.8.4-win32/$mingw_dmg --output-document $cachedir/$mingw_dmg + fi + + if [[ ! -d $mingw_path ]]; then + echo "Open the DMG file and install its contents" + open $cachedir/$mingw_dmg + fi + + echo "You will need to add $mingw_path to your \$PATH" +elif [[ `uname` == "Linux" ]]; then + sudo apt-get install -y --force-yes binutils-mingw-w64-i686 gcc-mingw-w64-i686 g++-mingw-w64-i686 +fi + +if [[ ! -f $cachedir/SDL2-devel-${SDL2_PV}-mingw.tar.gz ]]; then + wget http://libsdl.org/release/SDL2-devel-${SDL2_PV}-mingw.tar.gz --output-document $cachedir/SDL2-devel-${SDL2_PV}-mingw.tar.gz; +fi +if [[ ! -d $cachedir/SDL2-${SDL2_PV} ]]; then + pushd $cachedir + tar -xzf SDL2-devel-${SDL2_PV}-mingw.tar.gz + popd +fi + +# Apply platform patch +mingw_patch=libsdl2-mingw-2.0.3-fix-platform-detection-for-mingw.patch +if [[ ! -f $cachedir/$mingw_patch ]]; then + wget "https://github.com/anyc/anyc-overlay/raw/master/media-libs/libsdl2-mingw/files/$mingw_patch" --output-document $cachedir/$mingw_patch; + + # XXX not sure how to make this idempotent. + pushd $cachedir/SDL2-${SDL2_PV}/i686-w64-mingw32/include/SDL2/ + echo "Applying patch." + patch -p2 < ../../../../$mingw_patch + popd +fi + +if [[ ! -d /usr/local/cross-tools ]]; then + sudo mkdir -p /usr/local/cross-tools +fi +if [[ ! -d /usr/local/cross-tools/i686-w64-mingw32 ]]; then + sudo cp -r $cachedir/SDL2-${SDL2_PV}/i686-w64-mingw32 /usr/local/cross-tools/ +fi + +if [[ ! -f $cachedir/i686-w64-mingw32-pkg-config ]]; then + if [[ `uname` == "Darwin" ]]; then + # BSD echo doesn't recognize the -e flag. + echo "#! /bin/sh\nexport PKG_CONFIG_LIBDIR=/usr/local/cross-tools/i686-w64-mingw32/lib/pkgconfig\npkg-config \$@" > $cachedir/i686-w64-mingw32-pkg-config; + else + echo -e "#! /bin/sh\nexport PKG_CONFIG_LIBDIR=/usr/local/cross-tools/i686-w64-mingw32/lib/pkgconfig\npkg-config \$@" > $cachedir/i686-w64-mingw32-pkg-config; + fi +fi + +chmod +x $cachedir/i686-w64-mingw32-pkg-config +sudo cp $cachedir/i686-w64-mingw32-pkg-config /usr/local/bin/ + +ls -al /usr/local/bin | grep pkg-config +cat /usr/local/bin/i686-w64-mingw32-pkg-config diff --git a/src/window_options.c b/src/window_options.c index 62939efcef..edc4730f25 100644 --- a/src/window_options.c +++ b/src/window_options.c @@ -28,6 +28,8 @@ #include "window.h" #include "window_dropdown.h" +#include + enum WINDOW_OPTIONS_WIDGET_IDX { WIDX_BACKGROUND, WIDX_TITLE, @@ -676,4 +678,4 @@ static void window_options_update_height_markers() config_save(); gfx_invalidate_screen(); -} \ No newline at end of file +}