Skip to content

Commit e38ecaf

Browse files
committed
Do not pollute the global namespace
Fixes #7.
1 parent 02d0e73 commit e38ecaf

File tree

3 files changed

+245
-238
lines changed

3 files changed

+245
-238
lines changed

Makefile

+13-14
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,21 @@ CFLAGS=-DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_DISABLE_LFS -DLONGDOUBLE_TYPE=doubl
77
EXPORTED_FUNCTIONS="['_sqlite3_open', '_sqlite3_close', '_sqlite3_exec', '_sqlite3_free', '_sqlite3_data_count', '_sqlite3_column_type', '_sqlite3_column_text', '_sqlite3_column_double', '_sqlite3_prepare_v2', '_sqlite3_step', '_sqlite3_bind_text', '_sqlite3_bind_double', '_sqlite3_reset', '_sqlite3_finalize']"
88

99

10-
all: js/sql.js test/benchmark.js test/benchmark
10+
all: js/sql.js js/sql-api.js
1111

12-
js/sql.js: c/sqlite3.bc js/pre.js js/post.js
13-
$(EMCC) -s ASM_JS=1 $(CFLAGS) c/sqlite3.c --pre-js js/pre.js --post-js js/post.js -o js/sql.js -s EXPORTED_FUNCTIONS=$(EXPORTED_FUNCTIONS)
12+
# Old version, without prepared statements
13+
js/sql.js: js/shell-pre.js js/sql-raw.js js/shell-post.js
14+
cat js/shell-pre.js js/sql-raw.js js/shell-post.js > js/sql.js
1415

15-
js/sql-faststart.js: c/sqlite3.bc js/pre.js js/post.js
16-
$(EMCC) -s ASM_JS=2 $(CFLAGS) c/sqlite3.c --pre-js js/pre.js --post-js js/post.js -o js/sql-faststart.js -s EXPORTED_FUNCTIONS=$(EXPORTED_FUNCTIONS)
16+
js/sql-raw.js: c/sqlite3.bc js/pre.js js/post.js
17+
$(EMCC) -s ASM_JS=1 $(CFLAGS) c/sqlite3.c --pre-js js/pre.js --post-js js/post.js -o js/sql-raw.js -s EXPORTED_FUNCTIONS=$(EXPORTED_FUNCTIONS)
1718

18-
js/sql-api.js: c/sqlite3.bc js/api.js
19-
$(EMSCRIPTEN)/emcc -s RESERVED_FUNCTION_POINTERS=2 $(CFLAGS) c/sqlite3.c --post-js js/api.js -o js/sql-api.js -s EXPORTED_FUNCTIONS=$(EXPORTED_FUNCTIONS)
19+
# Object-oriented API
20+
js/sql-api.js: js/shell-pre.js js/sql-api-raw.js js/api-post.js
21+
cat js/shell-pre.js js/sql-api-raw.js js/api-post.js > js/sql-api.js
22+
23+
js/sql-api-raw.js: c/sqlite3.bc js/api.js
24+
$(EMSCRIPTEN)/emcc -s RESERVED_FUNCTION_POINTERS=2 $(CFLAGS) c/sqlite3.c --post-js js/api.js -o js/sql-api-raw.js -s EXPORTED_FUNCTIONS=$(EXPORTED_FUNCTIONS)
2025

2126
js/api.js: js/api.coffee
2227
coffee -b -c js/api.coffee
@@ -25,12 +30,6 @@ c/sqlite3.bc: c/sqlite3.c
2530
# Generate llvm bitcode
2631
$(EMCC) $(CFLAGS) c/sqlite3.c -o c/sqlite3.bc
2732

28-
test/benchmark.js: c/sqlite3.c c/benchmark.c
29-
$(EMCC) $(CFLAGS) c/sqlite3.bc c/benchmark.c -o test/benchmark.js
30-
31-
test/benchmark: c/benchmark.c c/sqlite3.c
32-
$(CC) $(CFLAGS) -pthread c/sqlite3.c c/benchmark.c -o test/benchmark -ldl
33-
3433
clean:
35-
rm -rf js/sql.js test/benchmark.js test/benchmark
34+
rm -rf js/sql.js js/sql-api.js js/sql-raw.js c/sqlite3.bc
3635

js/post.js

-1
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,3 @@ Module['open'] = function(data) {
7171
};
7272

7373
this['SQL'] = Module;
74-

0 commit comments

Comments
 (0)