1 # The default target of this Makefile is...
7 # make V=1 # V=1 increases verbosity
8 # make develop # pip install --editable .
9 # make test [flags=...] # run tests; flags=-x fails fast, --ff failed first
10 # make test V=2 # run tests; V=2 increases test verbosity
11 # make doc # build docs
12 # make flake8 # python style checks
13 # make pylint [color=1] # run pylint; color=1 colorizes output
14 # make pylint3k [color=1] # run python2+3 compatibility checks
15 # make format # run the black python formatter
16 # make check [color=1] # run test, doc, flake8, pylint3k, and pylint
17 # make check file=<filename> # run checks on <filename>
21 # make pot # update main translation template
22 # make po # merge translations
23 # make i18n # make pot + make po
27 # make prefix=<path> install
28 # DESTDIR is also supported.
30 # The external commands used by this Makefile are...
43 PYLINT
= $(PYTHON
) -B
-m pylint
44 PYTEST
= $(PYTHON
) -B
-m pytest
58 TEST_VERBOSE
= --verbose
67 FLAKE8_FLAGS
= $(VERBOSE
)
69 PYTEST_FLAGS
= $(QUIET
) $(TEST_VERBOSE
)
70 uname_S
:= $(shell uname
-s
)
71 ifneq ($(uname_S
),Linux
)
72 PYTEST_FLAGS
+= --ignore
=cola
/inotify.py
75 TOX_FLAGS
= $(VERBOSE_SHORT
) --develop
--skip-missing-interpreters
76 TOX_ENVS ?
= py
{27,36,37,38,39,lint
}
78 PYLINT_SCORE_FLAG
:= $(shell $(PYLINT
) --score
=no
--help
>/dev
/null
2>&1 && echo
" --score=no" || true
)
79 PYLINT_FLAGS
= --rcfile
=.pylintrc
81 PYLINT_FLAGS
+= --output-format
=colorized
83 ifneq ($(PYLINT_SCORE_FLAGSCORE
),)
84 PYLINT_FLAGS
+= $(PYLINT_SCORE_FLAG
)
87 # These values can be overridden on the command-line or via config.mak
89 python_version
:= $(shell $(PYTHON
) -c
'import sys; print("%s.%s" % sys.version_info[:2])')
90 python_lib
= python
$(python_version
)/site-packages
91 pythondir
= $(prefix)/lib
/$(python_lib
)
95 cola_app_base
= $(cola_base
).app
96 cola_app
= $(CURDIR
)/$(cola_app_base
)
97 cola_app_resources
= $(cola_app
)/Contents
/Resources
99 # Read $(VERSION) from cola/_version.py and strip quotes.
100 include cola
/_version.py
101 cola_version
:= $(subst ',,$(VERSION))
102 cola_dist := $(cola_base)-$(cola_version)
106 install_args += --root="$(DESTDIR)"
109 install_args += --prefix="$(prefix)"
115 ALL_PYTHON_DIRS = $(PYTHON_DIRS)
117 # User customizations
124 $(PIP) $(QUIET) $(VERBOSE) install $(install_args) .
128 $(MAKE) -C share/doc/git-cola all
132 $(MAKE) -C share/doc/git-cola html
136 $(MAKE) -C share/doc/git-cola man
140 $(MAKE) -C share/doc/git-cola install
144 $(MAKE) -C share/doc/git-cola install-html
148 $(MAKE) -C share/doc/git-cola install-man
152 $(RM) "$(DESTDIR)$(prefix)"/bin/cola
153 $(RM) "$(DESTDIR)$(prefix)"/bin/git-cola
154 $(RM) "$(DESTDIR)$(prefix)"/bin/git-cola-sequence-editor
155 $(RM) "$(DESTDIR)$(prefix)"/bin/git-dag
156 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-cola.desktop
157 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-cola-folder-handler.desktop
158 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-dag.desktop
159 $(RM) "$(DESTDIR)$(prefix)"/share/metainfo/git-dag.appdata.xml
160 $(RM) "$(DESTDIR)$(prefix)"/share/metainfo/git-cola.appdata.xml
161 $(RM) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable/apps/git-cola.svg
162 $(RM_R) "$(DESTDIR)$(prefix)"/share/doc/git-cola
163 $(RM_R) "$(DESTDIR)$(pythondir)"/git_cola-*
164 $(RM_R) "$(DESTDIR)$(pythondir)"/cola
165 $(RMDIR) -p "$(DESTDIR)$(pythondir)" 2>/dev/null || true
166 $(RMDIR) "$(DESTDIR)$(prefix)"/share/applications 2>/dev/null || true
167 $(RMDIR) "$(DESTDIR)$(prefix)"/share/metainfo 2>/dev/null || true
168 $(RMDIR) "$(DESTDIR)$(prefix)"/share/doc 2>/dev/null || true
169 $(RMDIR) "$(DESTDIR)$(prefix)"/share/locale/*/LC_MESSAGES 2>/dev/null || true
170 $(RMDIR) "$(DESTDIR)$(prefix)"/share/locale/* 2>/dev/null || true
171 $(RMDIR) "$(DESTDIR)$(prefix)"/share/locale 2>/dev/null || true
172 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable/apps 2>/dev/null || true
173 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable 2>/dev/null || true
174 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor 2>/dev/null || true
175 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons 2>/dev/null || true
176 $(RMDIR) "$(DESTDIR)$(prefix)"/share 2>/dev/null || true
177 $(RMDIR) "$(DESTDIR)$(prefix)"/bin 2>/dev/null || true
178 $(RMDIR) "$(DESTDIR)$(prefix)" 2>/dev/null || true
182 $(PYTEST) $(PYTEST_FLAGS) $(flags) $(PYTHON_DIRS)
186 $(PYTEST) $(PYTEST_FLAGS) --cov=cola $(flags) $(PYTHON_DIRS)
190 $(FIND) $(ALL_PYTHON_DIRS) -name '*.py
[cod
]' -print0 | $(XARGS) -0 $(RM)
191 $(FIND) $(ALL_PYTHON_DIRS) -name __pycache__ -print0 | $(XARGS) -0 $(RM_R)
192 $(RM_R) build dist tags git-cola.app
193 $(MAKE) -C share/doc/git-cola clean
200 # Regenerate git-cola.pot with new translations
210 --output-dir cola/i18n \
211 --output git-cola.pot \
215 # Update .po files with new translations from git-cola.pot
218 for po in cola/i18n/*.po; \
223 --no-fuzzy-matching \
225 --output-file $$po.new \
227 cola/i18n/git-cola.pot \
233 # Build a git-cola.app bundle.
236 $(MKDIR_P) $(cola_app)/Contents/MacOS
237 $(MKDIR_P) $(cola_app_resources)
238 $(PYTHON3) -m venv $(cola_app_resources)
239 $(cola_app_resources)/bin/pip install --requirement requirements/requirements.txt
240 $(cola_app_resources)/bin/pip install --requirement requirements/requirements-optional.txt
241 $(cola_app_resources)/bin/pip install --requirement requirements/requirements-dev.txt
243 $(CP) contrib/darwin/Info.plist contrib/darwin/PkgInfo $(cola_app)/Contents
244 $(CP) contrib/darwin/git-cola $(cola_app)/Contents/MacOS
245 $(CP) contrib/darwin/git-cola.icns $(cola_app)/Contents/Resources
246 $(MAKE) PIP=$(cola_app_resources)/bin/pip \
247 prefix=$(cola_app_resources) install
248 $(MAKE) SPHINXBUILD=$(cola_app_resources)/bin/sphinx-build \
249 prefix=$(cola_app_resources) install-doc
252 app-tarball:: git-cola.app
253 $(TAR) czf $(cola_dist).app.tar.gz $(cola_app_base)
255 # Preview the markdown using "make README.html"
262 $(FLAKE8) $(FLAKE8_FLAGS) $(flags) \
263 $(ALL_PYTHON_DIRS) contrib
268 $(PYLINT) $(PYLINT_FLAGS) --py3k $(flags) \
274 $(PYLINT) $(PYLINT_FLAGS) $(flags) \
281 $(FLAKE8) $(FLAKE8_FLAGS) $(flags) $(file)
282 $(PYLINT) $(PYLINT_FLAGS) --output-format=colorized $(flags) $(file)
283 $(PYLINT) $(PYLINT_FLAGS) --output-format=colorized --py3k $(flags) $(file)
285 # NOTE: flake8 is not part of "make check" because the pytest-flake8 plugin runs flake8
286 # checks during "make test" via pytest.
296 $(GIT) ls-files -- '*.py
' | \
298 $(XARGS) $(BLACK) --skip-string-normalization
300 # Run "make develop" from inside a newly created virtualenv to create an
301 # editable installation.
304 $(PIP) install --editable .
308 $(PIP) install --requirement requirements/requirements.txt
310 .PHONY: requirements-dev
312 $(PIP) install --requirement requirements/requirements-dev.txt
314 .PHONY: requirements-optional
315 requirements-optional::
316 $(PIP) install --requirement requirements/requirements-optional.txt
320 $(TOX) $(TOX_FLAGS) $(flags)
324 $(TOX) $(TOX_FLAGS) --parallel auto -e "$(TOX_ENVS)" $(flags)