From 06e0dd51c4e49143bc4acf8a8c49ca35c56de4df Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Thu, 17 Jan 2019 09:24:12 +0100 Subject: [PATCH] Build win{32,64} binaries with LDC (#568) Build win{32,64} binaries with LDC merged-on-behalf-of: BBasile --- .travis.yml | 29 ++++++++++++++---- makefile | 10 ++++++- release-windows.sh | 29 ++++++------------ setup-ldc-windows.sh | 70 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 112 insertions(+), 26 deletions(-) create mode 100644 setup-ldc-windows.sh diff --git a/.travis.yml b/.travis.yml index 8fcbfd4..860ed04 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ os: env: - BUILD= - BUILD=dub - + branches: only: - master @@ -24,7 +24,7 @@ jobs: include: - stage: GitHub Release #if: tag IS present - d: ldc-1.8.0 + d: ldc-1.13.0 os: linux script: echo "Deploying to GitHub releases ..." && ./release.sh deploy: @@ -38,7 +38,7 @@ jobs: tags: true - stage: GitHub Release #if: tag IS present - d: ldc-1.8.0 + d: ldc-1.13.0 os: osx script: echo "Deploying to GitHub releases ..." && ./release.sh deploy: @@ -56,12 +56,31 @@ jobs: os: linux language: generic sudo: yes - script: echo "Deploying to GitHub releases ..." && ./release-windows.sh && ARCH=64 ./release-windows.sh + script: echo "Deploying to GitHub releases ..." && ./release-windows.sh + addons: + apt: + packages: + - p7zip-full + deploy: + provider: releases + api_key: $GH_REPO_TOKEN + file_glob: true + file: bin/dcd-*.zip + skip_cleanup: true + on: + repo: dlang-community/DCD + tags: true + - stage: GitHub Release + #if: tag IS present + d: dmd + os: linux + language: generic + sudo: yes + script: echo "Deploying to GitHub releases ..." && ARCH=64 ./release-windows.sh addons: apt: packages: - p7zip-full - - wine deploy: provider: releases api_key: $GH_REPO_TOKEN diff --git a/makefile b/makefile index 6b3999e..2bf0be9 100644 --- a/makefile +++ b/makefile @@ -57,6 +57,10 @@ LDC_CLIENT_FLAGS := -Imsgpack-d/src\ -oq\ -of=bin/dcd-client +override DMD_CLIENT_FLAGS += $(DFLAGS) +override LDC_CLIENT_FLAGS += $(DFLAGS) +override GDC_CLIENT_FLAGS += $(DFLAGS) + SERVER_SRC := \ $(shell find src/dcd/common -name "*.d")\ $(shell find src/dcd/server -name "*.d")\ @@ -122,6 +126,10 @@ LDC_SERVER_FLAGS := -Icontainers/src\ -O5\ -release +override DMD_SERVER_FLAGS += $(DFLAGS) +override LDC_SERVER_FLAGS += $(DFLAGS) +override GDC_SERVER_FLAGS += $(DFLAGS) + dmdclient: githash mkdir -p bin ${DMD} ${CLIENT_SRC} ${DMD_CLIENT_FLAGS} @@ -143,7 +151,7 @@ gdcserver: githash ${GDC} ${SERVER_SRC} ${GDC_SERVER_FLAGS} ldcclient: githash - ${LDC} ${CLIENT_SRC} ${LDC_CLIENT_FLAGS} + ${LDC} ${CLIENT_SRC} ${LDC_CLIENT_FLAGS} -oq -of=bin/dcd-client ldcserver: githash ${LDC} $(LDC_SERVER_FLAGS) ${SERVER_SRC} -oq -of=bin/dcd-server diff --git a/release-windows.sh b/release-windows.sh index 82ef505..45bd1a7 100755 --- a/release-windows.sh +++ b/release-windows.sh @@ -1,33 +1,22 @@ #!/usr/bin/env bash -# Build the Windows binaries under Linux (requires wine) +# Build the Windows binaries under Linux set -eux -o pipefail -VERSION=$(git describe --abbrev=0 --tags) -OS=windows -if [ "${ARCH:-32}" == "64" ] ; then - ARCH_SUFFIX="x86_64" - export MFLAGS="-m64" -else - ARCH_SUFFIX="x86" - export MFLAGS="-m32" -fi +BIN_NAME=dcd # Allow the script to be run from anywhere DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $DIR -# Step 1: download the DMD binaries -if [ ! -d dmd2 ] ; then - wget http://downloads.dlang.org/releases/2.x/2.080.0/dmd.2.080.0.windows.7z - 7z x dmd.2.080.0.windows.7z > /dev/null -fi +source setup-ldc-windows.sh -# Step 2: Run DMD via wineconsole -archiveName="dcd-$VERSION-$OS-$ARCH_SUFFIX.zip" +# Run LDC with cross-compilation +archiveName="$BIN_NAME-$VERSION-$OS-$ARCH_SUFFIX.zip" echo "Building $archiveName" mkdir -p bin -git describe --tags > bin/githash.txt # no git installed under Wine -DC="$DIR/dmd2/windows/bin/dmd.exe" wine cmd /C build.bat +DC=ldmd2 make ldcclient ldcserver cd bin -zip "$archiveName" dcd-server.exe dcd-client.exe +mv dcd-client dcd-client.exe +mv dcd-server dcd-server.exe +zip "$archiveName" "dcd-client.exe" "dcd-server.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 <