@@ -27,23 +27,28 @@ help:
2727 @echo ' uninstall - uninstall (./local)'
2828 @echo ' gh-pages - build docs & deploy on gh-pages branch'
2929 @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'
3035 @echo ''
3136 @$(MAKE) -s -f utils/makefile.include make-help
3237 @echo ''
3338 @$(MAKE) -s -f utils/makefile.python python-help
3439
3540PHONY += install
36−install: pyenvinstall
41+install: buildenv pyenvinstall
3742
3843PHONY += uninstall
3944uninstall: pyenvuninstall
4045
4146PHONY += clean
42−clean: pyclean
47+clean: pyclean node.clean test.clean
4348 $(call cmd,common_clean)
4449
4550PHONY += run
46−run: pyenvinstall
51+run: buildenv pyenvinstall
4752 $(Q) ( \
4853 sed -i -e "s/debug : False/debug : True/g" ./searx/settings.yml ; \
4954 sleep 2 ; \
@@ -57,36 +62,174 @@ run: pyenvinstall
5762# ----
5863
5964PHONY += docs
60−docs: pyenvinstall sphinx-doc
65+docs: buildenv pyenvinstall sphinx-doc
6166 $(call cmd,sphinx,html,docs,docs)
6267
6368PHONY += docs-live
64−docs-live: pyenvinstall sphinx-live
69+docs-live: buildenv pyenvinstall sphinx-live
6570 $(call cmd,sphinx_autobuild,html,docs,docs)
6671
6772$(GH_PAGES)::
6873 @echo "doc available at --> $(DOCS_URL)"
6974
75+# update project files
76+# --------------------
77+
78+PHONY += project engines.languages useragents.update buildenv
79+
80+project: buildenv useragents.update engines.languages
81+
82+engines.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
89+
90+useragents.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
93+
94+buildenv:
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
107+
108+
109+# node / npm
110+# ----------
111+
112+node.env: buildenv
113+ $(Q)./manage.sh npm_packages
114+
115+node.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
124+
125+# build themes
126+# ------------
127+
128+PHONY += themes.bootstrap themes themes.oscar themes.simple themes.legacy themes.courgette themes.pixart
129+themes: buildenv themes.bootstrap themes.oscar themes.simple themes.legacy themes.courgette themes.pixart
130+
131+quiet_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"
134+
135+quiet_cmd_grunt = GRUNT $2
136+ cmd_grunt = PATH="$$(npm bin):$$PATH" \
137+ grunt --gruntfile "$2"
138+
139+themes.oscar:
140+ $(Q)echo '[!] build oscar theme'
141+ $(call cmd,grunt,searx/static/themes/oscar/gruntfile.js)
142+
143+themes.simple:
144+ $(Q)echo '[!] build simple theme'
145+ $(call cmd,grunt,searx/static/themes/simple/gruntfile.js)
146+
147+themes.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)
151+
152+themes.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)
156+
157+themes.pixart:
158+ $(Q)echo '[!] build pixart theme'
159+ $(call cmd,lessc,themes/pix-art/less/style.less,themes/pix-art/css/style.css)
160+
161+themes.bootstrap:
162+ $(call cmd,lessc,less/bootstrap/bootstrap.less,css/bootstrap.min.css)
163+
164+
165+# docker
166+# ------
167+
168+PHONY += docker
169+docker: buildenv
170+ $(Q)./manage.sh docker_build
171+
172+docker.push: buildenv
173+ $(Q)./manage.sh docker_build push
174+
175+# gecko
176+# -----
177+
178+PHONY += gecko.driver
179+gecko.driver:
180+ $(PY_ENV_ACT); ./manage.sh install_geckodriver
181+
70182# test
71183# ----
72184
73−PHONY += test test.pylint test.pep8 test.unit test.robot
185+PHONY += test test.pylint test.pep8 test.unit test.coverage test.robot
74186
75−test: test.pylint test.pep8 test.unit test.robot
187+test: buildenv test.pylint test.pep8 test.unit gecko.driver test.robot
76188
189+ifeq ($(PY),2)
190+test.pylint:
191+ @echo "LINT skip liniting py2"
192+else
77193# TODO: balance linting with pylint
78194test.pylint: pyenvinstall
79− $(call cmd,pylint,searx/preferences.py)
80− $(call cmd,pylint,searx/testing.py)
195+ $(call cmd,pylint,\
196+ searx/preferences.py \
197+ searx/testing.py \
198+ )
199+endif
200+
201+# ignored rules:
202+# E402 module level import not at top of file
203+# W503 line break before binary operator
81204
82205test.pep8: pyenvinstall
83− $(PY_ENV_ACT); ./manage.sh pep8_check
206+ @echo "TEST pep8"
207+ $(Q)$(PY_ENV_ACT); pep8 --exclude=searx/static --max-line-length=120 --ignore "E402,W503" searx tests
84208
85209test.unit: pyenvinstall
86− $(PY_ENV_ACT); ./manage.sh unit_tests
210+ @echo "TEST tests/unit"
211+ $(Q)$(PY_ENV_ACT); python -m nose2 -s tests/unit
87212
88−test.robot: pyenvinstall
89− $(PY_ENV_ACT); ./manage.sh install_geckodriver
90− $(PY_ENV_ACT); ./manage.sh robot_tests
213+test.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 \
219+
220+test.robot: pyenvinstall gecko.driver
221+ @echo "TEST robot"
222+ $(Q)$(PY_ENV_ACT); PYTHONPATH=. python searx/testing.py robot
223+
224+test.clean:
225+ @echo "CLEAN intermediate test stuff"
226+ $(Q)rm -rf geckodriver.log .coverage coverage/
227+
228+
229+# travis
230+# ------
231+
232+travis.codecov:
233+ $(Q)$(PY_ENV_BIN)/python -m pip install codecov
91234
92235.PHONY: $(PHONY)