mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
More work on the JS end-user deliverables. Add tool/stripccomments.c to support that.
FossilOrigin-Name: 2156f0744acfe425457430a0f6a7e02de907de85edba81a6d4eef40293e561c8
This commit is contained in:
@ -1,11 +1,29 @@
|
||||
########################################################################
|
||||
# This GNU makefile drives the build of the sqlite3 WASM
|
||||
# components. It is not part of the canonical build process.
|
||||
#
|
||||
# This build assumes a Linux platform and is not intended for
|
||||
# client-level use. It is for the sqlite project's own development of
|
||||
# the JS/WASM components.
|
||||
#
|
||||
# Primary targets:
|
||||
#
|
||||
# default, all = build in dev mode
|
||||
#
|
||||
# o0, o1, o2, o3, os, oz = full clean/rebuild with the -Ox level indicated
|
||||
# by the target name. Rebuild is necessary for all components to get
|
||||
# the desired optimization level.
|
||||
#
|
||||
# dist = create end user deliverables. Add dist-opt=oX to build with a
|
||||
# specific optimization level, where oX is one of the above-listed
|
||||
# o? target names.
|
||||
#
|
||||
# clean = clean up
|
||||
########################################################################
|
||||
SHELL := $(shell which bash 2>/dev/null)
|
||||
MAKEFILE := $(lastword $(MAKEFILE_LIST))
|
||||
all:
|
||||
release: all
|
||||
default: all
|
||||
release: default
|
||||
|
||||
# Emscripten SDK home dir and related binaries...
|
||||
EMSDK_HOME ?= $(word 1,$(wildcard $(HOME)/src/emsdk $(HOME)/emsdk))
|
||||
@ -46,7 +64,9 @@ dir.api := api
|
||||
dir.jacc := jaccwabyt
|
||||
dir.common := common
|
||||
dir.fiddle := fiddle
|
||||
dir.tool := $(dir.top)/tool
|
||||
CLEAN_FILES := *~ $(dir.jacc)/*~ $(dir.api)/*~ $(dir.common)/*~
|
||||
DISTCLEAN_FILES := ./-dummy
|
||||
emcc_enable_bigint ?= 1
|
||||
sqlite3.c := $(dir.top)/sqlite3.c
|
||||
sqlite3.h := $(dir.top)/sqlite3.h
|
||||
@ -113,8 +133,11 @@ emcc_opt_full := $(emcc_opt) -g3
|
||||
$(sqlite3.c) $(sqlite3.h):
|
||||
$(MAKE) -C $(dir.top) sqlite3.c
|
||||
|
||||
.PHONY: clean distclean
|
||||
clean:
|
||||
-rm -f $(CLEAN_FILES)
|
||||
distclean: clean
|
||||
-rm -f $(DISTCLEAN_FILES)
|
||||
|
||||
ifeq (release,$(filter release,$(MAKECMDGOALS)))
|
||||
ifeq (,$(wasm-strip))
|
||||
@ -128,7 +151,12 @@ endif
|
||||
version-info := $(dir.wasm)/version-info
|
||||
$(version-info): $(dir.wasm)/version-info.c $(sqlite3.h) $(MAKEFILE)
|
||||
$(CC) -O0 -I$(dir.top) -o $@ $<
|
||||
CLEAN_FILES := $(version-info)
|
||||
DISTCLEAN_FILES += $(version-info)
|
||||
|
||||
stripccomments := $(dir.tool)/stripccomments
|
||||
$(stripccomments): $(stripccomments).c $(MAKEFILE)
|
||||
$(CC) -o $@ $<
|
||||
DISTCLEAN_FILES += $(stripccomments)
|
||||
|
||||
EXPORTED_FUNCTIONS.api.in := $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-api
|
||||
|
||||
@ -480,11 +508,7 @@ push-fiddle: $(fiddle_files)
|
||||
# painful.
|
||||
|
||||
.PHONY: o0 o1 o2 o3 os oz
|
||||
o-xtra := -g3
|
||||
# ^^^ -g3 is important to keep higher -O levels from mangling (via
|
||||
# minification), or outright removing, otherwise working code.
|
||||
|
||||
o-xtra += -flto
|
||||
o-xtra := -flto
|
||||
# ^^^^ -flto can have a considerably performance boost at -O0 but
|
||||
# doubles the build time and seems to have negligible effect on
|
||||
# higher optimization levels.
|
||||
@ -515,7 +539,9 @@ PLATFORMS_WITH_NO_WASMFS := aarch64 # add any others here
|
||||
THIS_ARCH := $(shell /usr/bin/uname -m)
|
||||
ifneq (,$(filter $(THIS_ARCH),$(PLATFORMS_WITH_NO_WASMFS)))
|
||||
$(info This platform does not support the WASMFS build.)
|
||||
HAVE_WASMFS := 0
|
||||
else
|
||||
HAVE_WASMFS := 1
|
||||
include wasmfs.make
|
||||
endif
|
||||
|
||||
|
@ -15,10 +15,10 @@ This archive contains two related deliverables:
|
||||
but is less portable than the main build, so is provided
|
||||
as a separate binary.
|
||||
|
||||
Both directories contain small demonstration apps. Browsers will not
|
||||
server WASM files from file:// URLs, so the demonstrations require a
|
||||
web server and that server must include the following headers in its
|
||||
response when serving the files:
|
||||
Both directories contain small demonstration and test apps. Browsers
|
||||
will not serve WASM files from file:// URLs, so the demo/test apps
|
||||
require a web server and that server must include the following
|
||||
headers in its response when serving the files:
|
||||
|
||||
Cross-Origin-Opener-Policy: same-origin
|
||||
Cross-Origin-Embedder-Policy: require-corp
|
||||
|
@ -9,51 +9,87 @@
|
||||
#######################################################################
|
||||
MAKEFILE.dist := $(lastword $(MAKEFILE_LIST))
|
||||
|
||||
ifeq (0,$(HAVE_WASMFS))
|
||||
$(error The 'dist' target needs to be run on a WASMFS-capable platform.)
|
||||
endif
|
||||
|
||||
########################################################################
|
||||
# Chicken/egg situation: we need $(version-info) to get the version
|
||||
# info for the archive name, but that binary may not yet be built, so
|
||||
# we have to use a temporary name for the archive.
|
||||
# info for the archive name, but that binary may not yet be built, and
|
||||
# won't be built until we expand the dependencies. We have to use a
|
||||
# temporary name for the archive.
|
||||
dist-name = sqlite-wasm-TEMP
|
||||
dist-archive = $(dist-name).zip
|
||||
|
||||
.PHONY: $(dist-archive)
|
||||
CLEAN_FILES += $(wildcard sqlite-wasm-*.zip)
|
||||
#ifeq (0,1)
|
||||
# $(info WARNING *******************************************************************)
|
||||
# $(info ** Be sure to create the desired build configuration before creating the)
|
||||
# $(info ** distribution archive. Use one of the following targets to do so:)
|
||||
# $(info **)
|
||||
# $(info ** o2: builds with -O2, resulting in the fastest builds)
|
||||
# $(info ** oz: builds with -Oz, resulting in the smallest builds)
|
||||
# $(info /WARNING *******************************************************************)
|
||||
#endif
|
||||
|
||||
########################################################################
|
||||
# dist-opt must be the name of a target which triggers the
|
||||
# build of the files to be packed into the dist archive. The
|
||||
# intention is that it be one of (o0, o1, o2, o3, os, oz), each of
|
||||
# which uses like-named -Ox optimization level flags. The o2 target
|
||||
# provides the best overall runtime speeds. The oz target provides
|
||||
# slightly slower speeds (roughly 10%) with significantly smaller WASM
|
||||
# file sizes. Note that -O2 (the o2 target) results in faster binaries
|
||||
# than both -O3 and -Os (the o3 and os targets) in all tests run to
|
||||
# date.
|
||||
dist-opt ?= oz
|
||||
|
||||
demo-123.html := $(dir.wasm)/demo-123.html
|
||||
demo-123-worker.html := $(dir.wasm)/demo-123-worker.html
|
||||
demo-123.js := $(dir.wasm)/demo-123.js
|
||||
demo-files := $(demo-123.js) $(demo-123.html) $(demo-123-worker.html)
|
||||
demo-files := $(demo-123.js) $(demo-123.html) $(demo-123-worker.html) \
|
||||
tester1.html tester1.js tester1-worker.html
|
||||
README-dist := $(dir.wasm)/README-dist.txt
|
||||
$(dist-archive): $(sqlite3.wasm) $(sqlite3.js) $(sqlite3-wasmfs.wasm) $(sqlite3-wasmfs.js)
|
||||
#$(dist-archive): $(sqlite3.h) $(sqlite3.c) $(sqlite3-wasm.c)
|
||||
$(dist-archive): $(MAKEFILE.dist) $(version-info) $(demo-files) $(README-dist)
|
||||
$(dist-archive): oz
|
||||
rm -fr $(dist-name)
|
||||
mkdir -p $(dist-name)/main $(dist-name)/wasmfs
|
||||
cp -p $(README-dist) $(dist-name)/README.txt
|
||||
cp -p $(sqlite3.wasm) $(sqlite3.js) $(dist-name)/main
|
||||
cp -p $(demo-files) $(dist-name)/main
|
||||
cp -p $(sqlite3-wasmfs.wasm) $(sqlite3-wasmfs.js) $(dist-name)/wasmfs
|
||||
for i in $(demo-123.js) $(demo-123.html); do \
|
||||
dist-dir-main := $(dist-name)/main
|
||||
dist-dir-wasmfs := $(dist-name)/wasmfs
|
||||
########################################################################
|
||||
# $(dist-archive): create the end-user deliverable archive.
|
||||
#
|
||||
# Maintenance reminder: because $(dist-archive) depends on
|
||||
# $(dist-opt), and $(dist-opt) will depend on clean, having any deps
|
||||
# on $(dist-archive) which themselves may be cleaned up by the clean
|
||||
# target will lead to grief in parallel builds (-j #). Thus
|
||||
# $(dist-target)'s deps must be trimmed to non-generated files or
|
||||
# files which are _not_ cleaned up by the clean target.
|
||||
$(dist-archive): \
|
||||
$(stripccomments) $(version-info) \
|
||||
$(dist-opt) \
|
||||
$(MAKEFILE) $(MAKEFILE.dist)
|
||||
@echo "Making end-user deliverables..."
|
||||
@rm -fr $(dist-name)
|
||||
@mkdir -p $(dist-dir-main) $(dist-dir-wasmfs)
|
||||
@cp -p $(README-dist) $(dist-name)/README.txt
|
||||
@cp -p $(sqlite3.wasm) $(dist-dir-main)
|
||||
@$(stripccomments) -k -k < $(sqlite3.js) \
|
||||
> $(dist-dir-main)/$(notdir $(sqlite3.js))
|
||||
@cp -p $(demo-files) $(dist-dir-main)
|
||||
@cp -p $(sqlite3-wasmfs.wasm) sqlite3-wasmfs.worker.js $(dist-dir-wasmfs)
|
||||
@$(stripccomments) -k -k < $(sqlite3-wasmfs.js) \
|
||||
> $(dist-dir-wasmfs)/$(notdir $(sqlite3-wasmfs.js))
|
||||
@for i in $(demo-123.js) $(demo-123.html); do \
|
||||
sed -e 's/\bsqlite3\.js\b/sqlite3-wasmfs.js/' $$i \
|
||||
> $(dist-name)/wasmfs/$${i##*/} || exit; \
|
||||
> $(dist-dir-wasmfs)/$${i##*/} || exit; \
|
||||
done
|
||||
vnum=$$($(version-info) --version-number); \
|
||||
@vnum=$$($(version-info) --version-number); \
|
||||
vdir=sqlite-wasm-$$vnum; \
|
||||
arc=$$vdir.zip; \
|
||||
echo "Making $$arc ..."; \
|
||||
rm -f $$arc; \
|
||||
mv $(dist-name) $$vdir; \
|
||||
zip -qr $$arc $$vdir; \
|
||||
rm -fr $$vdir; \
|
||||
ls -la $$arc; \
|
||||
unzip -l $$arc
|
||||
unzip -lv $$arc || echo "Missing unzip app? Not fatal."
|
||||
|
||||
#$(shell $(version-info) --version-number)
|
||||
dist: $(dist-archive)
|
||||
|
Reference in New Issue
Block a user