2016-12-31 08:20:45 +00:00
|
|
|
SHELL=/bin/bash
|
2014-02-17 08:44:22 +00:00
|
|
|
LIB=xlsx
|
2015-04-02 20:32:22 +00:00
|
|
|
FMT=xlsx xlsm xlsb ods xls xml misc full
|
2014-04-23 01:37:08 +00:00
|
|
|
REQS=jszip.js
|
|
|
|
ADDONS=dist/cpexcel.js
|
2014-10-10 02:22:38 +00:00
|
|
|
AUXTARGETS=ods.js
|
2016-12-31 08:20:45 +00:00
|
|
|
CMDS=bin/xlsx.njs
|
|
|
|
HTMLLINT=index.html
|
2014-10-10 02:22:38 +00:00
|
|
|
|
|
|
|
ULIB=$(shell echo $(LIB) | tr a-z A-Z)
|
|
|
|
DEPS=$(sort $(wildcard bits/*.js))
|
|
|
|
TARGET=$(LIB).js
|
2016-12-31 08:20:45 +00:00
|
|
|
FLOWTARGET=$(LIB).flow.js
|
2017-02-03 20:50:45 +00:00
|
|
|
FLOWAUX=$(patsubst %.js,%.flow.js,$(AUXTARGETS))
|
|
|
|
AUXSCPTS=xlsxworker1.js xlsxworker2.js xlsxworker.js
|
|
|
|
FLOWTGTS=$(TARGET) $(AUXTARGETS) $(AUXSCPTS)
|
2017-02-10 19:23:01 +00:00
|
|
|
UGLIFYOPTS=--support-ie8
|
2016-12-31 08:20:45 +00:00
|
|
|
|
|
|
|
## Main Targets
|
2014-10-10 02:22:38 +00:00
|
|
|
|
|
|
|
.PHONY: all
|
2017-02-03 20:50:45 +00:00
|
|
|
all: $(TARGET) $(AUXTARGETS) $(AUXSCPTS) ## Build library and auxiliary scripts
|
2014-01-22 04:58:26 +00:00
|
|
|
|
2017-02-03 20:50:45 +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-05-29 22:30:03 +00:00
|
|
|
cat $^ | tr -d '\15\32' > $@
|
2013-03-31 22:56:45 +00:00
|
|
|
|
2014-04-15 09:04:03 +00:00
|
|
|
bits/01_version.js: package.json
|
2014-10-10 02:22:38 +00:00
|
|
|
echo "$(ULIB).version = '"`grep version package.json | awk '{gsub(/[^0-9a-z\.-]/,"",$$2); print $$2}'`"';" > $@
|
2014-01-22 04:58:26 +00:00
|
|
|
|
2017-02-24 10:33:01 +00:00
|
|
|
bits/18_cfb.js: node_modules/cfb/xlscfb.flow.js
|
2015-04-02 20:32:22 +00:00
|
|
|
cp $^ $@
|
|
|
|
|
2013-03-31 22:56:45 +00:00
|
|
|
.PHONY: clean
|
2016-12-31 08:20:45 +00:00
|
|
|
clean: ## Remove targets and build artifacts
|
2017-02-10 19:23:01 +00:00
|
|
|
rm -f $(TARGET) $(FLOWTARGET)
|
2014-06-05 07:06:20 +00:00
|
|
|
|
|
|
|
.PHONY: clean-data
|
|
|
|
clean-data:
|
|
|
|
rm -f *.xlsx *.xlsm *.xlsb *.xls *.xml
|
2013-10-30 19:26:07 +00:00
|
|
|
|
|
|
|
.PHONY: init
|
2016-12-31 08:20:45 +00:00
|
|
|
init: ## Initial setup for development
|
2013-10-30 19:26:07 +00:00
|
|
|
git submodule init
|
|
|
|
git submodule update
|
2014-01-15 13:58:55 +00:00
|
|
|
git submodule foreach git pull origin master
|
|
|
|
git submodule foreach make
|
2016-12-31 08:20:45 +00:00
|
|
|
mkdir -p tmp
|
|
|
|
|
|
|
|
.PHONY: dist
|
|
|
|
dist: dist-deps $(TARGET) bower.json ## Prepare JS files for distribution
|
|
|
|
cp $(TARGET) dist/
|
|
|
|
cp LICENSE dist/
|
2017-02-10 19:23:01 +00:00
|
|
|
uglifyjs $(UGLIFYOPTS) $(TARGET) -o dist/$(LIB).min.js --source-map dist/$(LIB).min.map --preamble "$$(head -n 1 bits/00_header.js)"
|
2016-12-31 08:20:45 +00:00
|
|
|
misc/strip_sourcemap.sh dist/$(LIB).min.js
|
2017-02-10 19:23:01 +00:00
|
|
|
uglifyjs $(UGLIFYOPTS) $(REQS) $(TARGET) -o dist/$(LIB).core.min.js --source-map dist/$(LIB).core.min.map --preamble "$$(head -n 1 bits/00_header.js)"
|
2016-12-31 08:20:45 +00:00
|
|
|
misc/strip_sourcemap.sh dist/$(LIB).core.min.js
|
2017-02-10 19:23:01 +00:00
|
|
|
uglifyjs $(UGLIFYOPTS) $(REQS) $(ADDONS) $(TARGET) -o dist/$(LIB).full.min.js --source-map dist/$(LIB).full.min.map --preamble "$$(head -n 1 bits/00_header.js)"
|
2016-12-31 08:20:45 +00:00
|
|
|
misc/strip_sourcemap.sh dist/$(LIB).full.min.js
|
|
|
|
|
|
|
|
.PHONY: dist-deps
|
|
|
|
dist-deps: ods.js ## Copy dependencies for distribution
|
|
|
|
cp node_modules/codepage/dist/cpexcel.full.js dist/cpexcel.js
|
|
|
|
cp jszip.js dist/jszip.js
|
|
|
|
cp ods.js dist/ods.js
|
2017-02-10 19:23:01 +00:00
|
|
|
uglifyjs $(UGLIFYOPTS) ods.js -o dist/ods.min.js --source-map dist/ods.min.map --preamble "$$(head -n 1 bits/00_header.js)"
|
2017-02-03 20:50:45 +00:00
|
|
|
misc/strip_sourcemap.sh dist/ods.min.js
|
2016-12-31 08:20:45 +00:00
|
|
|
|
|
|
|
.PHONY: aux
|
|
|
|
aux: $(AUXTARGETS)
|
|
|
|
|
|
|
|
.PHONY: ods
|
|
|
|
ods: ods.js
|
|
|
|
|
|
|
|
ODSDEPS=$(sort $(wildcard odsbits/*.js))
|
2017-02-03 20:50:45 +00:00
|
|
|
ods.flow.js: $(ODSDEPS) ## Build ODS support library
|
2017-02-24 10:33:01 +00:00
|
|
|
cat $^ | tr -d '\15\32' > $@
|
2013-10-30 19:26:07 +00:00
|
|
|
|
|
|
|
|
2016-12-31 08:20:45 +00:00
|
|
|
## Testing
|
|
|
|
|
2013-10-30 19:26:07 +00:00
|
|
|
.PHONY: test mocha
|
2016-12-31 08:20:45 +00:00
|
|
|
test mocha: test.js ## Run test suite
|
2014-07-28 15:57:28 +00:00
|
|
|
mocha -R spec -t 20000
|
2013-10-30 19:26:07 +00:00
|
|
|
|
2016-12-31 08:20:45 +00:00
|
|
|
#* To run tests for one format, make test_<fmt>
|
2014-02-13 06:22:42 +00:00
|
|
|
TESTFMT=$(patsubst %,test_%,$(FMT))
|
|
|
|
.PHONY: $(TESTFMT)
|
|
|
|
$(TESTFMT): test_%:
|
|
|
|
FMTS=$* make test
|
|
|
|
|
2013-05-18 00:12:10 +00:00
|
|
|
|
2016-12-31 08:20:45 +00:00
|
|
|
## Code Checking
|
|
|
|
|
2013-10-30 19:26:07 +00:00
|
|
|
.PHONY: lint
|
2017-02-03 20:50:45 +00:00
|
|
|
lint: $(TARGET) $(AUXTARGETS) ## Run jshint and jscs checks
|
2016-12-31 08:20:45 +00:00
|
|
|
@jshint --show-non-errors $(TARGET) $(AUXTARGETS)
|
|
|
|
@jshint --show-non-errors $(CMDS)
|
|
|
|
@jshint --show-non-errors package.json bower.json
|
|
|
|
@jshint --show-non-errors --extract=always $(HTMLLINT)
|
|
|
|
@jscs $(TARGET) $(AUXTARGETS)
|
2014-06-05 07:06:20 +00:00
|
|
|
|
2016-12-31 08:20:45 +00:00
|
|
|
.PHONY: flow
|
|
|
|
flow: lint ## Run flow checker
|
|
|
|
@flow check --all --show-all-errors
|
2014-01-22 04:58:26 +00:00
|
|
|
|
2017-02-10 19:23:01 +00:00
|
|
|
.PHONY: cov
|
2016-12-31 08:20:45 +00:00
|
|
|
cov: misc/coverage.html ## Run coverage test
|
2014-01-22 04:58:26 +00:00
|
|
|
|
2016-12-31 08:20:45 +00:00
|
|
|
#* To run coverage tests for one format, make cov_<fmt>
|
2014-05-16 00:33:34 +00:00
|
|
|
COVFMT=$(patsubst %,cov_%,$(FMT))
|
|
|
|
.PHONY: $(COVFMT)
|
|
|
|
$(COVFMT): cov_%:
|
|
|
|
FMTS=$* make cov
|
|
|
|
|
2014-02-17 08:44:22 +00:00
|
|
|
misc/coverage.html: $(TARGET) test.js
|
2016-12-31 08:20:45 +00:00
|
|
|
mocha --require blanket -R html-cov -t 20000 > $@
|
2014-01-22 04:58:26 +00:00
|
|
|
|
2017-02-10 19:23:01 +00:00
|
|
|
.PHONY: coveralls
|
2016-12-31 08:20:45 +00:00
|
|
|
coveralls: ## Coverage Test + Send to coveralls.io
|
|
|
|
mocha --require blanket --reporter mocha-lcov-reporter -t 20000 | node ./node_modules/coveralls/bin/coveralls.js
|
2014-04-23 01:37:08 +00:00
|
|
|
|
2014-10-10 02:22:38 +00:00
|
|
|
|
2016-12-31 08:20:45 +00:00
|
|
|
.PHONY: help
|
|
|
|
help:
|
|
|
|
@grep -hE '(^[a-zA-Z_-][ a-zA-Z_-]*:.*?|^#[#*])' $(MAKEFILE_LIST) | bash misc/help.sh
|
2014-10-10 02:22:38 +00:00
|
|
|
|
2016-12-31 08:20:45 +00:00
|
|
|
#* To show a spinner, append "-spin" to any target e.g. cov-spin
|
|
|
|
%-spin:
|
|
|
|
@make $* & bash misc/spin.sh $$!
|