X-Git-Url: https://git.yukkurigames.com/?p=string-lerp.git;a=blobdiff_plain;f=Makefile;h=6bddcb2a6800bc65d34cdbe72e75ee2c85a6184f;hp=862091d8deaa887165aba65076d70b425467c28f;hb=HEAD;hpb=0e8c216ff3039c994a86f423cf66b60f162d0298 diff --git a/Makefile b/Makefile index 862091d..6bddcb2 100644 --- a/Makefile +++ b/Makefile @@ -1,63 +1,55 @@ #!/usr/bin/make -f -JSTEST ?= node_modules/.bin/jstest -JSHINT ?= node_modules/.bin/jshint -UGLIFY ?= node_modules/.bin/uglifyjs -SOURCES = string-lerp.js -UGLIFIED = $(SOURCES:.js=.min.js) +PKGNAME := string-lerp +all: + $(info Interesting targets:) + $(info lint - validate source (with jshint)) + $(info test - run tests (with jstest)) + $(info ugly - generate minified source files) + $(info dist - generate redistributables (if git tagged)) + $(info ) + $(info (Running these may download packages from npm.)) + $(info ) + @: -TESTS = $(wildcard tests/*.js); -LINT_TARGETS = $(addprefix build/stamp/,$(addsuffix .lint,$(SOURCES))) -TEST_TARGETS = $(addprefix build/stamp/,$(addsuffix .test,$(SOURCES))) +include javascript.mk -.PHONY: all check lint test min clean distclean +GIT ?= git +git-describe = $(shell $(GIT) describe --tags --always $1) -all: - @echo "Interesting targets:" - @echo " lint - validate source (with jshint)" - @echo " test - run tests (with jstest)" - @echo " ugly - generate minified/mangled source files" - @echo - @echo "(Running these will download packages from NPM.)" - @echo +SOURCES := string-lerp.js +UGLIFIED := $(call uglify-stampify,$(SOURCES)) -%.min.js: %.js $(UGLIFY) - $(UGLIFY) --comments -m < $< > $@ +JSHINTCONFIG := tests/jshint.config +JSSTAMPDIR := build/stamp -build: - mkdir -p build/stamp build/dist +TESTS := $(wildcard tests/*.js) +LINTS := $(call jshint-stampify,$(SOURCES) $(TESTS)) +TEST_TARGETS = $(patsubst %.js,build/stamp/tests/%.js.test,$(SOURCES)) -build/stamp/%.lint: % build - @mkdir -p $(@D) - $(JSHINT) $< - @touch $@ +.DELETE_ON_ERROR: +.PHONY: all check lint test ugly dist clean distclean install .FORCE -build/stamp/%.test: tests/% % build - @mkdir -p $(@D) - @echo $(JSTEST) $< - @$(JSTEST) $< > $@ || (cat $@ && rm -f $@ && exit 1) - @touch $@ +check: lint test -ugly: $(UGLIFIED) +lint: $(LINTS) -check: lint test +test: $(TEST_TARGETS) + +ugly: check $(UGLIFIED) -lint: $(JSHINT) $(LINT_TARGETS) +$(PKGNAME)-%.zip $(PKGNAME)-%.tar.gz: .FORCE + @mkdir -p $(@D) + $(GIT) archive --prefix=$(PKGNAME)-$(*F)/ --output=$@ $(*F) -test: $(JSTEST) $(TEST_TARGETS) +dist: check $(addprefix build/dist/$(PKGNAME)-$(call git-describe),.zip .tar.gz) clean: - rm -rf build - rm -f $(UGLIFIED) + $(RM) -r build + $(RM) $(UGLIFIED) distclean: clean - rm -rf node_modules - -$(JSTEST): - npm install jstest - -$(JSHINT): - npm install jshint + $(RM) -r node_modules -$(UGLIFY): - npm install uglify-js +install: check + $(NPM) install -g .