将SQLite编译为SQL.js的问题

时间:2018-07-31 07:58:27

标签: javascript sqlite sql.js

我正在尝试使用Emscripten从Git https://github.com/kripken/sql.js上的源代码编译SQL.js,但是我遇到了问题。进行编译的原因是我想在SQLite(-DSQLITE_ENABLE_JSON1)中启用JSON函数。在使用已经编译的文件sql.js(https://raw.githubusercontent.com/kripken/sql.js/master/js/sql.js)之前,它可以正常工作,但是当然没有JSON函数。

我的脚本配置文件:

import os
LLVM_ROOT='c:/test/emsdk/clang/e1.38.10_64bit'
EMSCRIPTEN_NATIVE_OPTIMIZER='c:/test/emsdk/clang/e1.38.10_64bit/optimizer.exe'
BINARYEN_ROOT='c:/test/emsdk/clang/e1.38.10_64bit/binaryen'
NODE_JS='c:/test/emsdk/node/8.9.1_64bit/bin/node.exe'
PYTHON='c:/test/emsdk/python/2.7.13.1_64bit/python-2.7.13.amd64/python.exe'
JAVA='c:/test/emsdk/java/8.152_64bit/bin/java.exe'
EMSCRIPTEN_ROOT='c:/test/emsdk/emscripten/1.38.10'
SPIDERMONKEY_ENGINE = ''
V8_ENGINE = ''
TEMP_DIR = 'c:/users/.../appdata/local/temp'
COMPILER_ENGINE = NODE_JS
JS_ENGINES = [NODE_JS]

因此,当我看到有问题时,我尝试使用Git中的干净Makefile编译干净代码,而没有进行任何更改,而且在这里我也遇到了uglify错误:

Microsoft Windows [Version 10.0.17134.165]
(c) 2018 Microsoft Corporation. Vse pravice pridržane.

C:\Users\...\Downloads\sql.js-master_noChanges\sql.js-master>make
# Generate llvm bitcode
emcc -O2 -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_DISABLE_LFS -DLONGDOUBLE_TYPE=double -DSQLITE_THREADSAFE=0 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS c/sqlite3.c -o c/sqlite3.bc
emcc -O2 -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_DISABLE_LFS -DLONGDOUBLE_TYPE=double -DSQLITE_THREADSAFE=0 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -s LINKABLE=1 c/extension-functions.c -o c/extension-functions.bc
cat coffee/api.coffee coffee/exports.coffee coffee/api-data.coffee | coffee --bare --compile --stdio > js/api.js
emcc --memory-init-file 0 -O3 -s INLINING_LIMIT=50 -s RESERVED_FUNCTION_POINTERS=64 -s EXPORTED_FUNCTIONS=@exported_functions -s EXTRA_EXPORTED_RUNTIME_METHODS=@exported_runtime_methods c/extension-functions.bc c/sqlite3.bc --post-js js/api.js -o js/sql-optimized-raw.js ;\

module.js:538
    throw err;
    ^

Error: Cannot find module '../tools/eliminator/node_modules/uglify-js'
    at Function.Module._resolveFilename (module.js:536:15)
    at Function.Module._load (module.js:466:25)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (c:\test\emsdk\emscripten\1.38.10\tools\js-optimizer.js:132:14)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
ERROR:root:'c:/test/emsdk/node/8.9.1_64bit/bin/node.exe c:\test\emsdk\emscripten\1.38.10\tools\js-optimizer.js C:/Users/.../AppData/Local/Temp\tmplogsqv\sql-optimized-raw.bc.o.js.pp.js.mem.js noPrintMetadata AJSDCE minifyWhitespace' failed
make: *** [js/sql-optimized-raw.js] Error 1

然后,我尝试禁用所有优化,因此将所有EMFLAGS优化属性更改为-O1。对于EMFLAGS,我还添加了-s WASM = 0属性以不使用wasm。此处的编译有效,但有一个警告:

# Generate llvm bitcode
emcc -O2 -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_DISABLE_LFS -DLONGDOUBLE_TYPE=double -DSQLITE_THREADSAFE=0 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS c/sqlite3.c -o c/sqlite3.bc
emcc -O2 -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_DISABLE_LFS -DLONGDOUBLE_TYPE=double -DSQLITE_THREADSAFE=0 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -s LINKABLE=1 c/extension-functions.c -o c/extension-functions.bc
cat coffee/api.coffee coffee/exports.coffee coffee/api-data.coffee | coffee --bare --compile --stdio > js/api.js
emcc --memory-init-file 0 -O1 -s INLINING_LIMIT=50 -s RESERVED_FUNCTION_POINTERS=64 -s WASM=0 -s EXPORTED_FUNCTIONS=@exported_functions -s EXTRA_EXPORTED_RUNTIME_METHODS=@exported_runtime_methods c/extension-functions.bc c/sqlite3.bc --post-js js/api.js -o js/sql-optimized-raw.js ;\

cat js/shell-pre.js js/sql-optimized-raw.js js/shell-post.js > js/sql-optimized.js
cp js/sql-optimized.js js/sql.js
emcc -O1 -g -s INLINING_LIMIT=10 -s RESERVED_FUNCTION_POINTERS=64  -s WASM=0 -s EXPORTED_FUNCTIONS=@exported_functions -s EXTRA_EXPORTED_RUNTIME_METHODS=@exported_runtime_methods c/extension-functions.bc c/sqlite3.bc --post-js js/api.js -o js/sql-debug-raw.js ;\

cat js/shell-pre.js js/sql-debug-raw.js js/shell-post.js > js/sql-debug.js
cat coffee/worker.coffee | coffee --bare --compile --stdio > js/worker.js
cat js/sql.js js/worker.js > js/worker.sql.js
emcc --memory-init-file 0 -O1 -s INLINING_LIMIT=50 -s RESERVED_FUNCTION_POINTERS=64 -s ALLOW_MEMORY_GROWTH=1  -s WASM=0 -s EXPORTED_FUNCTIONS=@exported_functions -s EXTRA_EXPORTED_RUNTIME_METHODS=@exported_runtime_methods c/extension-functions.bc c/sqlite3.bc --post-js js/api.js -o js/sql-memory-growth-raw.js ;\

WARNING:root:not all asm.js optimizations are possible with ALLOW_MEMORY_GROWTH, disabling those. [-Walmost-asm]
cat js/shell-pre.js js/sql-memory-growth-raw.js js/shell-post.js > js/sql-memory-growth.js
rm js/sql-memory-growth-raw.js js/sql-optimized-raw.js js/sql-debug-raw.js

然后,如果我尝试在HTML中包含创建的sql.js文件,我也会遇到问题,如所附屏幕截图所示:Errors with SQL.js included in HTML

有人可以帮助我或指导我该做什么吗?我只需要具有启用的JSON函数(json_extract等)的SQL.js

谢谢。

最好的塞巴斯蒂安

0 个答案:

没有答案