CHANGES: mention the use of an embedded progress bar
[git-cola.git] / Makefile
blobfd2c7356734dd3e421cbb0c8ad03a5c91c7d6a69
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 # 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>
17 # Release Prep
18 # ------------
19 # make pot # update main translation template
20 # make po # merge translations
21 # make i18n # make pot + make po
23 # Installation
24 # ------------
25 # make prefix=<path> install
26 # DESTDIR is also supported.
28 # The external commands used by this Makefile are...
29 CERCIS = cercis
30 CP = cp
31 FIND = find
32 GREP = grep
33 GIT = git
34 MARKDOWN = markdown
35 MSGMERGE = msgmerge
36 MKDIR_P = mkdir -p
37 PIP = pip
38 PYTHON ?= python
39 PYTHON3 ?= python3
40 PYLINT = $(PYTHON) -B -m pylint
41 PYTEST = $(PYTHON) -B -m pytest
42 RM = rm -f
43 RM_R = rm -fr
44 RMDIR = rmdir
45 TAR = tar
46 TOX = tox
47 XARGS = xargs
48 XGETTEXT = xgettext
50 # Flags
51 # -----
52 ifdef V
53 VERBOSE = --verbose
54 ifeq ($(V),2)
55 TEST_VERBOSE = --verbose
56 VERBOSE_SHORT = -vv
57 else
58 VERBOSE_SHORT = -v
59 endif
60 else
61 QUIET = --quiet
62 endif
64 PYTEST_FLAGS = $(QUIET) $(TEST_VERBOSE)
65 uname_S := $(shell uname -s)
66 ifneq ($(uname_S),Linux)
67 PYTEST_FLAGS += --ignore=cola/inotify.py
68 endif
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
75 ifdef color
76 PYLINT_FLAGS += --output-format=colorized
77 endif
78 ifneq ($(PYLINT_SCORE_FLAGSCORE),)
79 PYLINT_FLAGS += $(PYLINT_SCORE_FLAG)
80 endif
82 # These values can be overridden on the command-line or via config.mak
83 prefix = $(HOME)
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)
87 # DESTDIR =
89 cola_base := git-cola
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)
99 install_args =
100 ifdef DESTDIR
101 install_args += --root="$(DESTDIR)"
102 export DESTDIR
103 endif
104 install_args += --prefix="$(prefix)"
105 install_args += --disable-pip-version-check
106 export prefix
108 PYTHON_DIRS = cola
109 PYTHON_DIRS += test
111 ALL_PYTHON_DIRS = $(PYTHON_DIRS)
113 # User customizations
114 -include config.mak
116 all::
118 .PHONY: install
119 install:: all
120 $(PIP) $(QUIET) $(VERBOSE) install $(install_args) .
122 .PHONY: doc
123 doc::
124 $(MAKE) -C docs all
126 .PHONY: html
127 html::
128 $(MAKE) -C docs html
130 .PHONY: man
131 man::
132 $(MAKE) -C docs man
134 .PHONY: install-doc
135 install-doc::
136 $(MAKE) -C docs install
138 .PHONY: install-html
139 install-html::
140 $(MAKE) -C docs install-html
142 .PHONY: install-man
143 install-man::
144 $(MAKE) -C docs install-man
146 .PHONY: uninstall
147 uninstall::
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
173 .PHONY: test
174 test::
175 $(PYTEST) $(PYTEST_FLAGS) $(flags) $(PYTHON_DIRS)
177 .PHONY: coverage
178 coverage::
179 $(PYTEST) $(PYTEST_FLAGS) --cov=cola $(flags) $(PYTHON_DIRS)
181 .PHONY: clean
182 clean::
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 git-cola.app
186 $(MAKE) -C docs clean
188 # Update i18n files
189 .PHONY: i18n
190 i18n:: pot
191 i18n:: po
193 # Regenerate git-cola.pot with new translations
194 .PHONY: pot
195 pot::
196 $(XGETTEXT) \
197 --language=Python \
198 --keyword=N_ \
199 --no-wrap \
200 --omit-header \
201 --sort-output \
202 --output-dir cola/i18n \
203 --output git-cola.pot \
204 cola/*.py \
205 cola/*/*.py
207 # Update .po files with new translations from git-cola.pot
208 .PHONY: po
209 po::
210 for po in cola/i18n/*.po; \
211 do \
212 $(MSGMERGE) \
213 --no-wrap \
214 --no-fuzzy-matching \
215 --sort-output \
216 --output-file $$po.new \
217 $$po \
218 cola/i18n/git-cola.pot \
219 && \
220 mv $$po.new $$po; \
222 done
224 # Build a git-cola.app bundle.
225 .PHONY: git-cola.app
226 git-cola.app::
227 cola_full_version := $(shell ./bin/git-cola version --brief)
229 git-cola.app::
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
240 endif
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
249 .PHONY: app-tarball
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"
254 %.html: %.md
255 $(MARKDOWN) $< >$@
257 .PHONY: pylint
258 pylint::
259 $(PYLINT) --version
260 $(PYLINT) $(PYLINT_FLAGS) $(flags) \
261 $(ALL_PYTHON_DIRS)
263 # Pre-commit checks
264 .PHONY: check
265 ifdef file
266 check::
267 $(PYLINT) $(PYLINT_FLAGS) --output-format=colorized $(flags) $(file)
268 else
269 check:: all
270 check:: test
271 check:: doc
272 check:: pylint
273 endif
275 .PHONY: fmt
276 fmt::
277 $(GIT) ls-files -- '*.py' | \
278 $(GREP) -v ^qtpy | \
279 $(XARGS) $(CERCIS)
281 # Run "make develop" from inside a newly created virtualenv to create an
282 # editable installation.
283 .PHONY: develop
284 develop::
285 $(PIP) install --editable .
287 .PHONY: requirements
288 requirements::
289 $(PIP) install --requirement requirements/requirements.txt
291 .PHONY: requirements-dev
292 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
299 .PHONY: tox
300 tox::
301 $(TOX) $(TOX_FLAGS) --parallel auto -e "${TOX_ENVS}" $(flags)
303 .PHONY: tox-check
304 tox-check::
305 $(TOX) $(TOX_FLAGS) --parallel auto -e check $(flags)