Makefile 8.33 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#############################################
# Copyright 2018, Nexedi SA
#
# This program is free software: you can Use, Study, Modify and Redistribute
# it under the terms of the GNU General Public License version 3, or (at your
# option) any later version, as published by the Free Software Foundation.
#
# You can also Link and Combine this program with other software covered by
# the terms of any of the Free Software licenses or any of the Open Source
# Initiative approved licenses and Convey the resulting work. Corresponding
# source of such a combination shall include the source code for all other
# software used.
#
# This program is distributed WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options.
#############################################
include config.mk
21

22 23 24 25 26 27
DISTDIR = dist
SRCDIR = src
LINTDIR = lint
TESTDIR = test
EXAMPLEDIR = examples
EXTERNALDIR = external
28

Romain Courteaud's avatar
Romain Courteaud committed
29
VERSION = 3.36.0
30 31
JIOVERSION = ${DISTDIR}/jio-v${VERSION}.js
JIOLATEST = ${DISTDIR}/jio-latest.js
32 33
JIONODEVERSION = ${DISTDIR}/jio-v${VERSION}-node.js
JIONODELATEST = ${DISTDIR}/jio-latest-node.js
34

35
all: fetch lint build
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 76 77 78 79 80 81
#############################################
# Lint
#############################################
LINTOPTS = --maxlen 80 --indent 2 --maxerr 3 --terse

${LINTDIR}/jio.storage/%.js: ${SRCDIR}/jio.storage/%.js
	@mkdir -p $(@D)
	${JSLINT} ${LINTOPTS} --predef jIO --predef window $<
	@cat $< > $@

${LINTDIR}/jio.js: ${SRCDIR}/jio.js
	@mkdir -p $(@D)
	${JSLINT} ${LINTOPTS} --nomen true $<
	@cat $< > $@

${LINTDIR}/jio.date/%.js: ${SRCDIR}/jio.date/%.js
	@mkdir -p $(@D)
	${JSLINT} ${LINTOPTS} $<
	@cat $< > $@

${LINTDIR}/queries/query.js: ${SRCDIR}/queries/query.js
	@mkdir -p $(@D)
	${JSLINT} ${LINTOPTS} $<
	@cat $< > $@

${LINTDIR}/${TESTDIR}/jio.storage/%.js: ${TESTDIR}/jio.storage/%.js
	@mkdir -p $(@D)
	${JSLINT} ${LINTOPTS} --predef QUnit --predef RSVP --predef jIO $<
	@cat $< > $@

${LINTDIR}/${TESTDIR}/queries/%.js: ${TESTDIR}/queries/%.js
	@mkdir -p $(@D)
	${JSLINT} ${LINTOPTS} --predef QUnit --predef RSVP --predef jIO $<
	@cat $< > $@

${LINTDIR}/${TESTDIR}/jio/%.js: ${TESTDIR}/jio/%.js
	@mkdir -p $(@D)
	${JSLINT} ${LINTOPTS} --predef QUnit --predef RSVP --predef jIO $<
	@cat $< > $@

${LINTDIR}/${EXAMPLEDIR}/%.js: ${EXAMPLEDIR}/%.js
	@mkdir -p $(@D)
	${JSLINT} ${LINTOPTS} --predef RSVP --predef window --predef QUnit --predef jIO --predef rJS $<
	@cat $< > $@

82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
${LINTDIR}/node/%.js: ${SRCDIR}/node/%.js
	@mkdir -p $(@D)
	${JSLINT} ${LINTOPTS} --nomen true $<
	@cat $< > $@

${LINTDIR}/${TESTDIR}/%.js: ${TESTDIR}/%.js
	@mkdir -p $(@D)
	${JSLINT} ${LINTOPTS} $<
	@cat $< > $@

${LINTDIR}/${TESTDIR}/node/%.js: ${TESTDIR}/node/%.js
	@mkdir -p $(@D)
	${JSLINT} ${LINTOPTS} $<
	@cat $< > $@

