|
| 1 | +name: Build for Windows |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + build-windows: |
| 7 | + name: windows ${{ join(matrix.*, ' ') }} |
| 8 | + env: |
| 9 | + OPTS: --with-vstudiotarget=${{ matrix.target }} ${{ matrix.opts }} |
| 10 | + TESTSUITE: ${{ matrix.testsuite }} |
| 11 | + |
| 12 | + runs-on: windows-latest |
| 13 | + timeout-minutes: 60 |
| 14 | + |
| 15 | + strategy: |
| 16 | + fail-fast: false |
| 17 | + matrix: |
| 18 | + include: |
| 19 | + # run only one job for windows, as more than one be enough currently to verify |
| 20 | + # PRs |
| 21 | + # tests are not enabled as they take very long and a lot of them will fail |
| 22 | + - target: Release |
| 23 | + |
| 24 | + defaults: |
| 25 | + run: |
| 26 | + shell: msys2 {0} |
| 27 | + |
| 28 | + steps: |
| 29 | + - name: checkout |
| 30 | + uses: actions/checkout@v2 |
| 31 | + with: |
| 32 | + submodules: recursive |
| 33 | + - name: install msys |
| 34 | + uses: msys2/setup-msys2@v2 |
| 35 | + with: |
| 36 | + msystem: UCRT64 |
| 37 | + release: false |
| 38 | + update: true |
| 39 | + install: base-devel git mingw-w64-ucrt-x86_64-toolchain autotools |
| 40 | + - name: set up python |
| 41 | + uses: actions/setup-python@v5 |
| 42 | + with: |
| 43 | + python-version: '3.x' |
| 44 | + |
| 45 | + # pypiwin32 has to be installed with a Windows python version therefore |
| 46 | + # this step will configure python first on Windows and exports |
| 47 | + # its location for MSYS bash. |
| 48 | + - name: configure python in Windows cmdline |
| 49 | + shell: cmd |
| 50 | + run: | |
| 51 | + python -m pip install --upgrade pip |
| 52 | + pip install pypiwin32 |
| 53 | + |
| 54 | + echo Python location: %pythonLocation% |
| 55 | + echo export pythonLocation="%pythonLocation%" > c:\msys64\home\%USERNAME%\.pythonenv.sh |
| 56 | + echo export PYTHONPATH="%cd%\python;%cd%\ovs\python;%pythonLocation%\Lib;%pythonLocation%\DLLs;%pythonLocation%\Lib\lib-tk" >> c:\msys64\home\%USERNAME%\.pythonenv.sh |
| 57 | + echo ".pythonenv.sh was generated in c:\msys64\home\%USERNAME%" |
| 58 | + - name: install openssl |
| 59 | + shell: powershell |
| 60 | + run: | |
| 61 | + $RUNNER_TEMP = $env:RUNNER_TEMP |
| 62 | + $ProgressPreference = 'SilentlyContinue' |
| 63 | +
|
| 64 | + Remove-Item -Recurse -Force -Path C:/OpenSSL-Win64 -ErrorAction Continue |
| 65 | + New-Item -ItemType Directory -Force -Path "$RUNNER_TEMP\ovs-build-downloads" |
| 66 | + |
| 67 | + # Find and download the latest stable OpenSSl 3.0. |
| 68 | + $URL = "https://raw.githubusercontent.com/slproweb/opensslhashes/master/win32_openssl_hashes.json" |
| 69 | + $webData = (Invoke-WebRequest -Uri $URL).content | ConvertFrom-Json |
| 70 | + $source = ($webData.files.PSObject.Properties | Where-Object { |
| 71 | + $_.Value.basever -match "^3\.0\.[0-9]+" -and |
| 72 | + $_.Value.bits -eq "64" -and |
| 73 | + $_.Value.arch -eq "INTEL" -and |
| 74 | + $_.Value.installer -eq "exe" -and |
| 75 | + -not $_.Value.light |
| 76 | + } | Select-Object Value | Select -First 1).PSObject.Properties.Value |
| 77 | + |
| 78 | + Write-Host "Latest OpenSSL 3.0:" ($source | Format-List | Out-String) |
| 79 | + |
| 80 | + $destination = "$RUNNER_TEMP\ovs-build-downloads\Win64OpenSSL.exe" |
| 81 | + if (Test-Path $destination) { |
| 82 | + $fileHash = (Get-FileHash $destination -Algorithm SHA256).Hash.ToLower() |
| 83 | + if ($fileHash -ne $source.sha256) { |
| 84 | + Write-Host "Cache miss:" $fileHash "!=" $source.sha256 |
| 85 | + Remove-Item -Path $destination |
| 86 | + } |
| 87 | + } |
| 88 | + |
| 89 | + if (Test-Path $destination) { |
| 90 | + Write-Host "Using cached:" $destination |
| 91 | + } else { |
| 92 | + Write-Host "Downloading:" $source.url |
| 93 | + Invoke-WebRequest $source.url -OutFile $destination |
| 94 | + } |
| 95 | + |
| 96 | + Write-Host "Installing:" $destination |
| 97 | + Start-Process -FilePath $destination -ArgumentList "/silent /verysilent /sp- /suppressmsgboxes /DIR=C:\OpenSSL-Win64" -Wait |
| 98 | + get-item -Path "C:\OpenSSL-Win64" |
| 99 | + - name: clone pthread |
| 100 | + shell: cmd |
| 101 | + run: git clone -q https://git.code.sf.net/p/pthreads4w/code c:\pthreads4w-code |
| 102 | + |
| 103 | + - name: disable link in MSYS |
| 104 | + run: | |
| 105 | + mv $(which link) $(which link)_copy |
| 106 | + mv /ucrt64/bin/python3 /ucrt64/bin/python3_off |
| 107 | + - name: build pthread |
| 108 | + shell: cmd |
| 109 | + run: | |
| 110 | + @call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" |
| 111 | + c:\MSYS64\msys2_shell.cmd -ucrt64 -here -defterm -no-start -use-full-path -c "cd /c/pthreads4w-code && nmake all install 2>&1" |
| 112 | + - name: generate build script |
| 113 | + run: | |
| 114 | + cat > $RUNNER_TEMP/build.sh <<EOF |
| 115 | + #!/bin/bash |
| 116 | + set -e |
| 117 | + source ~/.pythonenv.sh |
| 118 | + pushd ovs |
| 119 | + ./boot.sh |
| 120 | + ./configure CC=build-aux/cccl LD="\`which link\`" \ |
| 121 | + LIBS="-lws2_32 -lShlwapi -liphlpapi -lwbemuuid -lole32 -loleaut32" \ |
| 122 | + --prefix=C:/openvswitch/usr \ |
| 123 | + --localstatedir=C:/ProgramData/openvswitch/var \ |
| 124 | + --sysconfdir=C:/ProgramData/openvswitch/etc \ |
| 125 | + --with-pthread=c:/PTHREADS-BUILT/ \ |
| 126 | + --enable-ssl --with-openssl=C:/OpenSSL-Win64 \ |
| 127 | + -with-vstudiotargetver=Win10 \ |
| 128 | + $OPTS |
| 129 | + |
| 130 | + make -j4 |
| 131 | + make install |
| 132 | +
|
| 133 | + popd |
| 134 | +
|
| 135 | + ./boot.sh |
| 136 | + ./configure CC=build-aux/cccl LD="\`which link\`" \ |
| 137 | + LIBS="-lws2_32 -lShlwapi -liphlpapi -lwbemuuid -lole32 -loleaut32" \ |
| 138 | + --prefix=C:/openvswitch/usr \ |
| 139 | + --localstatedir=C:/ProgramData/openvswitch/var \ |
| 140 | + --sysconfdir=C:/ProgramData/openvswitch/etc \ |
| 141 | + --with-pthread=c:/PTHREADS-BUILT/ \ |
| 142 | + --enable-ssl --with-openssl=C:/OpenSSL-Win64 \ |
| 143 | + $OPTS |
| 144 | + |
| 145 | + make -j4 |
| 146 | + make install |
| 147 | + |
| 148 | + EOF |
| 149 | + chmod +x $RUNNER_TEMP/build.sh |
| 150 | + cat $RUNNER_TEMP/build.sh |
| 151 | + - name: build |
| 152 | + shell: cmd |
| 153 | + run: | |
| 154 | + @call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" |
| 155 | + c:\MSYS64\msys2_shell.cmd -ucrt64 -here -defterm -no-start -use-full-path -c "$RUNNER_TEMP/build.sh 2>&1" |
| 156 | + - name: upload ovs logs on failure |
| 157 | + if: failure() |
| 158 | + |
| 159 | + with: |
| 160 | + name: logs-windows-${{ join(matrix.*, '-') }} |
| 161 | + if-no-files-found: ignore |
| 162 | + path: ./ovs/config.log |
| 163 | + |
| 164 | + - name: upload logs on failure |
| 165 | + if: failure() |
| 166 | + |
| 167 | + with: |
| 168 | + name: logs-windows-${{ join(matrix.*, '-') }} |
| 169 | + if-no-files-found: ignore |
| 170 | + path: ./config.log |
| 171 | + |
| 172 | + - name: package |
| 173 | + run: | |
| 174 | + cp /c/PTHREADS-BUILT/bin/pthreadVC3.dll /C/openvswitch/usr/sbin |
| 175 | + cp /c/PTHREADS-BUILT/bin/pthreadVC3.dll /C/openvswitch/usr/bin |
| 176 | + cp /c/PTHREADS-BUILT/bin/pthreadVC3.dll /C/openvswitch/usr/sbin |
| 177 | + cp /c/PTHREADS-BUILT/bin/pthreadVC3.dll /C/openvswitch/usr/bin |
| 178 | + cp /c/OpenSSL-Win64/libcrypto-3-x64.dll /C/openvswitch/usr/sbin |
| 179 | + cp /c/OpenSSL-Win64/libcrypto-3-x64.dll /C/openvswitch/usr/bin |
| 180 | + cp /c/OpenSSL-Win64/libssl-3-x64.dll /C/openvswitch/usr/sbin |
| 181 | + cp /c/OpenSSL-Win64/libssl-3-x64.dll /C/openvswitch/usr/bin |
| 182 | + mkdir /C/openvswitch/driver |
| 183 | + cp ./ovs/datapath-windows/x64/Win10${{ matrix.target }}/package/* /C/openvswitch/driver |
| 184 | + cp ./ovs/datapath-windows/x64/Win10${{ matrix.target }}/package.cer /C/openvswitch/driver |
| 185 | + cp ./ovs/datapath-windows/misc/* /C/openvswitch/driver |
| 186 | + cp ./ovs/datapath-windows/ovsext/x64/Win10${{ matrix.target }}/DBO_OVSE.pdb /C/openvswitch/driver |
| 187 | + mv /C/openvswitch/driver/ovsext.inf /C/openvswitch/driver/DBO_OVSE.inf |
| 188 | + - name: upload build artifacts |
| 189 | + |
| 190 | + with: |
| 191 | + name: ovn-windows-${{ join(matrix.*, '-') }} |
| 192 | + path: c:\openvswitch |
0 commit comments