-
Notifications
You must be signed in to change notification settings - Fork 30
/
Makefile
61 lines (51 loc) · 1.64 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
PYTHON3=$(shell which python3 && which pip3)
USE_SELINUX=$(shell test -d /sys/fs/selinux && echo ":Z")
DOCKERFILE ?= $(CURDIR)/images/Dockerfile.el9
DIST=$(shell echo $(DOCKERFILE) | tr "." "\n" | tail -1 | tr '[:upper:]' '[:lower:]')
IMAGE ?= kht-builder-$(DIST)
ifneq ($(PYTHON3),)
PYTHON ?= python3
PIP ?= pip3
else
PYTHON ?= python
PIP ?= pip
endif
PODMAN=$(shell which podman)
ifneq ($(PODMAN),)
CONTAINER_EXEC ?= podman
else
CONTAINER_EXEC ?= docker
endif
default: help
help:
@echo "Usage: make [target] <ARG=value, ...>"
@echo
@echo "target:"
@echo " help show this message"
@echo " install install locally with default python"
@echo " test-install install test requirements"
@echo " test test locally"
@echo " docker-build build the docker image"
@echo " docker-run run bash in a preconfigured docker container"
@echo " docker-test test in a docker container"
@echo
@echo "python args:"
@echo " PYTHON python executable to use (python2, python3)"
@echo " PIP pip executable to use (pip, pip3)"
@echo
@echo "docker-* args:"
@echo " DOCKERFILE dockerfile to use (one of images/Dockerfile.*)"
install:
cd src/ && $(PYTHON) setup.py install
test-install:
$(PIP) install -r test-requirements.txt
test: test-install
$(PYTHON) test/unittest_suite.py
docker-build:
$(CONTAINER_EXEC) build -f $(DOCKERFILE) -t $(IMAGE) .
docker-run: docker-build
$(CONTAINER_EXEC) run --rm -itv $(CURDIR):/app$(USE_SELINUX) $(IMAGE) bash
docker-test: docker-build
$(CONTAINER_EXEC) run --rm -v $(CURDIR):/app$(USE_SELINUX) $(IMAGE) ./test/test_runner.sh
docker-clean:
$(CONTAINER_EXEC) image rm $(IMAGE)