Skip to content
This repository has been archived by the owner on Aug 28, 2019. It is now read-only.

Commit

Permalink
Add dev workflow scripts for build pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
wtgodbe committed May 17, 2016
1 parent 41a4ad5 commit 8568bf1
Show file tree
Hide file tree
Showing 13 changed files with 557 additions and 4 deletions.
2 changes: 1 addition & 1 deletion BuildToolsVersion.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.25-prerelease-00327-01
1.0.25-prerelease-00416-04
47 changes: 47 additions & 0 deletions build-packages.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
@if "%_echo%" neq "on" echo off
setlocal EnableDelayedExpansion

set "__ProjectDir=%~dp0"
set packagesLog=build-packages.log
set binclashLoggerDll=%~dp0Tools\net45\Microsoft.DotNet.Build.Tasks.dll
set binclashlog=%~dp0binclash.log
echo Running build-packages.cmd %* > %packagesLog%

set options=/nologo /maxcpucount /v:minimal /clp:Summary /nodeReuse:false /flp:v=detailed;Append;LogFile=%packagesLog% /l:BinClashLogger,%binclashLoggerDll%;LogFile=%binclashlog% /p:FilterToOSGroup=Windows_NT
set allargs=%*

if /I [%1] == [/?] goto Usage
if /I [%1] == [/help] goto Usage

REM ensure that msbuild is available
echo Running init-tools.cmd
call %~dp0init-tools.cmd

set __msbuildArgs="%__ProjectDir%\src\.nuget\Microsoft.NETCore.Runtime.CoreClr\Microsoft.NETCore.Runtime.CoreCLR.builds" !allargs!
echo msbuild.exe %__msbuildArgs% !options! >> %packagesLog%
call msbuild.exe %__msbuildArgs% !options!
if NOT [!ERRORLEVEL!]==[0] (
echo ERROR: An error occurred while building packages, see %packagesLog% for more details.
exit /b 1
)

set __msbuildArgs="%__ProjectDir%\src\.nuget\Microsoft.NETCore.Jit\Microsoft.NETCore.Jit.builds" !allargs!
echo msbuild.exe %__msbuildArgs% !options! >> %packagesLog%
call msbuild.exe %__msbuildArgs% !options!
if NOT [!ERRORLEVEL!]==[0] (
echo ERROR: An error occurred while building packages, see %packagesLog% for more details.
exit /b 1
)


echo Done Building Packages.
exit /b

:Usage
echo.
echo Builds the NuGet packages from the binaries that were built in the Build product binaries step.
echo The following properties are required to define build architecture
echo /p:__BuildArch=[architecture] /p:__BuildType=[configuration]
echo Architecture can be x64, x86, arm, or arm64
echo Configuration can be Release, Debug, or Checked
exit /b
148 changes: 148 additions & 0 deletions build-packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
#!/usr/bin/env bash

usage()
{
echo "Builds the NuGet packages from the binaries that were built in the Build product binaries step."
echo "Usage: build-packages [arch] [configuration]"
echo "arch can be x64, x86, arm, arm64 (default is x64)"
echo "configuration can be release, checked, debug (default is debug)"
echo
exit 1
}

__ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
build_packages_log=$__ProjectRoot/build-packages.log
binclashlog=$__ProjectRoot/binclash.log
binclashloggerdll=$__ProjectRoot/Tools/Microsoft.DotNet.Build.Tasks.dll
RuntimeOS=ubuntu.$VERSION_ID

__MSBuildPath=$__ProjectRoot/Tools/MSBuild.exe

# Parse arguments
__BuildArch=x64
__BuildType=Debug

allargs="$@"

echo -e "Running build-packages.sh $allargs" > $build_packages_log

if [ "$allargs" == "-h" ] || [ "$allargs" == "--help" ]; then
usage
fi

