@@ -28,6 +28,9 @@ help-min:
2828 @echo ' gh-pages - build docs & deploy on gh-pages branch'
2929 @echo ' clean - drop builds and environments'
3030 @echo ' project - re-build generic files of the searx project'
31+ @echo ' themes - re-build build the source of the themes'
32+ @echo ' docker - build Docker image'
33+ @echo ' node.env - download & install npm dependencies locally'
3134 @echo ''
3235 @echo 'environment'
3336 @echo ' SEARX_URL = $(SEARX_URL)'
@@ -49,7 +52,7 @@ PHONY += uninstall
4952uninstall: pyenvuninstall
5053
5154PHONY += clean
52−clean: pyclean docs-clean
55+clean: pyclean docs-clean node.clean test.clean
5356 $(call cmd,common_clean)
5457
5558PHONY += run
@@ -88,27 +91,124 @@ $(GH_PAGES)::
8891# update project files
8992# --------------------
9093
91−PHONY += project engines-languages
92−
93−project: searx/data/engines_languages.json
94−
95−searx/data/engines_languages.json: pyenvinstall
96− $(PY_ENV_ACT); python utils/fetch_languages.py
97− mv engines_languages.json searx/data/engines_languages.json
98− mv languages.py searx/languages.py
94+PHONY += project engines.languages searx.brand useragents.update
95+
96+project: useragents.update engines.languages searx.brand
97+
98+engines.languages: pyenvinstall
99+ $(Q)echo "fetch languages .."
100+ $(Q)$(PY_ENV_ACT); python utils/fetch_languages.py
101+ $(Q)echo "update searx/data/engines_languages.json"
102+ $(Q)mv engines_languages.json searx/data/engines_languages.json
103+ $(Q)echo "update searx/languages.py"
104+ $(Q)mv languages.py searx/languages.py
105+
106+useragents.update: pyenvinstall
107+ $(Q)echo "Update searx/data/useragents.json with the most recent versions of Firefox."
108+ $(Q)$(PY_ENV_ACT); python utils/fetch_firefox_version.py
109+
110+searx.brand:
111+ $(Q)echo "build searx/brand.py"
112+ $(Q)echo "GIT_URL = '$(GIT_URL)'" > searx/brand.py
113+ $(Q)echo "ISSUE_URL = 'https://github.com/asciimoo/searx/issues'" >> searx/brand.py
114+ $(Q)echo "SEARX_URL = '$(SEARX_URL)'" >> searx/brand.py
115+ $(Q)echo "DOCS_URL = '$(DOCS_URL)'" >> searx/brand.py
116+ $(Q)echo "PUBLIC_INSTANCES = 'https://searx.space'" >> searx/brand.py
117+ $(Q)echo "build utils/brand.env"
118+ $(Q)echo "export GIT_URL='$(GIT_URL)'" > utils/brand.env
119+ $(Q)echo "export ISSUE_URL='https://github.com/asciimoo/searx/issues'" >> utils/brand.env
120+ $(Q)echo "export SEARX_URL='$(SEARX_URL)'" >> utils/brand.env
121+ $(Q)echo "export DOCS_URL='$(DOCS_URL)'" >> utils/brand.env
122+ $(Q)echo "export PUBLIC_INSTANCES='https://searx.space'" >> utils/brand.env
123+
124+
125+# node / npm
126+# ----------
127+
128+node.env:
129+ $(Q)./manage.sh npm_packages
130+
131+node.clean:
132+ $(Q)echo "CLEAN locally installed npm dependencies"
133+ $(Q)rm -rf \
134+ ./node_modules \
135+ ./package-lock.json \
136+ ./searx/static/themes/oscar/package-lock.json \
137+ ./searx/static/themes/oscar/node_modules \
138+ ./searx/static/themes/simple/package-lock.json \
139+ ./searx/static/themes/simple/node_modules
140+
141+# build themes
142+# ------------
143+
144+PHONY += themes.bootstrap themes themes.oscar themes.simple themes.legacy themes.courgette themes.pixart
145+themes: themes.bootstrap themes.oscar themes.simple themes.legacy themes.courgette themes.pixart
146+
147+quiet_cmd_lessc = LESSC $3
148+ cmd_lessc = PATH="$$(npm bin):$$PATH" \
149+ lessc --clean-css="--s1 --advanced --compatibility=ie9" "searx/static/$2" "searx/static/$3"
150+
151+quiet_cmd_grunt = GRUNT $2
152+ cmd_grunt = PATH="$$(npm bin):$$PATH" \
153+ grunt --gruntfile "$2"
154+
155+themes.oscar:
156+ $(Q)echo '[!] build oscar theme'
157+ $(call cmd,grunt,searx/static/themes/oscar/gruntfile.js)
158+
159+themes.simple:
160+ $(Q)echo '[!] build simple theme'
161+ $(call cmd,grunt,searx/static/themes/simple/gruntfile.js)
162+
163+themes.legacy:
164+ $(Q)echo '[!] build legacy theme'
165+ $(call cmd,lessc,themes/legacy/less/style-rtl.less,themes/legacy/css/style-rtl.css)
166+ $(call cmd,lessc,themes/legacy/less/style.less,themes/legacy/css/style.css)
167+
168+themes.courgette:
169+ $(Q)echo '[!] build courgette theme'
170+ $(call cmd,lessc,themes/courgette/less/style.less,themes/courgette/css/style.css)
171+ $(call cmd,lessc,themes/courgette/less/style-rtl.less,themes/courgette/css/style-rtl.css)
172+
173+themes.pixart:
174+ $(Q)echo '[!] build pixart theme'
175+ $(call cmd,lessc,themes/pix-art/less/style.less,themes/pix-art/css/style.css)
176+
177+themes.bootstrap:
178+ $(call cmd,lessc,less/bootstrap/bootstrap.less,css/bootstrap.min.css)
179+
180+
181+# docker
182+# ------
183+
184+PHONY += docker
185+docker:
186+ $(Q)./manage.sh docker_build
187+
188+# gecko
189+# -----
190+
191+PHONY += gecko.driver
192+gecko.driver:
193+ $(PY_ENV_ACT); ./manage.sh install_geckodriver
99194
100195# test
101196# ----
102197
103−PHONY += test test.sh test.pylint test.pep8 test.unit test.robot
104−
105−test: test.pylint test.pep8 test.unit test.robot
198+PHONY += test test.sh test.pylint test.pep8 test.unit test.coverage test.robot
199+test: test.pylint test.pep8 test.unit gecko.driver test.robot
106200
107201# TODO: balance linting with pylint
108202
109203test.pylint: pyenvinstall
110− $(call cmd,pylint,searx/preferences.py)
111− $(call cmd,pylint,searx/testing.py)
204+ $(call cmd,pylint,\
205+ searx/preferences.py \
206+ searx/testing.py \
207+ )
208+
209+# ignored rules:
210+# E402 module level import not at top of file
211+# W503 line break before binary operator
112212
113213# ubu1604: uses shellcheck v0.3.7 (from 04/2015), no longer supported!
114214test.sh:
@@ -121,13 +221,26 @@ test.sh:
121221 shellcheck -x .config.sh
122222
123223test.pep8: pyenvinstall
124− $(PY_ENV_ACT); ./manage.sh pep8_check
224+ @echo "TEST pep8"
225+ $(Q)$(PY_ENV_ACT); pep8 --exclude=searx/static --max-line-length=120 --ignore "E402,W503" searx tests
125226
126227test.unit: pyenvinstall
127− $(PY_ENV_ACT); ./manage.sh unit_tests
128−
129−test.robot: pyenvinstall
130− $(PY_ENV_ACT); ./manage.sh install_geckodriver
131− $(PY_ENV_ACT); ./manage.sh robot_tests
228+ @echo "TEST tests/unit"
229+ $(Q)$(PY_ENV_ACT); python -m nose2 -s tests/unit
230+
231+test.coverage: pyenvinstall
232+ @echo "TEST unit test coverage"
233+ $(Q)$(PY_ENV_ACT); \
234+ python -m nose2 -C --log-capture --with-coverage --coverage searx -s tests/unit \
235+ && coverage report \
236+ && coverage html \
237+
238+test.robot: pyenvinstall gecko.driver
239+ @echo "TEST robot"
240+ $(Q)$(PY_ENV_ACT); PYTHONPATH=. python searx/testing.py robot
241+
242+test.clean:
243+ @echo "CLEAN intermediate test stuff"
244+ $(Q)rm -rf geckodriver.log .coverage coverage/
132245
133246.PHONY: $(PHONY)