Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move logic from the Makefile to either cibuild.sh or build/scripts #21146

Merged
merged 3 commits into from
Jul 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 0 additions & 69 deletions Makefile

This file was deleted.

39 changes: 39 additions & 0 deletions build/scripts/obtain_dotnet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
# 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.

# Source this script to ensure dotnet is installed and on the path.
# If the FORCE_DOWNLOAD environment variable is set to "true", the system's dotnet install is ignored,
# and dotnet is downloaded and installed locally.

set -e
set -u

# check if `dotnet` is already on the PATH
if command -v dotnet >/dev/null 2>&1
then
if [[ "${FORCE_DOWNLOAD:-false}" != true ]]
then
exit 0
fi
fi

# This is a function to keep variable assignments out of the parent script (that is sourcing this file)
install_dotnet () {
# Download and install `dotnet` locally
local DOTNET_VERSION=1.0.1
local THIS_DIR=$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)
local DOTNET_PATH=${THIS_DIR}/../../Binaries/dotnet-cli

if [[ ! -x "${DOTNET_PATH}/dotnet" ]]
then
echo "Downloading and installing .NET CLI version ${DOTNET_VERSION} to ${DOTNET_PATH}"
curl https://raw.githubusercontent.com/dotnet/cli/rel/${DOTNET_VERSION}/scripts/obtain/dotnet-install.sh | \
/usr/bin/env bash -s -- --version "${DOTNET_VERSION}" --install-dir "${DOTNET_PATH}"
else
echo "Skipping download of .NET CLI: Already installed at ${DOTNET_PATH}"
fi

export PATH=${DOTNET_PATH}:${PATH}
}
install_dotnet
23 changes: 16 additions & 7 deletions build/scripts/tests.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
#!/usr/bin/env bash
# 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.

BUILD_CONFIGURATION=$1
set -e
set -u

# This function will update the PATH variable to put the desired
# version of Mono ahead of the system one.
BUILD_CONFIGURATION=${1:-Debug}

cd Binaries/$BUILD_CONFIGURATION/CoreClrTest
THIS_DIR=$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)
BINARIES_PATH=${THIS_DIR}/../../Binaries
SRC_PATH=${THIS_DIR}/../../src
TEST_DIR=${BINARIES_PATH}/${BUILD_CONFIGURATION}/CoreClrTest

chmod +x ./corerun
RUNTIME_ID=$(dotnet --info | awk '/RID:/{print $2;}')

BUILD_ARGS="-c ${BUILD_CONFIGURATION} -r ${RUNTIME_ID} /consoleloggerparameters:Verbosity=minimal;summary /p:RoslynRuntimeIdentifier=${RUNTIME_ID}"
dotnet publish ${SRC_PATH}/Test/DeployCoreClrTestRuntime -o ${TEST_DIR} ${BUILD_ARGS}

cd ${TEST_DIR}

mkdir -p xUnitResults

./corerun ./xunit.console.netcore.exe *.UnitTests.dll -parallel all -xml xUnitResults/TestResults.xml
dotnet exec ./xunit.console.netcore.exe *.UnitTests.dll -parallel all -xml xUnitResults/TestResults.xml

if [ $? -ne 0 ]; then
echo Unit test failed
exit 1
fi

70 changes: 46 additions & 24 deletions cibuild.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env bash
# 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.

set -e
set -u

usage()
{
Expand All @@ -9,23 +13,22 @@ usage()
echo "Options"
echo " --debug Build Debug (default)"
echo " --release Build Release"
echo " --cleanrun Clean the project before building"
echo " --skiptest Do not run tests"
echo " --skipcrossgen Do not crossgen the bootstrapped compiler"
echo " --skipcommitprinting Do not print commit information"
echo " --nocache Force download of toolsets"
}

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

BUILD_CONFIGURATION=Debug
USE_CACHE=true
CLEAN_RUN=false
SKIP_TESTS=false
SKIP_CROSSGEN=false
SKIP_COMMIT_PRINTING=false

MAKE="make"
if [[ $OSTYPE == *[Bb][Ss][Dd]* ]]; then
MAKE="gmake"
fi

# 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
Expand All @@ -51,31 +54,30 @@ do
BUILD_CONFIGURATION=Release
shift 1
;;
--nocache)
USE_CACHE=false
--cleanrun)
CLEAN_RUN=true
shift 1
;;
--skiptests)
SKIP_TESTS=true
shift 1
;;
--skipcrossgen)
SKIP_CROSSGEN=true
shift 1
;;
--skipcommitprinting)
SKIP_COMMIT_PRINTING=true
shift 1
;;
--nocache)
# Temporarily ignore this argument until the change to netci.groovy gets merged.
# A follow-up PR will be made to remove this ignore.
shift 1
;;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaredpar As discussed, this needs to be in this PR until the netci.groovy change (also in this PR) is merged. A follow-up PR removing this will be made at that point.

