[Azure-Pipelines]: Build DMD with VisualD

This commit is contained in:
Sebastian Wilzbach 2019-03-05 08:10:43 +01:00
parent 306f927e8a
commit 4ddf1668cb
8 changed files with 230 additions and 174 deletions

View file

@ -0,0 +1,121 @@
#!/usr/bin/env bash
set -euxo pipefail
CURL_USER_AGENT="DMD-CI $(curl --version | head -n 1)"
DMD_DIR="$PWD"
download() {
local url="$1"
local path="$2"
curl -fsSL -A "$CURL_USER_AGENT" --connect-timeout 5 --speed-time 30 --speed-limit 1024 --retry 5 --retry-delay 5 "$url" -o "$path"
}
clone() {
local url="$1"
local path="$2"
local branch="$3"
for i in {0..4}; do
if git clone --depth 1 --branch "$branch" "$url" "$path" "${@:4}" --quiet; then
break
elif [ $i -lt 4 ]; then
sleep $((1 << $i))
else
echo "Failed to clone: ${url}"
exit 1
fi
done
}
################################################################################
# Download LDC
################################################################################
ldc() {
LDC_DIR="ldc2-${LDC_VERSION}-windows-multilib"
LDC_INSTALLER="${LDC_DIR}.7z"
LDC_URL="https://github.com/ldc-developers/ldc/releases/download/v${LDC_VERSION}/${LDC_INSTALLER}"
if [ ! -e "$LDC_INSTALLER" ] ; then
download "$LDC_URL" "$LDC_INSTALLER"
fi
7z x "$LDC_INSTALLER" > /dev/null
if [ ! -e "$LDC_DIR/bin/ldmd2.exe" ] ; then
echo "Unexpected LDC installation, $LDC_INSTALLER/bin/ldmd2.exe missing"
exit 1
fi
}
################################################################################
# Download VisualD
################################################################################
visuald() {
local VISUALD_INSTALLER="VisualD-${VISUALD_VER}.exe"
local VISUALD_URL="https://github.com/dlang/visuald/releases/download/${VISUALD_VER}/${VISUALD_INSTALLER}"
if [ ! -e "$VISUALD_INSTALLER" ] ; then
download "$VISUALD_URL" "$VISUALD_INSTALLER"
fi
}
################################################################################
# Download DigitalMars Make
################################################################################
dm_make() {
download "http://downloads.dlang.org/other/dm857c.zip" dmc.zip
unzip dmc.zip > /dev/null
export DMC="$PWD/dm/bin/dmc.exe"
export DM_MAKE="$PWD/dm/bin/make.exe"
mkdir -p dm/path
cp "$DMC" "$DM_MAKE" "dm/path"
}
################################################################################
# Download DigitalMars Make
################################################################################
install_grep() {
local tools_dir="${DMD_DIR}/tools"
mkdir -p "$tools_dir"
cd "$tools_dir"
download "http://downloads.dlang.org/other/grep-3.1.zip" "grep-3.1.zip"
unzip "grep-3.1.zip" # contains grep.exe
#export PATH="${tools_dir}:$PATH"
}
################################################################################
# Checkout other repositories
################################################################################
clone_repos() {
local REPO_BRANCH="$SYSTEM_PULLREQUEST_TARGETBRANCH"
for proj in druntime phobos; do
if [ "$REPO_BRANCH" != master ] && [ "$REPO_BRANCH" != stable ] &&
! git ls-remote --exit-code --heads "https://github.com/dlang/$proj.git" "$REPO_BRANCH" > /dev/null; then
# use master as fallback for other repos to test feature branches
clone "https://github.com/dlang/$proj.git" "${DMD_DIR}/../$proj" master
echo "[GIT_CLONE] Switched $proj to branch master \$(REPO_BRANCH=$REPO_BRANCH)"
else
clone "https://github.com/dlang/$proj.git" "${DMD_DIR}/../$proj" "$REPO_BRANCH"
echo "[GIT_CLONE] Switched $proj to branch $REPO_BRANCH"
fi
done
}
echo "[STEP]: Downloading LDC"
ldc
echo "[STEP]: Downloading VisualD"
visuald
echo "[STEP]: Downloading DigitalMars make"
dm_make
echo "[STEP]: Downloading grep"
install_grep
echo "[STEP]: Cloning repositories"
clone_repos

