diff --git a/.travis.yml b/.travis.yml index 2efa367..327345e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -95,6 +95,34 @@ api_key: $GH_REPO_TOKEN on: tags: true + - d: ldc + script: echo "Deploying to GitHub releases (win32) ..." && ./release-windows.sh + addons: + apt: + packages: + - p7zip-full + deploy: + - provider: releases + file_glob: true + file: bin/dub-*.zip + skip_cleanup: true + api_key: $GH_REPO_TOKEN + on: + tags: true + - d: ldc + script: echo "Deploying to GitHub releases (win64) ..." && ARCH=64 ./release-windows.sh + addons: + apt: + packages: + - p7zip-full + deploy: + - provider: releases + file_glob: true + file: bin/dub-*.zip + skip_cleanup: true + api_key: $GH_REPO_TOKEN + on: + tags: true - stage: update-latest script: echo "Deploying to GitHub pages ..." && mkdir -p docs && git describe --abbrev=0 --tags > docs/LATEST deploy: diff --git a/release-windows.sh b/release-windows.sh new file mode 100755 index 0000000..0deab6b --- /dev/null +++ b/release-windows.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# Build the Windows binaries under Linux +set -eux -o pipefail + +BIN_NAME=dub + +# Allow the script to be run from anywhere +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd $DIR + +source setup-ldc-windows.sh + +# Run LDC with cross-compilation +archiveName="$BIN_NAME-$VERSION-$OS-$ARCH_SUFFIX.zip" +echo "Building $archiveName" +mkdir -p bin +DC=ldmd2 DFLAGS="-release" ./build.sh + +cd bin +mv "${BIN_NAME}" "${BIN_NAME}.exe" +zip "$archiveName" "${BIN_NAME}.exe" diff --git a/setup-ldc-windows.sh b/setup-ldc-windows.sh new file mode 100644 index 0000000..0656b5a --- /dev/null +++ b/setup-ldc-windows.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +# sets up LDC for cross-compilation. Source this script, s.t. the new LDC is in PATH + +LDC_VERSION="1.13.0" +ARCH=${ARCH:-32} +VERSION=$(git describe --abbrev=0 --tags) +OS=windows + +# Step 0: install ldc +if [ ! -f install.sh ] ; then + wget https://dlang.org/install.sh +fi +. $(bash ./install.sh -a "ldc-${LDC_VERSION}") + +# for the install.sh script only +LDC_PATH="$(dirname $(dirname $(which ldc2)))" + +# Step 1a: download the LDC x64 windows binaries +if [ "${ARCH}" == 64 ] && [ ! -d "ldc2-${LDC_VERSION}-windows-x64" ] ; then + wget "https://github.com/ldc-developers/ldc/releases/download/v1.13.0/ldc2-${LDC_VERSION}-windows-x64.7z" + 7z x "ldc2-${LDC_VERSION}-windows-x64.7z" > /dev/null + # Step 2a: Add LDC windows binaries to LDC Linux + if [ ! -d "${LDC_PATH}/lib-win64" ] ; then + cp -r ldc2-1.13.0-windows-x64/lib "${LDC_PATH}/lib-win64" + cat >> "$LDC_PATH"/etc/ldc2.conf < /dev/null + # Step 2b: Add LDC windows binaries to LDC Linux + if [ ! -d "${LDC_PATH}/lib-win32" ] ; then + cp -r ldc2-1.13.0-windows-x86/lib "${LDC_PATH}/lib-win32" + cat >> "$LDC_PATH"/etc/ldc2.conf <