# $3 = optional c-pp -D... flags
$(2): $(1) $$(MAKEFILE_LIST) $$(bin.c-pp)
@mkdir -p $$(dir $$@)
- $$(bin.c-pp) -f $(1) -o $$@ $(3) $(SQLITE.CALL.C-PP.FILTER.global)
+ cat $(1) | $$(bin.c-pp) -o $$@ $(3) $(SQLITE.CALL.C-PP.FILTER.global)
CLEAN_FILES += $(2)
endef
# /end SQLITE.CALL.C-PP.FILTER
$(EXPORTED_FUNCTIONS.api): $(MKDIR.bld) $(EXPORTED_FUNCTIONS.api.in) $(sqlite3.c) $(MAKEFILE)
cat $(EXPORTED_FUNCTIONS.api.in) > $@
-########################################################################
-# sqlite3-license-version.js = generated JS file with the license
-# header and version info.
-sqlite3-license-version.js = $(dir.tmp)/sqlite3-license-version.js
-# sqlite3-api-build-version.js = generated JS file which populates the
-# sqlite3.version object using $(bin.version-info).
-sqlite3-api-build-version.js = $(dir.tmp)/sqlite3-api-build-version.js
-# sqlite3-api.jses = the list of JS files which make up
-# $(sqlite3-api.js.in), in the order they need to be assembled.
-sqlite3-api.jses = $(sqlite3-license-version.js)
-# sqlite3-api-prologue.js: initial bootstrapping bits:
-sqlite3-api.jses += $(dir.api)/sqlite3-api-prologue.js
-# whwhasm.js and jaccwabyt.js: Low-level utils, mostly replacing
-# Emscripten glue:
-sqlite3-api.jses += $(dir.common)/whwasmutil.js
-sqlite3-api.jses += $(dir.jacc)/jaccwabyt.js
-# sqlite3-api-glue Glues the previous part together with sqlite:
-sqlite3-api.jses += $(dir.api)/sqlite3-api-glue.c-pp.js
-# $(sqlite3-api-build-version.js) = library version info
-sqlite3-api.jses += $(sqlite3-api-build-version.js)
-# sqlite3-api-oo1 = the oo1 API:
-sqlite3-api.jses += $(dir.api)/sqlite3-api-oo1.c-pp.js
-# sqlite3-api-worker = the Worker1 API:
-sqlite3-api.jses += $(dir.api)/sqlite3-api-worker1.c-pp.js
-# sqlite3-vfs-helper = helper APIs for VFSes:
-sqlite3-api.jses += $(dir.api)/sqlite3-vfs-helper.c-pp.js
-ifeq (0,$(wasm-bare-bones))
- # sqlite3-vtab-helper = helper APIs for VTABLEs:
- sqlite3-api.jses += $(dir.api)/sqlite3-vtab-helper.c-pp.js
-endif
-# sqlite3-vfs-opfs = the first OPFS VFS:
-sqlite3-api.jses += $(dir.api)/sqlite3-vfs-opfs.c-pp.js
-# sqlite3-vfs-opfs-sahpool = the second OPFS VFS:
-sqlite3-api.jses += $(dir.api)/sqlite3-vfs-opfs-sahpool.c-pp.js
-# sqlite3-api-cleanup.js = "finalizes" the build and cleans up
-# any extraneous global symbols which are needed temporarily
-# by the previous files.
-sqlite3-api.jses += $(dir.api)/sqlite3-api-cleanup.js
-
########################################################################
# SOAP.js is an external API file which is part of our distribution
# but not part of the sqlite3-api.js amalgamation. It's a component of
# the first OPFS VFS and necessarily an external file.
SOAP.js = $(dir.api)/sqlite3-opfs-async-proxy.js
-SOAP.js.bld = $(dir.dout)/$(notdir $(SOAP.js))
+SOAP.js.out = $(dir.dout)/sqlite3-opfs-async-proxy.js
#
# $(sqlite3-api.ext.jses) = API-related files which are standalone files,
# not part of the amalgamation.
#
-sqlite3-api.ext.jses = $(SOAP.js.bld)
-$(SOAP.js.bld): $(SOAP.js)
+sqlite3-api.ext.jses = $(SOAP.js.out)
+$(SOAP.js.out): $(SOAP.js)
cp $< $@
########################################################################
echo '});'; \
} > $@
-########################################################################
-# $(sqlite3-license-version.js) contains the license header and
-# in-comment build version info.
-#
-# Maintenance reminder: there are awk binaries out there which do not
-# support -e SCRIPT.
-$(sqlite3-license-version.js): $(MKDIR.bld) $(sqlite3.h) \
- $(dir.api)/sqlite3-license-version-header.js $(MAKEFILE)
- @echo "Making $@..."; { \
- cat $(dir.api)/sqlite3-license-version-header.js; \
- echo '/*'; \
- echo '** This code was built from sqlite3 version...'; \
- echo "**"; \
- awk '/define SQLITE_VERSION/{$$1=""; print "**" $$0}' $(sqlite3.h); \
- awk '/define SQLITE_SOURCE_ID/{$$1=""; print "**" $$0}' $(sqlite3.h); \
- echo "**"; \
- echo "** with the help of Emscripten SDK version $(emcc.version)."; \
- echo '*/'; \
- } > $@
-
########################################################################
# --post-js and --pre-js are emcc flags we use to append/prepend JS to
# the generated emscripten module file. These rules set up the core
# code analyzers and cannot cope with the former.
#
# Most of what follows is the generation of those copies.
+
$(eval $(call SQLITE.CALL.C-PP.FILTER,$(dir.api)/sqlite3-worker1.c-pp.js,\
$(dir.dout)/sqlite3-worker1.js))
-$(eval $(call SQLITE.CALL.C-PP.FILTER,$(dir.api)/sqlite3-worker1.c-pp.js,\
- $(dir.dout)/sqlite3-worker1-bundler-friendly.mjs,\
- $(c-pp.D.sqlite3-bundler-friendly)))
-$(eval $(call SQLITE.CALL.C-PP.FILTER,$(dir.api)/sqlite3-worker1-promiser.c-pp.js,\
- $(dir.dout)/sqlite3-worker1-promiser.js))
-$(eval $(call SQLITE.CALL.C-PP.FILTER,$(dir.api)/sqlite3-worker1-promiser.c-pp.js,\
- $(dir.dout)/sqlite3-worker1-promiser-bundler-friendly.js,\
- $(c-pp.D.sqlite3-bundler-friendly)))
+sqlite3-api.ext.jses += $(dir.dout)/sqlite3-worker1.js
+
$(eval $(call SQLITE.CALL.C-PP.FILTER,$(dir.api)/sqlite3-worker1-promiser.c-pp.js,\
$(dir.dout)/sqlite3-worker1-promiser.mjs,\
-Dtarget=es6-module -Dtarget=es6-bundler-friendly))
+sqlite3-api.ext.jses += $(dir.dout)/sqlite3-worker1-promiser.mjs
+
+$(eval $(call SQLITE.CALL.C-PP.FILTER,$(dir.api)/sqlite3-worker1-promiser.c-pp.js,\
+ $(dir.dout)/sqlite3-worker1-promiser.js))
+sqlite3-api.ext.jses += $(dir.dout)/sqlite3-worker1-promiser.js
+
$(eval $(call SQLITE.CALL.C-PP.FILTER,demo-worker1-promiser.c-pp.js,demo-worker1-promiser.js))
$(eval $(call SQLITE.CALL.C-PP.FILTER,demo-worker1-promiser.c-pp.js,demo-worker1-promiser.mjs,\
-Dtarget=es6-module))
$(eval $(call SQLITE.CALL.C-PP.FILTER,demo-worker1-promiser.c-pp.html,demo-worker1-promiser.html))
$(eval $(call SQLITE.CALL.C-PP.FILTER,demo-worker1-promiser.c-pp.html,demo-worker1-promiser-esm.html,\
-Dtarget=es6-module))
+demo-worker1-promiser.html: $(dir.dout)/sqlite3-worker1-promiser.js demo-worker1-promiser.js
+demo-worker1-promiser-esm.html: $(sqlite3-worker1-promiser.mjs) demo-worker1-promiser.mjs
+all: demo-worker1-promiser.html demo-worker1-promiser-esm.html
+
+ifeq (0,1)
+$(eval $(call SQLITE.CALL.C-PP.FILTER,$(dir.api)/sqlite3-worker1.c-pp.js,\
+ $(dir.dout)/sqlite3-worker1-bundler-friendly.mjs,\
+ $(c-pp.D.sqlite3-bundler-friendly)))
+sqlite3-api.ext.jses += $(dir.dout)/sqlite3-worker1-bundler-friendly.mjs
+
+$(eval $(call SQLITE.CALL.C-PP.FILTER,$(dir.api)/sqlite3-worker1-promiser.c-pp.js,\
+ $(dir.dout)/sqlite3-worker1-promiser-bundler-friendly.js,\
+ $(c-pp.D.sqlite3-bundler-friendly)))
+sqlite3-api.ext.jses += $(dir.dout)/sqlite3-promiser-bundler-friendly.js
$(dir.dout)/sqlite3-bundler-friendly.mjs: \
$(dir.dout)/sqlite3-worker1-bundler-friendly.mjs \
$(dir.dout)/sqlite3-worker1-promiser-bundler-friendly.js
-demo-worker1-promiser.html: $(dir.dout)/sqlite3-worker1-promiser.js demo-worker1-promiser.js
-demo-worker1-promiser-esm.html: $(sqlite3-worker1-promiser.mjs) demo-worker1-promiser.mjs
-all: demo-worker1-promiser.html demo-worker1-promiser-esm.html
+endif
-sqlite3-api.ext.jses += \
- $(dir.dout)/sqlite3-worker1-promiser.mjs \
- $(dir.dout)/sqlite3-worker1-promiser.js \
- $(dir.dout)/sqlite3-worker1-bundler-friendly.mjs \
- $(dir.dout)/sqlite3-worker1.js
all quick: $(sqlite3-api.ext.jses)
q: quick
64bit: # populated by $(bin.mkwb)
@ls -la $@ $(speedtest1.wasm)
speedtest1: $(speedtest1.js)
-all: speedtest1
+#xxx#all: speedtest1
# end speedtest1.js
########################################################################
# tester1.mjs: cases 3 and 4
#
# To create those, we filter tester1.c-pp.js with $(bin.c-pp)...
-$(eval $(call SQLITE.CALL.C-PP.FILTER,tester1.c-pp.js,tester1.js))
-$(eval $(call SQLITE.CALL.C-PP.FILTER,tester1.c-pp.js,tester1.mjs,$(c-pp.D.sqlite3-esm)))
-$(eval $(call SQLITE.CALL.C-PP.FILTER,tester1.c-pp.html,tester1.html))
-$(eval $(call SQLITE.CALL.C-PP.FILTER,tester1.c-pp.html,tester1-esm.html,$(c-pp.D.sqlite3-esm)))
+$(eval $(call SQLITE.CALL.C-PP.FILTER,tester1.c-pp.js,tester1.js,$(c-pp.D.canonical)))
+$(eval $(call SQLITE.CALL.C-PP.FILTER,tester1.c-pp.js,tester1.mjs,$(c-pp.D.esm)))
+$(eval $(call SQLITE.CALL.C-PP.FILTER,tester1.c-pp.html,tester1.html,$(c-pp.D.canonical)))
+$(eval $(call SQLITE.CALL.C-PP.FILTER,tester1.c-pp.html,tester1-esm.html,$(c-pp.D.esm)))
tester1: tester1.js tester1.mjs tester1.html tester1-esm.html
# We do not include $(dir.dout)/sqlite3-bundler-friendly.mjs in this
# because bundlers are client-specific.
** purposes: they are not expanded into code anywhere.
*/
#define JS_BUILD_NAMES sqlite3 sqlite3-wasmfs
-/*
-** Valid build modes. For the "sqlite3-wasmfs" build, only "esm" (ES6
-** Module) is legal.
-*/
-#define JS_BUILD_MODES \
- vanilla vanilla64 esm esm64 bundler-friendly bundler-friendly64 node
/* Separator to help eyeballs find the different output sections */
-static const char * zBanner =
- "\n########################################################################\n";
+#define zBanner \
+ "\n########################################################################\n"
/*
** Flags for use with BuildDef::flags and the 3rd argument to
** legal/sensical.
*/
struct BuildDef {
- const char *zName; /* Name from JS_BUILD_NAMES */
- const char *zMode; /* Name from JS_BUILD_MODES */
- int flags; /* Flags from LibModeFlags */
+ /**
+ Base name of output JS and WASM files.
+ */
+ const char *zWasmFile;
const char *zJsOut; /* Name of generated sqlite3.js/.mjs */
- /* TODO?: dynamically determine zJsOut based on zName, zMode, and
- flags. */
const char *zWasmOut; /* zJsOut w/ .wasm extension if it needs to
be renamed. Do we still need this? */
const char *zCmppD; /* Extra -D... flags for c-pp */
const char *zEmcc; /* Extra flags for emcc */
+ const char *zEnv; /* emcc -sENVIRONMENT=X flag */
+ int flags; /* Flags from LibModeFlags */
};
typedef struct BuildDef BuildDef;
/* List of distinct library builds. See next comment block. */
#define BuildDefs_map(E) \
- E(canonical) \
+ E(canonical) \
+ E(esm)
+/*
E(canonical64) \
- E(esm) \
E(esm64) \
E(bundler) \
E(bundler64) \
E(node) \
E(wasmfs)
-
+*/
/*
** The set of WASM builds for the library (as opposed to the apps
** (fiddle, speedtest1)). Their order in BuildDefs_map is mostly
const BuildDefs oBuildDefs = {
.canonical = {
- .zName ="sqlite3", .zMode = "vanilla",
- .flags = 0,
- .zJsOut ="$(sqlite3.js)",
+ .zWasmFile ="sqlite3",
+ .zJsOut ="$(dir.dout)/sqlite3.js",
.zWasmOut = 0,
- .zCmppD = 0,
- .zEmcc =0
- },
-
- .canonical64 = {
- .zName="sqlite3", .zMode= "vanilla64",
- .flags= LIBMODE_NOT_IN_ALL | LIBMODE_64BIT,
- .zJsOut="$(sqlite3-64bit.js)",
- .zWasmOut=0,
- .zCmppD=0,
- .zEmcc="-sMEMORY64=1"
+ .zCmppD = "-Djust-testing",
+ .zEmcc =0,
+ .zEnv = "web,worker"
+ /* MUST be non-NULL in the canonical build so it can be used as
+ a default for all others. */,
+ .flags = 0
},
.esm = {
- .zName="sqlite3", .zMode= "esm",
- .flags= LIBMODE_ESM,
+ .zWasmFile="sqlite3",
.zJsOut="$(sqlite3.mjs)",
.zWasmOut=0,
.zCmppD= "-Dtarget=es6-module",
- .zEmcc=0
+ .zEmcc=0,
+ .zEnv = 0,
+ .flags= LIBMODE_ESM
+ },
+#if 0
+
+ .canonical64 = {
+ .zWasmFile="sqlite3-64bit",
+ .zJsOut="$(sqlite3-64bit.js)",
+ .zWasmOut=0,
+ .zCmppD=0,
+ .zEmcc="-sMEMORY64=1",
+ .zEnv = 0,
+ .flags= LIBMODE_NOT_IN_ALL | LIBMODE_64BIT
},
.esm64 = {
- .zName="sqlite3", .zMode= "esm64",
- .flags= LIBMODE_NOT_IN_ALL | LIBMODE_64BIT,
+ .zWasmFile="sqlite3",
.zJsOut="$(sqlite3-64bit.mjs)",
.zWasmOut=0,
.zCmppD=0,
- .zEmcc="-sMEMORY64=1"
+ .zEmcc="-sMEMORY64=1",
+ .zEnv = 0,
+ .flags= LIBMODE_NOT_IN_ALL | LIBMODE_64BIT
},
.bundler = {
** Testing these would require special-purpose node-based tools and
** custom test apps. Or we can pass them off as-is to the npm
** subproject and they spot failures pretty quickly ;). */
- .zName="sqlite3", .zMode= "bundler-friendly",
- .flags=LIBMODE_BUNDLER_FRIENDLY | LIBMODE_ESM,
+ .zWasmFile="sqlite3",
.zJsOut="$(dir.dout)/sqlite3-bundler-friendly.mjs",
.zWasmOut=0,
.zCmppD="$(c-pp.D.sqlite3-esm) -Dtarget=es6-bundler-friendly",
- .zEmcc=0
+ .zEmcc=0,
+ .zEnv = 0,
+ .flags=LIBMODE_BUNDLER_FRIENDLY | LIBMODE_ESM
},
.bundler64 = {
- .zName="sqlite3", .zMode= "bundler-friendly64",
- .flags= LIBMODE_BUNDLER_FRIENDLY | LIBMODE_ESM,
+ .zWasmFile="sqlite3",
.zJsOut="$(dir.dout)/sqlite3-bundler-friendly-64bit.mjs",
.zWasmOut=0,
.zCmppD="$(c-pp.D.sqlite3-esm) -Dtarget=es6-bundler-friendly",
- .zEmcc="-sMEMORY64=1"
+ .zEmcc="-sMEMORY64=1",
+ .zEnv = 0,
+ .flags= LIBMODE_BUNDLER_FRIENDLY | LIBMODE_ESM
},
/* Entirely unsupported. */
.node = {
- .zName="sqlite3", .zMode= "node",
- .flags= LIBMODE_UNSUPPORTED | LIBMODE_NODEJS,
+ .zWasmFile="sqlite3",
.zJsOut="$(dir.dout)/sqlite3-node.mjs",
.zWasmOut="sqlite3-node.wasm",
.zCmppD="$(c-pp.D.sqlite3-bundler-friendly) -Dtarget=node",
- .zEmcc=0
+ .zEmcc=0,
+ .zEnv = "node"
+ /* Adding ",node" to the list for the other -sENVIRONMENT values
+ causes Emscripten to generate code which confuses node: it
+ cannot reliably determine whether the build is for a browser or
+ for node. We neither build nor test node builds on a regular
+ basis. They are fully unsupported. */,
+ .flags= LIBMODE_UNSUPPORTED | LIBMODE_NODEJS
},
/* Entirely unsupported. */
.wasmfs = {
- .zName="sqlite3-wasmfs", .zMode= "esm" ,
- .flags= LIBMODE_UNSUPPORTED | LIBMODE_WASMFS | LIBMODE_ESM,
+ .zWasmFile="sqlite3-wasmfs",
.zJsOut="$(dir.wasmfs)/sqlite3-wasmfs.mjs",
.zWasmOut="sqlite3-wasmfs.wasm",
.zCmppD="$(c-pp.D.sqlite3-bundler-friendly) -Dwasmfs",
- .zEmcc="-sEXPORT_ES6 -sUSE_ES6_IMPORT_META"
+ .zEmcc="-sEXPORT_ES6 -sUSE_ES6_IMPORT_META",
+ .zEnv = 0,
+ .flags= LIBMODE_UNSUPPORTED | LIBMODE_WASMFS | LIBMODE_ESM
}
+#endif
};
/*
char const * aRequiredVars[] = {
"dir.top",
"dir.api", "dir.dout", "dir.tmp",
- "sqlite3-license-version.js",
"MAKEFILE", "MAKEFILE_LIST",
/* Fiddle... */
"dir.fiddle", "dir.fiddle-debug",
};
char const * zVar;
int i;
- pf("%s# Build setup sanity checks...\n", zBanner);
+ ps(zBanner "# Build setup sanity checks...");
for( i = 0; (zVar = aRequiredVars[i]); ++i ){
pf("ifeq (,$(%s))\n", zVar);
pf(" $(error build process error: expecting make var $$(%s) to "
"have been set up by now)\n", zVar);
ps("endif");
}
- pf("%s", zBanner);
- ps("# extern-post-js* and extern-pre-js* are files for use with");
- ps("# Emscripten's --extern-pre-js and --extern-post-js flags.");
- ps("extern-pre-js.js = $(dir.api)/extern-pre-js.js");
- ps("extern-post-js.js.in = $(dir.api)/extern-post-js.c-pp.js");
- ps("# Emscripten flags for --[extern-][pre|post]-js=... for the");
- ps("# various builds.");
- ps("pre-post-common.flags = --extern-pre-js=$(sqlite3-license-version.js)");
- ps("# pre-post-jses.deps.* = a list of dependencies for the\n"
- "# --[extern-][pre/post]-js files.");
- ps("pre-post-jses.deps.common = $(extern-pre-js.js) $(sqlite3-license-version.js)");
+
+ ps(zBanner
+ "# Inputs for the sqlite3-api.js family.\n"
+ "#\n"
+ "# sqlite3-license-version.js = generated JS file with the license\n"
+ "# header and version info.\n"
+ "sqlite3-license-version.js = $(dir.tmp)/sqlite3-license-version.js\n"
+ "# $(sqlite3-api-build-version.js) = generated JS file which populates the\n"
+ "# sqlite3.version object using $(bin.version-info).\n"
+ "sqlite3-api-build-version.js = $(dir.tmp)/sqlite3-api-build-version.js\n"
+ "# sqlite3-api.jses = the list of JS files which make up\n"
+ "# $(sqlite3-api.js.in), in the order they need to be assembled.\n"
+ "sqlite3-api.jses = $(sqlite3-license-version.js)\n"
+ "# sqlite3-api-prologue.js: initial bootstrapping bits:\n"
+ "sqlite3-api.jses += $(dir.api)/sqlite3-api-prologue.js\n"
+ "# whwhasm.js and jaccwabyt.js: Low-level utils, mostly replacing\n"
+ "# Emscripten glue:\n"
+ "sqlite3-api.jses += $(dir.common)/whwasmutil.js\n"
+ "sqlite3-api.jses += $(dir.jacc)/jaccwabyt.js\n"
+ "# sqlite3-api-glue Glues the previous part together with sqlite:\n"
+ "sqlite3-api.jses += $(dir.api)/sqlite3-api-glue.c-pp.js\n"
+ "sqlite3-api.jses += $(sqlite3-api-build-version.js)\n"
+ "# sqlite3-api-oo1 = the oo1 API:\n"
+ "sqlite3-api.jses += $(dir.api)/sqlite3-api-oo1.c-pp.js\n"
+ "# sqlite3-api-worker = the Worker1 API:\n"
+ "sqlite3-api.jses += $(dir.api)/sqlite3-api-worker1.c-pp.js\n"
+ "# sqlite3-vfs-helper = helper APIs for VFSes:\n"
+ "sqlite3-api.jses += $(dir.api)/sqlite3-vfs-helper.c-pp.js\n"
+ "ifeq (0,$(wasm-bare-bones))\n"
+ " # sqlite3-vtab-helper = helper APIs for VTABLEs:\n"
+ " sqlite3-api.jses += $(dir.api)/sqlite3-vtab-helper.c-pp.js\n"
+ "endif\n"
+ "# sqlite3-vfs-opfs = the first OPFS VFS:\n"
+ "sqlite3-api.jses += $(dir.api)/sqlite3-vfs-opfs.c-pp.js\n"
+ "# sqlite3-vfs-opfs-sahpool = the second OPFS VFS:\n"
+ "sqlite3-api.jses += $(dir.api)/sqlite3-vfs-opfs-sahpool.c-pp.js\n"
+ "# sqlite3-api-cleanup.js = \"finalizes\" the build and cleans up\n"
+ "# any extraneous global symbols which are needed temporarily\n"
+ "# by the previous files.\n"
+ "sqlite3-api.jses += $(dir.api)/sqlite3-api-cleanup.js"
+ );
+
+ ps(zBanner
+ "# $(sqlite3-license-version.js) contains the license header and\n"
+ "# in-comment build version info.\n"
+ "#\n"
+ "# Maintenance reminder: there are awk binaries out there which do not\n"
+ "# support -e SCRIPT.\n"
+ "$(sqlite3-license-version.js): $(MKDIR.bld) $(sqlite3.h) "
+ "$(dir.api)/sqlite3-license-version-header.js $(MAKEFILE)\n"
+ "\t@echo 'Making $@...'; { \\\n"
+ "\t\tcat $(dir.api)/sqlite3-license-version-header.js; \\\n"
+ "\t\techo '/*'; \\\n"
+ "\t\techo '** This code was built from sqlite3 version...'; \\\n"
+ "\t\techo '**'; \\\n"
+ "\t\tawk '/define SQLITE_VERSION/{$$1=\"\"; print \"**\" $$0}' $(sqlite3.h); \\\n"
+ "\t\tawk '/define SQLITE_SOURCE_ID/{$$1=\"\"; print \"**\" $$0}' $(sqlite3.h); \\\n"
+ "\t\techo '**'; \\\n"
+ "\t\techo '** with the help of Emscripten SDK version $(emcc.version).'; \\\n"
+ "\t\techo '*/'; \\\n"
+ "\t} > $@"
+ );
+
+ ps(zBanner
+ "# $(sqlite3-api-build-version.js) injects the build version info into\n"
+ "# the bundle in JSON form.\n"
+ "$(sqlite3-api-build-version.js): $(MKDIR.bld) $(bin.version-info) $(MAKEFILE)\n"
+ "\t@echo 'Making $@...'; { \\\n"
+ "\t\techo 'globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){'; \\\n"
+ "\t\techo -n ' sqlite3.version = '; \\\n"
+ "\t\t$(bin.version-info) --json; \\\n"
+ "\t\techo ';'; \\\n"
+ "\t\techo '});'; \\\n"
+ "\t} > $@"
+ );
+
+ ps(zBanner
+ "# extern-post-js* and extern-pre-js* are files for use with\n"
+ "# Emscripten's --extern-pre-js and --extern-post-js flags.\n"
+ "extern-pre-js.js = $(dir.api)/extern-pre-js.js\n"
+ "extern-post-js.js.in = $(dir.api)/extern-post-js.c-pp.js\n"
+ "# Emscripten flags for --[extern-][pre|post]-js=... for the\n"
+ "# various builds.\n"
+ "# pre-post-jses.*.deps = lists of dependencies for the\n"
+ "# --[extern-][pre/post]-js files.\n"
+ "pre-post-jses.common.deps = "
+ "$(extern-pre-js.js) $(sqlite3-license-version.js)"
+ );
{
/* SQLITE.CALL.WASM-OPT = shell code to run $(1) (source wasm file
/*"--safe-heap "*/
/*"--vacuum " saves nothing */
;
+ ps(zBanner
+ "# post-compilation WASM file optimization");
ps("ifeq (,$(bin.wasm-opt))");
- ps("define SQLITE.CALL.WASM-OPT");
- ps("echo 'wasm-opt not available for $(1)'");
- ps("endef");
+ {
+ ps("define SQLITE.CALL.WASM-OPT");
+ ps("echo 'wasm-opt not available for $(1)'");
+ ps("endef");
+ }
ps("else");
- ps("define SQLITE.CALL.WASM-OPT");
- pf("echo -n 'Before wasm-opt:'; ls -l $(1);\\\n"
- "\trm -f wasm-opt-tmp.wasm;\\\n"
- /* It's very likely that the set of wasm-opt flags varies from
- ** version to version, so we'll ignore any errors here. */
- "\tif $(bin.wasm-opt) $(1) -o wasm-opt-tmp.wasm \\\n"
- "\t\t%s; then \\\n"
- "\t\tmv wasm-opt-tmp.wasm $(1); \\\n"
- "\t\techo -n 'After wasm-opt: '; \\\n"
- "\t\tls -l $(1); \\\n"
- "\telse \\\n"
- "\t\techo 'WARNING: ignoring wasm-opt failure for $(1)'; \\\n"
- "\tfi\n",
- zOptFlags
- );
- ps("endef");
+ {
+ ps("define SQLITE.CALL.WASM-OPT");
+ pf("echo -n 'Before wasm-opt:'; ls -l $(1);\\\n"
+ "\trm -f wasm-opt-tmp.wasm;\\\n"
+ /* It's very likely that the set of wasm-opt flags varies from
+ ** version to version, so we'll ignore any errors here. */
+ "\tif $(bin.wasm-opt) $(1) -o wasm-opt-tmp.wasm \\\n"
+ "\t\t%s; then \\\n"
+ "\t\tmv wasm-opt-tmp.wasm $(1); \\\n"
+ "\t\techo -n 'After wasm-opt: '; \\\n"
+ "\t\tls -l $(1); \\\n"
+ "\telse \\\n"
+ "\t\techo 'WARNING: ignoring wasm-opt failure for $(1)'; \\\n"
+ "\tfi\n",
+ zOptFlags
+ );
+ ps("endef");
+ }
ps("endif");
}
}
** --post-js=FILE, and --extern-post-js=FILE emcc flags, as well as
** populating those files.
*/
-static void mk_pre_post(const char *zName /* build name */,
- const char *zMode /* build mode */,
+static void mk_pre_post(char const *zBuildName,
const char *zCmppD /* optional -D flags for c-pp for the
** --pre/--post-js files. */,
- const char *zWasmOut){
+ const char *zWasmOut ){
/* Very common printf() args combo. */
-#define zNM zName, zMode
- pf("%s# Begin --pre/--post flags for %s-%s\n", zBanner, zNM);
+ pf("%s# Begin --pre/--post flags for %s\n", zBanner, zBuildName);
if( zCmppD && *zCmppD ){
- pf("c-pp.D.%s-%s = %s\n", zNM, zCmppD ? zCmppD : "");
+ pf("c-pp.D.%s = %s\n", zBuildName, zCmppD);
}
- pf("pre-post-%s-%s.flags ?=\n", zNM);
+ pf("pre-post.%s.flags ?=\n", zBuildName);
/* --pre-js=... */
- pf("pre-js.js.%s-%s = $(dir.tmp)/pre-js.%s-%s.js\n",
- zNM, zNM);
- pf("$(pre-js.js.%s-%s): $(MAKEFILE_LIST) "
- "$(sqlite3-license-version.js)\n", zNM);
+ pf("pre-js.%s.js = $(dir.tmp)/pre-js.%s.js\n",
+ zBuildName, zBuildName);
+ pf("$(pre-js.%s.js): $(MAKEFILE_LIST) "
+ "$(sqlite3-license-version.js)\n", zBuildName);
if( 0==WASM_CUSTOM_INSTANTIATE || 0==zWasmOut ){
pf("$(eval $(call SQLITE.CALL.C-PP.FILTER,$(pre-js.js.in),"
- "$(pre-js.js.%s-%s),"
- C_PP_D_CUSTOM_INSTANTIATE "$(c-pp.D.%s-%s)))\n", zNM, zNM);
+ "$(pre-js.%s.js),"
+ C_PP_D_CUSTOM_INSTANTIATE "$(c-pp.D.%s)))\n",
+ zBuildName, zBuildName);
}else{
/* This part is needed for builds which have to rename the wasm file
in zJsOut so that the loader can find it. */
- pf("pre-js.js.%s-%s.intermediary = "
- "$(dir.tmp)/pre-js.%s-%s.intermediary.js\n",
- zNM, zNM);
+ pf("pre-js.%s.js.intermediary = "
+ "$(dir.tmp)/pre-js.%s.intermediary.js\n",
+ zBuildName, zBuildName);
pf("$(eval $(call SQLITE.CALL.C-PP.FILTER,$(pre-js.js.in),"
- "$(pre-js.js.%s-%s.intermediary),"
- C_PP_D_CUSTOM_INSTANTIATE "$(c-pp.D.%s-%s)))\n", zNM, zNM);
- pf("$(pre-js.js.%s-%s): $(pre-js.js.%s-%s.intermediary)\n", zNM, zNM);
- pf("\tcp $(pre-js.js.%s-%s.intermediary) $@\n", zNM);
+ "$(pre-js.%s.js.intermediary),"
+ C_PP_D_CUSTOM_INSTANTIATE "$(c-pp.D.%s)))\n",
+ zBuildName, zBuildName);
+ pf("$(pre-js.%s.js): $(pre-js.%s.js.intermediary)\n",
+ zBuildName, zBuildName);
+ pf("\tcp $(pre-js.%s.js.intermediary) $@\n", zBuildName);
pf("\t@echo 'sIMS.wasmFilename = \"%s\";' >> $@\n", zWasmOut)
/* see api/pre-js.c-pp.js:Module.instantiateModule() */;
}
/* --post-js=... */
- pf("post-js.js.%s-%s = $(dir.tmp)/post-js.%s-%s.js\n", zNM, zNM);
- pf("$(eval $(call SQLITE.CALL.C-PP.FILTER,$(post-js.js.in),"
- "$(post-js.js.%s-%s),$(c-pp.D.%s-%s)))\n", zNM, zNM);
+ pf("post-js.%s.js = $(dir.tmp)/post-js.%s.js\n",
+ zBuildName, zBuildName);
+ pf("post-jses.%s = "
+ "$(dir.api)/post-js-header.js "
+ "$(sqlite3-api.%s.js) "
+ "$(dir.api)/post-js-footer.js\n",
+ zBuildName, zBuildName);
+ pf("$(eval $(call SQLITE.CALL.C-PP.FILTER,$(post-jses.%s),"
+ "$(post-js.%s.js),$(c-pp.D.%s)))\n",
+ zBuildName, zBuildName, zBuildName);
/* --extern-post-js=... */
- pf("extern-post-js.js.%s-%s = $(dir.tmp)/extern-post-js.%s-%s.js\n",
- zNM, zNM);
+ pf("extern-post-js.%s.js = $(dir.tmp)/extern-post-js.%s.js\n",
+ zBuildName, zBuildName);
pf("$(eval $(call SQLITE.CALL.C-PP.FILTER,$(extern-post-js.js.in),"
- "$(extern-post-js.js.%s-%s),"
- C_PP_D_CUSTOM_INSTANTIATE "$(c-pp.D.%s-%s)))\n", zNM, zNM);
+ "$(extern-post-js.%s.js),"
+ C_PP_D_CUSTOM_INSTANTIATE "$(c-pp.D.%s)))\n",
+ zBuildName, zBuildName);
/* Combined flags for use with emcc... */
- pf("pre-post-common.flags.%s-%s = "
- "$(pre-post-common.flags) "
- "--post-js=$(post-js.js.%s-%s) "
- "--extern-post-js=$(extern-post-js.js.%s-%s)\n", zNM, zNM, zNM);
+ pf("pre-post.%s.flags += "
+ "--extern-pre-js=$(sqlite3-license-version.js) "
+ "--pre-js=$(pre-js.%s.js) "
+ "--post-js=$(post-js.%s.js) "
+ "--extern-post-js=$(extern-post-js.%s.js)\n",
+ zBuildName, zBuildName, zBuildName, zBuildName);
- pf("pre-post-%s-%s.flags += $(pre-post-common.flags.%s-%s) "
- "--pre-js=$(pre-js.js.%s-%s)\n", zNM, zNM, zNM);
/* Set up deps... */
- pf("pre-post-jses.%s-%s.deps = $(pre-post-jses.deps.common) "
- "$(post-js.js.%s-%s) $(extern-post-js.js.%s-%s)\n",
- zNM, zNM, zNM);
- pf("pre-post-%s-%s.deps = $(pre-post-jses.%s-%s.deps) "
- "$(dir.tmp)/pre-js.%s-%s.js\n",
- zNM, zNM, zNM);
- pf("# End --pre/--post flags for %s-%s%s", zNM, zBanner);
-#undef zNM
+ pf("pre-post.%s.deps = "
+ "$(pre-post-jses.common.deps) "
+ "$(post-js.%s.js) $(extern-post-js.%s.js) "
+ "$(dir.tmp)/pre-js.%s.js\n",
+ zBuildName, zBuildName, zBuildName, zBuildName);
+ pf("# End --pre/--post flags for %s%s", zBuildName, zBanner);
}
/*
static void mk_fiddle(void){
int i = 0;
- mk_pre_post("fiddle-module","vanilla", 0, "fiddle-module.wasm");
+ mk_pre_post("fiddle-module", 0, "fiddle-module.wasm");
for( ; i < 2; ++i ){
/* 0==normal, 1==debug */
const char *zTail = i ? ".debug" : "";
/*
** Emits makefile code for one build of the library.
*/
-static void mk_lib_mode(const BuildDef * pB){
+void mk_lib_mode(const char *zBuildName, const BuildDef * pB){
const char * zWasmOut = "$(basename $@).wasm"
/* The various targets named X.js or X.mjs (pB->zJsOut) also generate
** X.wasm, and we need that part of the name to perform some
** post-processing after Emscripten generates X.wasm. */;
- assert( pB->zName );
- assert( pB->zMode );
+ const char * zJsExt = (LIBMODE_ESM & pB->flags)
+ ? ".mjs" : ".js";
+ assert( pB->zWasmFile );
assert( pB->zJsOut );
/* Very common printf() args combo. */
-#define zNM pB->zName, pB->zMode
- pf("%s# Begin build [%s-%s]. flags=0x%02x\n", zBanner, zNM, pB->flags);
+ pf("%s# Begin build [%s]. flags=0x%02x\n", zBanner, zBuildName, pB->flags);
pf("# zJsOut=%s\n# zCmppD=%s\n# zWasmOut=%s\n", pB->zJsOut,
pB->zCmppD ? pB->zCmppD : "<none>",
pB->zWasmOut ? pB->zWasmOut : "");
- pf("$(info Setting up build [%s-%s]: %s)\n", zNM, pB->zJsOut);
- mk_pre_post(zNM, pB->zCmppD, pB->zWasmOut);
- pf("\nemcc.flags.%s.%s ?=\n", zNM);
- if( pB->zEmcc && pB->zEmcc[0] ){
- pf("emcc.flags.%s.%s += %s\n", zNM, pB->zEmcc);
+ pf("$(info Setting up build [%s]: %s)\n", zBuildName, pB->zJsOut);
+
+ assert( oBuildDefs.canonical.zEnv );
+ pf("emcc.environment.%s = %s\n", zBuildName,
+ pB->zEnv ? pB->zEnv : oBuildDefs.canonical.zEnv);
+ pf("emcc.flags.%s =\n", zBuildName);
+ if( pB->zEmcc ){
+ pf("emcc.flags.%s += %s\n", zBuildName, pB->zEmcc);
}
+ pf("sqlite3-api.%s.c-pp.js = $(dir.tmp)/sqlite3-api.%s.c-pp%s\n",
+ zBuildName, zBuildName, zJsExt);
+
+ pf("sqlite3-api.%s.js = $(dir.tmp)/sqlite3-api.%s%s\n",
+ zBuildName, zBuildName, zJsExt);
+ if( pB->zCmppD ){
+ pf("c-pp.D.%s = %s\n", zBuildName, pB->zCmppD );
+ }
+ pf("$(sqlite3-api.%s.c-pp.js): $(sqlite3-api.jses)\n"
+ "\t@echo 'Making $@ ...'; \\\n"
+ "\tfor i in $(sqlite3-api.jses); do \\\n"
+ "\t\techo \"/* BEGIN FILE: $$i */\"; \\\n"
+ "\t\tcat $$i; \\\n"
+ "\t\techo \"/* END FILE: $$i */\"; \\\n"
+ "\tdone > $@\n",
+ zBuildName);
+
+ pf("$(sqlite3-api.%s.js): $(sqlite3-api.%s.c-pp.js)\n"
+ "$(eval $(call SQLITE.CALL.C-PP.FILTER,"
+ "$(sqlite3-api.%s.c-pp.js), " /* $1 = src */
+ "$(sqlite3-api.%s.js), " /* $2 = tgt */
+ "$(c-pp.D.%s)" /* $3 = c-pp -Dx=Y flags */
+ "))\n",
+ zBuildName, zBuildName, zBuildName,
+ zBuildName, zBuildName);
+
+ mk_pre_post(zBuildName, pB->zCmppD, pB->zWasmOut);
+
/* target pB->zJsOut */
pf("%s: $(MAKEFILE_LIST) $(sqlite3-wasm.cfiles) $(EXPORTED_FUNCTIONS.api) "
"$(bin.mkwb) "
- "$(pre-post-%s-%s.deps) "
+ "$(pre-post.%s.deps) "
"$(sqlite3-api.ext.jses)"
/* ^^^ maintenance reminder: we set these as deps so that they
** get copied into place early. That allows the developer to
** are still compiling, which is especially helpful when running
** builds with long build times (like -Oz). */
"\n",
- pB->zJsOut, zNM);
+ pB->zJsOut, zBuildName);
pf("\t@echo \"Building $@ ...\"\n");
if( LIBMODE_UNSUPPORTED & pB->flags ){
ps("\t@echo 'ACHTUNG: $@ is an unsupported build. "
}
pf("\t$(bin.emcc) -o $@ $(emcc_opt_full) $(emcc.flags) \\\n");
pf("\t\t$(emcc.jsflags) -sENVIRONMENT=$(emcc.environment.%s) \\\n",
- pB->zMode);
- pf("\t\t$(pre-post-%s-%s.flags) \\\n", zNM);
- pf("\t\t$(emcc.flags.%s) $(emcc.flags.%s.%s) \\\n", pB->zName, zNM);
- 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", pB->zName, zNM);
+ zBuildName);
+ pf("\t\t$(pre-post.%s.flags) \\\n", zBuildName);
+ if( pB->zEmcc ){
+ pf("\t\t$(emcc.%s.flags) \\\n", zBuildName);
+ }
+ pf("\t\t$(cflags.common) $(cflags.%s) \\\n"
+ "\t\t$(SQLITE_OPT) \\\n"
+ "\t\t$(cflags.wasm_extra_init) $(sqlite3-wasm.cfiles)\n",
+ zBuildName);
if( (LIBMODE_ESM & pB->flags) || (LIBMODE_NODEJS & pB->flags) ){
/* TODO? Replace this $(call) with the corresponding makefile
** code. OTOH, we also use this $(call) in the speedtest1-wasmfs
** empty.
*/
if( (LIBMODE_BUNDLER_FRIENDLY & pB->flags) ){
- pf("\t@echo 'Patching $@ for %s.wasm...'; \\\n", pB->zName);
+#if 1
+ pf("\t@echo 'FIXME: missing build pieces for build %s'; exit 1\n",
+ zBuildName);
+#else
+ fixme;
+ pf("\t@echo 'Patching $@ for %s.wasm...'; \\\n", pB->zWasmFile);
pf("\t\trm -f %s; \\\n", zWasmOut);
- pf("\t\tsed -i -e 's/%s-%s.wasm/%s.wasm/g' $@ || exit;\n",
+ pf("\t\tsed -i -e 's/\"%s.wasm\"/\"%s.wasm\"/g' $@ || exit;\n",
/* ^^^^^^ reminder: Mac/BSD sed has no -i flag but this
** build process explicitly requires a Linux system. */
- zNM, pB->zName);
+ zNM, pB->zWasmFile);
pf("\t@ls -la $@\n");
if( LIBMODE_BUNDLER_FRIENDLY & pB->flags ){
/* Avoid a 3rd occurrence of the bug fixed by 65798c09a00662a3,
"then echo 'ERROR: bug fixed in 65798c09a00662a3 has re-appeared'; "
"exit 1; fi;\n");
}
+#endif
}else{
pf("\t@ls -la %s $@\n", zWasmOut);
}
&& 0==(LIBMODE_UNSUPPORTED & pB->flags) ){
pf("all: %s\n", pB->zJsOut);
}
- pf("# End build [%s-%s]%s", zNM, zBanner);
-#undef zNM
+ pf("# End build [%s]%s", zBuildName, zBanner);
}
int main(void){
const BuildDef *pB;
pf("# What follows was GENERATED by %s. Edit at your own risk.\n", __FILE__);
mk_prologue();
-#define E(N) mk_lib_mode(&oBuildDefs.N);
+#define E(N) mk_lib_mode(# N, &oBuildDefs.N);
BuildDefs_map(E)
#undef E
+#if 0
mk_fiddle();
- mk_pre_post("speedtest1","vanilla", 0, "speedtest1.wasm");
- mk_pre_post("speedtest1-wasmfs", "esm",
+ mk_pre_post(0, "speedtest1","vanilla", 0, "speedtest1.wasm");
+ mk_pre_post(0, "speedtest1-wasmfs", "esm",
"$(c-pp.D.sqlite3-bundler-friendly) -Dwasmfs",
"speetest1-wasmfs.wasm");
+#endif
return rc;
}