Skip to content

Commit 7de41a0

Browse files
committed
Try init static build
1 parent 88b1f2c commit 7de41a0

File tree

1 file changed

+59
-33
lines changed

1 file changed

+59
-33
lines changed

.github/workflows/build-windows.yml

Lines changed: 59 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ jobs:
1313
build:
1414
name: Build
1515
runs-on: ${{ matrix.os }}
16+
env:
17+
VCPKG_DEFAULT_TRIPLET: ${{ matrix.arch == 'Win32' && 'x86' || matrix.arch == 'Win64' && 'x64' }}-windows-static
18+
SQLCIPHER_NMAKE_VARS: USE_AMALGAMATION=1 NO_TCL=1 SQLITE3DLL=sqlcipher.dll SQLITE3LIB=sqlcipher.lib SQLITE3EXE=sqlcipher.exe
19+
SQLCIPHER_NMAKE_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
1620
permissions:
1721
contents: write
1822
strategy:
@@ -24,7 +28,7 @@ jobs:
2428
- name: Checkout
2529
uses: actions/checkout@v4
2630

27-
- name: Setup OpenSSL
31+
- name: Setup OpenSSL 1.1.1 for Win32
2832
if: matrix.arch == 'Win32'
2933
# https://github.com/actions/runner-images/blob/main/images/windows/scripts/build/Install-OpenSSL.ps1 & Win32OpenSSL.exe /? & Win32OpenSSL.exe /LOG="a.log" /SAVEINF="inf.inf"
3034
run: |
@@ -38,51 +42,73 @@ jobs:
3842
with:
3943
arch: ${{ matrix.arch == 'Win32' && 'amd64_x86' || matrix.arch == 'Win64' && 'amd64'}}
4044

41-
- name: Clear SQLite and temp files
45+
- name: Setup vcpkg cache
46+
# https://learn.microsoft.com/zh-cn/vcpkg/users/binarycaching#gha
47+
uses: actions/github-script@v7
48+
with:
49+
script: |
50+
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
51+
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
52+
53+
- name: Setup OpenSSL (static)
54+
# https://blog.hamaluik.ca/posts/statically-linking-sqlcipher-on-windows
55+
run: |
56+
vcpkg install openssl:${{ env.VCPKG_DEFAULT_TRIPLET }} --binarysource="clear;x-gha,readwrite"
57+
58+
- name: Init folders
4259
continue-on-error: true
4360
run: |
4461
mkdir -p C:\temp\${{ matrix.arch }}\
4562
mkdir -p C:\dev
4663
47-
- name: Install SQLite
48-
run: |
49-
$htmlContent = Invoke-WebRequest -Uri "https://sqlite.org/download.html" | Select-Object -ExpandProperty Content
50-
$regex = [regex]::new('PRODUCT,(\d+\.\d+\.\d+),(\d+/sqlite-amalgamation-\d+\.zip),\d+,(.+)')
51-
$match = $regex.Match($htmlContent)
52-
$relativeUrl = $match.Groups[2].Value
53-
$downloadLink = "https://sqlite.org/$relativeUrl"
54-
Invoke-WebRequest -Uri $downloadLink -OutFile 'C:\temp\${{ matrix.arch }}\sqlite.zip'
55-
Expand-Archive -Path C:\temp\${{ matrix.arch }}\sqlite.zip -DestinationPath C:\temp\${{ matrix.arch }}
56-
Move-Item -Path C:\temp\${{ matrix.arch }}\sqlite-amalgamation-* C:\dev\SQLite-${{ matrix.arch }}
57-
cd C:\dev\SQLite-${{ matrix.arch }}
58-
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
64+
# - name: Install SQLite
65+
# run: |
66+
# $htmlContent = Invoke-WebRequest -Uri "https://sqlite.org/download.html" | Select-Object -ExpandProperty Content
67+
# $regex = [regex]::new('PRODUCT,(\d+\.\d+\.\d+),(\d+/sqlite-amalgamation-\d+\.zip),\d+,(.+)')
68+
# $match = $regex.Match($htmlContent)
69+
# $relativeUrl = $match.Groups[2].Value
70+
# $downloadLink = "https://sqlite.org/$relativeUrl"
71+
# Invoke-WebRequest -Uri $downloadLink -OutFile 'C:\temp\${{ matrix.arch }}\sqlite.zip'
72+
# Expand-Archive -Path C:\temp\${{ matrix.arch }}\sqlite.zip -DestinationPath C:\temp\${{ matrix.arch }}
73+
# Move-Item -Path C:\temp\${{ matrix.arch }}\sqlite-amalgamation-* C:\dev\SQLite-${{ matrix.arch }}
74+
# cd C:\dev\SQLite-${{ matrix.arch }}
75+
# 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
5976

