Makefile 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. # You can set these variables from the command line.
  2. BABEL ?= node_modules/.bin/babel
  3. BOOTSTRAP = ./node_modules/
  4. BOURBON = ./node_modules/bourbon/app/assets/stylesheets/
  5. BUILDDIR = ./docs
  6. BUNDLE ?= ./.bundle/bin/bundle
  7. CHROMIUM ?= ./node_modules/.bin/run-headless-chromium
  8. CLEANCSS ?= ./node_modules/clean-css-cli/bin/cleancss --skip-rebase
  9. ESLINT ?= ./node_modules/.bin/eslint
  10. HTTPSERVE ?= ./node_modules/.bin/http-server
  11. HTTPSERVE_PORT ?= 8000
  12. INKSCAPE ?= inkscape
  13. JSDOC ?= ./node_modules/.bin/jsdoc
  14. OXIPNG ?= oxipng
  15. PAPER =
  16. PO2JSON ?= ./node_modules/.bin/po2json
  17. RJS ?= ./node_modules/.bin/r.js
  18. WEBPACK ?= ./node_modules/.bin/npx
  19. SASS ?= ./.bundle/bin/sass
  20. SED ?= sed
  21. SPHINXBUILD ?= ./bin/sphinx-build
  22. SPHINXOPTS =
  23. UGLIFYJS ?= node_modules/.bin/uglifyjs
  24. # In the case user wishes to use RVM
  25. USE_RVM ?= false
  26. RVM_RUBY_VERSION ?= 2.4.2
  27. ifeq ($(USE_RVM),true)
  28. RVM_USE = rvm use $(RVM_RUBY_VERSION)
  29. endif
  30. # Internal variables.
  31. ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) ./docs/source
  32. .PHONY: all
  33. all: dev dist
  34. .PHONY: help
  35. help:
  36. @echo "Please use \`make <target>' where <target> is one of the following:"
  37. @echo ""
  38. @echo " all A synonym for 'make dev'."
  39. @echo " build Create minified builds of converse.js and all its dependencies."
  40. @echo " clean Remove all NPM and Ruby packages."
  41. @echo " css Generate CSS from the Sass files."
  42. @echo " dev Set up the development environment. To force a fresh start, run 'make clean' first."
  43. @echo " html Make standalone HTML files of the documentation."
  44. @echo " po Generate gettext PO files for each i18n language."
  45. @echo " po2json Generate JSON files from the language PO files."
  46. @echo " pot Generate a gettext POT file to be used for translations."
  47. @echo " release Prepare a new release of converse.js. E.g. make release VERSION=0.9.5"
  48. @echo " serve Serve this directory via a webserver on port 8000."
  49. @echo " stamp-npm Install NPM dependencies"
  50. @echo " stamp-bundler Install Bundler (Ruby) dependencies"
  51. @echo " watch Tells Sass to watch the .scss files for changes and then automatically update the CSS files."
  52. @echo " logo Generate PNG logos of multiple sizes."
  53. ########################################################################
  54. ## Miscellaneous
  55. .PHONY: serve
  56. serve: dev
  57. $(HTTPSERVE) -p $(HTTPSERVE_PORT) -c-1
  58. .PHONY: serve_bg
  59. serve_bg: dev
  60. $(HTTPSERVE) -p $(HTTPSERVE_PORT) -c-1 -s &
  61. ########################################################################
  62. ## Translation machinery
  63. GETTEXT = xgettext --language="JavaScript" --keyword=__ --keyword=___ --from-code=UTF-8 --output=locale/converse.pot dist/converse-no-dependencies.js --package-name=Converse.js --copyright-holder="Jan-Carel Brand" --package-version=4.0.0 -c
  64. .PHONY: pot
  65. pot: dist/converse-no-dependencies-es2015.js
  66. $(GETTEXT) 2>&1 > /dev/null; exit $$?;
  67. .PHONY: po
  68. po:
  69. find ./locale -maxdepth 1 -mindepth 1 -type d -exec msgmerge {}/LC_MESSAGES/converse.po ./locale/converse.pot -U \;
  70. .PHONY: po2json
  71. po2json:
  72. find ./locale -maxdepth 1 -mindepth 1 -type d -exec $(PO2JSON) -f jed1.x -d converse {}/LC_MESSAGES/converse.po {}/LC_MESSAGES/converse.json \;
  73. ########################################################################
  74. ## Release management
  75. .PHONY: release
  76. release:
  77. $(SED) -ri s/Version:\ [0-9]\+\.[0-9]\+\.[0-9]\+/Version:\ $(VERSION)/ COPYRIGHT
  78. $(SED) -ri s/Version:\ [0-9]\+\.[0-9]\+\.[0-9]\+/Version:\ $(VERSION)/ src/start.frag
  79. $(SED) -ri s/Project-Id-Version:\ Converse\.js\ [0-9]\+\.[0-9]\+\.[0-9]\+/Project-Id-Version:\ Converse.js\ $(VERSION)/ locale/converse.pot
  80. $(SED) -ri s/\"version\":\ \"[0-9]\+\.[0-9]\+\.[0-9]\+\"/\"version\":\ \"$(VERSION)\"/ package.json
  81. $(SED) -ri s/--package-version=[0-9]\+\.[0-9]\+\.[0-9]\+/--package-version=$(VERSION)/ Makefile
  82. $(SED) -ri s/v[0-9]\+\.[0-9]\+\.[0-9]\+\.zip/v$(VERSION)\.zip/ index.html
  83. $(SED) -ri s/v[0-9]\+\.[0-9]\+\.[0-9]\+\.tar\.gz/v$(VERSION)\.tar\.gz/ index.html
  84. $(SED) -ri s/version\ =\ \'[0-9]\+\.[0-9]\+\.[0-9]\+\'/version\ =\ \'$(VERSION)\'/ docs/source/conf.py
  85. $(SED) -ri s/release\ =\ \'[0-9]\+\.[0-9]\+\.[0-9]\+\'/release\ =\ \'$(VERSION)\'/ docs/source/conf.py
  86. $(SED) -ri "s/(Unreleased)/`date +%Y-%m-%d`/" CHANGES.md
  87. $(SED) -ri "s/cdn.conversejs.org\/[0-9]+\.[0-9]+\.[0-9]+/cdn.conversejs.org\/$(VERSION)/" docs/source/quickstart.rst
  88. make pot
  89. make po
  90. make po2json
  91. make build
  92. ########################################################################
  93. ## Install dependencies
  94. stamp-npm: package.json package-lock.json
  95. npm install
  96. touch stamp-npm
  97. stamp-bundler: Gemfile
  98. mkdir -p .bundle
  99. $(RVM_USE)
  100. gem install --user bundler --bindir .bundle/bin
  101. $(BUNDLE) install --path .bundle --binstubs .bundle/bin
  102. touch stamp-bundler
  103. .PHONY: clean
  104. clean:
  105. rm -rf node_modules .bundle stamp-npm stamp-bundler
  106. rm dist/*.min.js
  107. rm css/website.min.css
  108. rm css/converse.min.css
  109. rm css/*.map
  110. .PHONY: dev
  111. dev: stamp-bundler stamp-npm
  112. ########################################################################
  113. ## Builds
  114. .PHONY: css
  115. css: dev sass/*.scss css/converse.css css/converse.min.css css/website.css css/website.min.css css/fonts.css
  116. css/converse.css:: dev sass
  117. $(SASS) -I $(BOURBON) -I $(BOOTSTRAP) sass/converse.scss css/converse.css
  118. css/fonts.css:: dev sass
  119. $(SASS) -I $(BOURBON) -I $(BOOTSTRAP) sass/font-awesome.scss $@
  120. css/website.css:: dev sass
  121. $(SASS) -I $(BOURBON) -I $(BOOTSTRAP) sass/_website.scss $@
  122. css/%.min.css:: css/%.css
  123. make dev
  124. $(CLEANCSS) $< > $@
  125. .PHONY: watch
  126. watch: dev
  127. $(SASS) --watch -I $(BOURBON) -I $(BOOTSTRAP) sass:css
  128. .PHONY: watchjs
  129. watchjs: dev
  130. ./node_modules/.bin/npx webpack --mode=development --watch
  131. .PHONY: logo
  132. logo: logo/conversejs-transparent16.png \
  133. logo/conversejs-transparent19.png \
  134. logo/conversejs-transparent48.png \
  135. logo/conversejs-transparent128.png \
  136. logo/conversejs-transparent512.png \
  137. logo/conversejs-filled16.png \
  138. logo/conversejs-filled19.png \
  139. logo/conversejs-filled48.png \
  140. logo/conversejs-filled128.png \
  141. logo/conversejs-filled512.png \
  142. logo/conversejs-transparent%.png:: logo/conversejs-transparent.svg
  143. $(INKSCAPE) -e $@ -w $* $<
  144. $(OXIPNG) $@
  145. logo/conversejs-filled%.png:: logo/conversejs-filled.svg
  146. $(INKSCAPE) -e $@ -w $* $<
  147. $(OXIPNG) $@
  148. BUILDS = dist/converse.js \
  149. dist/converse.min.js \
  150. dist/converse-headless.js \
  151. dist/converse-headless.min.js \
  152. dist/converse-no-dependencies.min.js \
  153. dist/converse-no-dependencies.js \
  154. dist/converse-no-dependencies-es2015.js
  155. dist/converse.js: src webpack.config.js stamp-npm
  156. ./node_modules/.bin/npx webpack --mode=development
  157. dist/converse.min.js: src webpack.config.js stamp-npm
  158. ./node_modules/.bin/npx webpack --mode=production
  159. dist/converse-headless.js: src webpack.config.js stamp-npm
  160. ./node_modules/.bin/npx webpack --mode=development --type=headless
  161. dist/converse-headless.min.js: src webpack.config.js stamp-npm
  162. ./node_modules/.bin/npx webpack --mode=production --type=headless
  163. dist/converse-no-dependencies.js: src webpack.config.js stamp-npm
  164. ./node_modules/.bin/npx webpack --mode=development --type=nodeps
  165. dist/converse-no-dependencies.min.js: src webpack.config.js stamp-npm
  166. ./node_modules/.bin/npx webpack --mode=production --type=nodeps
  167. dist/converse-no-dependencies-es2015.js: src webpack.config.js stamp-npm
  168. ./node_modules/.bin/npx webpack --mode=development --type=nodeps --lang=es2015
  169. .PHONY: dist
  170. dist:: build
  171. .PHONY: build
  172. build:: dev css $(BUILDS)
  173. ########################################################################
  174. ## Tests
  175. .PHONY: eslint
  176. eslint: stamp-npm
  177. $(ESLINT) src/
  178. $(ESLINT) spec/
  179. .PHONY: check
  180. check: eslint
  181. LOG_CR_VERBOSITY=INFO $(CHROMIUM) --no-sandbox http://localhost:$(HTTPSERVE_PORT)/tests/index.html
  182. ########################################################################
  183. ## Documentation
  184. .PHONY: html
  185. html:
  186. rm -rf $(BUILDDIR)/html
  187. $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
  188. make apidoc
  189. @echo
  190. @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
  191. ePHONY: apidoc
  192. apidoc:
  193. $(JSDOC) --readme docs/source/jsdoc_intro.md -c docs/source/conf.json -d docs/html/api src/*.js