1 # The default target of this Makefile is...
6 # make V=1 # generate files; V=1 increases verbosity
7 # make test [flags=...] # run tests; flags=-x fails fast, --ff failed first
8 # make test V=2 # V=2 increases test verbosity
9 # make doc # build docs
10 # make flake8 # python style checks
11 # make pylint [color=1] # run pylint; color=1 colorizes output
12 # make pylint3k [color=1] # run python2+3 compatibility checks
13 # make format # run the black python formatter
14 # make check [color=1] # run test, doc, flake8, pylint3k, 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 mo # generate message files
22 # make i18n # all three of the above
26 # make prefix=<path> install
27 # DESTDIR is also supported.
29 # To disable distutil's replacement of "#!/usr/bin/env python" with
30 # the path to the build environment's python, pass USE_ENV_PYTHON=1
33 # The external commands used by this Makefile are...
48 PYLINT
= $(PYTHON
) -B
-m pylint
49 PYTEST
= $(PYTHON
) -B
-m pytest
62 TEST_VERBOSE
= --verbose
71 FLAKE8_FLAGS
= $(VERBOSE
)
73 PYTEST_FLAGS
= $(QUIET
) $(TEST_VERBOSE
)
74 uname_S
:= $(shell uname
-s
)
75 ifneq ($(uname_S
),Linux
)
76 PYTEST_FLAGS
+= --ignore
=cola
/inotify.py
79 TOX_FLAGS
= $(VERBOSE_SHORT
) --develop
--skip-missing-interpreters
80 TOX_ENVS ?
= py
{27,36,37,38,39,lint
}
82 PYLINT_SCORE_FLAG
:= $(shell $(PYLINT
) --score
=no
--help
>/dev
/null
2>&1 && echo
" --score=no" || true
)
83 PYLINT_FLAGS
= --rcfile
=.pylintrc
85 PYLINT_FLAGS
+= --output-format
=colorized
87 ifneq ($(PYLINT_SCORE_FLAGSCORE
),)
88 PYLINT_FLAGS
+= $(PYLINT_SCORE_FLAG
)
91 # These values can be overridden on the command-line or via config.mak
93 bindir = $(prefix)/bin
94 python_code
:= "import sys; print('%s.%s' % (sys.version_info[0], sys.version_info[1]))"
95 python_version
:= $(shell $(PYTHON
) -c
$(python_code
))
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 build_args += --use-env-python
116 install_args += install
118 install_args += --root="$(DESTDIR)"
121 install_args += --prefix="$(prefix)"
122 install_args += --install-scripts="$(bindir)"
123 install_args += --single-version-externally-managed
124 install_args += --record=build/MANIFEST
130 ALL_PYTHON_DIRS = $(PYTHON_DIRS)
131 ALL_PYTHON_DIRS += extras
133 # User customizations
141 $(SETUP) $(QUIET) $(VERBOSE) $(build_args)
145 $(SETUP) $(QUIET) $(VERBOSE) $(install_args)
149 $(MAKE) -C share/doc/git-cola all
153 $(MAKE) -C share/doc/git-cola html
157 $(MAKE) -C share/doc/git-cola man
161 $(MAKE) -C share/doc/git-cola install
165 $(MAKE) -C share/doc/git-cola install-html
169 $(MAKE) -C share/doc/git-cola install-man
173 $(RM) "$(DESTDIR)$(prefix)"/bin/git-cola
174 $(RM) "$(DESTDIR)$(prefix)"/bin/git-cola-sequence-editor
175 $(RM) "$(DESTDIR)$(prefix)"/bin/git-dag
176 $(RM) "$(DESTDIR)$(prefix)"/bin/cola
177 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-cola.desktop
178 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-cola-folder-handler.desktop
179 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-dag.desktop
180 $(RM) "$(DESTDIR)$(prefix)"/share/metainfo/git-dag.appdata.xml
181 $(RM) "$(DESTDIR)$(prefix)"/share/metainfo/git-cola.appdata.xml
182 $(RM) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable/apps/git-cola.svg
183 $(RM_R) "$(DESTDIR)$(prefix)"/share/doc/git-cola
184 $(RM_R) "$(DESTDIR)$(prefix)"/share/git-cola
185 $(RM) "$(DESTDIR)$(prefix)"/share/locale/*/LC_MESSAGES/git-cola.mo
186 $(RM_R) "$(DESTDIR)$(pythondir)"/git_cola-*
187 $(RM_R) "$(DESTDIR)$(pythondir)"/cola
188 $(RMDIR) -p "$(DESTDIR)$(pythondir)" 2>/dev/null || true
189 $(RMDIR) "$(DESTDIR)$(prefix)"/share/applications 2>/dev/null || true
190 $(RMDIR) "$(DESTDIR)$(prefix)"/share/metainfo 2>/dev/null || true
191 $(RMDIR) "$(DESTDIR)$(prefix)"/share/doc 2>/dev/null || true
192 $(RMDIR) "$(DESTDIR)$(prefix)"/share/locale/*/LC_MESSAGES 2>/dev/null || true
193 $(RMDIR) "$(DESTDIR)$(prefix)"/share/locale/* 2>/dev/null || true
194 $(RMDIR) "$(DESTDIR)$(prefix)"/share/locale 2>/dev/null || true
195 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable/apps 2>/dev/null || true
196 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable 2>/dev/null || true
197 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor 2>/dev/null || true
198 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons 2>/dev/null || true
199 $(RMDIR) "$(DESTDIR)$(prefix)"/share 2>/dev/null || true
200 $(RMDIR) "$(DESTDIR)$(prefix)"/bin 2>/dev/null || true
201 $(RMDIR) "$(DESTDIR)$(prefix)" 2>/dev/null || true
205 $(PYTEST) $(PYTEST_FLAGS) $(flags) $(PYTHON_DIRS)
209 $(PYTEST) $(PYTEST_FLAGS) --cov=cola $(flags) $(PYTHON_DIRS)
213 $(FIND) $(ALL_PYTHON_DIRS) -name '*.py
[cod
]' -print0 | $(XARGS) -0 $(RM)
214 $(FIND) $(ALL_PYTHON_DIRS) -name __pycache__ -print0 | $(XARGS) -0 $(RM_R)
215 $(RM_R) build dist tags git-cola.app
217 $(MAKE) -C share/doc/git-cola clean
227 $(SETUP) build_pot --build-dir=po --no-lang
231 $(SETUP) build_pot --build-dir=po
235 $(SETUP) build_mo --force
239 $(MKDIR_P) $(cola_app)/Contents/MacOS
240 $(MKDIR_P) $(cola_app)/Contents/Resources
241 $(CP) contrib/darwin/Info.plist contrib/darwin/PkgInfo \
243 $(CP) contrib/darwin/git-cola $(cola_app)/Contents/MacOS
244 $(CP) contrib/darwin/git-cola.icns $(cola_app)/Contents/Resources
245 $(MAKE) prefix=$(cola_app)/Contents/Resources install install-doc
248 app-tarball:: git-cola.app
249 $(TAR) czf $(cola_dist).app.tar.gz $(cola_app_base)
251 # Preview the markdown using "make README.html"
258 $(FLAKE8) $(FLAKE8_FLAGS) $(flags) \
259 $(ALL_PYTHON_DIRS) contrib
264 $(PYLINT) $(PYLINT_FLAGS) --py3k $(flags) \
270 $(PYLINT) $(PYLINT_FLAGS) $(flags) \
277 $(FLAKE8) $(FLAKE8_FLAGS) $(flags) $(file)
278 $(PYLINT) $(PYLINT_FLAGS) --output-format=colorized $(flags) $(file)
279 $(PYLINT) $(PYLINT_FLAGS) --output-format=colorized --py3k $(flags) $(file)
281 # NOTE: flake8 is not part of "make check" because the pytest-flake8 plugin runs flake8
282 # checks during "make test" via pytest.
292 $(GIT) ls-files -- '*.py
' | \
294 $(XARGS) $(BLACK) --skip-string-normalization
296 .PHONY: requirements-dev
298 $(PIP) install --requirement requirements/requirements-dev.txt
300 .PHONY: requirements-optional
301 requirements-optional::
302 $(PIP) install --requirement requirements/requirements-optional.txt
306 $(TOX) $(TOX_FLAGS) $(flags)
310 $(TOX) $(TOX_FLAGS) --parallel auto -e "$(TOX_ENVS)" $(flags)