Skip to content

Commit 443565b

Browse files
committed
First attempt at Windows support
1 parent d8eca33 commit 443565b

File tree

2 files changed

+72
-2
lines changed

2 files changed

+72
-2
lines changed

.github/workflows/compile_sqlite.yml

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ jobs:
4444
matrix:
4545
# We only really need this for Ubuntu, but we recommend users run the same
4646
# steps so we better make sure they work on all platforms.
47-
#os: [ubuntu-latest, macos-latest, windows-latest]
4847
os: [ubuntu-latest, macos-latest]
4948

5049
runs-on: ${{ matrix.os }}
@@ -85,3 +84,46 @@ jobs:
8584
path: out/
8685
if-no-files-found: error
8786
retention-days: 1
87+
88+
build_sqlite_windows:
89+
needs: [download_sqlite]
90+
strategy:
91+
matrix:
92+
arch: [amd64, amd64_x86, amd64_arm64]
93+
94+
runs-on: windows-latest
95+
name: Compile sqlite3 Windows
96+
steps:
97+
- uses: actions/checkout@v4
98+
# - uses: actions/cache@v4
99+
# id: cache_build
100+
# with:
101+
# path: out/
102+
# key: sqlite-prebuilt-${{ runner.os }}-${{ matrix.arch }}-${{ hashFiles('tool/') }}
103+
104+
- name: Download sqlite3 sources
105+
# if: steps.cache_build.outputs.cache-hit != 'true'
106+
uses: actions/download-artifact@v4
107+
with:
108+
name: sqlite3-src
109+
path: sqlite3-src
110+
111+
- uses: dart-lang/setup-dart@v1
112+
# if: steps.cache_build.outputs.cache-hit != 'true'
113+
114+
- uses: ilammy/msvc-dev-cmd@v1
115+
with:
116+
arch: ${{ matrix.arch }}
117+
118+
- name: Compile sqlite3
119+
# if: steps.cache_build.outputs.cache-hit != 'true'
120+
run: |
121+
dart run tool/compile_sqlite.dart
122+
123+
- name: Upload sqlite3 binaries
124+
uses: actions/upload-artifact@v4
125+
with:
126+
name: sqlite3-libs-${{ runner.os }}-${{ matrix.arch }}
127+
path: out/
128+
if-no-files-found: error
129+
retention-days: 1

tool/compile_sqlite.dart

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ final defines = const LineSplitter()
77
.map((line) => '-D$line')
88
.toList();
99

10-
void main() async {
10+
void main(List<String> args) async {
1111
await Directory('out').create();
1212

1313
if (Platform.isLinux) {
@@ -25,6 +25,34 @@ void main() async {
2525
_compileAndroid(triple, name, sqlite3mc)
2626
]
2727
], eagerError: true);
28+
} else if (Platform.isWindows) {
29+
final abiName = args.single;
30+
final defines = const LineSplitter()
31+
.convert(_defaultDefines)
32+
.map((line) => line.trim())
33+
.map((line) => '/D$line');
34+
35+
for (final sqlite3Ciphers in [false, true]) {
36+
final args = [
37+
'/LD',
38+
sqlite3Ciphers
39+
? r'sqlite3-src\sqlite3mc\sqlite3mc_amalgamation.c'
40+
: r'sqlite3-src\sqlite3\sqlite3.c',
41+
'/DSQLITE_EXPORT=__declspec(dllexport)',
42+
'/O2',
43+
...defines,
44+
'/I',
45+
sqlite3Ciphers ? r'sqlite3-src\sqlite3mc' : 'sqlite3-src\sqlite3',
46+
'-o',
47+
'/Fe:out\win-$abiName-sqlite3${sqlite3Ciphers ? 'mc' : ''}.dll'
48+
];
49+
50+
print('Running cl ${args.join(' ')}');
51+
final result = await Process.run('cl', args);
52+
if (result.exitCode != 0) {
53+
throw 'Compiling for $abiName (ciphers: $sqlite3Ciphers) failed: ${result.stdout}\n ${result.stderr}';
54+
}
55+
}
2856
}
2957
}
3058

0 commit comments

Comments
 (0)