Run specific targets in bash

This commit is contained in:
Nate McMaster 2016-01-12 17:13:53 -08:00
parent 99474a2709
commit 0c0b724009
4 changed files with 61 additions and 51 deletions

97
KoreBuild-dotnet/build/KoreBuild.sh Normal file → Executable file
View File

@ -1,62 +1,75 @@
#!/usr/bin/env bash
if [ -z "$koreBuildFolder" ]; then
echo "koreBuildFolder is not set."
targets=""
filename=$0
while [[ $# > 0 ]]; do
case $1 in
-m)
shift
makeFilePath=$1
;;
-n)
shift
nugetPath=$1
;;
*)
targets+=" $1"
;;
esac
shift
done
if [ ! -e "$nugetPath" ] || [ ! -e "$makeFilePath" ]; then
printf "Usage: $filename -m [makefile] -n [nuget] [ [targets] ]\n\n"
echo " -m [makefile] The makefile.shade to execute"
echo " -n [nuget] nuget.exe"
echo " [targets] A space separated list of targets to run"
exit 1
fi
if [ -z "$nugetPath" ]; then
echo "nugetPath is not set."
exit 1
fi
# ==== find directory containing this file =====
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
thisDir="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
# ===================
sakeFolder=$koreBuildFolder/build/Sake
if test ! -d $sakeFolder; then
mono $nugetPath install Sake -ExcludeVersion -o $koreBuildFolder/build -nocache -pre
fi
if test ! -d $koreBuildFolder/build/xunit.runner.console; then
mono $nugetPath install xunit.runner.console -ExcludeVersion -o $koreBuildFolder/build -nocache -pre
sakeFolder=$thisDir/Sake
if [ ! -d $sakeFolder ]; then
mono $nugetPath install Sake -ExcludeVersion -o $thisDir -nocache -pre
fi
if [ ! -d $thisDir/xunit.runner.console ]; then
mono $nugetPath install xunit.runner.console -ExcludeVersion -o $thisDir -nocache -pre
fi
# Need to set this variable because by default the install script
# requires sudo
# requires sudo
export DOTNET_INSTALL_DIR=~/.dotnet
export PATH=~/.dotnet/bin:$PATH
export DOTNET_HOME=DOTNET_INSTALL_DIR
export KOREBUILD_FOLDER=$koreBuildFolder
source $koreBuildFolder/build/dotnet-install.sh
# ==== Temporary ====
if ! type dnvm > /dev/null 2>&1; then
source $koreBuildFolder/build/dnvm.sh
fi
if ! type dnx > /dev/null 2>&1 || [ -z "$SKIP_DNX_INSTALL" ]; then
dnvm install latest -runtime coreclr -alias default
dnvm install default -runtime mono -alias default
else
dnvm use default -runtime mono
fi
# ============
makefilePath=makefile.shade
if test ! -f $makefilePath; then
makefilePath=$koreBuildFolder/build/makefile.shade
source $thisDir/dotnet-install.sh
# ==== Temporary ====
if ! type dnvm > /dev/null 2>&1; then
source $thisDir/dnvm.sh
fi
echo "Using makefile: ${makefile}"
if ! type dnx > /dev/null 2>&1 || [ -z "$SKIP_DNX_INSTALL" ]; then
dnvm install latest -runtime coreclr -alias default
dnvm install default -runtime mono -alias default
else
dnvm use default -runtime mono
fi
# ============
# Probe for Mono Reference assemblies
if test -z "$DOTNET_REFERENCE_ASSEMBLIES_PATH"; then
if test $(uname) == Darwin && test -d "/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/xbuild-frameworks"; then
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 test -d "/usr/local/lib/mono/xbuild-frameworks"; then
elif [ -d "/usr/local/lib/mono/xbuild-frameworks" ]; then
export DOTNET_REFERENCE_ASSEMBLIES_PATH="/usr/local/lib/mono/xbuild-frameworks"
elif test -d "/usr/lib/mono/xbuild-frameworks"; then
elif [ -d "/usr/lib/mono/xbuild-frameworks" ]; then
export DOTNET_REFERENCE_ASSEMBLIES_PATH="/usr/lib/mono/xbuild-frameworks"
fi
fi
echo "Using Reference Assemblies from: $DOTNET_REFERENCE_ASSEMBLIES_PATH"
mono $sakeFolder/tools/Sake.exe -I $koreBuildFolder/build -f $makefilePath "$@"
mono $sakeFolder/tools/Sake.exe -I $thisDir -f $makeFilePath $targets

0
KoreBuild-dotnet/build/dotnet-install.sh vendored Normal file → Executable file
View File

0
KoreBuild-dotnet/build/install.sh Normal file → Executable file
View File

View File

@ -1,13 +1,5 @@
#!/usr/bin/env bash
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
repoFolder="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
buildFolder=.build
koreBuildFolder=$buildFolder/KoreBuild-dotnet
@ -42,7 +34,12 @@ fi
if test ! -d $koreBuildFolder; then
mono $nugetPath install KoreBuild-dotnet -ExcludeVersion -o $buildFolder -nocache -pre
chmod +x $koreBuildFolder/build/KoreBuild.sh
fi
source $koreBuildFolder/build/KoreBuild.sh
makeFile=makefile.shade
if [ ! -e $makeFile ]; then
makeFile=$koreBuildFolder/build/makefile.shade
fi
./$koreBuildFolder/build/KoreBuild.sh -n $nugetPath -m $makeFile "$@"