while :; do
if [ $# -le 0 ]; then
break
fi

lowerI="$(echo $1 | awk '{print tolower($0)}')"
case $lowerI in
-\?|-h|--help)
usage
exit 1
;;

x86)
__BuildArch=x86
;;

x64)
__BuildArch=x64
;;

arm)
__BuildArch=arm
;;

arm64)
__BuildArch=arm64
;;
debug)
__BuildType=Debug
;;
release)
__BuildType=Release
;;
checked)
__BuildType=Checked
esac
shift
done

# Use uname to determine what the OS is.
OSName=$(uname -s)
case $OSName in
Linux)
__BuildOS=Linux
;;

Darwin)
__BuildOS=OSX
;;

FreeBSD)
__BuildOS=FreeBSD
;;

OpenBSD)
__BuildOS=OpenBSD
;;

NetBSD)
__BuildOS=NetBSD
;;

SunOS)
__BuildOS=SunOS
;;

*)
echo "Unsupported OS $OSName detected, configuring as if for Linux"
__BuildOS=Linux
;;
esac

if [ "$__BuildOS" == "Linux" ]; then
# Detect Distro
if [ "$(cat /etc/*-release | grep -cim1 ubuntu)" -eq 1 ]; then
export __DistroName=ubuntu
elif [ "$(cat /etc/*-release | grep -cim1 centos)" -eq 1 ]; then
export __DistroName=rhel
elif [ "$(cat /etc/*-release | grep -cim1 rhel)" -eq 1 ]; then
export __DistroName=rhel
elif [ "$(cat /etc/*-release | grep -cim1 debian)" -eq 1 ]; then
export __DistroName=debian
else
export __DistroName=""
fi
fi

__IntermediatesDir="$__ProjectRoot/bin/obj/$__BuildOS.$__BuildArch.$__BuildType"

# Ensure that MSBuild is available
echo "Running init-tools.sh"
$__ProjectRoot/init-tools.sh

echo "Generating nuget packages for "$__BuildOS

# Invoke MSBuild
$__ProjectRoot/Tools/corerun "$__MSBuildPath" /nologo "$__ProjectRoot/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/Microsoft.NETCore.Runtime.CoreCLR.builds" /verbosity:minimal "/fileloggerparameters:Verbosity=normal;LogFile=$binclashlog" /t:Build /p:__BuildOS=$__BuildOS /p:__BuildArch=$__BuildArch /p:__BuildType=$__BuildType /p:__IntermediatesDir=$__IntermediatesDir /p:BuildNugetPackage=false /p:UseSharedCompilation=false

if [ $? -ne 0 ]; then
echo -e "\nAn error occurred. Aborting build-packages.sh ." >> $build_packages_log
echo "ERROR: An error occurred while building packages, see $build_packages_log for more details."
exit 1
fi

# Build the JIT packages
$__ProjectRoot/Tools/corerun "$__MSBuildPath" /nologo "$__ProjectRoot/src/.nuget/Microsoft.NETCore.Jit/Microsoft.NETCore.Jit.builds" /verbosity:minimal "/fileloggerparameters:Verbosity=normal;LogFile=$binclashlog" /t:Build /p:__BuildOS=$__BuildOS /p:__BuildArch=$__BuildArch /p:__BuildType=$__BuildType /p:__IntermediatesDir=$__IntermediatesDir /p:BuildNugetPackage=false /p:UseSharedCompilation=false

if [ $? -ne 0 ]; then
echo -e "\nAn error occurred. Aborting build-packages.sh ." >> $build_packages_log
echo "ERROR: An error occurred while building packages, see $build_packages_log for more details."
exit 1
fi

