Makefile 7.2 KB
Newer Older
JC Brand's avatar
JC Brand committed
1
# You can set these variables from the command line.
2
BABEL			?= node_modules/.bin/babel
cmrd Senya's avatar
cmrd Senya committed
3
BOOTSTRAP		= ./node_modules/
4
BUILDDIR		= ./docs
5 6
CHROMIUM		?= ./node_modules/.bin/run-headless-chromium
CLEANCSS		?= ./node_modules/clean-css-cli/bin/cleancss --skip-rebase
7 8
ESLINT			?= ./node_modules/.bin/eslint
HTTPSERVE	 	?= ./node_modules/.bin/http-server
JC Brand's avatar
JC Brand committed
9
HTTPSERVE_PORT	?= 8000
10
INKSCAPE		?= inkscape
11 12
INSTALL			?= install
JSDOC			?=	./node_modules/.bin/jsdoc
cmrd Senya's avatar
cmrd Senya committed
13
LERNA			?= ./node_modules/.bin/lerna
14
OXIPNG			?= oxipng
15
PAPER		 	=
JC Brand's avatar
JC Brand committed
16
RJS				?= ./node_modules/.bin/r.js
17
NPX				?= ./node_modules/.bin/npx
18
SASS			?= ./node_modules/.bin/node-sass
JC Brand's avatar
JC Brand committed
19
SED				?= sed
JC Brand's avatar
JC Brand committed
20
SPHINXBUILD	 	?= ./bin/sphinx-build
21
SPHINXOPTS		=
JC Brand's avatar
JC Brand committed
22
UGLIFYJS		?= node_modules/.bin/uglifyjs
JC Brand's avatar
JC Brand committed
23
XGETTEXT		= xgettext
24

25

JC Brand's avatar
JC Brand committed
26
# Internal variables.
27
ALLSPHINXOPTS	= -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) ./docs/source
28
VERSION_FORMAT	= [0-9]+\.[0-9]+\.[0-9]+
JC Brand's avatar
JC Brand committed
29

30
.PHONY: all
31
all: stamp-npm dist
32

33
.PHONY: help
JC Brand's avatar
JC Brand committed
34
help:
35 36
	@echo "Please use \`make <target>' where <target> is one of the following:"
	@echo ""
37 38 39 40 41 42
	@echo " all         Set up dev environment and create all builds"
	@echo " build       Create minified builds of converse.js and all its dependencies."
	@echo " clean       Remove all NPM packages."
	@echo " check       Run all tests."
	@echo " dev         Set up the development environment and build unminified resources. To force a fresh start, run 'make clean' first."
	@echo " devserver   Set up the development environment and start the webpack dev server."
43
	@echo " doc         Make standalone HTML files of the documentation."
44 45 46 47 48 49 50 51
	@echo " po          Generate gettext PO files for each i18n language."
	@echo " pot         Generate a gettext POT file to be used for translations."
	@echo " release     Prepare a new release of converse.js. E.g. make release VERSION=0.9.5"
	@echo " serve       Serve this directory via a webserver on port 8000."
	@echo " serve_bg    Same as \"serve\", but do it in the background"
	@echo " stamp-npm   Install NPM dependencies"
	@echo " watch       Watch for changes on JS and scss files and automatically update the generated files."
	@echo " logo        Generate PNG logos of multiple sizes."
52

53 54 55 56

########################################################################
## Miscellaneous

57
.PHONY: serve
JC Brand's avatar
JC Brand committed
58
serve: stamp-npm
59
	$(HTTPSERVE) -p $(HTTPSERVE_PORT) -c-1
60 61

.PHONY: serve_bg
JC Brand's avatar
JC Brand committed
62
serve_bg: stamp-npm
63
	$(HTTPSERVE) -p $(HTTPSERVE_PORT) -c-1 -s &
64

65 66 67
########################################################################
## Translation machinery

JC Brand's avatar
JC Brand committed
68 69 70
dist/converse-no-dependencies.js: src webpack.common.js webpack.nodeps.js stamp-npm @converse/headless
	npm run nodeps

