2014-06-16 21:27:47 +00:00
|
|
|
LIB=crc32
|
2015-05-06 21:47:18 +00:00
|
|
|
REQS=
|
|
|
|
ADDONS=
|
2022-01-24 08:14:46 +00:00
|
|
|
AUXTARGETS=crc32c.js demo/browser.js
|
2016-10-08 18:48:03 +00:00
|
|
|
CMDS=bin/crc32.njs
|
2016-06-16 20:49:46 +00:00
|
|
|
HTMLLINT=index.html
|
2015-05-06 21:47:18 +00:00
|
|
|
|
|
|
|
ULIB=$(shell echo $(LIB) | tr a-z A-Z)
|
2014-06-16 21:27:47 +00:00
|
|
|
DEPS=$(sort $(wildcard bits/*.js))
|
|
|
|
TARGET=$(LIB).js
|
2016-06-16 20:49:46 +00:00
|
|
|
FLOWTARGET=$(LIB).flow.js
|
2017-06-12 20:12:23 +00:00
|
|
|
FLOWTGTS=$(TARGET) $(AUXTARGETS)
|
|
|
|
CLOSURE=/usr/local/lib/node_modules/google-closure-compiler/compiler.jar
|
2016-06-16 20:49:46 +00:00
|
|
|
|
2022-08-13 04:29:46 +00:00
|
|
|
ESMJSTGT=crc32.mjs
|
|
|
|
ESMJSDEPS=$(shell cat misc/mjs.lst)
|
|
|
|
|
2016-06-16 20:49:46 +00:00
|
|
|
## Main Targets
|
2014-06-16 21:27:47 +00:00
|
|
|
|
2015-05-06 21:47:18 +00:00
|
|
|
.PHONY: all
|
2022-08-13 04:29:46 +00:00
|
|
|
all: $(TARGET) $(AUXTARGETS) $(ESMJSTGT) crc32c.mjs ## Build library and auxiliary scripts
|
2015-05-06 21:47:18 +00:00
|
|
|
|
2017-06-12 20:12:23 +00:00
|
|
|
$(FLOWTGTS): %.js : %.flow.js
|
2016-06-16 20:49:46 +00:00
|
|
|
node -e 'process.stdout.write(require("fs").readFileSync("$<","utf8").replace(/^[ \t]*\/\*[:#][^*]*\*\/\s*(\n)?/gm,"").replace(/\/\*[:#][^*]*\*\//gm,""))' > $@
|
2015-05-06 21:47:18 +00:00
|
|
|
|
2016-06-16 20:49:46 +00:00
|
|
|
$(FLOWTARGET): $(DEPS)
|
2014-06-16 21:27:47 +00:00
|
|
|
cat $^ | tr -d '\15\32' > $@
|
|
|
|
|
2022-08-13 04:29:46 +00:00
|
|
|
$(ESMJSTGT): $(ESMJSDEPS)
|
|
|
|
cat $^ | tr -d '\15\32' > $@
|
|
|
|
|
2014-06-16 21:27:47 +00:00
|
|
|
bits/01_version.js: package.json
|
2017-06-12 20:12:23 +00:00
|
|
|
echo "$(ULIB).version = '"`grep version package.json | awk '{gsub(/[^0-9a-z\.-]/,"",$$2); print $$2}'`"';" > $@
|
2014-06-16 21:27:47 +00:00
|
|
|
|
|
|
|
.PHONY: clean
|
2016-06-16 20:49:46 +00:00
|
|
|
clean: clean-baseline ## Remove targets and build artifacts
|
|
|
|
rm -f $(TARGET) $(FLOWTARGET)
|
|
|
|
|
2022-01-24 08:14:46 +00:00
|
|
|
crc32c.flow.js: crc32.flow.js
|
2022-01-25 05:48:10 +00:00
|
|
|
cat $^ | sed 's/-306674912/-2097792136/g; s/CRC32\([ \/\.]\)/CRC32C\1/g' > $@
|
2022-01-24 08:14:46 +00:00
|
|
|
|
2022-08-13 04:29:46 +00:00
|
|
|
crc32c.mjs: crc32.mjs
|
|
|
|
cat $^ | sed 's/-306674912/-2097792136/g; s/CRC32\([ \/\.]\)/CRC32C\1/g' > $@
|
|
|
|
|
2016-06-16 20:49:46 +00:00
|
|
|
## Testing
|
2014-06-16 21:27:47 +00:00
|
|
|
|
|
|
|
.PHONY: test mocha
|
2016-06-16 20:49:46 +00:00
|
|
|
test mocha: test.js $(TARGET) baseline ## Run test suite
|
2022-04-04 22:53:34 +00:00
|
|
|
./node_modules/.bin/mocha -R spec -t 60000
|
2014-06-16 21:27:47 +00:00
|
|
|
|
|
|
|
.PHONY: ctest
|
2016-06-16 20:49:46 +00:00
|
|
|
ctest: ## Build browser test (into ctest/ subdirectory)
|
2014-06-16 21:27:47 +00:00
|
|
|
cat misc/*.js > ctest/fixtures.js
|
|
|
|
cp -f test.js ctest/test.js
|
2016-10-08 18:48:03 +00:00
|
|
|
cp -f shim.js ctest/shim.js
|
2015-05-06 21:47:18 +00:00
|
|
|
cp -f $(TARGET) ctest/
|
2014-06-16 21:27:47 +00:00
|
|
|
|
2016-06-16 20:49:46 +00:00
|
|
|
.PHONY: ctestserv
|
|
|
|
ctestserv: ## Start a test server on port 8000
|
2024-09-22 03:22:28 +00:00
|
|
|
@cd ctest && python -mSimpleHTTPServer || python3 -mhttp.server || npx -y http-server -p 8000 .
|
2016-06-16 20:49:46 +00:00
|
|
|
|
|
|
|
.PHONY: baseline
|
|
|
|
baseline: ## Build test baselines
|
|
|
|
@bash ./misc/make_baseline.sh
|
|
|
|
|
|
|
|
.PHONY: clean-baseline
|
|
|
|
clean-baseline: ## Remove test baselines
|
|
|
|
@bash ./misc/make_baseline.sh clean
|
|
|
|
|
|
|
|
## Code Checking
|
|
|
|
|
2018-01-17 21:27:59 +00:00
|
|
|
.PHONY: fullint
|
|
|
|
fullint: lint old-lint tslint flow mdlint ## Run all checks
|
|
|
|
|
2014-06-16 21:27:47 +00:00
|
|
|
.PHONY: lint
|
2017-06-12 20:12:23 +00:00
|
|
|
lint: $(TARGET) $(AUXTARGETS) ## Run eslint checks
|
2022-04-04 22:53:34 +00:00
|
|
|
@eslint --ext .js,.njs,.json,.html,.htm $(TARGET) $(AUXTARGETS) $(CMDS) $(HTMLLINT) package.json
|
2017-06-12 20:12:23 +00:00
|
|
|
if [ -e $(CLOSURE) ]; then java -jar $(CLOSURE) $(REQS) $(FLOWTARGET) --jscomp_warning=reportUnknownTypes >/dev/null; fi
|
|
|
|
|
|
|
|
.PHONY: old-lint
|
|
|
|
old-lint: $(TARGET) $(AUXTARGETS) ## Run jshint and jscs checks
|
2016-06-16 20:49:46 +00:00
|
|
|
@jshint --show-non-errors $(TARGET) $(AUXTARGETS)
|
2016-10-08 18:48:03 +00:00
|
|
|
@jshint --show-non-errors $(CMDS)
|
2016-06-16 20:49:46 +00:00
|
|
|
@jshint --show-non-errors package.json
|
|
|
|
@jshint --show-non-errors --extract=always $(HTMLLINT)
|
|
|
|
@jscs $(TARGET) $(AUXTARGETS)
|
2017-06-12 20:12:23 +00:00
|
|
|
if [ -e $(CLOSURE) ]; then java -jar $(CLOSURE) $(REQS) $(FLOWTARGET) --jscomp_warning=reportUnknownTypes >/dev/null; fi
|
|
|
|
|
2017-09-14 05:28:47 +00:00
|
|
|
.PHONY: tslint
|
|
|
|
tslint: $(TARGET) ## Run typescript checks
|
|
|
|
#@npm install dtslint typescript
|
2018-01-17 21:27:59 +00:00
|
|
|
#@npm run-script dtslint
|
|
|
|
dtslint types
|
2015-05-06 21:47:18 +00:00
|
|
|
|
|
|
|
.PHONY: flow
|
2016-06-16 20:49:46 +00:00
|
|
|
flow: lint ## Run flow checker
|
|
|
|
@flow check --all --show-all-errors
|
2014-06-16 21:27:47 +00:00
|
|
|
|
2016-06-16 20:49:46 +00:00
|
|
|
.PHONY: cov
|
|
|
|
cov: misc/coverage.html ## Run coverage test
|
2014-06-16 21:27:47 +00:00
|
|
|
|
|
|
|
misc/coverage.html: $(TARGET) test.js
|
2022-04-04 22:53:34 +00:00
|
|
|
./node_modules/.bin/mocha --require blanket -R html-cov -t 60000 > $@
|
2014-06-16 21:27:47 +00:00
|
|
|
|
2016-06-16 20:49:46 +00:00
|
|
|
.PHONY: coveralls
|
|
|
|
coveralls: ## Coverage Test + Send to coveralls.io
|
2022-04-04 22:53:34 +00:00
|
|
|
./node_modules/.bin/mocha --require blanket --reporter mocha-lcov-reporter -t 60000 | node ./node_modules/coveralls/bin/coveralls.js
|
2014-06-16 21:27:47 +00:00
|
|
|
|
2018-01-17 21:27:59 +00:00
|
|
|
MDLINT=README.md
|
|
|
|
.PHONY: mdlint
|
|
|
|
mdlint: $(MDLINT) ## Check markdown documents
|
|
|
|
alex $^
|
|
|
|
mdspell -a -n -x -r --en-us $^
|
|
|
|
|
2014-06-16 21:27:47 +00:00
|
|
|
.PHONY: perf
|
2016-06-16 20:49:46 +00:00
|
|
|
perf: ## Run Performance Tests
|
|
|
|
@bash perf/perf.sh
|
2014-06-17 23:20:41 +00:00
|
|
|
|
2016-01-13 03:30:35 +00:00
|
|
|
|
2016-06-16 20:49:46 +00:00
|
|
|
.PHONY: help
|
|
|
|
help:
|
|
|
|
@grep -hE '(^[a-zA-Z_-][ a-zA-Z_-]*:.*?|^#[#*])' $(MAKEFILE_LIST) | bash misc/help.sh
|
2016-01-13 03:30:35 +00:00
|
|
|
|
2016-06-16 20:49:46 +00:00
|
|
|
#* To show a spinner, append "-spin" to any target e.g. cov-spin
|
|
|
|
%-spin:
|
|
|
|
@make $* & bash misc/spin.sh $$!
|