1
1
# dependencies
2
- SQLITE_VERSION = version-3.47.0
3
- SQLITE_TARBALL_URL = https://www.sqlite.org/src/tarball/sqlite.tar.gz?r=${SQLITE_VERSION}
4
-
2
+ SQLITE_VERSION = 3.47.0
3
+ MC_SQLITE_VERSION = 1.9.0
4
+ SQLITE_TARBALL_URL = https://www.sqlite.org/src/tarball/sqlite.tar.gz?r=version-${SQLITE_VERSION}
5
+ MC_SQLITE_URL = https://github.com/utelle/SQLite3MultipleCiphers/releases/download/v${MC_SQLITE_VERSION}/sqlite3mc-${MC_SQLITE_VERSION}-sqlite-${SQLITE_VERSION}-amalgamation.zip
5
6
EXTENSION_FUNCTIONS = extension-functions.c
6
7
EXTENSION_FUNCTIONS_URL = https://www.sqlite.org/contrib/download/extension-functions.c?get=25
7
8
EXTENSION_FUNCTIONS_SHA3 = ee39ddf5eaa21e1d0ebcbceeab42822dd0c4f82d8039ce173fd4814807faabfa
@@ -21,6 +22,17 @@ CFILES = \
21
22
22
23
POWERSYNC_CFILES = $(notdir $(wildcard powersync-static/* .c) )
23
24
25
+ MC_CFILES = \
26
+ sqlite3mc_amalgamation.c \
27
+ extension-functions.c \
28
+ main.c \
29
+ libauthorizer.c \
30
+ libfunction.c \
31
+ libhook.c \
32
+ libprogress.c \
33
+ libvfs.c \
34
+ $(CFILES_EXTRA )
35
+
24
36
JSFILES = \
25
37
src/libauthorizer.js \
26
38
src/libfunction.js \
@@ -35,9 +47,11 @@ vpath %.c powersync-static
35
47
36
48
POWERSYNC_EXPORTED_FUNCTIONS = powersync-static/powersync_exported_functions.json
37
49
EXPORTED_FUNCTIONS = src/exported_functions.json
50
+ MC_EXPORTED_FUNCTIONS = multiple-ciphers/mc_exported_functions.json
38
51
39
52
# EMCC does not support multiple exports files. Need to combine them temporarily
40
53
COMBINED_EXPORTED_FUNCTIONS = tmp/combined_exports.json
54
+ MC_COMBINED_EXPORTED_FUNCTIONS = tmp/mc_combined_exports.json
41
55
42
56
EXPORTED_RUNTIME_METHODS = src/extra_exported_runtime_methods.json
43
57
ASYNCIFY_IMPORTS = src/asyncify_imports.json
@@ -51,6 +65,9 @@ POWERSYNC_OBJ_FILES_DEBUG = $(patsubst %.c,tmp/powersync-obj/debug/%.o,$(POWERSY
51
65
POWERSYNC_OBJ_FILES_DIST = $(patsubst % .c,tmp/powersync-obj/dist/% .o,$(POWERSYNC_CFILES ) )
52
66
POWERSYNC_STATIC_FILES = powersync-libs/libpowersync-wasm.a
53
67
68
+ MC_OBJ_FILES_DEBUG = $(patsubst % .c,tmp/mc-obj/debug/% .o,$(MC_CFILES ) )
69
+ MC_OBJ_FILES_DIST = $(patsubst % .c,tmp/mc-obj/dist/% .o,$(MC_CFILES ) )
70
+
54
71
# build options
55
72
EMCC ?= emcc
56
73
@@ -99,6 +116,10 @@ COMBINED_EMFLAGS_INTERFACES = \
99
116
-s EXPORTED_FUNCTIONS=@$(COMBINED_EXPORTED_FUNCTIONS ) \
100
117
-s EXPORTED_RUNTIME_METHODS=@$(EXPORTED_RUNTIME_METHODS )
101
118
119
+ MC_COMBINED_EMFLAGS_INTERFACES = \
120
+ -s EXPORTED_FUNCTIONS=@$(MC_COMBINED_EXPORTED_FUNCTIONS ) \
121
+ -s EXPORTED_RUNTIME_METHODS=@$(EXPORTED_RUNTIME_METHODS )
122
+
102
123
EMFLAGS_LIBRARIES = \
103
124
--js-library src/libadapters.js \
104
125
--post-js src/libauthorizer.js \
@@ -129,6 +150,7 @@ WASQLITE_DEFINES = \
129
150
-DSQLITE_DEFAULT_MEMSTATUS=0 \
130
151
-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 \
131
152
-DSQLITE_DQS=0 \
153
+ -D__WASM__ \
132
154
-DSQLITE_LIKE_DOESNT_MATCH_BLOBS \
133
155
-DSQLITE_MAX_EXPR_DEPTH=0 \
134
156
-DSQLITE_OMIT_AUTOINIT \
@@ -171,12 +193,23 @@ clean-deps:
171
193
$(COMBINED_EXPORTED_FUNCTIONS ) : $(EXPORTED_FUNCTIONS ) $(POWERSYNC_EXPORTED_FUNCTIONS )
172
194
jq -s ' add' $(EXPORTED_FUNCTIONS ) $(POWERSYNC_EXPORTED_FUNCTIONS ) > $(COMBINED_EXPORTED_FUNCTIONS )
173
195
196
+ $(MC_COMBINED_EXPORTED_FUNCTIONS ) : $(EXPORTED_FUNCTIONS ) $(POWERSYNC_EXPORTED_FUNCTIONS ) $(MC_EXPORTED_FUNCTIONS )
197
+ jq -s ' add' $(EXPORTED_FUNCTIONS ) $(POWERSYNC_EXPORTED_FUNCTIONS ) $(MC_EXPORTED_FUNCTIONS ) > $(MC_COMBINED_EXPORTED_FUNCTIONS )
198
+
174
199
deps/$(SQLITE_VERSION ) /sqlite3.h deps/$(SQLITE_VERSION ) /sqlite3.c :
175
200
mkdir -p cache/$(SQLITE_VERSION )
176
201
curl -LsS $(SQLITE_TARBALL_URL ) | tar -xzf - -C cache/$(SQLITE_VERSION ) / --strip-components=1
177
202
mkdir -p deps/$(SQLITE_VERSION )
178
203
(cd deps/$( SQLITE_VERSION) ; ../../cache/$( SQLITE_VERSION) /configure --enable-all && make sqlite3.c)
179
204
205
+ # Download and extract sqlite3mc_amalgamation.c to the deps directory
206
+ deps/$(SQLITE_VERSION ) /sqlite3mc_amalgamation.c :
207
+ mkdir -p cache/sqlite3mc-$(MC_SQLITE_VERSION )
208
+ curl -LsS $(MC_SQLITE_URL ) -o cache/sqlite3mc-$(MC_SQLITE_VERSION ) /sqlite3mc.zip
209
+ unzip -o cache/sqlite3mc-$(MC_SQLITE_VERSION ) /sqlite3mc.zip -d cache/sqlite3mc-$(MC_SQLITE_VERSION )
210
+ rm -rf cache/sqlite3mc-$(MC_SQLITE_VERSION ) /sqlite3mc.zip
211
+ cp cache/sqlite3mc-$(MC_SQLITE_VERSION ) /sqlite3mc_amalgamation.c deps/$(SQLITE_VERSION ) /sqlite3mc_amalgamation.c
212
+
180
213
# Download static files from PowerSync Core repository
181
214
$(POWERSYNC_STATIC_FILES ) :
182
215
node scripts/download-core-build.js
@@ -241,14 +274,24 @@ tmp/powersync-obj/dist/%.o: %.c
241
274
mkdir -p tmp/powersync-obj/dist
242
275
$(EMCC ) $(CFLAGS_DIST ) $(WASQLITE_DEFINES ) $^ -c -o $@
243
276
277
+ # Build multiple ciphers
278
+ tmp/mc-obj/debug/% .o : % .c
279
+ mkdir -p tmp/mc-obj/debug
280
+ $(EMCC ) $(CFLAGS_DEBUG ) $(WASQLITE_DEFINES ) $^ -c -o $@
281
+
282
+ # Build multiple ciphers
283
+ tmp/mc-obj/dist/% .o : % .c
284
+ mkdir -p tmp/mc-obj/dist
285
+ $(EMCC ) $(CFLAGS_DIST ) $(WASQLITE_DEFINES ) $^ -c -o $@
286
+
244
287
245
288
# # debug
246
289
.PHONY : clean-debug
247
290
clean-debug :
248
291
rm -rf debug
249
292
250
293
.PHONY : debug
251
- debug : debug/wa-sqlite.mjs debug/wa-sqlite-async.mjs debug/wa-sqlite-jspi.mjs debug/wa-sqlite-dynamic-main.mjs debug/wa-sqlite-dynamic-main-async.mjs
294
+ debug : debug/wa-sqlite.mjs debug/wa-sqlite-async.mjs debug/wa-sqlite-jspi.mjs debug/wa-sqlite-dynamic-main.mjs debug/wa-sqlite-dynamic-main-async.mjs debug/mc-wa-sqlite.mjs debug/mc-wa-sqlite-async.mjs debug/mc-wa-sqlite-jspi.mjs
252
295
253
296
# Statically links PowerSync Core
254
297
debug/wa-sqlite.mjs : $(OBJ_FILES_DEBUG ) $(POWERSYNC_OBJ_FILES_DEBUG ) $(EXPORTED_FUNCTIONS ) $(EXPORTED_RUNTIME_METHODS ) $(POWERSYNC_STATIC_FILES ) $(COMBINED_EXPORTED_FUNCTIONS )
@@ -261,7 +304,7 @@ debug/wa-sqlite.mjs: $(OBJ_FILES_DEBUG) $(POWERSYNC_OBJ_FILES_DEBUG) $(EXPORTED_
261
304
$(POWERSYNC_OBJ_FILES_DEBUG ) -o $@
262
305
263
306
# Statically links PowerSync Core
264
- debug/wa-sqlite-async.mjs : $(OBJ_FILES_DEBUG ) $(POWERSYNC_OBJ_FILES_DEBUG ) $(EXPORTED_FUNCTIONS ) $(EXPORTED_RUNTIME_METHODS ) $(ASYNCIFY_IMPORTS ) $(POWERSYNC_STATIC_FILES ) $(COMBINED_EXPORTED_FUNCTIONS )
307
+ debug/wa-sqlite-async.mjs : $(OBJ_FILES_DEBUG ) $(POWERSYNC_OBJ_FILES_DEBUG ) $(EXPORTED_FUNCTIONS ) $(EXPORTED_RUNTIME_METHODS ) $(ASYNCIFY_IMPORTS ) $(POWERSYNC_STATIC_FILES ) $(COMBINED_EXPORTED_FUNCTIONS )
265
308
mkdir -p debug
266
309
$(EMCC ) $(EMFLAGS_DEBUG ) \
267
310
$(COMBINED_EMFLAGS_INTERFACES ) \
@@ -272,7 +315,7 @@ debug/wa-sqlite-async.mjs: $(OBJ_FILES_DEBUG) $(POWERSYNC_OBJ_FILES_DEBUG) $(EX
272
315
$(OBJ_FILES_DEBUG ) -o $@
273
316
274
317
# Statically links PowerSync Core
275
- debug/wa-sqlite-jspi.mjs : $(OBJ_FILES_DEBUG ) $(POWERSYNC_OBJ_FILES_DEBUG ) $(JSFILES ) $(EXPORTED_FUNCTIONS ) $(EXPORTED_RUNTIME_METHODS ) $(ASYNCIFY_IMPORTS ) $(POWERSYNC_STATIC_FILES ) $(COMBINED_EXPORTED_FUNCTIONS )
318
+ debug/wa-sqlite-jspi.mjs : $(OBJ_FILES_DEBUG ) $(POWERSYNC_OBJ_FILES_DEBUG ) $(JSFILES ) $(EXPORTED_FUNCTIONS ) $(EXPORTED_RUNTIME_METHODS ) $(ASYNCIFY_IMPORTS ) $(POWERSYNC_STATIC_FILES ) $(COMBINED_EXPORTED_FUNCTIONS )
276
319
mkdir -p debug
277
320
$(EMCC ) $(EMFLAGS_DEBUG ) $(EMFLAGS_DYNAMIC ) \
278
321
$(COMBINED_EMFLAGS_INTERFACES ) \
@@ -282,6 +325,38 @@ debug/wa-sqlite-jspi.mjs: $(OBJ_FILES_DEBUG) $(POWERSYNC_OBJ_FILES_DEBUG) $(JSFI
282
325
$(POWERSYNC_OBJ_FILES_DEBUG ) \
283
326
$(OBJ_FILES_DEBUG ) -o $@
284
327
328
+ # Statically links PowerSync Core
329
+ debug/mc-wa-sqlite.mjs : $(MC_OBJ_FILES_DEBUG ) $(POWERSYNC_OBJ_FILES_DEBUG ) $(EXPORTED_FUNCTIONS ) $(EXPORTED_RUNTIME_METHODS ) $(POWERSYNC_STATIC_FILES ) $(MC_COMBINED_EXPORTED_FUNCTIONS )
330
+ mkdir -p debug
331
+ $(EMCC ) $(EMFLAGS_DEBUG ) \
332
+ $(COMBINED_EMFLAGS_INTERFACES ) \
333
+ $(EMFLAGS_LIBRARIES ) \
334
+ $(POWERSYNC_STATIC_FILES ) \
335
+ $(OBJ_FILES_DEBUG ) \
336
+ $(MC_OBJ_FILES_DEBUG ) -o $@
337
+
338
+ # Statically links PowerSync Core
339
+ debug/mc-wa-sqlite-async.mjs : $(MC_OBJ_FILES_DEBUG ) $(POWERSYNC_OBJ_FILES_DEBUG ) $(EXPORTED_FUNCTIONS ) $(EXPORTED_RUNTIME_METHODS ) $(ASYNCIFY_IMPORTS ) $(POWERSYNC_STATIC_FILES ) $(MC_COMBINED_EXPORTED_FUNCTIONS )
340
+ mkdir -p debug
341
+ $(EMCC ) $(EMFLAGS_DEBUG ) \
342
+ $(COMBINED_EMFLAGS_INTERFACES ) \
343
+ $(EMFLAGS_LIBRARIES ) \
344
+ $(EMFLAGS_ASYNCIFY_DEBUG ) \
345
+ $(POWERSYNC_STATIC_FILES ) \
346
+ $(POWERSYNC_OBJ_FILES_DEBUG ) \
347
+ $(MC_OBJ_FILES_DEBUG ) -o $@
348
+
349
+ # Statically links PowerSync Core
350
+ debug/mc-wa-sqlite-jspi.mjs : $(MC_OBJ_FILES_DEBUG ) $(POWERSYNC_OBJ_FILES_DEBUG ) $(JSFILES ) $(EXPORTED_FUNCTIONS ) $(EXPORTED_RUNTIME_METHODS ) $(ASYNCIFY_IMPORTS ) $(POWERSYNC_STATIC_FILES ) $(MC_COMBINED_EXPORTED_FUNCTIONS )
351
+ mkdir -p debug
352
+ $(EMCC ) $(EMFLAGS_DEBUG ) $(EMFLAGS_DYNAMIC ) \
353
+ $(COMBINED_EMFLAGS_INTERFACES ) \
354
+ $(EMFLAGS_LIBRARIES ) \
355
+ $(EMFLAGS_JSPI ) \
356
+ $(POWERSYNC_STATIC_FILES ) \
357
+ $(POWERSYNC_OBJ_FILES_DEBUG ) \
358
+ $(MC_OBJ_FILES_DEBUG ) -o $@
359
+
285
360
286
361
# Dynamic main module
287
362
# Exported functions are omitted here since everything is currently exported
@@ -330,10 +405,10 @@ clean-dist:
330
405
rm -rf dist
331
406
332
407
.PHONY : dist
333
- dist : dist/wa-sqlite.mjs dist/wa-sqlite-async.mjs dist/wa-sqlite-jspi.mjs dist/wa-sqlite-dynamic-main.mjs dist/wa-sqlite-async-dynamic-main.mjs
408
+ dist : dist/wa-sqlite.mjs dist/wa-sqlite-async.mjs dist/wa-sqlite-jspi.mjs dist/wa-sqlite-dynamic-main.mjs dist/wa-sqlite-async-dynamic-main.mjs dist/mc-wa-sqlite.mjs dist/mc-wa-sqlite-async.mjs dist/mc-wa-sqlite-jspi.mjs
334
409
335
410
# Statically links PowerSync Core
336
- dist/wa-sqlite.mjs : $(OBJ_FILES_DIST ) $(POWERSYNC_OBJ_FILES_DIST ) $(EXPORTED_FUNCTIONS ) $(EXPORTED_RUNTIME_METHODS ) $(POWERSYNC_STATIC_FILES ) $(COMBINED_EXPORTED_FUNCTIONS )
411
+ dist/wa-sqlite.mjs : $(OBJ_FILES_DIST ) $(POWERSYNC_OBJ_FILES_DIST ) $(EXPORTED_FUNCTIONS ) $(EXPORTED_RUNTIME_METHODS ) $(POWERSYNC_STATIC_FILES ) $(COMBINED_EXPORTED_FUNCTIONS )
337
412
mkdir -p dist
338
413
$(EMCC ) $(EMFLAGS_DIST ) \
339
414
$(COMBINED_EMFLAGS_INTERFACES ) \
@@ -343,7 +418,7 @@ dist/wa-sqlite.mjs: $(OBJ_FILES_DIST) $(POWERSYNC_OBJ_FILES_DIST) $(EXPORTED_FUN
343
418
$(OBJ_FILES_DIST ) -o $@
344
419
345
420
# Statically links PowerSync Core
346
- dist/wa-sqlite-async.mjs : $(OBJ_FILES_DIST ) $(POWERSYNC_OBJ_FILES_DIST ) $(EXPORTED_FUNCTIONS ) $(EXPORTED_RUNTIME_METHODS ) $(ASYNCIFY_IMPORTS ) $(POWERSYNC_STATIC_FILES ) $(COMBINED_EXPORTED_FUNCTIONS )
421
+ dist/wa-sqlite-async.mjs : $(OBJ_FILES_DIST ) $(POWERSYNC_OBJ_FILES_DIST ) $(EXPORTED_FUNCTIONS ) $(EXPORTED_RUNTIME_METHODS ) $(ASYNCIFY_IMPORTS ) $(POWERSYNC_STATIC_FILES ) $(COMBINED_EXPORTED_FUNCTIONS )
347
422
mkdir -p dist
348
423
$(EMCC ) $(EMFLAGS_DIST ) \
349
424
$(COMBINED_EMFLAGS_INTERFACES ) \
@@ -354,7 +429,7 @@ dist/wa-sqlite-async.mjs: $(OBJ_FILES_DIST) $(POWERSYNC_OBJ_FILES_DIST) $(EXPORT
354
429
$(OBJ_FILES_DIST ) -o $@
355
430
356
431
# Statically links PowerSync Core
357
- dist/wa-sqlite-jspi.mjs : $(OBJ_FILES_DIST ) $(POWERSYNC_OBJ_FILES_DIST ) $(JSFILES ) $(EXPORTED_FUNCTIONS ) $(EXPORTED_RUNTIME_METHODS ) $(ASYNCIFY_IMPORTS ) $(POWERSYNC_STATIC_FILES ) $(COMBINED_EXPORTED_FUNCTIONS )
432
+ dist/wa-sqlite-jspi.mjs : $(OBJ_FILES_DIST ) $(POWERSYNC_OBJ_FILES_DIST ) $(JSFILES ) $(EXPORTED_FUNCTIONS ) $(EXPORTED_RUNTIME_METHODS ) $(ASYNCIFY_IMPORTS ) $(POWERSYNC_STATIC_FILES ) $(COMBINED_EXPORTED_FUNCTIONS )
358
433
mkdir -p dist
359
434
$(EMCC ) $(EMFLAGS_DIST ) \
360
435
$(COMBINED_EMFLAGS_INTERFACES ) \
@@ -364,6 +439,38 @@ dist/wa-sqlite-jspi.mjs: $(OBJ_FILES_DIST) $(POWERSYNC_OBJ_FILES_DIST) $(JSFILES
364
439
$(POWERSYNC_OBJ_FILES_DIST ) \
365
440
$(OBJ_FILES_DIST ) -o $@
366
441
442
+ # Statically links PowerSync Core with multiple ciphers
443
+ dist/mc-wa-sqlite.mjs : $(MC_OBJ_FILES_DIST ) $(POWERSYNC_OBJ_FILES_DIST ) $(EXPORTED_FUNCTIONS ) $(EXPORTED_RUNTIME_METHODS ) $(POWERSYNC_STATIC_FILES ) $(MC_COMBINED_EXPORTED_FUNCTIONS )
444
+ mkdir -p dist
445
+ $(EMCC ) $(EMFLAGS_DIST ) \
446
+ $(MC_COMBINED_EMFLAGS_INTERFACES ) \
447
+ $(EMFLAGS_LIBRARIES ) \
448
+ $(POWERSYNC_STATIC_FILES ) \
449
+ $(POWERSYNC_OBJ_FILES_DIST ) \
450
+ $(MC_OBJ_FILES_DIST ) -o $@
451
+
452
+ # Statically links PowerSync Core with multiple ciphers
453
+ dist/mc-wa-sqlite-async.mjs : $(MC_OBJ_FILES_DIST ) $(POWERSYNC_OBJ_FILES_DIST ) $(EXPORTED_FUNCTIONS ) $(EXPORTED_RUNTIME_METHODS ) $(ASYNCIFY_IMPORTS ) $(POWERSYNC_STATIC_FILES ) $(MC_COMBINED_EXPORTED_FUNCTIONS )
454
+ mkdir -p dist
455
+ $(EMCC ) $(EMFLAGS_DIST ) \
456
+ $(MC_COMBINED_EMFLAGS_INTERFACES ) \
457
+ $(EMFLAGS_LIBRARIES ) \
458
+ $(EMFLAGS_ASYNCIFY_DIST ) \
459
+ $(POWERSYNC_STATIC_FILES ) \
460
+ $(POWERSYNC_OBJ_FILES_DIST ) \
461
+ $(MC_OBJ_FILES_DIST ) -o $@
462
+
463
+ # Statically links PowerSync Core with multiple ciphers
464
+ dist/mc-wa-sqlite-jspi.mjs : $(MC_OBJ_FILES_DIST ) $(POWERSYNC_OBJ_FILES_DIST ) $(JSFILES ) $(EXPORTED_FUNCTIONS ) $(EXPORTED_RUNTIME_METHODS ) $(ASYNCIFY_IMPORTS ) $(POWERSYNC_STATIC_FILES ) $(MC_COMBINED_EXPORTED_FUNCTIONS )
465
+ mkdir -p dist
466
+ $(EMCC ) $(EMFLAGS_DIST ) \
467
+ $(MC_COMBINED_EMFLAGS_INTERFACES ) \
468
+ $(EMFLAGS_LIBRARIES ) \
469
+ $(EMFLAGS_JSPI ) \
470
+ $(POWERSYNC_STATIC_FILES ) \
471
+ $(POWERSYNC_OBJ_FILES_DIST ) \
472
+ $(MC_OBJ_FILES_DIST ) -o $@
473
+
367
474
# Dynamic main module
368
475
# Exported functions are omitted here since everything is currently exported
369
476
dist/wa-sqlite-dynamic-main.mjs : $(OBJ_FILES_DIST ) $(EXPORTED_FUNCTIONS ) $(EXPORTED_RUNTIME_METHODS ) $(COMBINED_EXPORTED_FUNCTIONS )
0 commit comments