1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-12-24 14:17:58 +03:00

wasm: do not build the (untested/unsupported) node-for-node build by default, to cut build time by about 15%. Adjacent cleanups in mkwasmbuilds.c.

FossilOrigin-Name: e4539ebebd89840b76f5a0626393299100685a38f45546a0bf7a62e4df56f863
This commit is contained in:
stephan
2025-02-20 05:39:18 +00:00
parent b42310a6b9
commit 9e632f5512
4 changed files with 57 additions and 32 deletions

View File

@@ -892,12 +892,13 @@ EXPORTED_FUNCTIONS.fiddle := $(dir.tmp)/EXPORTED_FUNCTIONS.fiddle
########################################################################
########################################################################
# We have to ensure that we do not build $(sqlite3*.*js) in parallel
# because they all result in the creation of $(sqlite3.wasm). We have
# no way to build just a .[m]js file without also building the .wasm
# file because the generated .[m]js file has to include info about the
# imports needed by the wasm file, so they have to be built
# for any builds which result in the creation of $(sqlite3.wasm). We
# have no way to build just a .[m]js file without also building the
# .wasm file because the generated .[m]js file has to include info
# about the imports needed by the wasm file, so they have to be built
# together. i.e. we're building $(sqlite3.wasm) multiple times, but
# that's unavoidable (and harmless, just a waste of build time).
# that's unavoidable (and harmless, but is a significant waste of
# build time).
$(sqlite3.wasm): $(sqlite3.js)
$(sqlite3.mjs): $(sqlite3.js)
$(sqlite3-bundler-friendly.mjs): $(sqlite3.mjs)

View File

