Permalink
Browse files

Build script cleanup (#30345)

Move Linux build logic to build\scripts\build.sh
Eliminate MicroBuild scripts
  • Loading branch information...
tmat committed Oct 10, 2018
1 parent a0be292 commit 698d470ab911c6b5376b4dafb4beb5eded91d8ea
@@ -32,37 +32,28 @@ steps:
feed: '8f470c7e-ac49-4afe-a6ee-cf784e438b93'
- task: CmdLine@1
displayName: Create output directory
inputs:
filename: mkdir
arguments: 'Binaries\$(BuildConfiguration)'
- task: VSBuild@1
- task: PowerShell@2
displayName: Build
inputs:
solution: 'src/Tools/MicroBuild/Build.proj'
vsVersion: 15.0
msbuildArgs: >-
/p:TreatWarningsAsErrors=true
/p:DeployExtension=false
/p:TrackFileAccess=false
/p:OfficialBuildId=$(BUILD.BUILDNUMBER)
/p:VisualStudioVersion=14.0
/flp1:Summary;Verbosity=diagnostic;Encoding=UTF-8;LogFile=$(Build.SourcesDirectory)\Binaries\$(BuildConfiguration)\Roslyn.log
/flp2:WarningsOnly;Verbosity=diagnostic;Encoding=UTF-8;LogFile=$(Build.SourcesDirectory)\Binaries\$(BuildConfiguration)\Roslyn.wrn
/flp3:ErrorsOnly;Verbosity=diagnostic;Encoding=UTF-8;LogFile=$(Build.SourcesDirectory)\Binaries\$(BuildConfiguration)\Roslyn.err
/p:RoslynMyGetApiKey=$(Roslyn.MyGetApiKey)
/p:RoslynNuGetApiKey=$(Roslyn.NuGetApiKey)
/p:RoslynGitHubEmail=$(Roslyn.GitHubEmail)
/p:RoslynGitHubToken=$(Roslyn.GitHubToken)
/p:RoslynGitHubUserName=$(Roslyn.GitHubUserName)
/p:PB_PublishBlobFeedKey=$(PB_PublishBlobFeedKey)
/p:PublishStableVersions=false
/p:VersionStampToPublish=prerelease
/p:DotNetSymbolServerTokenMsdl=$(microsoft-symbol-server-pat)
/p:DotNetSymbolServerTokenSymWeb=$(symweb-symbol-server-pat)
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
maximumCpuCount: true
logProjectEvents: false
filePath: 'build\scripts\cibuild.cmd'
arguments: -configuration $(BuildConfiguration) -official -testDesktop -procdump -deployExtensions:$false
/p:OfficialBuildId=$(BUILD.BUILDNUMBER)
/p:DotNetSignType=$(PB_SignType)
/p:DotNetSymbolServerTokenMsdl=$(microsoft-symbol-server-pat)
/p:DotNetSymbolServerTokenSymWeb=$(symweb-symbol-server-pat)
condition: succeeded()
- task: PowerShell@2
displayName: Publish Assets
inputs:
arguments: '-config $(BuildConfiguration) -branchName "$(Build.SourceBranch)" -mygetApiKey $(Roslyn.MyGetApiKey) -nugetApiKey $(Roslyn.NuGetApiKey) -gitHubUserName $(Roslyn.GitHubUserName) -gitHubToken $(Roslyn.GitHubToken) -gitHubEmail $(Roslyn.GitHubEmail)'
filePath: 'build\scripts\publish-assets.ps1'
condition: succeeded()
- task: PublishBuildArtifacts@1
displayName: Publish Logs
@@ -86,7 +77,7 @@ steps:
displayName: Upload VSTS Drop
inputs:
DropFolder: 'Binaries\VSSetup\$(BuildConfiguration)\Insertion'
condition: and(succeeded(), contains(variables['PB_PublishType'], 'vsts'))
condition: succeeded()
- task: NuGetCommand@2
displayName: NuGet CoreXT publish
@@ -96,7 +87,7 @@ steps:
packagesToPush: '$(Build.SourcesDirectory)\Binaries\$(BuildConfiguration)\DevDivPackages\**\*.nupkg'
publishVstsFeed: '97a41293-2972-4f48-8c0e-05493ae82010'
allowPackageConflicts: true
condition: and(succeeded(), contains(variables['PB_PublishType'], 'vsts'))
condition: succeeded()
# Publish VSTS artifact that the RoslynInsertionTool is able to find by its name.
# The backing storage of the artifact is a file share.
@@ -130,5 +121,5 @@ steps:
ArtifactName: '$(Build.BuildNumber)'
publishLocation: FilePath
TargetPath: '$(DropRoot)\Roslyn-Signed\$(Build.SourceBranchName)\$(BuildConfiguration)'
condition: and(succeededOrFailed(), contains(variables['PB_PublishType'], 'vsts'))
condition: succeededOrFailed()
@@ -19,7 +19,8 @@ phases:
_testKind: Test64
steps:
- script: build/scripts/cibuild.cmd -$(_configuration) -testDesktop -$(_testKind)
- script: build/scripts/cibuild.cmd -configuration $(_configuration) -testDesktop -$(_testKind)
displayName: Build and Test
- task: PublishTestResults@1
inputs:
@@ -49,7 +50,8 @@ phases:
_configuration: Release
steps:
- script: build/scripts/cibuild.cmd -$(_configuration) -testCoreClr -buildCoreClr
- script: build/scripts/cibuild.cmd -configuration $(_configuration) -testCoreClr -buildCoreClr
displayName: Build and Test
- task: PublishTestResults@1
inputs:
@@ -73,6 +75,7 @@ phases:
timeoutInMinutes: 90
steps:
- script: build/scripts/cibuild.cmd -testDeterminism
displayName: Build - Validate determinism
- task: PublishBuildArtifacts@1
inputs:
@@ -87,7 +90,8 @@ phases:
name: dotnet-external-temp
timeoutInMinutes: 90
steps:
- script: build/scripts/test-build-correctness.cmd -cibuild -release
- script: build/scripts/test-build-correctness.cmd -configuration Release -cibuild
displayName: Build - Validate correctness
- task: PublishBuildArtifacts@1
inputs:
@@ -104,14 +108,16 @@ phases:
parallel: 2
matrix:
coreclr:
_args: --debug
_args: --configuration Debug
_name: CoreClr
mono:
_args: --debug --docker --mono
_args: --configuration Debug --docker --mono
_name: Mono
steps:
- script: ./build/scripts/cibuild.sh $(_args)
displayName: Build and Test
- script: ./build/scripts/dockerstop.sh
displayName: Stop Docker
condition: eq(variables['_name'], 'Mono')
- task: PublishTestResults@1
inputs:
213 build.sh
@@ -1,209 +1,16 @@
#!/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
source="${BASH_SOURCE[0]}"
usage()
{
echo "Main interface to running builds on Mac/Linux"
echo "Usage: build.sh [options]"
echo ""
echo "Options"
echo " --debug Build Debug (default)"
echo " --release Build Release"
echo " --restore Restore projects required to build"
echo " --build Build all projects"
echo " --pack Build nuget packages"
echo " --test Run unit tests"
echo " --mono Run unit tests with mono"
echo " --build-bootstrap Build the bootstrap compilers"
echo " --use-bootstrap Use the built bootstrap compilers when running main build"
echo " --bootstrap Implies --build-bootstrap and --use-bootstrap"
}
# resolve $SOURCE until the file is no longer a symlink
while [[ -h $source ]]; do
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
source="$(readlink "$source")"
root_path="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
binaries_path="${root_path}"/Binaries
bootstrap_path="${binaries_path}"/Bootstrap
args=
build_in_docker=false
build_configuration=Debug
restore=false
build=false
test_=false
pack=false
use_mono=false
build_bootstrap=false
use_bootstrap=false
stop_vbcscompiler=false
# 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"
if [[ $# = 0 ]]
then
usage
echo ""
echo "To build and test this repo, try: ./build.sh --restore --build --test"
exit 1
fi
while [[ $# > 0 ]]
do
opt="$(echo "$1" | awk '{print tolower($0)}')"
case "$opt" in
-h|--help)
usage
exit 1
;;
--docker)
build_in_docker=true
shift
continue
;;
--debug)
build_configuration=Debug
;;
--release)
build_configuration=Release
;;
--restore|-r)
restore=true
;;
--build|-b)
build=true
;;
--test|-t)
test_=true
;;
--mono)
use_mono=true
;;
--build-bootstrap)
build_bootstrap=true
;;
--use-bootstrap)
use_bootstrap=true
;;
--bootstrap)
build_bootstrap=true
use_bootstrap=true
;;
--stop-vbcscompiler)
stop_vbcscompiler=true
;;
--pack)
pack=true
;;
*)
echo "$1"
usage
exit 1
;;
esac
args="$args $1"
shift
# if $source was a relative symlink, we need to resolve it relative to the path where the
# symlink file was located
[[ $source != /* ]] && source="$scriptroot/$source"
done
config_path=${binaries_path}/${build_configuration}
logs_path=${config_path}/Logs
mkdir -p ${binaries_path}
mkdir -p ${config_path}
mkdir -p ${logs_path}
function stop_processes {
echo "Killing running build processes..."
pkill -9 "dotnet" || true
pkill -9 "vbcscompiler" || true
}
if [[ "$build_in_docker" = true ]]
then
echo "Docker exec: $args"
BUILD_COMMAND=/opt/code/build.sh "$root_path"/build/scripts/dockerrun.sh $args
exit
fi
source "${root_path}"/build/scripts/obtain_dotnet.sh
if [[ "$restore" == true ]]
then
echo "Restoring RoslynToolset.csproj"
dotnet restore "${root_path}/build/ToolsetPackages/RoslynToolset.csproj" "/bl:${logs_path}/Restore-RoslynToolset.binlog"
echo "Restoring Compilers.sln"
dotnet restore "${root_path}/Compilers.sln" "/bl:${logs_path}/Restore-Compilers.binlog"
fi
build_args="--no-restore -c ${build_configuration} /nologo"
if [[ "$build_bootstrap" == true ]]
then
echo "Building bootstrap compiler"
rm -rf ${bootstrap_path}
mkdir -p ${bootstrap_path}
project_path=src/NuGet/Microsoft.NETCore.Compilers/Microsoft.NETCore.Compilers.Package.csproj
dotnet pack -nologo ${project_path} /p:DotNetUseShippingVersions=true /p:InitialDefineConstants=BOOTSTRAP /p:PackageOutputPath=${bootstrap_path}
unzip ${bootstrap_path}/Microsoft.NETCore.Compilers.*.nupkg -d ${bootstrap_path}
chmod -R 755 ${bootstrap_path}
echo "Cleaning Bootstrap compiler artifacts"
dotnet clean ${project_path}
stop_processes
fi
if [[ "${use_bootstrap}" == true ]]
then
build_args+=" /p:BootstrapBuildPath=${bootstrap_path}"
fi
# https://github.com/dotnet/roslyn/issues/23736
UNAME="$(uname)"
if [[ "$UNAME" == "Darwin" ]]
then
build_args+=" /p:UseRoslynAnalyzers=false"
fi
if [[ "${build}" == true ]]
then
echo "Building Compilers.sln"
if [[ "${pack}" == true ]]
then
build_args+=" /t:Pack"
fi
dotnet build "${root_path}/Compilers.sln" ${build_args} "/bl:${binaries_path}/Build.binlog"
fi
if [[ "${stop_vbcscompiler}" == true ]]
then
if [[ "${use_bootstrap}" == true ]]
then
dotnet build-server shutdown
else
echo "--stop-vbcscompiler requires --use-bootstrap. Aborting."
exit 1
fi
fi
if [[ "${test_}" == true ]]
then
if [[ "${use_mono}" == true ]]
then
test_runtime=mono
# Echo out the mono version to the comamnd line so it's visible in CI logs. It's not fixed
# as we're using a feed vs. a hard coded package.
mono --version
else
test_runtime=dotnet
fi
"${root_path}"/build/scripts/tests.sh "${build_configuration}" "${test_runtime}"
fi
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
"$scriptroot/build/scripts/build.sh" $@
Oops, something went wrong.

0 comments on commit 698d470

Please sign in to comment.