Skip to content

Commit

Permalink
Tweak Windows scripts to use Cygwin
Browse files Browse the repository at this point in the history
  • Loading branch information
redmanmale authored and nurupo committed May 30, 2020
1 parent 56992b0 commit 787aa63
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 12 deletions.
2 changes: 2 additions & 0 deletions other/docker/windows/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ ARG VERSION_VPX=v1.6.1
ARG SUPPORT_TEST=false
ARG SUPPORT_ARCH_i686=true
ARG SUPPORT_ARCH_x86_64=true
ARG CROSS_COMPILE=true

# Make those available when running the container
ENV SUPPORT_TEST=${SUPPORT_TEST}
ENV SUPPORT_ARCH_i686=${SUPPORT_ARCH_i686}
ENV SUPPORT_ARCH_x86_64=${SUPPORT_ARCH_x86_64}
ENV CROSS_COMPILE=${CROSS_COMPILE}

ADD get_packages.sh .
RUN sh ./get_packages.sh
Expand Down
25 changes: 18 additions & 7 deletions other/docker/windows/build_dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/usr/bin/env sh

set -e -x
# disable on Cygwin otherwise some builds fail
if [ "${CROSS_COMPILE}" = "true" ]; then
set -e -x
fi

#=== Cross-Compile Dependencies ===

Expand All @@ -15,14 +18,14 @@ build()

# prefix that we will copy to the user
PREFIX_DIR="/root/prefix/${ARCH}"
# prefix for things that shouldn't be copied to the user
EXTRA_PREFIX_DIR="/root/extra-prefix/${ARCH}"
mkdir -p "${PREFIX_DIR}" "${EXTRA_PREFIX_DIR}"
rm -rf "${PREFIX_DIR}"
mkdir -p "${PREFIX_DIR}"

export MAKEFLAGS=j$(nproc)
export CFLAGS=-O3

cd /tmp
rm -rf /tmp/*

echo
echo "=== Building Sodium ${VERSION_SODIUM} ${ARCH} ==="
Expand All @@ -36,9 +39,17 @@ build()

echo
echo "=== Building Opus ${VERSION_OPUS} ${ARCH} ==="
git clone --depth=1 --branch="${VERSION_OPUS}" https://github.com/xiph/opus
cd opus
./autogen.sh
if [ "${CROSS_COMPILE}" = "true" ]; then
git clone --depth=1 --branch="${VERSION_OPUS}" https://github.com/xiph/opus
cd opus
./autogen.sh
else
# autogen.sh failed on Cygwin due to ltmain.sh symlink
VERSION_OPUS="${VERSION_OPUS#?}" # remove first 'v'
curl "https://archive.mozilla.org/pub/opus/opus-${VERSION_OPUS}.tar.gz" -o opus.tar.gz
tar xzf opus.tar.gz
cd "opus-${VERSION_OPUS}"
fi
./configure --host="${WINDOWS_TOOLCHAIN}" --prefix="${PREFIX_DIR}" --disable-extra-programs --disable-doc --disable-shared --enable-static
make
make install
Expand Down
33 changes: 28 additions & 5 deletions other/docker/windows/build_toxcore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ build()

# where to put the result of this particular build
RESULT_PREFIX_DIR="/prefix/${ARCH}"
rm -rf "${RESULT_PREFIX_DIR}"
mkdir -p "${RESULT_PREFIX_DIR}"

rm -rf /tmp/*

# where to install static/shared toxcores before deciding whether they should be copied over to the user
STATIC_TOXCORE_PREFIX_DIR="/tmp/static_prefix"
SHARED_TOXCORE_PREFIX_DIR="/tmp/shared_prefix"
Expand All @@ -37,8 +40,18 @@ build()
echo "=== Building toxcore ${ARCH} ==="
export PKG_CONFIG_PATH="${DEP_PREFIX_DIR}/lib/pkgconfig:${EXTRA_DEP_PREFIX_DIR}/lib/pkgconfig"

cp /toxcore /tmp/toxcore -R
if [ "${CROSS_COMPILE}" = "true" ]; then
TOXCORE_DIR="/toxcore"
else
# get Toxcore root
cd "$( cd "$( dirname -- "$0" )" >/dev/null 2>&1 && pwd )"
cd ../../../
TOXCORE_DIR="$(pwd)"
fi

cp "${TOXCORE_DIR}" /tmp/toxcore -R
cd /tmp/toxcore/build

echo "
SET(CMAKE_SYSTEM_NAME Windows)
Expand All @@ -59,7 +72,7 @@ build()
-DENABLE_STATIC=ON \
-DCMAKE_C_FLAGS="${CMAKE_C_FLAGS}" \
-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS}" \
-DCMAKE_EXE_LINKER_FLAGS="${CMAKE_EXE_LINKER_FLAGS}" \
-DCMAKE_EXE_LINKER_FLAGS="${CMAKE_EXE_LINKER_FLAGS} -fstack-protector" \
-DCMAKE_SHARED_LINKER_FLAGS="${CMAKE_SHARED_LINKER_FLAGS}" \
${EXTRA_CMAKE_FLAGS} \
..
Expand Down Expand Up @@ -99,17 +112,25 @@ build()
do
${WINDOWS_TOOLCHAIN}-ar xv ${archive}
done

if [ "${CROSS_COMPILE}" = "true" ]; then
LIBWINPTHREAD="/usr/${WINDOWS_TOOLCHAIN}/sys-root/mingw/lib/libwinpthread.a"
else
LIBWINPTHREAD="/usr/${WINDOWS_TOOLCHAIN}/lib/libwinpthread.a"
fi

${WINDOWS_TOOLCHAIN}-gcc -Wl,--export-all-symbols \
-Wl,--out-implib=libtox.dll.a \
-shared \
-o libtox.dll \
*.obj \
${STATIC_TOXCORE_PREFIX_DIR}/lib/*.a \
${DEP_PREFIX_DIR}/lib/*.a \
/usr/${WINDOWS_TOOLCHAIN}/lib/libwinpthread.a \
"${LIBWINPTHREAD}" \
-liphlpapi \
-lws2_32 \
-static-libgcc
-static-libgcc \
-lssp
cp libtox.dll.a ${RESULT_PREFIX_DIR}/lib
mkdir -p ${RESULT_PREFIX_DIR}/bin
cp libtox.dll ${RESULT_PREFIX_DIR}/bin
Expand Down Expand Up @@ -165,4 +186,6 @@ echo "Built toxcore successfully!"
echo

# since we are building as root
chmod 777 /prefix -R
if [ "${CROSS_COMPILE}" = "true" ]; then
chmod 777 /prefix -R
fi
20 changes: 20 additions & 0 deletions other/windows_build_script_toxcore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh

export VERSION_SODIUM="1.0.18"
export VERSION_OPUS="v1.2.1"
export VERSION_VPX="v1.6.1"

export SUPPORT_TEST=false
export SUPPORT_ARCH_i686=false
export SUPPORT_ARCH_x86_64=true
export CROSS_COMPILE=false

sh ./other/docker/windows/build_dependencies.sh

export ENABLE_TEST=false
export ALLOW_TEST_FAILURE=false
export ENABLE_ARCH_i686=false
export ENABLE_ARCH_x86_64=true
export EXTRA_CMAKE_FLAGS="-DWARNINGS=OFF -DBOOTSTRAP_DAEMON=OFF -DTEST_TIMEOUT_SECONDS=300"

sh ./other/docker/windows/build_toxcore.sh

0 comments on commit 787aa63

Please sign in to comment.