Clean up build scripts

Decompose into self-contained granular components
Provide reasonable defaults for cross cutting concerns, allowing for independent execution of steps
Start unifying Windows/Bash architecture

fix Bash CI scripts

dockerbuild.sh _common.sh path

Add missing restore-packages.sh

Copy/paste issues

Quote $SOURCE
fix .gitignore

PR Feedback

Merge in @SridarMS's work to avoid redownloading DNX

enabling build of dotnet-build

merge in @SridharMS's CentOS changes

Enable building FSC

enable restoring specific subdirectories

Fix dnx version check

Add missed dependency

Fix pathing to tests

Match Linux build version to Windows, fixing linux tests as a side effect.

workaround for coreclr#2215

fix pathing issue

disable building in docker

BUILD_IN_DOCKER was set, somehow...

fix headers
This commit is contained in:
Piotr Puszkiewicz 2015-12-28 11:47:21 -08:00
parent d1a257bff7
commit 4b217db9c0
66 changed files with 1163 additions and 242 deletions

21
scripts/common/_clang.sh Normal file
View file

@ -0,0 +1,21 @@
#!/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 up the environment to be used for building with clang.
if which "clang-3.5" > /dev/null 2>&1; then
export CC="$(which clang-3.5)"
export CXX="$(which clang++-3.5)"
elif which "clang-3.6" > /dev/null 2>&1; then
export CC="$(which clang-3.6)"
export CXX="$(which clang++-3.6)"
elif which clang > /dev/null 2>&1; then
export CC="$(which clang)"
export CXX="$(which clang++)"
else
error "Unable to find Clang Compiler"
error "Install clang-3.5 or clang3.6"
exit 1
fi

View file

@ -0,0 +1,23 @@
#
# 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.
#
. $PSScriptRoot\_utility.ps1
$Rid = "win7-x64"
$Tfm = "dnxcore50"
$RepoRoot = Convert-Path "$PSScriptRoot\..\.."
$OutputDir = "$RepoRoot\artifacts\$Rid"
$DnxDir = "$OutputDir\dnx"
$DnxRoot = "$DnxDir\bin"
$Stage1Dir = "$OutputDir\stage1"
$Stage2Dir = "$OutputDir\stage2"
$HostDir = "$OutputDir\corehost"
$PackageDir = "$RepoRoot\artifacts\packages\dnvm"
# Set reasonable defaults for unset variables
setEnvIfDefault "DOTNET_INSTALL_DIR" "$(Convert-Path "$PSScriptRoot\..")\.dotnet_stage0\win7-x64"
setEnvIfDefault "DOTNET_BUILD_VERSION" "0.1.0.0"
setPathAndHomeIfDefault "$Stage2Dir"
setEnvIfDefault "CONFIGURATION" "Debug"

37
scripts/common/_common.sh Normal file
View file

