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 (,$(filter snapshot
,$(MAKECMDGOALS
)))
23 dist-name-prefix
:= sqlite-wasm
25 dist-name-prefix
:= sqlite-wasm-snapshot-
$(shell /usr
/bin
/date
+%Y
%m
%d
)
27 dist-name
:= $(dist-name-prefix
)-TEMP
29 ########################################################################
30 # dist.build must be the name of a target which triggers the build of
31 # the files to be packed into the dist archive. The intention is that
32 # it be one of (o0, o1, o2, o3, os, oz), each of which uses like-named
33 # -Ox optimization level flags. The o2 target provides the best
34 # overall runtime speeds. The oz target provides slightly slower
35 # speeds (roughly 10%) with significantly smaller WASM file
36 # sizes. Note that -O2 (the o2 target) results in faster binaries than
37 # both -O3 and -Os (the o3 and os targets) in all tests run to
38 # date. Our general policy is that we want the smallest binaries for
39 # dist zip files, so use the oz build unless there is a compelling
43 dist-dir.top
:= $(dist-name
)
44 dist-dir.jswasm
:= $(dist-dir.top
)/$(notdir $(dir.dout
))
45 dist-dir.common
:= $(dist-dir.top
)/common
47 demo-123.html demo-123-worker.html demo-123.js \
48 tester1.html tester1-worker.html tester1-esm.html \
49 tester1.js tester1.mjs \
50 demo-jsstorage.html demo-jsstorage.js \
51 demo-worker1.html demo-worker1.js \
52 demo-worker1-promiser.html demo-worker1-promiser.js
53 dist.jswasm.extras
:= $(sqlite3-api.ext.jses
) $(sqlite3.wasm
)
54 dist.common.extras
:= \
55 $(wildcard $(dir.common
)/*.css
) \
56 $(dir.common
)/SqliteTestUtil.js
59 # DIST_STRIP_COMMENTS $(call)able to be used in stripping C-style
60 # from the dist copies of certain files.
63 # $2 = flags for $(bin.stripcomments)
64 define DIST_STRIP_COMMENTS
65 $(bin.stripccomments
) $(2) < $(1) > $(dist-dir.jswasm
)/$(notdir $(1)) || exit
;
67 # STRIP_K1.js = list of JS files which need to be passed through
68 # $(bin.stripcomments) with a single -k flag.
69 STRIP_K1.js
:= $(sqlite3-worker1.js
) $(sqlite3-worker1-promiser.js
) \
70 $(sqlite3-worker1-bundler-friendly.js
) $(sqlite3-worker1-promiser-bundler-friendly.js
)
71 # STRIP_K2.js = list of JS files which need to be passed through
72 # $(bin.stripcomments) with two -k flags.
73 STRIP_K2.js
:= $(sqlite3.js
) $(sqlite3.mjs
) $(sqlite3-bundler-friendly.mjs
)
74 ########################################################################
75 # dist: create the end-user deliverable archive.
77 # Maintenance reminder: because dist depends on $(dist.build), and
78 # $(dist.build) will depend on clean, having any deps on
79 # $(dist-archive) which themselves may be cleaned up by the clean
80 # target will lead to grief in parallel builds (-j #). Thus
81 # dist's deps must be trimmed to non-generated files or
82 # files which are _not_ cleaned up by the clean target.
84 # Note that we require $(bin.version-info) in order to figure out the
85 # dist file's name, so cannot (without a recursive make) have the
86 # target name equal to the archive name.
88 $(bin.stripccomments
) $(bin.version-info
) \
89 $(dist.build
) $(STRIP_K1.js
) $(STRIP_K2.js
) \
90 $(MAKEFILE
) $(MAKEFILE.
dist)
91 @echo
"Making end-user deliverables..."
92 @
rm -fr
$(dist-dir.top
)
93 @mkdir
-p
$(dist-dir.jswasm
) $(dist-dir.common
)
94 @cp
-p
$(dist.top.extras
) $(dist-dir.top
)
95 @cp
-p README-dist.txt
$(dist-dir.top
)/README.txt
96 @cp
-p index-dist.html
$(dist-dir.top
)/index.html
97 @cp
-p
$(dist.jswasm.extras
) $(dist-dir.jswasm
)
98 @
$(foreach JS
,$(STRIP_K1.js
),$(call DIST_STRIP_COMMENTS
,$(JS
),-k
))
99 @
$(foreach JS
,$(STRIP_K2.js
),$(call DIST_STRIP_COMMENTS
,$(JS
),-k
-k
))
100 @cp
-p
$(dist.common.extras
) $(dist-dir.common
)
102 vnum
=$$($(bin.version-info
) --download-version
); \
103 vdir
=$(dist-name-prefix
)-$$vnum; \
105 echo
"Making $$arczip ..."; \
106 rm -fr
$$arczip $$vdir; \
107 mv
$(dist-dir.top
) $$vdir; \
108 zip
-qr
$$arczip $$vdir; \
112 unzip
-lv
$$arczip || echo
"Missing unzip app? Not fatal."
113 ifeq (,$(wasm.docs.found
))
115 @echo
"To upload the snapshot build to the wasm docs server:"; \
116 echo
"1) move $(dist-name-prefix)*.zip to the top of a wasm docs checkout."; \
117 echo
"2) run 'make uv-sync'"
120 @echo
"Moving snapshot to [$(wasm.docs.found)]..."; \
121 mv
$(dist-name-prefix
)*.zip
$(wasm.docs.found
)/.
122 @echo
"Run 'make uv-sync' from $(wasm.docs.found) to upload it."
124 # We need a separate `clean` rule to account for weirdness in
125 # a sub-make, where we get a copy of the $(dist-name) dir
126 # copied into the new $(dist-name) dir.
130 rm -fr
$(dist-name
) $(wildcard sqlite-wasm-
*.zip
)