1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-06 06:32:56 +01:00

Merge pull request #1983 from janisozaur/docker32

Docker32
This commit is contained in:
Ted John
2015-09-28 23:23:09 +01:00
12 changed files with 277 additions and 166 deletions

View File

@@ -10,18 +10,21 @@ notifications:
on_failure: change
on_success: change
cache:
cache:
directories:
- cache
- .cache
apt: true
env:
- OPENRCT2_CMAKE_OPTS="-DCMAKE_TOOLCHAIN_FILE=../CMakeLists_mingw.txt"
- OPENRCT2_CMAKE_OPTS="-DDISABLE_NETWORK=ON -DCMAKE_TOOLCHAIN_FILE=../CMakeLists_mingw.txt"
- OPENRCT2_CMAKE_OPTS="-DDISABLE_NETWORK=ON -DDISABLE_HTTP_TWITCH=ON -DCMAKE_TOOLCHAIN_FILE=../CMakeLists_mingw.txt"
- OPENRCT2_CMAKE_OPTS="-DDISABLE_HTTP_TWITCH=ON -DCMAKE_TOOLCHAIN_FILE=../CMakeLists_mingw.txt"
- OPENRCT2_CMAKE_OPTS="-DDISABLE_NETWORK=ON -DDISABLE_HTTP_TWITCH=ON -DCMAKE_C_COMPILER=gcc-4.8 -DCMAKE_CXX_COMPILER=g++-4.8"
- OPENRCT2_CMAKE_OPTS="-DDISABLE_NETWORK=OFF -DDISABLE_HTTP_TWITCH=ON -DCMAKE_C_COMPILER=gcc-4.8 -DCMAKE_CXX_COMPILER=g++-4.8"
- OPENRCT2_CMAKE_OPTS="-DDISABLE_NETWORK=OFF -DDISABLE_HTTP_TWITCH=OFF -DCMAKE_C_COMPILER=gcc-4.8 -DCMAKE_CXX_COMPILER=g++-4.8"
- OPENRCT2_CMAKE_OPTS="-DCMAKE_TOOLCHAIN_FILE=../CMakeLists_mingw.txt" TARGET=windows
- OPENRCT2_CMAKE_OPTS="-DDISABLE_NETWORK=ON -DCMAKE_TOOLCHAIN_FILE=../CMakeLists_mingw.txt" TARGET=windows
- OPENRCT2_CMAKE_OPTS="-DDISABLE_NETWORK=ON -DDISABLE_HTTP_TWITCH=ON -DCMAKE_TOOLCHAIN_FILE=../CMakeLists_mingw.txt" TARGET=windows
- OPENRCT2_CMAKE_OPTS="-DDISABLE_HTTP_TWITCH=ON -DCMAKE_TOOLCHAIN_FILE=../CMakeLists_mingw.txt" TARGET=windows
- TARGET=docker32
- OPENRCT2_CMAKE_OPTS="-DDISABLE_NETWORK=ON -DDISABLE_HTTP_TWITCH=ON" TARGET=docker32
sudo: required

View File

