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 format # run the black python formatter
15 # make check [color=1] # run test, doc, flake8 and pylint
16 # make check file=<filename> # run checks on <filename>
20 # make pot # update main translation template
21 # make po # merge translations
22 # make i18n # make pot + make po
26 # make prefix=<path> install
27 # DESTDIR is also supported.
29 # The external commands used by this Makefile are...
42 PYLINT
= $(PYTHON
) -B
-m pylint
43 PYTEST
= $(PYTHON
) -B
-m pytest
57 TEST_VERBOSE
= --verbose
66 FLAKE8_FLAGS
= $(VERBOSE
)
68 PYTEST_FLAGS
= $(QUIET
) $(TEST_VERBOSE
)
69 uname_S
:= $(shell uname
-s
)
70 ifneq ($(uname_S
),Linux
)
71 PYTEST_FLAGS
+= --ignore
=cola
/inotify.py
74 TOX_FLAGS
= $(VERBOSE_SHORT
) --develop
--skip-missing-interpreters
75 TOX_ENVS ?
= py
{36,37,38,39,310,311}
77 PYLINT_SCORE_FLAG
:= $(shell $(PYLINT
) --score
=no
--help
>/dev
/null
2>&1 && echo
" --score=no" || true
)
78 PYLINT_FLAGS
= --rcfile
=.pylintrc
80 PYLINT_FLAGS
+= --output-format
=colorized
82 ifneq ($(PYLINT_SCORE_FLAGSCORE
),)
83 PYLINT_FLAGS
+= $(PYLINT_SCORE_FLAG
)
86 # These values can be overridden on the command-line or via config.mak
88 python_version
:= $(shell $(PYTHON
) -c
'import sys; print("%s.%s" % sys.version_info[:2])')
89 python_lib
= python
$(python_version
)/site-packages
90 pythondir
= $(prefix)/lib
/$(python_lib
)
94 cola_app_base
= $(cola_base
).app
95 cola_app
= $(CURDIR
)/$(cola_app_base
)
96 cola_app_resources
= $(cola_app
)/Contents
/Resources
98 # Read $(VERSION) from cola/_version.py and strip quotes.
99 include cola
/_version.py
100 cola_version
:= $(subst ',,$(VERSION))
101 cola_dist := $(cola_base)-$(cola_version)
105 install_args += --root="$(DESTDIR)"
108 install_args += --prefix="$(prefix)"
109 install_args += --disable-pip-version-check
115 ALL_PYTHON_DIRS = $(PYTHON_DIRS)
117 # User customizations
124 $(PIP) $(QUIET) $(VERBOSE) install $(install_args) .
140 $(MAKE) -C docs install
144 $(MAKE) -C docs install-html
148 $(MAKE) -C docs 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/icons/hicolor/scalable/apps 2>/dev/null || true
170 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable 2>/dev/null || true
171 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor 2>/dev/null || true
172 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons 2>/dev/null || true
173 $(RMDIR) "$(DESTDIR)$(prefix)"/share 2>/dev/null || true
174 $(RMDIR) "$(DESTDIR)$(prefix)"/bin 2>/dev/null || true
175 $(RMDIR) "$(DESTDIR)$(prefix)" 2>/dev/null || true
179 $(PYTEST) $(PYTEST_FLAGS) $(flags) $(PYTHON_DIRS)
183 $(PYTEST) $(PYTEST_FLAGS) --cov=cola $(flags) $(PYTHON_DIRS)
187 $(FIND) $(ALL_PYTHON_DIRS) -name '*.py
[cod
]' -print0 | $(XARGS) -0 $(RM)
188 $(FIND) $(ALL_PYTHON_DIRS) -name __pycache__ -print0 | $(XARGS) -0 $(RM_R)
189 $(RM_R) build dist tags git-cola.app
190 $(MAKE) -C docs clean
197 # Regenerate git-cola.pot with new translations
206 --output-dir cola/i18n \
207 --output git-cola.pot \
211 # Update .po files with new translations from git-cola.pot
214 for po in cola/i18n/*.po; \
218 --no-fuzzy-matching \
220 --output-file $$po.new \
222 cola/i18n/git-cola.pot \
228 # Build a git-cola.app bundle.
231 cola_full_version := $(shell ./bin/git-cola version --brief)
234 $(MKDIR_P) $(cola_app)/Contents/MacOS
235 $(MKDIR_P) $(cola_app_resources)
236 $(PYTHON3) -m venv --copies $(cola_app_resources)
237 $(cola_app_resources)/bin/pip install --requirement requirements/requirements.txt
238 $(cola_app_resources)/bin/pip install --requirement requirements/requirements-optional.txt
239 $(cola_app_resources)/bin/pip install --requirement requirements/requirements-dev.txt
241 $(CP) contrib/darwin/Info.plist contrib/darwin/PkgInfo $(cola_app)/Contents
242 ifneq ($(cola_full_version),)
243 sed -i -e s/0.0.0.0/$(cola_full_version)/ $(cola_app)/Contents/Info.plist
245 sed -i -e s/0.0.0/$(cola_version)/ $(cola_app)/Contents/Info.plist
246 $(CP) contrib/darwin/git-cola $(cola_app)/Contents/MacOS
247 $(CP) contrib/darwin/git-cola.icns $(cola_app)/Contents/Resources
248 $(MAKE) PIP=$(cola_app_resources)/bin/pip \
249 prefix=$(cola_app_resources) install
250 $(MAKE) SPHINXBUILD=$(cola_app_resources)/bin/sphinx-build \
251 prefix=$(cola_app_resources) install-doc
254 app-tarball:: git-cola.app
255 $(TAR) czf $(cola_dist).app.tar.gz $(cola_app_base)
257 # Preview the markdown using "make README.html"
264 $(FLAKE8) $(FLAKE8_FLAGS) $(flags) \
265 $(ALL_PYTHON_DIRS) contrib
270 $(PYLINT) $(PYLINT_FLAGS) $(flags) \
277 $(FLAKE8) $(FLAKE8_FLAGS) $(flags) $(file)
278 $(PYLINT) $(PYLINT_FLAGS) --output-format=colorized $(flags) $(file)
289 $(GIT) ls-files -- '*.py
' | \
291 $(XARGS) $(BLACK) --skip-string-normalization
293 # Run "make develop" from inside a newly created virtualenv to create an
294 # editable installation.
297 $(PIP) install --editable .
301 $(PIP) install --requirement requirements/requirements.txt
303 .PHONY: requirements-dev
305 $(PIP) install --requirement requirements/requirements-dev.txt
307 .PHONY: requirements-optional
308 requirements-optional::
309 $(PIP) install --requirement requirements/requirements-optional.txt
313 $(TOX) $(TOX_FLAGS) --parallel auto -e "${TOX_ENVS}" $(flags)
317 $(TOX) $(TOX_FLAGS) --parallel auto -e check $(flags)