*)
usage
exit 1
;;
esac
done

MAKE_ARGS="BUILD_CONFIGURATION=$BUILD_CONFIGURATION SKIP_CROSSGEN=$SKIP_CROSSGEN"

if [ "$CLEAN_RUN" == "true" ]; then
echo Clean out the enlistment
git clean -dxf .
Expand All @@ -86,13 +88,33 @@ if [ "$SKIP_COMMIT_PRINTING" == "false" ]; then
git show --no-patch --pretty=raw HEAD
fi

echo Building Bootstrap
$MAKE bootstrap $MAKE_ARGS
# obtain_dotnet.sh puts the right dotnet on the PATH
FORCE_DOWNLOAD=true
source ${THIS_DIR}/build/scripts/obtain_dotnet.sh

echo Building CrossPlatform.sln
$MAKE all $MAKE_ARGS BOOTSTRAP=true BUILD_LOG_PATH=Binaries/Build.log
RUNTIME_ID=$(dotnet --info | awk '/RID:/{print $2;}')
echo "Using Runtime Identifier: ${RUNTIME_ID}"

if [ "$SKIP_TESTS" == "false" ]; then
$MAKE test $MAKE_ARGS
fi
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

BUILD_ARGS="-c ${BUILD_CONFIGURATION} -r ${RUNTIME_ID} /nologo /consoleloggerparameters:Verbosity=minimal;summary /filelogger /fileloggerparameters:Verbosity=normal;logFile=${BUILD_LOG_PATH} /p:RoslynRuntimeIdentifier=${RUNTIME_ID}"

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
19 changes: 4 additions & 15 deletions docs/infrastructure/cross-platform.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,15 @@

Linux and Mac support for developing Roslyn is very much a work in progress. Not everything is supported at the moment and the steps detailed on this page will change very frequently. If this is an area you are interested in then please check back frequently for updates.

## Building using a pre-made toolset
## Building

Right now Roslyn builds on *nix using a mix of Mono and CoreCLR. Patching the right Mono version and acquiring all the tools
can be very difficult, so we've saved pre-built versions on Azure.
Build all cross-platform projects with: `dotnet build CrossPlatform.sln`.

Running `make` should download all these toolset binaries and kick off a build using MSBuild running on Mono.
If you do not have a system-wide `dotnet` install, you can obtain one with `./build/scripts/obtain_dotnet.sh`. This will install a compatible version of the CLI to `./Binaries/dotnet-cli` - add this to your PATH before trying to build `CrossPlatform.sln`. Alternatively, sourcing the script with `source ./build/scripts/obtain_dotnet.sh` will add it to your PATH for you.

## Using the compiler

After building there should be at least two versions of `csc.exe` in your output directory.

The first is in the `Binaries/Debug` directory. This is the "full .NET framework" version. That means it expects to run on a
full .NET framework, like either the Windows .NET framework or Mono. You would run this like you run other mono programs, i.e.
`mono csc.exe`.

The second copy is in the `Binaries/Debug/csccore` directory. This is a version running directly on CoreCLR -- no Mono necessary.
Just run `csc` in that directory. Note that this version includes a copy of CoreCLR in the output directory, so it is not portable.
The version of CoreCLR copied is specific to whatever machine you built with, so if you're running OS X, this will only run on OS X.
Similarly with Linux (and whatever distro you're using).

After building, there will be a `csc` in the `Binaries/Debug/Exes/CscCore` directory.

### Known issues when running `csc.exe`

Expand Down
29 changes: 0 additions & 29 deletions docs/infrastructure/unix-toolset.md

This file was deleted.

6 changes: 3 additions & 3 deletions netci.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ commitPullList.each { isPr ->
def myJob = job(jobName) {
description("Ubuntu 14.04 tests")
steps {
shell("./cibuild.sh --nocache --debug")
shell("./cibuild.sh --debug")
}
}

Expand All @@ -120,7 +120,7 @@ commitPullList.each { isPr ->
def myJob = job(jobName) {
description("Ubuntu 16.04 tests")
steps {
shell("./cibuild.sh --nocache --debug")
shell("./cibuild.sh --debug")
}
}

Expand All @@ -137,7 +137,7 @@ commitPullList.each { isPr ->
def myJob = job(jobName) {
description("Mac tests")
steps {
shell("./cibuild.sh --nocache --debug")
shell("./cibuild.sh --debug")
}
}

Expand Down