-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
76 lines (62 loc) · 2.17 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
.DEFAULT_GOAL = all
REVISION = $(shell git rev-parse HEAD | cut -c 1-7)
VERSION = $(shell python3 setup.py --version 2>/dev/null)
WHEEL_REV = _dist/litrepl-$(VERSION)-$(REVISION)-py3-none-any.whl
WHEEL = dist/litrepl-$(VERSION)-py3-none-any.whl
PY = $(shell find -name '*\.py' | grep -v semver.py | grep -v revision.py)
VIM = $(shell find vim -name '*\.vim')
VIMB_REV = _dist/vim-litrepl-$(VERSION)-$(REVISION).tar.gz
TESTS = ./sh/runtests.sh
.stamp_test: $(PY) $(VIM) $(TESTS) Makefile python/bin/litrepl
LITREPL_BIN="`pwd`/python/bin" \
LITREPL_ROOT=`pwd` \
sh $(TESTS)
touch $@
.PHONY: help # Print help
help:
@echo "LitREPL is a macroprocessing Python library for Litrate programming and code execution"
@echo Build targets:
@cat Makefile | sed -n 's@^.PHONY: \([a-z]\+\) # \(.*\)@ \1: \2@p' | column -t -l2
.PHONY: test # Run the test script (./sh/runtests.sh)
test: .stamp_test
.stamp_readme: $(PY)
cp README.md _README.md.in
cat _README.md.in | \
litrepl --foreground --exception-exitcode=100 \
--result-textwidth=100 --sh-interpreter=- \
eval-sections >README.md
touch $@
.PHONY: readme # Update code sections in the README.md
readme: .stamp_readme
$(WHEEL_REV): $(PY) Makefile .stamp_test .stamp_readme
mkdir -p $$(dirname $@) || true
test -n "$(VERSION)"
rm -rf build dist || true
python3 setup.py sdist bdist_wheel
test -f $(WHEEL)
cp $(WHEEL) $(WHEEL_REV)
.PHONY: wheel # Build Python wheel (the DEFAULT target)
wheel: $(WHEEL_REV)
.PHONY: vimbundle # Build Vim bundle
vimbundle: $(VIMB_REV)
$(VIMB_REV): $(VIM)
mkdir -p $$(dirname $@) || true
rm -rf build/vim || true
mkdir -p build/vim/plugin
cp -r vim/plugin/*vim build/vim/plugin
sed -i "s/version-to-be-filled-by-the-packager/$(VERSION)+g$(REVISION)/g" \
build/vim/plugin/litrepl.vim
tar -czvf $@ -C build/vim plugin
.PHONY: version # Print the version
version:
@echo $(VERSION)+g$(REVISION)
.PHONY: dist # Build Python and Vim packages
dist: $(WHEEL_REV) $(VIMB_REV)
.PHONY: upload # Upload Python wheel to Pypi.org (./_token.pypi is required)
upload: $(WHEEL_REV) $(VIMB_REV)
twine upload \
--username __token__ \
--password $(shell cat _token.pypi) \
dist/*
.PHONY: all
all: wheel