-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
127 lines (99 loc) · 2.87 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# -*- mode: makefile; -*-
UNAME := $(shell uname -s)
CONTAINER_RUNTIME = $(shell command -v podman 2> /dev/null || echo docker)
DOXYGEN = doxygen
OPEN = $(shell which xdg-open || which gnome-open || which open)
PYTHON = /usr/bin/env python3
PIPARG = # e.g., --user
PIP = $(PYTHON) -m pip $(PIPARG)
PYTEST = /usr/bin/env pytest
R = /usr/bin/env R --no-save --no-restore
GIT = git
CMAKE = /usr/bin/env cmake
SELF_DIR = $(dir $(lastword $(MAKEFILE_LIST)))
GETVER = $(abspath $(SELF_DIR))/getrversion.py
LINTER = cclint
NINJA := $(shell command -v ninja 2> /dev/null)
NINJA_BUILD_OPT = -v
FINDEXEC :=
ifeq ($(UNAME),Darwin)
FINDEXEC += -perm +111
else
FINDEXEC += -executable
endif
PKG = kvaser
default: install
@echo "-----------------------"
@$(PYTHON) -m $(PKG)
.PHONY: update
update:
$(PIP) install wheel setuptools twine --upgrade
UID := $(shell id -u)
PWD := $(shell pwd)
.PHONY: build source
DOCKERRUN = $(CONTAINER_RUNTIME) run -ti --rm --privileged --user $(UID):0 --network=host -v $(PWD):/io buildmany
build: clean
$(PYTHON) setup.py bdist_wheel -d dist
$(MAKE) source
source:
$(PYTHON) setup.py sdist
.PHONY: clean
clean:
@rm -Rf dist/* *.egg-info build *.so *.so.* src/*.egg-info tests/bin/*
.PHONY: upload_test
upload_test:
$(PYTHON) -m twine upload --repository pypitest dist/*
.PHONY: upload
upload: source
$(PYTHON) -m twine upload dist/* --verbose --repository-url https://upload.pypi.org/legacy/
.PHONY: uninstall
uninstall:
$(PIP) uninstall $(PKG) -y
.PHONY: install
install: uninstall
$(PYTHON) setup.py install
rm -Rf *.egg-info
.PHONY: installdev
installdev:
$(PIP) install -e .
.PHONY: check
check:
$(PYTHON) setup.py flake8
.PHONY: test
test:
$(PYTHON) setup.py test
.PHONY: cov
cov: coverage
@$(OPEN) tests/htmlcov/index.html
.PHONY: coverage
coverage:
pytest --cov=kvaser tests/ --cov-report=html:tests/htmlcov $(TESTOPT)
.PHONY: installpypi_test
installpypi_test:
$(PIP) install --upgrade --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ ${PKG}
.PHONY: installpypi
installpypi: uninstall
$(PIP) install --upgrade $(PKG) --no-binary :all:
################################################################################
.PHONY: markdown
markdown:
@if [ -z "command -v grip" ]; then \
echo "Install dependency: pip install grip"; \
else grip 1313 -b; fi
.PHONY: doc
doc:
@cd doc; $(MAKE) html
.PHONY: d
d: doc
@open doc/build/html/index.html
################################################################################
.PHONY: dockerbuild
dockerbuild:
$(CONTAINER_RUNTIME) build --build-arg UID=${UID} --network=host . -t target_test
.PHONY: docker
docker:
$(CONTAINER_RUNTIME) run -ti --rm --privileged --network=host -v $(PWD):/io target_test bash
DOCKERTEST=kkholst/stat:python
.PHONY: dockertest
dockertest:
$(CONTAINER_RUNTIME) run -ti --rm --privileged --network=host -u 0:0 -v $(PWD):/data ${DOCKERTEST} bash