forked from OpenXT/xc-windows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
do_build.ps1
181 lines (154 loc) · 7.26 KB
/
do_build.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
$ErrorActionPreference = 'stop'
$ScriptDir = Split-Path -parent $MyInvocation.MyCommand.Path
Import-Module $ScriptDir\..\BuildSupport\invoke.psm1
Import-Module $ScriptDir\..\BuildSupport\checked-copy.psm1
#Helper Functions
function enable-read-execute([string]$file)
{
$acl = Get-Acl $file
$ar = New-Object System.Security.Accesscontrol.FileSystemAccessRule("Everyone", "ReadAndExecute", "Allow")
$acl.SetAccessRule($ar)
Set-Acl $file $acl
}
#Get parameters
$args | Foreach-Object {$argtable = @{}} {if ($_ -Match "(.*)=(.*)") {$argtable[$matches[1]] = $matches[2];}}
$ddkdir = $argtable["DdkDir"]
$licfile = $argtable["License"]
$type = $argtable["BuildType"]
$developer = $argtable["Developer"]
$signtool = $argtable["SignTool"]
$certname = $argtable["CertName"]
$SHA1Thumb = $argtable["SHA1Thumb"].replace(" ","")
$SHA256Thumb = $argtable["SHA256Thumb"].replace(" ","")
$VSDir = $argtable["VSDir"]
$verstr = $argtable["VerString"]
$ver0 = $argtable["VerMajor"]
$ver1 = $argtable["VerMinor"]
$ver2 = $argtable["VerMicro"]
$ver3 = $argtable["BuildNumber"]
$tag = $argtable["BuildTag"]
$branch = $argtable["BuildBranch"]
$MSBuild = $argtable["MSBuild"]
$giturl = $argtable["GitUrl"]
$gitbin = $argtable["GitBin"]
$crosssign = $argtable["CrossSign"]
$compile = $true # can be set to false if you just want to get to signing quickly
#Set some important variables
$mywd = Split-Path -Parent $MyInvocation.MyCommand.Path
if ($signtool.Length -lt 1) {
throw "Please specify the location of a directory containing signtool using the /signtool argument"
}
Push-Location -Path $mywd
#Set build type
$cfg = "fre"
if ($type.ToLower().CompareTo("debug") -eq 0)
{
$cfg = "chk"
}
Write-Host ("Building Xen Tools version: " + $verstr + " in: " + $mywd)
# Before running any of the batch files, make sure they have an access rule to allow execute
enable-read-execute -file ".\dostampinf.bat"
enable-read-execute -file ".\dobuild.bat"
enable-read-execute -file ".\dowin8build.bat"
enable-read-execute -file ".\doverifysign.ps1"
enable-read-execute -file ".\dotestsign.bat"
# If no specific license is specified, grab the default EULA
if ($licfile.Length -lt 1)
{
$licfile = $mywd + "\xenclient-eula\EULA-en-us"
}
# Modify the findddk.bat to use the DDK specified for the build. If you suspect this is a hack
# you would be correct my friend...
Set-Content -Path ".\findddk.bat" -Value ("set ddk_path=" + $ddkdir)
if ($compile) {
Invoke-CommandChecked "Timestamping INF files" ".\dostampinf.bat" $ddkdir $mywd $verstr
Invoke-CommandChecked "Building 32 bit bits" ".\dobuild.bat" $ddkdir $mywd $cfg "x86"
Invoke-CommandChecked "Building 64 bit bits" ".\dobuild.bat" $ddkdir $mywd $cfg "x64"
Invoke-CommandChecked "Building Win8 32 bit bits" ".\dowin8build.bat" $VSDir $mywd $cfg "x86"
Invoke-CommandChecked "Building Win8 64 bit bits" ".\dowin8build.bat" $VSDir $mywd $cfg "x64"
}
Push-Location
# TODO: use the logic in openxt.git/windows/winbuild-all.ps1 to do git clones rather than
# have this logic that duplicates it. Cope with the way that will checkout xc-vusb one
# level higher, i.e. as a peer of xc-windows not a subdirecory of xc-windows.
$gitsrc = $giturl + "/" + "xc-vusb.git"
$doclone = $true
# skip the clone if it has already been done
if (Test-Path ("xc-vusb\.git")) {
$nfiles = (Get-ChildItem "xc-vusb").Count
# it is possible a failure during an earlier clone resulted in a directory,
# possibly with a .git subdirectory, so if we see that we still need to clone
if ([int]$nfiles -gt 1) {
$doclone = $false
}
}
if ($doclone) {
Invoke-CommandChecked "git clone xc-vusb" $gitbin clone "-n" $gitsrc
Invoke-CommandChecked "git fetch origin" $gitbin fetch origin
if ($branch.Length -gt 0) {
Push-Location -Path "xc-vusb"
Write-Host ("Checking out: " + $branch + " For: xc-vusb")
if ($branch.CompareTo("master") -eq 0) {
Invoke-CommandChecked "git checkout" $gitbin checkout -q $branch
} else {
& $gitbin checkout -q origin/$branch
# standard practice on XT is to fall back to master for
# branches that do not exist.
if (-Not ($LastExitCode -eq 0)) {
Invoke-CommandChecked "git checkout" $gitbin checkout -q -b $branch
}
}
Pop-Location
} elseif ($tag.Length -gt 0) {
Push-Location -Path "xc-vusb"
Write-Host ("Checking out: " + $tag + " For: xc-vusb")
Invoke-CommandChecked "git checkout tag for xc-vusb" $gitbin checkout -q -b $tag $tag
Pop-Location
} else {
throw "No branch or tag for xc-vusb checkout"
}
}
#Build xc-vusb
$usbBuild = "Win7 $type"
if ($compile) {
Invoke-CommandChecked "xc-vusb msbuild 32 bit" $MSBuild xc-vusb\Drivers\xenvusb\xenvusb.sln /p:Configuration=$usbBuild
Invoke-CommandChecked "xc-vusb msbuild 64 bit" $MSBuild xc-vusb\Drivers\xenvusb\xenvusb.sln /p:Configuration=$usbBuild /p:Platform="x64"
}
New-Item -Path ".\xc-vusb\build\x86" -Type Directory -Force
New-Item -Path ".\xc-vusb\build\x64" -Type Directory -Force
if ($type.ToLower().CompareTo("debug") -eq 0) {
Checked-Copy ".\xc-vusb\Drivers\xenvusb\xenvusb.inf" ".\xc-vusb\build\x86\"
Checked-Copy ".\xc-vusb\Drivers\xenvusb\Win7Debug\xenvusb.sys" ".\xc-vusb\build\x86\"
Checked-Copy ".\xc-vusb\Drivers\xenvusb\xenvusb64.inf" ".\xc-vusb\build\x64\xenvusb.inf"
Checked-Copy ".\xc-vusb\Drivers\xenvusb\x64\Win7Debug\xenvusb.sys" ".\xc-vusb\build\x64\"
} else {
Checked-Copy ".\xc-vusb\Drivers\xenvusb\xenvusb.inf" ".\xc-vusb\build\x86\"
Checked-Copy ".\xc-vusb\Drivers\xenvusb\Win7Release\xenvusb.sys" ".\xc-vusb\build\x86\"
Checked-Copy ".\xc-vusb\Drivers\xenvusb\xenvusb64.inf" ".\xc-vusb\build\x64\xenvusb.inf"
Checked-Copy ".\xc-vusb\Drivers\xenvusb\x64\Win7Release\xenvusb.sys" ".\xc-vusb\build\x64\"
}
if ($crosssign) {
Invoke-CommandChecked "do_sign" powershell ./do_sign.ps1 -certname ("'"+$certname+"'") -signtool ("'"+$signtool+"'") -SHA1Thumb ("'"+$SHA1Thumb+"'") -SHA256Thumb ("'"+$SHA256Thumb+"'") -crosssign ("'"+$crosssign+"'")
} else {
Invoke-CommandChecked "do_sign" powershell ./do_sign.ps1 -certname ("'"+$certname+"'") -signtool ("'"+$signtool+"'") -SHA1Thumb ("'"+$SHA1Thumb+"'") -SHA256Thumb ("'"+$SHA256Thumb+"'")
}
#Only do verification if not doing a developer build
if($developer -ne $true){
#Verify the drivers are signed using default signtool through %PATH% or use a specific one
Invoke-CommandChecked "doverifysign" .\doverifysign.ps1 $signtool\signtool.exe
}
Pop-Location
# Change dir and copy the default EULA or specified license to install folder
Push-Location -Path "install"
Checked-Copy $licfile ".\license.txt"
# Package the NSIS installer - need the individual version numbers here
Write-Host "Building driver installer"
Invoke-CommandChecked "makensis" makensis "/DINSTALL_XENVESA" "/DINSTALL_XENVESA8" ("/DVERMAJOR=" + $ver0) ("/DVERMINOR=" + $ver1) ("/DVERMICRO=" + $ver2) ("/DVERBUILD=" + $ver3) "xensetup.nsi"
if (!(Test-Path -Path ".\xensetup.exe" -PathType Leaf))
{
log-error -err "Failed to make xensetup.exe installer package"
return $false
}
Pop-Location
Pop-Location
return $true