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 pylint [color=1] # run pylint; color=1 colorizes output
13 # make fmt # run the code formatter
14 # make check [color=1] # run test, doc and pylint
15 # make check file=<filename> # run checks on <filename>
19 # make pot # update main translation template
20 # make po # merge translations
21 # make i18n # make pot + make po
25 # make prefix=<path> install
26 # DESTDIR is also supported.
28 # The external commands used by this Makefile are...
40 PYLINT
= $(PYTHON
) -B
-m pylint
41 PYTEST
= $(PYTHON
) -B
-m pytest
55 TEST_VERBOSE
= --verbose
64 PYTEST_FLAGS
= $(QUIET
) $(TEST_VERBOSE
)
65 uname_S
:= $(shell uname
-s
)
66 ifneq ($(uname_S
),Linux
)
67 PYTEST_FLAGS
+= --ignore
=cola
/inotify.py
70 TOX_FLAGS
= $(VERBOSE_SHORT
) --develop
--skip-missing-interpreters
71 TOX_ENVS ?
= py
{36,37,38,39,310,311}
73 PYLINT_SCORE_FLAG
:= $(shell $(PYLINT
) --score
=no
--help
>/dev
/null
2>&1 && echo
" --score=no" || true
)
74 PYLINT_FLAGS
= --rcfile
=.pylintrc
76 PYLINT_FLAGS
+= --output-format
=colorized
78 ifneq ($(PYLINT_SCORE_FLAGSCORE
),)
79 PYLINT_FLAGS
+= $(PYLINT_SCORE_FLAG
)
82 # These values can be overridden on the command-line or via config.mak
84 python_version
:= $(shell $(PYTHON
) -c
'import sys; print("%s.%s" % sys.version_info[:2])')
85 python_lib
= python
$(python_version
)/site-packages
86 pythondir
= $(prefix)/lib
/$(python_lib
)
90 cola_app_base
= $(cola_base
).app
91 cola_app
= $(CURDIR
)/$(cola_app_base
)
92 cola_app_resources
= $(cola_app
)/Contents
/Resources
94 # Read $(VERSION) from cola/_version.py and strip quotes.
95 include cola
/_version.py
96 cola_version
:= $(subst ',,$(VERSION))
97 cola_dist := $(cola_base)-$(cola_version)
101 install_args += --root="$(DESTDIR)"
104 install_args += --prefix="$(prefix)"
105 install_args += --disable-pip-version-check
111 ALL_PYTHON_DIRS = $(PYTHON_DIRS)
113 # User customizations
120 $(PIP) $(QUIET) $(VERBOSE) install $(install_args) .
136 $(MAKE) -C docs install
140 $(MAKE) -C docs install-html
144 $(MAKE) -C docs install-man
148 $(RM) "$(DESTDIR)$(prefix)"/bin/cola
149 $(RM) "$(DESTDIR)$(prefix)"/bin/git-cola
150 $(RM) "$(DESTDIR)$(prefix)"/bin/git-cola-sequence-editor
151 $(RM) "$(DESTDIR)$(prefix)"/bin/git-dag
152 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-cola.desktop
153 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-cola-folder-handler.desktop
154 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-dag.desktop
155 $(RM) "$(DESTDIR)$(prefix)"/share/metainfo/git-dag.appdata.xml
156 $(RM) "$(DESTDIR)$(prefix)"/share/metainfo/git-cola.appdata.xml
157 $(RM) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable/apps/git-cola.svg
158 $(RM_R) "$(DESTDIR)$(prefix)"/share/doc/git-cola
159 $(RM_R) "$(DESTDIR)$(pythondir)"/git_cola-*
160 $(RM_R) "$(DESTDIR)$(pythondir)"/cola
161 $(RMDIR) -p "$(DESTDIR)$(pythondir)" 2>/dev/null || true
162 $(RMDIR) "$(DESTDIR)$(prefix)"/share/applications 2>/dev/null || true
163 $(RMDIR) "$(DESTDIR)$(prefix)"/share/metainfo 2>/dev/null || true
164 $(RMDIR) "$(DESTDIR)$(prefix)"/share/doc 2>/dev/null || true
165 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable/apps 2>/dev/null || true
166 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable 2>/dev/null || true
167 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor 2>/dev/null || true
168 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons 2>/dev/null || true
169 $(RMDIR) "$(DESTDIR)$(prefix)"/share 2>/dev/null || true
170 $(RMDIR) "$(DESTDIR)$(prefix)"/bin 2>/dev/null || true
171 $(RMDIR) "$(DESTDIR)$(prefix)" 2>/dev/null || true
175 $(PYTEST) $(PYTEST_FLAGS) $(flags) $(PYTHON_DIRS)
179 $(PYTEST) $(PYTEST_FLAGS) --cov=cola $(flags) $(PYTHON_DIRS)
183 $(FIND) $(ALL_PYTHON_DIRS) -name '*.py
[cod
]' -print0 | $(XARGS) -0 $(RM)
184 $(FIND) $(ALL_PYTHON_DIRS) -name __pycache__ -print0 | $(XARGS) -0 $(RM_R)
185 $(RM_R) build dist tags git-cola.app
186 $(MAKE) -C docs clean
193 # Regenerate git-cola.pot with new translations
202 --output-dir cola/i18n \
203 --output git-cola.pot \
207 # Update .po files with new translations from git-cola.pot
210 for po in cola/i18n/*.po; \
214 --no-fuzzy-matching \
216 --output-file $$po.new \
218 cola/i18n/git-cola.pot \
224 # Build a git-cola.app bundle.
227 cola_full_version := $(shell ./bin/git-cola version --brief)
230 $(MKDIR_P) $(cola_app)/Contents/MacOS
231 $(MKDIR_P) $(cola_app_resources)
232 $(PYTHON3) -m venv $(cola_app_resources)
233 $(cola_app_resources)/bin/pip install --requirement requirements/requirements.txt
234 $(cola_app_resources)/bin/pip install --requirement requirements/requirements-optional.txt
235 $(cola_app_resources)/bin/pip install --requirement requirements/requirements-dev.txt
237 $(CP) contrib/darwin/Info.plist contrib/darwin/PkgInfo $(cola_app)/Contents
238 ifneq ($(cola_full_version),)
239 sed -i -e s/0.0.0.0/$(cola_full_version)/ $(cola_app)/Contents/Info.plist
241 sed -i -e s/0.0.0/$(cola_version)/ $(cola_app)/Contents/Info.plist
242 $(CP) contrib/darwin/git-cola $(cola_app)/Contents/MacOS
243 $(CP) contrib/darwin/git-cola.icns $(cola_app)/Contents/Resources
244 $(MAKE) PIP=$(cola_app_resources)/bin/pip \
245 prefix=$(cola_app_resources) install
246 $(MAKE) SPHINXBUILD=$(cola_app_resources)/bin/sphinx-build \
247 prefix=$(cola_app_resources) install-doc
250 app-tarball:: git-cola.app
251 $(TAR) czf $(cola_dist).app.tar.gz $(cola_app_base)
253 # Preview the markdown using "make README.html"
260 $(PYLINT) $(PYLINT_FLAGS) $(flags) \
267 $(PYLINT) $(PYLINT_FLAGS) --output-format=colorized $(flags) $(file)
277 $(GIT) ls-files -- '*.py
' | \
281 # Run "make develop" from inside a newly created virtualenv to create an
282 # editable installation.
285 $(PIP) install --editable .
289 $(PIP) install --requirement requirements/requirements.txt
291 .PHONY: requirements-dev
293 $(PIP) install --requirement requirements/requirements-dev.txt
295 .PHONY: requirements-optional
296 requirements-optional::
297 $(PIP) install --requirement requirements/requirements-optional.txt
301 $(TOX) $(TOX_FLAGS) --parallel auto -e "${TOX_ENVS}" $(flags)
305 $(TOX) $(TOX_FLAGS) --parallel auto -e check $(flags)