cibuild.sh 3.7 KB
Newer Older
1
#!/usr/bin/env bash
2 3 4
# Copyright (c) .NET Foundation and contributors. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.

J
Jared Parsons 已提交
5
set -e
6
set -u
J
jaredpar 已提交
7

D
Drew DeVault 已提交
8 9 10 11 12 13
usage()
{
    echo "Runs our integration suite on Linux"
    echo "usage: cibuild.sh [options]"
    echo ""
    echo "Options"
14 15
    echo "  --debug               Build Debug (default)"
    echo "  --release             Build Release"
16
    echo "  --cleanrun            Clean the project before building"
17
    echo "  --skiptest            Do not run tests"
18
    echo "  --skipcommitprinting  Do not print commit information"
D
Drew DeVault 已提交
19 20
}

21 22 23 24 25 26
THIS_DIR=$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)
BINARIES_PATH=${THIS_DIR}/Binaries
BOOTSTRAP_PATH=${BINARIES_PATH}/Bootstrap
SRC_PATH=${THIS_DIR}/src
BUILD_LOG_PATH=${BINARIES_PATH}/Build.log

27
BUILD_CONFIGURATION=Debug
28
CLEAN_RUN=false
29
SKIP_TESTS=false
30
SKIP_COMMIT_PRINTING=false
J
jaredpar 已提交
31

32 33 34 35 36 37 38 39 40
# $HOME is unset when running the mac unit tests.
if [[ -z ${HOME+x} ]]
then
    # Note that while ~ usually refers to $HOME, in the case where $HOME is unset,
    # it looks up the current user's home dir, which is what we want.
    # https://www.gnu.org/software/bash/manual/html_node/Tilde-Expansion.html
    export HOME=$(cd ~ && pwd)
fi

J
Jared Parsons 已提交
41 42 43
# LTTNG is the logging infrastructure used by coreclr.  Need this variable set 
# so it doesn't output warnings to the console.
export LTTNG_HOME=$HOME
J
Jared Parsons 已提交
44

M
Matt Ellis 已提交
45 46 47 48 49
# There's no reason to send telemetry or prime a local package cach when building
# in CI.
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1

J
jaredpar 已提交
50 51
while [[ $# > 0 ]]
do
M
Matt Ellis 已提交
52
    opt="$(echo $1 | awk '{print tolower($0)}')"
J
jaredpar 已提交
53 54 55 56 57
    case $opt in
        -h|--help)
        usage
        exit 1
        ;;
58 59 60 61 62 63 64 65
        --debug)
        BUILD_CONFIGURATION=Debug
        shift 1
        ;;
        --release)
        BUILD_CONFIGURATION=Release
        shift 1
        ;;
66 67
        --cleanrun)
        CLEAN_RUN=true
J
Jared Parsons 已提交
68 69
        shift 1
        ;;
70 71 72 73
        --skiptests)
        SKIP_TESTS=true
        shift 1
        ;;
74 75 76 77
        --skipcommitprinting)
        SKIP_COMMIT_PRINTING=true
        shift 1
        ;;
J
jaredpar 已提交
78 79 80 81 82 83 84
        *)
        usage 
        exit 1
        ;;
    esac
done

J
Jared Parsons 已提交
85 86 87 88
if [ "$CLEAN_RUN" == "true" ]; then
    echo Clean out the enlistment
    git clean -dxf . 
fi
J
Jared Parsons 已提交
89

90 91 92 93
if [ "$SKIP_COMMIT_PRINTING" == "false" ]; then
    echo Building this commit:
    git show --no-patch --pretty=raw HEAD
fi
94

95 96 97
# obtain_dotnet.sh puts the right dotnet on the PATH
FORCE_DOWNLOAD=true
source ${THIS_DIR}/build/scripts/obtain_dotnet.sh
J
Jared Parsons 已提交
98

99 100
RUNTIME_ID=$(dotnet --info | awk '/RID:/{print $2;}')
echo "Using Runtime Identifier: ${RUNTIME_ID}"
J
Jared Parsons 已提交
101

102 103 104 105 106 107
RESTORE_ARGS="-r ${RUNTIME_ID} -v Minimal --disable-parallel"
echo "Restoring BaseToolset.csproj"
dotnet restore ${RESTORE_ARGS} ${THIS_DIR}/build/ToolsetPackages/BaseToolset.csproj
echo "Restoring CrossPlatform.sln"
dotnet restore ${RESTORE_ARGS} ${THIS_DIR}/CrossPlatform.sln

108
BUILD_ARGS="--no-restore -c ${BUILD_CONFIGURATION} -r ${RUNTIME_ID} /nologo /consoleloggerparameters:Verbosity=minimal;summary /filelogger /fileloggerparameters:Verbosity=normal;logFile=${BUILD_LOG_PATH} /p:RoslynRuntimeIdentifier=${RUNTIME_ID} /maxcpucount:1"
J
jaredpar 已提交
109

110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
echo "Building bootstrap CscCore"
dotnet publish ${SRC_PATH}/Compilers/CSharp/CscCore -o ${BOOTSTRAP_PATH}/csc ${BUILD_ARGS}
echo "Building bootstrap VbcCore"
dotnet publish ${SRC_PATH}/Compilers/VisualBasic/VbcCore -o ${BOOTSTRAP_PATH}/vbc ${BUILD_ARGS}
rm -rf ${BINARIES_PATH}/${BUILD_CONFIGURATION}
BUILD_ARGS+=" /p:CscToolPath=${BOOTSTRAP_PATH}/csc /p:CscToolExe=csc /p:VbcToolPath=${BOOTSTRAP_PATH}/vbc /p:VbcToolExe=vbc"

echo "Building CrossPlatform.sln"
dotnet build ${THIS_DIR}/CrossPlatform.sln ${BUILD_ARGS}

if [[ "${SKIP_TESTS}" == false ]]
then
    echo "Running tests"
    ${THIS_DIR}/build/scripts/tests.sh ${BUILD_CONFIGURATION}
fi