2
0
Эх сурвалжийг харах

MicroBuild v2: changes to project files and build scripts to enable building in MBv2, and PGO builds of ChakraCore; add nuspec for ChakraCore.

Doug Ilijev 10 жил өмнө
parent
commit
2f13802dcd
41 өөрчлөгдсөн 600 нэмэгдсэн , 40 устгасан
  1. 3 0
      .gitignore
  2. 1 1
      Build/Chakra.Build.ProjectConfiguration.props
  3. 9 1
      Build/Common.Build.Default.props
  4. 12 0
      Build/MicroBuildv2.Build.ProjectConfiguration.props
  5. 30 0
      Build/Microsoft.ChakraCore.nuspec
  6. 5 0
      Build/packages/MicroBuild.Core.0.2.0/build/MicroBuild.Core.props
  7. 5 0
      Build/packages/MicroBuild.Core.0.2.0/build/MicroBuild.Core.targets
  8. 29 0
      Build/packages/MicroBuild.Core.0.2.0/build/MicroBuild.Plugin.props
  9. 39 0
      Build/scripts/finalize_build.ps1
  10. 153 0
      Build/scripts/init_build.ps1
  11. 45 0
      Build/scripts/pogo_training.ps1
  12. 7 7
      Build/scripts/post_build.ps1
  13. 15 0
      Build/scripts/post_pgi.cmd
  14. 31 0
      Build/scripts/post_pgo.cmd
  15. 41 17
      Build/scripts/pre_build.ps1
  16. 50 0
      Build/scripts/pre_pgi.cmd
  17. 15 0
      Build/scripts/pre_pgo.cmd
  18. 3 6
      Build/scripts/pre_post_util.ps1
  19. 4 8
      Build/scripts/util.ps1
  20. 19 0
      bin/ChakraCore/ChakraCore.vcxproj
  21. 4 0
      bin/GCStress/packages.config
  22. 4 0
      bin/ch/packages.config
  23. 4 0
      bin/rl/packages.config
  24. 4 0
      lib/Backend/packages.config
  25. 4 0
      lib/Common/Codex/packages.config
  26. 4 0
      lib/Common/Common/packages.config
  27. 4 0
      lib/Common/Core/packages.config
  28. 4 0
      lib/Common/DataStructures/packages.config
  29. 4 0
      lib/Common/Exceptions/packages.config
  30. 4 0
      lib/Common/Memory/packages.config
  31. 4 0
      lib/Common/Util/packages.config
  32. 4 0
      lib/Jsrt/Core/packages.config
  33. 4 0
      lib/Jsrt/packages.config
  34. 4 0
      lib/Parser/packages.config
  35. 4 0
      lib/Runtime/Base/packages.config
  36. 4 0
      lib/Runtime/ByteCode/packages.config
  37. 4 0
      lib/Runtime/Debug/packages.config
  38. 4 0
      lib/Runtime/Language/packages.config
  39. 4 0
      lib/Runtime/Library/packages.config
  40. 4 0
      lib/Runtime/Math/packages.config
  41. 4 0
      lib/Runtime/Types/packages.config

+ 3 - 0
.gitignore

@@ -15,6 +15,8 @@ build_*.err
 buildchk.*
 buildfre.*
 Build/swum-cache.txt
+ComputedEnvironment.cmd
+packages/
 *.tlog/
 .*.swp
 sd.ini
