-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Building Windows Artifacts
Eugene Kliuchnikov edited this page Mar 26, 2020
·
1 revision
#!/bin/bash
rm -rf out && mkdir out
BROTLI_TAG="vX.Y.Z" # <-------- specify desired tag / commit has here
function create_toolchain {
BROTLI_TOOLCHAIN=$1
cat >>out/toolchain-${BROTLI_TOOLCHAIN}.cmake << EOF
SET(CMAKE_SYSTEM_NAME Windows)
set(COMPILER_PREFIX "${BROTLI_TOOLCHAIN}-w64-mingw32")
find_program(CMAKE_RC_COMPILER NAMES \${COMPILER_PREFIX}-windres)
find_program(CMAKE_C_COMPILER NAMES \${COMPILER_PREFIX}-gcc)
find_program(CMAKE_CXX_COMPILER NAMES \${COMPILER_PREFIX}-g++)
SET(USER_ROOT_PATH /home/win-dev-${BROTLI_TOOLCHAIN})
SET(CMAKE_FIND_ROOT_PATH /usr/\${COMPILER_PREFIX} \${USER_ROOT_PATH})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
EOF
}
function create_artifact {
BROTLI_TOOLCHAIN=$1
cat >>out/script-${BROTLI_TOOLCHAIN}.sh << EOF
mkdir out-${BROTLI_TOOLCHAIN}
cd out-${BROTLI_TOOLCHAIN}
cmake \
-DCMAKE_TOOLCHAIN_FILE=/out/toolchain-${BROTLI_TOOLCHAIN}.cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_FLAGS="-s" \
..
make
advzip -a4 -i 1 brotli.zip \
brotli.exe
cp -f brotli.zip /out/brotli-${BROTLI_TAG}-win_${BROTLI_TOOLCHAIN}.zip
advzip -a4 -i 1 brotli_dll.zip \
libbrotlicommon.dll libbrotlidec.dll libbrotlienc.dll
cp -f brotli_dll.zip /out/brotli_dll-${BROTLI_TAG}-win_${BROTLI_TOOLCHAIN}.zip
cd ..
EOF
}
create_toolchain "i686"
create_artifact "i686"
create_toolchain "x86_64"
create_artifact "x86_64"
cat >>out/script.sh << EOF
apt-get update
apt-get -y install \
advancecomp cmake git mingw-w64
git clone https://github.com/google/brotli
cd brotli
git checkout $BROTLI_TAG
../script-i686.sh
../script-x86_64.sh
EOF
docker run -it -v `pwd`/out:/out debian:testing /bin/bash -c \
"cd home; cp /out/script*.sh ./; chmod +x ./script*.sh; ./script.sh"
Compressed artifacts will be placed in out
subfolder:
brotli-vX.Y.Z-win_i686.zip
brotli-vX.Y.Z-win_x86_64.zip
brotli_dll-vX.Y.Z-win_i686.zip
brotli_dll-vX.Y.Z-win_x86_64.zip