|
1 | | -name: Build SMF plugin |
| 1 | +# Copyright 2025 Solace Corporation. All rights reserved. |
2 | 2 |
|
| 3 | +name: Build Plugin |
3 | 4 | on: |
4 | 5 | push: |
5 | 6 | branches: |
6 | 7 | - main |
| 8 | + |
7 | 9 | workflow_dispatch: |
8 | 10 | inputs: |
9 | | - MAJOR_VERSION: |
10 | | - description: "Major version of the wireshark tag to use when building plugin" |
11 | | - required: false |
12 | | - default: '' |
13 | | - MINOR_VERSION: |
14 | | - description: "Minor version of the wireshark tag to use when building plugin" |
15 | | - required: false |
16 | | - default: '' |
17 | | - PATCH_VERSION: |
18 | | - description: "Patch version of the wireshark tag to use when building plugin" |
19 | | - required: false |
20 | | - default: '' |
21 | | - SMF_PLUGIN_PATCH_VERSION: |
22 | | - description: "PATCH for SMF plugin" |
23 | | - type: string |
24 | | - required: true |
25 | | - default: '' |
| 11 | + version_major: |
| 12 | + description: "Major version of the wireshark tag to use when building the plugin" |
| 13 | + type: string |
| 14 | + required: true |
| 15 | + default: '4' |
| 16 | + version_minor: |
| 17 | + description: "Minor version of the wireshark tag to use when building the plugin" |
| 18 | + type: string |
| 19 | + required: true |
| 20 | + default: '6' |
| 21 | + version_patch: |
| 22 | + description: "Patch version of the wireshark tag to use when building the plugin" |
| 23 | + type: string |
| 24 | + required: true |
| 25 | + default: '1' |
| 26 | + version_extra: |
| 27 | + description: "Extra version for the SMF plugin" |
| 28 | + type: string |
| 29 | + required: true |
| 30 | + default: '0' |
| 31 | + build_linux: |
| 32 | + description: 'Build for Linux' |
| 33 | + type: boolean |
| 34 | + default: true |
| 35 | + build_windows: |
| 36 | + description: 'Build for Windows' |
| 37 | + type: boolean |
| 38 | + default: true |
| 39 | + build_macos: |
| 40 | + description: 'Build for MacOS' |
| 41 | + type: boolean |
| 42 | + default: true |
| 43 | + |
| 44 | + workflow_call: |
| 45 | + inputs: |
| 46 | + version_major: |
| 47 | + type: string |
| 48 | + required: true |
| 49 | + version_minor: |
| 50 | + type: string |
| 51 | + required: true |
| 52 | + version_patch: |
| 53 | + type: string |
| 54 | + required: true |
| 55 | + version_extra: |
| 56 | + type: string |
| 57 | + required: true |
| 58 | + build_linux: |
| 59 | + type: boolean |
| 60 | + default: true |
| 61 | + build_windows: |
| 62 | + type: boolean |
| 63 | + default: true |
| 64 | + build_macos: |
| 65 | + type: boolean |
| 66 | + default: true |
| 67 | + |
26 | 68 | jobs: |
27 | | - # Commenting out intel mac for regular builds as it is currently broken. |
28 | | - #build_macos: |
29 | | - # uses: ./.github/workflows/macos.yml |
30 | | - # with: |
31 | | - # MAJOR_VERSION: ${{ inputs.MAJOR_VERSION || '4' }} |
32 | | - # MINOR_VERSION: ${{ inputs.MINOR_VERSION || '0' }} |
33 | | - # PATCH_VERSION: ${{ inputs.PATCH_VERSION || '5' }} |
34 | | - build_macos_arm64: |
35 | | - uses: ./.github/workflows/macos_arm64.yml |
36 | | - with: |
37 | | - MAJOR_VERSION: ${{ inputs.MAJOR_VERSION || '4' }} |
38 | | - MINOR_VERSION: ${{ inputs.MINOR_VERSION || '6' }} |
39 | | - PATCH_VERSION: ${{ inputs.PATCH_VERSION || '0' }} |
40 | | - SMF_PLUGIN_PATCH_VERSION: ${{ inputs.SMF_PLUGIN_PATCH_VERSION || 'dev' }} |
41 | | - build_windows: |
42 | | - uses: ./.github/workflows/windows.yml |
43 | | - with: |
44 | | - MAJOR_VERSION: ${{ inputs.MAJOR_VERSION || '4' }} |
45 | | - MINOR_VERSION: ${{ inputs.MINOR_VERSION || '6' }} |
46 | | - PATCH_VERSION: ${{ inputs.PATCH_VERSION || '0' }} |
47 | | - # this goes into FILEVERSION which appears when you hover over the DLL, but cannot |
48 | | - # contain a string like "dev" |
49 | | - SMF_PLUGIN_PATCH_VERSION: ${{ inputs.SMF_PLUGIN_PATCH_VERSION || '-1' }} |
50 | | - build_linux: |
51 | | - uses: ./.github/workflows/ubuntu.yml |
52 | | - with: |
53 | | - MAJOR_VERSION: ${{ inputs.MAJOR_VERSION || '4' }} |
54 | | - MINOR_VERSION: ${{ inputs.MINOR_VERSION || '6' }} |
55 | | - PATCH_VERSION: ${{ inputs.PATCH_VERSION || '0' }} |
56 | | - SMF_PLUGIN_PATCH_VERSION: ${{ inputs.SMF_PLUGIN_PATCH_VERSION || 'dev' }} |
| 69 | + setup: |
| 70 | + name: Setup Build Parameters |
| 71 | + runs-on: ubuntu-latest |
| 72 | + outputs: |
| 73 | + version_major: ${{ steps.defaults.outputs.version_major }} |
| 74 | + version_minor: ${{ steps.defaults.outputs.version_minor }} |
| 75 | + version_patch: ${{ steps.defaults.outputs.version_patch }} |
| 76 | + version_extra: ${{ steps.defaults.outputs.version_extra }} |
| 77 | + build_linux: ${{ steps.defaults.outputs.build_linux }} |
| 78 | + build_windows: ${{ steps.defaults.outputs.build_windows }} |
| 79 | + build_macos: ${{ steps.defaults.outputs.build_macos }} |
| 80 | + matrix: ${{ steps.set-matrix.outputs.matrix }} |
| 81 | + steps: |
| 82 | + - name: Set defaults |
| 83 | + id: defaults |
| 84 | + run: | |
| 85 | + echo "version_major=${{ inputs.version_major || '4' }}" >> $GITHUB_OUTPUT |
| 86 | + echo "version_minor=${{ inputs.version_minor || '6' }}" >> $GITHUB_OUTPUT |
| 87 | + echo "version_patch=${{ inputs.version_patch || '1' }}" >> $GITHUB_OUTPUT |
| 88 | + echo "version_extra=${{ inputs.version_extra || '0' }}" >> $GITHUB_OUTPUT |
| 89 | + echo "build_linux=${{ inputs.build_linux || 'true' }}" >> $GITHUB_OUTPUT |
| 90 | + echo "build_windows=${{ inputs.build_windows || 'true' }}" >> $GITHUB_OUTPUT |
| 91 | + echo "build_macos=${{ inputs.build_macos || 'true' }}" >> $GITHUB_OUTPUT |
| 92 | +
|
| 93 | + - name: Set OS Matrix |
| 94 | + id: set-matrix |
| 95 | + run: | |
| 96 | + ALL_OS='[ |
| 97 | + { |
| 98 | + "name": "linux", |
| 99 | + "pretty-name": "Linux", |
| 100 | + "runner": "ubuntu-22.04", |
| 101 | + "deps": "sudo wireshark-src/tools/debian-setup.sh", |
| 102 | + "artifact": "wireshark-smf-linux-x86_64.tar.gz" |
| 103 | + }, |
| 104 | + { |
| 105 | + "name": "windows", |
| 106 | + "pretty-name": "Windows", |
| 107 | + "runner": "windows-2022", |
| 108 | + "deps": "choco install winflexbison3 --no-progress", |
| 109 | + "c-flags": "/std:c11", |
| 110 | + "artifact": "wireshark-smf-windows-x64.zip" |
| 111 | + }, |
| 112 | + { |
| 113 | + "name": "macos", |
| 114 | + "pretty-name": "MacOS", |
| 115 | + "runner": "macos-14", |
| 116 | + "deps": "wireshark-src/tools/macos-setup-brew.sh --install-required", |
| 117 | + "artifact": "wireshark-smf-macos-arm64.tar.gz" |
| 118 | + } |
| 119 | + ]' |
| 120 | +
|
| 121 | + MATRIX=$(echo "$ALL_OS" | jq -c '[.[] | select( |
| 122 | + (.name == "linux" and "${{ steps.defaults.outputs.build_linux }}" == "true") or |
| 123 | + (.name == "windows" and "${{ steps.defaults.outputs.build_windows }}" == "true") or |
| 124 | + (.name == "macos" and "${{ steps.defaults.outputs.build_macos }}" == "true") |
| 125 | + )]') |
| 126 | +
|
| 127 | + echo "matrix=$MATRIX" >> $GITHUB_OUTPUT |
| 128 | +
|
| 129 | + build_plugin: |
| 130 | + needs: setup |
| 131 | + strategy: |
| 132 | + matrix: |
| 133 | + os: ${{ fromJson(needs.setup.outputs.matrix) }} |
| 134 | + name: Build on ${{ matrix.os.pretty-name }} |
| 135 | + env: |
| 136 | + WIRESHARK_BASE_DIR: ${{ github.workspace }}/wireshark-libs |
| 137 | + runs-on: ${{ matrix.os.runner }} |
| 138 | + steps: |
| 139 | + - name: Checkout |
| 140 | + uses: actions/checkout@v6 |
| 141 | + |
| 142 | + - name: Setup MSVC Environment |
| 143 | + if: matrix.os.name == 'windows' |
| 144 | + uses: ilammy/msvc-dev-cmd@v1 |
| 145 | + |
| 146 | + - name: Get MacOS GLib Version |
| 147 | + id: macos-deps-hash |
| 148 | + if: matrix.os.name == 'macos' |
| 149 | + run: | |
| 150 | + GLIB_VER=$(brew list --versions glib | awk '{print $2}') |
| 151 | + echo "glib version: $GLIB_VER" |
| 152 | + echo "GLIB_VER=$GLIB_VER" >> $GITHUB_OUTPUT |
| 153 | +
|
| 154 | + - name: Cache Wireshark Libs |
| 155 | + if: matrix.os.name == 'windows' |
| 156 | + id: cache-wireshark-libs |
| 157 | + uses: actions/cache@v4 |
| 158 | + with: |
| 159 | + path: ${{ env.WIRESHARK_BASE_DIR }} |
| 160 | + key: wireshark-libs-v${{ needs.setup.outputs.version_major }}.${{ needs.setup.outputs.version_minor }}.${{ needs.setup.outputs.version_patch }}-${{ matrix.os.name }} |
| 161 | + |
| 162 | + - name: Cache Wireshark Install |
| 163 | + id: cache-wireshark-install |
| 164 | + uses: actions/cache@v4 |
| 165 | + with: |
| 166 | + path: wireshark-install |
| 167 | + key: wireshark-v${{ needs.setup.outputs.version_major }}.${{ needs.setup.outputs.version_minor }}.${{ needs.setup.outputs.version_patch }}${{ matrix.os.name == 'macos' && format('-glib{0}', steps.macos-deps-hash.outputs.GLIB_VER) || '' }}-${{ matrix.os.name }} |
| 168 | + |
| 169 | + - name: Create Wireshark Install Directory |
| 170 | + if: steps.cache-wireshark-install.outputs.cache-hit != 'true' |
| 171 | + run: mkdir wireshark-install |
| 172 | + |
| 173 | + - name: Checkout Wireshark |
| 174 | + if: steps.cache-wireshark-install.outputs.cache-hit != 'true' |
| 175 | + uses: actions/checkout@v6 |
| 176 | + with: |
| 177 | + repository: wireshark/wireshark |
| 178 | + path: wireshark-src |
| 179 | + ref: v${{ needs.setup.outputs.version_major }}.${{ needs.setup.outputs.version_minor }}.${{ needs.setup.outputs.version_patch }} |
| 180 | + |
| 181 | + - name: Install Wireshark Dependencies |
| 182 | + if: steps.cache-wireshark-install.outputs.cache-hit != 'true' && matrix.os.deps |
| 183 | + run: ${{ matrix.os.deps }} |
| 184 | + |
| 185 | + - name: Install Qt |
| 186 | + if: steps.cache-wireshark-install.outputs.cache-hit != 'true' && matrix.os.name == 'windows' |
| 187 | + uses: jurplel/install-qt-action@v4 |
| 188 | + with: |
| 189 | + modules: "qt5compat" |
| 190 | + |
| 191 | + - name: Configure Wireshark |
| 192 | + if: steps.cache-wireshark-install.outputs.cache-hit != 'true' |
| 193 | + run: >- |
| 194 | + cmake -G Ninja -S wireshark-src -B wireshark-build |
| 195 | + -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/wireshark-install" |
| 196 | + -DBUILD_wireshark=OFF |
| 197 | + -DBUILD_tshark=OFF |
| 198 | + -DBUILD_editcap=OFF |
| 199 | + -DBUILD_capinfos=OFF |
| 200 | + -DBUILD_mmdbresolve=OFF |
| 201 | + -DENABLE_XXHASH=OFF |
| 202 | + -DENABLE_PCAP=OFF |
| 203 | +
|
| 204 | + - name: Build Wireshark |
| 205 | + if: steps.cache-wireshark-install.outputs.cache-hit != 'true' |
| 206 | + run: cmake --build wireshark-build |
| 207 | + |
| 208 | + - name: Install Wireshark |
| 209 | + if: steps.cache-wireshark-install.outputs.cache-hit != 'true' |
| 210 | + run: cmake --build wireshark-build --target install |
| 211 | + |
| 212 | + - name: Install Wireshark Headers |
| 213 | + if: steps.cache-wireshark-install.outputs.cache-hit != 'true' |
| 214 | + run: cmake --build wireshark-build --target install-headers |
| 215 | + |
| 216 | + - name: Locate Windows Third Party Libs |
| 217 | + if: matrix.os.name == 'windows' |
| 218 | + run: | |
| 219 | + $RequiredLibs = @("glib-2.0.lib", "zlib.lib") |
| 220 | + $FoundPaths = @() |
| 221 | +
|
| 222 | + foreach ($LibName in $RequiredLibs) { |
| 223 | + $AllCopies = Get-ChildItem -Path "${{ env.WIRESHARK_BASE_DIR }}" -Filter $LibName -Recurse -File |
| 224 | +
|
| 225 | + $BestMatch = $AllCopies | Where-Object { |
| 226 | + $_.FullName -match "vcpkg-export" -and $_.FullName -notmatch "\\debug\\" |
| 227 | + } | Select-Object -First 1 |
| 228 | +
|
| 229 | + if (-not $BestMatch) { |
| 230 | + Write-Error "Could not find release version of $LibName inside a vcpkg-export directory!" |
| 231 | + exit 1 |
| 232 | + } |
| 233 | +
|
| 234 | + $InstallRoot = $BestMatch.Directory.Parent.FullName |
| 235 | + $FoundPaths += $InstallRoot |
| 236 | + } |
| 237 | +
|
| 238 | + $FinalPath = ($FoundPaths | Select-Object -Unique) -join ";" |
| 239 | +
|
| 240 | + Write-Host "Selected Library Path: $FinalPath" |
| 241 | + echo "WS_DEP_PATH=$FinalPath" >> $env:GITHUB_ENV |
| 242 | +
|
| 243 | + - name: Add Wireshark Build Path |
| 244 | + if: matrix.os.name == 'windows' |
| 245 | + run: echo "WS_DEP_PATH=${{ env.WS_DEP_PATH }};${{ github.workspace }}/wireshark-build" >> $env:GITHUB_ENV |
| 246 | + |
| 247 | + - name: Configure Plugin |
| 248 | + run: >- |
| 249 | + cmake -G Ninja -S . -B build |
| 250 | + -DCMAKE_PREFIX_PATH="${{ github.workspace }}/wireshark-install;${{ env.WS_DEP_PATH }}" |
| 251 | + -DCMAKE_BUILD_TYPE="RelWithDebInfo" |
| 252 | + -DWireshark_VERSION="${{ needs.setup.outputs.version_major }}.${{ needs.setup.outputs.version_minor }}.${{ needs.setup.outputs.version_patch }}" |
| 253 | + -DCMAKE_C_FLAGS="${{ matrix.os.c-flags }}" |
| 254 | + -DPLUGIN_VERSION_MAJOR=${{ needs.setup.outputs.version_major }} |
| 255 | + -DPLUGIN_VERSION_MINOR=${{ needs.setup.outputs.version_minor }} |
| 256 | + -DPLUGIN_VERSION_PATCH=${{ needs.setup.outputs.version_patch }} |
| 257 | + -DPLUGIN_VERSION_EXTRA=${{ needs.setup.outputs.version_extra }} |
| 258 | +
|
| 259 | + - name: Build Plugin |
| 260 | + run: cmake --build build |
| 261 | + |
| 262 | + - name: Update Dependency Paths |
| 263 | + if: matrix.os.name == 'macos' |
| 264 | + run: | |
| 265 | + install_name_tool -change /opt/homebrew/opt/glib/lib/libglib-2.0.0.dylib @rpath/libglib-2.0.0.dylib build/smf.so |
| 266 | + install_name_tool -change /opt/homebrew/opt/xxhash/lib/libxxhash.0.dylib @rpath/libxxhash.0.dylib build/smf.so |
| 267 | +
|
| 268 | + - name: Create Compressed Tarball |
| 269 | + if: matrix.os.name == 'linux' || matrix.os.name == 'macos' |
| 270 | + run: tar -czvf ${{ matrix.os.artifact }} -C build smf.so |
| 271 | + |
| 272 | + - name: Create ZIP Archive |
| 273 | + if: matrix.os.name == 'windows' |
| 274 | + run: Get-ChildItem -Path build/smf.dll, build/smf.pdb | Compress-Archive -DestinationPath ${{ matrix.os.artifact }} |
| 275 | + |
| 276 | + - name: Upload Artifacts |
| 277 | + uses: actions/upload-artifact@v4 |
| 278 | + with: |
| 279 | + name: ${{ matrix.os.artifact }} |
| 280 | + path: ${{ matrix.os.artifact }} |
| 281 | + overwrite: true |
0 commit comments