KoreBuild/build/KoreBuild.sh

99 строки
3.3 KiB
Bash
Исходник Обычный вид История

2016-02-26 02:46:30 +03:00
#!/usr/bin/env bash
targets=""
repoFolder=""
2016-02-26 02:46:30 +03:00
while [[ $# > 0 ]]; do
case $1 in
-r)
2016-02-26 02:46:30 +03:00
shift
repoFolder=$1
2016-02-26 02:46:30 +03:00
;;
*)
targets+=" $1"
;;
esac
shift
done
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
echo "Building $repoFolder"
cd $repoFolder
2016-02-26 02:46:30 +03:00
scriptRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Make the path relative to the repo root because Sake/Spark doesn't support full paths
koreBuildFolder="${scriptRoot/$repoFolder/}"
koreBuildFolder="${koreBuildFolder#/}"
2016-02-26 02:46:30 +03:00
versionFile="$koreBuildFolder/cli.version"
2016-03-07 21:37:38 +03:00
version=$(<$versionFile)
2016-03-04 01:16:50 +03:00
[ -z "$KOREBUILD_DOTNET_CHANNEL" ] && KOREBUILD_DOTNET_CHANNEL=rel-1.0.0
2016-03-04 01:24:02 +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"
# 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.
2016-04-03 04:20:32 +03:00
[[ ":$PATH:" != *":$DOTNET_INSTALL_DIR:"* ]] && export PATH="$PATH:$DOTNET_INSTALL_DIR"
2016-02-26 02:46:30 +03:00
else
# Need to set this variable because by default the install script
# requires sudo
2016-11-08 21:30:03 +03:00
[ -z "$DOTNET_INSTALL_DIR" ] && DOTNET_INSTALL_DIR=~/.dotnet
export DOTNET_INSTALL_DIR=$DOTNET_INSTALL_DIR
export KOREBUILD_FOLDER="$(dirname $koreBuildFolder)"
2016-05-31 20:02:29 +03:00
chmod +x $koreBuildFolder/dotnet/dotnet-install.sh
2016-03-28 20:52:47 +03:00
# Install the version of dotnet-cli used to compile
$koreBuildFolder/dotnet/dotnet-install.sh --channel $KOREBUILD_DOTNET_CHANNEL --version $KOREBUILD_DOTNET_VERSION
# Add .NET installation directory to the path if it isn't yet included.
2016-04-03 04:20:32 +03:00
[[ ":$PATH:" != *":$DOTNET_INSTALL_DIR:"* ]] && export PATH="$DOTNET_INSTALL_DIR:$PATH"
2016-02-26 02:46:30 +03:00
fi
2016-04-03 04:20:32 +03:00
# workaround for CLI issue: https://github.com/dotnet/cli/issues/2143
DOTNET_PATH=`which dotnet | head -n 1`
ROOT_PATH=`dirname $DOTNET_PATH`
FOUND=`find $ROOT_PATH/shared -name dotnet`
if [ ! -z "$FOUND" ]; then
echo $FOUND | xargs rm
2016-04-01 19:12:15 +03:00
fi
2016-02-27 03:44:52 +03:00
if [ "$(uname)" == "Darwin" ]; then
ulimit -n 2048
fi
netfxversion='4.6.0'
netFrameworkFolder=$repoFolder/$koreBuildFolder/netframeworkreferenceassemblies
netFrameworkContentDir=$netFrameworkFolder/$netfxversion/content
sakeFolder=$koreBuildFolder/sake
if [ ! -d $sakeFolder ]; then
toolsProject="$koreBuildFolder/tools.proj"
dotnet restore "$toolsProject" --packages $scriptRoot -v Minimal "/p:NetFxVersion=$netfxversion"
2016-02-28 23:10:28 +03:00
# Rename the project after restore because we don't want it to be restore afterwards
mv "$toolsProject" "$toolsProject.norestore"
fi
2016-11-28 21:08:47 +03:00
export ReferenceAssemblyRoot=$netFrameworkContentDir
2016-11-17 03:22:50 +03:00
nugetPath="$koreBuildFolder/nuget.exe"
if [ ! -f $nugetPath ]; then
nugetUrl="https://dist.nuget.org/win-x86-commandline/v3.5.0-beta2/NuGet.exe"
wget -O $nugetPath $nugetUrl 2>/dev/null || curl -o $nugetPath --location $nugetUrl 2>/dev/null
fi
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