dotnet-installer/scripts/bootstrap.sh

127 lines
5 KiB
Bash
Raw Normal View History

2015-10-16 22:30:28 +00:00
#!/usr/bin/env bash
set -e
2015-10-16 22:30:28 +00:00
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
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
REPOROOT="$( cd -P "$DIR/.." && pwd )"
2015-10-29 17:33:39 +00:00
source "$DIR/_common.sh"
OUTPUT_ROOT=$REPOROOT/artifacts/$RID
DNX_DIR=$OUTPUT_ROOT/dnx
STAGE1_DIR=$OUTPUT_ROOT/stage1
STAGE2_DIR=$OUTPUT_ROOT/stage2
HOST_DIR=$OUTPUT_ROOT/corehost
if ! type -p cmake >/dev/null; then
error "cmake is required to build the native host 'corehost'"
error "OS X w/Homebrew: 'brew install cmake'"
error "Ubuntu: 'sudo apt-get install cmake'"
exit 1
fi
2015-10-29 17:33:39 +00:00
[ -z "$CONFIGURATION" ] && CONFIGURATION=Debug
# TODO: Replace this with a dotnet generation
TFM=dnxcore50
2015-10-16 22:30:28 +00:00
REPOROOT="$( cd -P "$DIR/.." && pwd )"
START_PATH=$PATH
2015-10-29 17:33:39 +00:00
banner "Installing stage0"
2015-11-03 19:04:20 +00:00
[ -d "$HOME/.dotnet" ] || mkdir -p "$HOME/.dotnet"
2015-10-29 17:02:14 +00:00
source $DIR/dnvm2.sh
dnvm upgrade -a dotnet_stage0
DNX_ROOT="$(dirname $(which dotnet))/dnx"
2015-10-16 22:30:28 +00:00
2015-10-29 17:33:39 +00:00
banner "Restoring packages"
dotnet restore "$REPOROOT" --quiet --runtime "osx.10.10-x64" --runtime "ubuntu.14.04-x64" --runtime "win7-x64"
2015-10-16 22:30:28 +00:00
# Clean up stage1
[ -d "$STAGE1_DIR" ] && rm -Rf "$STAGE1_DIR"
banner "Building corehost"
pushd "$REPOROOT/src/corehost" 2>&1 >/dev/null
[ -d "cmake/$RID" ] || mkdir -p "cmake/$RID"
cd "cmake/$RID"
cmake ../.. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE:STRING=$CONFIGURATION
make
# Publish to artifacts
[ -d "$HOST_DIR" ] || mkdir -p $HOST_DIR
cp "$REPOROOT/src/corehost/cmake/$RID/corehost" $HOST_DIR
popd 2>&1 >/dev/null
2015-10-29 17:33:39 +00:00
banner "Building stage1 using downloaded stage0"
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE1_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Cli"
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE1_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Compiler"
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE1_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Compiler.Csc"
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE1_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Publish"
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE1_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Resgen"
2015-10-30 22:40:13 +00:00
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE1_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Run"
# Deploy CLR host to the output
cp "$HOST_DIR/corehost" "$STAGE1_DIR"
2015-10-16 22:30:28 +00:00
# Add stage1 to the path and use it to build stage2
export PATH=$STAGE1_DIR:$START_PATH
2015-10-16 22:30:28 +00:00
2015-10-28 21:35:29 +00:00
# Clean up stage2
[ -d "$STAGE2_DIR" ] && rm -Rf "$STAGE2_DIR"
2015-10-29 17:33:39 +00:00
banner "Building stage2 dotnet using compiled stage1 ..."
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE2_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Cli"
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE2_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Compiler"
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE2_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Compiler.Csc"
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE2_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Publish"
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE2_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Resgen"
2015-10-30 22:40:13 +00:00
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE2_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Run"
2015-10-22 06:41:38 +00:00
echo "Crossgenning Roslyn compiler ..."
$REPOROOT/scripts/crossgen/crossgen_roslyn.sh "$STAGE2_DIR"
# Deploy CLR host to the output
cp "$HOST_DIR/corehost" "$STAGE2_DIR"
2015-10-22 06:41:38 +00:00
# Make Stage 2 Folder Accessible
chmod -R a+r $REPOROOT
# Copy DNX in to stage2
cp -R $DNX_ROOT $STAGE2_DIR/dnx
# Copy and CHMOD the dotnet-restore script
cp $DIR/dotnet-restore.sh $STAGE2_DIR/dotnet-restore
chmod a+x $STAGE2_DIR/dotnet-restore
# Smoke-test the output
2015-10-29 17:33:39 +00:00
banner "Testing stage2 ..."
export PATH=$STAGE2_DIR:$START_PATH
2015-10-30 02:45:55 +00:00
rm "$REPOROOT/test/TestApp/project.lock.json"
dotnet restore "$REPOROOT/test/TestApp" --runtime "osx.10.10-x64" --runtime "ubuntu.14.04-x64" --runtime "win7-x64"
dotnet compile "$REPOROOT/test/TestApp" --output "$REPOROOT/artifacts/$RID/smoketest"
export CLRHOST_CLR_PATH=$STAGE2_DIR
2015-11-02 00:21:10 +00:00
# set -e will abort if the exit code of this is non-zero
$REPOROOT/artifacts/$RID/smoketest/TestApp
# Check that a compiler error is reported
set +e
2015-10-28 21:35:29 +00:00
dotnet compile "$REPOROOT/test/compile/failing/SimpleCompilerError" --framework "$TFM" 2>/dev/null >/dev/null
rc=$?
if [ $rc == 0 ]; then
2015-10-29 17:33:39 +00:00
error "Compiler failure test failed! The compiler did not fail to compile!"
exit 1
fi
set -e