##// END OF EJS Templates
make: add a pyoxidizer target...
Augie Fackler -
r46437:be6544a0 default
parent child Browse files
Show More
@@ -1,267 +1,272 b''
1 # If you want to change PREFIX, do not just edit it below. The changed
1 # If you want to change PREFIX, do not just edit it below. The changed
2 # value wont get passed on to recursive make calls. You should instead
2 # value wont get passed on to recursive make calls. You should instead
3 # override the variable on the command like:
3 # override the variable on the command like:
4 #
4 #
5 # % make PREFIX=/opt/ install
5 # % make PREFIX=/opt/ install
6
6
7 export PREFIX=/usr/local
7 export PREFIX=/usr/local
8
8
9 # Default to Python 3.
9 # Default to Python 3.
10 #
10 #
11 # Windows ships Python 3 as `python.exe`.
11 # Windows ships Python 3 as `python.exe`.
12 ifeq ($(OS),Windows_NT)
12 ifeq ($(OS),Windows_NT)
13 PYTHON?=python
13 PYTHON?=python
14 else
14 else
15 PYTHON?=python3
15 PYTHON?=python3
16 endif
16 endif
17
17
18 PYOXIDIZER?=pyoxidizer
19
18 $(eval HGROOT := $(shell pwd))
20 $(eval HGROOT := $(shell pwd))
19 HGPYTHONS ?= $(HGROOT)/build/pythons
21 HGPYTHONS ?= $(HGROOT)/build/pythons
20 PURE=
22 PURE=
21 PYFILESCMD=find mercurial hgext doc -name '*.py'
23 PYFILESCMD=find mercurial hgext doc -name '*.py'
22 PYFILES:=$(shell $(PYFILESCMD))
24 PYFILES:=$(shell $(PYFILESCMD))
23 DOCFILES=mercurial/helptext/*.txt
25 DOCFILES=mercurial/helptext/*.txt
24 export LANGUAGE=C
26 export LANGUAGE=C
25 export LC_ALL=C
27 export LC_ALL=C
26 TESTFLAGS ?= $(shell echo $$HGTESTFLAGS)
28 TESTFLAGS ?= $(shell echo $$HGTESTFLAGS)
27 OSXVERSIONFLAGS ?= $(shell echo $$OSXVERSIONFLAGS)
29 OSXVERSIONFLAGS ?= $(shell echo $$OSXVERSIONFLAGS)
28 CARGO = cargo
30 CARGO = cargo
29
31
30 # Set this to e.g. "mingw32" to use a non-default compiler.
32 # Set this to e.g. "mingw32" to use a non-default compiler.
31 COMPILER=
33 COMPILER=
32
34
33 COMPILERFLAG_tmp_ =
35 COMPILERFLAG_tmp_ =
34 COMPILERFLAG_tmp_${COMPILER} ?= -c $(COMPILER)
36 COMPILERFLAG_tmp_${COMPILER} ?= -c $(COMPILER)
35 COMPILERFLAG=${COMPILERFLAG_tmp_${COMPILER}}
37 COMPILERFLAG=${COMPILERFLAG_tmp_${COMPILER}}
36
38
37 help:
39 help:
38 @echo 'Commonly used make targets:'
40 @echo 'Commonly used make targets:'
39 @echo ' all - build program and documentation'
41 @echo ' all - build program and documentation'
40 @echo ' install - install program and man pages to $$PREFIX ($(PREFIX))'
42 @echo ' install - install program and man pages to $$PREFIX ($(PREFIX))'
41 @echo ' install-home - install with setup.py install --home=$$HOME ($(HOME))'
43 @echo ' install-home - install with setup.py install --home=$$HOME ($(HOME))'
42 @echo ' local - build for inplace usage'
44 @echo ' local - build for inplace usage'
43 @echo ' tests - run all tests in the automatic test suite'
45 @echo ' tests - run all tests in the automatic test suite'
44 @echo ' test-foo - run only specified tests (e.g. test-merge1.t)'
46 @echo ' test-foo - run only specified tests (e.g. test-merge1.t)'
45 @echo ' dist - run all tests and create a source tarball in dist/'
47 @echo ' dist - run all tests and create a source tarball in dist/'
46 @echo ' clean - remove files created by other targets'
48 @echo ' clean - remove files created by other targets'
47 @echo ' (except installed files or dist source tarball)'
49 @echo ' (except installed files or dist source tarball)'
48 @echo ' update-pot - update i18n/hg.pot'
50 @echo ' update-pot - update i18n/hg.pot'
49 @echo
51 @echo
50 @echo 'Example for a system-wide installation under /usr/local:'
52 @echo 'Example for a system-wide installation under /usr/local:'
51 @echo ' make all && su -c "make install" && hg version'
53 @echo ' make all && su -c "make install" && hg version'
52 @echo
54 @echo
53 @echo 'Example for a local installation (usable in this directory):'
55 @echo 'Example for a local installation (usable in this directory):'
54 @echo ' make local && ./hg version'
56 @echo ' make local && ./hg version'
55
57
56 all: build doc
58 all: build doc
57
59
58 local:
60 local:
59 $(PYTHON) setup.py $(PURE) \
61 $(PYTHON) setup.py $(PURE) \
60 build_py -c -d . \
62 build_py -c -d . \
61 build_ext $(COMPILERFLAG) -i \
63 build_ext $(COMPILERFLAG) -i \
62 build_hgexe $(COMPILERFLAG) -i \
64 build_hgexe $(COMPILERFLAG) -i \
63 build_mo
65 build_mo
64 env HGRCPATH= $(PYTHON) hg version
66 env HGRCPATH= $(PYTHON) hg version
65
67
66 build:
68 build:
67 $(PYTHON) setup.py $(PURE) build $(COMPILERFLAG)
69 $(PYTHON) setup.py $(PURE) build $(COMPILERFLAG)
68
70
69 wheel:
71 wheel:
70 FORCE_SETUPTOOLS=1 $(PYTHON) setup.py $(PURE) bdist_wheel $(COMPILERFLAG)
72 FORCE_SETUPTOOLS=1 $(PYTHON) setup.py $(PURE) bdist_wheel $(COMPILERFLAG)
71
73
72 doc:
74 doc:
73 $(MAKE) -C doc
75 $(MAKE) -C doc
74
76
75 cleanbutpackages:
77 cleanbutpackages:
76 rm -f hg.exe
78 rm -f hg.exe
77 -$(PYTHON) setup.py clean --all # ignore errors from this command
79 -$(PYTHON) setup.py clean --all # ignore errors from this command
78 find contrib doc hgext hgext3rd i18n mercurial tests hgdemandimport \
80 find contrib doc hgext hgext3rd i18n mercurial tests hgdemandimport \
79 \( -name '*.py[cdo]' -o -name '*.so' \) -exec rm -f '{}' ';'
81 \( -name '*.py[cdo]' -o -name '*.so' \) -exec rm -f '{}' ';'
80 rm -f MANIFEST MANIFEST.in hgext/__index__.py tests/*.err
82 rm -f MANIFEST MANIFEST.in hgext/__index__.py tests/*.err
81 rm -f mercurial/__modulepolicy__.py
83 rm -f mercurial/__modulepolicy__.py
82 if test -d .hg; then rm -f mercurial/__version__.py; fi
84 if test -d .hg; then rm -f mercurial/__version__.py; fi
83 rm -rf build mercurial/locale
85 rm -rf build mercurial/locale
84 $(MAKE) -C doc clean
86 $(MAKE) -C doc clean
85 $(MAKE) -C contrib/chg distclean
87 $(MAKE) -C contrib/chg distclean
86 rm -rf rust/target
88 rm -rf rust/target
87 rm -f mercurial/rustext.so
89 rm -f mercurial/rustext.so
88
90
89 clean: cleanbutpackages
91 clean: cleanbutpackages
90 rm -rf packages
92 rm -rf packages
91
93
92 install: install-bin install-doc
94 install: install-bin install-doc
93
95
94 install-bin: build
96 install-bin: build
95 $(PYTHON) setup.py $(PURE) install --root="$(DESTDIR)/" --prefix="$(PREFIX)" --force
97 $(PYTHON) setup.py $(PURE) install --root="$(DESTDIR)/" --prefix="$(PREFIX)" --force
96
98
97 install-doc: doc
99 install-doc: doc
98 cd doc && $(MAKE) $(MFLAGS) install
100 cd doc && $(MAKE) $(MFLAGS) install
99
101
100 install-home: install-home-bin install-home-doc
102 install-home: install-home-bin install-home-doc
101
103
102 install-home-bin: build
104 install-home-bin: build
103 $(PYTHON) setup.py $(PURE) install --home="$(HOME)" --prefix="" --force
105 $(PYTHON) setup.py $(PURE) install --home="$(HOME)" --prefix="" --force
104
106
105 install-home-doc: doc
107 install-home-doc: doc
106 cd doc && $(MAKE) $(MFLAGS) PREFIX="$(HOME)" install
108 cd doc && $(MAKE) $(MFLAGS) PREFIX="$(HOME)" install
107
109
108 MANIFEST-doc:
110 MANIFEST-doc:
109 $(MAKE) -C doc MANIFEST
111 $(MAKE) -C doc MANIFEST
110
112
111 MANIFEST.in: MANIFEST-doc
113 MANIFEST.in: MANIFEST-doc
112 hg manifest | sed -e 's/^/include /' > MANIFEST.in
114 hg manifest | sed -e 's/^/include /' > MANIFEST.in
113 echo include mercurial/__version__.py >> MANIFEST.in
115 echo include mercurial/__version__.py >> MANIFEST.in
114 sed -e 's/^/include /' < doc/MANIFEST >> MANIFEST.in
116 sed -e 's/^/include /' < doc/MANIFEST >> MANIFEST.in
115
117
116 dist: tests dist-notests
118 dist: tests dist-notests
117
119
118 dist-notests: doc MANIFEST.in
120 dist-notests: doc MANIFEST.in
119 TAR_OPTIONS="--owner=root --group=root --mode=u+w,go-w,a+rX-s" $(PYTHON) setup.py -q sdist
121 TAR_OPTIONS="--owner=root --group=root --mode=u+w,go-w,a+rX-s" $(PYTHON) setup.py -q sdist
120
122
121 check: tests
123 check: tests
122
124
123 tests:
125 tests:
124 # Run Rust tests if cargo is installed
126 # Run Rust tests if cargo is installed
125 if command -v $(CARGO) >/dev/null 2>&1; then \
127 if command -v $(CARGO) >/dev/null 2>&1; then \
126 $(MAKE) rust-tests; \
128 $(MAKE) rust-tests; \
127 fi
129 fi
128 cd tests && $(PYTHON) run-tests.py $(TESTFLAGS)
130 cd tests && $(PYTHON) run-tests.py $(TESTFLAGS)
129
131
130 test-%:
132 test-%:
131 cd tests && $(PYTHON) run-tests.py $(TESTFLAGS) $@
133 cd tests && $(PYTHON) run-tests.py $(TESTFLAGS) $@
132
134
133 testpy-%:
135 testpy-%:
134 @echo Looking for Python $* in $(HGPYTHONS)
136 @echo Looking for Python $* in $(HGPYTHONS)
135 [ -e $(HGPYTHONS)/$*/bin/python ] || ( \
137 [ -e $(HGPYTHONS)/$*/bin/python ] || ( \
136 cd $$(mktemp --directory --tmpdir) && \
138 cd $$(mktemp --directory --tmpdir) && \
137 $(MAKE) -f $(HGROOT)/contrib/Makefile.python PYTHONVER=$* PREFIX=$(HGPYTHONS)/$* python )
139 $(MAKE) -f $(HGROOT)/contrib/Makefile.python PYTHONVER=$* PREFIX=$(HGPYTHONS)/$* python )
138 cd tests && $(HGPYTHONS)/$*/bin/python run-tests.py $(TESTFLAGS)
140 cd tests && $(HGPYTHONS)/$*/bin/python run-tests.py $(TESTFLAGS)
139
141
140 rust-tests: py_feature = $(shell $(PYTHON) -c \
142 rust-tests: py_feature = $(shell $(PYTHON) -c \
141 'import sys; print(["python27-bin", "python3-bin"][sys.version_info[0] >= 3])')
143 'import sys; print(["python27-bin", "python3-bin"][sys.version_info[0] >= 3])')
142 rust-tests:
144 rust-tests:
143 cd $(HGROOT)/rust/hg-cpython \
145 cd $(HGROOT)/rust/hg-cpython \
144 && $(CARGO) test --quiet --all \
146 && $(CARGO) test --quiet --all \
145 --no-default-features --features "$(py_feature) $(HG_RUST_FEATURES)"
147 --no-default-features --features "$(py_feature) $(HG_RUST_FEATURES)"
146
148
147 check-code:
149 check-code:
148 hg manifest | xargs python contrib/check-code.py
150 hg manifest | xargs python contrib/check-code.py
149
151
150 format-c:
152 format-c:
151 clang-format --style file -i \
153 clang-format --style file -i \
152 `hg files 'set:(**.c or **.cc or **.h) and not "listfile:contrib/clang-format-ignorelist"'`
154 `hg files 'set:(**.c or **.cc or **.h) and not "listfile:contrib/clang-format-ignorelist"'`
153
155
154 update-pot: i18n/hg.pot
156 update-pot: i18n/hg.pot
155
157
156 i18n/hg.pot: $(PYFILES) $(DOCFILES) i18n/posplit i18n/hggettext
158 i18n/hg.pot: $(PYFILES) $(DOCFILES) i18n/posplit i18n/hggettext
157 $(PYTHON) i18n/hggettext mercurial/commands.py \
159 $(PYTHON) i18n/hggettext mercurial/commands.py \
158 hgext/*.py hgext/*/__init__.py \
160 hgext/*.py hgext/*/__init__.py \
159 mercurial/fileset.py mercurial/revset.py \
161 mercurial/fileset.py mercurial/revset.py \
160 mercurial/templatefilters.py \
162 mercurial/templatefilters.py \
161 mercurial/templatefuncs.py \
163 mercurial/templatefuncs.py \
162 mercurial/templatekw.py \
164 mercurial/templatekw.py \
163 mercurial/filemerge.py \
165 mercurial/filemerge.py \
164 mercurial/hgweb/webcommands.py \
166 mercurial/hgweb/webcommands.py \
165 mercurial/util.py \
167 mercurial/util.py \
166 $(DOCFILES) > i18n/hg.pot.tmp
168 $(DOCFILES) > i18n/hg.pot.tmp
167 # All strings marked for translation in Mercurial contain
169 # All strings marked for translation in Mercurial contain
168 # ASCII characters only. But some files contain string
170 # ASCII characters only. But some files contain string
169 # literals like this '\037\213'. xgettext thinks it has to
171 # literals like this '\037\213'. xgettext thinks it has to
170 # parse them even though they are not marked for translation.
172 # parse them even though they are not marked for translation.
171 # Extracting with an explicit encoding of ISO-8859-1 will make
173 # Extracting with an explicit encoding of ISO-8859-1 will make
172 # xgettext "parse" and ignore them.
174 # xgettext "parse" and ignore them.
173 $(PYFILESCMD) | xargs \
175 $(PYFILESCMD) | xargs \
174 xgettext --package-name "Mercurial" \
176 xgettext --package-name "Mercurial" \
175 --msgid-bugs-address "<mercurial-devel@mercurial-scm.org>" \
177 --msgid-bugs-address "<mercurial-devel@mercurial-scm.org>" \
176 --copyright-holder "Matt Mackall <mpm@selenic.com> and others" \
178 --copyright-holder "Matt Mackall <mpm@selenic.com> and others" \
177 --from-code ISO-8859-1 --join --sort-by-file --add-comments=i18n: \
179 --from-code ISO-8859-1 --join --sort-by-file --add-comments=i18n: \
178 -d hg -p i18n -o hg.pot.tmp
180 -d hg -p i18n -o hg.pot.tmp
179 $(PYTHON) i18n/posplit i18n/hg.pot.tmp
181 $(PYTHON) i18n/posplit i18n/hg.pot.tmp
180 # The target file is not created before the last step. So it never is in
182 # The target file is not created before the last step. So it never is in
181 # an intermediate state.
183 # an intermediate state.
182 mv -f i18n/hg.pot.tmp i18n/hg.pot
184 mv -f i18n/hg.pot.tmp i18n/hg.pot
183
185
184 %.po: i18n/hg.pot
186 %.po: i18n/hg.pot
185 # work on a temporary copy for never having a half completed target
187 # work on a temporary copy for never having a half completed target
186 cp $@ $@.tmp
188 cp $@ $@.tmp
187 msgmerge --no-location --update $@.tmp $^
189 msgmerge --no-location --update $@.tmp $^
188 mv -f $@.tmp $@
190 mv -f $@.tmp $@
189
191
190 # Packaging targets
192 # Packaging targets
191
193
192 packaging_targets := \
194 packaging_targets := \
193 centos5 \
195 centos5 \
194 centos6 \
196 centos6 \
195 centos7 \
197 centos7 \
196 centos8 \
198 centos8 \
197 deb \
199 deb \
198 docker-centos5 \
200 docker-centos5 \
199 docker-centos6 \
201 docker-centos6 \
200 docker-centos7 \
202 docker-centos7 \
201 docker-centos8 \
203 docker-centos8 \
202 docker-debian-bullseye \
204 docker-debian-bullseye \
203 docker-debian-buster \
205 docker-debian-buster \
204 docker-debian-stretch \
206 docker-debian-stretch \
205 docker-fedora \
207 docker-fedora \
206 docker-ubuntu-trusty \
208 docker-ubuntu-trusty \
207 docker-ubuntu-trusty-ppa \
209 docker-ubuntu-trusty-ppa \
208 docker-ubuntu-xenial \
210 docker-ubuntu-xenial \
209 docker-ubuntu-xenial-ppa \
211 docker-ubuntu-xenial-ppa \
210 docker-ubuntu-artful \
212 docker-ubuntu-artful \
211 docker-ubuntu-artful-ppa \
213 docker-ubuntu-artful-ppa \
212 docker-ubuntu-bionic \
214 docker-ubuntu-bionic \
213 docker-ubuntu-bionic-ppa \
215 docker-ubuntu-bionic-ppa \
214 fedora \
216 fedora \
215 linux-wheels \
217 linux-wheels \
216 linux-wheels-x86_64 \
218 linux-wheels-x86_64 \
217 linux-wheels-i686 \
219 linux-wheels-i686 \
218 ppa
220 ppa
219
221
220 # Forward packaging targets for convenience.
222 # Forward packaging targets for convenience.
221 $(packaging_targets):
223 $(packaging_targets):
222 $(MAKE) -C contrib/packaging $@
224 $(MAKE) -C contrib/packaging $@
223
225
224 osx:
226 osx:
225 rm -rf build/mercurial
227 rm -rf build/mercurial
226 /usr/bin/python2.7 setup.py install --optimize=1 \
228 /usr/bin/python2.7 setup.py install --optimize=1 \
227 --root=build/mercurial/ --prefix=/usr/local/ \
229 --root=build/mercurial/ --prefix=/usr/local/ \
228 --install-lib=/Library/Python/2.7/site-packages/
230 --install-lib=/Library/Python/2.7/site-packages/
229 make -C doc all install DESTDIR="$(PWD)/build/mercurial/"
231 make -C doc all install DESTDIR="$(PWD)/build/mercurial/"
230 # Place a bogon .DS_Store file in the target dir so we can be
232 # Place a bogon .DS_Store file in the target dir so we can be
231 # sure it doesn't get included in the final package.
233 # sure it doesn't get included in the final package.
232 touch build/mercurial/.DS_Store
234 touch build/mercurial/.DS_Store
233 # install zsh completions - this location appears to be
235 # install zsh completions - this location appears to be
234 # searched by default as of macOS Sierra.
236 # searched by default as of macOS Sierra.
235 install -d build/mercurial/usr/local/share/zsh/site-functions/
237 install -d build/mercurial/usr/local/share/zsh/site-functions/
236 install -m 0644 contrib/zsh_completion build/mercurial/usr/local/share/zsh/site-functions/_hg
238 install -m 0644 contrib/zsh_completion build/mercurial/usr/local/share/zsh/site-functions/_hg
237 # install bash completions - there doesn't appear to be a
239 # install bash completions - there doesn't appear to be a
238 # place that's searched by default for bash, so we'll follow
240 # place that's searched by default for bash, so we'll follow
239 # the lead of Apple's git install and just put it in a
241 # the lead of Apple's git install and just put it in a
240 # location of our own.
242 # location of our own.
241 install -d build/mercurial/usr/local/hg/contrib/
243 install -d build/mercurial/usr/local/hg/contrib/
242 install -m 0644 contrib/bash_completion build/mercurial/usr/local/hg/contrib/hg-completion.bash
244 install -m 0644 contrib/bash_completion build/mercurial/usr/local/hg/contrib/hg-completion.bash
243 make -C contrib/chg \
245 make -C contrib/chg \
244 HGPATH=/usr/local/bin/hg \
246 HGPATH=/usr/local/bin/hg \
245 PYTHON=/usr/bin/python2.7 \
247 PYTHON=/usr/bin/python2.7 \
246 DESTDIR=../../build/mercurial \
248 DESTDIR=../../build/mercurial \
247 PREFIX=/usr/local \
249 PREFIX=/usr/local \
248 clean install
250 clean install
249 mkdir -p $${OUTPUTDIR:-dist}
251 mkdir -p $${OUTPUTDIR:-dist}
250 HGVER=$$(python contrib/genosxversion.py $(OSXVERSIONFLAGS) build/mercurial/Library/Python/2.7/site-packages/mercurial/__version__.py) && \
252 HGVER=$$(python contrib/genosxversion.py $(OSXVERSIONFLAGS) build/mercurial/Library/Python/2.7/site-packages/mercurial/__version__.py) && \
251 OSXVER=$$(sw_vers -productVersion | cut -d. -f1,2) && \
253 OSXVER=$$(sw_vers -productVersion | cut -d. -f1,2) && \
252 pkgbuild --filter \\.DS_Store --root build/mercurial/ \
254 pkgbuild --filter \\.DS_Store --root build/mercurial/ \
253 --identifier org.mercurial-scm.mercurial \
255 --identifier org.mercurial-scm.mercurial \
254 --version "$${HGVER}" \
256 --version "$${HGVER}" \
255 build/mercurial.pkg && \
257 build/mercurial.pkg && \
256 productbuild --distribution contrib/packaging/macosx/distribution.xml \
258 productbuild --distribution contrib/packaging/macosx/distribution.xml \
257 --package-path build/ \
259 --package-path build/ \
258 --version "$${HGVER}" \
260 --version "$${HGVER}" \
259 --resources contrib/packaging/macosx/ \
261 --resources contrib/packaging/macosx/ \
260 "$${OUTPUTDIR:-dist/}"/Mercurial-"$${HGVER}"-macosx"$${OSXVER}".pkg
262 "$${OUTPUTDIR:-dist/}"/Mercurial-"$${HGVER}"-macosx"$${OSXVER}".pkg
261
263
264 pyoxidizer:
265 $(PYOXIDIZER) build --path ./rust/hgcli --release
266
262 .PHONY: help all local build doc cleanbutpackages clean install install-bin \
267 .PHONY: help all local build doc cleanbutpackages clean install install-bin \
263 install-doc install-home install-home-bin install-home-doc \
268 install-doc install-home install-home-bin install-home-doc \
264 dist dist-notests check tests rust-tests check-code format-c \
269 dist dist-notests check tests rust-tests check-code format-c \
265 update-pot \
270 update-pot pyoxidizer \
266 $(packaging_targets) \
271 $(packaging_targets) \
267 osx
272 osx
General Comments 0
You need to be logged in to leave comments. Login now