1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

feat(build): hash everything in Windows cross-compilation

This commit is contained in:
Maxim Biro 2017-10-21 17:17:51 -04:00
parent 9358297af8
commit 319d871be3

View File

@ -177,6 +177,20 @@ check_sha256()
fi fi
} }
# If it's not a tarball but a git repo, let's check a hash of a file containing hashes of all files
check_sha256_git()
{
# There shoudl be .git directory
if [ ! -d ".git" ]
then
echo "Error: this function should be called in the root of a git repository."
exit 1
fi
# Create a file listing hashes of all the files except .git/*
find . -type f | grep -v "^./.git" | LC_COLLATE=C sort --stable --ignore-case | xargs sha256sum > /tmp/hashes.sha
check_sha256 "$1" "/tmp/hashes.sha"
}
# Strip binaries to reduce file size, we don't need this information anyway # Strip binaries to reduce file size, we don't need this information anyway
strip_all() strip_all()
{ {
@ -356,17 +370,17 @@ set -u
SQLCIPHER_PREFIX_DIR="$DEP_DIR/libsqlcipher" SQLCIPHER_PREFIX_DIR="$DEP_DIR/libsqlcipher"
SQLCIPHER_VERSION=v3.4.1 SQLCIPHER_VERSION=v3.4.1
SQLCIPHER_HASH="4172cc6e5a79d36e178d36bd5cc467a938e08368952659bcd95eccbaf0fa4ad4"
if [ ! -f "$SQLCIPHER_PREFIX_DIR/done" ] if [ ! -f "$SQLCIPHER_PREFIX_DIR/done" ]
then then
rm -rf "$SQLCIPHER_PREFIX_DIR" rm -rf "$SQLCIPHER_PREFIX_DIR"
mkdir -p "$SQLCIPHER_PREFIX_DIR" mkdir -p "$SQLCIPHER_PREFIX_DIR"
git clone \ wget https://github.com/sqlcipher/sqlcipher/archive/$SQLCIPHER_VERSION.tar.gz -O sqlcipher.tar.gz
--branch $SQLCIPHER_VERSION \ check_sha256 "$SQLCIPHER_HASH" "sqlcipher.tar.gz"
--depth 1 \ bsdtar -xf sqlcipher.tar.gz
https://github.com/sqlcipher/sqlcipher \ rm sqlcipher.tar.gz
sqlcipher cd sqlcipher*
cd sqlcipher
sed -i s/'LIBS="-lcrypto $LIBS"'/'LIBS="-lcrypto -lgdi32 $LIBS"'/g configure sed -i s/'LIBS="-lcrypto $LIBS"'/'LIBS="-lcrypto -lgdi32 $LIBS"'/g configure
sed -i s/'LIBS="-lcrypto $LIBS"'/'LIBS="-lcrypto -lgdi32 $LIBS"'/g configure sed -i s/'LIBS="-lcrypto $LIBS"'/'LIBS="-lcrypto -lgdi32 $LIBS"'/g configure
@ -405,7 +419,7 @@ EOF
echo -n $SQLCIPHER_VERSION > $SQLCIPHER_PREFIX_DIR/done echo -n $SQLCIPHER_VERSION > $SQLCIPHER_PREFIX_DIR/done
cd .. cd ..
rm -rf ./sqlcipher rm -rf ./sqlcipher*
else else
echo "Using cached build of SQLCipher `cat $SQLCIPHER_PREFIX_DIR/done`" echo "Using cached build of SQLCipher `cat $SQLCIPHER_PREFIX_DIR/done`"
fi fi
@ -499,6 +513,7 @@ fi
OPENAL_PREFIX_DIR="$DEP_DIR/libopenal" OPENAL_PREFIX_DIR="$DEP_DIR/libopenal"
OPENAL_VERSION=b80570bed017de60b67c6452264c634085c3b148 OPENAL_VERSION=b80570bed017de60b67c6452264c634085c3b148
OPENAL_HASH="734ef00895a9c1eb1505c11d638030b73593376df75da66ac5db6aa3e2f76807"
if [ ! -f "$OPENAL_PREFIX_DIR/done" ] if [ ! -f "$OPENAL_PREFIX_DIR/done" ]
then then
rm -rf "$OPENAL_PREFIX_DIR" rm -rf "$OPENAL_PREFIX_DIR"
@ -507,6 +522,10 @@ then
git clone https://github.com/irungentoo/openal-soft-tox openal-soft-tox git clone https://github.com/irungentoo/openal-soft-tox openal-soft-tox
cd openal* cd openal*
git checkout $OPENAL_VERSION git checkout $OPENAL_VERSION
check_sha256_git "$OPENAL_HASH"
mkdir -p build
cd build
echo " echo "
SET(CMAKE_SYSTEM_NAME Windows) SET(CMAKE_SYSTEM_NAME Windows)
@ -530,12 +549,15 @@ then
-DALSOFT_EXAMPLES=OFF \ -DALSOFT_EXAMPLES=OFF \
-DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \ -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
-DDSOUND_INCLUDE_DIR=/usr/$ARCH-w64-mingw32/include \ -DDSOUND_INCLUDE_DIR=/usr/$ARCH-w64-mingw32/include \
-DDSOUND_LIBRARY=/usr/$ARCH-w64-mingw32/lib/libdsound.a -DDSOUND_LIBRARY=/usr/$ARCH-w64-mingw32/lib/libdsound.a \
..
make make
make install make install
echo -n $OPENAL_VERSION > $OPENAL_PREFIX_DIR/done echo -n $OPENAL_VERSION > $OPENAL_PREFIX_DIR/done
cd ..
cd .. cd ..
rm -rf ./openal* rm -rf ./openal*
else else
@ -547,6 +569,7 @@ fi
FILTERAUDIO_PREFIX_DIR="$DEP_DIR/libfilteraudio" FILTERAUDIO_PREFIX_DIR="$DEP_DIR/libfilteraudio"
FILTERAUDIO_VERSION=ada2f4fdc04940cdeee47caffe43add4fa017096 FILTERAUDIO_VERSION=ada2f4fdc04940cdeee47caffe43add4fa017096
FILTERAUDIO_HASH="cf481e87c860aaf28b50d125195d84556f36d0ebb529d7ebdac39f8cc497256a"
if [ ! -f "$FILTERAUDIO_PREFIX_DIR/done" ] if [ ! -f "$FILTERAUDIO_PREFIX_DIR/done" ]
then then
rm -rf "$FILTERAUDIO_PREFIX_DIR" rm -rf "$FILTERAUDIO_PREFIX_DIR"
@ -555,6 +578,7 @@ then
git clone https://github.com/irungentoo/filter_audio filter_audio git clone https://github.com/irungentoo/filter_audio filter_audio
cd filter* cd filter*
git checkout $FILTERAUDIO_VERSION git checkout $FILTERAUDIO_VERSION
check_sha256_git "$FILTERAUDIO_HASH"
$ARCH-w64-mingw32-gcc -O2 -g0 -c \ $ARCH-w64-mingw32-gcc -O2 -g0 -c \
aec/aec_core.c \ aec/aec_core.c \
@ -741,20 +765,19 @@ fi
# Opus # Opus
OPUS_PREFIX_DIR="$DEP_DIR/libopus" OPUS_PREFIX_DIR="$DEP_DIR/libopus"
OPUS_VERSION=v1.2.1 OPUS_VERSION=1.2.1
OPUS_HASH="cfafd339ccd9c5ef8d6ab15d7e1a412c054bf4cb4ecbbbcc78c12ef2def70732"
if [ ! -f "$OPUS_PREFIX_DIR/done" ] if [ ! -f "$OPUS_PREFIX_DIR/done" ]
then then
rm -rf "$OPUS_PREFIX_DIR" rm -rf "$OPUS_PREFIX_DIR"
mkdir -p "$OPUS_PREFIX_DIR" mkdir -p "$OPUS_PREFIX_DIR"
git clone \ wget https://archive.mozilla.org/pub/opus/opus-$OPUS_VERSION.tar.gz
--branch $OPUS_VERSION \ check_sha256 "$OPUS_HASH" "opus-$OPUS_VERSION.tar.gz"
--depth 1 \ bsdtar -xf opus*.tar.gz
git://git.opus-codec.org/opus.git \ rm opus*.tar.gz
opus cd opus*
cd opus
./autogen.sh
CFLAGS="-O2 -g0" ./configure --host="$ARCH-w64-mingw32" \ CFLAGS="-O2 -g0" ./configure --host="$ARCH-w64-mingw32" \
--prefix="$OPUS_PREFIX_DIR" \ --prefix="$OPUS_PREFIX_DIR" \
--disable-shared \ --disable-shared \
@ -766,7 +789,7 @@ then
echo -n $OPUS_VERSION > $OPUS_PREFIX_DIR/done echo -n $OPUS_VERSION > $OPUS_PREFIX_DIR/done
cd .. cd ..
rm -rf ./opus rm -rf ./opus*
else else
echo "Using cached build of Opus `cat $OPUS_PREFIX_DIR/done`" echo "Using cached build of Opus `cat $OPUS_PREFIX_DIR/done`"
fi fi
@ -776,19 +799,18 @@ fi
SODIUM_PREFIX_DIR="$DEP_DIR/libsodium" SODIUM_PREFIX_DIR="$DEP_DIR/libsodium"
SODIUM_VERSION=1.0.15 SODIUM_VERSION=1.0.15
SODIUM_HASH="fb6a9e879a2f674592e4328c5d9f79f082405ee4bb05cb6e679b90afe9e178f4"
if [ ! -f "$SODIUM_PREFIX_DIR/done" ] if [ ! -f "$SODIUM_PREFIX_DIR/done" ]
then then
rm -rf "$SODIUM_PREFIX_DIR" rm -rf "$SODIUM_PREFIX_DIR"
mkdir -p "$SODIUM_PREFIX_DIR" mkdir -p "$SODIUM_PREFIX_DIR"
git clone \ wget https://download.libsodium.org/libsodium/releases/libsodium-$SODIUM_VERSION.tar.gz
--branch $SODIUM_VERSION \ check_sha256 "$SODIUM_HASH" "libsodium-$SODIUM_VERSION.tar.gz"
--depth 1 \ bsdtar -xf libsodium*.tar.gz
https://github.com/jedisct1/libsodium \ rm libsodium*.tar.gz
libsodium cd libsodium*
cd libsodium
./autogen.sh
./configure --host="$ARCH-w64-mingw32" \ ./configure --host="$ARCH-w64-mingw32" \
--prefix="$SODIUM_PREFIX_DIR" \ --prefix="$SODIUM_PREFIX_DIR" \
--disable-shared \ --disable-shared \
@ -799,7 +821,7 @@ then
echo -n $SODIUM_VERSION > $SODIUM_PREFIX_DIR/done echo -n $SODIUM_VERSION > $SODIUM_PREFIX_DIR/done
cd .. cd ..
rm -rf ./libsodium rm -rf ./libsodium*
else else
echo "Using cached build of Sodium `cat $SODIUM_PREFIX_DIR/done`" echo "Using cached build of Sodium `cat $SODIUM_PREFIX_DIR/done`"
fi fi
@ -808,18 +830,18 @@ fi
# VPX # VPX
VPX_PREFIX_DIR="$DEP_DIR/libvpx" VPX_PREFIX_DIR="$DEP_DIR/libvpx"
VPX_VERSION=v1.6.1 VPX_VERSION=1.6.1
VPX_HASH="1c2c0c2a97fba9474943be34ee39337dee756780fc12870ba1dc68372586a819"
if [ ! -f "$VPX_PREFIX_DIR/done" ] if [ ! -f "$VPX_PREFIX_DIR/done" ]
then then
rm -rf "$VPX_PREFIX_DIR" rm -rf "$VPX_PREFIX_DIR"
mkdir -p "$VPX_PREFIX_DIR" mkdir -p "$VPX_PREFIX_DIR"
git clone \ wget http://storage.googleapis.com/downloads.webmproject.org/releases/webm/libvpx-$VPX_VERSION.tar.bz2
--branch $VPX_VERSION \ check_sha256 "$VPX_HASH" "libvpx-$VPX_VERSION.tar.bz2"
--depth 1 \ bsdtar -xf libvpx-*.tar.bz2
https://github.com/webmproject/libvpx \ rm libvpx*.tar.bz2
libvpx cd libvpx*
cd libvpx
if [[ "$ARCH" == "x86_64" ]] if [[ "$ARCH" == "x86_64" ]]
then then
@ -842,7 +864,7 @@ then
echo -n $VPX_VERSION > $VPX_PREFIX_DIR/done echo -n $VPX_VERSION > $VPX_PREFIX_DIR/done
cd .. cd ..
rm -rf ./libvpx rm -rf ./libvpx*
else else
echo "Using cached build of VPX `cat $VPX_PREFIX_DIR/done`" echo "Using cached build of VPX `cat $VPX_PREFIX_DIR/done`"
fi fi
@ -851,18 +873,21 @@ fi
# Toxcore # Toxcore
TOXCORE_PREFIX_DIR="$DEP_DIR/libtoxcore" TOXCORE_PREFIX_DIR="$DEP_DIR/libtoxcore"
TOXCORE_VERSION=v0.1.10 TOXCORE_VERSION=0.1.10
TOXCORE_HASH=4e9a2881dd0ea8e65a35fc9621644ccf500c1797a2d37983b0057ed3be971299
if [ ! -f "$TOXCORE_PREFIX_DIR/done" ] if [ ! -f "$TOXCORE_PREFIX_DIR/done" ]
then then
rm -rf "$TOXCORE_PREFIX_DIR" rm -rf "$TOXCORE_PREFIX_DIR"
mkdir -p "$TOXCORE_PREFIX_DIR" mkdir -p "$TOXCORE_PREFIX_DIR"
git clone \ wget https://github.com/TokTok/c-toxcore/releases/download/v$TOXCORE_VERSION/c-toxcore-$TOXCORE_VERSION.tar.gz
--branch $TOXCORE_VERSION \ check_sha256 "$TOXCORE_HASH" "c-toxcore-$TOXCORE_VERSION.tar.gz"
--depth 1 \ bsdtar -xf c-toxcore*.tar.gz
https://github.com/TokTok/c-toxcore \ rm c-toxcore*.tar.gz
c-toxcore cd c-toxcore*
cd c-toxcore
mkdir -p build
cd build
export PKG_CONFIG_PATH="$OPUS_PREFIX_DIR/lib/pkgconfig:$SODIUM_PREFIX_DIR/lib/pkgconfig:$VPX_PREFIX_DIR/lib/pkgconfig" export PKG_CONFIG_PATH="$OPUS_PREFIX_DIR/lib/pkgconfig:$SODIUM_PREFIX_DIR/lib/pkgconfig:$VPX_PREFIX_DIR/lib/pkgconfig"
export PKG_CONFIG_LIBDIR="/usr/$ARCH-w64-mingw32" export PKG_CONFIG_LIBDIR="/usr/$ARCH-w64-mingw32"
@ -883,7 +908,8 @@ then
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=Release \
-DENABLE_STATIC=ON \ -DENABLE_STATIC=ON \
-DENABLE_SHARED=OFF \ -DENABLE_SHARED=OFF \
-DCMAKE_TOOLCHAIN_FILE=toolchain.cmake -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
..
make make
make install make install
@ -893,12 +919,42 @@ then
unset PKG_CONFIG_LIBDIR unset PKG_CONFIG_LIBDIR
cd .. cd ..
rm -rf ./c-toxcore
cd ..
rm -rf ./c-toxcore*
else else
echo "Using cached build of Toxcore `cat $TOXCORE_PREFIX_DIR/done`" echo "Using cached build of Toxcore `cat $TOXCORE_PREFIX_DIR/done`"
fi fi
# mingw-w64-debug-scripts
MINGW_W64_DEBUG_SCRIPTS_PREFIX_DIR="$DEP_DIR/mingw-w64-debug-scripts"
MINGW_W64_DEBUG_SCRIPTS_VERSION=7341e1ffdea352e5557f3fcae51569f13e1ef270
MINGW_W64_DEBUG_SCRIPTS_HASH="a92883ddfe83780818347fda4ac07bce61df9226818df2f52fe4398fe733e204"
if [ ! -f "$MINGW_W64_DEBUG_SCRIPTS_PREFIX_DIR/done" ]
then
rm -rf "$MINGW_W64_DEBUG_SCRIPTS_PREFIX_DIR"
mkdir -p "$MINGW_W64_DEBUG_SCRIPTS_PREFIX_DIR"
# Get dbg executable and the debug scripts
git clone https://github.com/nurupo/mingw-w64-debug-scripts mingw-w64-debug-scripts
cd mingw-w64-debug-scripts
git checkout $MINGW_W64_DEBUG_SCRIPTS_VERSION
check_sha256_git "$MINGW_W64_DEBUG_SCRIPTS_HASH"
make $ARCH EXE_NAME=qtox.exe
mkdir -p "$MINGW_W64_DEBUG_SCRIPTS_PREFIX_DIR/bin"
mv output/$ARCH/* "$MINGW_W64_DEBUG_SCRIPTS_PREFIX_DIR/bin/"
echo -n $MINGW_W64_DEBUG_SCRIPTS_VERSION > $MINGW_W64_DEBUG_SCRIPTS_PREFIX_DIR/done
cd ..
rm -rf ./mingw-w64-debug-scripts
else
echo "Using cached build of mingw-w64-debug-scripts `cat $MINGW_W64_DEBUG_SCRIPTS_PREFIX_DIR/done`"
fi
# Stop here if running the second stage on Travis CI # Stop here if running the second stage on Travis CI
set +u set +u
if [ "$TRAVIS_CI_STAGE" == "stage2" ] if [ "$TRAVIS_CI_STAGE" == "stage2" ]
@ -911,6 +967,7 @@ then
fi fi
set -u set -u
strip_all strip_all
@ -926,7 +983,7 @@ cd qtox
cp -a $QTOX_SRC_DIR/. . cp -a $QTOX_SRC_DIR/. .
rm -rf ./build rm -rf ./build
mkdir build mkdir -p build
cd build cd build
PKG_CONFIG_PATH="" PKG_CONFIG_PATH=""
@ -995,12 +1052,7 @@ then
cp -r "$PWD/src" "$QTOX_PREFIX_DIR/$PWD" cp -r "$PWD/src" "$QTOX_PREFIX_DIR/$PWD"
# Get dbg executable and the debug scripts # Get dbg executable and the debug scripts
git clone https://github.com/nurupo/mingw-w64-debug-scripts cp -r $MINGW_W64_DEBUG_SCRIPTS_PREFIX_DIR/bin/* "$QTOX_PREFIX_DIR/"
cd mingw-w64-debug-scripts
git checkout 7341e1ffdea352e5557f3fcae51569f13e1ef270
make $ARCH EXE_NAME=qtox.exe
mv output/$ARCH/* "$QTOX_PREFIX_DIR/"
cd ..
fi fi
# Strip # Strip