2 #^^^ help emacs select edit mode
4 # Intended to include'd by ./GNUmakefile.
6 # 'make dist' rules for creating a distribution archive of the WASM/JS
7 # pieces, noting that we only build a dist of the built files, not the
8 # numerous pieces required to build them.
10 # Use 'make snapshot' to create "snapshot" releases. They use a
11 # distinctly different zip file and top directory name to distinguish
12 # them from release builds.
13 #######################################################################
14 MAKEFILE.
dist := $(lastword
$(MAKEFILE_LIST
))
16 ########################################################################
17 # Chicken/egg situation: we need $(bin.version-info) to get the
18 # version info for the archive name, but that binary may not yet be
19 # built, and won't be built until we expand the dependencies. Thus we
20 # have to use a temporary name for the archive until we can get
22 ifeq (1,$(SQLITE_C_IS_SEE
))
23 dist-name-extra
:= -see
27 ifeq (,$(filter snapshot
,$(MAKECMDGOALS
)))
28 dist-name-prefix
:= sqlite-wasm
$(dist-name-extra
)
30 dist-name-prefix
:= sqlite-wasm
$(dist-name-extra
)-snapshot-
$(shell /usr
/bin
/date
+%Y
%m
%d
)
32 dist-name
:= $(dist-name-prefix
)-TEMP
34 ########################################################################
35 # dist.build must be the name of a target which triggers the build of
36 # the files to be packed into the dist archive. The intention is that
37 # it be one of (o0, o1, o2, o3, os, oz), each of which uses like-named
38 # -Ox optimization level flags. The o2 target provides the best
39 # overall runtime speeds. The oz target provides slightly slower
40 # speeds (roughly 10%) with significantly smaller WASM file
41 # sizes. Note that -O2 (the o2 target) results in faster binaries than
42 # both -O3 and -Os (the o3 and os targets) in all tests run to
43 # date. Our general policy is that we want the smallest binaries for
44 # dist zip files, so use the oz build unless there is a compelling
48 dist-dir.top
:= $(dist-name
)
49 dist-dir.jswasm
:= $(dist-dir.top
)/$(notdir $(dir.dout
))
50 dist-dir.common
:= $(dist-dir.top
)/common
52 demo-123.html demo-123-worker.html demo-123.js \
53 tester1.html tester1-worker.html tester1-esm.html \
54 tester1.js tester1.mjs \
55 demo-jsstorage.html demo-jsstorage.js \
56 demo-worker1.html demo-worker1.js \
57 demo-worker1-promiser.html demo-worker1-promiser.js \
58 demo-worker1-promiser-esm.html demo-worker1-promiser.mjs
59 dist.jswasm.extras
:= $(sqlite3.wasm
) \
60 $(sqlite3-api.ext.jses
)
61 dist.common.extras
:= \
62 $(wildcard $(dir.common
)/*.css
) \
63 $(dir.common
)/SqliteTestUtil.js
65 #$(info sqlite3-worker1-promiser.mjs = $(sqlite3-worker1-promiser.mjs))
66 #$(info sqlite3-worker1.js = $(sqlite3-worker1.js))
67 #$(info sqlite3-api.ext.jses = $(sqlite3-api.ext.jses))
68 #$(info dist.jswasm.extras = $(dist.jswasm.extras))
70 # DIST_STRIP_COMMENTS $(call)able to be used in stripping C-style
71 # from the dist copies of certain files.
74 # $2 = flags for $(bin.stripcomments)
75 define DIST_STRIP_COMMENTS
76 $(bin.stripccomments
) $(2) < $(1) > $(dist-dir.jswasm
)/$(notdir $(1)) || exit
;
78 # STRIP_K1.js = list of JS files which need to be passed through
79 # $(bin.stripcomments) with a single -k flag.
80 STRIP_K1.js
:= $(sqlite3-worker1.js
) $(sqlite3-worker1-promiser.js
) \
81 $(sqlite3-worker1-bundler-friendly.js
) \
82 $(sqlite3-api.ext.jses
)
83 # STRIP_K2.js = list of JS files which need to be passed through
84 # $(bin.stripcomments) with two -k flags.
85 STRIP_K2.js
:= $(sqlite3.js
) $(sqlite3.mjs
) \
86 $(sqlite3-bundler-friendly.mjs
) $(sqlite3-node.mjs
)
87 ########################################################################
88 # dist: create the end-user deliverable archive.
90 # Maintenance reminder: because dist depends on $(dist.build), and
91 # $(dist.build) will depend on clean, having any deps on
92 # $(dist-archive) which themselves may be cleaned up by the clean
93 # target will lead to grief in parallel builds (-j #). Thus
94 # dist's deps must be trimmed to non-generated files or
95 # files which are _not_ cleaned up by the clean target.
97 # Note that we require $(bin.version-info) in order to figure out the
98 # dist file's name, so cannot (without a recursive make) have the
99 # target name equal to the archive name.
101 $(bin.stripccomments
) $(bin.version-info
) \
102 $(dist.build
) $(STRIP_K1.js
) $(STRIP_K2.js
) \
103 $(dist.jswasm.extras
) $(dist.common.extras
) \
104 $(MAKEFILE
) $(MAKEFILE.
dist)
105 @echo
"Making end-user deliverables..."
106 @
rm -fr
$(dist-dir.top
)
107 @mkdir
-p
$(dist-dir.jswasm
) $(dist-dir.common
)
108 @cp
-p
$(dist.top.extras
) $(dist-dir.top
)
109 @cp
-p README-dist.txt
$(dist-dir.top
)/README.txt
110 @cp
-p index-dist.html
$(dist-dir.top
)/index.html
111 @cp
-p
$(dist.jswasm.extras
) $(dist-dir.jswasm
)
112 @
$(foreach JS
,$(STRIP_K1.js
),$(call DIST_STRIP_COMMENTS
,$(JS
),-k
))
113 @
$(foreach JS
,$(STRIP_K2.js
),$(call DIST_STRIP_COMMENTS
,$(JS
),-k
-k
))
114 @cp
-p
$(dist.common.extras
) $(dist-dir.common
)
116 vnum
=$$($(bin.version-info
) --download-version
); \
117 vdir
=$(dist-name-prefix
)-$$vnum; \
119 echo
"Making $$arczip ..."; \
120 rm -fr
$$arczip $$vdir; \
121 mv
$(dist-dir.top
) $$vdir; \
122 zip
-qr
$$arczip $$vdir; \
126 unzip
-lv
$$arczip || echo
"Missing unzip app? Not fatal."
127 ifeq (,$(wasm.docs.found
))
129 @echo
"To upload the snapshot build to the wasm docs server:"; \
130 echo
"1) move $(dist-name-prefix)*.zip to the top of a wasm docs checkout."; \
131 echo
"2) run 'make uv-sync'"
134 @echo
"Moving snapshot to [$(wasm.docs.found)]..."; \
135 mv
$(dist-name-prefix
)*.zip
$(wasm.docs.found
)/.
136 @echo
"Run 'make uv-sync' from $(wasm.docs.found) to upload it."
138 # We need a separate `clean` rule to account for weirdness in
139 # a sub-make, where we get a copy of the $(dist-name) dir
140 # copied into the new $(dist-name) dir.
144 rm -fr
$(dist-name
) $(wildcard sqlite-wasm-
*.zip
)