sequenceeditor: self.diffwidget -> self.diff typofix
[git-cola.git] / Makefile
blob1ebc351584854948fef3c4a58f6fb31020b1f9ec
1 # The default target of this Makefile is...
2 .PHONY: all
3 all::
5 # Development
6 # -----------
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>
19 # Release Prep
20 # ------------
21 # make pot # update main translation template
22 # make po # merge translations
23 # make i18n # make pot + make po
25 # Installation
26 # ------------
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
32 # when invoking make.
34 # The external commands used by this Makefile are...
35 BLACK = black
36 CP = cp
37 FIND = find
38 FLAKE8 = flake8
39 GREP = grep
40 GIT = git
41 MARKDOWN = markdown
42 MSGMERGE = msgmerge
43 MKDIR_P = mkdir -p
44 PIP = pip
45 PYTHON ?= python
46 PYLINT = $(PYTHON) -B -m pylint
47 PYTEST = $(PYTHON) -B -m pytest
48 RM = rm -f
49 RM_R = rm -fr
50 RMDIR = rmdir
51 TAR = tar
52 TOX = tox
53 XARGS = xargs
54 XGETTEXT = xgettext
56 # Flags
57 # -----
58 ifdef V
59 VERBOSE = --verbose
60 ifeq ($(V),2)
61 TEST_VERBOSE = --verbose
62 VERBOSE_SHORT = -vv
63 else
64 VERBOSE_SHORT = -v
65 endif
66 else
67 QUIET = --quiet
68 endif
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
76 endif
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
83 ifdef color
84 PYLINT_FLAGS += --output-format=colorized
85 endif
86 ifneq ($(PYLINT_SCORE_FLAGSCORE),)
87 PYLINT_FLAGS += $(PYLINT_SCORE_FLAG)
88 endif
90 # These values can be overridden on the command-line or via config.mak
91 prefix = $(HOME)
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)
95 # DESTDIR =
97 cola_base := git-cola
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)
106 install_args =
107 ifdef DESTDIR
108 install_args += --root="$(DESTDIR)"
109 export DESTDIR
110 endif
111 install_args += --prefix="$(prefix)"
112 export prefix
114 PYTHON_DIRS = cola
115 PYTHON_DIRS += test
117 ALL_PYTHON_DIRS = $(PYTHON_DIRS)
119 # User customizations
120 -include config.mak
122 all::
124 .PHONY: install
125 install:: all
126 $(PIP) $(QUIET) $(VERBOSE) install $(install_args) .
128 .PHONY: doc
129 doc::
130 $(MAKE) -C share/doc/git-cola all
132 .PHONY: html
133 html::
134 $(MAKE) -C share/doc/git-cola html
136 .PHONY: man
137 man::
138 $(MAKE) -C share/doc/git-cola man
140 .PHONY: install-doc
141 install-doc::
142 $(MAKE) -C share/doc/git-cola install
144 .PHONY: install-html
145 install-html::
146 $(MAKE) -C share/doc/git-cola install-html
148 .PHONY: install-man
149 install-man::
150 $(MAKE) -C share/doc/git-cola install-man
152 .PHONY: uninstall
153 uninstall::
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
182 .PHONY: test
183 test::
184 $(PYTEST) $(PYTEST_FLAGS) $(flags) $(PYTHON_DIRS)
186 .PHONY: coverage
187 coverage::
188 $(PYTEST) $(PYTEST_FLAGS) --cov=cola $(flags) $(PYTHON_DIRS)
190 .PHONY: clean
191 clean::
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
197 # Update i18n files
198 .PHONY: i18n
199 i18n:: pot
200 i18n:: po
202 # Regenerate git-cola.pot with new translations
203 .PHONY: pot
204 pot::
205 $(XGETTEXT) \
206 --language=Python \
207 --keyword=N_ \
208 --no-wrap \
209 --no-location \
210 --omit-header \
211 --sort-output \
212 --output-dir cola/i18n \
213 --output git-cola.pot \
214 cola/*.py \
215 cola/*/*.py
217 # Update .po files with new translations from git-cola.pot
218 .PHONY: po
219 po::
220 for po in cola/i18n/*.po; \
221 do \
222 $(MSGMERGE) \
223 --no-location \
224 --no-wrap \
225 --no-fuzzy-matching \
226 --sort-output \
227 --output-file $$po.new \
228 $$po \
229 cola/i18n/git-cola.pot \
230 && \
231 mv $$po.new $$po; \
233 done
235 .PHONY: git-cola.app
236 git-cola.app::
237 $(MKDIR_P) $(cola_app)/Contents/MacOS
238 $(MKDIR_P) $(cola_app)/Contents/Resources
239 $(CP) contrib/darwin/Info.plist contrib/darwin/PkgInfo \
240 $(cola_app)/Contents
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
245 .PHONY: app-tarball
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"
250 %.html: %.md
251 $(MARKDOWN) $< >$@
253 .PHONY: flake8
254 flake8::
255 $(FLAKE8) --version
256 $(FLAKE8) $(FLAKE8_FLAGS) $(flags) \
257 $(ALL_PYTHON_DIRS) contrib
259 .PHONY: pylint3k
260 pylint3k::
261 $(PYLINT) --version
262 $(PYLINT) $(PYLINT_FLAGS) --py3k $(flags) \
263 $(ALL_PYTHON_DIRS)
265 .PHONY: pylint
266 pylint::
267 $(PYLINT) --version
268 $(PYLINT) $(PYLINT_FLAGS) $(flags) \
269 $(ALL_PYTHON_DIRS)
271 # Pre-commit checks
272 .PHONY: check
273 ifdef file
274 check::
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)
278 else
279 # NOTE: flake8 is not part of "make check" because the pytest-flake8 plugin runs flake8
280 # checks during "make test" via pytest.
281 check:: all
282 check:: test
283 check:: doc
284 check:: pylint3k
285 check:: pylint
286 endif
288 .PHONY: format
289 format::
290 $(GIT) ls-files -- '*.py' | \
291 $(GREP) -v ^qtpy | \
292 $(XARGS) $(BLACK) --skip-string-normalization
294 # Run "make develop" from inside a newly created virtualenv to create an
295 # editable installation.
296 .PHONY: develop
297 develop::
298 $(PIP) install --editable .
300 .PHONY: requirements
301 requirements::
302 $(PIP) install --requirement requirements/requirements.txt
304 .PHONY: requirements-dev
305 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
312 .PHONY: tox
313 tox::
314 $(TOX) $(TOX_FLAGS) $(flags)
316 .PHONY: tox-check
317 tox-check::
318 $(TOX) $(TOX_FLAGS) --parallel auto -e "$(TOX_ENVS)" $(flags)