2016-02-26 02:46:30 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
targets=""
|
2016-02-25 21:24:25 +03:00
|
|
|
repoFolder=""
|
2016-02-26 02:46:30 +03:00
|
|
|
while [[ $# > 0 ]]; do
|
|
|
|
case $1 in
|
2016-02-25 21:24:25 +03:00
|
|
|
-r)
|
2016-02-26 02:46:30 +03:00
|
|
|
shift
|
2016-02-25 21:24:25 +03:00
|
|
|
repoFolder=$1
|
2016-02-26 02:46:30 +03:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
targets+=" $1"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
2016-02-25 21:24:25 +03:00
|
|
|
if [ ! -e "$repoFolder" ]; then
|
|
|
|
printf "Usage: $filename -r [repoFolder] [ [targets] ]\n\n"
|
|
|
|
echo " -r [repo] The repository to build"
|
|
|
|
echo " [targets] A space separated list of targets to run"
|
2016-02-26 02:46:30 +03:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-02-25 21:24:25 +03:00
|
|
|
echo "Building $repoFolder"
|
|
|
|
cd $repoFolder
|
2016-02-26 02:46:30 +03:00
|
|
|
|
2016-02-25 21:24:25 +03:00
|
|
|
# Make the path relative to the repo root because Sake/Spark doesn't support full paths
|
|
|
|
koreBuildFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
koreBuildFolder="${koreBuildFolder/$repoFolder/}"
|
|
|
|
koreBuildFolder="${koreBuildFolder#/}"
|
2016-02-26 02:46:30 +03:00
|
|
|
|
2016-03-04 01:16:50 +03:00
|
|
|
if test `uname` = Darwin; then
|
|
|
|
version=$(<cli.version.darwin)
|
|
|
|
else
|
|
|
|
version=$(<cli.version.unix)
|
|
|
|
fi
|
|
|
|
|
2016-02-25 21:24:25 +03:00
|
|
|
[ -z "$KOREBUILD_DOTNET_CHANNEL" ] && KOREBUILD_DOTNET_CHANNEL=beta
|
2016-03-04 01:16:50 +03:00
|
|
|
[ -z "$KOREBUILD_DOTNET_VERSION" ] && KOREBUILD_DOTNET_VERSION=version
|
2016-02-26 02:46:30 +03:00
|
|
|
|
|
|
|
if [ ! -z "$KOREBUILD_SKIP_RUNTIME_INSTALL" ]; then
|
|
|
|
echo "Skipping runtime installation because KOREBUILD_SKIP_RUNTIME_INSTALL is set"
|
2016-03-04 02:30:06 +03:00
|
|
|
|
|
|
|
# Add .NET installation directory to the path if it isn't yet included.
|
|
|
|
# Add to the _end_ in case preferred .NET CLI is not in the default location.
|
|
|
|
[[ ":$PATH:" != *":$DOTNET_INSTALL_DIR/bin:"* ]] && export PATH="$PATH:$DOTNET_INSTALL_DIR/bin"
|
2016-02-26 02:46:30 +03:00
|
|
|
else
|
|
|
|
# Need to set this variable because by default the install script
|
|
|
|
# requires sudo
|
|
|
|
export DOTNET_INSTALL_DIR=~/.dotnet
|
2016-02-25 21:24:25 +03:00
|
|
|
export KOREBUILD_FOLDER="$(dirname $koreBuildFolder)"
|
|
|
|
chmod +x $koreBuildFolder/dotnet/install.sh
|
|
|
|
$koreBuildFolder/dotnet/install.sh --channel $KOREBUILD_DOTNET_CHANNEL --version $KOREBUILD_DOTNET_VERSION
|
2016-03-04 02:30:06 +03:00
|
|
|
|
|
|
|
# Add .NET installation directory to the path if it isn't yet included.
|
|
|
|
[[ ":$PATH:" != *":$DOTNET_INSTALL_DIR/bin:"* ]] && export PATH="$DOTNET_INSTALL_DIR/bin:$PATH"
|
2016-02-26 02:46:30 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Probe for Mono Reference assemblies
|
|
|
|
if [ -z "$DOTNET_REFERENCE_ASSEMBLIES_PATH" ]; then
|
|
|
|
if [ $(uname) == Darwin ] && [ -d "/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/xbuild-frameworks" ]; then
|
|
|
|
export DOTNET_REFERENCE_ASSEMBLIES_PATH="/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/xbuild-frameworks"
|
|
|
|
elif [ -d "/usr/local/lib/mono/xbuild-frameworks" ]; then
|
|
|
|
export DOTNET_REFERENCE_ASSEMBLIES_PATH="/usr/local/lib/mono/xbuild-frameworks"
|
|
|
|
elif [ -d "/usr/lib/mono/xbuild-frameworks" ]; then
|
|
|
|
export DOTNET_REFERENCE_ASSEMBLIES_PATH="/usr/lib/mono/xbuild-frameworks"
|
|
|
|
fi
|
|
|
|
fi
|
2016-02-27 03:44:52 +03:00
|
|
|
|
|
|
|
if [ "$(uname)" == "Darwin" ]; then
|
|
|
|
ulimit -n 2048
|
|
|
|
fi
|
|
|
|
|
2016-02-26 02:46:30 +03:00
|
|
|
echo "Using Reference Assemblies from: $DOTNET_REFERENCE_ASSEMBLIES_PATH"
|
2016-02-25 21:24:25 +03:00
|
|
|
|
|
|
|
sakeFolder=$koreBuildFolder/Sake
|
|
|
|
if [ ! -d $sakeFolder ]; then
|
2016-02-28 23:10:28 +03:00
|
|
|
toolsProject="$koreBuildFolder/project.json"
|
|
|
|
dotnet restore "$toolsProject" --packages "$koreBuildFolder" -v Minimal
|
|
|
|
# Rename the project after restore because we don't want it to be restore afterwards
|
|
|
|
mv "$toolsProject" "$toolsProject.norestore"
|
2016-02-25 21:24:25 +03:00
|
|
|
fi
|
|
|
|
|
2016-03-04 00:09:25 +03:00
|
|
|
nugetPath="$koreBuildFolder/nuget.exe"
|
|
|
|
if [ ! -f $nugetPath ]; then
|
|
|
|
nugetUrl="https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
|
|
|
|
wget -O $nugetPath $nugetUrl 2>/dev/null || curl -o $nugetPath --location $nugetUrl 2>/dev/null
|
|
|
|
fi
|
|
|
|
|
2016-02-25 21:24:25 +03:00
|
|
|
makeFile="makefile.shade"
|
|
|
|
if [ ! -e $makeFile ]; then
|
|
|
|
makeFile="$koreBuildFolder/shade/makefile.shade"
|
|
|
|
fi
|
|
|
|
|
|
|
|
export KOREBUILD_FOLDER="$koreBuildFolder"
|
|
|
|
mono $sakeFolder/0.2.2/tools/Sake.exe -I $koreBuildFolder/shade -f $makeFile $targets
|