|
| 1 | +name: Build - Windows |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + |
| 7 | +jobs: |
| 8 | + build: |
| 9 | + name: Build |
| 10 | + runs-on: ${{ matrix.os }} |
| 11 | + strategy: |
| 12 | + fail-fast: false |
| 13 | + matrix: |
| 14 | + os: [windows-2022] |
| 15 | + arch: ["Win32", "Win64"] |
| 16 | + steps: |
| 17 | + - name: Checkout |
| 18 | + uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Setup MSVC |
| 21 | + uses: ilammy/msvc-dev-cmd@v1 |
| 22 | + with: |
| 23 | + arch: ${{ matrix.arch == 'Win32' && 'amd64_x86' || matrix.arch == 'Win64' && 'amd64'}} |
| 24 | + |
| 25 | + - name: Clear SQLite and temp files |
| 26 | + continue-on-error: true |
| 27 | + run: | |
| 28 | + mkdir -p C:\temp\${{ matrix.arch }}\ |
| 29 | + mkdir -p C:\dev |
| 30 | +
|
| 31 | + - name: Install SQLite |
| 32 | + run: | |
| 33 | + $htmlContent = Invoke-WebRequest -Uri "https://sqlite.org/download.html" | Select-Object -ExpandProperty Content |
| 34 | + $regex = [regex]::new('PRODUCT,(\d+\.\d+\.\d+),(\d+/sqlite-amalgamation-\d+\.zip),\d+,(.+)') |
| 35 | + $match = $regex.Match($htmlContent) |
| 36 | + $relativeUrl = $match.Groups[2].Value |
| 37 | + $downloadLink = "https://sqlite.org/$relativeUrl" |
| 38 | + Invoke-WebRequest -Uri $downloadLink -OutFile 'C:\temp\${{ matrix.arch }}\sqlite.zip' |
| 39 | + Expand-Archive -Path C:\temp\${{ matrix.arch }}\sqlite.zip -DestinationPath C:\temp\${{ matrix.arch }} |
| 40 | + Move-Item -Path C:\temp\${{ matrix.arch }}\sqlite-amalgamation-* C:\dev\SQLite-${{ matrix.arch }} |
| 41 | + cd C:\dev\SQLite-${{ matrix.arch }} |
| 42 | + cl sqlite3.c -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_STAT4 -DSQLITE_SOUNDEX -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_GEOPOLY -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_MAX_ATTACHED=125 -DSQLITE_API="__declspec(dllexport)" -link -dll -out:sqlite3.dll |
| 43 | +
|
| 44 | + - name: Install SQLite Extensions |
| 45 | + run: | |
| 46 | + cp .\src\extensions\extension-formats.c C:\dev\SQLite-${{ matrix.arch}}\ |
| 47 | + cp .\src\extensions\extension-formats.def C:\dev\SQLite-${{ matrix.arch}}\ |
| 48 | + cp .\src\extensions\extension-functions.c C:\dev\SQLite-${{ matrix.arch}}\ |
| 49 | + cp .\src\extensions\extension-functions.def C:\dev\SQLite-${{ matrix.arch}}\ |
| 50 | + cd C:\dev\SQLite-${{ matrix.arch}}\ |
| 51 | + cl /MD extension-formats.c -link -dll -def:extension-formats.def -out:formats.dll |
| 52 | + cl /MD extension-functions.c -link -dll -def:extension-functions.def -out:math.dll |
| 53 | + # FIXME: Disable building the 'fileio' extension for now (#3488) |
| 54 | + # If this issue is resolved, be sure to delete the related patch for WiX |
| 55 | + # curl -L -o fileio.c "https://sqlite.org/src/raw?filename=ext/misc/fileio.c&ci=trunk" |
| 56 | + # curl -L -o test_windirent.c "https://sqlite.org/src/raw?filename=src/test_windirent.c&ci=trunk" |
| 57 | + # curl -L -o test_windirent.h "https://sqlite.org/src/raw?filename=src/test_windirent.h&ci=trunk" |
| 58 | + # cl /MD fileio.c test_windirent.c -link sqlite3.lib -dll -out:fileio.dll |
| 59 | +
|
| 60 | + - name: Install SQLCipher |
| 61 | + # ref: https://github.com/actions/runner-images/blob/main/images/windows/scripts/build/Install-OpenSSL.ps1#L12 |
| 62 | + run: | |
| 63 | + mkdir -p C:\dev\SQLCipher-${{ matrix.arch }} |
| 64 | + cd C:\dev\SQLCipher-${{ matrix.arch }} |
| 65 | + git clone https://github.com/sqlcipher/sqlcipher.git . |
| 66 | + git reset --hard $(git describe --tags --abbrev=0) |
| 67 | + nmake /f Makefile.msc sqlcipher.dll USE_AMALGAMATION=1 NO_TCL=1 SQLITE3DLL=sqlcipher.dll SQLITE3LIB=sqlcipher.lib SQLITE3EXE=sqlcipher.exe LTLINKOPTS="$env:ProgramFiles\OpenSSL\lib\libcrypto.lib" OPT_FEATURE_FLAGS="-DSQLITE_TEMP_STORE=2 -DSQLITE_HAS_CODEC=1 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS5=1 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1 -DSQLITE_ENABLE_STAT4=1 -DSQLITE_SOUNDEX=1 -DSQLITE_ENABLE_JSON1=1 -DSQLITE_ENABLE_GEOPOLY=1 -DSQLITE_ENABLE_RTREE=1 -DSQLCIPHER_CRYPTO_OPENSSL=1 -DSQLITE_MAX_ATTACHED=125 -I$env:ProgramFiles\OpenSSL\include" |
| 68 | + mkdir sqlcipher |
| 69 | + copy sqlite3.h sqlcipher |
| 70 | +
|
| 71 | + - name: Prepare artifacts |
| 72 | + run: | |
| 73 | + cd C:\ |
| 74 | + Compress-Archive -Path C:\dev\* -DestinationPath build-artifacts-${{ matrix.arch }}.zip |
| 75 | +
|
| 76 | + - name: Upload artifacts |
| 77 | + uses: actions/upload-artifact@v4 |
| 78 | + with: |
| 79 | + name: build-artifacts-${{ matrix.os }}-${{ matrix.arch }} |
| 80 | + path: build-artifacts-${{ matrix.arch }}.zip |
| 81 | + retention-days: 7 |
0 commit comments