JC Brand's avatar
JC Brand committed
71
GETTEXT = $(XGETTEXT) --from-code=UTF-8 --language=JavaScript --keyword=__ --keyword=___ --force-po --output=locale/converse.pot --package-name=Converse.js --copyright-holder="Jan-Carel Brand" --package-version=6.0.0 dist/converse-no-dependencies.js -c
72

73
.PHONY: pot
JC Brand's avatar
JC Brand committed
74
pot: dist/converse-no-dependencies.js
75
	$(GETTEXT) 2>&1 > /dev/null; exit $$?;
JC Brand's avatar
JC Brand committed
76
	rm dist/converse-no-dependencies.js
JC Brand's avatar
JC Brand committed
77

78
.PHONY: po
79
po:
80 81
	find ./locale -maxdepth 1 -mindepth 1 -type d -exec msgmerge {}/LC_MESSAGES/converse.po ./locale/converse.pot -U \;

82 83 84
########################################################################
## Release management

85
.PHONY: release
JC Brand's avatar
JC Brand committed
86
release:
87 88 89 90 91 92 93 94 95
	$(SED) -i '/^_converse.VERSION_NAME =/s/=.*/= "v$(VERSION)";/' src/headless/converse-core.js
	$(SED) -i '/Version:/s/:.*/: $(VERSION)/' COPYRIGHT
	$(SED) -i '/Project-Id-Version:/s/:.*/: Converse.js $(VERSION)\n"/' locale/converse.pot
	$(SED) -i '/"version":/s/:.*/: "$(VERSION)",/' package.json
	$(SED) -i '/"version":/s/:.*/: "$(VERSION)",/' src/headless/package.json
	$(SED) -ri 's/--package-version=$(VERSION_FORMAT)/--package-version=$(VERSION)/' Makefile
	$(SED) -i -e "/version =/s/=.*/= '$(VERSION)'/" -e "/release =/s/=.*/= '$(VERSION)'/" docs/source/conf.py
	$(SED) -i "s/[Uu]nreleased/`date +%Y-%m-%d`/" CHANGES.md
	$(SED) -ri 's,cdn.conversejs.org/$(VERSION_FORMAT),cdn.conversejs.org/$(VERSION),' docs/source/quickstart.rst
96 97
	$(SED) -ri 's,cdn.conversejs.org/$(VERSION_FORMAT),cdn.conversejs.org/$(VERSION),' *.html
	$(SED) -ri 's,cdn.conversejs.org/$(VERSION_FORMAT),cdn.conversejs.org/$(VERSION),' demo/*.html
JC Brand's avatar
JC Brand committed
98 99
	make pot
	make po
JC Brand's avatar
JC Brand committed
100
	make build
JC Brand's avatar
JC Brand committed
101
	npm pack
JC Brand's avatar
JC Brand committed
102

103 104 105 106
.PHONY: postrelease
postrelease:
	$(SED) -i '/^_converse.VERSION_NAME =/s/=.*/= "v$(VERSION)dev";/' src/headless/converse-core.js

107 108 109
########################################################################
## Install dependencies

cmrd Senya's avatar
cmrd Senya committed
110 111 112
$(LERNA):
	npm install lerna

113 114 115
package-lock.json: package.json
	npm install

116
stamp-npm: $(LERNA) package.json package-lock.json src/headless/package.json
JC Brand's avatar
JC Brand committed
117
	npm run lerna
JC Brand's avatar
JC Brand committed
118
	touch stamp-npm
119

120
.PHONY: clean
121
clean:
122
	npm run clean
123
	rm -rf lib bin include parts
JC Brand's avatar
JC Brand committed
124

125
.PHONY: dev
126
dev: stamp-npm
127
	npm run dev
128

129 130 131 132
.PHONY: devserver
devserver: stamp-npm
	npm run serve

133 134 135
########################################################################
## Builds

136 137 138 139
dist/converse.js:: stamp-npm dev

