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 # 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 # To disable distutil's replacement of "#!/usr/bin/env python" with
31 # the path to the build environment's python, pass USE_ENV_PYTHON=1
34 # The external commands used by this Makefile are...
46 PYLINT
= $(PYTHON
) -B
-m pylint
47 PYTEST
= $(PYTHON
) -B
-m pytest
61 TEST_VERBOSE
= --verbose
70 FLAKE8_FLAGS
= $(VERBOSE
)
72 PYTEST_FLAGS
= $(QUIET
) $(TEST_VERBOSE
)
73 uname_S
:= $(shell uname
-s
)
74 ifneq ($(uname_S
),Linux
)
75 PYTEST_FLAGS
+= --ignore
=cola
/inotify.py
78 TOX_FLAGS
= $(VERBOSE_SHORT
) --develop
--skip-missing-interpreters
79 TOX_ENVS ?
= py
{27,36,37,38,39,lint
}
81 PYLINT_SCORE_FLAG
:= $(shell $(PYLINT
) --score
=no
--help
>/dev
/null
2>&1 && echo
" --score=no" || true
)
82 PYLINT_FLAGS
= --rcfile
=.pylintrc
84 PYLINT_FLAGS
+= --output-format
=colorized
86 ifneq ($(PYLINT_SCORE_FLAGSCORE
),)
87 PYLINT_FLAGS
+= $(PYLINT_SCORE_FLAG
)
90 # These values can be overridden on the command-line or via config.mak
92 python_version
:= $(shell $(PYTHON
) -c
'import sys; print("%s.%s" % sys.version_info[:2])')
93 python_lib
= python
$(python_version
)/site-packages
94 pythondir
= $(prefix)/lib
/$(python_lib
)
98 cola_app_base
= $(cola_base
).app
99 cola_app
= $(CURDIR
)/$(cola_app_base
)
101 # Read $(VERSION) from cola/_version.py and strip quotes.
102 include cola
/_version.py
103 cola_version
:= $(subst ',,$(VERSION))
104 cola_dist := $(cola_base)-$(cola_version)
108 install_args += --root="$(DESTDIR)"
111 install_args += --prefix="$(prefix)"
117 ALL_PYTHON_DIRS = $(PYTHON_DIRS)
119 # User customizations
126 $(PIP) $(QUIET) $(VERBOSE) install $(install_args) .
130 $(MAKE) -C share/doc/git-cola all
134 $(MAKE) -C share/doc/git-cola html
138 $(MAKE) -C share/doc/git-cola man
142 $(MAKE) -C share/doc/git-cola install
146 $(MAKE) -C share/doc/git-cola install-html
150 $(MAKE) -C share/doc/git-cola install-man
154 $(RM) "$(DESTDIR)$(prefix)"/bin/cola
155 $(RM) "$(DESTDIR)$(prefix)"/bin/git-cola
156 $(RM) "$(DESTDIR)$(prefix)"/bin/git-cola-sequence-editor
157 $(RM) "$(DESTDIR)$(prefix)"/bin/git-dag
158 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-cola.desktop
159 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-cola-folder-handler.desktop
160 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-dag.desktop
161 $(RM) "$(DESTDIR)$(prefix)"/share/metainfo/git-dag.appdata.xml
162 $(RM) "$(DESTDIR)$(prefix)"/share/metainfo/git-cola.appdata.xml
163 $(RM) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable/apps/git-cola.svg
164 $(RM_R) "$(DESTDIR)$(prefix)"/share/doc/git-cola
165 $(RM_R) "$(DESTDIR)$(pythondir)"/git_cola-*
166 $(RM_R) "$(DESTDIR)$(pythondir)"/cola
167 $(RMDIR) -p "$(DESTDIR)$(pythondir)" 2>/dev/null || true
168 $(RMDIR) "$(DESTDIR)$(prefix)"/share/applications 2>/dev/null || true
169 $(RMDIR) "$(DESTDIR)$(prefix)"/share/metainfo 2>/dev/null || true
170 $(RMDIR) "$(DESTDIR)$(prefix)"/share/doc 2>/dev/null || true
171 $(RMDIR) "$(DESTDIR)$(prefix)"/share/locale/*/LC_MESSAGES 2>/dev/null || true
172 $(RMDIR) "$(DESTDIR)$(prefix)"/share/locale/* 2>/dev/null || true
173 $(RMDIR) "$(DESTDIR)$(prefix)"/share/locale 2>/dev/null || true
174 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable/apps 2>/dev/null || true
175 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable 2>/dev/null || true
176 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor 2>/dev/null || true
177 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons 2>/dev/null || true
178 $(RMDIR) "$(DESTDIR)$(prefix)"/share 2>/dev/null || true
179 $(RMDIR) "$(DESTDIR)$(prefix)"/bin 2>/dev/null || true
180 $(RMDIR) "$(DESTDIR)$(prefix)" 2>/dev/null || true
184 $(PYTEST) $(PYTEST_FLAGS) $(flags) $(PYTHON_DIRS)
188 $(PYTEST) $(PYTEST_FLAGS) --cov=cola $(flags) $(PYTHON_DIRS)
192 $(FIND) $(ALL_PYTHON_DIRS) -name '*.py
[cod
]' -print0 | $(XARGS) -0 $(RM)
193 $(FIND) $(ALL_PYTHON_DIRS) -name __pycache__ -print0 | $(XARGS) -0 $(RM_R)
194 $(RM_R) build dist tags git-cola.app
195 $(MAKE) -C share/doc/git-cola clean
202 # Regenerate git-cola.pot with new translations
212 --output-dir cola/i18n \
213 --output git-cola.pot \
217 # Update .po files with new translations from git-cola.pot
220 for po in cola/i18n/*.po; \
225 --no-fuzzy-matching \
227 --output-file $$po.new \
229 cola/i18n/git-cola.pot \
237 $(MKDIR_P) $(cola_app)/Contents/MacOS
238 $(MKDIR_P) $(cola_app)/Contents/Resources
239 $(CP) contrib/darwin/Info.plist contrib/darwin/PkgInfo \
241 $(CP) contrib/darwin/git-cola $(cola_app)/Contents/MacOS
242 $(CP) contrib/darwin/git-cola.icns $(cola_app)/Contents/Resources
243 $(MAKE) prefix=$(cola_app)/Contents/Resources install install-doc
246 app-tarball:: git-cola.app
247 $(TAR) czf $(cola_dist).app.tar.gz $(cola_app_base)
249 # Preview the markdown using "make README.html"
256 $(FLAKE8) $(FLAKE8_FLAGS) $(flags) \
257 $(ALL_PYTHON_DIRS) contrib
262 $(PYLINT) $(PYLINT_FLAGS) --py3k $(flags) \
268 $(PYLINT) $(PYLINT_FLAGS) $(flags) \
275 $(FLAKE8) $(FLAKE8_FLAGS) $(flags) $(file)
276 $(PYLINT) $(PYLINT_FLAGS) --output-format=colorized $(flags) $(file)
277 $(PYLINT) $(PYLINT_FLAGS) --output-format=colorized --py3k $(flags) $(file)
279 # NOTE: flake8 is not part of "make check" because the pytest-flake8 plugin runs flake8
280 # checks during "make test" via pytest.
290 $(GIT) ls-files -- '*.py
' | \
292 $(XARGS) $(BLACK) --skip-string-normalization
294 # Run "make develop" from inside a newly created virtualenv to create an
295 # editable installation.
298 $(PIP) install --editable .
302 $(PIP) install --requirement requirements/requirements.txt
304 .PHONY: requirements-dev
306 $(PIP) install --requirement requirements/requirements-dev.txt
308 .PHONY: requirements-optional
309 requirements-optional::
310 $(PIP) install --requirement requirements/requirements-optional.txt
314 $(TOX) $(TOX_FLAGS) $(flags)
318 $(TOX) $(TOX_FLAGS) --parallel auto -e "$(TOX_ENVS)" $(flags)