View file

@ -0,0 +1,84 @@
steps:
- script: |
:: Use Windows CRLF line endings for checked-out text files
git config --global core.autocrlf true
set
displayName: Print environment variables
- checkout: self
fetchDepth: 1
- script: |
bash --version
sh --login .azure-pipelines/windows-visual-studio.sh
displayName: Download requires binaries
- script: |
@echo on
call "%VSINSTALLDIR%\VC\Auxiliary\Build\vcvarsall.bat" %ARCH%
set LDC_DIR=ldc2-%LDC_VERSION%-windows-multilib
set VISUALD_INSTALLER=VisualD-%VISUALD_VER%.exe
set DMD_DIR=%cd%
set DMD=%DMD_DIR%\generated\Windows\Release\Win32\dmd.exe
set DMD_TESTSUITE_MAKE_ARGS=-j3
set DM_MAKE=%DMD_DIR%\dm\path\make.exe
FOR /F "tokens=* USEBACKQ" %%F IN (`where cl.exe`) DO (SET MSVC_CC=%%~fsF)
FOR /F "tokens=* USEBACKQ" %%F IN (`where lib.exe`) DO (SET MSVC_AR=%%~fsF)
REM this returns two lines (GNU's link.exe is on the second line)
REM Just take the first one
FOR /F "tokens=* USEBACKQ" %%F IN (`where link.exe`) DO (SET MSVC_LD=%%~fsF
GOTO :Next)
:Next
FOR /F "tokens=* USEBACKQ" %%F IN (`where make.exe`) DO (SET GNU_MAKE=%%~fsF)
REM WORKAROUND: move files to a directory without spaces
copy "%MSVC_AR%" "%DMD_DIR%\dm\path\lib.exe"
copy "%MSVC_LD%" "%DMD_DIR%\dm\path\link.exe"
copy "%MSVC_CC%" "%DMD_DIR%\dm\path\cl.exe"
set MSVC_AR=%DMD_DIR%\dm\path\lib.exe
set MSVC_CC=%DMD_DIR%\dm\path\cl.exe
set MSVC_LD=%DMD_DIR%\dm\path\link.exe
REM expose dm_make as default make
set PATH=%DMD_DIR%\dm\path;%DMD_DIR%\tools;%PATH%
dir "%DMD_DIR%\tools"
"%DMD_DIR%\tools\grep.exe --version
echo %PATH%
grep --version
exit 1
.\%VISUALD_INSTALLER% /S
REM configure DMD path
REM reg add "HKLM\SOFTWARE\DMD" /v InstallationFolder /t REG_SZ /d "%DMD_DIR%\dmd2" /reg:32 /f
REM configure LDC path
reg add "HKLM\SOFTWARE\LDC" /v InstallationFolder /t REG_SZ /d "%DMD_DIR%\%LDC_DIR%" /reg:32 /f
REM build via VS projects with LDC
cd src
REM unfortunately, multilib version of LDC and Visual D don't work together seamlessly (anymore?)
set LDC_ARGS="/p:ExternalLinkerOptions=phobos2-ldc.lib druntime-ldc.lib"
set LDC_ARGS=%LDC_ARGS% /p:DCompiler=LDC
msbuild /target:dmd /p:Configuration=Release /p:Platform=Win32 %LDC_ARGS% vcbuild\dmd.sln
%DMD% --version
grep --version
REM Check: run druntime unittests
cd "%DMD_DIR%\..\druntime"
"%DM_MAKE%" -f win64.mak MODEL=32mscoff DMD="%DMD%" VCDIR="%VCINSTALLDIR%." CC="%MSVC_CC%" SDKDIR=unused MAKE="%DM_MAKE%" target
echo "[DRUNTIME] running tests..."
"%DM_MAKE%" -f win64.mak MODEL=32mscoff DMD="%DMD%" VCDIR="%VCINSTALLDIR%." CC="%MSVC_CC%" SDKDIR=unused MAKE="%DM_MAKE%" unittest32mscoff
REM build zlib first (to workaround DigitalMars's whitespace limitations)
cd "%DMD_DIR%\..\phobos\etc\c\zlib"
"%DM_MAKE%" -f win64.mak "zlib32mscoff.lib" MODEL=32mscoff DMD="%DMD%" VCDIR="%VCINSTALLDIR%." CC="%MSVC_CC%" LIB="%MSVC_AR%" LD="%MSVC_LD%"
REM Check: build phobos unittests
cd "%DMD_DIR%\..\phobos"
"%DM_MAKE%" -f win64.mak MODEL=32mscoff DMD="%DMD%" VCDIR="%VCINSTALLDIR%." CC="%MSVC_CC%" "MAKE=%DM_MAKE%" CFLAGS="/C7" SDKDIR=unused
REM Build DMD VERSION + string imports (not built by VisualD)
copy "%DMD_DIR%\VERSION" "%DMD_DIR%\generated\Windows\Release\Win32\VERSION"
REM Run DMD testsuite
cd "%DMD_DIR%\test"
cp %DMD_DIR%\..\phobos\phobos32mscoff.lib .
"%GNU_MAKE%" -j1 all MODEL=32mscoff ARGS="-O -inline -g" OS=win32 DMD="%DMD%" DMD_MODEL=win32

View file

@ -7,7 +7,7 @@ steps:
- checkout: self
fetchDepth: 1
- script: |
echo on
@echo on
call "%VSINSTALLDIR%\VC\Auxiliary\Build\vcvarsall.bat" %ARCH%
FOR /F "tokens=* USEBACKQ" %%F IN (`where cl.exe`) DO (SET MSVC_CC=%%~fsF)
FOR /F "tokens=* USEBACKQ" %%F IN (`where lib.exe`) DO (SET MSVC_AR=%%~fsF)

View file

@ -1,85 +0,0 @@
#!/bin/sh
set -e -v
clone() {
local url="$1"
local path="$2"
local branch="$3"
for i in {0..4}; do
if git clone --branch "$branch" "$url" "$path" "${@:4}" --quiet; then
break
elif [ $i -lt 4 ]; then
sleep $((1 << $i))
else
echo "Failed to clone: ${url}"
exit 1
fi
done
}
echo "C_COMPILER: $C_COMPILER"
echo "D_COMPILER: $D_COMPILER"
echo "D_VERSION: $D_VERSION"
cd /c/projects/
if [ ! -f "gnumake/make.exe" ]; then
mkdir gnumake
cd gnumake
appveyor DownloadFile "https://ftp.gnu.org/gnu/make/make-4.2.tar.gz" -FileName make.tar.gz
7z x make.tar.gz -so | 7z x -si -ttar > /dev/null
cd make-4.2
# usr/bin/link overriding VS's link.exe, give priority to VS's in PATH
export PATH="/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/:$PATH"
./build_w32.bat > /dev/null
cp WinRel/gnumake.exe ../make.exe
cd ../..
gnumake/make.exe --version
fi
if [ $D_COMPILER == "dmd" ]; then
appveyor DownloadFile "http://downloads.dlang.org/releases/2.x/${D_VERSION}/dmd.${D_VERSION}.windows.7z" -FileName dmd2.7z
#appveyor DownloadFile "http://nightlies.dlang.org/dmd-master-2017-12-22/dmd.master.windows.7z" -FileName dmd2.7z
7z x dmd2.7z > /dev/null
export PATH=$PWD/dmd2/windows/bin/:$PATH
export DMD=/c/projects/dmd2/windows/bin/dmd.exe
dmd --version
fi
for proj in druntime phobos; do
if [ $APPVEYOR_REPO_BRANCH != master ] && [ $APPVEYOR_REPO_BRANCH != stable ] &&
! git ls-remote --exit-code --heads https://github.com/dlang/$proj.git $APPVEYOR_REPO_BRANCH > /dev/null; then
# use master as fallback for other repos to test feature branches
clone https://github.com/dlang/$proj.git $proj master
echo "+++ Switched $proj to branch master (APPVEYOR_REPO_BRANCH=$APPVEYOR_REPO_BRANCH)"
else
clone https://github.com/dlang/$proj.git $proj $APPVEYOR_REPO_BRANCH
echo "+++ Switched $proj to branch $APPVEYOR_REPO_BRANCH"
fi
done
# build via makefile
cd /c/projects/dmd/src
make -f win64.mak reldmd DMD=../src/dmd
cd /c/projects/druntime
make -f win64.mak DMD=../dmd/src/dmd
cd /c/projects/phobos
make -f win64.mak DMD=../dmd/src/dmd
cp /c/projects/phobos/phobos64.lib /c/projects/dmd/
export OS="Win_64"
export CC='c:/"Program Files (x86)"/"Microsoft Visual Studio 14.0"/VC/bin/amd64/cl.exe'
export MODEL="64"
export MODEL_FLAG="-m64"
cd /c/projects/dmd/test
DMD_TESTSUITE_MAKE_ARGS=-j3 ../../gnumake/make -j1 start_all_tests MODEL=$MODEL ARGS="-O -inline -g" MODEL_FLAG=$MODEL_FLAG LIB="../../phobos;$LIB"

View file

@ -1,85 +0,0 @@
os: Visual Studio 2015
environment:
matrix:
- ARCH: x64
D_COMPILER: dmd
D_VERSION: 2.079.1
C_COMPILER: MSVC
VISUALD_VER: v0.45.1-rc2
LDC_VERSION: 1.8.0
cache:
- C:\projects\gnumake\make.exe
- C:\projects\VisualD-v0.45.1-rc2.exe
- C:\projects\ldc2-1.8.0-windows-multilib.7z
skip_commits:
# Avoid retesting the merged PR on `master` or `stable`
message: /^Merge pull request/
artifacts:
- path: src/dmd.exe
name: dmd 64-bit
- path: generated/Windows/Release/Win32/dmd.exe
name: dmd 32-bit built with LDC
init:
- git config --global core.autocrlf input
build_script:
- cd c:/projects/
- call "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
- set LDC_DIR=ldc2-%LDC_VERSION%-windows-multilib
- set LDC_INSTALLER=%LDC_DIR%.7z
- set LDC_URL=https://github.com/ldc-developers/ldc/releases/download/v%LDC_VERSION%/%LDC_INSTALLER%
- ps: |
If (-not (Test-Path $Env:LDC_INSTALLER)) {
Start-FileDownload $Env:LDC_URL -FileName $Env:LDC_INSTALLER
}
7z x $Env:LDC_INSTALLER > $null
If (-not (Test-Path $Env:LDC_DIR/bin/ldmd2.exe)) {
echo "Unexpected LDC installation, $Env:LDC_INSTALLER/bin/ldmd2.exe missing"
}
# Download & install Visual D (needs admin rights?)
- set VISUALD_INSTALLER=VisualD-%VISUALD_VER%.exe
- set VISUALD_URL=https://github.com/dlang/visuald/releases/download/%VISUALD_VER%/%VISUALD_INSTALLER%
- ps: |
If (-not (Test-Path $Env:VISUALD_INSTALLER)) {
Start-FileDownload $Env:VISUALD_URL -FileName $Env:VISUALD_INSTALLER
}
- .\%VISUALD_INSTALLER% /S
# configure DMD path
- reg add "HKCU\SOFTWARE\Microsoft\VisualStudio\14.0\ToolsOptionsPages\Projects\Visual D Settings" /v DMDInstallDir /t REG_SZ /d c:\projects\dmd2 /reg:32 /f
# configure LDC path
- reg add "HKCU\SOFTWARE\Microsoft\VisualStudio\14.0\ToolsOptionsPages\Projects\Visual D Settings" /v LDCInstallDir /t REG_SZ /d c:\projects\%LDC_DIR%\ /reg:32 /f
# disable link dependencies monitoring, fails on AppVeyor server
- reg add "HKLM\SOFTWARE\Microsoft\VisualStudio\14.0\ToolsOptionsPages\Projects\Visual D Settings" /v optlinkDeps /t REG_DWORD /d 0 /reg:32 /f
- bash --version
- sh --login /c/projects/dmd/appveyor.sh
# build via VS projects with LDC
- cd c:\projects\dmd\src
# unfortunately, multilib version of LDC and Visual D don't work together seamlessly (anymore?)
- set LDC_ARGS="/p:ExternalLinkerOptions=phobos2-ldc.lib druntime-ldc.lib"
- set LDC_ARGS=%LDC_ARGS% /p:DCompiler=LDC
- msbuild /target:dmd /p:Configuration=Release /p:Platform=Win32 %LDC_ARGS% vcbuild\dmd.sln
# check: build druntime unittests and dmd test suite
- cd c:\projects\druntime
- set PATH=c:\projects\dmd2\windows\bin;%PATH%
- make -f win64.mak MODEL=32mscoff DMD=..\dmd\generated\Windows\Release\Win32\dmd.exe VCDIR="%VCINSTALLDIR%." "CC=%VCINSTALLDIR%/bin/cl.exe" SDKDIR=unused clean
- make -f win64.mak MODEL=32mscoff DMD=..\dmd\generated\Windows\Release\Win32\dmd.exe VCDIR="%VCINSTALLDIR%." "CC=%VCINSTALLDIR%/bin/cl.exe" SDKDIR=unused target unittest32mscoff
- cd c:\projects\phobos
- make -f win64.mak MODEL=32mscoff DMD=..\dmd\generated\Windows\Release\Win32\dmd.exe VCDIR="%VCINSTALLDIR%." "CC=%VCINSTALLDIR%/bin/cl.exe" SDKDIR=unused clean
- make -f win64.mak MODEL=32mscoff DMD=..\dmd\generated\Windows\Release\Win32\dmd.exe VCDIR="%VCINSTALLDIR%." "CC=%VCINSTALLDIR%/bin/cl.exe" SDKDIR=unused
- cd c:\projects\dmd\test
- set CC=c:/"Program Files (x86)"/"Microsoft Visual Studio 14.0"/VC/bin/cl.exe
- set DMD_TESTSUITE_MAKE_ARGS=-j3
- ..\..\gnumake\make -j1 start_all_tests MODEL=32mscoff ARGS="-O -inline -g" "OS=win32" DMD=..\generated\Windows\Release\Win32\dmd.exe LIB="../../phobos;%LIB%" RESULTS_DIR=test_m32mscoff
test_script: true

View file

@ -23,3 +23,20 @@ jobs:
#D_COMPILER: dmd
steps:
- template: .azure-pipelines/windows.yml
- job: Windows_VisualD
timeoutInMinutes: 120
pool:
vmImage: 'vs2017-win2016'
variables:
VSINSTALLDIR: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\
strategy:
matrix:
visuald-ldc:
OS: Win_32
MODEL: 32
ARCH: x86
D_COMPILER: ldc
VISUALD_VER: v0.48.1
LDC_VERSION: 1.14.0
steps:
- template: .azure-pipelines/windows-visual-studio.yml

View file

@ -59,6 +59,9 @@
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir>..\..\generated\Windows\$(Configuration)\$(PlatformName)\</OutDir>
<IntDir>$(OutDir)\backend\</IntDir>
<_DCompilerExe Condition="'$(DCompiler)' == 'LDC' and '$(Platform)'=='x64'">$(LDCBinDir)ldmd2.exe -m64</_DCompilerExe>
<_DCompilerExe Condition="'$(DCompiler)' == 'LDC' and '$(Platform)'=='Win32'">$(LDCBinDir)ldmd2.exe -m32</_DCompilerExe>
<_DCompilerExe Condition="'$(_DCompilerExe)' == ''">$(DMDBinDir)dmd.exe</_DCompilerExe>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<ItemDefinitionGroup>
@ -99,7 +102,7 @@
</ClCompile>
<CustomBuild Include="..\dmd\backend\optabgen.d">
<Message>Building and running $(IntDir)%(Filename).exe</Message>
<Command>$(DMDBinDir)\dmd.exe -I.. -version=MARS -of"$(IntDir)generated\%(Filename).exe" "%(FullPath)"
<Command>$(_DCompilerExe) -I.. -version=MARS -of"$(IntDir)generated\%(Filename).exe" "%(FullPath)"
if errorlevel 1 exit /B %ERRORLEVEL%
pushd $(IntDir)generated
"%(Filename).exe"

View file

@ -60,7 +60,8 @@ string dmdModel()
return dmdModel;
const prefix = generatedDir.buildPath(os, build);
return dmdModel = prefix.buildPath("64", dmdFilename).exists ? "64" : "32";
return dmdModel = environment.get("DMD_MODEL",
prefix.buildPath("64", dmdFilename).exists ? "64" : "32");
}
string model()