@@ -28,3 +30,4 @@ profile.dpl.*
 Build/Chakra.Core.VC.opendb
 test/benchmarks/*.txt
 test/benchmarks/*.dpl
+*.nupkg

+ 1 - 1
Build/Chakra.Build.ProjectConfiguration.props

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <Import Project="Common.Build.ProjectConfiguration.props" />
+  <Import Project="MicroBuildv2.Build.ProjectConfiguration.props" />
 </Project>
-

+ 9 - 1
Build/Common.Build.Default.props

@@ -40,7 +40,15 @@
     <CharacterSet>Unicode</CharacterSet>
   </PropertyGroup>
 
-  <!-- Alternate platform names-->
+  <!-- Change configuration name to output to a different folder -->
+  <!-- POGO instrumentation -->
+  <PropertyGroup>
+    <IsPogoBuild />
+    <IsPogoBuild Condition="('$(POGO_TYPE)'=='PGO' OR '$(POGO_TYPE)'=='PGI')">true</IsPogoBuild>
+    <OutDirName Condition="'$(IsPogoBuild)'=='true'">$(Configuration.ToLower())_pogo</OutDirName>
+  </PropertyGroup>
+
+  <!-- Alternate platform names -->
   <PropertyGroup>
     <!-- PlatformPathName is used in OutDir/IntDir name-->
     <PlatformPathName>$(Platform)</PlatformPathName>

+ 12 - 0
Build/MicroBuildv2.Build.ProjectConfiguration.props

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(SolutionDir)packages\MicroBuild.Core.0.2.0\build\MicroBuild.Core.props" Condition="Exists('$(SolutionDir)packages\MicroBuild.Core.0.2.0\build\MicroBuild.Core.props')" />
+  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
+    <PropertyGroup>
+      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
+    </PropertyGroup>
+    <Error Condition="!Exists('$(SolutionDir)packages\MicroBuild.Core.0.2.0\build\MicroBuild.Core.props')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)packages\MicroBuild.Core.0.2.0\build\MicroBuild.Core.props'))" />
+    <Error Condition="!Exists('$(SolutionDir)packages\MicroBuild.Core.0.2.0\build\MicroBuild.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)packages\MicroBuild.Core.0.2.0\build\MicroBuild.Core.targets'))" />
+  </Target>
+  <Import Project="$(SolutionDir)packages\MicroBuild.Core.0.2.0\build\MicroBuild.Core.targets" Condition="Exists('$(SolutionDir)packages\MicroBuild.Core.0.2.0\build\MicroBuild.Core.targets')" />
+</Project>

+ 30 - 0
Build/Microsoft.ChakraCore.nuspec

@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<package xmlns="http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd">
+    <metadata>
+        <id>Microsoft.ChakraCore</id>
+        <version>1.2</version>
+        <authors>Chakra Team</authors>
+        <owners>Chakra Team</owners>
+        <licenseUrl>https://github.com/Microsoft/ChakraCore/blob/master/LICENSE.txt</licenseUrl>
+        <projectUrl>https://github.com/Microsoft/ChakraCore</projectUrl>
+        <requireLicenseAcceptance>false</requireLicenseAcceptance>
+        <developmentDependency>true</developmentDependency>
+        <description>ChakraCore is the core part of the Chakra Javascript engine that powers Microsoft Edge.</description>
+        <!--
+        <releaseNotes>**** TODO: need link</releaseNotes>
+        -->
+        <copyright>Copyright (C) 2016 Microsoft</copyright>
+        <language>en-US</language>
+        <tags>Chakra,ChakraCore</tags>
+    </metadata>
+    <files>
+        <file src="VcBuild\bin\x86_release\ChakraCore.dll" target="x86\ChakraCore.dll" />
+        <file src="VcBuild\bin\x86_release\ChakraCore.pdb" target="x86\ChakraCore.pdb" />
+        <file src="VcBuild\bin\x86_release\ch.exe" target="x86\ch.exe" />
+        <file src="VcBuild\bin\x86_release\ch.pdb" target="x86\ch.pdb" />
+        <file src="VcBuild\bin\x64_release\ChakraCore.dll" target="x64\ChakraCore.dll" />
+        <file src="VcBuild\bin\x64_release\ChakraCore.pdb" target="x64\ChakraCore.pdb" />
+        <file src="VcBuild\bin\x64_release\ch.exe" target="x64\ch.exe" />
+        <file src="VcBuild\bin\x64_release\ch.pdb" target="x64\ch.pdb" />
+    </files>
+</package>

+ 5 - 0
Build/packages/MicroBuild.Core.0.2.0/build/MicroBuild.Core.props

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+    <Import Project="$(MSBuildThisFileDirectory)\MicroBuild.Plugin.props" Condition="'$(MicroBuildSentinelFile)' == ''" />
+    <Import Project="$(MicroBuildPluginDirectory)\MicroBuild.Plugins.*\**\build\MicroBuild.Plugins.*.props" Condition="'$(MicroBuildPluginDirectory)' != ''" />
+</Project>

+ 5 - 0
Build/packages/MicroBuild.Core.0.2.0/build/MicroBuild.Core.targets

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+    <Import Project="$(MSBuildThisFileDirectory)\MicroBuild.Plugin.props" Condition="'$(MicroBuildSentinelFile)' == ''" />
+    <Import Project="$(MicroBuildPluginDirectory)\MicroBuild.Plugins.*\**\build\MicroBuild.Plugins.*.targets" Condition="'$(MicroBuildPluginDirectory)' != ''" />
+</Project>

+ 29 - 0
Build/packages/MicroBuild.Core.0.2.0/build/MicroBuild.Plugin.props

@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+    <PropertyGroup>
+        <!-- MicroBuild plugins can be installed in any parent directory up the tree from the project that is building.
+        The use of a sentinel file (which will be installed automatically due to package dependencies from any plugin)
+        will help us locate the plugin packages directory while being constrained to using MSBuild's intrinsic functions,
+        since we want the imports to occur at evaluation time instead of when a specific target is executing.
+
+        Note: All MicroBuild plugins must be installed to the same directory (under the same packages folder). If plugins
+        are installed to different directories, the plugins which are in the directories closest to the executing project
+        up the hierarchy will be discovered, and the ones higher up the tree will be ignored.
+         -->
+        <MicroBuildSentinelFile>packages\MicroBuild.Core.Sentinel.1.0.0\sentinel.txt</MicroBuildSentinelFile>
+        <MicroBuildSentinelFileV3>MicroBuild.Core.Sentinel\1.0.0\sentinel.txt</MicroBuildSentinelFileV3>
+
+        <MicroBuildPluginDirectory>$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), $(MicroBuildSentinelFile)))</MicroBuildPluginDirectory>
+        <MicroBuildPluginDirectory Condition="'$(MicroBuildPluginDirectory)' != ''">$(MicroBuildPluginDirectory)\packages</MicroBuildPluginDirectory>
+
+        <!-- Some people might want to put the plugin packages directly in their Nuget v3 global cache. This doesn't happen by default,
+        but we will allow for it here. We don't support nuget.config's globalPackagesFolder setting here because we don't have a good
+        way to load/parse that file with MSBuild intrinsics. We can check the other two mechanisms though, which are the %NUGET_PACKAGES%
+        environment variable and %USERPROFILE%\.nuget\packages -->
+        <MicroBuildPluginDirectory Condition="'$(MicroBuildPluginDirectory)' == '' and '$(NUGET_PACKAGES)' != '' and Exists('$(NUGET_PACKAGES)\$(MicroBuildSentinelFileV3)')">$(NUGET_PACKAGES)</MicroBuildPluginDirectory>
+        <MicroBuildPluginDirectory Condition="'$(MicroBuildPluginDirectory)' == '' and '$(USERPROFILE)' != '' and Exists('$(USERPROFILE)\.nuget\packages\$(MicroBuildSentinelFileV3)')">$(USERPROFILE)\.nuget\packages</MicroBuildPluginDirectory>
+
+        <!-- Allow for the ability to override the plugin directory, for example in automated builds -->
+        <MicroBuildPluginDirectory Condition="'$(MicroBuildOverridePluginDirectory)' != ''">$(MicroBuildOverridePluginDirectory)</MicroBuildPluginDirectory>
+    </PropertyGroup>
+</Project>

+ 39 - 0
Build/scripts/finalize_build.ps1

@@ -0,0 +1,39 @@
+#-------------------------------------------------------------------------------------------------------
+# Copyright (C) Microsoft. All rights reserved.
+# Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
+#-------------------------------------------------------------------------------------------------------
+
+#
+# Clean up the sentinel which previously marked the build as incomplete.
+#
+
+Remove-Item -Path ${Env:FlavorBuildIncompleteFile} -Force
+
+#
+# Create build status JSON file for this flavor.
+#
+
+$FullOutputPath = Join-Path $Env:DROP_ROOT $Env:OutputPath
+$BuildLogsPath = Join-Path $FullOutputPath "buildlogs"
+$buildFlavorErrFile = Join-Path $BuildLogsPath "build_${Env:BuildPlatform}${Env:BuildConfiguration}.err"
+
+# If build_{}{}.err contains any text then there were build errors and we record that the build failed.
+$BuildFailed = $false
+if (Test-Path $buildFlavorErrFile) {
+    $BuildFailed = (Get-Item $buildFlavorErrFile).length -gt 0
+}
+
+$status = "passed"
+if ($BuildFailed) {
+    $status = "failed"
+}
+
+$buildFlavorJsonFile = Join-Path $FullOutputPath "${Env:FlavorName}.json"
+$buildFlavorJson = New-Object System.Object
+
+$buildFlavorJson | Add-Member -type NoteProperty -name status -value $status
+$buildFlavorJson | Add-Member -type NoteProperty -name arch -value $Env:BuildPlatform
+$buildFlavorJson | Add-Member -type NoteProperty -name flavor -value $Env:BuildConfiguration
+
+$buildFlavorJson | ConvertTo-Json | Write-Output
+$buildFlavorJson | ConvertTo-Json | Out-File $buildFlavorJsonFile -Encoding ascii

+ 153 - 0
Build/scripts/init_build.ps1

@@ -0,0 +1,153 @@
+#-------------------------------------------------------------------------------------------------------
+# Copyright (C) Microsoft. All rights reserved.
+# Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
+#-------------------------------------------------------------------------------------------------------
+
+param (
+    [string]$envconfig = "ComputedEnvironment.cmd",
+
+    [Parameter(Mandatory=$True)]
+    [string]$oauth
+)
+
+$branch = $env:BUILD_SOURCEBRANCH
+if (-not $branch) {
+    $branch = $(git rev-parse --symbolic-full-name HEAD)
+}
+
+$BranchName = $branch.split('/',3)[2]
+$BranchPath = $BranchName.replace('/','\')
+$CommitHash = ${env:BUILD_SOURCEVERSION}
+if (-not $CommitHash) {
+    $CommitHash = $(git rev-parse HEAD)
+}
+
+$Username = $(git log $CommitHash -1 --pretty=%ae).split('@')[0]
+$CommitDateTime = [DateTime]$(git log $CommitHash -1 --pretty=%aD)
+$CommitTime = Get-Date $CommitDateTime -Format yyMMdd.HHmm
+
+#
+# (borrowed from pre_build.ps1)
+# Get PushID and PushDate from VSO
+# TODO (doilij) refactor this into a method in a util script.
+#
+
+# Get the git remote path and construct the rest API URI
+$remote = (iex "git remote -v")[0].split()[1].replace("_git", "_apis/git/repositories");
+$remote = $remote.replace("mshttps", "https")
+
+# Get the pushId and push date time to use that for build number and build date time
+$uri = ("{0}/commits/{1}?api-version=1.0" -f $remote, $commitHash)
+$oauthToken = Get-Content $oauth
+$header = @{Authorization=("Basic {0}" -f $oauthToken) }
+$info = Invoke-RestMethod -Headers $header -Uri $uri -Method GET
+
+$BuildPushDate = [datetime]$info.push.date
+$PushDate = Get-Date $BuildPushDate -Format yyMMdd.HHmm
+$buildPushId = $info.push.pushId
+$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}"
+
+#
+# (end code borrowed from pre_build.ps1)
+#
+
+# unless it is a build branch, subdivide the output directory by month
+if ($BranchPath.StartsWith("build")) {
+    $YearAndMonth = ""
+} else {
+    $YearAndMonth = Get-Date $BuildPushDate -Format yyMM
+}
+
+$YearAndMonthSeparator = ""
+if ($YearAndMonth) {
+    $YearAndMonthSeparator = "\"
+}
+
+$BuildIdentifier = "${PushID}_${PushDate}_${Username}_${CommitHash}"
+$OutputPath = "${BranchPath}\${YearAndMonth}${YearAndMonthSeparator}${BuildIdentifier}"
+$FlavorName = "${Env:BuildPlatform}_${Env:BuildConfiguration}"
+
+# Create a sentinel file for each build flavor and for the overall build
+# to track whether the build is complete.
+# * build.incomplete                   # will be deleted when the release task completes
+# * ${arch}_${flavor}.incomplete       # will be deleted when the build of this flavor completes
+
+$buildIncompleteFileContentsString = @"
+{0} in progress.
+The contents of this directory should not be relied on until the build completes.
+"@
+
+$FullOutputPath = Join-Path ${env:DROP_ROOT} ${OutputPath}
+New-Item -ItemType Directory -Force -Path $FullOutputPath
+New-Item -ItemType Directory -Force -Path (Join-Path $Env:BUILD_BINARIESDIRECTORY "buildlogs")
+New-Item -ItemType Directory -Force -Path (Join-Path $Env:BUILD_BINARIESDIRECTORY "logs")
+
+$buildIncompleteFile = Join-Path $FullOutputPath "build.incomplete"
+$flavorBuildIncompleteFile = Join-Path $FullOutputPath "${FlavorName}.incomplete"
+
+if (-not (Test-Path $buildIncompleteFile)) {
+    ($buildIncompleteFileContentsString -f "Build") `
+        | Out-File $buildIncompleteFile -Encoding Ascii
+}
+if (-not (Test-Path $flavorBuildIncompleteFile)) {
+    ($buildIncompleteFileContentsString -f "Build of ${FlavorName}") `
+        | Out-File $flavorBuildIncompleteFile -Encoding Ascii
+}
+
+# Write the $envconfig script.
+
+@"
+set BranchName=${BranchName}
+set BranchPath=${BranchPath}
+set YearAndMonth=${YearAndMonth}
+set BuildIdentifier=${BuildIdentifier}
+
+set PushID=${PushID}
+set FullVersionString=${FullVersionString}
+set PushDate=${PushDate}
+set CommitTime=${CommitTime}
+set Username=${Username}
+set CommitHash=${CommitHash}
+
+set OutputPath=${OutputPath}
+set FlavorName=${FlavorName}
+
+set BuildIncompleteFile=${buildIncompleteFile}
+set FlavorBuildIncompleteFile=${flavorBuildIncompleteFile}
+"@ `
+    | Out-File $envconfig -Encoding Ascii
+
+# Use the MBv2 environment to construct a MBv1 VSO environment
+# for the sake of reusing the pre-build and post-build scripts as they are.
+
+@"
+set TF_BUILD_SOURCEGETVERSION=LG:${branch}:${CommitHash}
+set TF_BUILD_DROPLOCATION=${Env:BUILD_BINARIESDIRECTORY}
+
+set TF_BUILD_BUILDDEFINITIONNAME=${Env:BUILD_DEFINITIONNAME}
+set TF_BUILD_BUILDNUMBER=${Env:BUILD_BUILDNUMBER}
+set TF_BUILD_BUILDURI=${Env:BUILD_BUILDURI}
+"@ `
+    | Out-File $envconfig -Encoding Ascii -Append
+
+# Set VSO variables that can be consumed by other VSO tasks.
+# Uses command syntax documented here:
+# https://github.com/Microsoft/vso-agent-tasks/blob/master/docs/authoring/commands.md
+# Lines written to stdout that match this pattern are interpreted with this command syntax.
+
+Write-Output "Setting VSO variable VSO_OutputPath = ${OutputPath}"
+Write-Output "##vso[task.setvariable variable=VSO_OutputPath;]${OutputPath}"
+
+Write-Output "Setting VSO variable VSO_FullVersionString = ${FullVersionString}"
+Write-Output "##vso[task.setvariable variable=VSO_FullVersionString;]${FullVersionString}"
+
+# TODO (doilij): move this up and assign values
+
+# Inferable Environment (if not specified, inferred by pre_post_util.ps1):
+#   $Env:TF_BUILD_SOURCESDIRECTORY  (a.k.a. $srcpath)
+#   $Env:TF_BUILD_BUILDDIRECTORY    (a.k.a. $objpath)
+#   $Env:TF_BUILD_BINARIESDIRECTORY (a.k.a. $binpath)

+ 45 - 0
Build/scripts/pogo_training.ps1

@@ -0,0 +1,45 @@
+param (
+    [string[]]$scenarios = @(),
+
+    [Parameter(Mandatory=$True)]
+    [string]$binary,
+
+    [Parameter(Mandatory=$True)]
+    [string]$arch,
+
+    # force callers to specify this in case of future use
+    [Parameter(Mandatory=$True)]
+    [string]$flavor = ""
+)
+
+$binpath = Split-Path -Path $binary -Parent
+$pgodll = Join-Path $binpath "pgort140.dll";
+if (-not (Test-Path ($pgodll))) {
+    $vcarchpath = ""
+    if ($arch -eq "x64") {
+        $vcarchpath = "amd64"
+    } elseif ($arch -eq "arm") {
+        $vcarchpath = "arm"
+    }
+    $pgoSrcDll = Join-Path ${env:ProgramFiles(x86)} (Join-Path (Join-Path "Microsoft Visual Studio 14.0\VC\bin" $vcarchpath) "pgort140.dll")
+    Copy-Item $pgoSrcDll $pgodll
+}
+
+for ($i=0; $i -lt $scenarios.Length; $i = $i+1) {
+    $path = $scenarios[$i]
+
+    $items = @()
+    if (Test-Path $path -PathType Container) {
+        # *.js files in directories
+        $items = Get-ChildItem -Path $path -Filter "*.js" | % {join-path $path $_ }
+    }
+    else {
+        $items = @($path)
+    }
+
+    for ($j=0; $j -lt $items.Length; $j = $j+1) {
+        $testFile = $items[$j]
+        Write-Host "$binary $testFile"
+        iex "$binary $testFile"
+    }
+}

+ 7 - 7
Build/scripts/post_build.ps1

@@ -5,7 +5,7 @@
 
 param (
     [ValidateSet("x86", "x64", "arm", "*")]
-    [string]$arch="*",
+    [string]$arch = "*",
 
     [ValidateSet("debug", "release", "test", "codecoverage", "*")]
     [string]$flavor = "*",
@@ -14,14 +14,16 @@ param (
     [string]$binpath = "",
     [string]$objpath = "",
 
-    [string]$srcsrvcmdpath = "Build\script\srcsrv.bat",
-    [string]$bvtcmdpath="",
+    [Parameter(Mandatory=$True)]
+    [string]$srcsrvcmdpath,
+
+    [string]$bvtcmdpath = "",
     [string]$repo = "core",
     [string]$logFile = "",
 
     # comma separated list of [arch,flavor,arch2,flavor2,...] to build
     [string[]]$pogo = @(),
-    [string]$pogoscript="",
+    [string]$pogoscript = "",
 
     [switch]$noaction
 )
@@ -47,13 +49,12 @@ if ($arch -eq "*") {
     . "$PSScriptRoot\pre_post_util.ps1"
 
     if (($logFile -eq "") -and (Test-Path Env:\TF_BUILD_BINARIESDIRECTORY)) {
-        $logFile = "$Env:TF_BUILD_BINARIESDIRECTORY\logs\post_build_$arch_$flavor.log"
+        $logFile = "${Env:TF_BUILD_BINARIESDIRECTORY}\logs\post_build_${arch}_${flavor}.log"
         if (Test-Path -Path $logFile) {
             Remove-Item $logFile -Force
         }
     }
 
-
     WriteMessage "======================================================================================"
     WriteMessage "Post build script for $arch $flavor";
     WriteMessage "======================================================================================"
@@ -95,4 +96,3 @@ if ($arch -eq "*") {
 }
 
 exit $global:exitcode
-

+ 15 - 0
Build/scripts/post_pgi.cmd

@@ -0,0 +1,15 @@
+::-------------------------------------------------------------------------------------------------------
+:: Copyright (C) Microsoft. All rights reserved.
+:: Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
+::-------------------------------------------------------------------------------------------------------
+
+:: PGO Build Workflow:
+:: - init_pgi.cmd
+:: - build (with PGI instrumentation enabled)
+:: * init_pgo.cmd
+:: - build (using PGO profile)
+
+set _LINK_=
+set POGO_TYPE=
+
+goto:eof

+ 31 - 0
Build/scripts/post_pgo.cmd

@@ -0,0 +1,31 @@
+::-------------------------------------------------------------------------------------------------------
+:: Copyright (C) Microsoft. All rights reserved.
+:: Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
+::-------------------------------------------------------------------------------------------------------
+
+:: PGO Build Workflow:
+:: - init_pgi.cmd
+:: - build (with PGI instrumentation enabled)
+:: * init_pgo.cmd
+:: - build (using PGO profile)
+set binpath_pgo=%1
+
+if "%binpath_pgo%"=="" (
+  goto:usage
+)
+
+set POGO_TYPE=
+ 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* )
+
+goto:eof
+
+:usage
+  echo Invalid/missing arguments
+  echo.
+  echo Usage: post_pgo.cmd ^<binary_path^>
+  echo   - binary_path: output path of your binaries
+
+exit /b 1

+ 41 - 17
Build/scripts/pre_build.ps1

@@ -13,20 +13,25 @@
 # output to make it easy to inspect builds.
 #
 # Require Environment:
-#   $TF_BUILD_SOURCEGETVERSION
-#   $TF_BUILD_DROPLOCATION
+#   $Env:TF_BUILD_SOURCEGETVERSION
+#   $Env:TF_BUILD_DROPLOCATION
 #
-# Inferable Environment:
-#   $TF_BUILD_SOURCESDIRECTORY
-#   $TF_BUILD_BUILDBINARIESDIRECTORY
-#   $TF_BUILD_BUILDDIRECTORY
+# Inferable Environment (if not specified, inferred by pre_post_util.ps1):
+#   $Env:TF_BUILD_SOURCESDIRECTORY  (a.k.a. $srcpath)
+#   $Env:TF_BUILD_BUILDDIRECTORY    (a.k.a. $objpath)
+#   $Env:TF_BUILD_BINARIESDIRECTORY (a.k.a. $binpath)
 #
 # Optional information:
-#   $TF_BUILD_BUILDDEFINITIONNAME
-#   $TF_BUILD_BUILDNUMBER
-#   $TF_BUILD_BUILDURI
+#   $Env:TF_BUILD_BUILDDEFINITIONNAME
+#   $Env:TF_BUILD_BUILDNUMBER
+#   $Env:TF_BUILD_BUILDURI
 
 param (
+    [ValidateSet("x86", "x64", "arm", "")]
+    [string]$arch = "",
+    [ValidateSet("debug", "release", "test", "codecoverage", "")]
+    [string]$flavor = "",
+
     [string]$srcpath = "",
     [string]$binpath = "",
     [string]$objpath = "",
@@ -67,7 +72,6 @@ if (Test-Path Env:\TF_BUILD_SOURCEGETVERSION)
     Write-Output "TF_BUILD_BUILDURI = $Env:TF_BUILD_BUILDURI" | Out-File $outputFile -Append
     Write-Output "" | Out-File $outputFile -Append
 
-
     # Get the git remote path and construct the rest API URI
     $remote = (iex "$gitExe remote -v")[0].split()[1].replace("_git", "_apis/git/repositories");
     $remote = $remote.replace("mshttps", "https");
@@ -79,21 +83,41 @@ if (Test-Path Env:\TF_BUILD_SOURCEGETVERSION)
     $info = Invoke-RestMethod -Headers $header -Uri $uri -Method GET
 
     $buildDate = ([datetime]$info.push.date).toString("yyMMdd-HHmm")
-    $buildPushId = $info.push.pushId;
-    $buildPushIdPart1 = [int]($buildPushId / 65536);
-    $buildPushIdPart2 = [int]($buildPushId % 65536);
-    Write-Output ("PushId = $buildPushId ({0}.{1})" -f $buildPushIdPart1.ToString("00000"), $buildPushIdPart2.ToString("00000")) | Out-File $outputFile -Append
-    Write-Output "PushDate = $buildDate" | Out-File $outputFile -Append
-    Write-Output "" | Out-File $outputFile -Append
+    $buildPushId = $info.push.pushId
+    $buildPushIdPart1 = [int]([math]::Floor($buildPushId / 65536))
+    $buildPushIdPart2 = [int]($buildPushId % 65536)
+    $buildPushIdString = "{0}.{1}" -f $buildPushIdPart1.ToString("00000"), $buildPushIdPart2.ToString("00000")
+
+    Write-Output "PushId = $buildPushId $buildPushIdString" | Out-File $outputFile -Append
+    Write-Output "PushDate = $buildDate"                    | Out-File $outputFile -Append
+    Write-Output ""                                         | Out-File $outputFile -Append
 
     # commit message
     $command = "$gitExe log -1 --name-status -p $commitHash"
     iex $command | Out-File $outputFile -Append
     Pop-Location
 
-
     # commit hash
     $buildCommit = ($Env:TF_BUILD_SOURCEGETVERSION).SubString(14);
+    $commitHash = $buildCommit.Split(":")[1]
+
+    $outputJsonFile = Join-Path -Path $outputDir -ChildPath "change.json"
+    $changeJson = New-Object System.Object
+
+    $changeJson | Add-Member -type NoteProperty -name BuildDefinitionName -value $Env:TF_BUILD_BUILDDEFINITIONNAME
+    $changeJson | Add-Member -type NoteProperty -name BuildNumber -value $Env:TF_BUILD_BUILDNUMBER
+    $changeJson | Add-Member -type NoteProperty -name BuildDate -value $buildDate
+    $changeJson | Add-Member -type NoteProperty -name BuildUri -value $Env:TF_BUILD_BUILDURI
+    $changeJson | Add-Member -type NoteProperty -name Branch -value $Env:BranchName
+    $changeJson | Add-Member -type NoteProperty -name CommitHash -value $commitHash
+    $changeJson | Add-Member -type NoteProperty -name PushId -value $buildPushId
+    $changeJson | Add-Member -type NoteProperty -name PushIdPart1 -value $buildPushIdPart1
+    $changeJson | Add-Member -type NoteProperty -name PushIdPart2 -value $buildPushIdPart2
+    $changeJson | Add-Member -type NoteProperty -name PushIdString -value $buildPushIdString
+    $changeJson | Add-Member -type NoteProperty -name SourceGetVersion -value $Env:TF_BUILD_SOURCEGETVERSION
+
+    $changeJson | ConvertTo-Json | Write-Output
+    $changeJson | ConvertTo-Json | Out-File $outputJsonFile -Encoding ascii
 
     $buildInfoOutputDir = $objpath
     if (-not(Test-Path -Path $buildInfoOutputDir)) {

+ 50 - 0
Build/scripts/pre_pgi.cmd

@@ -0,0 +1,50 @@
+::-------------------------------------------------------------------------------------------------------
+:: Copyright (C) Microsoft. All rights reserved.
+:: Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
+::-------------------------------------------------------------------------------------------------------
+
+:: PGO Build Workflow:
+:: * init_pgi.cmd
+:: - build (with PGI instrumentation enabled)
+:: - init_pgo.cmd
+:: - build (using PGO profile)
+@echo off
+
+set arch_pgi=%1
+set flavor_pgi=%2
+set binpath_pgi=%3
+set builderror=
+
+if "%arch_pgi%"=="" (
+  goto:usage
+)
+if "%flavor_pgi%"=="" (
+  goto:usage
+)
+if "%binpath_pgi%"=="" (
+  goto:usage
+)
+
+if not exist %binpath_pgi% (
+  md %binpath_pgi%
+) else (
+  if exist %binpath_pgi%\*.pgc ( del %binpath_pgi%\*.pgc )
+)
+
+REM Build with pgo instrumentation
+set POGO_TYPE=PGI
+
+REM Temporary fix around pgo bug, todo:: check if still necessary once toolset is updated
+set _LINK_=/cgthreads:1
+
+goto:eof
+
+:usage
+  echo Invalid/missing arguments
+  echo.
+  echo Usage: pre_pgi.cmd ^<arch^> ^<flavor^> ^<binary_path^>
+  echo   - arch  : Architecture you want to build pogo
+  echo   - flavor: flavor you want to build pogo
+  echo   - binary_path: output path of your binaries
+
+exit /b 1

+ 15 - 0
Build/scripts/pre_pgo.cmd

@@ -0,0 +1,15 @@
+::-------------------------------------------------------------------------------------------------------
+:: Copyright (C) Microsoft. All rights reserved.
+:: Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
+::-------------------------------------------------------------------------------------------------------
+
+:: PGO Build Workflow:
+:: - init_pgi.cmd
+:: - build (with PGI instrumentation enabled)
+:: * init_pgo.cmd
+:: - build (using PGO profile)
+
+ REM Optimize build with pgo data
+set POGO_TYPE=PGO
+
+goto:eof

+ 3 - 6
Build/scripts/pre_post_util.ps1

@@ -20,8 +20,7 @@ function WriteCommonArguments() {
     WriteMessage "Binaries Path: $binpath"
 }
 
-function GetGitPath()
-{
+function GetGitPath() {
     $gitExe = "git.exe"
 
     if (!(Get-Command $gitExe -ErrorAction SilentlyContinue)) {
@@ -34,7 +33,5 @@ function GetGitPath()
 }
 
 $srcpath = UseValueOrDefault $srcpath "$env:TF_BUILD_SOURCESDIRECTORY" (Resolve-Path "$OuterScriptRoot\..\..");
-$binpath = UseValueOrDefault $binpath "$env:TF_BUILD_BINARIESDIRECTORY" "$srcpath\Build\VcBuild\bin\$arch_$flavor";
-$objpath = UseValueOrDefault $objpath "$env:TF_BUILD_BUILDDIRECTORY" "$srcpath\Build\VcBuild\obj\$arch_$flavor";
-
-
+$objpath = UseValueOrDefault $objpath "$env:TF_BUILD_BUILDDIRECTORY" "${srcpath}\Build\VcBuild\obj\${arch}_${flavor}";
+$binpath = UseValueOrDefault $binpath "$env:TF_BUILD_BINARIESDIRECTORY" "${srcpath}\Build\VcBuild";

+ 4 - 8
Build/scripts/util.ps1

@@ -3,20 +3,16 @@
 # Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
 #-------------------------------------------------------------------------------------------------------
 
-function WriteMessage($str)
-{
+function WriteMessage($str) {
     Write-Output $str
-    if ($logFile -ne "")
-    {
+    if ($logFile -ne "") {
         Write-Output $str | Out-File $logFile -Append
     }
 }
 
-function WriteErrorMessage($str)
-{
+function WriteErrorMessage($str) {
     $host.ui.WriteErrorLine($str);
-    if ($logFile -ne "")
-    {
+    if ($logFile -ne "") {
         Write-Output $str | Out-File $logFile -Append
     }
 }

+ 19 - 0
bin/ChakraCore/ChakraCore.vcxproj

@@ -75,6 +75,19 @@
       </AdditionalIncludeDirectories>
     </ResourceCompile>
   </ItemGroup>
+  <PropertyGroup Condition="'$(IsPogoBuild)'=='true'" Label="Configuration">
+    <WholeProgramOptimization Condition="'$(POGO_TYPE)'=='PGI'">PGInstrument</WholeProgramOptimization>
+    <WholeProgramOptimization Condition="'$(POGO_TYPE)'=='PGO'">PGOnstrument</WholeProgramOptimization>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(IsPogoBuild)'=='true'">
+    <Link>
+      <LinkTimeCodeGeneration Condition="'$(POGO_TYPE)'=='PGI'">PGInstrument</LinkTimeCodeGeneration>
+      <LinkTimeCodeGeneration Condition="'$(POGO_TYPE)'=='PGO'">PGOptimization</LinkTimeCodeGeneration>
+    </Link>
+    <ClCompile>
+      <WholeProgramOptimization>true</WholeProgramOptimization>
+    </ClCompile>
+  </ItemDefinitionGroup>
   <ItemGroup>
     <ProjectReference Include="..\..\lib\Jsrt\Chakra.Jsrt.vcxproj">
       <Project>{706083f7-6aa4-4558-a153-6352ef9220f5}</Project>
@@ -134,6 +147,12 @@
   <ItemGroup>
     <ClInclude Include="TestHooks.h" />
   </ItemGroup>
+  <!-- Conditionally include the group of files to sign because MBv2 knows what to do with this but the old build definition gets confused. -->
+  <ItemGroup Condition="'$(VSO_MICROBUILD_V2)'=='True'">
+    <FilesToSign Include="$(OutDir)\ChakraCore.dll">
+      <Authenticode>Microsoft</Authenticode>
+    </FilesToSign>
+  </ItemGroup>
   <Import Project="$(BuildConfigPropsPath)Chakra.Build.targets" Condition="exists('$(BuildConfigPropsPath)Chakra.Build.targets')" />
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
 </Project>

+ 4 - 0
bin/GCStress/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="MicroBuild.Core" version="0.2.0" targetFramework="native" developmentDependency="true" />
+</packages>

+ 4 - 0
bin/ch/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="MicroBuild.Core" version="0.2.0" targetFramework="native" developmentDependency="true" />
+</packages>

+ 4 - 0
bin/rl/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="MicroBuild.Core" version="0.2.0" targetFramework="native" developmentDependency="true" />
+</packages>

+ 4 - 0
lib/Backend/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="MicroBuild.Core" version="0.2.0" targetFramework="native" developmentDependency="true" />
+</packages>

+ 4 - 0
lib/Common/Codex/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="MicroBuild.Core" version="0.2.0" targetFramework="native" developmentDependency="true" />
+</packages>

+ 4 - 0
lib/Common/Common/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="MicroBuild.Core" version="0.2.0" targetFramework="native" developmentDependency="true" />
+</packages>

+ 4 - 0
lib/Common/Core/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="MicroBuild.Core" version="0.2.0" targetFramework="native" developmentDependency="true" />
+</packages>

+ 4 - 0
lib/Common/DataStructures/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="MicroBuild.Core" version="0.2.0" targetFramework="native" developmentDependency="true" />
+</packages>

+ 4 - 0
lib/Common/Exceptions/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="MicroBuild.Core" version="0.2.0" targetFramework="native" developmentDependency="true" />
+</packages>

+ 4 - 0
lib/Common/Memory/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="MicroBuild.Core" version="0.2.0" targetFramework="native" developmentDependency="true" />
+</packages>

+ 4 - 0
lib/Common/Util/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="MicroBuild.Core" version="0.2.0" targetFramework="native" developmentDependency="true" />
+</packages>

+ 4 - 0
lib/Jsrt/Core/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="MicroBuild.Core" version="0.2.0" targetFramework="native" developmentDependency="true" />
+</packages>

+ 4 - 0
lib/Jsrt/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="MicroBuild.Core" version="0.2.0" targetFramework="native" developmentDependency="true" />
+</packages>

+ 4 - 0
lib/Parser/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="MicroBuild.Core" version="0.2.0" targetFramework="native" developmentDependency="true" />
+</packages>

+ 4 - 0
lib/Runtime/Base/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="MicroBuild.Core" version="0.2.0" targetFramework="native" developmentDependency="true" />
+</packages>

+ 4 - 0
lib/Runtime/ByteCode/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="MicroBuild.Core" version="0.2.0" targetFramework="native" developmentDependency="true" />
+</packages>

+ 4 - 0
lib/Runtime/Debug/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="MicroBuild.Core" version="0.2.0" targetFramework="native" developmentDependency="true" />
+</packages>

+ 4 - 0
lib/Runtime/Language/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="MicroBuild.Core" version="0.2.0" targetFramework="native" developmentDependency="true" />
+</packages>

+ 4 - 0
lib/Runtime/Library/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="MicroBuild.Core" version="0.2.0" targetFramework="native" developmentDependency="true" />
+</packages>

+ 4 - 0
lib/Runtime/Math/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="MicroBuild.Core" version="0.2.0" targetFramework="native" developmentDependency="true" />
+</packages>

+ 4 - 0
lib/Runtime/Types/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="MicroBuild.Core" version="0.2.0" targetFramework="native" developmentDependency="true" />
+</packages>