@@ -135,6 +135,24 @@ static void mk_prologue(void){
}
}
/*
** Flags for use with the 3rd argument to mk_pre_post() and
** mk_lib_mode().
*/
enum LibModeFlags {
/* Indicates an ESM module build. */
LIBMODE_ESM = 0x01,
/* Indicates a "bundler-friendly" build mode. */
LIBMODE_BUNDLER_FRIENDLY = 0x02 | LIBMODE_ESM,
/* Indicates to _not_ add this build to the 'all' target. */
LIBMODE_DONT_ADD_TO_ALL = 0x04,
/* Indicates a node.js-for-node.js build (untested and
** unsupported). */
LIBMODE_NODEJS = 0x08,
/* Indicates a wasmfs build (untested and unsupported). */
LIBMODE_WASMFS = 0x10 | LIBMODE_ESM
};
/*
** Emits makefile code for setting up values for the --pre-js=FILE,
** --post-js=FILE, and --extern-post-js=FILE emcc flags, as well as
@@ -142,6 +160,7 @@ static void mk_prologue(void){
*/
static void mk_pre_post(const char *zName /* build name */,
const char *zMode /* build mode */,
int flags /* LIBMODE_... mask */,
const char *zCmppD /* optional -D flags for c-pp for the
** --pre/--post-js files. */){
pf("%s# Begin --pre/--post flags for %s-%s\n", zBanner, zNM);
@@ -166,9 +185,10 @@ static void mk_pre_post(const char *zName /* build name */,
pf("\tcp $(pre-js.js.%s-%s.intermediary) $@\n", zNM);
/* Amend $(pre-js.js.zName-zMode) for all targets except the plain
** "sqlite3" build... */
** "sqlite3" and the "sqlite3-wasmfs" builds... */
if( 0!=strcmp("sqlite3-wasmfs", zName)
&& 0!=strcmp("sqlite3", zName) ){
#error "This part ^^^ is needs adapting for use with the LIBMODE_... flags"
pf("\t@echo 'Module[xNameOfInstantiateWasm].uri = "
"\"%s.wasm\";' >> $@\n", zName);
}
@@ -209,7 +229,7 @@ static void mk_pre_post(const char *zName /* build name */,
static void mk_fiddle(){
int i = 0;
mk_pre_post("fiddle-module","vanilla", 0);
mk_pre_post("fiddle-module","vanilla", 0, 0);
for( ; i < 2; ++i ){
const char *zTail = i ? ".debug" : "";
const char *zDir = i ? "$(dir.fiddle-debug)" : "$(dir.fiddle)";
@@ -257,7 +277,7 @@ static void mk_fiddle(){
*/
static void mk_lib_mode(const char *zName /* build name */,
const char *zMode /* build mode */,
int bIsEsm /* true only for ESM build */,
int flags /* LIBMODE_... mask */,
const char *zApiJsOut /* name of generated sqlite3-api.js/.mjs */,
const char *zJsOut /* name of generated sqlite3.js/.mjs */,
const char *zCmppD /* extra -D flags for c-pp */,
@@ -276,7 +296,7 @@ static void mk_lib_mode(const char *zName /* build name */,
pf("%s# Begin build [%s-%s]\n", zBanner, zNM);
pf("# zApiJsOut=%s\n# zJsOut=%s\n# zCmppD=%s\n", zApiJsOut, zJsOut, zCmppD);
pf("$(info Setting up build [%s-%s]: %s)\n", zNM, zJsOut);
mk_pre_post(zNM, zCmppD);
mk_pre_post(zNM, flags, zCmppD);
pf("\nemcc.flags.%s.%s ?=\n", zNM);
if( zEmcc[0] ){
pf("emcc.flags.%s.%s += %s\n", zNM, zEmcc);
@@ -303,13 +323,13 @@ static void mk_lib_mode(const char *zName /* build name */,
pf("\t\t$(cflags.common) $(SQLITE_OPT) \\\n"
"\t\t$(cflags.%s) $(cflags.%s.%s) \\\n"
"\t\t$(cflags.wasm_extra_init) $(sqlite3-wasm.cfiles)\n", zName, zNM);
if( bIsEsm ){
if( LIBMODE_ESM & flags ){
/* TODO? Replace this $(call) with the corresponding makefile
** code. OTOH, we also use this $(call) in the speedtest1-wasmfs
** build, which is not part of the rules emitted by this
** program. */
pf("\t@$(call SQLITE.CALL.xJS.ESM-EXPORT-DEFAULT,1,%d)\n",
0==strcmp("sqlite3-wasmfs", zName) ? 1 : 0);
(LIBMODE_WASMFS & flags) ? 1 : 0);
}
pf("\t@chmod -x %s; \\\n"
"\t\t$(maybe-wasm-strip) %s;\n",
@@ -331,15 +351,15 @@ static void mk_lib_mode(const char *zName /* build name */,
** resulting .wasm file is identical for all builds for which zEmcc
** is empty.
*/
if( 0==strcmp("bundler-friendly", zMode)
|| 0==strcmp("node", zMode) ){
if( (LIBMODE_BUNDLER_FRIENDLY & flags)
|| (LIBMODE_NODEJS & flags) ){
pf("\t@echo 'Patching $@ for %s.wasm...'; \\\n", zName);
pf("\t\trm -f %s; \\\n", zWasmOut);
pf("\t\tsed -i -e 's/%s-%s.wasm/%s.wasm/g' $@ || exit;\n",
/* ^^^^^^ reminder: Mac/BSD sed has no -i flag */
zNM, zName);
pf("\t@ls -la $@\n");
if( 0==strcmp("bundler-friendly", zMode) ){
if( LIBMODE_BUNDLER_FRIENDLY & flags ){
/* Avoid a 3rd occurance of the bug fixed by 65798c09a00662a3,
** which was (in two cases) caused by makefile refactoring and
** not recognized until after a release was made with the broken
@@ -352,9 +372,7 @@ static void mk_lib_mode(const char *zName /* build name */,
}else{
pf("\t@ls -la %s $@\n", zWasmOut);
}
if( 0!=strcmp("sqlite3-wasmfs", zName) ){
/* The sqlite3-wasmfs build is optional and needs to be invoked
** conditionally using info we don't have here. */
if( 0==(LIBMODE_DONT_ADD_TO_ALL & flags) ){
pf("all: %s\n", zJsOut);
}
pf("# End build [%s-%s]%s", zNM, zBanner);
@@ -366,22 +384,28 @@ int main(void){
mk_prologue();
mk_lib_mode("sqlite3", "vanilla", 0,
"$(sqlite3-api.js)", "$(sqlite3.js)", 0, 0);
mk_lib_mode("sqlite3", "esm", 1,
mk_lib_mode("sqlite3", "esm", LIBMODE_ESM,
"$(sqlite3-api.mjs)", "$(sqlite3.mjs)",
"-Dtarget=es6-module", 0);
mk_lib_mode("sqlite3", "bundler-friendly", 1,
"$(sqlite3-api-bundler-friendly.mjs)", "$(sqlite3-bundler-friendly.mjs)",
mk_lib_mode("sqlite3", "bundler-friendly", LIBMODE_BUNDLER_FRIENDLY,
"$(sqlite3-api-bundler-friendly.mjs)",
"$(sqlite3-bundler-friendly.mjs)",
"$(c-pp.D.sqlite3-esm) -Dtarget=es6-bundler-friendly", 0);
mk_lib_mode("sqlite3" , "node", 1,
mk_lib_mode("sqlite3" , "node",
LIBMODE_NODEJS | LIBMODE_DONT_ADD_TO_ALL,
"$(sqlite3-api-node.mjs)", "$(sqlite3-node.mjs)",
"$(c-pp.D.sqlite3-bundler-friendly) -Dtarget=node", 0);
mk_lib_mode("sqlite3-wasmfs", "esm" ,1,
mk_lib_mode("sqlite3-wasmfs", "esm" ,
LIBMODE_WASMFS | LIBMODE_DONT_ADD_TO_ALL,
/* The sqlite3-wasmfs build is optional and needs to be invoked
** conditionally using info we don't have here. */
"$(sqlite3-api-wasmfs.mjs)", "$(sqlite3-wasmfs.mjs)",
"$(c-pp.D.sqlite3-bundler-friendly) -Dwasmfs",
"-sEXPORT_ES6 -sUSE_ES6_IMPORT_META");
mk_fiddle();
mk_pre_post("speedtest1","vanilla", 0);
mk_pre_post("speedtest1-wasmfs","esm", "$(c-pp.D.sqlite3-bundler-friendly) -Dwasmfs");
mk_pre_post("speedtest1","vanilla", 0, 0);
mk_pre_post("speedtest1-wasmfs","esm", 0,
"$(c-pp.D.sqlite3-bundler-friendly) -Dwasmfs");
return rc;
}

View File

@@ -1,5 +1,5 @@
C wasm\smakefile\sdocs:\smake\sexplicit\sthat\sthe\snode.js-for-node.js\sbuilds\s(as\sopposed\sto\sthe\snode.js-for-browser\sbuilds)\sare\sboth\suntested\sand\sunsupported.
D 2025-02-20T04:45:02.076
C wasm:\sdo\snot\sbuild\sthe\s(untested/unsupported)\snode-for-node\sbuild\sby\sdefault,\sto\scut\sbuild\stime\sby\sabout\s15%.\sAdjacent\scleanups\sin\smkwasmbuilds.c.
D 2025-02-20T05:39:18.599
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d
@@ -619,7 +619,7 @@ F ext/session/sqlite3session.c 52a680dbb03c4734748b215d95987fb4d95ab23baaf053a01
F ext/session/sqlite3session.h aa5de3ec8ef0e5313e9f65dafd69e8ba292d170f07b57da9200c040068dab061
F ext/session/test_session.c 12e0a2c15fd60f92da4bb29c697c9177ff0c0dbcdc5129a54c47e999f147937a
F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c
F ext/wasm/GNUmakefile afecad95600b0361865a81c4490743f54fd2a5a4db64e50b361a9db0cb0553f5
F ext/wasm/GNUmakefile c6a98150911c8f882aa75a9fbf148b124c59b22078799f9f9c6061bfbb128a33
F ext/wasm/README-dist.txt f01081a850ce38a56706af6b481e3a7878e24e42b314cfcd4b129f0f8427066a
F ext/wasm/README.md b89605f65661cf35bf034ff6d43e448cc169b8017fc105d498e33b81218b482c
F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff
@@ -680,7 +680,7 @@ F ext/wasm/index-dist.html 56132399702b15d70c474c3f1952541e25cb0922942868f70daf1
F ext/wasm/index.html bcaa00eca521b372a6a62c7e7b17a870b0fcdf3e418a5921df1fd61e5344080d
F ext/wasm/jaccwabyt/jaccwabyt.js 1264710db3cfbcb6887d95665b7aeba60c1126eaef789ca4cf1a4a17d5bc7f54
F ext/wasm/jaccwabyt/jaccwabyt.md 59a20df389abcc3606eb4eaea7fb7ba14504beb3e345dbea9b99a0618ba3bec8
F ext/wasm/mkwasmbuilds.c baf6636e139e2c1e3b56e8dc26073ec80f6d14ae1876b023985315f43ccf312b
F ext/wasm/mkwasmbuilds.c 57ce3c6e30c17078586dde9b5dec946f6a2d08f195067d4b6feefbc0bf1e0a4b
F ext/wasm/module-symbols.html dc476b403369b26a1a23773e13b80f41b9a49f0825e81435fe3600a7cfbbe337
F ext/wasm/scratchpad-wasmfs.html a3d7388f3c4b263676b58b526846e9d02dfcb4014ff29d3a5040935286af5b96
F ext/wasm/scratchpad-wasmfs.mjs 66034b9256b218de59248aad796760a1584c1dd842231505895eff00dbd57c63
@@ -2210,8 +2210,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350
F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P b5dbd521951e129b4dec69f191a872500dbf387b34a8479ad58b053ffcccbab9
R 9e14f25c151c1ed248cfdda16fbb7871
P e1f184889fef4603d61d306c8c0dc86df616290ccf73dbd871fa27bd99e5e5c9
R 84806d4092a27a5838a354dffcfb957d
U stephan
Z a5f06d7dda0edaff65b376e4feee5c8b
Z 323bb73cbee281d90dd439bde340e242
# Remove this line to create a well-formed Fossil manifest.

View File

@@ -1 +1 @@
e1f184889fef4603d61d306c8c0dc86df616290ccf73dbd871fa27bd99e5e5c9
e4539ebebd89840b76f5a0626393299100685a38f45546a0bf7a62e4df56f863