1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
#!/usr/bin/make -f
include /usr/share/dpkg/pkg-info.mk
# detect if build targets experimental suite (or is a draft)
DEB_SUITE_EXP = $(filter experimental% UNRELEASED,$(DEB_DISTRIBUTION))
# GNU LibreJS 5.0 compatible license string
# * See <https://www.gnu.org/software/librejs/free-your-javascript.html>
LICENSE = // @license magnet:?xt=urn:btih:87f119ba0b429ba17a44b4bffcab33165ebdacc0&dn=freebsd.txt BSD-2-Clause
# generate documentation unless nodoc requested
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
DOCS = README.html README.txt
MANPAGES = debian-man/terser.1
endif
ESLINT = eslint --format tap
MOCHA = mocha --no-timeout --reporter tap
# generate manpage with help2man from --help option of Node.js script
_mkman = help2man $(if $3,--name "$(strip $3)") --no-info --output $2 $1 \
|| { $1 --help; false; }
override_dh_auto_configure:
mkdir -p node_modules
for l in acorn escodegen rimraf semver source-map source-map-support; do \
ln -s /usr/share/nodejs/$$l node_modules/; \
done
mkdir -p node_modules/@jridgewell
ln -s /usr/share/nodejs/@jridgewell/source-map node_modules/@jridgewell
override_dh_auto_build: \
debian/js/bundle.js.gz $(DOCS) $(MANPAGES)
# build manpage
debian-man/terser.1: debian-man/%.1: bin/% debian/js/bundle.js.gz
mkdir --parents $(dir $@)
$(call _mkman, $<, $@, \
JavaScript parser and mangler/compressor and beautifier toolkit)
# * don't fail on experimental builds
# * trick testsuite into not using mochallel
# * ignore tests relying on NodeJS module astring (we use escodegen)
override_dh_auto_test:
$(ESLINT) lib
node test/compress.js
$(MOCHA) test/mocha | debian/tap-todo \
'^input sourcemaps Should preserve unmapped segments in output source map$$' \
'^spidermonkey export/import sanity test should produce a spidermonkey AST w/ .format.spidermonkey: true.$$' \
'^spidermonkey export/import sanity test should produce an AST compatible with astring$$' \
$(if $(DEB_SUITE_EXP),|| true)
# install core documentation with all binary packages
override_dh_installdocs:
dh_installdocs -- $(DOCS)
# build browser and test libraries
debian/js/%.js:
rollup --no-esModule -c
cp --force dist/bundle.min.cjs dist/bundle.js
mkdir --parents debian/js
install --mode a=r,u+w -D --target-directory debian/js \
-- dist/bundle*
mv debian/js/bundle.min.cjs debian/js/bundle.min.js
mv --force dist/bundle.js dist/bundle.min.cjs
# pre-compress for browser use
%.gz: %
pigz --force --keep -11 -- $<
brotli --force --keep --best --suffix=.brotli -- $<
%.html: %.md
cmark-gfm $< > $@
%.txt: %.md
cmark-gfm --to plaintext $< > $@
%:
dh $@
.SECONDARY:
|