-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ps1
125 lines (101 loc) · 3.68 KB
/
main.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
param(
# The directory path of the github project
[Parameter(Mandatory = $true)]
[string] $localSourceDir,
# The name of user that owns the github repository
[Parameter(Mandatory = $true)]
[string] $repo_userId,
# The name of the repository
[Parameter(Mandatory = $true)]
[string] $repo_name,
# The repository branch
[Parameter(Mandatory = $true)]
[string] $repo_branch,
# Source paths to ignore, format input like this "name,name,name"
[string[]] $ignoreArray,
# An array of arrays of strings "one_FolderPath,one_UserName,one_RepoName,one_Branch;two_FolderPath,two_UserName,two_RepoName,two_Branch"
[string[][]] $subModules,
# Paths to find .pdb's in, if empty then the path to the project is used
[string[]] $pdbPaths
)
##
# Variables
##
$subModules_ArrayArray = @(@())
if ($subModules -ne $null)
{
$subModules = $subModules.split(";")
foreach ($rawArray in $subModules)
{
$rawArray = $rawArray.split(",")
$subModules_ArrayArray += ,$rawArray
}
}
if ($ignoreArray -ne $null)
{
$ignoreArray = $ignoreArray.split(",")
}
if ($pdbPaths -ne $null)
{
$pdbPaths = $pdbPaths.split(",")
}
$repo_name = $repo_name -replace "$repo_userId/",""
$symbolsFolder = "symbols_tempJ1M39VNNDF"
$outputFolder = "symstore_temp6JB24HH2Z"
$dbgToolsPath = "${env:ProgramFiles(x86)}\Windows Kits\10\Debuggers\x86"
##
# Begin
##
# Debuggers tools from winsdk are required
if (-Not (Test-Path -path $dbgToolsPath))
{
Write-Out "Installing debuggers tools from winsdk..."
Invoke-WebRequest https://go.microsoft.com/fwlink/?linkid=2173743 -OutFile winsdksetup.exe;
start-Process winsdksetup.exe -ArgumentList '/features OptionId.WindowsDesktopDebuggers /q' -Wait;
Remove-Item -Force winsdksetup.exe;
}
# Submodules need the version used at compilation time deduced
for ($i = 0 ; $i -lt $subModules_ArrayArray.Count ; $i++)
{
$subModule_UserName = $subModules_ArrayArray[$i][1]
$subModule_RepoName = $subModules_ArrayArray[$i][2]
$subModule_Branch = $subModules_ArrayArray[$i][3]
$mainRepoContentJson = (Invoke-WebRequest "https://api.github.com/repos/$subModule_UserName/$subModule_RepoName/commits/$subModule_Branch" -UseBasicParsing | ConvertFrom-Json)
$subModules_ArrayArray[$i][3] = $mainRepoContentJson.sha
}
# Copy symbols from the source directory
cmd /c rmdir $symbolsFolder /s /q
cmd /c mkdir $symbolsFolder
if ($pdbPaths -eq $null)
{
cmd /c .\pdbcpy.cmd $localSourceDir $symbolsFolder
}
else
{
foreach ($pdbPath in $pdbPaths)
{
cmd /c .\pdbcpy.cmd $pdbPath $symbolsFolder
}
}
# Edit the pdb's with http addresses
.\github-sourceindexer.ps1 -ignoreUnknown -ignore $ignoreArray -sourcesroot $localSourceDir -dbgToolsPath $dbgToolsPath -symbolsFolder $symbolsFolder -userId $repo_userId -repository $repo_name -branch $repo_branch -subModules $subModules_ArrayArray -verbose
# Run symstore on all of the .pdb's
cmd /c rmdir $outputFolder /s /q
cmd /c mkdir $outputFolder
cmd /c "${env:ProgramFiles(x86)}\Windows Kits\10\Debuggers\x64\symstore.exe" add /compress /r /f $symbolsFolder /s $outputFolder /t SLOBS
# Upload to aws
try
{
.\s3upload.ps1 -symStoreFolder $outputFolder
# Cleanup
cmd /c rmdir $outputFolder /s /q
cmd /c rmdir $symbolsFolder /s /q
}
catch
{
Write-Error "s3upload.ps1 failed"
cmd /c rmdir $outputFolder /s /q
cmd /c rmdir $symbolsFolder /s /q
# Run the failure upward to the calling script if there is one
exit 1
}