@@ -5,15 +5,15 @@ import {
55 mkdirSync ,
66 openSync ,
77 rmSync ,
8- } from ' node:fs' ;
9- import { execFileSync } from ' node:child_process' ;
10- import path from ' node:path' ;
8+ } from " node:fs" ;
9+ import { execFileSync } from " node:child_process" ;
10+ import path from " node:path" ;
1111
12- const WORK_DIR = path . resolve ( ' work' ) ;
13- const SQLITE_DIR = path . join ( WORK_DIR , ' sqlite-src' ) ;
14- const EXT_WASM = path . join ( SQLITE_DIR , ' ext' , ' wasm' ) ;
15- const DIST_DIR = path . resolve ( ' dist' ) ;
16- const SRC_DIR = path . resolve ( ' src' ) ;
12+ const WORK_DIR = path . resolve ( " work" ) ;
13+ const SQLITE_DIR = path . join ( WORK_DIR , " sqlite-src" ) ;
14+ const EXT_WASM = path . join ( SQLITE_DIR , " ext" , " wasm" ) ;
15+ const DIST_DIR = path . resolve ( " dist" ) ;
16+ const SRC_DIR = path . resolve ( " src" ) ;
1717
1818// 1) Clean dist
1919if ( existsSync ( DIST_DIR ) ) {
@@ -22,74 +22,73 @@ if (existsSync(DIST_DIR)) {
2222mkdirSync ( DIST_DIR , { recursive : true } ) ;
2323
2424// 2) Build
25- console . log ( ' Building SQLite...' ) ;
26- execFileSync ( path . join ( SQLITE_DIR , ' configure' ) , [ ' --enable-all' ] , {
25+ console . log ( " Building SQLite..." ) ;
26+ execFileSync ( path . join ( SQLITE_DIR , " configure" ) , [ " --enable-all" ] , {
2727 // It's important to set the current working directory to the SQLite source
2828 // directory or else it will treat it as an out-of-tree build and not look for
2929 // EMSDK.
3030 cwd : SQLITE_DIR ,
31- stdio : ' inherit' ,
31+ stdio : " inherit" ,
3232} ) ;
33- execFileSync ( ' make' , [ '-C' , SQLITE_DIR , ' clean' ] , { stdio : ' inherit' } ) ;
34- execFileSync ( ' make' , [ '-C' , SQLITE_DIR , ' sqlite3.c' ] , { stdio : ' inherit' } ) ;
33+ execFileSync ( " make" , [ "-C" , SQLITE_DIR , " clean" ] , { stdio : " inherit" } ) ;
34+ execFileSync ( " make" , [ "-C" , SQLITE_DIR , " sqlite3.c" ] , { stdio : " inherit" } ) ;
3535
36- console . log ( ' Building WASM target...' ) ;
37- execFileSync ( ' make' , [ '-C' , EXT_WASM , ' clean' ] , { stdio : ' inherit' } ) ;
36+ console . log ( " Building WASM target..." ) ;
37+ execFileSync ( " make" , [ "-C" , EXT_WASM , " clean" ] , { stdio : " inherit" } ) ;
3838execFileSync (
39- ' make' ,
39+ " make" ,
4040 [
41- '-C' ,
41+ "-C" ,
4242 EXT_WASM ,
43- ' b-esm' ,
44- ' emcc_opt=-Oz' ,
45- ' c-pp.D.esm=-Dtarget:es6-module' ,
46- ' sqlite3-api.jses=$(sqlite3-license-version.js) ' +
47- ' $(dir.api)/sqlite3-api-prologue.js ' +
48- ' $(dir.common)/whwasmutil.js ' +
49- ' $(dir.jacc)/jaccwabyt.js ' +
50- ' $(dir.api)/sqlite3-api-glue.c-pp.js ' +
51- ' $(sqlite3-api-build-version.js) ' +
52- ' $(dir.api)/sqlite3-api-oo1.c-pp.js ' +
43+ " b-esm" ,
44+ " emcc_opt=-Oz" ,
45+ " c-pp.D.esm=-Dtarget:es6-module" ,
46+ " sqlite3-api.jses=$(sqlite3-license-version.js) " +
47+ " $(dir.api)/sqlite3-api-prologue.js " +
48+ " $(dir.common)/whwasmutil.js " +
49+ " $(dir.jacc)/jaccwabyt.js " +
50+ " $(dir.api)/sqlite3-api-glue.c-pp.js " +
51+ " $(sqlite3-api-build-version.js) " +
52+ " $(dir.api)/sqlite3-api-oo1.c-pp.js " +
5353 // Omit $(dir.api)/sqlite3-api-worker1.c-pp.js
54- ' $(dir.api)/sqlite3-vfs-helper.c-pp.js ' +
55- ' $(dir.api)/sqlite3-vtab-helper.c-pp.js ' +
54+ " $(dir.api)/sqlite3-vfs-helper.c-pp.js " +
55+ " $(dir.api)/sqlite3-vtab-helper.c-pp.js " +
5656 // Omit $(dir.api)/sqlite3-vfs-opfs.c-pp.js
57- '$(dir.api)/sqlite3-vfs-opfs-sahpool.c-pp.js ' +
58- '$(dir.api)/sqlite3-api-cleanup.js' ,
57+ "$(dir.api)/sqlite3-vfs-opfs-sahpool.c-pp.js" ,
5958 ] ,
60- { stdio : ' inherit' }
59+ { stdio : " inherit" } ,
6160) ;
6261
6362// 3) Strip comments
64- console . log ( ' Building tool to strip comments...' ) ;
65- execFileSync ( ' make' , [ '-C' , EXT_WASM , ' t-stripccomments' ] , {
66- stdio : ' inherit' ,
63+ console . log ( " Building tool to strip comments..." ) ;
64+ execFileSync ( " make" , [ "-C" , EXT_WASM , " t-stripccomments" ] , {
65+ stdio : " inherit" ,
6766} ) ;
68- console . log ( ' Stripping C comments from output...' ) ;
69- const inFd = openSync ( path . join ( EXT_WASM , ' jswasm' , ' sqlite3.mjs' ) , 'r' ) ;
70- const apiFileOut = path . join ( EXT_WASM , ' jswasm' , ' sqlite3-stripped.mjs' ) ;
71- const outFd = openSync ( apiFileOut , 'w' ) ;
67+ console . log ( " Stripping C comments from output..." ) ;
68+ const inFd = openSync ( path . join ( EXT_WASM , " jswasm" , " sqlite3.mjs" ) , "r" ) ;
69+ const apiFileOut = path . join ( EXT_WASM , " jswasm" , " sqlite3-stripped.mjs" ) ;
70+ const outFd = openSync ( apiFileOut , "w" ) ;
7271try {
73- execFileSync ( path . join ( SQLITE_DIR , ' tool' , ' stripccomments' ) , [ '-k' , '-k' ] , {
72+ execFileSync ( path . join ( SQLITE_DIR , " tool" , " stripccomments" ) , [ "-k" , "-k" ] , {
7473 cwd : SQLITE_DIR ,
75- stdio : [ inFd , outFd , ' inherit' ] ,
74+ stdio : [ inFd , outFd , " inherit" ] ,
7675 } ) ;
7776} finally {
7877 closeSync ( inFd ) ;
7978 closeSync ( outFd ) ;
8079}
8180
8281// 4) Format output
83- console . log ( ' Formatting output with oxfmt...' ) ;
84- execFileSync ( ' pnpm' , [ ' oxfmt' , apiFileOut ] , { stdio : ' inherit' } ) ;
82+ console . log ( " Formatting output with oxfmt..." ) ;
83+ execFileSync ( " pnpm" , [ " oxfmt" , apiFileOut ] , { stdio : " inherit" } ) ;
8584
8685// 5) Copy output to dist
87- const wasmModule = path . join ( EXT_WASM , ' jswasm' , ' esm' , ' sqlite3.wasm' ) ;
88- cpSync ( wasmModule , path . join ( DIST_DIR , ' sqlite3.wasm' ) ) ;
89- cpSync ( apiFileOut , path . join ( DIST_DIR , ' sqlite3.js' ) ) ;
90- const types = path . join ( SRC_DIR , ' sqlite3.d.ts' ) ;
91- cpSync ( types , path . join ( DIST_DIR , ' sqlite3.d.ts' ) ) ;
92- const revFile = path . join ( WORK_DIR , ' sqlite-rev.txt' ) ;
93- cpSync ( revFile , path . join ( DIST_DIR , ' sqlite-rev.txt' ) ) ;
86+ const wasmModule = path . join ( EXT_WASM , " jswasm" , " esm" , " sqlite3.wasm" ) ;
87+ cpSync ( wasmModule , path . join ( DIST_DIR , " sqlite3.wasm" ) ) ;
88+ cpSync ( apiFileOut , path . join ( DIST_DIR , " sqlite3.js" ) ) ;
89+ const types = path . join ( SRC_DIR , " sqlite3.d.ts" ) ;
90+ cpSync ( types , path . join ( DIST_DIR , " sqlite3.d.ts" ) ) ;
91+ const revFile = path . join ( WORK_DIR , " sqlite-rev.txt" ) ;
92+ cpSync ( revFile , path . join ( DIST_DIR , " sqlite-rev.txt" ) ) ;
9493
95- console . log ( ' Build complete: dist/sqlite3.{js,wasm,d.ts}' ) ;
94+ console . log ( " Build complete: dist/sqlite3.{js,wasm,d.ts}" ) ;
0 commit comments