forked from dosbox-staging/dosbox-staging
-
Notifications
You must be signed in to change notification settings - Fork 4
252 lines (218 loc) · 8.29 KB
/
windows.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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
name: Windows builds
on: [push, pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build_windows_vs:
name: ${{ matrix.conf.name }}
runs-on: windows-2022
if: github.event_name != 'pull_request' || contains('dreamer,kcgen,ant-222,Wengier', github.actor) == false
strategy:
matrix:
conf:
- name: MSVC 32-bit
arch: x86
#max_warnings: 5
- name: MSVC 64-bit
arch: x64
#max_warnings: 1105
steps:
- name: Backup existing vcpkg installation
shell: pwsh
run: |
mv c:\vcpkg c:\vcpkg-bak
md c:\vcpkg -ea 0
- name: Generate vcpkg cache key
id: prep-vcpkg
shell: bash
run: |
echo "::set-output name=year_and_week::$(date '+%Y%W')"
- name: Cache vcpkg
uses: actions/cache@v2
id: cache-vcpkg
with:
path: c:\vcpkg
key: vcpkg-${{ matrix.conf.arch }}-${{ steps.prep-vcpkg.outputs.year_and_week }}-3
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v1.1
with:
vs-prerelease: true
msbuild-architecture: ${{ matrix.conf.arch }}
- name: Install new packages using vcpkg
if: steps.cache-vcpkg.outputs.cache-hit != 'true'
shell: pwsh
run: |
rm -R c:\vcpkg
c:
cd \
git clone --depth 1 https://github.com/Microsoft/vcpkg.git
cd vcpkg
.\bootstrap-vcpkg.bat
vcpkg install --triplet ${{ matrix.conf.arch }}-windows libpng sdl2 sdl2-net sdl2-mixer libmt32emu opusfile fluidsynth pdcurses gtest
if (-not $?) { throw "vcpkg failed to install library dependencies" }
rm -R c:\vcpkg\buildtrees
rm -R c:\vcpkg\packages
- name: Integrate packages
shell: pwsh
run: |
vcpkg integrate install
if (-not $?) { throw "vcpkg failed to integrate packages" }
- name: Checkout repository
uses: actions/checkout@v2
- name: Log environment
shell: pwsh
run: .\scripts\log-env.ps1
- name: Run tests
shell: pwsh
run: |
cd vs
# TODO: get unit tests working in Debug-mode; for now use release flags (better than nothing)
MSBuild -m dosbox.sln -t:tests:Rebuild -p:Configuration=Release -p:Platform=${{ matrix.conf.arch }}
- name: Build
shell: pwsh
run: |
cd vs
MSBuild -m dosbox.sln -t:dosbox:Rebuild -p:Configuration=Debug -p:Platform=${{ matrix.conf.arch }} | Tee-Object build.log
- name: Summarize warnings
shell: pwsh
#env:
# max_warnings: ${{ matrix.conf.max_warnings }}
run: python scripts\count-warnings.py -f --msvc vs\build.log
build_windows_vs_release:
name: ${{ matrix.conf.name }}
needs: build_windows_vs
runs-on: windows-2022
strategy:
matrix:
conf:
- name: Release build (32-bit)
arch: x86
vs-release-dirname: Win32
- name: Release build (64-bit)
arch: x64
vs-release-dirname: x64
steps:
- name: Prepare vcpkg for cache restore
shell: pwsh
run: |
mv c:\vcpkg c:\vcpkg-bak
md c:\vcpkg -ea 0
- name: Generate vcpkg cache key
id: prep-vcpkg
shell: bash
run: |
echo "::set-output name=year_and_week::$(date '+%Y%W')"
- name: Restore the most recent cache of vcpkg
uses: actions/cache@v2
with:
path: c:\vcpkg
key: vcpkg-${{ matrix.conf.arch }}-${{ steps.prep-vcpkg.outputs.year_and_week }}-3
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v1.1
with:
vs-prerelease: true
msbuild-architecture: ${{ matrix.conf.arch }}
- name: Integrate packages
shell: pwsh
run: |
vcpkg integrate install
if (-not $?) { throw "vcpkg failed to integrate packages" }
- name: Checkout repository
uses: actions/checkout@v2
- name: Log environment
shell: pwsh
run: .\scripts\log-env.ps1
- name: Adjust config.h
shell: bash
run: |
set -x
git fetch --prune --unshallow
export VERSION=$(git describe --abbrev=4)
# inject version based on vcs
sed -i "s|DOSBOX_DETAILED_VERSION \"git\"|DOSBOX_DETAILED_VERSION \"$VERSION\"|" src/platform/visualc/config.h
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Build release
shell: pwsh
run: |
cd vs
MSBuild -m dosbox.sln -t:dosbox:Rebuild -p:Configuration=Release -p:Platform=${{ matrix.conf.arch }}
- name: Package
shell: bash
run: |
# Construct VC_REDIST_DIR
readonly VC_REDIST_BASE="C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Redist/MSVC"
readonly VC_REDIST_VERSION="14.30.30704"
readonly VC_REDIST_CRT_VERSION="Microsoft.VC143.CRT"
export VC_REDIST_DIR="$VC_REDIST_BASE/$VC_REDIST_VERSION/${{ matrix.conf.arch }}/$VC_REDIST_CRT_VERSION"
find "$VC_REDIST_DIR" -maxdepth 3 -type d
# Package
./scripts/create-package.sh \
-p msvc \
vs/${{ matrix.conf.vs-release-dirname }}/Release \
"dest"
- name: Enable the debugger in config.h
shell: bash
run: |
set -x
sed -i "s|C_DEBUG.*|C_DEBUG 1|" src/platform/visualc/config.h
sed -i "s|C_HEAVY_DEBUG.*|C_HEAVY_DEBUG 1|" src/platform/visualc/config.h
- name: Build release with the debugger
shell: pwsh
env:
PATH: '${env:PATH};C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\amd64'
run: |
cd vs
MSBuild -m dosbox.sln -t:dosbox:"Clean;Rebuild" -p:Configuration=Release -p:Platform=${{ matrix.conf.arch }}
- name: Package the debugger
shell: bash
run: |
set -x
# Move the debugger build into the release area
readonly RELEASE_DIR=${{ matrix.conf.vs-release-dirname }}/Release
ls "vs/$RELEASE_DIR"
cp vs/$RELEASE_DIR/dosbox.exe dest/dosbox_with_debugger.exe
cp vs/$RELEASE_DIR/pdcurses.dll dest/
# Create dir for zipping
mv dest dosbox-staging-windows-${{ matrix.conf.arch }}-${{ env.VERSION }}
- name: Windows Defender AV Scan
shell: powershell
run: |
$ErrorActionPreference = 'Stop'
$dosboxDir = "${{ github.workspace }}\dosbox-staging-windows-${{ matrix.conf.arch }}-${{ env.VERSION }}"
& 'C:\Program Files\Windows Defender\MpCmdRun.exe' -Scan -ScanType 3 -DisableRemediation -File $dosboxDir
if( $LASTEXITCODE -ne 0 ) {
Get-Content -Path $env:TEMP\MpCmdRun.log
Throw "Exit $LASTEXITCODE : Windows Defender found an issue"
}
- name: Upload package
uses: actions/upload-artifact@v2
with:
name: dosbox-staging-windows-${{ matrix.conf.arch }}-${{ env.VERSION }}
path: dosbox-staging-windows-${{ matrix.conf.arch }}-${{ env.VERSION }}
# This job exists only to publish an artifact with version info when building
# from main branch, so snapshot build version will be visible on:
# https://dosbox-staging.github.io/downloads/devel/
#
publish_additional_artifacts:
name: Publish additional artifacts
needs: build_windows_vs_release
runs-on: windows-2022
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v2
- name: Generate changelog
shell: bash
run: |
set +x
git fetch --unshallow
VERSION=$(git describe --abbrev=4)
echo "VERSION=$VERSION" >> $GITHUB_ENV
NEWEST_TAG=$(git describe --abbrev=0)
git log "$NEWEST_TAG..HEAD" > changelog-$VERSION.txt
- uses: actions/upload-artifact@v2
with:
# Keep exactly this artifact name; it's being used to propagate
# version info via GitHub REST API
name: changelog-${{ env.VERSION }}.txt
path: changelog-${{ env.VERSION }}.txt