echo "Done building packages."
echo -e "\nDone building packages." >> $build_packages_log
exit 0
11 changes: 11 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ set __SkipCoreLibBuild=
set __SkipNativeBuild=
set __SkipTestBuild=
set __BuildSequential=
set __SkipRestore=
set __SkipNuget=
set __msbuildCleanBuildArgs=
set __msbuildExtraArgs=
set __SignTypeReal=
Expand Down Expand Up @@ -113,6 +115,8 @@ if /i "%1" == "skipconfigure" (set __SkipConfigure=1&shift&goto Arg_Loop)
if /i "%1" == "skipmscorlib" (set __SkipCoreLibBuild=1&shift&goto Arg_Loop)
if /i "%1" == "skipnative" (set __SkipNativeBuild=1&shift&goto Arg_Loop)
if /i "%1" == "skiptests" (set __SkipTestBuild=1&shift&goto Arg_Loop)
if /i "%1" == "skiprestore" (set __SkipRestore=1&shift&goto Arg_Loop)
if /i "%1" == "skipnuget" (set __SkipNuget=1&shift&goto Arg_Loop)
if /i "%1" == "sequential" (set __BuildSequential=1&shift&goto Arg_Loop)
if /i "%1" == "disableoss" (set __SignTypeReal="/p:SignType=real"&shift&goto Arg_Loop)
if /i "%1" == "priority" (set __TestPriority=%2&set __PassThroughArgs=%__PassThroughArgs% %2&shift&shift&goto Arg_Loop)
Expand Down Expand Up @@ -274,6 +278,10 @@ set __msbuildCommonArgs=/nologo /nodeReuse:false %__msbuildCleanBuildArgs% %__ms
if not defined __BuildSequential (
set __msbuildCommonArgs=%__msbuildCommonArgs% /maxcpucount
)
if defined __SkipRestore (
set __msbuildCommonArgs=%__msbuildCommonArgs% /p:RestoreDuringBuild=false
)


REM =========================================================================================
REM ===
Expand Down Expand Up @@ -471,6 +479,7 @@ if NOT errorlevel 0 (

:GenerateNuget
if /i "%__BuildArch%" =="arm64" goto :SkipNuget
if /i "%__SkipNuget%" == 1 goto :SkipNuget

set "__BuildLog=%__LogsDir%\Nuget_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
set "__BuildWrn=%__LogsDir%\Nuget_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn"
Expand Down Expand Up @@ -679,6 +688,8 @@ echo skipconfigure: skip CMake ^(default: CMake is run^)
echo skipmscorlib: skip building System.Private.CoreLib ^(default: System.Private.CoreLib is built^).
echo skipnative: skip building native components ^(default: native components are built^).
echo skiptests: skip building tests ^(default: tests are built^).
echo skiprestore: skip restoring packages ^(default: packages are restored during build^).
echo skipnuget: skip building nuget packages ^(default: packages are built^).
echo disableoss: Disable Open Source Signing for System.Private.CoreLib.
echo toolset_dir ^<dir^> : set the toolset directory -- Arm64 use only. Required for Arm64 builds.
echo.
Expand Down
8 changes: 7 additions & 1 deletion build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@

<Import Project="dir.traversal.targets" />

<!-- The following properties are in place to keep the behavior of build.cmd while we work on the dev workflow steps. -->
<PropertyGroup>
<!-- To disable the restoration of packages, set RestoreDuringBuild=false or pass /p:RestoreDuringBuild=false.-->
<RestoreDuringBuild Condition="'$(RestoreDuringBuild)'==''">true</RestoreDuringBuild>
</PropertyGroup>

<!-- Override clean from dir.traversal.targets and just remove the full BinDir -->
<Target Name="Clean">
<Delete Files="$(BinDir)mscorlib.*" />
<Delete Files="$(BinDir)System.Private.CoreLib.*" />
</Target>

<Target Name="RestoreNETCorePlatforms" AfterTargets="Build">
<Target Name="RestoreNETCorePlatforms" AfterTargets="Build" Condition="'$(RestoreDuringBuild)'=='true'">
<Exec Command="$(DnuRestoreCommand) &quot;$(SourceDir).nuget/init/project.json&quot; --source https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
</Target>

Expand Down
17 changes: 15 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ usage()
echo "skipnative - do not build native components."
echo "skipmscorlib - do not build mscorlib.dll."
echo "skiptests - skip the tests in the 'tests' subdirectory."
echo "skiprestore - skip restoring nuget packages."
echo "skipnuget - skip building nuget packages."
echo "disableoss - Disable Open Source Signing for mscorlib."
echo "skipgenerateversion - disable version generation even if MSBuild is supported."
echo "cmakeargs - user-settable additional arguments passed to CMake."
Expand Down Expand Up @@ -439,6 +441,8 @@ __MSBCleanBuildArgs=
__UseNinja=0
__ConfigureOnly=0
__SkipConfigure=0
__SkipRestore=""
__SkipNuget=0
__SkipCoreCLR=0
__SkipMSCorLib=0
__CleanBuild=0
Expand Down Expand Up @@ -574,6 +578,14 @@ while :; do
__IncludeTests=
;;

skiprestore)
__SkipRestore="/p:RestoreDuringBuild=true"
;;

