1 # The default target of this Makefile is...
6 # make develop # python setup.py develop ~ one-time virtualenv development setup
7 # make V=1 # generate files; V=1 increases verbosity
8 # make test [flags=...] # run tests; flags=-x fails fast, --ff failed first
9 # make test V=2 # V=2 increases test verbosity
10 # make doc # build docs
11 # make flake8 # python style checks
12 # make pylint [color=1] # run pylint; color=1 colorizes output
13 # make pylint3k [color=1] # run python2+3 compatibility checks
14 # make format # run the black python formatter
15 # make check [color=1] # run test, doc, flake8, pylint3k, 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 mo # generate message files
23 # make i18n # all three of the above
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...
49 PYLINT
= $(PYTHON
) -B
-m pylint
50 PYTEST
= $(PYTHON
) -B
-m pytest
63 TEST_VERBOSE
= --verbose
72 FLAKE8_FLAGS
= $(VERBOSE
)
74 PYTEST_FLAGS
= $(QUIET
) $(TEST_VERBOSE
)
75 uname_S
:= $(shell uname
-s
)
76 ifneq ($(uname_S
),Linux
)
77 PYTEST_FLAGS
+= --ignore
=cola
/inotify.py
80 TOX_FLAGS
= $(VERBOSE_SHORT
) --develop
--skip-missing-interpreters
81 TOX_ENVS ?
= py
{27,36,37,38,39,lint
}
83 PYLINT_SCORE_FLAG
:= $(shell $(PYLINT
) --score
=no
--help
>/dev
/null
2>&1 && echo
" --score=no" || true
)
84 PYLINT_FLAGS
= --rcfile
=.pylintrc
86 PYLINT_FLAGS
+= --output-format
=colorized
88 ifneq ($(PYLINT_SCORE_FLAGSCORE
),)
89 PYLINT_FLAGS
+= $(PYLINT_SCORE_FLAG
)
92 # These values can be overridden on the command-line or via config.mak
94 bindir = $(prefix)/bin
95 python_version
:= $(shell $(PYTHON
) -c
'import sys; print("%s.%s" % sys.version_info[:2])')
96 python_lib
= python
$(python_version
)/site-packages
97 pythondir
= $(prefix)/lib
/$(python_lib
)
100 cola_base
:= git-cola
101 cola_app_base
= $(cola_base
).app
102 cola_app
= $(CURDIR
)/$(cola_app_base
)
104 # Read $(VERSION) from cola/_version.py and strip quotes.
105 include cola
/_version.py
106 cola_version
:= $(subst ',,$(VERSION))
107 cola_dist := $(cola_base)-$(cola_version)
109 SETUP ?= $(PYTHON) setup.py
113 install_args += install
115 install_args += --root="$(DESTDIR)"
118 install_args += --prefix="$(prefix)"
119 install_args += --install-scripts="$(bindir)"
120 install_args += --single-version-externally-managed
121 install_args += --record=build/MANIFEST
127 ALL_PYTHON_DIRS = $(PYTHON_DIRS)
128 ALL_PYTHON_DIRS += extras
130 # User customizations
138 $(SETUP) $(QUIET) $(VERBOSE) $(build_args)
142 $(SETUP) $(QUIET) $(VERBOSE) $(install_args)
146 $(MAKE) -C share/doc/git-cola all
150 $(MAKE) -C share/doc/git-cola html
154 $(MAKE) -C share/doc/git-cola man
158 $(MAKE) -C share/doc/git-cola install
162 $(MAKE) -C share/doc/git-cola install-html
166 $(MAKE) -C share/doc/git-cola install-man
170 $(RM) "$(DESTDIR)$(prefix)"/bin/git-cola
171 $(RM) "$(DESTDIR)$(prefix)"/bin/git-cola-sequence-editor
172 $(RM) "$(DESTDIR)$(prefix)"/bin/git-dag
173 $(RM) "$(DESTDIR)$(prefix)"/bin/cola
174 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-cola.desktop
175 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-cola-folder-handler.desktop
176 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-dag.desktop
177 $(RM) "$(DESTDIR)$(prefix)"/share/metainfo/git-dag.appdata.xml
178 $(RM) "$(DESTDIR)$(prefix)"/share/metainfo/git-cola.appdata.xml
179 $(RM) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable/apps/git-cola.svg
180 $(RM_R) "$(DESTDIR)$(prefix)"/share/doc/git-cola
181 $(RM_R) "$(DESTDIR)$(prefix)"/share/git-cola
182 $(RM) "$(DESTDIR)$(prefix)"/share/locale/*/LC_MESSAGES/git-cola.mo
183 $(RM_R) "$(DESTDIR)$(pythondir)"/git_cola-*
184 $(RM_R) "$(DESTDIR)$(pythondir)"/cola
185 $(RMDIR) -p "$(DESTDIR)$(pythondir)" 2>/dev/null || true
186 $(RMDIR) "$(DESTDIR)$(prefix)"/share/applications 2>/dev/null || true
187 $(RMDIR) "$(DESTDIR)$(prefix)"/share/metainfo 2>/dev/null || true
188 $(RMDIR) "$(DESTDIR)$(prefix)"/share/doc 2>/dev/null || true
189 $(RMDIR) "$(DESTDIR)$(prefix)"/share/locale/*/LC_MESSAGES 2>/dev/null || true
190 $(RMDIR) "$(DESTDIR)$(prefix)"/share/locale/* 2>/dev/null || true
191 $(RMDIR) "$(DESTDIR)$(prefix)"/share/locale 2>/dev/null || true
192 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable/apps 2>/dev/null || true
193 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable 2>/dev/null || true
194 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor 2>/dev/null || true
195 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons 2>/dev/null || true
196 $(RMDIR) "$(DESTDIR)$(prefix)"/share 2>/dev/null || true
197 $(RMDIR) "$(DESTDIR)$(prefix)"/bin 2>/dev/null || true
198 $(RMDIR) "$(DESTDIR)$(prefix)" 2>/dev/null || true
202 $(PYTEST) $(PYTEST_FLAGS) $(flags) $(PYTHON_DIRS)
206 $(PYTEST) $(PYTEST_FLAGS) --cov=cola $(flags) $(PYTHON_DIRS)
210 $(FIND) $(ALL_PYTHON_DIRS) -name '*.py
[cod
]' -print0 | $(XARGS) -0 $(RM)
211 $(FIND) $(ALL_PYTHON_DIRS) -name __pycache__ -print0 | $(XARGS) -0 $(RM_R)
212 $(RM_R) build dist tags git-cola.app
214 $(MAKE) -C share/doc/git-cola clean
224 $(SETUP) build_pot --build-dir=po --no-lang
228 $(SETUP) build_pot --build-dir=po
232 $(SETUP) build_mo --force
236 $(MKDIR_P) $(cola_app)/Contents/MacOS
237 $(MKDIR_P) $(cola_app)/Contents/Resources
238 $(CP) contrib/darwin/Info.plist contrib/darwin/PkgInfo \
240 $(CP) contrib/darwin/git-cola $(cola_app)/Contents/MacOS
241 $(CP) contrib/darwin/git-cola.icns $(cola_app)/Contents/Resources
242 $(MAKE) prefix=$(cola_app)/Contents/Resources install install-doc
245 app-tarball:: git-cola.app
246 $(TAR) czf $(cola_dist).app.tar.gz $(cola_app_base)
248 # Preview the markdown using "make README.html"
255 $(FLAKE8) $(FLAKE8_FLAGS) $(flags) \
256 $(ALL_PYTHON_DIRS) contrib
261 $(PYLINT) $(PYLINT_FLAGS) --py3k $(flags) \
267 $(PYLINT) $(PYLINT_FLAGS) $(flags) \
274 $(FLAKE8) $(FLAKE8_FLAGS) $(flags) $(file)
275 $(PYLINT) $(PYLINT_FLAGS) --output-format=colorized $(flags) $(file)
276 $(PYLINT) $(PYLINT_FLAGS) --output-format=colorized --py3k $(flags) $(file)
278 # NOTE: flake8 is not part of "make check" because the pytest-flake8 plugin runs flake8
279 # checks during "make test" via pytest.
289 $(GIT) ls-files -- '*.py
' | \
291 $(XARGS) $(BLACK) --skip-string-normalization
293 # Run "make develop" from inside a newly created virtualenv to setup the build system
294 # using "python setup.py develop".
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) $(flags)
317 $(TOX) $(TOX_FLAGS) --parallel auto -e "$(TOX_ENVS)" $(flags)