mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Minor build cleanups and fix a harmless race condition in the OPFS part of tester1.js.
FossilOrigin-Name: 70ee6ee014bc4e2c1daa9b4a8909cf76ccecf32de1eb39055f20d3d0b1daa1bd
This commit is contained in:
@ -568,12 +568,14 @@ oz: clean
|
||||
|
||||
include fiddle.make
|
||||
|
||||
ifneq (,$(filter wasmfs,$(MAKECMDGOALS)))
|
||||
# wasmfs build disabled 2022-10-19 per /chat
|
||||
# discussion. OPFS-over-wasmfs was initially a stopgap measure and a
|
||||
# convenient point of comparison for the OPFS sqlite3_vfs's
|
||||
# performance, but it currently doubles our deliverables and build
|
||||
# maintenance burden for very little, if any, benefit.
|
||||
# Only add wasmfs if wasmfs.enable=1 or we're running (dist)clean
|
||||
wasmfs.enable ?= $(if $(filter %clean,$(MAKECMDGOALS)),1,0)
|
||||
ifeq (1,$(wasmfs.enable))
|
||||
# wasmfs build disabled 2022-10-19 per /chat discussion.
|
||||
# OPFS-over-wasmfs was initially a stopgap measure and a convenient
|
||||
# point of comparison for the OPFS sqlite3_vfs's performance, but it
|
||||
# currently doubles our deliverables and build maintenance burden for
|
||||
# little, if any, benefit.
|
||||
#
|
||||
########################################################################
|
||||
# Some platforms do not support the WASMFS build. Raspberry Pi OS is one
|
||||
|
@ -15,9 +15,11 @@
|
||||
#define SQLITE_WASM
|
||||
#ifdef SQLITE_WASM_ENABLE_C_TESTS
|
||||
/*
|
||||
** Functions blocked off by SQLITE_WASM_TESTS are intended solely for
|
||||
** use in unit/regression testing. They may be safely omitted from
|
||||
** client-side builds.
|
||||
** Code blocked off by SQLITE_WASM_TESTS is intended solely for use in
|
||||
** unit/regression testing. They may be safely omitted from
|
||||
** client-side builds. The main unit test script, tester1.js, will
|
||||
** skip related tests if it doesn't find the corresponding functions
|
||||
** in the WASM exports.
|
||||
*/
|
||||
# define SQLITE_WASM_TESTS 1
|
||||
#else
|
||||
@ -1026,7 +1028,7 @@ int sqlite3_wasm_vfs_create_file( sqlite3_vfs *pVfs,
|
||||
pPos += n;
|
||||
}
|
||||
if( 0==rc && nData>0 ){
|
||||
assert(nData<512);
|
||||
assert( nData<blockSize );
|
||||
rc = pIo->xWrite(pFile, pPos, nData, (sqlite3_int64)(pPos - pData));
|
||||
}
|
||||
}
|
||||
@ -1072,7 +1074,7 @@ sqlite3_kvvfs_methods * sqlite3_wasm_kvvfs_methods(void){
|
||||
return &sqlite3KvvfsMethods;
|
||||
}
|
||||
|
||||
#if defined(__EMSCRIPTEN__) && defined(SQLITE_WASM_WASMFS)
|
||||
#if defined(__EMSCRIPTEN__) && defined(SQLITE_ENABLE_WASMFS)
|
||||
#include <emscripten/wasmfs.h>
|
||||
|
||||
/*
|
||||
@ -1093,7 +1095,7 @@ sqlite3_kvvfs_methods * sqlite3_wasm_kvvfs_methods(void){
|
||||
**
|
||||
** Returns 0 on success, SQLITE_NOMEM if instantiation of the backend
|
||||
** object fails, SQLITE_IOERR if mkdir() of the zMountPoint dir in
|
||||
** the virtual FS fails. In builds compiled without SQLITE_WASM_WASMFS
|
||||
** the virtual FS fails. In builds compiled without SQLITE_ENABLE_WASMFS
|
||||
** defined, SQLITE_NOTFOUND is returned without side effects.
|
||||
*/
|
||||
SQLITE_WASM_KEEP
|
||||
@ -1102,9 +1104,6 @@ int sqlite3_wasm_init_wasmfs(const char *zMountPoint){
|
||||
if( !zMountPoint || !*zMountPoint ) zMountPoint = "/opfs";
|
||||
if( !pOpfs ){
|
||||
pOpfs = wasmfs_create_opfs_backend();
|
||||
if( pOpfs ){
|
||||
emscripten_console_log("Created WASMFS OPFS backend.");
|
||||
}
|
||||
}
|
||||
/** It's not enough to instantiate the backend. We have to create a
|
||||
mountpoint in the VFS and attach the backend to it. */
|
||||
@ -1128,7 +1127,7 @@ int sqlite3_wasm_init_wasmfs(const char *zUnused){
|
||||
if(zUnused){/*unused*/}
|
||||
return SQLITE_NOTFOUND;
|
||||
}
|
||||
#endif /* __EMSCRIPTEN__ && SQLITE_WASM_WASMFS */
|
||||
#endif /* __EMSCRIPTEN__ && SQLITE_ENABLE_WASMFS */
|
||||
|
||||
#if SQLITE_WASM_TESTS
|
||||
|
||||
|
@ -1782,7 +1782,7 @@
|
||||
sh = await fh.createSyncAccessHandle();
|
||||
T.assert(fSize === await sh.getSize());
|
||||
}finally{
|
||||
if(sh) sh.close();
|
||||
if(sh) await sh.close();
|
||||
unlink();
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ sqlite3-wasmfs.cflags :=
|
||||
sqlite3-wasmfs.cflags += -std=c99 -fPIC
|
||||
sqlite3-wasmfs.cflags += -pthread
|
||||
sqlite3-wasmfs.cflags += $(cflags.common)
|
||||
sqlite3-wasmfs.cflags += $(SQLITE_OPT) -DSQLITE_WASM_WASMFS
|
||||
sqlite3-wasmfs.cflags += $(SQLITE_OPT) -DSQLITE_ENABLE_WASMFS
|
||||
|
||||
########################################################################
|
||||
# emcc flags specific to building the final .js/.wasm file...
|
||||
@ -88,7 +88,7 @@ all: wasmfs
|
||||
speedtest1-wasmfs.js := $(dir.wasmfs)/speedtest1-wasmfs.js
|
||||
speedtest1-wasmfs.wasm := $(subst .js,.wasm,$(speedtest1-wasmfs.js))
|
||||
speedtest1-wasmfs.eflags := $(sqlite3-wasmfs.fsflags)
|
||||
speedtest1-wasmfs.eflags += $(SQLITE_OPT) -DSQLITE_WASM_WASMFS
|
||||
speedtest1-wasmfs.eflags += $(SQLITE_OPT) -DSQLITE_ENABLE_WASMFS
|
||||
speedtest1-wasmfs.eflags += -sALLOW_MEMORY_GROWTH=0
|
||||
speedtest1-wasmfs.eflags += -sINITIAL_MEMORY=$(emcc.INITIAL_MEMORY.128)
|
||||
$(eval $(call call-make-pre-js,speedtest1-wasmfs))
|
||||
|
Reference in New Issue
Block a user