ci: Configure CI for Windows · dbl007/sqlitebrowser@621bb00 · GitHub
Skip to content

Commit 621bb00

Browse files
committed
ci: Configure CI for Windows
1 parent 6aa288c commit 621bb00

7 files changed

Lines changed: 283 additions & 1 deletion

File tree

‎.github/patch/CMakeLists.txt.patch‎

Lines changed: 33 additions & 0 deletions

‎.github/patch/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
A collection of patch files used when a need change to a file in the source tree is required for GitHub Actions to work.

‎.github/patch/product.wxs.patch‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
diff --git a/installer/windows/product.wxs b/installer/windows/product.wxs
2+
index c040591a..da3c2604 100644
3+
--- a/installer/windows/product.wxs
4+
+++ b/installer/windows/product.wxs
5+
@@ -63,7 +63,7 @@
6+
<Directory Id="extensions" Name="extensions">
7+
<Component><File Source="$(var.SQLitePath)\math.dll" /></Component>
8+
<Component><File Source="$(var.SQLitePath)\formats.dll" /></Component>
9+
- <Component><File Source="$(var.SQLitePath)\fileio.dll" /></Component>
10+
+ <!-- <Component><File Source="$(var.SQLitePath)\fileio.dll" /></Component> -->
11+
</Directory>
12+
<Directory Id="imageformats" Name="imageformats">
13+
<Component><File Source="$(var.QtPath)\plugins\imageformats\qgif.dll" /></Component>
14+
@@ -149,9 +149,9 @@
15+
<Feature Id="FormatsExtension" Title="Formats" Description="Provide additional field display formats." AllowAdvertise="no">
16+
<ComponentRef Id="formats.dll" />
17+
</Feature>
18+
- <Feature Id="FileioExtension" Title="Fileio" Description="Implements SQL functions readfile(), writefile(), and eponymous virtual type 'fsdir'." AllowAdvertise="no">
19+
+ <!-- <Feature Id="FileioExtension" Title="Fileio" Description="Implements SQL functions readfile(), writefile(), and eponymous virtual type 'fsdir'." AllowAdvertise="no">
20+
<ComponentRef Id="fileio.dll" />
21+
- </Feature>
22+
+ </Feature> -->
23+
</Feature>
24+
25+
<!-- Registry -->
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
diff --git a/installer/windows/translations.wxs b/installer/windows/translations.wxs
2+
index f842e05b..0743a202 100644
3+
--- a/installer/windows/translations.wxs
4+
+++ b/installer/windows/translations.wxs
5+
@@ -97,7 +97,7 @@
6+
<Component><File Source="$(var.QtPath)\translations\qtxmlpatterns_pl.qm" /></Component>
7+
8+
<!-- Brazilian Portuguese -->
9+
- <Component><File Source="$(var.QtPath)\translations\qt_pt_BR.qm" /></Component>
10+
+ <Component><File Source="$(var.QtPath)\translations\qt_pt.qm" /></Component>
11+
12+
<!-- Russian -->
13+
<Component><File Source="$(var.QtPath)\translations\qt_ru.qm" /></Component>
14+
@@ -197,7 +197,7 @@
15+
<ComponentRef Id="qtxmlpatterns_pl.qm" />
16+
17+
<!-- Brazilian Portuguese -->
18+
- <ComponentRef Id="qt_pt_BR.qm" />
19+
+ <ComponentRef Id="qt_pt.qm" />
20+
21+
<!-- Russian -->
22+
<ComponentRef Id="qt_ru.qm" />

