Makefile 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. # -*- coding: utf-8; mode: makefile-gmake -*-
  2. export GIT_URL=https://github.com/asciimoo/searx
  3. export SEARX_URL=https://searx.me
  4. export DOCS_URL=https://asciimoo.github.io/searx
  5. PYOBJECTS = searx
  6. DOC = docs
  7. PY_SETUP_EXTRAS ?= \[test\]
  8. PYDIST=./dist/py
  9. PYBUILD=./build/py
  10. include utils/makefile.include
  11. include utils/makefile.python
  12. include utils/makefile.sphinx
  13. all: clean install
  14. PHONY += help
  15. help:
  16. @echo ' test - run developer tests'
  17. @echo ' docs - build documentation'
  18. @echo ' docs-live - autobuild HTML documentation while editing'
  19. @echo ' run - run developer instance'
  20. @echo ' install - developer install (./local)'
  21. @echo ' uninstall - uninstall (./local)'
  22. @echo ' gh-pages - build docs & deploy on gh-pages branch'
  23. @echo ' clean - drop builds and environments'
  24. @echo ' project - re-build generic files of the searx project'
  25. @echo ' buildenv - re-build environment files (aka brand)'
  26. @echo ' themes - re-build build the source of the themes'
  27. @echo ' docker - build Docker image'
  28. @echo ' node.env - download & install npm dependencies locally'
  29. @echo ''
  30. @$(MAKE) -s -f utils/makefile.include make-help
  31. @echo ''
  32. @$(MAKE) -s -f utils/makefile.python python-help
  33. PHONY += install
  34. install: buildenv pyenvinstall
  35. PHONY += uninstall
  36. uninstall: pyenvuninstall
  37. PHONY += clean
  38. clean: pyclean node.clean test.clean
  39. $(call cmd,common_clean)
  40. PHONY += run
  41. run: buildenv pyenvinstall
  42. $(Q) ( \
  43. sed -i -e "s/debug : False/debug : True/g" ./searx/settings.yml ; \
  44. sleep 2 ; \
  45. xdg-open http://127.0.0.1:8888/ ; \
  46. sleep 3 ; \
  47. sed -i -e "s/debug : True/debug : False/g" ./searx/settings.yml ; \
  48. ) &
  49. $(PY_ENV)/bin/python ./searx/webapp.py
  50. # docs
  51. # ----
  52. PHONY += docs
  53. docs: buildenv pyenvinstall sphinx-doc
  54. $(call cmd,sphinx,html,docs,docs)
  55. PHONY += docs-live
  56. docs-live: buildenv pyenvinstall sphinx-live
  57. $(call cmd,sphinx_autobuild,html,docs,docs)
  58. $(GH_PAGES)::
  59. @echo "doc available at --> $(DOCS_URL)"
  60. # update project files
  61. # --------------------
  62. PHONY += project engines.languages useragents.update buildenv
  63. project: buildenv useragents.update engines.languages
  64. engines.languages: pyenvinstall
  65. $(Q)echo "fetch languages .."
  66. $(Q)$(PY_ENV_ACT); python utils/fetch_languages.py
  67. $(Q)echo "update searx/data/engines_languages.json"
  68. $(Q)mv engines_languages.json searx/data/engines_languages.json
  69. $(Q)echo "update searx/languages.py"
  70. $(Q)mv languages.py searx/languages.py
  71. useragents.update: pyenvinstall
  72. $(Q)echo "Update searx/data/useragents.json with the most recent versions of Firefox."
  73. $(Q)$(PY_ENV_ACT); python utils/fetch_firefox_version.py
  74. buildenv:
  75. $(Q)echo "build searx/brand.py"
  76. $(Q)echo "GIT_URL = '$(GIT_URL)'" > searx/brand.py
  77. $(Q)echo "ISSUE_URL = 'https://github.com/asciimoo/searx/issues'" >> searx/brand.py
  78. $(Q)echo "SEARX_URL = '$(SEARX_URL)'" >> searx/brand.py
  79. $(Q)echo "DOCS_URL = '$(DOCS_URL)'" >> searx/brand.py
  80. $(Q)echo "PUBLIC_INSTANCES = 'https://searx.space'" >> searx/brand.py
  81. $(Q)echo "build utils/brand.env"
  82. $(Q)echo "export GIT_URL='$(GIT_URL)'" > utils/brand.env
  83. $(Q)echo "export ISSUE_URL='https://github.com/asciimoo/searx/issues'" >> utils/brand.env
  84. $(Q)echo "export SEARX_URL='$(SEARX_URL)'" >> utils/brand.env
  85. $(Q)echo "export DOCS_URL='$(DOCS_URL)'" >> utils/brand.env
  86. $(Q)echo "export PUBLIC_INSTANCES='https://searx.space'" >> utils/brand.env
  87. # node / npm
  88. # ----------
  89. node.env: buildenv
  90. $(Q)./manage.sh npm_packages
  91. node.clean:
  92. $(Q)echo "CLEAN locally installed npm dependencies"
  93. $(Q)rm -rf \
  94. ./node_modules \
  95. ./package-lock.json \
  96. ./searx/static/themes/oscar/package-lock.json \
  97. ./searx/static/themes/oscar/node_modules \
  98. ./searx/static/themes/simple/package-lock.json \
  99. ./searx/static/themes/simple/node_modules
  100. # build themes
  101. # ------------
  102. PHONY += themes.bootstrap themes themes.oscar themes.simple themes.legacy themes.courgette themes.pixart
  103. themes: buildenv themes.bootstrap themes.oscar themes.simple themes.legacy themes.courgette themes.pixart
  104. quiet_cmd_lessc = LESSC $3
  105. cmd_lessc = PATH="$$(npm bin):$$PATH" \
  106. lessc --clean-css="--s1 --advanced --compatibility=ie9" "searx/static/$2" "searx/static/$3"
  107. quiet_cmd_grunt = GRUNT $2
  108. cmd_grunt = PATH="$$(npm bin):$$PATH" \
  109. grunt --gruntfile "$2"
  110. themes.oscar:
  111. $(Q)echo '[!] build oscar theme'
  112. $(call cmd,grunt,searx/static/themes/oscar/gruntfile.js)
  113. themes.simple:
  114. $(Q)echo '[!] build simple theme'
  115. $(call cmd,grunt,searx/static/themes/simple/gruntfile.js)
  116. themes.legacy:
  117. $(Q)echo '[!] build legacy theme'
  118. $(call cmd,lessc,themes/legacy/less/style-rtl.less,themes/legacy/css/style-rtl.css)
  119. $(call cmd,lessc,themes/legacy/less/style.less,themes/legacy/css/style.css)
  120. themes.courgette:
  121. $(Q)echo '[!] build courgette theme'
  122. $(call cmd,lessc,themes/courgette/less/style.less,themes/courgette/css/style.css)
  123. $(call cmd,lessc,themes/courgette/less/style-rtl.less,themes/courgette/css/style-rtl.css)
  124. themes.pixart:
  125. $(Q)echo '[!] build pixart theme'
  126. $(call cmd,lessc,themes/pix-art/less/style.less,themes/pix-art/css/style.css)
  127. themes.bootstrap:
  128. $(call cmd,lessc,less/bootstrap/bootstrap.less,css/bootstrap.min.css)
  129. # docker
  130. # ------
  131. PHONY += docker
  132. docker: buildenv
  133. $(Q)./manage.sh docker_build
  134. docker.push: buildenv
  135. $(Q)./manage.sh docker_build push
  136. # gecko
  137. # -----
  138. PHONY += gecko.driver
  139. gecko.driver:
  140. $(PY_ENV_ACT); ./manage.sh install_geckodriver
  141. # test
  142. # ----
  143. PHONY += test test.pylint test.pep8 test.unit test.coverage test.robot
  144. test: buildenv test.pylint test.pep8 test.unit gecko.driver test.robot
  145. # TODO: balance linting with pylint
  146. test.pylint: pyenvinstall
  147. $(call cmd,pylint,\
  148. searx/preferences.py \
  149. searx/testing.py \
  150. )
  151. # ignored rules:
  152. # E402 module level import not at top of file
  153. # W503 line break before binary operator
  154. test.pep8: pyenvinstall
  155. @echo "TEST pep8"
  156. $(Q)$(PY_ENV_ACT); pep8 --exclude=searx/static --max-line-length=120 --ignore "E402,W503" searx tests
  157. test.unit: pyenvinstall
  158. @echo "TEST tests/unit"
  159. $(Q)$(PY_ENV_ACT); python -m nose2 -s tests/unit
  160. test.coverage: pyenvinstall
  161. @echo "TEST unit test coverage"
  162. $(Q)$(PY_ENV_ACT); \
  163. python -m nose2 -C --log-capture --with-coverage --coverage searx -s tests/unit \
  164. && coverage report \
  165. && coverage html \
  166. test.robot: pyenvinstall gecko.driver
  167. @echo "TEST robot"
  168. $(Q)$(PY_ENV_ACT); PYTHONPATH=. python searx/testing.py robot
  169. test.clean:
  170. @echo "CLEAN intermediate test stuff"
  171. $(Q)rm -rf geckodriver.log .coverage coverage/
  172. .PHONY: $(PHONY)