-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
103 lines (85 loc) · 2.7 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
.PHONY: docs
ifneq ($(shell which python3),)
PYTHON = python3
else
ifneq ($(shell which python),)
PYTHON = python
else
$(warning Python not found. Neither python nor python3 was found.)
endif
endif
ifneq ($(shell which ccache),)
CCACHE := $(patsubst %,% ,ccache)
endif
COVERAGE = $(PYTHON) -m coverage
TEST_COVERAGE = env MYS="PYTHONPATH=$(CURDIR):$(CURDIR)/mys/pygments $(COVERAGE) run -p --source=mys --omit=\"**/mys/parser/**\" -m mys" $(COVERAGE) run -p --source=mys --omit="**/mys/parser/**" -m pytest -q -n auto --lf
TEST = env PYTHONPATH=$(CURDIR):$(CURDIR)/mys/pygments $(PYTHON) -m pytest -q -n auto --lf
COMBINE = $(COVERAGE) combine -a $$(find . -name ".coverage.*")
all: style lint test-lib
$(MAKE) test
$(MAKE) docs
$(MAKE) examples
test-lib:
$(MAKE) -C mys/lib/test
test-coverage: c-extension
rm -f $$(find . -name ".coverage*")
+$(TEST_COVERAGE) $(ARGS)
$(COMBINE)
$(COVERAGE) html
$(COVERAGE) annotate --directory textcov
test: c-extension
+$(TEST) $(ARGS)
test-install:
rm -rf install
rm -rf dist
$(PYTHON) setup.py build sdist
mkdir -p install
cd install && \
tar xf ../dist/*.tar.gz --strip-components=1 && \
$(PYTHON) setup.py install --prefix install
+cd install/install && \
export PATH=$$(readlink -f bin):$$PATH && \
export PYTHONPATH=$$(readlink -f lib/python*/site-packages/mys-*) && \
which mys && \
mys new foo && \
cd foo && \
mys run -v && \
mys test -v
clean:
$(MAKE) -C examples clean
$(MAKE) -C mys/lib/test clean
rm -rf tests/build .test_* htmlcov build .coverage
c-extension:
env CC="$(CCACHE)gcc" $(PYTHON) setup.py build_ext -b . -j 4
TEST_FILES := $(shell ls tests/test_*.py)
remove-coverage:
rm -f $$(find . -name ".coverage*")
lint:
pylint $$(git ls-files "*.py" \
| grep -v "docs/\|publish/setup.py\|parser/ast.py\|examples/wip\|mys/pygments\|doc/conf.py\|tools/")
style:
isort --force-single-line-imports .
docs: c-extension
$(MAKE) -C docs clean
env PYTHONPATH=$(CURDIR):$(CURDIR)/mys/pygments:$$PYTHONPATH $(MAKE) -C docs SPHINXOPTS="-W" html
@echo
@echo "Open file://$(CURDIR)/docs/build/html/index.html in a web browser."
@echo
VERSION := $(shell $(PYTHON) -c "print(open('mys/version.py').read().split('\'')[1])")
PUBLISH_ADDRESS ?= https://mys-lang.org
PUBLISH_TOKEN ?=
publish: docs
cp -r docs/build/html .
rm -rf $(VERSION)
mv html $(VERSION)
tar czf mys-$(VERSION).tar.gz $(VERSION)
ifeq ($(PUBLISH_TOKEN),)
curl --fail -X POST --data-binary @mys-$(VERSION).tar.gz \
$(PUBLISH_ADDRESS)/mys-$(VERSION).tar.gz
else
curl --fail -X POST --data-binary @mys-$(VERSION).tar.gz \
$(PUBLISH_ADDRESS)/mys-$(VERSION).tar.gz?token=$(PUBLISH_TOKEN)
endif
.PHONY: examples
examples: c-extension
$(MAKE) -C examples