From e59562f2a26bf8f986950b18916596323507151d Mon Sep 17 00:00:00 2001 From: Doug Ilijev Date: Mon, 25 Apr 2016 15:39:25 -0700 Subject: [PATCH] Enable POGO builds in MBv2 daily config, automatic NuGet generation and publication. Add build composition script. --- Build/Microsoft.ChakraCore.nuspec | 16 ++++----- Build/scripts/compose_build.ps1 | 56 +++++++++++++++++++++++++++++ Build/scripts/init_build.ps1 | 16 +++++++-- Build/scripts/pgo/pogo_training.ps1 | 18 ++++++---- Build/scripts/pgo/post_pgi.cmd | 7 ++++ Build/scripts/pgo/post_pgo.cmd | 10 +++++- Build/scripts/pgo/pre_pgi.cmd | 5 +++ Build/scripts/pgo/pre_pgo.cmd | 7 ++++ 8 files changed, 117 insertions(+), 18 deletions(-) create mode 100644 Build/scripts/compose_build.ps1 diff --git a/Build/Microsoft.ChakraCore.nuspec b/Build/Microsoft.ChakraCore.nuspec index 84c13b388e9..117dca43c38 100644 --- a/Build/Microsoft.ChakraCore.nuspec +++ b/Build/Microsoft.ChakraCore.nuspec @@ -18,13 +18,13 @@ Chakra,ChakraCore - - - - - - - - + + + + + + + + diff --git a/Build/scripts/compose_build.ps1 b/Build/scripts/compose_build.ps1 new file mode 100644 index 00000000000..eb791d6a550 --- /dev/null +++ b/Build/scripts/compose_build.ps1 @@ -0,0 +1,56 @@ +#------------------------------------------------------------------------------------------------------- +# Copyright (C) Microsoft. All rights reserved. +# Licensed under the MIT license. See LICENSE.txt file in the project root for full license information. +#------------------------------------------------------------------------------------------------------- + +# Compose Build script +# +# Aggregate metadata about a build and produce a file with useful information about the build +# for tools to consume and get a quick overview of the status of a completed build. + +param ( + [Parameter(Mandatory=$True)] + [string]$rootPath +) + +# +# Clean up the sentinel which previously marked this build as incomplete. +# + +$buildIncompleteFile = Join-Path $rootPath "build.incomplete" +if (Test-Path $buildIncompleteFile) { + Remove-Item -Path $buildIncompleteFile -Force +} + +# +# Aggregate build metadata and produce build.json +# + +$outputJsonFile = Join-Path -Path $rootPath -ChildPath "build.json" +$buildInfo = New-Object System.Object + +$changeJson = (Get-ChildItem -Path $rootPath "change.json" -Recurse)[0] | % { $_.FullName } +$changeInfo = (Get-Content $changeJson) -join "`n" | ConvertFrom-Json + +# Determine the overall build status. Mark the build as "passed" until "failed" is encountered. +$overallBuildStatus = "passed" + +$files = Get-ChildItem -Path $rootPath "*.json" -Recurse ` + | ? { ($_.Name -ne "change.json") -and ($_.Name -ne "build.json") } ` + | % { $_.FullName } +$builds = New-Object System.Collections.ArrayList +foreach ($file in $files) { + $json = (Get-Content $file) -join "`n" | ConvertFrom-Json + $_ = $builds.Add($json) + + if ($json.status -eq "failed") { + $overallBuildStatus = "failed" + } +} + +$buildInfo | Add-Member -type NoteProperty -name status -value $overallBuildStatus +$buildInfo | Add-Member -type NoteProperty -name change -value $changeInfo +$buildInfo | Add-Member -type NoteProperty -name builds -value $builds + +$buildInfo | ConvertTo-Json | Write-Output +$buildInfo | ConvertTo-Json | Out-File $outputJsonFile -Encoding ascii diff --git a/Build/scripts/init_build.ps1 b/Build/scripts/init_build.ps1 index 62dd0cdca34..e69e018e1b2 100644 --- a/Build/scripts/init_build.ps1 +++ b/Build/scripts/init_build.ps1 @@ -56,7 +56,8 @@ $buildPushIdPart1 = [int]([math]::Floor($buildPushId / 65536)) $buildPushIdPart2 = [int]($buildPushId % 65536) $PushID = "{0}.{1}" -f $buildPushIdPart1.ToString("00000"), $buildPushIdPart2.ToString("00000") -$FullVersionString = "${Env:VERSION_MAJOR}.${Env:VERSION_MINOR}.${PushID}" +$VersionString = "${Env:VERSION_MAJOR}.${Env:VERSION_MINOR}.${PushID}" +$PreviewVersionString = "${VersionString}-preview" # # (end code borrowed from pre_build.ps1) @@ -105,6 +106,13 @@ if (-not (Test-Path $flavorBuildIncompleteFile)) { | Out-File $flavorBuildIncompleteFile -Encoding Ascii } +$PogoConfig = "False" +if (((${Env:BuildPlatform} -eq "x64") -or (${Env:BuildPlatform} -eq "x86")) ` + -and (${Env:BuildConfiguration} -eq "release")) +{ + $PogoConfig = "True" +} + # Write the $envconfig script. @" @@ -114,17 +122,21 @@ set YearAndMonth=${YearAndMonth} set BuildIdentifier=${BuildIdentifier} set PushID=${PushID} -set FullVersionString=${FullVersionString} +set VersionString=${VersionString} +set PreviewVersionString=${PreviewVersionString} set PushDate=${PushDate} set CommitTime=${CommitTime} set Username=${Username} set CommitHash=${CommitHash} set OutputPath=${OutputPath} +set FullOutputPath=${FullOutputPath} set FlavorName=${FlavorName} set BuildIncompleteFile=${buildIncompleteFile} set FlavorBuildIncompleteFile=${flavorBuildIncompleteFile} + +set PogoConfig=${PogoConfig} "@ ` | Out-File $envconfig -Encoding Ascii diff --git a/Build/scripts/pgo/pogo_training.ps1 b/Build/scripts/pgo/pogo_training.ps1 index 13d5bf38c9c..7402f331313 100644 --- a/Build/scripts/pgo/pogo_training.ps1 +++ b/Build/scripts/pgo/pogo_training.ps1 @@ -15,10 +15,6 @@ param ( [string[]]$scenarios = @(), - [string]$vcinstallroot = ${env:ProgramFiles(x86)}, - [string]$vcbinpath = "Microsoft Visual Studio 14.0\VC\bin", - [string]$dllname = "pgort140.dll", - [Parameter(Mandatory=$True)] [string]$binary, @@ -27,9 +23,18 @@ param ( # force callers to specify this in case of future use [Parameter(Mandatory=$True)] - [string]$flavor = "" + [string]$flavor, + + [string]$vcinstallroot = ${env:ProgramFiles(x86)}, + [string]$vcbinpath = "Microsoft Visual Studio 14.0\VC\bin", + [string]$dllname = "pgort140.dll" ) +if (${Env:PogoConfig} -eq "False") { + Write-Host "---- Not a Pogo Config. Skipping step." + return 0 +} + $binpath = Split-Path -Path $binary -Parent $pgoOutDll = Join-Path $binpath $dllname; if (-not (Test-Path ($pgoOutDll))) { @@ -49,8 +54,7 @@ for ($i = 0; $i -lt $scenarios.Length; $i = $i + 1) { if (Test-Path $path -PathType Container) { # *.js files in directories $items = Get-ChildItem -Path $path -Filter "*.js" | % {join-path $path $_ } - } - else { + } else { $items = @($path) } diff --git a/Build/scripts/pgo/post_pgi.cmd b/Build/scripts/pgo/post_pgi.cmd index ca318a82c88..e525ae66631 100644 --- a/Build/scripts/pgo/post_pgi.cmd +++ b/Build/scripts/pgo/post_pgi.cmd @@ -12,6 +12,13 @@ :: - build (using PGO profile) :: - post_pgo.cmd +@echo off + +if "%PogoConfig%"=="False" ( + echo ---- Not a Pogo Config. Skipping step. + exit /b 0 +) + set _LINK_= set POGO_TYPE= diff --git a/Build/scripts/pgo/post_pgo.cmd b/Build/scripts/pgo/post_pgo.cmd index b31e9af9449..f0a1dc7db25 100644 --- a/Build/scripts/pgo/post_pgo.cmd +++ b/Build/scripts/pgo/post_pgo.cmd @@ -12,6 +12,13 @@ :: - build (using PGO profile) :: * post_pgo.cmd +@echo off + +if "%PogoConfig%"=="False" ( + echo ---- Not a Pogo Config. Skipping step. + exit /b 0 +) + set binpath_pgo=%1 if "%binpath_pgo%"=="" ( @@ -19,7 +26,8 @@ if "%binpath_pgo%"=="" ( ) set POGO_TYPE= - REM Clean binaries we no longer need + +REM Clean binaries we no longer need if exist %binpath_pgo%\*.pgc ( del %binpath_pgo%\*.pgc ) if exist %binpath_pgo%\*.pgd ( del %binpath_pgo%\*.pgd ) if exist %binpath_pgo%\pgort* ( del %binpath_pgo%\pgort* ) diff --git a/Build/scripts/pgo/pre_pgi.cmd b/Build/scripts/pgo/pre_pgi.cmd index e9ac317906d..b68e83e6fc2 100644 --- a/Build/scripts/pgo/pre_pgi.cmd +++ b/Build/scripts/pgo/pre_pgi.cmd @@ -14,6 +14,11 @@ @echo off +if "%PogoConfig%"=="False" ( + echo ---- Not a Pogo Config. Skipping step. + exit /b 0 +) + set arch_pgi=%1 set flavor_pgi=%2 set binpath_pgi=%3 diff --git a/Build/scripts/pgo/pre_pgo.cmd b/Build/scripts/pgo/pre_pgo.cmd index 768316d10b1..4887e960467 100644 --- a/Build/scripts/pgo/pre_pgo.cmd +++ b/Build/scripts/pgo/pre_pgo.cmd @@ -12,6 +12,13 @@ :: - build (using PGO profile) :: - post_pgo.cmd +@echo off + +if "%PogoConfig%"=="False" ( + echo ---- Not a Pogo Config. Skipping step. + exit /b 0 +) + REM Optimize build with PGO data set POGO_TYPE=PGO