forked from ravendb/ravendb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
191 lines (151 loc) · 5.61 KB
/
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
182
183
184
185
186
187
188
189
190
param(
$Target="",
[switch]$WinX64,
[switch]$WinX86,
[switch]$LinuxX64,
[switch]$Osx,
[switch]$Rpi,
[switch]$DontRebuildStudio,
[switch]$DontBuildStudio,
[switch]$JustStudio,
[switch]$JustNuget,
[switch]$Debug,
[switch]$DryRunVersionBump = $false,
[switch]$DryRunSign = $false,
[switch]$Help)
$ErrorActionPreference = "Stop"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
. '.\scripts\checkLastExitCode.ps1'
. '.\scripts\checkPrerequisites.ps1'
. '.\scripts\restore.ps1'
. '.\scripts\clean.ps1'
. '.\scripts\archive.ps1'
. '.\scripts\package.ps1'
. '.\scripts\buildProjects.ps1'
. '.\scripts\getScriptDirectory.ps1'
. '.\scripts\copyAssets.ps1'
. '.\scripts\version.ps1'
. '.\scripts\updateSourceWithBuildInfo.ps1'
. '.\scripts\nuget.ps1'
. '.\scripts\target.ps1'
. '.\scripts\help.ps1'
. '.\scripts\sign.ps1'
. '.\scripts\docker.ps1'
if ($Help) {
Help
}
CheckPrerequisites
$PROJECT_DIR = Get-ScriptDirectory
$RELEASE_DIR = [io.path]::combine($PROJECT_DIR, "artifacts")
$OUT_DIR = [io.path]::combine($PROJECT_DIR, "artifacts")
$CLIENT_SRC_DIR = [io.path]::combine($PROJECT_DIR, "src", "Raven.Client")
$CLIENT_OUT_DIR = [io.path]::combine($PROJECT_DIR, "src", "Raven.Client", "bin", "Release")
$TESTDRIVER_SRC_DIR = [io.path]::combine($PROJECT_DIR, "src", "Raven.TestDriver")
$TESTDRIVER_OUT_DIR = [io.path]::combine($PROJECT_DIR, "src", "Raven.TestDriver", "bin", "Release")
$SERVER_SRC_DIR = [io.path]::combine($PROJECT_DIR, "src", "Raven.Server")
$SPARROW_SRC_DIR = [io.path]::combine($PROJECT_DIR, "src", "Sparrow")
$SPARROW_OUT_DIR = [io.path]::combine($PROJECT_DIR, "src", "Sparrow", "bin", "Release")
$TYPINGS_GENERATOR_SRC_DIR = [io.path]::combine($PROJECT_DIR, "tools", "TypingsGenerator")
$TYPINGS_GENERATOR_BIN_DIR = [io.path]::combine($TYPINGS_GENERATOR_SRC_DIR, "bin")
$STUDIO_SRC_DIR = [io.path]::combine($PROJECT_DIR, "src", "Raven.Studio")
$STUDIO_OUT_DIR = [io.path]::combine($PROJECT_DIR, "src", "Raven.Studio", "build")
$RVN_SRC_DIR = [io.path]::combine($PROJECT_DIR, "tools", "rvn")
$DRTOOL_SRC_DIR = [io.path]::combine($PROJECT_DIR, "tools", "Voron.Recovery")
if ([string]::IsNullOrEmpty($Target) -eq $false) {
$Target = $Target.Split(",")
} else {
$Target = $null
if ($WinX64) {
$Target = @( "win-x64" );
}
if ($WinX86) {
$Target = @( "win-x86" );
}
if ($LinuxX64) {
$Target = @( "linux-x64" );
}
if ($Osx) {
$Target = @( "osx" );
}
if ($Rpi) {
$Target = @( "rpi" );
}
}
$targets = GetBuildTargets $Target
if ($targets.Count -eq 0) {
write-host "No targets specified."
exit 0;
} else {
Write-Host -ForegroundColor Magenta "Build targets: $($targets.Name)"
}
New-Item -Path $RELEASE_DIR -Type Directory -Force
CleanFiles $RELEASE_DIR
CleanSrcDirs $TYPINGS_GENERATOR_SRC_DIR, $RVN_SRC_DIR, $DRTOOL_SRC_DIR, $SERVER_SRC_DIR, $CLIENT_SRC_DIR, $SPARROW_SRC_DIR, $TESTDRIVER_SRC_DIR
LayoutDockerPrerequisites $PROJECT_DIR $RELEASE_DIR
$versionObj = SetVersionInfo
$version = $versionObj.Version
$versionSuffix = $versionObj.VersionSuffix
$buildNumber = $versionObj.BuildNumber
$buildType = $versionObj.BuildType.ToLower()
Write-Host -ForegroundColor Green "Building $version"
ValidateClientDependencies $CLIENT_SRC_DIR $SPARROW_SRC_DIR
UpdateSourceWithBuildInfo $PROJECT_DIR $buildNumber $version
DownloadDependencies
if ($JustStudio -eq $False) {
BuildSparrow $SPARROW_SRC_DIR
BuildClient $CLIENT_SRC_DIR
BuildTestDriver $TESTDRIVER_SRC_DIR
CreateNugetPackage $CLIENT_SRC_DIR $RELEASE_DIR $versionSuffix
CreateNugetPackage $TESTDRIVER_SRC_DIR $RELEASE_DIR $versionSuffix
}
if ($JustNuget) {
exit 0
}
if (ShouldBuildStudio $STUDIO_OUT_DIR $DontRebuildStudio $DontBuildStudio) {
BuildTypingsGenerator $TYPINGS_GENERATOR_SRC_DIR
BuildStudio $STUDIO_SRC_DIR $version
write-host "Studio built successfully."
} else {
write-host "Not building studio..."
}
if ($JustStudio) {
exit 0
}
Foreach ($target in $targets) {
$specOutDir = [io.path]::combine($OUT_DIR, $target.Name)
CleanDir $specOutDir
BuildServer $SERVER_SRC_DIR $specOutDir $target $Debug
BuildTool rvn $RVN_SRC_DIR $specOutDir $target $Debug
BuildTool drtools $DRTOOL_SRC_DIR $specOutDir $target $Debug
$specOutDirs = @{
"Main" = $specOutDir;
"Client" = $CLIENT_OUT_DIR;
"Server" = $([io.path]::combine($specOutDir, "Server"));
"Rvn" = $([io.path]::combine($specOutDir, "rvn"));
"Studio" = $STUDIO_OUT_DIR;
"Sparrow" = $SPARROW_OUT_DIR;
"Drtools" = $([io.path]::combine($specOutDir, "drtools"));
}
$packOpts = @{
"Target" = $target;
"SkipCopyStudioPackage" = !!$DontBuildStudio;
"DryRunSign" = $DryRunSign;
"VersionInfo" = $versionObj;
"OutDirs" = $specOutDirs;
}
if ($buildNumber -ne $DEV_BUILD_NUMBER -or $buildType -eq 'nightly') {
if ($target.IsUnix -eq $False) {
$serverPath = [io.path]::combine($specOutDirs.Server, "Raven.Server.exe");
$rvnPath = [io.path]::combine($specOutDirs.Rvn, "rvn.exe");
$drtoolsPath = [io.path]::combine($specOutDirs.Drtools, "Voron.Recovery.exe");
SignFile $PROJECT_DIR $serverPath $DryRunSign
SignFile $PROJECT_DIR $rvnPath $DryRunSign
SignFile $PROJECT_DIR $drtoolsPath $DryRunSign
}
}
CreateRavenPackage $PROJECT_DIR $RELEASE_DIR $packOpts
}
write-host "Done creating packages."
if ($buildType -eq 'stable') {
BumpVersion $PROJECT_DIR $versionObj.VersionPrefix $versionObj.BuildType $DryRunVersionBump
}