60-
- name: Install SQLite Extensions
61-
run: |
62-
cp .\src\extensions\extension-formats.c C:\dev\SQLite-${{ matrix.arch}}\
63-
cp .\src\extensions\extension-formats.def C:\dev\SQLite-${{ matrix.arch}}\
64-
cp .\src\extensions\extension-functions.c C:\dev\SQLite-${{ matrix.arch}}\
65-
cp .\src\extensions\extension-functions.def C:\dev\SQLite-${{ matrix.arch}}\
66-
cd C:\dev\SQLite-${{ matrix.arch}}\
67-
cl /MD extension-formats.c -link -dll -def:extension-formats.def -out:formats.dll
68-
cl /MD extension-functions.c -link -dll -def:extension-functions.def -out:math.dll
69-
# FIXME: Disable building the 'fileio' extension for now (#3488)
70-
# If this issue is resolved, be sure to delete the related patch for WiX
71-
# curl -L -o fileio.c "https://sqlite.org/src/raw?filename=ext/misc/fileio.c&ci=trunk"
72-
# curl -L -o test_windirent.c "https://sqlite.org/src/raw?filename=src/test_windirent.c&ci=trunk"
73-
# curl -L -o test_windirent.h "https://sqlite.org/src/raw?filename=src/test_windirent.h&ci=trunk"
74-
# cl /MD fileio.c test_windirent.c -link sqlite3.lib -dll -out:fileio.dll
77+
# - name: Build SQLite Extensions
78+
# run: |
79+
# cp .\src\extensions\extension-formats.c C:\dev\SQLite-${{ matrix.arch}}\
80+
# cp .\src\extensions\extension-formats.def C:\dev\SQLite-${{ matrix.arch}}\
81+
# cp .\src\extensions\extension-functions.c C:\dev\SQLite-${{ matrix.arch}}\
82+
# cp .\src\extensions\extension-functions.def C:\dev\SQLite-${{ matrix.arch}}\
83+
# cd C:\dev\SQLite-${{ matrix.arch}}\
84+
# cl /MD extension-formats.c -link -dll -def:extension-formats.def -out:formats.dll
85+
# cl /MD extension-functions.c -link -dll -def:extension-functions.def -out:math.dll
86+
# # FIXME: Disable building the 'fileio' extension for now (#3488)
87+
# # If this issue is resolved, be sure to delete the related patch for WiX
88+
# # curl -L -o fileio.c "https://sqlite.org/src/raw?filename=ext/misc/fileio.c&ci=trunk"
89+
# # curl -L -o test_windirent.c "https://sqlite.org/src/raw?filename=src/test_windirent.c&ci=trunk"
90+
# # curl -L -o test_windirent.h "https://sqlite.org/src/raw?filename=src/test_windirent.h&ci=trunk"
91+
# # cl /MD fileio.c test_windirent.c -link sqlite3.lib -dll -out:fileio.dll
7592

76-
- name: Install SQLCipher
93+
- name: Build SQLCipher (dynamically linked)
7794
# ref: https://github.com/actions/runner-images/blob/main/images/windows/scripts/build/Install-OpenSSL.ps1#L12
7895
run: |
7996
mkdir -p C:\dev\SQLCipher-${{ matrix.arch }}
8097
cd C:\dev\SQLCipher-${{ matrix.arch }}
8198
git clone -q https://github.com/sqlcipher/sqlcipher.git .
8299
git reset --hard $(git describe --tags --abbrev=0)
83-
nmake /f Makefile.msc 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`""
100+
nmake /f Makefile.msc ${{ env.SQLCIPHER_NMAKE_VARS }} LTLINKOPTS="`"$env:ProgramFiles\OpenSSL\lib\libcrypto.lib`"" OPT_FEATURE_FLAGS="${{ env.SQLCIPHER_NMAKE_OPT_FEATURE_FLAGS }} `"-I$env:ProgramFiles\OpenSSL\include`""
84101
mkdir sqlcipher
85-
copy sqlite3.c,sqlite3.h,sqlcipher.dll,sqlcipher.lib,sqlcipher.exe,"$env:ProgramFiles\OpenSSL\libcrypto-*" sqlcipher
102+
move sqlcipher.exe sqlcipher-dynamic.exe
103+
copy sqlite3.c,sqlite3.h,sqlcipher.dll,sqlcipher.lib,sqlcipher-dynamic.exe,"$env:ProgramFiles\OpenSSL\libcrypto-*" sqlcipher
104+
105+
- name: Build SQLCipher (statically linked)
106+
# ref: https://github.com/actions/runner-images/blob/main/images/windows/scripts/build/Install-OpenSSL.ps1#L12
107+
run: |
108+
cd C:\dev\SQLCipher-${{ matrix.arch }}
109+
nmake /f Makefile.msc clean
110+
nmake /f Makefile.msc ${{ env.SQLCIPHER_NMAKE_VARS }} LTLINKOPTS="`"$env:VCPKG_INSTALLATION_ROOT\packages\openssl_${{ env.VCPKG_DEFAULT_TRIPLET }}\lib\libcrypto.lib`"" OPT_FEATURE_FLAGS="${{ env.SQLCIPHER_NMAKE_OPT_FEATURE_FLAGS }} `"-I$env:VCPKG_INSTALLATION_ROOT\packages\openssl_${{ env.VCPKG_DEFAULT_TRIPLET }}\include`"" LTLIBS="libcrypto${{ matrix.arch == 'Win32' && '32' }}.lib libssl${{ matrix.arch == 'Win32' && '32' }}.lib WS2_32.Lib Gdi32.Lib AdvAPI32.Lib Crypt32.Lib User32.Lib"
111+
copy sqlcipher.exe,"$env:ProgramFiles\OpenSSL\libcrypto-*" sqlcipher
86112
87113
- name: Prepare artifacts
88114
run: |
@@ -99,4 +125,4 @@ jobs:
99125
uses: softprops/action-gh-release@v2
100126
with:
101127
tag_name: latest
102-
files: build-artifacts-${{ matrix.arch }}.zip
128+
files: dynamic-${{ matrix.arch }}.zip

0 commit comments

Comments
 (0)