Skip to content

Instantly share code, notes, and snippets.

@Orvid
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Orvid/7b254c307c701318488a to your computer and use it in GitHub Desktop.
Save Orvid/7b254c307c701318488a to your computer and use it in GitHub Desktop.
Current state of my build D script
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" amd64 && msbuild dmd/src/dmd_msc_vs10.sln /t:Rebuild /p:Configuration=Release /p:Platform=x64 && exit
#! /bin/bash
MAKE=/F/D/dm/bin/make.exe
VCDIR="/C/Program Files (x86)/Microsoft Visual Studio 10.0/VC"
SDKDIR="/C/Program Files (x86)/Microsoft SDKs/Windows/v7.0A"
DMD_BUILT_PATH=dmd/src/vcbuild/x64/Release/dmd_msc.exe
INSTALL_BASE_PATH=/F/D/dmd3/windows
HEAD_REMOTE="head"
MESSAGES=""
RESET_DMD=0
RESET_DRUNTIME=0
RESET_PHOBOS=0
RESET_TOOLS=0
function halt_build() {
if [ -z "$1" ]; then
echo "ISE: halt_build: Exit message not provided!"
exit 1
fi
echo "$1"
exit 2
}
function add_error() {
if [ -z "$1" ]; then
echo "ISE: add_error: No error message provided!"
exit 3
fi
MESSAGES= $MESSAGES + "\n" + "$1"
}
function update() {
local stashed=1
cd "$1"
git fetch $HEAD_REMOTE
if [ -n "$(echo "$(git stash)" | grep -e "No local changes to save")" ]; then
stashed=0
else
echo "Stashed changes to $2"
fi
if [ $3 -eq 1 ]; then
git reset --hard $HEAD_REMOTE/master
else
if [ -n "$(echo "$(git rebase $HEAD_REMOTE/master)" | grep -e "CONFLICT")" ]; then
halt_build "Conflicts encountered when rebasing $2 to $HEAD_REMOTE/master."
fi
fi
if [ $stashed -eq 1 ]; then
git stash pop
fi
echo "Updated $2"
cd ..
}
function copy_source() {
rm -rf $INSTALL_BASE_PATH/../src/$1
mkdir $INSTALL_BASE_PATH/../src/$1
cp -r $1/* $INSTALL_BASE_PATH/../src/$1
if [ "$1" == "druntime" ]; then
mkdir $INSTALL_BASE_PATH/../src/$1/import
cp -r $1/src/* $INSTALL_BASE_PATH/../src/$1/import
fi
echo "Copied source for $2"
}
function build_dmd_msvc64() {
cmd /k ""buildDMD.bat"";
if ! [ -f $DMD_BUILT_PATH ]; then
halt_build "Building DMD failed... Not building druntime, phobos, or the tools."
fi;
cp $DMD_BUILT_PATH $INSTALL_BASE_PATH/bin/dmd.exe
}
function do_make() {
local copiedFiles=()
IFS=';' read -ra copiedFiles <<< "$3"
cd "$1"
$MAKE -F "$2" DMD="$INSTALL_BASE_PATH/bin/dmd.exe" VCDIR="$VCDIR" SDKDIR="$SDKDIR"
for (( i = 0; i < ${#copiedFiles[@]}; i=i + 2 )); do
local sourceFile="${copiedFiles[$i]}"
local destinationFile="${copiedFiles[$i + 1]}"
destinationFile="${destinationFile/\~/$sourceFile}"
cp -f "$sourceFile" "$INSTALL_BASE_PATH/$destinationFile"
echo "Copied $sourceFile to $INSTALL_BASE_PATH/$destinationFile"
done
cd ..
}
function clean() {
cd "$1"
$MAKE -F "$2" clean
cd ..
}
update "dmd" "DMD" $RESET_DMD
update "druntime" "DRuntime" $RESET_DRUNTIME
update "phobos" "Phobos" $RESET_PHOBOS
copy_source "druntime" "DRuntime"
copy_source "phobos" "Phobos"
build_dmd_msvc64
# 64-bit libs
do_make "druntime" "win64.mak" "lib/druntime64.lib;lib64/druntime64.lib;lib/gcstub64.obj;lib64/gcstub64.obj"
do_make "phobos" "win64.mak" "phobos64.lib;lib64/~"
clean "druntime" "win64.mak"
clean "phobos" "win64.mak"
# 32-bit libs
do_make "druntime" "win32.mak" "lib/druntime.lib;~;lib/gcstub.obj;~"
do_make "phobos" "win32.mak" "phobos.lib;lib/~"
clean "druntime" "win32.mak"
clean "phobos" "win32.mak"
#cd tools
#git fetch origin
#git reset --hard origin/master
#cd ..
if [ -n "$MESSAGES" ]; then
echo "$MESSAGES"
exit 1
else
echo "Build completed successfully."
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment