on 87fba9c help sign in
searx/Makefile
235 lines 6.7 kB history raw
1# -*- coding: utf-8; mode: makefile-gmake -*-
3export GIT_URL=https://github.com/asciimoo/searx
4export SEARX_URL=https://searx.me
5export DOCS_URL=https://asciimoo.github.io/searx
7PYOBJECTS = searx
8DOC = docs
9PY_SETUP_EXTRAS ?= \[test\]
11PYDIST=./dist/py
12PYBUILD=./build/py
14include utils/makefile.include
15include utils/makefile.python
16include utils/makefile.sphinx
18all: clean install
20PHONY += help
21help:
22 @echo ' test - run developer tests'
23 @echo ' docs - build documentation'
24 @echo ' docs-live - autobuild HTML documentation while editing'
25 @echo ' run - run developer instance'
26 @echo ' install - developer install (./local)'
27 @echo ' uninstall - uninstall (./local)'
28 @echo ' gh-pages - build docs & deploy on gh-pages branch'
29 @echo ' clean - drop builds and environments'
30 @echo ' project - re-build generic files of the searx project'
31 @echo ' buildenv - re-build environment files (aka brand)'
32 @echo ' themes - re-build build the source of the themes'
33 @echo ' docker - build Docker image'
34 @echo ' node.env - download & install npm dependencies locally'
35 @echo ''
36 @$(MAKE) -s -f utils/makefile.include make-help
37 @echo ''
38 @$(MAKE) -s -f utils/makefile.python python-help
40PHONY += install
41install: buildenv pyenvinstall
43PHONY += uninstall
44uninstall: pyenvuninstall
46PHONY += clean
47clean: pyclean node.clean test.clean
48 $(call cmd,common_clean)
50PHONY += run
51run: buildenv pyenvinstall
52 $(Q) ( \
53 sed -i -e "s/debug : False/debug : True/g" ./searx/settings.yml ; \
54 sleep 2 ; \
55 xdg-open http://127.0.0.1:8888/ ; \
56 sleep 3 ; \
57 sed -i -e "s/debug : True/debug : False/g" ./searx/settings.yml ; \
58 ) &
59 $(PY_ENV)/bin/python ./searx/webapp.py
61# docs
62# ----
64PHONY += docs
65docs: buildenv pyenvinstall sphinx-doc
66 $(call cmd,sphinx,html,docs,docs)
68PHONY += docs-live
69docs-live: buildenv pyenvinstall sphinx-live
70 $(call cmd,sphinx_autobuild,html,docs,docs)
72$(GH_PAGES)::
73 @echo "doc available at --> $(DOCS_URL)"
75# update project files
76# --------------------
78PHONY += project engines.languages useragents.update buildenv
80project: buildenv useragents.update engines.languages
82engines.languages: pyenvinstall
83 $(Q)echo "fetch languages .."
84 $(Q)$(PY_ENV_ACT); python utils/fetch_languages.py
85 $(Q)echo "update searx/data/engines_languages.json"
86 $(Q)mv engines_languages.json searx/data/engines_languages.json
87 $(Q)echo "update searx/languages.py"
88 $(Q)mv languages.py searx/languages.py
90useragents.update: pyenvinstall
91 $(Q)echo "Update searx/data/useragents.json with the most recent versions of Firefox."
92 $(Q)$(PY_ENV_ACT); python utils/fetch_firefox_version.py
94buildenv:
95 $(Q)echo "build searx/brand.py"
96 $(Q)echo "GIT_URL = '$(GIT_URL)'" > searx/brand.py
97 $(Q)echo "ISSUE_URL = 'https://github.com/asciimoo/searx/issues'" >> searx/brand.py
98 $(Q)echo "SEARX_URL = '$(SEARX_URL)'" >> searx/brand.py
99 $(Q)echo "DOCS_URL = '$(DOCS_URL)'" >> searx/brand.py
100 $(Q)echo "PUBLIC_INSTANCES = 'https://searx.space'" >> searx/brand.py
101 $(Q)echo "build utils/brand.env"
102 $(Q)echo "export GIT_URL='$(GIT_URL)'" > utils/brand.env
103 $(Q)echo "export ISSUE_URL='https://github.com/asciimoo/searx/issues'" >> utils/brand.env
104 $(Q)echo "export SEARX_URL='$(SEARX_URL)'" >> utils/brand.env
105 $(Q)echo "export DOCS_URL='$(DOCS_URL)'" >> utils/brand.env
106 $(Q)echo "export PUBLIC_INSTANCES='https://searx.space'" >> utils/brand.env
109# node / npm
110# ----------
112node.env: buildenv
113 $(Q)./manage.sh npm_packages
115node.clean:
116 $(Q)echo "CLEAN locally installed npm dependencies"
117 $(Q)rm -rf \
118 ./node_modules \
119 ./package-lock.json \
120 ./searx/static/themes/oscar/package-lock.json \
121 ./searx/static/themes/oscar/node_modules \
122 ./searx/static/themes/simple/package-lock.json \
123 ./searx/static/themes/simple/node_modules
125# build themes
126# ------------
128PHONY += themes.bootstrap themes themes.oscar themes.simple themes.legacy themes.courgette themes.pixart
129themes: buildenv themes.bootstrap themes.oscar themes.simple themes.legacy themes.courgette themes.pixart
131quiet_cmd_lessc = LESSC $3
132 cmd_lessc = PATH="$$(npm bin):$$PATH" \
133 lessc --clean-css="--s1 --advanced --compatibility=ie9" "searx/static/$2" "searx/static/$3"
135quiet_cmd_grunt = GRUNT $2
136 cmd_grunt = PATH="$$(npm bin):$$PATH" \
137 grunt --gruntfile "$2"
139themes.oscar:
140 $(Q)echo '[!] build oscar theme'
141 $(call cmd,grunt,searx/static/themes/oscar/gruntfile.js)
143themes.simple:
144 $(Q)echo '[!] build simple theme'
145 $(call cmd,grunt,searx/static/themes/simple/gruntfile.js)
147themes.legacy:
148 $(Q)echo '[!] build legacy theme'
149 $(call cmd,lessc,themes/legacy/less/style-rtl.less,themes/legacy/css/style-rtl.css)
150 $(call cmd,lessc,themes/legacy/less/style.less,themes/legacy/css/style.css)
152themes.courgette:
153 $(Q)echo '[!] build courgette theme'
154 $(call cmd,lessc,themes/courgette/less/style.less,themes/courgette/css/style.css)
155 $(call cmd,lessc,themes/courgette/less/style-rtl.less,themes/courgette/css/style-rtl.css)
157themes.pixart:
158 $(Q)echo '[!] build pixart theme'
159 $(call cmd,lessc,themes/pix-art/less/style.less,themes/pix-art/css/style.css)
161themes.bootstrap:
162 $(call cmd,lessc,less/bootstrap/bootstrap.less,css/bootstrap.min.css)
165# docker
166# ------
168PHONY += docker
169docker: buildenv
170 $(Q)./manage.sh docker_build
172docker.push: buildenv
173 $(Q)./manage.sh docker_build push
175# gecko
176# -----
178PHONY += gecko.driver
179gecko.driver:
180 $(PY_ENV_ACT); ./manage.sh install_geckodriver
182# test
183# ----
185PHONY += test test.pylint test.pep8 test.unit test.coverage test.robot
187test: buildenv test.pylint test.pep8 test.unit gecko.driver test.robot
189ifeq ($(PY),2)
190test.pylint:
191 @echo "LINT skip liniting py2"
192else
193# TODO: balance linting with pylint
194test.pylint: pyenvinstall
195 $(call cmd,pylint,\
196 searx/preferences.py \
197 searx/testing.py \
198 )
199endif
201# ignored rules:
202# E402 module level import not at top of file
203# W503 line break before binary operator
205test.pep8: pyenvinstall
206 @echo "TEST pep8"
207 $(Q)$(PY_ENV_ACT); pep8 --exclude=searx/static --max-line-length=120 --ignore "E402,W503" searx tests
209test.unit: pyenvinstall
210 @echo "TEST tests/unit"
211 $(Q)$(PY_ENV_ACT); python -m nose2 -s tests/unit
213test.coverage: pyenvinstall
214 @echo "TEST unit test coverage"
215 $(Q)$(PY_ENV_ACT); \
216 python -m nose2 -C --log-capture --with-coverage --coverage searx -s tests/unit \
217 && coverage report \
218 && coverage html \
220test.robot: pyenvinstall gecko.driver
221 @echo "TEST robot"
222 $(Q)$(PY_ENV_ACT); PYTHONPATH=. python searx/testing.py robot
224test.clean:
225 @echo "CLEAN intermediate test stuff"
226 $(Q)rm -rf geckodriver.log .coverage coverage/
229# travis
230# ------
232travis.codecov:
233 $(Q)$(PY_ENV_BIN)/python -m pip install codecov
235.PHONY: $(PHONY)