@ -0,0 +1,37 @@
#
# 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.
#
COMMONSOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
COMMONDIR="$( cd -P "$( dirname "$COMMONSOURCE" )" && pwd )"
COMMONSOURCE="$(readlink "$COMMONSOURCE")"
[[ $COMMONSOURCE != /* ]] && COMMONSOURCE="$COMMONDIR/$COMMONSOURCE" # 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 "$COMMONSOURCE" )" && pwd )"
source "$DIR/_clang.sh"
source "$DIR/_prettyprint.sh"
source "$DIR/_rid.sh"
# TODO: Replace this with a dotnet generation
export TFM=dnxcore50
export REPOROOT=$(cd $DIR/../.. && pwd)
export OUTPUT_ROOT=$REPOROOT/artifacts/$RID
export DNX_DIR=$OUTPUT_ROOT/dnx
export DNX_ROOT=$DNX_DIR/bin
export STAGE1_DIR=$OUTPUT_ROOT/stage1
export STAGE2_DIR=$OUTPUT_ROOT/stage2
export HOST_DIR=$OUTPUT_ROOT/corehost
[ -z "$DOTNET_INSTALL_DIR" ] && export DOTNET_INSTALL_DIR=$REPOROOT/.dotnet_stage0/$RID
[ -z "$DOTNET_BUILD_VERSION" ] && export DOTNET_BUILD_VERSION=0.1.0.0
[ -z "$DOTNET_HOME" ] && export DOTNET_HOME=$STAGE2_DIR && export PATH=$STAGE2_DIR/bin:$PATH
[ -z "$CONFIGURATION" ] && export CONFIGURATION=Debug
# if the conditional set is the last command in this file AND
# the condition is false then the program exits here. Seems like
# a bug in BASH... or indication that there is more to learn about Linux
# the below line is a hack that works around this issue
a=1+1

View file

@ -0,0 +1,63 @@
#!/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.
#
# Detect build servers
if [[ ! -z "$JENKINS_URL" || ! -z "$BUILD_BUILDID" ]]; then
# Jenkins or VSO build, disable colors because they make things gross.
NO_COLOR=1
fi
if [ "$NO_COLOR" != "1" ]; then
# ANSI Colors
RCol='\e[0m' # Text Reset
# Regular Bold Underline High Intensity BoldHigh Intens Background High Intensity Backgrounds
Bla='\e[0;30m'; BBla='\e[1;30m'; UBla='\e[4;30m'; IBla='\e[0;90m'; BIBla='\e[1;90m'; On_Bla='\e[40m'; On_IBla='\e[0;100m';
Red='\e[0;31m'; BRed='\e[1;31m'; URed='\e[4;31m'; IRed='\e[0;91m'; BIRed='\e[1;91m'; On_Red='\e[41m'; On_IRed='\e[0;101m';
Gre='\e[0;32m'; BGre='\e[1;32m'; UGre='\e[4;32m'; IGre='\e[0;92m'; BIGre='\e[1;92m'; On_Gre='\e[42m'; On_IGre='\e[0;102m';
Yel='\e[0;33m'; BYel='\e[1;33m'; UYel='\e[4;33m'; IYel='\e[0;93m'; BIYel='\e[1;93m'; On_Yel='\e[43m'; On_IYel='\e[0;103m';
Blu='\e[0;34m'; BBlu='\e[1;34m'; UBlu='\e[4;34m'; IBlu='\e[0;94m'; BIBlu='\e[1;94m'; On_Blu='\e[44m'; On_IBlu='\e[0;104m';
Pur='\e[0;35m'; BPur='\e[1;35m'; UPur='\e[4;35m'; IPur='\e[0;95m'; BIPur='\e[1;95m'; On_Pur='\e[45m'; On_IPur='\e[0;105m';
Cya='\e[0;36m'; BCya='\e[1;36m'; UCya='\e[4;36m'; ICya='\e[0;96m'; BICya='\e[1;96m'; On_Cya='\e[46m'; On_ICya='\e[0;106m';
Whi='\e[0;37m'; BWhi='\e[1;37m'; UWhi='\e[4;37m'; IWhi='\e[0;97m'; BIWhi='\e[1;97m'; On_Whi='\e[47m'; On_IWhi='\e[0;107m';
fi
cecho()
{
local text=$1
printf "%b\n" "$text"
}
header()
{
local text=$1
cecho "${BGre}*** $text ***${RCol}"
}
info()
{
local text=$1
cecho "${Gre}info :${RCol} $text"
}
warning()
{
local text=$1
cecho "${Yel}warn :${RCol} $text" 1>&2
}
error()
{
local text=$1
cecho "${Red}error:${RCol} $text" 1>&2
}
die()
{
local text=$1
error "$text"
exit 1
}

37
scripts/common/_rid.sh Normal file
View file

@ -0,0 +1,37 @@
#!/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.
#
export UNAME=$(uname)
if [ -z "$RID" ]; then
if [ "$UNAME" == "Darwin" ]; then
export OSNAME=osx
if [ -n "$(sw_vers -productVersion | grep 10.10.)" ]; then
export RID=osx.10.10-x64
elif [ -n "$(sw_vers -productVersion | grep 10.11.)" ]; then
export RID=osx.10.10-x64
else
error "unknown OS X: $(sw_vers -productVersion)" 1>&2
fi
elif [ "$UNAME" == "Linux" ]; then
# Detect Distro
if [ "$(cat /etc/*-release | grep -cim1 ubuntu)" -eq 1 ]; then
export OSNAME=ubuntu
export RID=ubuntu.14.04-x64
elif [ "$(cat /etc/*-release | grep -cim1 centos)" -eq 1 ]; then
export OSNAME=centos
export RID=centos.7.1-x64
else
error "unknown Linux Distro" 1>&2
fi
else
error "unknown OS: $UNAME" 1>&2
fi
fi
if [ -z "$RID" ]; then
exit 1
fi

View file

@ -0,0 +1,63 @@
#
# 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.
#
function header([string]$message)
{
Write-Host -ForegroundColor Green "*** $message ***"
}
function info([string]$message)
{
Write-Host -ForegroundColor Yellow "*** $message ***"
}
function error([string]$message)
{
Write-Host -ForegroundColor Red "$message"
}
function setEnvIfDefault([string]$envVarName, [string]$value)
{
If ([Environment]::GetEnvironmentVariable($envVarName) -eq $null)
{
[Environment]::SetEnvironmentVariable($envVarName, $value)
}
}
function setPathAndHomeIfDefault([string]$rootPath)
{
If ($env:DOTNET_HOME -eq $null)
{
$env:DOTNET_HOME=$rootPath
$env:PATH="$rootPath\bin;$env:PATH"
}
}
function _([string]$command)
{
& "$command"
if (!$?) {
error "Command Failed: '& $command'"
Exit 1
}
}
function _([string]$command, $arguments)
{
& "$command" @arguments
if (!$?) {
error "Command Failed: '& $command'"
Exit 1
}
}
function _cmd([string]$command)
{
cmd /c "$command"
if (!$?) {
error "Command Failed: 'cmd /c $command'"
Exit 1
}
}