summaryrefslogtreecommitdiff
path: root/.github/actions/build-windows-deps/action.yml
blob: 0d1dc844ef756faf0741059daf7c82dd0e022268 (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
name: "Build Windows dependencies"
description: "Restore or populate Windows Boost, pFUnit, and Hamlib dependency caches."

inputs:
  boost_version:
    description: "Boost version to build"
    required: false
    default: "1.91.0"
  boost_source_sha256:
    description: "Expected SHA-256 for the Boost source archive"
    required: false
    default: "de5e6b0e4913395c6bdfa90537febd9028ea4c0735d2cdb0cd9b45d5f51264f5"
  windows_api_floor:
    description: "Windows API floor used for Boost and WSJT-X builds"
    required: false
    default: "0x0601"
  hamlib_branch:
    description: "Hamlib branch to build"
    required: true
  cold_build:
    description: "Bypass dependency cache restores and saves"
    required: false
    default: "false"
  save_caches:
    description: "Whether to save dependency caches on misses"
    required: false
    default: "true"

outputs:
  boost_prefix:
    description: "MSYS path to the Boost prefix"
    value: ${{ steps.paths.outputs.boost_prefix }}
  hamlib_prefix:
    description: "MSYS path to the Hamlib prefix"
    value: ${{ steps.paths.outputs.hamlib_prefix }}
  pfunit_dir:
    description: "Directory containing PFUNITConfig.cmake"
    value: ${{ steps.pfunit.outputs.pfunit_dir }}
  gftl_dir:
    description: "Directory containing GFTLConfig.cmake"
    value: ${{ steps.pfunit.outputs.gftl_dir }}
  gftl_shared_dir:
    description: "Directory containing GFTL_SHAREDConfig.cmake"
    value: ${{ steps.pfunit.outputs.gftl_shared_dir }}
  fargparse_dir:
    description: "Directory containing FARGPARSEConfig.cmake"
    value: ${{ steps.pfunit.outputs.fargparse_dir }}

runs:
  using: "composite"
  steps:
    - name: Validate workflow inputs
      shell: bash
      env:
        HAMLIB_BRANCH: ${{ inputs.hamlib_branch }}
      run: .github/scripts/validate-ci-inputs.sh

    - name: Resolve dependency prefixes
      id: paths
      shell: msys2 {0}
      run: |
        WORKSPACE=$(cygpath "${GITHUB_WORKSPACE}")
        {
          echo "boost_prefix=${WORKSPACE}/boost-prefix"
          echo "hamlib_prefix=${WORKSPACE}/hamlib-prefix"
          echo "pfunit_prefix=${WORKSPACE}/pfunit-prefix"
        } >> "$GITHUB_OUTPUT"

    - name: Restore Boost cache
      id: boost-cache
      if: inputs.cold_build != 'true'
      uses: actions/cache/restore@v6
      with:
        path: boost-prefix
        key: boost-windows-windows-latest-mingw64-${{ inputs.boost_version }}-${{ inputs.boost_source_sha256 }}-winapi${{ inputs.windows_api_floor }}-epoch1-${{ hashFiles('.github/scripts/build-boost-windows.sh') }}

    - name: Build Boost
      id: boost-build
      if: steps.boost-cache.outputs.cache-hit != 'true'
      shell: msys2 {0}
      run: .github/scripts/build-boost-windows.sh "${{ inputs.boost_version }}" "${{ inputs.boost_source_sha256 }}" "${{ inputs.windows_api_floor }}" "${{ steps.paths.outputs.boost_prefix }}"

    - name: Save Boost cache
      if: inputs.cold_build != 'true' && inputs.save_caches == 'true' && steps.boost-cache.outputs.cache-hit != 'true'
      uses: actions/cache/save@v6
      with:
        path: boost-prefix
        key: ${{ steps.boost-cache.outputs.cache-primary-key }}

    - name: Verify Boost Windows API floor
      shell: msys2 {0}
      run: |
        boost_dlls=("${{ steps.paths.outputs.boost_prefix }}"/lib/libboost_*.dll)
        if [ ! -e "${boost_dlls[0]}" ]; then
          echo "::error::Boost DLLs not found under ${{ steps.paths.outputs.boost_prefix }}/lib"
          ls -la "${{ steps.paths.outputs.boost_prefix }}/lib" || true
          exit 1
        fi
        bad=0
        for boost_dll in "${boost_dlls[@]}"; do
          echo "Inspecting ${boost_dll}"
          objdump -p "$boost_dll" | awk '/DLL Name:/ {print "  " $3}' | sort -u
          if objdump -p "$boost_dll" | awk '/WaitOnAddress|WakeByAddressSingle|WakeByAddressAll|api-ms-win-core-synch-l1-2-0\.dll/ { found=1; print } END { exit found ? 0 : 1 }'; then
            echo "::error::${boost_dll} imports Windows 8+ synchronization APIs"
            bad=1
          fi
        done
        exit "$bad"

    - name: Locate gfortran
      id: fc
      shell: msys2 {0}
      run: echo "version=$(gfortran -dumpfullversion -dumpversion)" >> "$GITHUB_OUTPUT"

    - name: Restore pFUnit cache
      id: pfunit-cache
      if: inputs.cold_build != 'true'
      uses: actions/cache/restore@v6
      with:
        path: pfunit-prefix
        key: pfunit-windows-windows-latest-mingw64-v4.14.0-gfortran${{ steps.fc.outputs.version }}-epoch1-${{ hashFiles('.github/scripts/build-pfunit-windows.sh') }}

    - name: Build pFUnit
      id: pfunit-build
      if: steps.pfunit-cache.outputs.cache-hit != 'true'
      shell: msys2 {0}
      run: .github/scripts/build-pfunit-windows.sh v4.14.0 "${{ steps.paths.outputs.pfunit_prefix }}"

    - name: Locate pFUnit config
      id: pfunit
      shell: msys2 {0}
      run: |
        for pkg in PFUNIT GFTL GFTL_SHARED FARGPARSE; do
          CONFIG=$(find "${{ steps.paths.outputs.pfunit_prefix }}" -name ${pkg}Config.cmake | head -1)
          if [ -z "$CONFIG" ]; then
            echo "ERROR: ${pkg}Config.cmake not found under pfunit-prefix"
            find "${{ steps.paths.outputs.pfunit_prefix }}" -maxdepth 3 -type d
            exit 1
          fi
          DIR="$(dirname "$CONFIG")"
          echo "Found ${pkg}Config.cmake at: $CONFIG"
          echo "$(echo $pkg | tr '[:upper:]' '[:lower:]')_dir=${DIR}" >> "$GITHUB_OUTPUT"
        done

    - name: Save pFUnit cache
      if: inputs.cold_build != 'true' && inputs.save_caches == 'true' && steps.pfunit-cache.outputs.cache-hit != 'true'
      uses: actions/cache/save@v6
      with:
        path: pfunit-prefix
        key: ${{ steps.pfunit-cache.outputs.cache-primary-key }}

    - name: Restore Hamlib cache
      id: hamlib-cache
      if: inputs.cold_build != 'true'
      uses: actions/cache/restore@v6
      with:
        path: hamlib-prefix
        key: hamlib-windows-windows-latest-mingw64-${{ inputs.hamlib_branch }}-epoch2-${{ hashFiles('.github/scripts/build-hamlib-windows.sh') }}

    - name: Build Hamlib
      id: hamlib-build
      if: steps.hamlib-cache.outputs.cache-hit != 'true'
      shell: msys2 {0}
      env:
        MSYS2_PATH_TYPE: inherit
        HAMLIB_BRANCH: ${{ inputs.hamlib_branch }}
      run: .github/scripts/build-hamlib-windows.sh "$HAMLIB_BRANCH" "${{ steps.paths.outputs.hamlib_prefix }}"

    - name: Verify Hamlib prefix
      shell: msys2 {0}
      run: |
        test -f "${{ steps.paths.outputs.hamlib_prefix }}/bin/libhamlib-4.dll"
        test -f "${{ steps.paths.outputs.hamlib_prefix }}/bin/rigctl.exe"
        test -f "${{ steps.paths.outputs.hamlib_prefix }}/bin/rigctld.exe"
        test -f "${{ steps.paths.outputs.hamlib_prefix }}/bin/rigctlcom.exe"
        test -f "${{ steps.paths.outputs.hamlib_prefix }}/include/hamlib/rig.h"
        test -f "${{ steps.paths.outputs.hamlib_prefix }}/lib/libhamlib.dll.a"

    - name: Save Hamlib cache
      if: inputs.cold_build != 'true' && inputs.save_caches == 'true' && steps.hamlib-cache.outputs.cache-hit != 'true'
      uses: actions/cache/save@v6
      with:
        path: hamlib-prefix
        key: ${{ steps.hamlib-cache.outputs.cache-primary-key }}

    - name: Summarize dependency caches
      if: always()
      shell: bash
      env:
        CACHE_STEPS: ${{ toJSON(steps) }}
        COLD_BUILD: ${{ inputs.cold_build }}
      run: python .github/scripts/summarize-native-caches.py boost hamlib pfunit >> "$GITHUB_STEP_SUMMARY"