@@ -26,21 +26,30 @@ project(${PROJECT})
add_definitions(-DORCT2_RESOURCE_DIR="${ORCT2_RESOURCE_DIR}")
add_definitions(-DHAVE_CONFIG_H)
add_definitions(-DCURL_STATICLIB)
INCLUDE(FindPkgConfig)
option(DISABLE_HTTP_TWITCH "Disable HTTP and Twitch support.")
if (DISABLE_HTTP_TWITCH)
add_definitions(-DDISABLE_HTTP -DDISABLE_TWITCH)
else (DISABLE_HTTP_TWITCH)
PKG_CHECK_MODULES(LIBCURL REQUIRED libcurl)
PKG_CHECK_MODULES(JANSSON REQUIRED jansson)
SET(HTTPLIBS ${LIBCURL_LIBRARIES} ${JANSSON_LIBRARIES})
if (WIN32)
SET(HTTPLIBS ${HTTPLIBS} ssl crypto winmm.lib ws2_32)
endif (WIN32)
endif (DISABLE_HTTP_TWITCH)
option(DISABLE_NETWORK "Disable multiplayer functionality. Mainly for testing.")
if (DISABLE_NETWORK)
add_definitions(-DDISABLE_NETWORK)
else (DISABLE_NETWORK)
if (WIN32)
SET(NETWORKLIBS ${NETWORKLIBS} ws2_32)
endif (WIN32)
endif (DISABLE_NETWORK)
set(ORCTLIBS_INCLUDE /usr/local/cross-tools/orctlibs/include)
set(JANSSON_INCLUDE /usr/local/cross-tools/orctlibs/include/jansson)
set(ORCTLIBS_LIB_DIR /usr/local/cross-tools/orctlibs/lib)
set(ORCTLIBS_LIB jansson curl ssl crypto)
# include lib
include_directories("lib/")
# include speex header
@@ -52,18 +61,15 @@ if (UNIX)
# force 32bit build for now and set necessary flags to compile code as is
set(CMAKE_C_FLAGS "-m32 -masm=intel -fvar-tracking-assignments -std=gnu99")
set(CMAKE_CXX_FLAGS "-m32 -std=gnu++11 -fvar-tracking-assignments -masm=intel")
set(LIB32 /usr/lib32)
set(CMAKE_SHARED_LINKER_FLAGS "-m32 -Wl,-melf_i386 -L${LIB32} -lSDL2_ttf")
set(CMAKE_SHARED_LINKER_FLAGS "-m32 -Wl,-melf_i386")
set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS})
# find and include SDL2
INCLUDE(FindPkgConfig)
PKG_CHECK_MODULES(SDL2 REQUIRED sdl2 SDL2_ttf)
INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIRS})
endif (UNIX)
INCLUDE_DIRECTORIES(${ORCTLIBS_INCLUDE} ${JANSSON_INCLUDE})
LINK_DIRECTORIES(${LINK_DIRECTORIES} ${LIB32} ${SDL2_LIBRARY_DIRS} ${ORCTLIBS_LIB_DIR})
# find and include SDL2
PKG_CHECK_MODULES(SDL2 REQUIRED sdl2 SDL2_ttf)
INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIRS} ${LIBCURL_INCLUDE_DIRS} ${JANSSON_INCLUDE_DIRS})
LINK_DIRECTORIES(${SDL2_LIBRARY_DIRS} ${JANSSON_LIBRARY_DIRS} ${LIBCURL_LIBRARY_DIRS})
if (WIN32)
# build as library for now, replace with add_executable
@@ -78,8 +84,4 @@ endif (WIN32)
# libopenrct2.dll -> openrct2.dll
set_target_properties(${PROJECT} PROPERTIES PREFIX "")
TARGET_LINK_LIBRARIES(${PROJECT} ${SDL2_LIBRARIES} ${ORCTLIBS_LIB})
if (WIN32)
target_link_libraries(${PROJECT} winmm.lib -limm32 -lversion ws2_32)
endif (WIN32)
TARGET_LINK_LIBRARIES(${PROJECT} ${SDL2_LIBRARIES} ${ORCTLIBS_LIB} ${JANSSON_LIBRARIES} ${HTTPLIBS} ${NETWORKLIBS})

View File

@@ -19,11 +19,6 @@ else()
set(CMAKE_SHARED_LINKER_FLAGS "-static-libgcc -static-libstdc++" CACHE STRING "" FORCE)
endif(${ACTUAL_SYSTEM} MATCHES "Linux")
# find and include SDL2
INCLUDE(FindPkgConfig)
PKG_CHECK_MODULES(SDL2 REQUIRED sdl2 SDL2_ttf)
INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIRS})
if(APPLE)
SET(TARGET_ENVIRONMENT /usr/local/mingw-w32-bin_i686-darwin/i686-w64-mingw32)
else()
@@ -39,3 +34,5 @@ SET(CMAKE_FIND_ROOT_PATH ${TARGET_ENVIRONMENT})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# INCLUDE_DIRECTORIES(${ORCTLIBS_INCLUDE} ${JANSSON_INCLUDE})

View File

