Skip to content

Commit 4e91be7

Browse files
committed
Upgrade to Sqlite 3.28.0
Download sqlite on demand when building. Remove old unused static sqlite source files. No longer use keyword "nothing" in examples or tests because it leads to a SQL error. (NOTHING is now a reserved word in Sqlite)
1 parent a85a60a commit 4e91be7

20 files changed

+613307
-803754
lines changed

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,25 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2020
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2121
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
SOFTWARE.
23+
24+
25+
26+
# Some portions of the Makefile taken from:
27+
Copyright 2017 Ryusei Yamaguchi
28+
29+
Permission is hereby granted, free of charge, to any person obtaining a copy of
30+
this software and associated documentation files (the "Software"), to deal in
31+
the Software without restriction, including without limitation the rights to
32+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
33+
the Software, and to permit persons to whom the Software is furnished to do so,
34+
subject to the following conditions:
35+
36+
The above copyright notice and this permission notice shall be included in all
37+
copies or substantial portions of the Software.
38+
39+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
40+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
41+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
42+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
43+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
44+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Makefile

Lines changed: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
# Note: Last built with version 1.38.30 of Emscripten
22

33
# TODO: Emit a file showing which version of emcc and SQLite was used to compile the emitted output.
4-
# TODO: Make it easier to use a newer version of Sqlite.
54
# TODO: Create a release on Github with these compiled assets rather than checking them in
65
# TODO: Consider creating different files based on browser vs module usage: https://github.com/vuejs/vue/tree/dev/dist
76

7+
# I got this handy makefile syntax from : https://github.com/mandel59/sqlite-wasm (MIT License) Credited in LICENSE
8+
# To use another version of Sqlite, visit https://www.sqlite.org/download.html and copy the appropriate values here:
9+
SQLITE_AMALGAMATION = sqlite-amalgamation-3280000
10+
SQLITE_AMALGAMATION_ZIP_URL = https://www.sqlite.org/2019/sqlite-amalgamation-3280000.zip
11+
SQLITE_AMALGAMATION_ZIP_SHA1 = eb82fcc95104c8e2d9550ab023c1054b9cc40a76
12+
13+
# Note that extension-functions.c hasn't been updated since 2010-02-06, so likely doesn't need to be updated
14+
EXTENSION_FUNCTIONS = extension-functions.c
15+
EXTENSION_FUNCTIONS_URL = https://www.sqlite.org/contrib/download/extension-functions.c?get=25
16+
EXTENSION_FUNCTIONS_SHA1 = c68fa706d6d9ff98608044c00212473f9c14892f
17+
818
EMCC=emcc
919

1020
CFLAGS=-O2 -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_DISABLE_LFS -DLONGDOUBLE_TYPE=double -DSQLITE_THREADSAFE=0 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS
@@ -117,19 +127,61 @@ out/api.js: src/output-pre.js src/api.coffee src/exports.coffee src/api-data.cof
117127
cat src/output-pre.js $@ src/output-post.js > out/api-wrapped.js
118128
mv out/api-wrapped.js $@
119129

120-
out/sqlite3.bc: sqlite/sqlite3.c
130+
out/sqlite3.bc: sqlite-src/$(SQLITE_AMALGAMATION)
121131
# Generate llvm bitcode
122-
$(EMCC) $(CFLAGS) sqlite/sqlite3.c -o out/sqlite3.bc
132+
$(EMCC) $(CFLAGS) sqlite-src/$(SQLITE_AMALGAMATION)/sqlite3.c -o $@
123133

124-
out/extension-functions.bc: sqlite/extension-functions.c
125-
$(EMCC) $(CFLAGS) -s LINKABLE=1 sqlite/extension-functions.c -o out/extension-functions.bc
134+
out/extension-functions.bc: sqlite-src/$(SQLITE_AMALGAMATION)/$(EXTENSION_FUNCTIONS)
135+
$(EMCC) $(CFLAGS) -s LINKABLE=1 sqlite-src/$(SQLITE_AMALGAMATION)/extension-functions.c -o $@
126136

127137
# TODO: This target appears to be unused. If we re-instatate it, we'll need to add more files inside of the JS folder
128138
# module.tar.gz: test package.json AUTHORS README.md dist/sql-asm.js
129139
# tar --create --gzip $^ > $@
130140

131-
.PHONY: clean
132-
clean:
133-
rm -f out/* dist/*
141+
## cache
142+
143+
.PHONY: clean-cache
144+
clean-cache:
145+
rm -rf cache
146+
147+
cache/$(SQLITE_AMALGAMATION).zip:
148+
mkdir -p cache
149+
curl -LsSf '$(SQLITE_AMALGAMATION_ZIP_URL)' -o $@
150+
151+
cache/$(EXTENSION_FUNCTIONS):
152+
mkdir -p cache
153+
curl -LsSf '$(EXTENSION_FUNCTIONS_URL)' -o $@
154+
155+
## sqlite-src
156+
157+
.PHONY: clean-sqlite-src
158+
clean-sqlite-src:
159+
rm -rf sqlite
160+
161+
.PHONY: sqlite-src
162+
sqlite-src: sqlite-src/$(SQLITE_AMALGAMATION) sqlite-src/$(EXTENSION_FUNCTIONS)
163+
164+
sqlite-src/$(SQLITE_AMALGAMATION): cache/$(SQLITE_AMALGAMATION).zip
165+
mkdir -p sqlite-src
166+
echo '$(SQLITE_AMALGAMATION_ZIP_SHA1) ./cache/$(SQLITE_AMALGAMATION).zip' > cache/check.txt
167+
sha1sum -c cache/check.txt
168+
rm -rf $@
169+
unzip 'cache/$(SQLITE_AMALGAMATION).zip' -d sqlite-src/
170+
touch $@
171+
172+
sqlite-src/$(SQLITE_AMALGAMATION)/$(EXTENSION_FUNCTIONS): cache/$(EXTENSION_FUNCTIONS)
173+
mkdir -p sqlite-src
174+
echo '$(EXTENSION_FUNCTIONS_SHA1) ./cache/$(EXTENSION_FUNCTIONS)' > cache/check.txt
175+
sha1sum -c cache/check.txt
176+
cp 'cache/$(EXTENSION_FUNCTIONS)' $@
177+
178+
179+
.PHONY: clean
180+
clean:
181+
rm -rf out/* dist/*
134182

183+
.PHONY: clean-all
184+
clean-all:
185+
rm -f out/* dist/* cache/*
186+
rm -rf sqlite-src/
135187

0 commit comments

Comments
 (0)