Welcome to mirror list, hosted at ThFree Co, Russian Federation.

windows-msys2.yml « workflows « .github - github.com/dosbox-staging/dosbox-staging.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e6ce27e70ab70594979020a0f676d2b632ea0bb8 (plain)
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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
name: Windows MSYS2 builds

on: [push, pull_request]

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

env:
  CCACHE_DIR:      "/c/ccache"
  CCACHE_MAXSIZE:  "64M"
  CCACHE_COMPRESS: "true"
  BUILD_RELEASE_DIR: build/release
  BUILD_DEBUGGER_DIR: build/debugger

jobs:
  build_msys2:
    name: ${{ matrix.conf.name }}
    runs-on: windows-latest
    if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository

    strategy:
      matrix:
        conf:
          - name: GCC (MinGW) x86 +tests
            toolchain: ""
            arch: i686
            sys: MINGW32
            cc: gcc
            max_warnings: 0
            run_tests: true
            build_flags: -Dbuildtype=debug

          - name: GCC (UCRT) x86_64 +debugger
            toolchain: ucrt-
            arch: x86_64
            sys: UCRT64
            cc: gcc
            max_warnings: 0
            build_flags: -Denable_debugger=normal

          - name: Clang x86_64 +debugger
            toolchain: clang-
            arch: x86_64
            sys: CLANG64
            cc: clang
            max_warnings: 1
            build_flags: -Denable_debugger=normal

          - name: Clang x86_64 +tests
            toolchain: clang-
            arch: x86_64
            sys: CLANG64
            cc: clang
            max_warnings: 0
            run_tests: true
            build_flags: -Dbuildtype=debug

    defaults:
      run:
        shell: msys2 {0}

    steps:
      - name: Disable git line ending conversion
        shell: powershell
        run: |
          git config --global core.autocrlf false
          git config --global core.eol lf

      - name: Checkout repository
        uses: actions/checkout@v3
        with:
          submodules: false

      - name: Setup MSYS2 and install packages
        uses: msys2/setup-msys2@v2
        with:
          msystem: ${{matrix.conf.sys}}
          update: true
          install: >-
            mingw-w64-${{matrix.conf.toolchain}}${{matrix.conf.arch}}-${{matrix.conf.cc}}
            mingw-w64-${{matrix.conf.toolchain}}${{matrix.conf.arch}}-meson
            mingw-w64-${{matrix.conf.toolchain}}${{matrix.conf.arch}}-ccache
            mingw-w64-${{matrix.conf.toolchain}}${{matrix.conf.arch}}-pkgconf
            mingw-w64-${{matrix.conf.toolchain}}${{matrix.conf.arch}}-ntldd
            mingw-w64-${{matrix.conf.toolchain}}${{matrix.conf.arch}}-ncurses
            mingw-w64-${{matrix.conf.toolchain}}${{matrix.conf.arch}}-glib2
            mingw-w64-${{matrix.conf.toolchain}}${{matrix.conf.arch}}-libpng
            mingw-w64-${{matrix.conf.toolchain}}${{matrix.conf.arch}}-opusfile
            mingw-w64-${{matrix.conf.toolchain}}${{matrix.conf.arch}}-libslirp
            mingw-w64-${{matrix.conf.toolchain}}${{matrix.conf.arch}}-SDL2
            mingw-w64-${{matrix.conf.toolchain}}${{matrix.conf.arch}}-SDL2_net
            mingw-w64-${{matrix.conf.toolchain}}${{matrix.conf.arch}}-zlib
            mingw-w64-${{matrix.conf.toolchain}}${{matrix.conf.arch}}-speexdsp

      - name:  Prepare compiler cache
        id:    prep-ccache
        run: |
          mkdir -p "${CCACHE_DIR}"
          echo "dir=$(cygpath -w $CCACHE_DIR)"                                   >> $GITHUB_OUTPUT
          echo "today=$(date -I)"                                                >> $GITHUB_OUTPUT
          echo "yesterday=$(date --date=yesterday -I)"                           >> $GITHUB_OUTPUT
          echo "name_hash=$(echo '${{ matrix.conf.name }}' | shasum | cut -b-8)" >> $GITHUB_OUTPUT

      - uses:  actions/cache@v3.0.11
        id:    cache-ccache
        with:
          path: ${{ steps.prep-ccache.outputs.dir }}
          key:  ccache-msys2-${{ matrix.conf.sys }}-${{ steps.prep-ccache.outputs.name_hash }}-${{ steps.prep-ccache.outputs.today }}-3
          restore-keys: |
            ccache-msys2-${{ matrix.conf.sys }}-${{ steps.prep-ccache.outputs.name_hash }}-${{ steps.prep-ccache.outputs.yesterday }}-3

      - name:  Cache subprojects
        uses:  actions/cache@v3.0.11
        with:
          path: subprojects/packagecache
          key:  subprojects-${{ hashFiles('subprojects/*.wrap') }}-3

      - name: Log environment
        run:  ./scripts/log-env.sh

      - name: Setup build
        run: |
          meson setup ${{ matrix.conf.build_flags }} build

      - name: Build
        run: |
          set -xo pipefail
          scripts/retry_command.sh 10 meson compile -C build |& tee build.log
          ccache -s
          #
          # Reason for retry is due to intermittent Python symbol extractor failure
          # under MSYS2 reported in bug: https://github.com/msys2/MINGW-packages/issues/11864

      - name: Run tests
        if:   matrix.conf.run_tests
        run:  meson test --num-processes 128 -t 0 -C build --print-errorlogs

      - name: Summarize warnings
        if:   matrix.conf.run_tests != true
        env:
          MAX_WARNINGS: ${{ matrix.conf.max_warnings }}
        run:  python ./scripts/count-warnings.py -lf build.log

  build_msys2_release:
    name: ${{ matrix.conf.name }} Release
    runs-on: windows-latest
    if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository

    strategy:
      matrix:
        conf:
          - name: Clang x86_64
            arch: x86_64
            sys: CLANG64

    defaults:
      run:
        shell: msys2 {0}

    steps:
      - name: Disable git line ending conversion
        shell: powershell
        run: |
          git config --global core.autocrlf false
          git config --global core.eol lf

      - name: Checkout repository
        uses: actions/checkout@v3
        with:
          submodules: false

      - name: Setup MSYS2
        uses: msys2/setup-msys2@v2
        with:
          msystem: ${{matrix.conf.sys}}
          update: true
          install: |
            git
            mingw-w64-clang-${{matrix.conf.arch}}-clang
            mingw-w64-clang-${{matrix.conf.arch}}-meson
            mingw-w64-clang-${{matrix.conf.arch}}-ccache
            mingw-w64-clang-${{matrix.conf.arch}}-pkgconf
            mingw-w64-clang-${{matrix.conf.arch}}-ntldd
            mingw-w64-clang-${{matrix.conf.arch}}-ncurses
            mingw-w64-clang-${{matrix.conf.arch}}-glib2
            mingw-w64-clang-${{matrix.conf.arch}}-libpng
            mingw-w64-clang-${{matrix.conf.arch}}-opusfile
            mingw-w64-clang-${{matrix.conf.arch}}-libslirp
            mingw-w64-clang-${{matrix.conf.arch}}-SDL2
            mingw-w64-clang-${{matrix.conf.arch}}-SDL2_net
            mingw-w64-clang-${{matrix.conf.arch}}-zlib
            mingw-w64-clang-${{matrix.conf.arch}}-speexdsp

      - name:  Prepare compiler cache
        id:    prep-ccache
        run: |
          mkdir -p "${CCACHE_DIR}"
          echo "dir=$(cygpath -w $CCACHE_DIR)"         >> $GITHUB_OUTPUT
          echo "today=$(date -I)"                      >> $GITHUB_OUTPUT
          echo "yesterday=$(date --date=yesterday -I)" >> $GITHUB_OUTPUT

      - uses:  actions/cache@v3.0.11
        id:    cache-ccache
        with:
          path: ${{ steps.prep-ccache.outputs.dir }}
          key:  ccache-msys2-${{matrix.conf.sys}}-release-${{ steps.prep-ccache.outputs.today }}-3
          restore-keys: |
            ccache-msys2-${{matrix.conf.sys}}-release-${{ steps.prep-ccache.outputs.yesterday }}-3

      - name:  Cache subprojects
        uses:  actions/cache@v3.0.11
        with:
          path: subprojects/packagecache
          key:  subprojects-${{ hashFiles('subprojects/*.wrap') }}-3

      - name: Log environment
        run:  ./scripts/log-env.sh

      - name: Inject version string
        run: |
          set -x
          git fetch --prune --unshallow
          export VERSION=$(git describe --abbrev=5)
          echo "VERSION=$VERSION" >> $GITHUB_ENV

      - name: Inject package name
        run: |
          set -x
          echo "PKG_RELEASE=dosbox-staging-windows-msys2-${{ matrix.conf.arch }}-${{ env.VERSION }}" >> $GITHUB_ENV

      - name: Setup release build
        run: meson setup -Ddefault_library=static -Db_lto=true -Db_lto_threads=$(nproc) $BUILD_RELEASE_DIR

      - name: Setup debugger build
        run: meson setup -Ddefault_library=static -Db_lto=true -Db_lto_threads=$(nproc) -Denable_debugger=normal $BUILD_DEBUGGER_DIR

      - name: Build release
        run: |
          set -euo pipefail
          scripts/retry_command.sh 2 meson compile -C $BUILD_RELEASE_DIR
          #
          # Reason for retry is due to intermittent Python symbol extractor failure
          # under MSYS2 reported in bug: https://github.com/msys2/MINGW-packages/issues/11864

      - name: Build debugger
        run: |
          set -euo pipefail
          scripts/retry_command.sh 2 meson compile -C $BUILD_DEBUGGER_DIR
          #
          # Reason for retry is due to intermittent Python symbol extractor failure
          # under MSYS2 reported in bug: https://github.com/msys2/MINGW-packages/issues/11864

      - name: Package
        run: |
          # Package the debug build to bring in required dependencies such as ncurses
          ./scripts/create-package.sh \
            -p msys2 \
            "$BUILD_DEBUGGER_DIR" \
            "$PKG_RELEASE"
          mv "${PKG_RELEASE}/dosbox.exe" "${PKG_RELEASE}/dosbox_with_debugger.exe"
          install -DT "${BUILD_RELEASE_DIR}/dosbox.exe" "${PKG_RELEASE}/dosbox.exe"
          echo "artifact_name=dosbox-staging-windows-x64-`git describe --abbrev=4`" >> $GITHUB_ENV
          echo "artifact_path=${{ github.workspace }}\msvc" >> $GITHUB_ENV

      - name: Windows Defender AV Scan
        shell: powershell
        run: |
          $ErrorActionPreference = 'Stop'
          $dosboxDir = "${{ github.workspace }}\${{ env.PKG_RELEASE }}"
          & '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: Wait for MSVC builds to complete
        uses: fountainhead/action-wait-for-check@v1.1.0
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          checkName: Publish additional Windows artifacts
          ref: ${{ github.event.pull_request.head.sha || github.sha }}

      - name: Download MSVC artifact
        uses: dawidd6/action-download-artifact@v2
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          workflow: windows-msvc.yml
          name: ${{ env.artifact_name }}
          path: ${{ env.artifact_path }}
          if_no_artifact_found: warn

      - name: Prepare Windows installer
        shell: bash
        run: |
          if [[ "${{ github.ref }}" == "refs/tags/"* ]] && [[ "${{ github.ref }}" != *"-"* ]]; then
            version_tag=`echo ${{ github.ref }} | sed -r 's/([^\/]*\/){2}//'`
            packageinfo="release $version_tag"
          elif [[ "${{ github.ref }}" == "refs/heads/release/"* ]]; then
            version_tag=`git describe --tags | cut -f1 -d"-"`
            packageinfo="release $version_tag"
          elif [ -n "${{ github.ref }}" ] && [ -n "${{ github.sha }}" ]; then
            git_branch=`echo ${{ github.ref }} | sed -r 's/([^\/]*\/){2}//'`
            git_commit=`echo ${{ github.sha }} | awk '{print substr($0,1,9);exit}'`
            packageinfo="a development branch named $git_branch with commit $git_commit"
          else
            packageinfo="a development branch"
          fi
          mkdir out
          echo "version_number=`git describe --tags --abbrev=4`" >> $GITHUB_ENV
          sed -e "s|%PACKAGE_INFORMATION%|${packageinfo}|;s|%GITHUB_REPO%|${{ github.repository }}|" docs/README.template >out/setup_preamble.txt
          sed -i "s|DOSBOX-STAGING-VERSION|`git describe --tags --abbrev=4`|" contrib/windows_installer/DOSBox-Staging-setup.iss
          echo @echo off >out/dosbox_with_console.bat
          echo \"%~dp0\\dosbox.exe\" %* >>out/dosbox_with_console.bat
          echo if errorlevel 1 pause >>out/dosbox_with_console.bat
          if [ -d msvc ]; then
            cp msvc/dosbox*.exe out
            mv out/dosbox.exe out/dosbox_msvc.exe
            mv out/dosbox_with_debugger.exe out/dosbox_msvc_with_debugger.exe
          else
            echo Note: MSVC build will not be included in the Windows installer.
            sed -i -e 's|^\(Name: \"defaultmsvc\"\)|;\1|;s|^\(Source: \"{#DOSBoxAppExeMSVC\)|;\1|;s|; Tasks: not defaultmsvc$||' contrib/windows_installer/DOSBox-Staging-setup.iss
          fi

      - name: Build Windows installer
        shell: pwsh
        run: |
          cd out
          mkdir program
          copy ${{ github.workspace }}\contrib\windows_installer\* .
          copy ${{ github.workspace }}\contrib\icons\dosbox-staging.ico .
          copy ${{ github.workspace }}\contrib\icons\dosbox-staging.bmp .
          copy ${{ github.workspace }}\contrib\icons\dosbox-staging-side.bmp .
          xcopy /s ${{ github.workspace }}\${{ env.PKG_RELEASE }}\* program
          replace /a ..\msvc\*.dll program
          move program\dosbox.exe .
          move program\dosbox_with_debugger.exe .
          C:\PROGRA~2\INNOSE~1\ISCC.exe DOSBox-Staging-setup.iss

      - name: Upload package
        uses: actions/upload-artifact@v3
        with:
          name: ${{ env.PKG_RELEASE }}
          path: ${{ env.PKG_RELEASE }}

      - name: Upload installer
        uses: actions/upload-artifact@v3
        with:
          name: dosbox-staging-${{ env.version_number }}-setup.exe
          path: ${{ github.workspace }}\out\dosbox-staging-${{ env.version_number }}-setup.exe

  # 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_msys2_release
    runs-on: windows-latest
    if: github.event_name == 'push' && github.ref == 'refs/heads/main'
    steps:
      - uses: actions/checkout@v3
        with:
          submodules: false

      - 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@v3
        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