‎.github/patch/variables.wxi.patch‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
diff --git a/installer/windows/variables.wxi b/installer/windows/variables.wxi
2+
index fbedf0c3..368888ef 100644
3+
--- a/installer/windows/variables.wxi
4+
+++ b/installer/windows/variables.wxi
5+
@@ -40,8 +40,8 @@
6+
Visual Studio 2017. The build "ARCH" will be set automatically.
7+
-->
8+
9+
- <?define VCRedistPath="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Redist\MSVC\14.16.27012\MergeModules" ?>
10+
- <?define VCRedistFile="Microsoft_VC141_CRT_$(sys.BUILDARCH).msm" ?>
11+
+ <?define VCRedistPath="C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Redist\MSVC\14.29.30133\MergeModules" ?>
12+
+ <?define VCRedistFile="Microsoft_VC142_CRT_$(sys.BUILDARCH).msm" ?>
13+
14+
<!--
15+
=================================================== Build System ===================================================
16+
@@ -49,20 +49,11 @@
17+
Paths for the various libraries the application needs to compile. Change these to match the build machine.
18+
-->
19+
20+
- <?if $(sys.BUILDARCH)="x64"?>
21+
- <?define QtPath="C:\dev\Qt\5.12.12\msvc2017_64" ?>
22+
- <?define SQLitePath="C:\dev\SQLite-Win64" ?>
23+
- <?define SQLCipherPath="C:\git_repos\SQLCipher-Win64" ?>
24+
- <?define OpenSSLPath="C:\dev\OpenSSL-Win64" ?>
25+
- <?define SQLiteExePath="C:\builds\release-sqlite-win64\Release" ?>
26+
- <?define SQLCipherExePath="C:\builds\release-sqlcipher-win64\Release" ?>
27+
- <?elseif $(sys.BUILDARCH)="x86"?>
28+
- <?define QtPath="C:\dev\Qt\5.12.12\msvc2017" ?>
29+
- <?define SQLitePath="C:\dev\SQLite-Win32" ?>
30+
- <?define SQLCipherPath="C:\git_repos\SQLCipher-Win32" ?>
31+
- <?define OpenSSLPath="C:\dev\OpenSSL-Win32" ?>
32+
- <?define SQLiteExePath="C:\builds\release-sqlite-win32\Release" ?>
33+
- <?define SQLCipherExePath="C:\builds\release-sqlcipher-win32\Release" ?>
34+
- <?endif?>
35+
+ <?define QtPath="$(env.Qt5_Dir)" ?>
36+
+ <?define SQLitePath="$(env.SQLitePath)" ?>
37+
+ <?define SQLCipherPath="$(env.SQLCipherPath)" ?>
38+
+ <?define OpenSSLPath="$(env.OpenSSLPath)" ?>
39+
+ <?define SQLiteExePath="$(env.ExePath)\release-sqlite\Release" ?>
40+
+ <?define SQLCipherExePath="$(env.ExePath)\release-sqlcipher\Release" ?>
41+
42+
</Include>
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
name: Build - Windows
2+
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
6+
7+
jobs:
8+
build:
9+
name: Build
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os: [windows-2019]
15+
arch: ["Win32", "Win64"]
16+
env:
17+
OPENSSL_VERSION: 1.1.1.2100
18+
QT_VERSION: 5.15.2
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Cache OpenSSL
24+
id: cache-openssl
25+
uses: actions/cache@v3
26+
with:
27+
key: cache-openssl-${{ matrix.arch }}-${{ env.OPENSSL_VERSION }}
28+
path: ${{ matrix.arch == 'Win32' && 'C:\Program Files (x86)\OpenSSL-Win32' || matrix.arch == 'Win64' && 'C:\Program Files\OpenSSL' }}
29+
30+
- if: steps.cache-openssl.outputs.cache-hit != 'true'
31+
name: Install OpenSSL
32+
run: |
33+
if ("${{ matrix.arch }}" -eq "Win32") {
34+
choco install openssl --x86 --version=${{ env.OPENSSL_VERSION}}
35+
} else {
36+
choco install openssl --version=${{ env.OPENSSL_VERSION}}
37+
}
38+
39+
# When building SQLCipher, if we specify a path to OpenSSL and
40+
# there are spaces in the path, an error will occur, so to
41+
# avoid this, create the symlink.
42+
- name: Create OpenSSL symlink
43+
run: |
44+
mkdir C:\dev
45+
if ("${{ matrix.arch }}" -eq "Win32") {
46+
New-Item -Path "C:\dev\OpenSSL-${{ matrix.arch }}" -ItemType SymbolicLink -Value "C:\Program Files (x86)\OpenSSL-Win32\"
47+
} else {
48+
New-Item -Path "C:\dev\OpenSSL-${{ matrix.arch }}" -ItemType SymbolicLink -Value "C:\Program Files\OpenSSL"
49+
}
50+
51+
- name: Install Qt
52+
uses: jurplel/install-qt-action@v3
53+
with:
54+
arch: ${{ matrix.arch == 'Win32' && 'win32_msvc2019' || matrix.arch == 'Win64' && 'win64_msvc2019_64'}}
55+
cache: true
56+
cache-key-prefix: "cache"
57+
version: ${{ env.QT_VERSION }}
58+
59+
- name: Setup MSVC
60+
uses: ilammy/msvc-dev-cmd@v1
61+
with:
62+
arch: ${{ matrix.arch == 'Win32' && 'amd64_x86' || matrix.arch == 'Win64' && 'amd64'}}
63+
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 'sqlite.zip'
72+
Expand-Archive -Path sqlite.zip -DestinationPath C:\dev\
73+
Move-Item -Path C:\dev\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
76+
77+
- name: Install 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+
# curl -L -o fileio.c "https://sqlite.org/src/raw?filename=ext/misc/fileio.c&ci=trunk"
88+
# curl -L -o test_windirent.c "https://sqlite.org/src/raw?filename=src/test_windirent.c&ci=trunk"
89+
# curl -L -o test_windirent.h "https://sqlite.org/src/raw?filename=src/test_windirent.h&ci=trunk"
90+
# cl /MD fileio.c test_windirent.c -link sqlite3.lib -dll -out:fileio.dll
91+
92+
- name: Install SQLCipher
93+
env:
94+
CPPFLAGS: -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"C:\dev\OpenSSL-${{ matrix.arch }}\include\"
95+
run: |
96+
cd C:\dev
97+
git clone https://github.com/sqlcipher/sqlcipher
98+
mv sqlcipher SQLCipher-${{ matrix.arch }}
99+
cd SQLCipher-${{ matrix.arch }}
100+
git switch $(git describe --tags --abbrev=0)
101+
nmake /D /f Makefile.msc sqlcipher.dll USE_AMALGAMATION=1 NO_TCL=1 SQLITE3DLL=sqlcipher.dll SQLITE3LIB=sqlcipher.lib SQLITE3EXE=sqlcipher.exe LTLINKOPTS="C:\dev\OpenSSL-${{ matrix.arch }}\lib\libcrypto.lib"
102+
mkdir sqlcipher
103+
copy sqlite3.h sqlcipher
104+
105+
- name: Patch CMakeLists.txt and WXI Variables
106+
run: |
107+
git apply .github\patch\CMakeLists.txt.patch
108+
git apply .github\patch\product.wxs.patch
109+
git apply .github\patch\translations.wxs.patch
110+
git apply .github\patch\variables.wxi.patch
111+
112+
- name: Configure build
113+
run: |
114+
mkdir release-sqlite && cd release-sqlite
115+
if ("${{ matrix.arch }}" -eq "Win32") {
116+
cmake -G "Visual Studio 16 2019" -A "Win32" ..\
117+
} else {
118+
cmake -G "Visual Studio 16 2019" ..\
119+
}
120+
121+
- name: Build
122+
run: cd release-sqlite && devenv /Build Release sqlitebrowser.sln /Project ALL_BUILD
123+
124+
- name: Configure build (SQLCipher)
125+
run: |
126+
mkdir release-sqlcipher && cd release-sqlcipher
127+
if ("${{ matrix.arch }}" -eq "Win32") {
128+
cmake -G "Visual Studio 16 2019" -Dsqlcipher=1 -A "Win32" ..\
129+
} else {
130+
cmake -G "Visual Studio 16 2019" -Dsqlcipher=1 ..\
131+
}
132+
133+
- name: Build
134+
run: |
135+
cd release-sqlcipher
136+
devenv /Build Release sqlitebrowser.sln /Project ALL_BUILD
137+
mv "Release\DB Browser for SQLite.exe" "Release\DB Browser for SQLCipher.exe"
138+
139+
- name: Package
140+
env:
141+
ExePath: ${{ github.workspace }}
142+
OpenSSLPath: C:\dev\OpenSSL-${{ matrix.arch }}
143+
SQLCipherPath: C:\dev\SQLCipher-${{ matrix.arch }}
144+
SQLitePath: C:\dev\SQLite-${{ matrix.arch }}
145+
run: |
146+
cd installer/windows
147+
./build.cmd "${{ matrix.arch }}".ToLower()
148+
# FIXME:
149+
dir
150+
151+
- name: Upload artifacts
152+
uses: actions/upload-artifact@v3
153+
with:
154+
name: build-artifacts
155+
path: installer\windows\DB.Browser.for.SQLite-*.msi

‎.github/workflows/cppcmake.yml‎

Lines changed: 5 additions & 1 deletion

0 commit comments

Comments
 (0)