-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
75 lines (60 loc) · 2.53 KB
/
Makefile
File metadata and controls
75 lines (60 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
SRC_DIR = src
BUILD_DIR = build
PREFIX = .
DIST_DIR = ${PREFIX}/dist
JS_FILES = license.txt\
${SRC_DIR}/scrollbar-size.js \
${SRC_DIR}/viewport.js
JS = ${DIST_DIR}/jquery.scrollbar-utils.js
JS_MIN = ${DIST_DIR}/jquery.scrollbar-utils.min.js
JS_PACK = ${DIST_DIR}/jquery.scrollbar-utils.pack.js
JS_ENGINE ?= `which node nodejs`
COMPILER = ${JS_ENGINE} ${BUILD_DIR}/uglify.js --unsafe
MINIFIER = java -Xmx96m -jar ${BUILD_DIR}/yuicompressor.jar
PACKER = java -jar ${BUILD_DIR}/rhino.jar ${BUILD_DIR}/packer.js
JSDOC = /c/devl/js/tools/jsdoc-toolkit-2.4.0
ANT_HOME = /c/devl/java/tools/apache-ant-1.7.0/bin/ant
JGROUSE_DOC = /c/devl/js/tools/jGrouseDoc-2.1
VERSION = `cat version.txt`
DATE = `git log --pretty=format:'%ad' -1`
all: clean js lint min pack doc
@@echo "done"
doc:
@@echo "Creating documentation using jsdoc-toolkit...."
# java -Djsdoc=${JSDOC} -jar ${JSDOC}/jsrun.jar ${JSDOC}/app/run.js -t=${JSDOC}/templates/jsdoc -r -a -d=./dist/docs ./src/
${ANT_HOME} -Dbasedir=. -DjGrouseHome=${JGROUSE_DOC} -DoutputDir=${DIST_DIR}/docs -DinputDir=${SRC_DIR} -f ${JGROUSE_DOC}/build.xml
build/create_dist:
@@mkdir -p ${DIST_DIR}
#join all files into one, add version and licence to the head of the file
js: build/create_dist
@@echo "Building" ${JS}
# join all files into one | replace @Date variable with date command eval | replace @VERSION variable with version number
@@cat ${JS_FILES} | sed 's/@DATE/'"${DATE}"'/' | sed s/@VERSION/${VERSION}/ > ${JS}
#run JSLint checks on the joined file (using node.js)
lint: js
@@if test ! -z ${JS_ENGINE}; then \
echo "Checking jQuery against JSLint..."; \
${JS_ENGINE} $(BUILD_DIR)/jslint-check.js ${JS} ; \
else \
echo "You must have NodeJS installed in order to test JS against JSLint."; \
fi
#run node.js with uglify script that compresses the js, remove all comments. add copyright notice to the head of the file (head -12)
min: js
@@if test ! -z ${JS_ENGINE}; then \
echo "Building" ${JS_MIN}; \
head -12 ${JS} > ${JS_MIN}; \
${COMPILER} ${JS} > ${JS_MIN}.tmp; \
sed '$ s#^\( \*/\)\(.\+\)#\1\n\2;#' ${JS_MIN}.tmp >> ${JS_MIN}; \
rm -rf $(JS_MIN).tmp; \
else \
echo "You must have NodeJS installed in order to minify JS."; \
fi
#run rhino server and pack minified js file into even smaller size. add copyright notice at the start (head -12)
pack: min
@@echo "Building" ${JS_PACK}
@@head -12 ${JS} > ${JS_PACK}
@@${PACKER} ${JS_MIN} ${JS_PACK}.tmp
@@cat ${JS_PACK}.tmp >> ${JS_PACK} && rm ${JS_PACK}.tmp
clean:
@@echo "Removing distribution directory:" ${DIST_DIR}
@@rm -rf ${DIST_DIR}