-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add source linking information during the build (#2857)
Copies source linking scripts and processes from Microsoft/Microsoft-UI-XAML. This embeds source information inside the PDBs in two formats: One for WinDBG using a PowerShell script that runs during the build, and one for Visual Studio using the Microsoft.SourceLink.GitHub NuGet pacakge. Sources are automatically pulled from raw.githubusercontent.com when debugging a release build inside either of these utilities as of this change.
- Loading branch information
Showing
22 changed files
with
301 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
[CmdLetBinding()] | ||
Param( | ||
[Parameter(Mandatory=$true, Position=0)][string]$SearchDir, | ||
[Parameter(Mandatory=$true, Position=1)][string]$SourceRoot, | ||
[Parameter(Mandatory=$true, Position=2)][string]$CommitId, | ||
[string]$Organization = "microsoft", | ||
[string]$Repo = "terminal", | ||
[switch]$recursive | ||
) | ||
|
||
$debuggerPath = (Get-ItemProperty -path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots" -name WindowsDebuggersRoot10).WindowsDebuggersRoot10 | ||
$srcsrvPath = Join-Path $debuggerPath "x64\srcsrv" | ||
$srctoolExe = Join-Path $srcsrvPath "srctool.exe" | ||
$pdbstrExe = Join-Path $srcsrvPath "pdbstr.exe" | ||
|
||
$fileTable = @{} | ||
foreach ($gitFile in & git ls-files) | ||
{ | ||
$fileTable[$gitFile] = $gitFile | ||
} | ||
|
||
$mappedFiles = New-Object System.Collections.ArrayList | ||
|
||
foreach ($file in (Get-ChildItem -r:$recursive "$SearchDir\*.pdb")) | ||
{ | ||
Write-Verbose "Found $file" | ||
|
||
$ErrorActionPreference = "Continue" # Azure Pipelines defaults to "Stop", continue past errors in this script. | ||
|
||
$allFiles = & $srctoolExe -r "$file" | ||
|
||
# If the pdb didn't have enough files then skip it (the srctool output has a blank line even when there's no info | ||
# so check for less than 2 lines) | ||
if ($allFiles.Length -lt 2) | ||
{ | ||
continue | ||
} | ||
|
||
for ($i = 0; $i -lt $allFiles.Length; $i++) | ||
{ | ||
if ($allFiles[$i].StartsWith($SourceRoot, [StringComparison]::OrdinalIgnoreCase)) | ||
{ | ||
$relative = $allFiles[$i].Substring($SourceRoot.Length).TrimStart("\") | ||
$relative = $relative.Replace("\", "/") | ||
|
||
# Git urls are case-sensitive but the PDB might contain a lowercased version of the file path. | ||
# Look up the relative url in the output of "ls-files". If it's not there then it's not something | ||
# in git, so don't index it. | ||
$relative = $fileTable[$relative] | ||
if ($relative) | ||
{ | ||
$mapping = $allFiles[$i] + "*$relative" | ||
$mappedFiles.Add($mapping) | ||
|
||
Write-Verbose "Mapped path $($i): $mapping" | ||
} | ||
} | ||
} | ||
|
||
$pdbstrFile = Join-Path "$env:TEMP" "pdbstr.txt" | ||
|
||
Write-Verbose "pdbstr.txt = $pdbstrFile" | ||
|
||
@" | ||
SRCSRV: ini ------------------------------------------------ | ||
VERSION=2 | ||
VERCTRL=http | ||
SRCSRV: variables ------------------------------------------ | ||
ORGANIZATION=$Organization | ||
REPO=$Repo | ||
COMMITID=$CommitId | ||
HTTP_ALIAS=https://raw.githubusercontent.com/%ORGANIZATION%/%REPO%/%COMMITID%/ | ||
HTTP_EXTRACT_TARGET=%HTTP_ALIAS%%var2% | ||
SRCSRVTRG=%HTTP_EXTRACT_TARGET% | ||
SRC_INDEX=public | ||
SRCSRV: source files --------------------------------------- | ||
$($mappedFiles -join "`r`n") | ||
SRCSRV: end ------------------------------------------------ | ||
"@ | Set-Content $pdbstrFile | ||
|
||
& $pdbstrExe -p:"$file" -w -s:srcsrv -i:$pdbstrFile | ||
} | ||
|
||
# Return with exit 0 to override any weird error code from other tools | ||
Exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Microsoft.Build.Tasks.Git" version="1.0.0-beta2-19367-01" targetFramework="native" developmentDependency="true" /> | ||
<package id="Microsoft.SourceLink.Common" version="1.0.0-beta2-19367-01" targetFramework="native" developmentDependency="true" /> | ||
<package id="Microsoft.SourceLink.GitHub" version="1.0.0-beta2-19367-01" targetFramework="native" developmentDependency="true" /> | ||
<package id="Microsoft.Toolkit.Win32.UI.XamlApplication" version="6.0.0-preview7" targetFramework="native" /> | ||
<package id="Microsoft.UI.Xaml" version="2.2.190611001-prerelease" targetFramework="native" /> | ||
<package id="Microsoft.Windows.CppWinRT" version="2.0.190730.2" targetFramework="native" /> | ||
</packages> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Microsoft.Build.Tasks.Git" version="1.0.0-beta2-19367-01" targetFramework="native" developmentDependency="true" /> | ||
<package id="Microsoft.SourceLink.Common" version="1.0.0-beta2-19367-01" targetFramework="native" developmentDependency="true" /> | ||
<package id="Microsoft.SourceLink.GitHub" version="1.0.0-beta2-19367-01" targetFramework="native" developmentDependency="true" /> | ||
<package id="Microsoft.Windows.CppWinRT" version="2.0.190730.2" targetFramework="native" /> | ||
<package id="vcpkg-cpprestsdk" version="2.10.0" targetFramework="native" /> | ||
</packages> | ||
</packages> |
Oops, something went wrong.