Makefile 10.1 KB
Newer Older
1
PYTHON=$(shell which python 2>/dev/null || which python3 2>/dev/null)
2
PYTHON_DEVELOP_ARGS=$(shell if ($(PYTHON) setup.py develop --help 2>/dev/null | grep -q '\-\-user'); then echo "--user"; else echo ""; fi)
3
VERSION=$(shell $(PYTHON) setup.py --version 2>/dev/null)
4
DESTDIR=/
L
Lukáš Doktor 已提交
5
AVOCADO_DIRNAME=$(shell echo $${PWD\#\#*/})
6
AVOCADO_EXTERNAL_PLUGINS=$(filter-out ../$(AVOCADO_DIRNAME), $(shell find ../ -maxdepth 1 -mindepth 1 -type d))
7 8 9 10 11 12 13 14
# List of optional plugins that have to be in setup in a giver order
# because there may be depedencies between plugins
AVOCADO_OPTIONAL_PLUGINS_ORDERED="./optional_plugins/runner_remote"
# Other optional plugins found in "optional_plugins" directory
AVOCADO_OPTIONAL_PLUGINS_OTHERS=$(shell find ./optional_plugins -maxdepth 1 -mindepth 1 -type d)
# Unique list of optional plugins
AVOCADO_OPTIONAL_PLUGINS=$(shell (echo "$(AVOCADO_OPTIONAL_PLUGINS_ORDERED) $(AVOCADO_OPTIONAL_PLUGINS_OTHERS)" | tr ' ' '\n' | awk '!a[$$0]++'))
AVOCADO_PLUGINS=$(AVOCADO_OPTIONAL_PLUGINS) $(AVOCADO_EXTERNAL_PLUGINS)
15 16 17
RELEASE_COMMIT=$(shell git log --pretty=format:'%H' -n 1 $(VERSION))
RELEASE_SHORT_COMMIT=$(shell git log --pretty=format:'%h' -n 1 $(VERSION))
COMMIT=$(shell git log --pretty=format:'%H' -n 1)
18
COMMIT_DATE=$(shell git log --pretty='format:%cd' --date='format:%Y%m%d' -n 1)
19
SHORT_COMMIT=$(shell git log --pretty=format:'%h' -n 1)
20
MOCK_CONFIG=default
21 22

all:
23
	@echo
C
Cleber Rosa 已提交
24
	@echo "Development related targets:"
25 26
	@echo "check:          Runs tree static check, unittests and fast functional tests"
	@echo "check-full:     Runs tree static check, and all unittests and functional tests"
P
P.-H. Lin 已提交
27
	@echo "develop:        Runs 'python setup.py --develop' on this tree alone"
28 29 30 31
	@echo "link:           Runs 'python setup.py --develop' in all subprojects and links the needed resources"
	@echo "clean:          Get rid of scratch, byte files and removes the links to other subprojects"
	@echo "selfcheck:      Runs tree static check, unittests and functional tests using Avocado itself"
	@echo "spell:          Runs spell checker on comments and docstrings (requires python-enchant)"
C
Cleber Rosa 已提交
32
	@echo
33 34 35
	@echo "Package requirements related targets"
	@echo "requirements:            Install runtime requirements"
	@echo "requirements-selftests:  Install runtime and selftests requirements"
36
	@echo "requirements-plugins:    Install plugins requirements"
37
	@echo
P
P.-H. Lin 已提交
38
	@echo "Platform independent distribution/installation related targets:"
39 40 41 42 43 44 45 46
	@echo "source:   Create source package"
	@echo "install:  Install on local system"
	@echo "man:      Generate the avocado man page"
	@echo
	@echo "RPM related targets:"
	@echo "srpm:  Generate a source RPM package (.srpm)"
	@echo "rpm:   Generate binary RPMs"
	@echo
47
	@echo "Release related targets:"
48 49 50 51
	@echo "source-release:     Create source package for the latest tagged release"
	@echo "srpm-release:       Generate a source RPM package (.srpm) for the latest tagged release"
	@echo "rpm-release:        Generate binary RPMs for the latest tagged release"
	@echo "propagate-version:  Propagate './VERSION' to all plugins/modules"
52
	@echo
53 54 55

source: clean
	if test ! -d SOURCES; then mkdir SOURCES; fi
56
	git archive --prefix="avocado-$(COMMIT)/" -o "SOURCES/avocado-$(SHORT_COMMIT).tar.gz" HEAD
57

58
source-release: clean
59
	if test ! -d SOURCES; then mkdir SOURCES; fi
60
	git archive --prefix="avocado-$(VERSION)/" -o "SOURCES/avocado-$(VERSION).tar.gz" $(VERSION)
61

62 63
source-pypi: clean
	if test ! -d PYPI_UPLOAD; then mkdir PYPI_UPLOAD; fi
64
	git archive --format="tar" --prefix="avocado-framework/" $(VERSION) | tar --file - --delete 'avocado-framework/optional_plugins' > "PYPI_UPLOAD/avocado-framework-$(VERSION).tar"
65 66 67 68 69 70 71 72
	for PLUGIN in $(AVOCADO_OPTIONAL_PLUGINS); do\
		if test -f $$PLUGIN/setup.py; then\
			echo ">> Creating source distribution for $$PLUGIN";\
			cd $$PLUGIN;\
			$(PYTHON) setup.py sdist -d ../../PYPI_UPLOAD;\
			cd -;\
                fi;\
	done
73

74 75 76 77 78 79 80 81 82 83 84 85 86
wheel: clean
	if test ! -d PYPI_UPLOAD; then mkdir PYPI_UPLOAD; fi
	$(PYTHON) setup.py bdist_wheel -d PYPI_UPLOAD
	for PLUGIN in $(AVOCADO_OPTIONAL_PLUGINS); do\
		if test -f $$PLUGIN/setup.py; then\
			echo ">> Creating wheel distribution for $$PLUGIN";\
			cd $$PLUGIN;\
			$(PYTHON) setup.py bdist_wheel -d ../../PYPI_UPLOAD;\
			cd -;\
                fi;\
	done

pypi: wheel source-pypi develop
87 88 89 90 91 92
	mkdir PYPI_UPLOAD/avocado-framework
	cp avocado_framework.egg-info/PKG-INFO PYPI_UPLOAD/avocado-framework
	tar rf "PYPI_UPLOAD/avocado-framework-$(VERSION).tar" -C PYPI_UPLOAD avocado-framework/PKG-INFO
	gzip -9 "PYPI_UPLOAD/avocado-framework-$(VERSION).tar"
	rm -f PYPI_UPLOAD/avocado-framework/PKG-INFO
	rmdir PYPI_UPLOAD/avocado-framework
93 94 95 96 97
	@echo
	@echo "Please use the files on PYPI_UPLOAD dir to upload a new version to PyPI"
	@echo "The URL to do that may be a bit tricky to find, so here it is:"
	@echo " https://pypi.python.org/pypi?%3Aaction=submit_form"
	@echo
98
	@echo "Alternatively, you can also run a command like: "
99
	@echo " twine upload -u <PYPI_USERNAME> PYPI_UPLOAD/*.{tar.gz,whl}"
100
	@echo
101

102 103 104
install:
	$(PYTHON) setup.py install --root $(DESTDIR) $(COMPILE)

105 106
srpm: source
	if test ! -d BUILD/SRPM; then mkdir -p BUILD/SRPM; fi
107
	mock --old-chroot -r $(MOCK_CONFIG) --resultdir BUILD/SRPM -D "rel_build 0" -D "commit $(COMMIT)" -D "commit_date $(COMMIT_DATE)" --buildsrpm --spec python-avocado.spec --sources SOURCES
108 109 110

rpm: srpm
	if test ! -d BUILD/RPM; then mkdir -p BUILD/RPM; fi
111
	mock --old-chroot -r $(MOCK_CONFIG) --resultdir BUILD/RPM -D "rel_build 0" -D "commit $(COMMIT)" -D "commit_date $(COMMIT_DATE)" --rebuild BUILD/SRPM/python-avocado-$(VERSION)-*.src.rpm
112 113 114

srpm-release: source-release
	if test ! -d BUILD/SRPM; then mkdir -p BUILD/SRPM; fi
115
	mock --old-chroot -r $(MOCK_CONFIG) --resultdir BUILD/SRPM -D "rel_build 1" --buildsrpm --spec python-avocado.spec --sources SOURCES
C
Cleber Rosa 已提交
116

117 118
rpm-release: srpm-release
	if test ! -d BUILD/RPM; then mkdir -p BUILD/RPM; fi
119
	mock --old-chroot -r $(MOCK_CONFIG) --resultdir BUILD/RPM -D "rel_build 1" --rebuild BUILD/SRPM/python-avocado-$(VERSION)-*.src.rpm
120

121 122
clean:
	$(PYTHON) setup.py clean
123
	$(MAKE) -f $(CURDIR)/debian/rules clean || true
124
	rm -rf build/ MANIFEST BUILD BUILDROOT SPECS RPMS SRPMS SOURCES PYPI_UPLOAD
125
	rm -f man/avocado.1
126
	rm -f man/avocado-rest-client.1
127
	rm -rf docs/build
128
	find docs/source/api/ -name '*.rst' -delete
129
	for MAKEFILE in $(AVOCADO_PLUGINS); do\
130
		if test -f $$MAKEFILE/Makefile -o -f $$MAKEFILE/setup.py; then echo ">> UNLINK $$MAKEFILE";\
131
			if test -f $$MAKEFILE/Makefile; then AVOCADO_DIRNAME=$(AVOCADO_DIRNAME) make -C $$MAKEFILE unlink &>/dev/null || echo ">> FAIL $$MAKEFILE";\
132
			elif test -f $$MAKEFILE/setup.py; then cd $$MAKEFILE; $(PYTHON) setup.py develop --uninstall $(PYTHON_DEVELOP_ARGS); cd -; fi;\
133
		else echo ">> SKIP $$MAKEFILE"; fi;\
134
	done
135
	$(PYTHON) setup.py develop --uninstall $(PYTHON_DEVELOP_ARGS)
L
Lukáš Doktor 已提交
136
	rm -rf avocado_framework.egg-info
137 138
	rm -rf /var/tmp/avocado*
	rm -rf /tmp/avocado*
139
	find . -name '*.pyc' -delete
140
	find $(AVOCADO_OPTIONAL_PLUGINS) -name '*.egg-info' -exec rm -r {} +
141

142 143 144 145
pip:
	$(PYTHON) -m pip --version || $(PYTHON) -c "import os; import sys; import urllib; f = urllib.urlretrieve('https://bootstrap.pypa.io/get-pip.py')[0]; os.system('%s %s' % (sys.executable, f))"

requirements: pip
L
Lukáš Doktor 已提交
146
	- pip install "pip>=6.0.1"
147
	- pip install -r requirements.txt
148

149
requirements-selftests: requirements
150
	- pip install -r requirements-selftests.txt
151

152
requirements-plugins: requirements
153 154 155 156 157 158
	for MAKEFILE in $(AVOCADO_PLUGINS);do\
		if test -f $$MAKEFILE/Makefile; then echo ">> REQUIREMENTS (Makefile) $$MAKEFILE"; AVOCADO_DIRNAME=$(AVOCADO_DIRNAME) make -C $$MAKEFILE requirement &>/dev/null;\
		elif test -f $$MAKEFILE/requirements.txt; then echo ">> REQUIREMENTS (requirements.txt) $$MAKEFILE"; pip install $(PYTHON_DEVELOP_ARGS) -r $$MAKEFILE/requirements.txt;\
		else echo ">> SKIP $$MAKEFILE";\
		fi;\
	done;
159

160
smokecheck: clean develop
161
	./scripts/avocado run passtest.py
162

163
check: clean develop check_cyclical modules_boundaries
164
	# Unless manually set, this is equivalent to AVOCADO_CHECK_LEVEL=0
165
	selftests/checkall
166
	selftests/check_tmp_dirs
167

168
check-full: clean develop check_cyclical modules_boundaries
169
	AVOCADO_CHECK_LEVEL=2 selftests/checkall
170 171
	selftests/check_tmp_dirs

172
selfcheck: clean check_cyclical modules_boundaries develop
173 174 175
	AVOCADO_SELF_CHECK=1 selftests/checkall
	selftests/check_tmp_dirs

176 177 178
check_cyclical:
	selftests/cyclical_deps avocado

179 180 181
modules_boundaries:
	selftests/modules_boundaries

182
develop:
183
	$(PYTHON) setup.py develop $(PYTHON_DEVELOP_ARGS)
184 185 186
	for MAKEFILE in $(AVOCADO_OPTIONAL_PLUGINS); do\
		if test -f $$MAKEFILE/Makefile -o -f $$MAKEFILE/setup.py; then echo ">> LINK $$MAKEFILE";\
			if test -f $$MAKEFILE/Makefile; then AVOCADO_DIRNAME=$(AVOCADO_DIRNAME) make -C $$MAKEFILE link &>/dev/null;\
187
			elif test -f $$MAKEFILE/setup.py; then cd $$MAKEFILE; $(PYTHON) setup.py develop $(PYTHON_DEVELOP_ARGS); cd -; fi;\
188 189
		else echo ">> SKIP $$MAKEFILE"; fi;\
	done
190 191

link: develop
192
	for MAKEFILE in $(AVOCADO_EXTERNAL_PLUGINS); do\
193
		if test -f $$MAKEFILE/Makefile -o -f $$MAKEFILE/setup.py; then echo ">> LINK $$MAKEFILE";\
194
			if test -f $$MAKEFILE/Makefile; then AVOCADO_DIRNAME=$(AVOCADO_DIRNAME) make -C $$MAKEFILE link &>/dev/null || echo ">> FAIL $$MAKEFILE";\
195
			elif test -f $$MAKEFILE/setup.py; then cd $$MAKEFILE; $(PYTHON) setup.py develop $(PYTHON_DEVELOP_ARGS); cd -; fi;\
196
		else echo ">> SKIP $$MAKEFILE"; fi;\
197
	done
C
Cleber Rosa 已提交
198

199 200 201
spell:
	pylint --errors-only --disable=all --enable=spelling --spelling-dict=en_US --spelling-private-dict-file=spell.ignore * && echo OK

202
man: man/avocado.1 man/avocado-rest-client.1
203

204 205 206 207 208 209 210 211 212
variables:
	@echo "PYTHON: $(PYTHON)"
	@echo "VERSION: $(VERSION)"
	@echo "DESTDIR: $(DESTDIR)"
	@echo "AVOCADO_DIRNAME: $(AVOCADO_DIRNAME)"
	@echo "AVOCADO_PLUGINS: $(AVOCADO_PLUGINS)"
	@echo "RELEASE_COMMIT: $(RELEASE_COMMIT)"
	@echo "RELEASE_SHORT_COMMIT: $(RELEASE_SHORT_COMMIT)"
	@echo "COMMIT: $(COMMIT)"
213
	@echo "COMMIT_DATE: $(COMMIT_DATE)"
214
	@echo "SHORT_COMMIT: $(SHORT_COMMIT)"
215
	@echo "MOCK_CONFIG: $(MOCK_CONFIG)"
216
	@echo "PYTHON_DEVELOP_ARGS: $(PYTHON_DEVELOP_ARGS)"
217

218 219 220 221 222 223 224
propagate-version:
	for DIR in $(AVOCADO_PLUGINS); do\
		if test -f "$$DIR/VERSION"; then\
			echo ">> Updating $$DIR"; echo "$(VERSION)" > "$$DIR/VERSION";\
		else echo ">> Skipping $$DIR"; fi;\
	done

225
.PHONY: source install clean check link variables
226 227 228 229

# implicit rule/recipe for man page creation
%.1: %.rst
	rst2man $< $@