mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Integrate the opfs-sahpool VFS into the JS build and get it loading (but it's still far from functional).
FossilOrigin-Name: ef96e6b586825a2b3ed011174309cba8ce1031876c86dc59ed87ab9bbc64f57f
This commit is contained in:
@ -51,6 +51,7 @@ MAKEFILE := $(lastword $(MAKEFILE_LIST))
|
||||
CLEAN_FILES :=
|
||||
DISTCLEAN_FILES := ./--dummy--
|
||||
default: all
|
||||
#default: quick
|
||||
release: oz
|
||||
# JS_BUILD_MODES exists solely to reduce repetition in documentation
|
||||
# below.
|
||||
@ -375,6 +376,7 @@ sqlite3-api.jses += $(dir.api)/sqlite3-api-oo1.js
|
||||
sqlite3-api.jses += $(dir.api)/sqlite3-api-worker1.js
|
||||
sqlite3-api.jses += $(dir.api)/sqlite3-v-helper.js
|
||||
sqlite3-api.jses += $(dir.api)/sqlite3-vfs-opfs.c-pp.js
|
||||
sqlite3-api.jses += $(dir.api)/sqlite3-vfs-opfs-sahpool.js
|
||||
sqlite3-api.jses += $(dir.api)/sqlite3-api-cleanup.js
|
||||
|
||||
# SOAP.js is an external API file which is part of our distribution
|
||||
@ -754,7 +756,7 @@ $(5): $(4) $$(MAKEFILE) $$(sqlite3-wasm.cfiles) $$(EXPORTED_FUNCTIONS.api) $$(pr
|
||||
esac; \
|
||||
ls -la $$$$dotwasm $$@
|
||||
all: $(5)
|
||||
quick: $(5)
|
||||
#quick: $(5)
|
||||
CLEAN_FILES += $(4) $(5)
|
||||
endef
|
||||
# ^^^ /SETUP_LIB_BUILD_MODE
|
||||
@ -959,6 +961,7 @@ tester1: tester1.js tester1.mjs tester1.html tester1-esm.html
|
||||
# Note that we do not include $(sqlite3-bundler-friendly.mjs) in this
|
||||
# because bundlers are client-specific.
|
||||
all quick: tester1
|
||||
quick: $(sqlite3.js)
|
||||
|
||||
########################################################################
|
||||
# Convenience rules to rebuild with various -Ox levels. Much
|
||||
|
@ -79,7 +79,7 @@ const installOpfsVfs = async function(sqlite3){
|
||||
sqlite3.config.log
|
||||
];
|
||||
const logImpl = (level,...args)=>{
|
||||
if(verbosity>level) loggers[level]("OPFS syncer:",...args);
|
||||
if(verbosity>level) loggers[level]("opfs-sahpool:",...args);
|
||||
};
|
||||
const log = (...args)=>logImpl(2, ...args);
|
||||
const warn = (...args)=>logImpl(1, ...args);
|
||||
@ -117,13 +117,14 @@ const installOpfsVfs = async function(sqlite3){
|
||||
unavailable in the WASM build.*/;
|
||||
const pDVfs = capi.sqlite3_vfs_find(null)/*default VFS*/;
|
||||
const dVfs = pDVfs
|
||||
? new sqlite3_vfs(pDVfs)
|
||||
? new capi.sqlite3_vfs(pDVfs)
|
||||
: null /* dVfs will be null when sqlite3 is built with
|
||||
SQLITE_OS_OTHER. */;
|
||||
opfsVfs.$iVersion = 2/*yes, two*/;
|
||||
opfsVfs.$szOsFile = capi.sqlite3_file.structInfo.sizeof;
|
||||
opfsVfs.$mxPathname = HEADER_MAX_PATH_SIZE;
|
||||
opfsVfs.$zName = wasm.allocCString("opfs-sahpool");
|
||||
log('opfsVfs.$zName =',opfsVfs.$zName);
|
||||
opfsVfs.addOnDispose(
|
||||
'$zName', opfsVfs.$zName,
|
||||
'cleanup default VFS wrapper', ()=>(dVfs ? dVfs.dispose() : null)
|
||||
@ -143,9 +144,9 @@ const installOpfsVfs = async function(sqlite3){
|
||||
addCapacity: async function(n){
|
||||
for(let i = 0; i < n; ++i){
|
||||
const name = Math.random().toString(36).replace('0.','');
|
||||
const h = await this.dirHandle.getFileName(name, {create:true});
|
||||
const h = await this.dirHandle.getFileHandle(name, {create:true});
|
||||
const ah = await h.createSyncAccessHandle();
|
||||
this.mapAH2Name(ah,name);
|
||||
this.mapAH2Name.set(ah,name);
|
||||
this.setAssociatedPath(ah, '', 0);
|
||||
}
|
||||
},
|
||||
@ -280,21 +281,29 @@ const installOpfsVfs = async function(sqlite3){
|
||||
return i;
|
||||
};
|
||||
}
|
||||
if(!opfsVfs.$xSleep){
|
||||
vfsSyncWrappers.xSleep = function(pVfs,ms){
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
|
||||
try{
|
||||
log("vfs list:",capi.sqlite3_js_vfs_list());
|
||||
sqlite3.vfs.installVfs({
|
||||
io: {struct: opfsIoMethods, methods: ioSyncWrappers},
|
||||
vfs: {struct: opfsVfs, methods: vfsSyncWrappers}
|
||||
});
|
||||
log("vfs list:",capi.sqlite3_js_vfs_list());
|
||||
}catch(e){
|
||||
promiseReject(e);
|
||||
return;
|
||||
}
|
||||
|
||||
VState.isReady = VState.reset().then(async ()=>{
|
||||
if(0===VState.getCapacity())[
|
||||
if(0===VState.getCapacity()){
|
||||
await VState.addCapacity(DEFAULT_CAPACITY);
|
||||
}
|
||||
log("opfs-sahpool VFS initialized.");
|
||||
promiseResolve(sqlite3);
|
||||
}).catch(promiseReject);
|
||||
})/*thePromise*/;
|
||||
|
@ -1288,7 +1288,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule;
|
||||
if(1){
|
||||
const vfsList = capi.sqlite3_js_vfs_list();
|
||||
T.assert(vfsList.length>1);
|
||||
//log("vfsList =",vfsList);
|
||||
log("vfsList =",vfsList);
|
||||
wasm.scopedAllocCall(()=>{
|
||||
const vfsArg = (v)=>wasm.xWrap.testConvertArg('sqlite3_vfs*',v);
|
||||
for(const v of vfsList){
|
||||
|
Reference in New Issue
Block a user