js-adler32/Makefile

115 lines
3.2 KiB
Makefile
Raw Normal View History

2014-06-18 17:58:20 +00:00
LIB=adler32
REQS=
ADDONS=
AUXTARGETS=demo/browser.js
2016-10-13 01:23:45 +00:00
CMDS=bin/adler32.njs
HTMLLINT=index.html
ULIB=$(shell echo $(LIB) | tr a-z A-Z)
2014-06-18 17:58:20 +00:00
DEPS=$(sort $(wildcard bits/*.js))
TARGET=$(LIB).js
FLOWTARGET=$(LIB).flow.js
2017-06-12 19:15:04 +00:00
FLOWTGTS=$(TARGET) $(AUXTARGETS)
CLOSURE=/usr/local/lib/node_modules/google-closure-compiler/compiler.jar
## Main Targets
2014-06-18 17:58:20 +00:00
.PHONY: all
all: $(TARGET) $(AUXTARGETS) ## Build library and auxiliary scripts
2017-06-12 19:15:04 +00:00
$(FLOWTGTS): %.js : %.flow.js
node -e 'process.stdout.write(require("fs").readFileSync("$<","utf8").replace(/^[ \t]*\/\*[:#][^*]*\*\/\s*(\n)?/gm,"").replace(/\/\*[:#][^*]*\*\//gm,""))' > $@
$(FLOWTARGET): $(DEPS)
2014-06-18 17:58:20 +00:00
cat $^ | tr -d '\15\32' > $@
bits/01_version.js: package.json
2017-06-12 19:15:04 +00:00
echo "$(ULIB).version = '"`grep version package.json | awk '{gsub(/[^0-9a-z\.-]/,"",$$2); print $$2}'`"';" > $@
2014-06-18 17:58:20 +00:00
.PHONY: clean
clean: clean-baseline ## Remove targets and build artifacts
rm -f $(TARGET) $(FLOWTARGET)
## Testing
2014-06-18 17:58:20 +00:00
.PHONY: test mocha
test mocha: test.js $(TARGET) baseline ## Run test suite
2018-04-21 14:02:35 +00:00
mocha -R spec -t 60000
2014-06-18 17:58:20 +00:00
.PHONY: ctest
ctest: ## Build browser test (into ctest/ subdirectory)
2014-06-18 17:58:20 +00:00
cat misc/*.js > ctest/fixtures.js
cp -f test.js ctest/test.js
2016-10-13 01:23:45 +00:00
cp -f shim.js ctest/shim.js
cp -f $(TARGET) ctest/
2014-06-18 17:58:20 +00:00
.PHONY: ctestserv
ctestserv: ## Start a test server on port 8000
@cd ctest && python -mSimpleHTTPServer
.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 19:19:26 +00:00
.PHONY: fullint
fullint: lint old-lint tslint flow mdlint ## Run all checks
2014-06-18 17:58:20 +00:00
.PHONY: lint
2017-06-12 19:15:04 +00:00
lint: $(TARGET) $(AUXTARGETS) ## Run eslint checks
@eslint --ext .js,.njs,.json,.html,.htm $(TARGET) $(AUXTARGETS) $(CMDS) $(HTMLLINT) package.json bower.json
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
@jshint --show-non-errors $(TARGET) $(AUXTARGETS)
2016-10-13 01:23:45 +00:00
@jshint --show-non-errors $(CMDS)
@jshint --show-non-errors package.json
@jshint --show-non-errors --extract=always $(HTMLLINT)
@jscs $(TARGET) $(AUXTARGETS)
2017-06-12 19:15:04 +00:00
if [ -e $(CLOSURE) ]; then java -jar $(CLOSURE) $(REQS) $(FLOWTARGET) --jscomp_warning=reportUnknownTypes >/dev/null; fi
2018-01-17 19:19:26 +00:00
.PHONY: tslint
tslint: $(TARGET) ## Run typescript checks
#@npm install dtslint typescript
#@npm run-script dtslint
dtslint types
.PHONY: flow
flow: lint ## Run flow checker
@flow check --all --show-all-errors
2014-06-18 17:58:20 +00:00
.PHONY: cov
cov: misc/coverage.html ## Run coverage test
2014-06-18 17:58:20 +00:00
misc/coverage.html: $(TARGET) test.js
2016-10-13 01:23:45 +00:00
mocha --require blanket -R html-cov -t 30000 > $@
2014-06-18 17:58:20 +00:00
.PHONY: coveralls
coveralls: ## Coverage Test + Send to coveralls.io
mocha --require blanket --reporter mocha-lcov-reporter -t 20000 | node ./node_modules/coveralls/bin/coveralls.js
2014-06-18 17:58:20 +00:00
2018-01-17 19:19:26 +00:00
MDLINT=README.md
.PHONY: mdlint
mdlint: $(MDLINT) ## Check markdown documents
alex $^
mdspell -a -n -x -r --en-us $^
2014-06-18 17:58:20 +00:00
.PHONY: perf
perf: ## Run Performance Tests
@bash perf/perf.sh
.PHONY: help
help:
@grep -hE '(^[a-zA-Z_-][ a-zA-Z_-]*:.*?|^#[#*])' $(MAKEFILE_LIST) | bash misc/help.sh
#* To show a spinner, append "-spin" to any target e.g. cov-spin
%-spin:
@make $* & bash misc/spin.sh $$!