forked from EventStore/EventStore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.ps1
152 lines (131 loc) · 6.33 KB
/
default.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
# Event Store Build (.NET/Windows) - eventstore.ps1
# Use Invoke-psake ? to see further description
Framework "4.0x64"
Task default -depends Build-Quick
Task ? -description "Writes script documentation to the host" {
Write-Host ""
Write-Host "Event Store Build - Main Script"
Write-Host "-------------------------------"
Write-Host ""
Write-Host "This script is used as part of the build for the Event Store on the .NET framework"
Write-Host "on Windows."
Write-Host ""
Write-Host "The script uses the psake PowerShell module, which is included in the Event Store"
Write-Host "repository but can also be found here: http://github.com/psake/psake"
Write-Host ""
Write-Host "IMPORTANT: We default to building X64 in Release mode. The Platform and Configuration"
Write-Host "parameters allow this to be overriden."
Write-Host ""
Write-Host "IMPORTANT: We guess about which platform toolset to use based on observation of"
Write-Host "where various directories are when VS2012, VS2010 or the Windows SDK 7.1 are installed."
Write-Host "If you don't like our guess, pass in the platformToolset parameter with the same value"
Write-Host "as you'd pass to the C++ compiler (e.g. v110, v100 etc)."
Write-Host ""
Write-Host "Tasks:"
Write-Host "------"
Write-Host " Build-Quick - will fail if V8 and JS1 aren't available. Only useful for building"
Write-Host " during development."
Write-Host ""
Write-Host " Build-Incremental - will only build dependencies (V8, JS1) if necessary (only"
Write-Host " cleans the Event Store itself)"
Write-Host ""
Write-Host " Build-Full - will always build dependencies (cleans before building)"
Write-Host ""
Write-Host "Parameters:"
Write-Host "-----------"
Write-Host " version - the semantic version number to apply (e.g. 1.0.2.0). Last digit should"
Write-Host " be 0 (to comply with assembly versioning rules)."
Write-Host ""
Write-Host " platform - target platform. Either x64 (default) or x86."
Write-Host ""
Write-Host " configuration - target configuration. Either release (default) or debug."
Write-Host ""
Write-Host " platformToolset - the platform toolset to use. Default is to detect the latest"
Write-Host " supported version. Valid values are v100, v110, WindowsSDK7.1"
Write-Host ""
}
# Configuration
Properties {
$nativeBuildParameters = @{}
$managedBuildParameters = @{}
$nativeBuildProperties = @{}
$managedBuildProperties = @{}
if ($platform -eq $null) {
Write-Verbose "Platform: defaulting to x64 and Any CPU for managed"
$platform = "x64"
$managedBuildParameters.Add("platform", "Any CPU")
$nativeBuildParameters.Add("platform", "x64")
} else {
Write-Verbose "Platform: set to $platform"
$managedBuildParameters.Add("platform", $platform)
$nativeBuildParameters.Add("platform", $platform)
}
if ($configuration -eq $null) {
Write-Verbose "Configuration: defaulting to Release"
$managedBuildParameters.Add("configuration", "release")
$nativeBuildParameters.Add("configuration", "release")
} else {
Write-Verbose "Configuration: set to $configuration"
$managedBuildParameters.Add("configuration", $configuration)
$nativeBuildParameters.Add("configuration", $configuration)
}
if ($platformToolset -ne $null) {
Write-Verbose "Platform Toolset: set to $platformToolset for native code"
$nativeBuildParameters.Add("platformToolset", $platformToolset)
} else {
Write-Verbose "Platform Toolset will be guessed by a horrible, probably brittle mechanism recommended by MSFT support"
}
if ($version -ne $null) {
Write-Verbose "Version: Set to $version"
$nativeBuildProperties.Add("versionString", $version)
$managedBuildProperties.Add("versionString", $version)
} else {
Write-Verbose "Version: None specified, defaulting to 0.0.0.0"
}
$baseDirectory = Resolve-Path .
$srcDirectory = Join-Path $baseDirectory (Join-Path "src" "EventStore")
$libsDirectory = Join-Path $srcDirectory "libs"
$outputDirectory = Join-Path $baseDirectory "bin\"
$managedBuildParameters.Add("outputDirectory", $outputDirectory)
}
Task Clean-Output {
Remove-Item -Recurse -Force $outputDirectory -ErrorAction SilentlyContinue
}
Task Build-Quick -Depends Clean-Output {
$hasDependencies = (Test-Path (Join-Path $libsDirectory (Join-Path $platform "js1.dll")))
if ($hasDependencies) {
Write-Host "Re-using JS1.dll from a previous build - it is likely to have the wrong commit hash!" -ForegroundColor Yellow
Invoke-psake .\eventstore.ps1 Build-EventStore -parameters $managedBuildParameters -properties $managedBuildProperties -Verbose
} else {
throw "Build-Quick can only be used if a full or incremental build has build JS1.dll and it is in the libs directory"
}
}
Task Build-Incremental -Depends Clean-Output {
if (Test-Dependencies -eq $false)
{
Invoke-psake .\dependencies.ps1 Get-Dependencies -Verbose
}
Invoke-psake .\native-code.ps1 Build-NativeIncremental -parameters $nativeBuildParameters -properties $nativeBuildProperties -Verbose
Invoke-psake .\eventstore.ps1 Build-EventStore -parameters $managedBuildParameters -properties $managedBuildProperties -Verbose
}
Task Build-Full -Depends Clean-Output {
if (Test-Dependencies -eq $false)
{
Invoke-psake .\dependencies.ps1 Get-Dependencies -Verbose
}
Invoke-psake .\native-code.ps1 Build-NativeFull -parameters $nativeBuildParameters -properties $nativeBuildProperties -Verbose
Invoke-psake .\eventstore.ps1 Build-EventStore -parameters $managedBuildParameters -properties $managedBuildProperties -Verbose
}
#--------------------------------------------------------------------------
# Helper Functions
Function Test-Dependencies
{
# This is a derp, using exceptions for flow control. If you can think
# of a better way for this, pull request plz.
try {
Invoke-psake .\dependencies.ps1 Test-Dependencies -Verbose
return $true
} catch {
return $false
}
}