-
Notifications
You must be signed in to change notification settings - Fork 27
/
appveyor.yml
209 lines (183 loc) · 10.2 KB
/
appveyor.yml
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# See https://www.appveyor.com/docs/build-environment/
image: Visual Studio 2019
version: '{build}'
install:
# Set up Visual Studio build environment, 32-bit output with a 64-bit builder
# > Increment version number when newer version of Visual Studio supported by Appveyor
- cmd: '"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build/vcvarsall.bat" amd64_x86'
# Set up Conan package manager
- ps: |
# Get Python 3 'Scripts' path
#
# Find the Python 3 interpreter, get the directory name, then append "Scripts" to it
# Capture this output within PowerShell as a single string (without trailing newline)
#
# See https://stackoverflow.com/questions/8097354/how-do-i-capture-the-output-into-a-variable-from-an-external-process-in-powershe
$pythonCmdOutput = (py -3 -c "import os, sys; print(os.path.join(os.path.dirname(sys.executable), 'Scripts'), end='')") -join "`n"
# Sanity-check that directory exists
if (Test-Path "$pythonCmdOutput" -PathType Container) {
echo "Python 3 path found: '$pythonCmdOutput'"
} else {
Throw "Could not find Python 3 path, non-existent response: '$pythonCmdOutput'"
# Stops the build
}
# Add to path (semicolon is separator)
$env:PATH += ";$pythonCmdOutput"
# Specifically use Python 3's "pip" to install Conan
- cmd: py.exe -3 -m pip install conan==1.62.0
- cmd: conan user # Create conan data directory
- cmd: conan --version
- cmd: choco install doxygen.install
cache:
# Keep a copy of Conan's build results, speeding up OpenSSL rebuilds
#
# NOTE: AppVeyor limits available cache storage across ALL projects in a given
# account. If build cache takes up too much space, consider dropping it.
#
# See https://www.appveyor.com/docs/build-cache/
- C:\Users\Appveyor\.conan -> appveyor.yml, conanfile.txt
# OpenSSL package does NOT have "short_paths=True", so the following is not needed.
# If future OpenSSL versions aren't stored in "C:\Users\appveyor\.conan\data\openssl"
# this cache location may need enabled.
#
# See https://github.com/bincrafters/community/issues/134 "Caching conan (boost) packages on appveyor"
#- C:\.conan -> appveyor.yml, conanfile.txt
init:
# Set "build version number" to "short-commit-hash" or when tagged to "tag name" (Travis style)
# Thanks to @jakoch and @ronaldbarendse
# Modified to also include the build number, distinguishes rebuilds of the same commit
# See comments on https://github.com/appveyor/ci/issues/691
#
# While it's possible to use 'Update-AppveyorBuild -Version' to change the build number, that
# breaks Github's "Details" link until the build completes. Just change the build output.
- ps: |
if ($env:APPVEYOR_REPO_TAG -eq "true")
{
# Trim any starting 'v' from tags
$env:DEPLOY_IMAGE_NAME = "$($env:APPVEYOR_REPO_TAG_NAME.TrimStart("v"))-$env:APPVEYOR_BUILD_NUMBER"
} else {
$env:DEPLOY_IMAGE_NAME = "dev-$($env:APPVEYOR_REPO_COMMIT.Substring(0, 8))-$env:APPVEYOR_BUILD_NUMBER"
}
function ConvertMarkdownToHtml([String] $InputFile, [String] $OutputDir) {
# Find the filename without path
$filename = Split-Path $InputFile -leaf
# Convert to Markdown
# See https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/convertfrom-markdown
# Convert ".md" links to ".md.htm", ensuring filename starts with a letter/number
# Check if we're running on PowerShell 7 or newer
if ($PSVersionTable.PSVersion -ge [Version]::new(7, 0, 0)) {
# ConvertFrom-Markdown is native
(ConvertFrom-Markdown -Path "$InputFile").Html | % {$_ -replace "<a href=""(\w.*)\.md(#.*)?"">", "<a href=""`$1.md.htm`$2"">"} | Out-File "$OutputDir/$filename.htm"
} else {
# Send to the AppVeyor PowerShell 7 program
# Don't use a PowerShell Script Block as it prevents parameters from being substituted in
& "C:\Program Files\PowerShell\7\pwsh.exe" -Command @"
(ConvertFrom-Markdown -Path ""$InputFile"").Html | % {`$_ -replace ""<a href=""""(\w.*)\.md(#.*)?"""">"", ""<a href=""""```$1.md.htm```$2"""">""} | Out-File ""$OutputDir/$filename.htm""
"@
}
}
build_script:
- ps: |
# Install Conan dependencies for 32-bit (x86) using the local directory's conanfile
#
# NOTE: "--build=missing" may increase build time if not in cache!
#
# If x86 packages of OpenSSL are available in the future, this can safely be removed,
# turning this back into an error message instead of building from source.
conan install . --settings arch=x86 --build=missing
# > For statically-linked OpenSSL, specify: -s compiler="Visual Studio" -s compiler.runtime=MT
# Then modify makefile.win to reference ..MT.lib instead. Dynamic linking is preferred.
# Set up the variables for makefile.win
$env:OUTDIR = "$env:APPVEYOR_BUILD_FOLDER/build"
# Conan.io exports outputs to here, including OpenSSL
$env:PACKAGE_DIR = "$env:APPVEYOR_BUILD_FOLDER/bin"
# Build Fuzzball
# > NMake writes to standard error for the version header when it's not actually an error.
# Treat all output as standard output instead.
# See https://stackoverflow.com/questions/2095088/error-when-calling-3rd-party-executable-from-powershell-when-using-an-ide
cmd /c 'nmake /f %APPVEYOR_BUILD_FOLDER%/makefile.win 2>&1'
# Stop build if failed
if ($LastExitCode -ne 0) {
# NOTE: $LastExitCode only applies to native commands, not PowerShell commands!
# See https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_automatic_variables?view=powershell-7.1#lastexitcode
echo "Build command exit code not zero: $LastExitCode"
Throw "Could not compile Fuzzball, build failed"
# Throw stops execution
}
# Package and store the build results
# > File name of compressed output
$artifact_name = "fuzzball-win32-$env:DEPLOY_IMAGE_NAME"
# > Folder name stored inside compressed output
# Don't include "...-$env:APPVEYOR_BUILD_VERSION" as that's now part of the artifact name
$artifact_root = "$env:APPVEYOR_BUILD_FOLDER/$artifact_name"
# > Exact filename for compressed output (change extension for different format)
$artifact_zip = "$artifact_name.zip"
$docs_zip = "$artifact_name-docs.zip"
echo "Preparing release artifact..."
mkdir "$artifact_root"
# Copy contents of game folder
cp -Recurse "$env:APPVEYOR_BUILD_FOLDER/game/*" "$artifact_root"
# Remove Unix "restart.in" if copied
if (Test-Path "$artifact_root/restart.in") {
Remove-Item "$artifact_root/restart.in"
}
# Copy starter database folder
cp -Recurse "$env:APPVEYOR_BUILD_FOLDER/dbs" "$artifact_root"
# Copy documentation folders
cp -Recurse "$env:APPVEYOR_BUILD_FOLDER/docs" "$artifact_root"
md "$artifact_root/data/info"
cp "$env:APPVEYOR_BUILD_FOLDER/docs/mpi-intro" "$artifact_root/data/info"
cp "$env:APPVEYOR_BUILD_FOLDER/docs/mpi-intro2" "$artifact_root/data/info"
cp "$env:APPVEYOR_BUILD_FOLDER/docs/muf-tutorial" "$artifact_root/data/info"
cp "$env:APPVEYOR_BUILD_FOLDER/docs/changesfb7" "$artifact_root/data/info"
# Copy source and include folder
cp -Recurse "$env:APPVEYOR_BUILD_FOLDER/src" "$artifact_root"
cp -Recurse "$env:APPVEYOR_BUILD_FOLDER/include" "$artifact_root"
# Copy Windows source
cp -Recurse "$env:APPVEYOR_BUILD_FOLDER/win32" "$artifact_root"
# Copy text help files to data folder
cp "$artifact_root/docs/*.txt" "$artifact_root/data/"
# Copy README files, transforming to Windows line endings
# See https://stackoverflow.com/questions/17579553/windows-command-to-convert-unix-line-endings/17580505#17580505
#
(Get-Content "$env:APPVEYOR_BUILD_FOLDER/README.md") | Set-Content "$artifact_root/README.md.txt"
(Get-Content "$env:APPVEYOR_BUILD_FOLDER/README_WINDOWS.md") | Set-Content "$artifact_root/README_WINDOWS.md.txt"
#
# Also render the Markdown into an HTML file for easier reference
ConvertMarkdownToHtml "$env:APPVEYOR_BUILD_FOLDER/README.md" "$artifact_root"
ConvertMarkdownToHtml "$env:APPVEYOR_BUILD_FOLDER/README_WINDOWS.md" "$artifact_root"
# Copy compiled binaries and libraries
cp -Recurse "$env:APPVEYOR_BUILD_FOLDER/build/*" "$artifact_root"
# Build docs
& "c:\program files\doxygen\bin\doxygen.exe" "$env:APPVEYOR_BUILD_FOLDER/Doxyfile"
# Verify basics and make the archive
if ((Test-Path "$artifact_root/fbmuck.exe") -And (Test-Path "$artifact_root/restart.exe")) {
echo "Packaging release artifact..."
7z a "$artifact_zip" "$artifact_root"
7z a "$docs_zip" "$env:APPVEYOR_BUILD_FOLDER/api-docs"
Push-AppveyorArtifact "$artifact_zip"
Push-AppveyorArtifact "$docs_zip"
echo "Packaging successful!"
} else {
Throw "Could not find compiled Fuzzball or related executables, build failed"
}
# Guidance for future maintainers: Powershell versus Windows Command Interpreter
# Environment variables
# > Powershell: $env:NAME
# > cmd: %NAME%
# Quoting
# > Powershell: $env:NAME = "TEST"
# echo "Test message"
# > cmd: set NAME=TEST
# echo Test message
# Running programs with spaces
# > Powershell: & "C:\path to\app.exe" Argument1 Argument2
# > cmd: "C:\path to\app.exe" Argument1 Argument2
# (No difference if without spaces)
# Running programs in current directory
# > Powershell: .\app.exe
# > cmd: app.exe
# Paths
# > Powershell: 'C:/path/to/file' or 'C:\path\to\file'
# > cmd: 'C:\path\to\file' only
# Thanks to TheOneRing (Freenode #quassel, Github) for initial help with setting up Appveyor