97 98 99 100 101 102 103 104 105 106 107
#############################################
# Check test files
#############################################
lint: $(patsubst ${TESTDIR}/jio.storage/%.js, ${LINTDIR}/${TESTDIR}/jio.storage/%.js, $(wildcard ${TESTDIR}/jio.storage/*.js)) \
	$(patsubst ${TESTDIR}/queries/%.js, ${LINTDIR}/${TESTDIR}/queries/%.js, $(wildcard ${TESTDIR}/queries/*.js)) \
	$(patsubst ${TESTDIR}/jio/%.js, ${LINTDIR}/${TESTDIR}/jio/%.js, $(wildcard ${TESTDIR}/jio/*.js)) \
	$(patsubst ${EXAMPLEDIR}/%.js, ${LINTDIR}/${EXAMPLEDIR}/%.js, $(wildcard ${EXAMPLEDIR}/*.js)) \
	$(patsubst ${EXAMPLEDIR}/%.js, ${LINTDIR}/${EXAMPLEDIR}/%.js, $(wildcard ${EXAMPLEDIR}/*.js)) \
	${LINTDIR}/queries/query.js \
	${LINTDIR}/jio.date/jiodate.js \
	${LINTDIR}/jio.js \
108 109 110
	${LINTDIR}/node/jio.js \
	${LINTDIR}/${TESTDIR}/node.js \
	${LINTDIR}/${TESTDIR}/node/node-require.js \
111 112 113 114 115
	$(patsubst ${SRCDIR}/jio.storage/%.js, ${LINTDIR}/jio.storage/%.js, $(wildcard ${SRCDIR}/jio.storage/*.js))

#############################################
# Build
#############################################
116
build: ${JIOLATEST} ${JIONODELATEST}
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143

${JIOLATEST}: ${JIOVERSION}
	@mkdir -p $(@D)
	cp $< $@

${JIOVERSION}: ${EXTERNALDIR}/URI.js \
	${EXTERNALDIR}/uritemplate.js \
	${EXTERNALDIR}/lz-string.js \
	${EXTERNALDIR}/moment.js \
	${SRCDIR}/queries/parser-begin.js \
	${SRCDIR}/queries/build/parser.js \
	${SRCDIR}/queries/parser-end.js \
	${SRCDIR}/queries/query.js \
	${SRCDIR}/jio.date/jiodate.js \
	${SRCDIR}/jio.js \
	${EXTERNALDIR}/rusha.js \
	${SRCDIR}/jio.storage/replicatestorage.js \
	${SRCDIR}/jio.storage/shastorage.js \
	${SRCDIR}/jio.storage/uuidstorage.js \
	${SRCDIR}/jio.storage/memorystorage.js \
	${SRCDIR}/jio.storage/zipstorage.js \
	${SRCDIR}/jio.storage/parserstorage.js \
	${SRCDIR}/jio.storage/httpstorage.js \
	${SRCDIR}/jio.storage/dropboxstorage.js \
	${SRCDIR}/jio.storage/davstorage.js \
	${SRCDIR}/jio.storage/gdrivestorage.js \
	${SRCDIR}/jio.storage/unionstorage.js \
144
	${SRCDIR}/jio.storage/linsharestorage.js \
145 146 147 148 149 150 151 152 153
	${SRCDIR}/jio.storage/erp5storage.js \
	${SRCDIR}/jio.storage/querystorage.js \
	${SRCDIR}/jio.storage/drivetojiomapping.js \
	${SRCDIR}/jio.storage/documentstorage.js \
	${SRCDIR}/jio.storage/localstorage.js \
	${SRCDIR}/jio.storage/indexeddbstorage.js \
	${SRCDIR}/jio.storage/cryptstorage.js \
	${SRCDIR}/jio.storage/websqlstorage.js \
	${SRCDIR}/jio.storage/fbstorage.js \
preetwinder's avatar
preetwinder committed
154
	${SRCDIR}/jio.storage/cloudooostorage.js \
preetwinder's avatar
preetwinder committed
155
	${SRCDIR}/jio.storage/nocapacitystorage.js \
156 157
	${SRCDIR}/jio.storage/liststorage.js \
	${SRCDIR}/jio.storage/indexstorage2.js
158 159 160
	@mkdir -p $(@D)
	cat $^ > $@

161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
#############################################
# Node
#############################################
${JIONODELATEST}: ${JIONODEVERSION}
	@mkdir -p $(@D)
	cp $< $@

${JIONODEVERSION}: ${SRCDIR}/node/jio-start.js \
	${EXTERNALDIR}/rsvp-2.0.4.js \
	${EXTERNALDIR}/moment.js \
	${EXTERNALDIR}/URI.js \
	${EXTERNALDIR}/uritemplate.js \
	${EXTERNALDIR}/rusha.js \
	${SRCDIR}/node/jio-external.js \
	${EXTERNALDIR}/xhr2.js \
	${SRCDIR}/queries/parser-begin.js \
	${SRCDIR}/queries/build/parser.js \
	${SRCDIR}/queries/parser-end.js \
	${SRCDIR}/queries/query.js \
	${SRCDIR}/node/jio-compat.js \
	${SRCDIR}/jio.date/jiodate.js \
	${SRCDIR}/jio.js \
	${SRCDIR}/node/jio.js \
	${SRCDIR}/jio.storage/replicatestorage.js \
	${SRCDIR}/jio.storage/shastorage.js \
	${SRCDIR}/jio.storage/uuidstorage.js \
	${SRCDIR}/jio.storage/memorystorage.js \
	${SRCDIR}/jio.storage/dropboxstorage.js \
	${SRCDIR}/jio.storage/gdrivestorage.js \
	${SRCDIR}/jio.storage/unionstorage.js \
	${SRCDIR}/jio.storage/erp5storage.js \
	${SRCDIR}/jio.storage/querystorage.js \
	${SRCDIR}/jio.storage/drivetojiomapping.js \
	${SRCDIR}/jio.storage/documentstorage.js \
	${SRCDIR}/jio.storage/fbstorage.js \
	${SRCDIR}/node/jio-end.js
	@mkdir -p $(@D)
	cat $^ > $@

200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
#############################################
# Jison
#############################################
${SRCDIR}/queries/build/parser.js: ${SRCDIR}/queries/core/parser.par
	@mkdir -p $(@D)
	${JISON} -m js -o $@ $<

#############################################
# Dependencies
#############################################
fetch: ${EXTERNALDIR}/uritemplate.js \
	${EXTERNALDIR}/lz-string.js \
	${EXTERNALDIR}/moment.js \
	${EXTERNALDIR}/rusha.js \
	${EXTERNALDIR}/rsvp-2.0.4.js \
	${EXTERNALDIR}/qunit.css \
	${EXTERNALDIR}/qunit.js \
	${EXTERNALDIR}/sinon.js \
	${EXTERNALDIR}/renderjs-latest.js

${EXTERNALDIR}/uritemplate.js:
	@mkdir -p $(@D)
	curl -s -o $@ https://lab.nexedi.com/nexedi/uritemplate-js/raw/master/bin/uritemplate.js

${EXTERNALDIR}/lz-string.js:
	@mkdir -p $(@D)
	curl -s -o $@ https://raw.githubusercontent.com/pieroxy/lz-string/1.4.4/libs/lz-string.js

${EXTERNALDIR}/moment.js:
	@mkdir -p $(@D)
	curl -s -o $@ https://raw.githubusercontent.com/moment/moment/2.22.1/moment.js

${EXTERNALDIR}/rusha.js:
	@mkdir -p $(@D)
	curl -s -o $@ https://raw.githubusercontent.com/srijs/rusha/v0.8.2/rusha.js

${EXTERNALDIR}/rsvp-2.0.4.js:
	@mkdir -p $(@D)
	curl -s -o $@ https://lab.nexedi.com/nexedi/rsvp.js/raw/master/dist/rsvp-2.0.4.js

${EXTERNALDIR}/qunit.css:
	@mkdir -p $(@D)
	curl -s -o $@ https://code.jquery.com/qunit/qunit-1.12.0.css

${EXTERNALDIR}/qunit.js:
	@mkdir -p $(@D)
	curl -s -o $@ https://code.jquery.com/qunit/qunit-1.12.0.js

${EXTERNALDIR}/sinon.js:
	@mkdir -p $(@D)
	curl -s -o $@ https://sinonjs.org/releases/sinon-1.7.3.js

${EXTERNALDIR}/renderjs-latest.js:
	@mkdir -p $(@D)
	curl -s -o $@ https://lab.nexedi.com/nexedi/renderjs/raw/master/dist/renderjs-latest.js
255

256
.PHONY: clean ${JIOVERSION} ${JIONODEVERSION}
257

258
clean:
259
	rm -rf ${LINTDIR}
260

261 262
forceclean: clean
	rm -rf ${EXTERNALDIR} ${SRCDIR}/queries/build/parser.js