dist/converse.css:: stamp-npm dev

JC Brand's avatar
JC Brand committed
140
dist/website.css:: stamp-npm sass
141
	$(SASS) --source-map true --include-path $(BOOTSTRAP) sass/website.scss $@
142

143
dist/website.min.css:: stamp-npm dist/website.css
JC Brand's avatar
JC Brand committed
144
	$(CLEANCSS) dist/website.css > $@
145

146
.PHONY: watch
JC Brand's avatar
JC Brand committed
147
watch: stamp-npm
148
	npm run watch
149

150 151
.PHONY: logo
logo: logo/conversejs-transparent16.png \
152 153 154 155 156 157 158 159 160
		logo/conversejs-transparent19.png \
		logo/conversejs-transparent48.png \
		logo/conversejs-transparent128.png \
		logo/conversejs-transparent512.png \
		logo/conversejs-filled16.png \
		logo/conversejs-filled19.png \
		logo/conversejs-filled48.png \
		logo/conversejs-filled128.png \
		logo/conversejs-filled512.png \
161 162 163 164 165 166 167 168 169

logo/conversejs-transparent%.png:: logo/conversejs-transparent.svg
	$(INKSCAPE) -e $@ -w $* $<
	$(OXIPNG) $@

logo/conversejs-filled%.png:: logo/conversejs-filled.svg
	$(INKSCAPE) -e $@ -w $* $<
	$(OXIPNG) $@

170 171 172
BUILDS = src/headless/dist/converse-headless.min.js

@converse/headless: src/headless
173

174
src/headless/dist/converse-headless.min.js: src webpack.common.js stamp-npm @converse/headless
175
	npm run headless
JC Brand's avatar
JC Brand committed
176

177

JC Brand's avatar
JC Brand committed
178 179
.PHONY: dist
dist:: build
180

181
.PHONY: build
182
build:: stamp-npm
183
	npm run dev && npm run build && make dist/website.css && make dist/website.min.css
184 185 186 187

.PHONY: cdn
cdn:: stamp-npm
	npm run cdn
JC Brand's avatar
JC Brand committed
188

189 190 191
########################################################################
## Tests

192
.PHONY: eslint
JC Brand's avatar
JC Brand committed
193
eslint: stamp-npm
194 195 196 197
	$(ESLINT) src/*.js
	$(ESLINT) src/utils/*.js
	$(ESLINT) src/headless/*.js
	$(ESLINT) src/headless/utils/*.js
198
	$(ESLINT) spec/
199

JC Brand's avatar
JC Brand committed
200
.PHONY: check
201
check: eslint dev
JC Brand's avatar
JC Brand committed
202
	LOG_CR_VERBOSITY=INFO $(CHROMIUM) --disable-gpu --no-sandbox http://localhost:$(HTTPSERVE_PORT)/tests/index.html
203 204 205 206

########################################################################
## Documentation

207
./bin/activate:
208
	python3.7 -m venv .
209 210 211

.installed.cfg: requirements.txt buildout.cfg
	./bin/pip install -r requirements.txt
212 213
	./bin/pip install --upgrade pip==19.2.1
	./bin/pip install --upgrade setuptools==41.0.1
214 215 216 217
	./bin/buildout -v

docsdev: ./bin/activate .installed.cfg

218
.PHONY: html
219 220 221 222
html: doc

.PHONY: doc
doc: stamp-npm docsdev apidoc
JC Brand's avatar
JC Brand committed
223
	rm -rf $(BUILDDIR)/html
JC Brand's avatar
JC Brand committed
224
	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
225
	make apidoc
JC Brand's avatar
JC Brand committed
226 227
	@echo
	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
JC Brand's avatar
JC Brand committed
228

229
PHONY: apidoc
JC Brand's avatar
JC Brand committed
230
apidoc:
231
	$(JSDOC) --private --readme docs/source/jsdoc_intro.md -c docs/source/conf.json -d docs/html/api src/*.js src/utils/*.js src/headless/*.js src/headless/utils/*.js