skipnuget)
__SkipNuget=1
;;

disableoss)
__SignTypeReal="/p:SignType=real"
;;
Expand Down Expand Up @@ -688,8 +700,9 @@ build_coreclr
build_CoreLib

# Generate nuget packages

generate_NugetPackages
if [ $__SkipNuget != 1 ]; then
generate_NugetPackages
fi


# Build complete
Expand Down
24 changes: 24 additions & 0 deletions clean.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@if not defined __echo @echo off
setlocal EnableDelayedExpansion

echo Running clean.cmd

if /I [%1] == [/?] goto Usage
if /I [%1] == [/help] goto Usage

:: Set __ProjectDir to be the directory of this script
set "__ProjectDir=%~dp0"
:: remove trailing slash
if %__ProjectDir:~-1%==\ set "__ProjectDir=%__ProjectDir:~0,-1%"
set "__RootBinDir=%__ProjectDir%\bin"

if exist "%__RootBinDir%" rd /s /q "%__RootBinDir%"
if exist "%__ProjectDir%\Tools" rd /s /q "%__ProjectDir%\Tools"

exit /b 0

:Usage
echo.
echo Repository cleaning script.
echo No option parameters.
exit /b
12 changes: 12 additions & 0 deletions clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

# Obtain the location of the bash script to figure out where the root of the repo is.
__ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

echo Cleaning previous output for the selected configuration

rm -rf "$__ProjectRoot/bin"

rm -rf "$__ProjectRoot/Tools"

exit 0
35 changes: 35 additions & 0 deletions publish-packages.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@if "%_echo%" neq "on" echo off
setlocal EnableDelayedExpansion

set packagesLog=publish-packages.log
echo Running publish-packages.cmd %* > %packagesLog%

set options=/nologo /v:minimal /flp:v=detailed;Append;LogFile=%packagesLog%
set allargs=%*

if /I [%1] == [/?] goto Usage
if /I [%1] == [/help] goto Usage

REM ensure that msbuild is available
echo Running init-tools.cmd
call %~dp0init-tools.cmd

echo msbuild.exe %~dp0src\publish.proj !options! !allargs! >> %packagesLog%
call msbuild.exe %~dp0src\publish.proj !options! !allargs!
if NOT [%ERRORLEVEL%]==[0] (
echo ERROR: An error occurred while publishing packages, see %packagesLog% for more details.
exit /b 1
)

echo Done publishing packages.
exit /b

:Usage
echo.
echo Publishes the NuGet packages to the specified location.
echo For publishing to Azure the following properties are required.
echo /p:CloudDropAccountName="account name"
echo /p:CloudDropAccessToken="access token"
echo /p:__BuildType="Configuration Group"
echo /p:__BuildArch="Architecture"
exit /b
Loading

0 comments on commit 8568bf1

Please sign in to comment.