Makefile 2.11 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# dir
JIO_DIR		= src/jio
STORAGE_DIR 	= src/jio.storage
QUERIES_DIR 	= src/queries
JSCC_DIR   	= ~/modules/jscc

# files
JIO		= jio.js
JIO_MIN		= jio.min.js
COMPLEX		= complex_queries.js
COMPLEX_MIN	= complex_queries.min.js
PARSER_PAR  	= $(QUERIES_DIR)/parser.par
PARSER_OUT   	= $(QUERIES_DIR)/parser.js

# using rhino
JSCC_CMD   	= rhino $(JSCC_DIR)/jscc.js -t $(JSCC_DIR)/driver_web.js_ 
17 18 19 20
# npm install jslint
LINT_CMD	= $(shell which jslint || echo node ~/node_modules/jslint/bin/jslint.js) --terse
# npm install uglify-js
UGLIFY_CMD	= $(shell which uglifyjs || echo node ~/node_modules/uglify-js/bin/uglifyjs)
21 22 23

auto: compile build lint
build: concat uglify
24 25

# The order is important!
26 27 28
CONCAT_JIO_NAMES = intro exceptions jio.intro storages/* commands/* jobs/status/* jobs/job announcements/announcement activityUpdater announcements/announcer jobs/jobIdHandler jobs/jobManager jobs/jobRules jio.core jio.outro jioNamespace outro
CONCAT_STORAGE_NAMES = *
CONCAT_QUERIES_NAMES = begin parser-begin parser parser-end serializer query end
29 30
LINT_NAMES  = exceptions storages/* commands/* jobs/status/* jobs/* announcements/* activityUpdater jio.core jioNamespace

31 32 33
CONCAT_QUERIES_FILES = $(CONCAT_QUERIES_NAMES:%=$(QUERIES_DIR)/%.js)
CONCAT_JIO_FILES = $(CONCAT_JIO_NAMES:%=$(JIO_DIR)/%.js)
LINT_FILES  = $(LINT_NAMES:%=$(JIO_DIR)/%.js) $(CONCAT_STORAGE_NAMES:%=$(STORAGE_DIR)/%.js)
34

35 36 37
# build parser.js
compile: 
	$(JSCC_CMD) -o $(PARSER_OUT) $(PARSER_PAR)
38

39
# concat source files into jio.js and complex-queries.js
40
concat:
41 42
	cat $(CONCAT_JIO_FILES) > "$(JIO)"
	cat $(CONCAT_QUERIES_FILES) > "$(COMPLEX)"
43

44
# uglify into jio.min.js and complex.min.js
45
uglify:
46 47
	$(UGLIFY_CMD) "$(JIO)" > "$(JIO_MIN)"
	$(UGLIFY_CMD) "$(COMPLEX)" > "$(COMPLEX_MIN)"
48

49
# lint all files in JIO and STORAGE and QUERIES DIR
50
# command: jslint [options] file
Tristan Cavelier's avatar
Tristan Cavelier committed
51 52 53 54
# [options] are defined at the top of the source file:
# Example:
# /*jslint indent: 2, maxlen: 80 */
# /*global hex_sha256: true, jQuery: true */
55
lint:
56
	$(LINT_CMD) $(LINT_FILES)
57 58 59 60 61 62

.phony: clean
clean:
	find -name '*~' -delete

realclean:
63 64 65 66 67
	rm -f "$(JIO)"
	rm -f "$(JIO_MIN)"
	rm -f "$(COMPLEX)"
	rm -f "$(COMPLEX_MIN)"
	rm -f "$(PARSER_OUT)"