Skip to content

Commit 2f13802

Browse files
committed
MicroBuild v2: changes to project files and build scripts to enable building in MBv2, and PGO builds of ChakraCore; add nuspec for ChakraCore.
1 parent a458628 commit 2f13802

41 files changed

Lines changed: 600 additions & 40 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ build_*.err
1515
buildchk.*
1616
buildfre.*
1717
Build/swum-cache.txt
18+
ComputedEnvironment.cmd
19+
packages/
1820
*.tlog/
1921
.*.swp
2022
sd.ini
@@ -28,3 +30,4 @@ profile.dpl.*
2830
Build/Chakra.Core.VC.opendb
2931
test/benchmarks/*.txt
3032
test/benchmarks/*.dpl
33+
*.nupkg
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="Common.Build.ProjectConfiguration.props" />
4+
<Import Project="MicroBuildv2.Build.ProjectConfiguration.props" />
45
</Project>
5-

Build/Common.Build.Default.props

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,15 @@
4040
<CharacterSet>Unicode</CharacterSet>
4141
</PropertyGroup>
4242

43-
<!-- Alternate platform names-->
43+
<!-- Change configuration name to output to a different folder -->
44+
<!-- POGO instrumentation -->
45+
<PropertyGroup>
46+
<IsPogoBuild />
47+
<IsPogoBuild Condition="('$(POGO_TYPE)'=='PGO' OR '$(POGO_TYPE)'=='PGI')">true</IsPogoBuild>
48+
<OutDirName Condition="'$(IsPogoBuild)'=='true'">$(Configuration.ToLower())_pogo</OutDirName>
49+
</PropertyGroup>
50+
51+
<!-- Alternate platform names -->
4452
<PropertyGroup>
4553
<!-- PlatformPathName is used in OutDir/IntDir name-->
4654
<PlatformPathName>$(Platform)</PlatformPathName>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<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')" />
4+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
5+
<PropertyGroup>
6+
<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>
7+
</PropertyGroup>
8+
<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'))" />
9+
<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'))" />
10+
</Target>
11+
<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')" />
12+
</Project>

Build/Microsoft.ChakraCore.nuspec

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<package xmlns="http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd">
3+
<metadata>
4+
<id>Microsoft.ChakraCore</id>
5+
<version>1.2</version>
6+
<authors>Chakra Team</authors>
7+
<owners>Chakra Team</owners>
8+
<licenseUrl>https://github.com/Microsoft/ChakraCore/blob/master/LICENSE.txt</licenseUrl>
9+
<projectUrl>https://github.com/Microsoft/ChakraCore</projectUrl>
10+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
11+
<developmentDependency>true</developmentDependency>
12+
<description>ChakraCore is the core part of the Chakra Javascript engine that powers Microsoft Edge.</description>
13+
<!--
14+
<releaseNotes>**** TODO: need link</releaseNotes>
15+
-->
16+
<copyright>Copyright (C) 2016 Microsoft</copyright>
17+
<language>en-US</language>
18+
<tags>Chakra,ChakraCore</tags>
19+
</metadata>
20+
<files>
21+
<file src="VcBuild\bin\x86_release\ChakraCore.dll" target="x86\ChakraCore.dll" />
22+
<file src="VcBuild\bin\x86_release\ChakraCore.pdb" target="x86\ChakraCore.pdb" />
23+
<file src="VcBuild\bin\x86_release\ch.exe" target="x86\ch.exe" />
24+
<file src="VcBuild\bin\x86_release\ch.pdb" target="x86\ch.pdb" />
25+
<file src="VcBuild\bin\x64_release\ChakraCore.dll" target="x64\ChakraCore.dll" />
26+
<file src="VcBuild\bin\x64_release\ChakraCore.pdb" target="x64\ChakraCore.pdb" />
27+
<file src="VcBuild\bin\x64_release\ch.exe" target="x64\ch.exe" />
28+
<file src="VcBuild\bin\x64_release\ch.pdb" target="x64\ch.pdb" />
29+
</files>
30+
</package>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildThisFileDirectory)\MicroBuild.Plugin.props" Condition="'$(MicroBuildSentinelFile)' == ''" />
4+
<Import Project="$(MicroBuildPluginDirectory)\MicroBuild.Plugins.*\**\build\MicroBuild.Plugins.*.props" Condition="'$(MicroBuildPluginDirectory)' != ''" />
5+
</Project>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildThisFileDirectory)\MicroBuild.Plugin.props" Condition="'$(MicroBuildSentinelFile)' == ''" />
4+
<Import Project="$(MicroBuildPluginDirectory)\MicroBuild.Plugins.*\**\build\MicroBuild.Plugins.*.targets" Condition="'$(MicroBuildPluginDirectory)' != ''" />
5+
</Project>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<!-- MicroBuild plugins can be installed in any parent directory up the tree from the project that is building.
5+
The use of a sentinel file (which will be installed automatically due to package dependencies from any plugin)
6+
will help us locate the plugin packages directory while being constrained to using MSBuild's intrinsic functions,
7+
since we want the imports to occur at evaluation time instead of when a specific target is executing.
8+
9+
Note: All MicroBuild plugins must be installed to the same directory (under the same packages folder). If plugins
10+
are installed to different directories, the plugins which are in the directories closest to the executing project
11+
up the hierarchy will be discovered, and the ones higher up the tree will be ignored.
12+
-->
13+
<MicroBuildSentinelFile>packages\MicroBuild.Core.Sentinel.1.0.0\sentinel.txt</MicroBuildSentinelFile>
14+
<MicroBuildSentinelFileV3>MicroBuild.Core.Sentinel\1.0.0\sentinel.txt</MicroBuildSentinelFileV3>
15+
16+
<MicroBuildPluginDirectory>$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), $(MicroBuildSentinelFile)))</MicroBuildPluginDirectory>
17+
<MicroBuildPluginDirectory Condition="'$(MicroBuildPluginDirectory)' != ''">$(MicroBuildPluginDirectory)\packages</MicroBuildPluginDirectory>
18+
19+
<!-- Some people might want to put the plugin packages directly in their Nuget v3 global cache. This doesn't happen by default,
20+
but we will allow for it here. We don't support nuget.config's globalPackagesFolder setting here because we don't have a good
21+
way to load/parse that file with MSBuild intrinsics. We can check the other two mechanisms though, which are the %NUGET_PACKAGES%
22+
environment variable and %USERPROFILE%\.nuget\packages -->
23+
<MicroBuildPluginDirectory Condition="'$(MicroBuildPluginDirectory)' == '' and '$(NUGET_PACKAGES)' != '' and Exists('$(NUGET_PACKAGES)\$(MicroBuildSentinelFileV3)')">$(NUGET_PACKAGES)</MicroBuildPluginDirectory>
24+
<MicroBuildPluginDirectory Condition="'$(MicroBuildPluginDirectory)' == '' and '$(USERPROFILE)' != '' and Exists('$(USERPROFILE)\.nuget\packages\$(MicroBuildSentinelFileV3)')">$(USERPROFILE)\.nuget\packages</MicroBuildPluginDirectory>
25+
26+
<!-- Allow for the ability to override the plugin directory, for example in automated builds -->
27+
<MicroBuildPluginDirectory Condition="'$(MicroBuildOverridePluginDirectory)' != ''">$(MicroBuildOverridePluginDirectory)</MicroBuildPluginDirectory>
28+
</PropertyGroup>
29+
</Project>

Build/scripts/finalize_build.ps1

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#-------------------------------------------------------------------------------------------------------
2+
# Copyright (C) Microsoft. All rights reserved.
3+
# Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4+
#-------------------------------------------------------------------------------------------------------
5+
6+
#
7+
# Clean up the sentinel which previously marked the build as incomplete.
8+
#
9+
10+
Remove-Item -Path ${Env:FlavorBuildIncompleteFile} -Force
11+
12+
#
13+
# Create build status JSON file for this flavor.
14+
#
15+
16+
$FullOutputPath = Join-Path $Env:DROP_ROOT $Env:OutputPath
17+
$BuildLogsPath = Join-Path $FullOutputPath "buildlogs"
18+
$buildFlavorErrFile = Join-Path $BuildLogsPath "build_${Env:BuildPlatform}${Env:BuildConfiguration}.err"
19+
20+
# If build_{}{}.err contains any text then there were build errors and we record that the build failed.
21+
$BuildFailed = $false
22+
if (Test-Path $buildFlavorErrFile) {
23+
$BuildFailed = (Get-Item $buildFlavorErrFile).length -gt 0
24+
}
25+
26+
$status = "passed"
27+
if ($BuildFailed) {
28+
$status = "failed"
29+
}
30+
31+
$buildFlavorJsonFile = Join-Path $FullOutputPath "${Env:FlavorName}.json"
32+
$buildFlavorJson = New-Object System.Object
33+
34+
$buildFlavorJson | Add-Member -type NoteProperty -name status -value $status
35+
$buildFlavorJson | Add-Member -type NoteProperty -name arch -value $Env:BuildPlatform
36+
$buildFlavorJson | Add-Member -type NoteProperty -name flavor -value $Env:BuildConfiguration
37+
38+
$buildFlavorJson | ConvertTo-Json | Write-Output
39+
$buildFlavorJson | ConvertTo-Json | Out-File $buildFlavorJsonFile -Encoding ascii

Build/scripts/init_build.ps1

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
#-------------------------------------------------------------------------------------------------------
2+
# Copyright (C) Microsoft. All rights reserved.
3+
# Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4+
#-------------------------------------------------------------------------------------------------------
5+
6+
param (
7+
[string]$envconfig = "ComputedEnvironment.cmd",
8+
9+
[Parameter(Mandatory=$True)]
10+
[string]$oauth
11+
)
12+
13+
$branch = $env:BUILD_SOURCEBRANCH
14+
if (-not $branch) {
15+
$branch = $(git rev-parse --symbolic-full-name HEAD)
16+
}
17+
18+
$BranchName = $branch.split('/',3)[2]
19+
$BranchPath = $BranchName.replace('/','\')
20+
$CommitHash = ${env:BUILD_SOURCEVERSION}
21+
if (-not $CommitHash) {
22+
$CommitHash = $(git rev-parse HEAD)
23+
}
24+
25+
$Username = $(git log $CommitHash -1 --pretty=%ae).split('@')[0]
26+
$CommitDateTime = [DateTime]$(git log $CommitHash -1 --pretty=%aD)
27+
$CommitTime = Get-Date $CommitDateTime -Format yyMMdd.HHmm
28+
29+
#
30+
# (borrowed from pre_build.ps1)
31+
# Get PushID and PushDate from VSO
32+
# TODO (doilij) refactor this into a method in a util script.
33+
#
34+
35+
# Get the git remote path and construct the rest API URI
36+
$remote = (iex "git remote -v")[0].split()[1].replace("_git", "_apis/git/repositories");
37+
$remote = $remote.replace("mshttps", "https")
38+
39+
# Get the pushId and push date time to use that for build number and build date time
40+
$uri = ("{0}/commits/{1}?api-version=1.0" -f $remote, $commitHash)
41+
$oauthToken = Get-Content $oauth
42+
$header = @{Authorization=("Basic {0}" -f $oauthToken) }
43+
$info = Invoke-RestMethod -Headers $header -Uri $uri -Method GET
44+
45+
$BuildPushDate = [datetime]$info.push.date
46+
$PushDate = Get-Date $BuildPushDate -Format yyMMdd.HHmm
47+
$buildPushId = $info.push.pushId
48+
$buildPushIdPart1 = [int]([math]::Floor($buildPushId / 65536))
49+
$buildPushIdPart2 = [int]($buildPushId % 65536)
50+
51+
$PushID = "{0}.{1}" -f $buildPushIdPart1.ToString("00000"), $buildPushIdPart2.ToString("00000")
52+
$FullVersionString = "${Env:VERSION_MAJOR}.${Env:VERSION_MINOR}.${PushID}"
53+
54+
#
55+
# (end code borrowed from pre_build.ps1)
56+
#
57+
58+
# unless it is a build branch, subdivide the output directory by month
59+
if ($BranchPath.StartsWith("build")) {
60+
$YearAndMonth = ""
61+
} else {
62+
$YearAndMonth = Get-Date $BuildPushDate -Format yyMM
63+
}
64+
65+
$YearAndMonthSeparator = ""
66+
if ($YearAndMonth) {
67+
$YearAndMonthSeparator = "\"
68+
}
69+
70+
$BuildIdentifier = "${PushID}_${PushDate}_${Username}_${CommitHash}"
71+
$OutputPath = "${BranchPath}\${YearAndMonth}${YearAndMonthSeparator}${BuildIdentifier}"
72+
$FlavorName = "${Env:BuildPlatform}_${Env:BuildConfiguration}"
73+
74+
# Create a sentinel file for each build flavor and for the overall build
75+
# to track whether the build is complete.
76+
# * build.incomplete # will be deleted when the release task completes
77+
# * ${arch}_${flavor}.incomplete # will be deleted when the build of this flavor completes
78+
79+
$buildIncompleteFileContentsString = @"
80+
{0} in progress.
81+
The contents of this directory should not be relied on until the build completes.
82+
"@
83+
84+
$FullOutputPath = Join-Path ${env:DROP_ROOT} ${OutputPath}
85+
New-Item -ItemType Directory -Force -Path $FullOutputPath
86+
New-Item -ItemType Directory -Force -Path (Join-Path $Env:BUILD_BINARIESDIRECTORY "buildlogs")
87+
New-Item -ItemType Directory -Force -Path (Join-Path $Env:BUILD_BINARIESDIRECTORY "logs")
88+
89+
$buildIncompleteFile = Join-Path $FullOutputPath "build.incomplete"
90+
$flavorBuildIncompleteFile = Join-Path $FullOutputPath "${FlavorName}.incomplete"
91+
92+
if (-not (Test-Path $buildIncompleteFile)) {
93+
($buildIncompleteFileContentsString -f "Build") `
94+
| Out-File $buildIncompleteFile -Encoding Ascii
95+
}
96+
if (-not (Test-Path $flavorBuildIncompleteFile)) {
97+
($buildIncompleteFileContentsString -f "Build of ${FlavorName}") `
98+
| Out-File $flavorBuildIncompleteFile -Encoding Ascii
99+
}
100+
101+
# Write the $envconfig script.
102+
103+
@"
104+
set BranchName=${BranchName}
105+
set BranchPath=${BranchPath}
106+
set YearAndMonth=${YearAndMonth}
107+
set BuildIdentifier=${BuildIdentifier}
108+
109+
set PushID=${PushID}
110+
set FullVersionString=${FullVersionString}
111+
set PushDate=${PushDate}
112+
set CommitTime=${CommitTime}
113+
set Username=${Username}
114+
set CommitHash=${CommitHash}
115+
116+
set OutputPath=${OutputPath}
117+
set FlavorName=${FlavorName}
118+
119+
set BuildIncompleteFile=${buildIncompleteFile}
120+
set FlavorBuildIncompleteFile=${flavorBuildIncompleteFile}
121+
"@ `
122+
| Out-File $envconfig -Encoding Ascii
123+
124+
# Use the MBv2 environment to construct a MBv1 VSO environment
125+
# for the sake of reusing the pre-build and post-build scripts as they are.
126+
127+
@"
128+
set TF_BUILD_SOURCEGETVERSION=LG:${branch}:${CommitHash}
129+
set TF_BUILD_DROPLOCATION=${Env:BUILD_BINARIESDIRECTORY}
130+
131+
set TF_BUILD_BUILDDEFINITIONNAME=${Env:BUILD_DEFINITIONNAME}
132+
set TF_BUILD_BUILDNUMBER=${Env:BUILD_BUILDNUMBER}
133+
set TF_BUILD_BUILDURI=${Env:BUILD_BUILDURI}
134+
"@ `
135+
| Out-File $envconfig -Encoding Ascii -Append
136+
137+
# Set VSO variables that can be consumed by other VSO tasks.
138+
# Uses command syntax documented here:
139+
# https://github.com/Microsoft/vso-agent-tasks/blob/master/docs/authoring/commands.md
140+
# Lines written to stdout that match this pattern are interpreted with this command syntax.
141+
142+
Write-Output "Setting VSO variable VSO_OutputPath = ${OutputPath}"
143+
Write-Output "##vso[task.setvariable variable=VSO_OutputPath;]${OutputPath}"
144+
145+
Write-Output "Setting VSO variable VSO_FullVersionString = ${FullVersionString}"
146+
Write-Output "##vso[task.setvariable variable=VSO_FullVersionString;]${FullVersionString}"
147+
148+
# TODO (doilij): move this up and assign values
149+
150+
# Inferable Environment (if not specified, inferred by pre_post_util.ps1):
151+
# $Env:TF_BUILD_SOURCESDIRECTORY (a.k.a. $srcpath)
152+
# $Env:TF_BUILD_BUILDDIRECTORY (a.k.a. $objpath)
153+
# $Env:TF_BUILD_BINARIESDIRECTORY (a.k.a. $binpath)

0 commit comments

Comments
 (0)