@@ -5,62 +5,66 @@ set -e
cachedir=.cache
mkdir -p $cachedir
# Sets default target to "linux", if none specified
TARGET=${TARGET-linux}
if [[ ! -d build ]]; then
mkdir -p build
fi
libversion=2
# keep in sync with version in install.sh
sha256sum=0a7b5ea46e9cb4b19000b69690eae0b75929752f7db192c78bd7ffb61d696835
libVFile="./libversion"
libdir="./lib"
currentversion=0
needsdownload="true"
if [ -f $libVFile ]; then
while read line; do
currentversion=$line
continue
if [ -f $libVFile ]; then
while read line; do
currentversion=$line
continue
done < $libVFile
fi
if [ $currentversion -ge $libversion ]; then
if [ "z$currentversion" == "z$sha256sum" ]; then
needsdownload="false"
fi
if [ ! -d $libdir ]; then
needsdownload="true"
needsdownload="true"
fi
if [[ "$needsdownload" = "true" ]]; then
echo "New libraries need to be downloaded, the script might ask you for sudo access password"
rm -rf ./lib
if [[ -f $cachedir/orctlibs.zip ]]; then
rm -rf $cachedir/orctlibs.zip
fi
if [[ -d /usr/local/cross-tools/orctlibs ]]; then
sudo rm -rf /usr/local/cross-tools/orctlibs
fi
if [[ -d $cachedir/orctlibs ]]; then
rm -rf $cachedir/orctlibs
fi
curl https://download.openrct2.website/dev/lib/mingw -o $cachedir/orctlibs.zip
mkdir -p $cachedir/orctlibs
pushd $cachedir/orctlibs
unzip -uaq ../orctlibs.zip
popd
sudo mkdir -p /usr/local/cross-tools/orctlibs
mkdir -p lib
sudo cp -rf $cachedir/orctlibs/glob/* /usr/local/cross-tools/orctlibs/.
cp -rf $cachedir/orctlibs/local/* ./lib/.
echo $libversion > $libVFile
echo "Found library had sha256sum $currentversion, expected $sha256sum"
echo "New libraries need to be downloaded. Clearing cache and calling ./install.sh"
rm -rf ./lib
if [[ -f $cachedir/orctlibs.zip ]]; then
rm -rf $cachedir/orctlibs.zip
fi
if [[ -d /usr/local/cross-tools/orctlibs ]]; then
sudo rm -rf /usr/local/cross-tools/orctlibs
fi
if [[ -d $cachedir/orctlibs ]]; then
rm -rf $cachedir/orctlibs
fi
./install.sh
fi
pushd build
echo OPENRCT2_CMAKE_OPTS = $OPENRCT_CMAKE_OPTS
cmake -DCMAKE_BUILD_TYPE=Debug $OPENRCT2_CMAKE_OPTS ..
make
echo OPENRCT2_CMAKE_OPTS = $OPENRCT2_CMAKE_OPTS
if [[ $TARGET == "docker32" ]]
then
PARENT=`readlink -f ../`
chmod a+rwx `pwd`
chmod g+s `pwd`
docker run -u travis -v $PARENT:/work/openrct2 -w /work/openrct2/build -i -t janisozaur/openrct2:32bit-only bash -c "cmake ../ $OPENRCT2_CMAKE_OPTS && make"
else
cmake -DCMAKE_BUILD_TYPE=Debug $OPENRCT2_CMAKE_OPTS ..
make
fi
popd
if [[ ! -h openrct2.dll ]]; then
if [[ ! -h openrct2.dll ]]; then
ln -s build/openrct2.dll openrct2.dll
fi
@@ -74,4 +78,3 @@ if [[ -t 1 ]]; then
else
echo -e "\nDone! Run OpenRCT2 by typing:\n\nwine openrct2.exe\n"
fi

View File

@@ -0,0 +1,29 @@
FROM nfnty/arch-mini
RUN pacman -Syyu --noconfirm
RUN pacman -S --noconfirm git curl jshon expac yajl wget unzip cmake
RUN pacman -S --noconfirm --needed base-devel
RUN useradd -mg root travis
RUN usermod -aG wheel travis
RUN sed -i 's/# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/g' /etc/sudoers
WORKDIR /tmp
USER travis
RUN curl -sLO https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=package-query
RUN mv PKGBUILD?h=package-query PKGBUILD
RUN makepkg
USER root
RUN pacman --noconfirm -U *.pkg.tar.xz
USER travis
RUN curl -sLO https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=yaourt
RUN mv PKGBUILD?h=yaourt PKGBUILD
RUN makepkg
USER root
RUN pacman --noconfirm -U *.pkg.tar.xz
RUN pacman -R --noconfirm gcc
RUN yes | pacman -S gcc-libs-multilib
RUN pacman -S --noconfirm gcc-multilib
USER travis
RUN yaourt -S --noconfirm lib32-jansson lib32-curl lib32-sdl2 lib32-sdl2_ttf lib32-speex

View File

@@ -4,10 +4,95 @@ SDL2_PV=2.0.3
SDL2_TTF_PV=2.0.12
cachedir=.cache
liburl=https://openrct.net/launcher/libs/orctlibs.zip
mkdir -p $cachedir
echo `uname`
# Sets default target to "linux", if none specified
TARGET=${TARGET-linux}
# keep in sync with version in build.sh
libversion=3
libVFile="./libversion"
function download_sdl {
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 [[ ! -f $cachedir/SDL2_ttf-devel-${SDL2_TTF_PV}-mingw.tar.gz ]]; then
wget https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-devel-${SDL2_TTF_PV}-mingw.tar.gz --output-document $cachedir/SDL2_ttf-devel-${SDL2_TTF_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
if [[ ! -d $cachedir/SDL2_ttf-${SDL2_TTF_PV} ]]; then
pushd $cachedir
tar -xzf SDL2_ttf-devel-${SDL2_TTF_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
}
function download_libs {
if [[ ! -f $cachedir/orctlibs.zip ]]; then
curl $liburl -o $cachedir/orctlibs.zip;
fi
if [[ ! -d $cachedir/orctlibs ]]; then
mkdir -p $cachedir/orctlibs
pushd $cachedir/orctlibs
unzip -uaq ../orctlibs.zip
popd
fi
}
function install_cross_tools {
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/
sudo cp -r $cachedir/SDL2_ttf-${SDL2_TTF_PV}/i686-w64-mingw32 /usr/local/cross-tools/
fi
if [[ ! -d /usr/local/cross-tools/orctlibs ]]; then
sudo mkdir -p /usr/local/cross-tools/orctlibs
sudo cp -rf $cachedir/orctlibs/glob/* /usr/local/cross-tools/orctlibs/.
fi
}
function install_pkg_config {
if [[ ! -f $cachedir/i686-w64-mingw32-pkg-config ]]; then
# If this fails to work because of newlines, be sure you are running this
# script with Bash, and not sh. We should really move this to a separate
# file.
echo -e "#!/bin/sh\nexport PKG_CONFIG_PATH=/usr/local/cross-tools/i686-w64-mingw32/lib/pkgconfig:/usr/local/cross-tools/orctlibs/lib/pkgconfig\npkg-config \$@" > $cachedir/i686-w64-mingw32-pkg-config;
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
}
function install_local_libs {
mkdir -p lib
cp -rf $cachedir/orctlibs/local/* ./lib/.
}
echo TARGET = $TARGET
if [[ `uname` == "Darwin" ]]; then
echo "Installation of OpenRCT2 assumes you have homebrew and use it to install packages."
@@ -74,91 +159,50 @@ if [[ `uname` == "Darwin" ]]; then
popd
fi
elif [[ `uname` == "Linux" ]]; then
if [[ ! -z "$TRAVIS" ]]; then
sudo dpkg --add-architecture i386
fi
sudo apt-get update
if [[ -z "$TRAVIS" ]]; then
sudo apt-get install -y binutils-mingw-w64-i686 gcc-mingw-w64-i686 g++-mingw-w64-i686 cmake
if [[ -z "$DISABLE_G2_BUILD" ]]; then
sudo apt-get install -y wine
fi
else
apt-cache search libsdl2
apt-cache policy libsdl2-dev:i386
apt-cache policy libsdl2-dev
sudo apt-get install -y --force-yes binutils-mingw-w64-i686 gcc-mingw-w64-i686 g++-mingw-w64-i686 cmake libsdl2-dev:i386 libsdl2-ttf-dev:i386 gcc-4.8 pkg-config:i386 g++-4.8-multilib gcc-4.8-multilib libjansson-dev:i386 libspeex-dev:i386 libspeexdsp-dev:i386 libcurl4-openssl-dev:i386 libcrypto++-dev:i386
export CC=gcc-4.8
export CXX=g++-4.8
# prevent build.sh from re-doing all the steps again
case "$TARGET" in
"linux")
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y --force-yes cmake libsdl2-dev:i386 libsdl2-ttf-dev:i386 gcc-4.8 pkg-config:i386 g++-4.8-multilib gcc-4.8-multilib libjansson-dev:i386 libspeex-dev:i386 libspeexdsp-dev:i386 libcurl4-openssl-dev:i386 libcrypto++-dev:i386
wget https://launchpad.net/ubuntu/+archive/primary/+files/libjansson4_2.7-1ubuntu1_i386.deb
wget https://launchpad.net/ubuntu/+archive/primary/+files/libjansson-dev_2.7-1ubuntu1_i386.deb
sudo dpkg -i libjansson4_2.7-1ubuntu1_i386.deb
sudo dpkg -i libjansson-dev_2.7-1ubuntu1_i386.deb
sudo apt-get install -f
export CC=gcc-4.8
export CXX=g++-4.8
;;
"windows")
sudo apt-get update
sudo apt-get install -y --force-yes binutils-mingw-w64-i686 gcc-mingw-w64-i686 g++-mingw-w64-i686 cmake
;;
"docker32")
docker pull janisozaur/openrct2:32bit-only
;;
*)
echo "unkown target $TARGET"
exit 1
esac
fi
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 [[ ! -f $cachedir/SDL2_ttf-devel-${SDL2_TTF_PV}-mingw.tar.gz ]]; then
wget https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-devel-${SDL2_TTF_PV}-mingw.tar.gz --output-document $cachedir/SDL2_ttf-devel-${SDL2_TTF_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
if [[ ! -d $cachedir/SDL2_ttf-${SDL2_TTF_PV} ]]; then
pushd $cachedir
tar -xzf SDL2_ttf-devel-${SDL2_TTF_PV}-mingw.tar.gz
popd
fi
if [[ ! -f $cachedir/orctlibs.zip ]]; then
curl https://download.openrct2.website/dev/lib/mingw -o $cachedir/orctlibs.zip;
fi
if [[ ! -d $cachedir/orctlibs ]]; then
mkdir -p $cachedir/orctlibs
pushd $cachedir/orctlibs
unzip -uaq ../orctlibs.zip
popd
fi
download_libs
# mind the gap (trailing space)
sha256sum $cachedir/orctlibs.zip | cut -f1 -d\ > $libVFile
echo "Downloaded library with sha256sum: $(cat $libVFile)"
# Local libs are required for all targets
install_local_libs
# 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
if [[ $TARGET == "windows" ]]; then
download_sdl
install_cross_tools
install_pkg_config
# $TARGET == "windows"
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/
sudo cp -r $cachedir/SDL2_ttf-${SDL2_TTF_PV}/i686-w64-mingw32 /usr/local/cross-tools/
fi
if [[ ! -d /usr/local/cross-tools/orctlibs ]]; then
sudo mkdir -p /usr/local/cross-tools/orctlibs
mkdir -p lib
sudo cp -rf $cachedir/orctlibs/glob/* /usr/local/cross-tools/orctlibs/.
cp -rf $cachedir/orctlibs/local/* ./lib/.
fi
if [[ ! -f $cachedir/i686-w64-mingw32-pkg-config ]]; then
# If this fails to work because of newlines, be sure you are running this
# script with Bash, and not sh. We should really move this to a separate
# file.
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
set -x
dpkg -L libsdl2-dev
dpkg -L libsdl2-ttf-dev
set +x
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

View File

@@ -1,9 +1,10 @@
#init
$libversion = 2
$libversion = 3
$path = Split-Path $Script:MyInvocation.MyCommand.Path
$zip = $path+'\orctlibs.zip'
$libs = $path+'\lib'
$libsVFile = $path+'\libversion'
$liburl = 'https://openrct.net/launcher/libs/orctlibs_vs.zip'
$libsTest = Test-Path $libs
#libs version test
@@ -23,7 +24,7 @@ if (!$libsTest -or $needsdownload) {
rm $libs -Recurse -Force
}
mkdir $libs
Invoke-WebRequest https://download.openrct2.website/dev/lib/vs -OutFile $path\orctlibs.zip
Invoke-WebRequest $liburl -OutFile $path\orctlibs.zip
[System.Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem') > $null
[System.IO.Compression.ZipFile]::ExtractToDirectory($zip, $libs)
rm $path\orctlibs.zip -Force -ErrorAction SilentlyContinue

View File

@@ -1,5 +1,6 @@
extern "C" {
#include "http.h"
#include "../platform/platform.h"
}
#ifdef DISABLE_HTTP
@@ -10,7 +11,6 @@ void http_dispose() { }
#else
#include <SDL.h>
#include <jansson/jansson.h>
// cURL includes windows.h, but we don't need all of it.
#define WIN32_LEAN_AND_MEAN
@@ -69,8 +69,8 @@ http_json_response *http_request_json(const char *url)
writeBuffer.length = 0;
writeBuffer.capacity = 0;
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, TRUE);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, true);
curl_easy_setopt(curl, CURLOPT_CAINFO, "curl-ca-bundle.crt");
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &writeBuffer);
@@ -149,4 +149,4 @@ void http_request_json_dispose(http_json_response *response)
free(response);
}
#endif
#endif

View File

@@ -2,7 +2,7 @@
#define _HTTP_H_
#ifndef DISABLE_HTTP
#include <jansson/jansson.h>
#include <jansson.h>
#include "../common.h"
typedef struct {

View File

@@ -337,16 +337,20 @@ bool Network::BeginClient(const char* host, unsigned short port)
return false;
}
sockaddr_in server_address;
#ifdef USE_INET_PTON
char address[64];
if (!network_get_address(address, sizeof(address), host)) {
log_error("Unable to resolve hostname.");
return false;
}
sockaddr_in server_address;
if (inet_pton(AF_INET, address, &server_address.sin_addr) != 1) {
return false;
}
#else
server_address.sin_addr.S_un.S_addr = inet_addr(network_getAddress((char *)host));
#endif // USE_INET_PTON
server_address.sin_family = AF_INET;
server_address.sin_port = htons(port);
@@ -1093,6 +1097,7 @@ void network_send_gamecmd(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uint32
}
}
#ifdef USE_INET_PTON
static bool network_get_address(char *dst, size_t dstLength, const char *host)
{
struct addrinfo *remoteHost;
@@ -1112,6 +1117,21 @@ static bool network_get_address(char *dst, size_t dstLength, const char *host)
// No IPv4 addresses found for host name
return false;
}
#else
static char *network_getAddress(char *host)
{
struct hostent *remoteHost;
struct in_addr addr;
remoteHost = gethostbyname(host);
if (remoteHost != NULL && remoteHost->h_addrtype == AF_INET && remoteHost->h_addr_list[0] != 0) {
addr.s_addr = *(u_long *)remoteHost->h_addr_list[0];
return inet_ntoa(addr);
}
return host;
}
#endif // USE_INET_PTON
#else
int network_get_mode() { return NETWORK_MODE_NONE; }

View File

@@ -44,24 +44,32 @@ extern "C" {
#ifndef DISABLE_NETWORK
#ifdef _WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#define LAST_SOCKET_ERROR() WSAGetLastError()
#undef EWOULDBLOCK
#define EWOULDBLOCK WSAEWOULDBLOCK
#ifndef __MINGW32__
#define USE_INET_PTON
#else
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/tcp.h>
#include <sys/socket.h>
#include <sys/fcntl.h>
typedef int SOCKET;
#define SOCKET_ERROR -1
#define INVALID_SOCKET -1
#define LAST_SOCKET_ERROR() errno
#define closesocket close
#define ioctlsocket ioctl
#warning using deprecated network functions in lieu of inet_pton, inet_ntop
#endif // __MINGW32__
#ifdef _WIN32
#include <winsock2.h>
#ifdef USE_INET_PTON
#include <ws2tcpip.h>
#endif
#define LAST_SOCKET_ERROR() WSAGetLastError()
#undef EWOULDBLOCK
#define EWOULDBLOCK WSAEWOULDBLOCK
#else
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/tcp.h>
#include <sys/socket.h>
#include <sys/fcntl.h>
typedef int SOCKET;
#define SOCKET_ERROR -1
#define INVALID_SOCKET -1
#define LAST_SOCKET_ERROR() errno
#define closesocket close
#define ioctlsocket ioctl
#endif // _WIN32
enum {
@@ -264,7 +272,11 @@ void network_send_chat(const char* text);
void network_send_gamecmd(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uint32 esi, uint32 edi, uint32 ebp, uint8 callback);
void network_print_error();
#ifdef USE_INET_PTON
static bool network_get_address(char *dst, size_t dstLength, const char *host);
#else
static char *network_getAddress(char *host);
#endif // USE_INET_PTON
#ifdef __cplusplus
}