blob: af0e2bfdc7013a633e82a437f2b0bc92931e8541 [file] [log] [blame]
Shad Ansarid3654512021-09-29 10:31:53 -07001#
Shad Ansari47432b62021-09-27 22:46:25 +00002# SPDX-FileCopyrightText: 2020-present Open Networking Foundation <info@opennetworking.org>
3# SPDX-License-Identifier: LicenseRef-ONF-Member-1.01
4#
5define PROJECT_HELP_MSG
6Usage:
7 make help show this message
8 make clean remove intermediate files
Shad Ansari55ff1852021-09-27 20:05:54 +00009
Shad Ansari47432b62021-09-27 22:46:25 +000010 make ${VENV} make a virtualenv in the base directory
11 make python-reqs install python packages in requirements.pip
12 make git-config set local git configuration
13 make setup make python-reqs
14
15 make run launch network-video-recorder
16 make run-native run native application (no docker)
17 make run-native-no-show run native applicaiton (no docker) w/o video output
18endef
19export PROJECT_HELP_MSG
20
Shad Ansari5aa73462021-10-04 21:43:07 -070021SHELL = bash -eu -o pipefail
22
23VERSION ?= $(shell cat ./VERSION)
24#CONTAINER_NAME ?= person-detection-app
25CONTAINER_NAME ?= $(notdir $(abspath .))
26
27DOCKER_REGISTRY ?=
28DOCKER_REPOSITORY ?=
29DOCKER_BUILD_ARGS ?= --rm --force-rm
30DOCKER_TAG ?= ${VERSION}
31DOCKER_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}${CONTAINER_NAME}:${DOCKER_TAG}
32
33DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote))
34DOCKER_LABEL_VCS_REF ?= $(shell git diff-index --quiet HEAD -- && git rev-parse HEAD || echo "unknown")
35DOCKER_LABEL_COMMIT_DATE ?= $(shell git diff-index --quiet HEAD -- && git show -s --format=%cd --date=iso-strict HEAD || echo "unknown" )
36DOCKER_LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ")
37
Shad Ansari47432b62021-09-27 22:46:25 +000038VENV = .venv
39PYTHON = $(VENV)/bin/python3
40PIP = $(VENV)/bin/pip
Shad Ansari47432b62021-09-27 22:46:25 +000041
Shad Ansari5aa73462021-10-04 21:43:07 -070042all: test
Shad Ansarib5808d72021-10-04 12:43:27 -070043
Shad Ansari47432b62021-09-27 22:46:25 +000044help:
45 echo "$$PROJECT_HELP_MSG" | less
46
Shad Ansari47432b62021-09-27 22:46:25 +000047$(VENV): $(VENV)/touchfile
48
49$(VENV)/touchfile: requirements.txt
50 test -d $(VENV) || python3 -m venv $(VENV)
51 . $(VENV)/bin/activate; pip install -Ur requirements.txt
52 touch $(VENV)/touchfile
53
54$(VENV)/bin/activate: requirements.txt
55 python3 -m venv $(VENV)
56 $(PIP) install -r requirements.txt
57
Shad Ansariae90d252021-10-22 16:40:29 +000058freeze:
59 pip3 freeze | grep -v "pkg-resources" > requirements.txt
60
Shad Ansari5aa73462021-10-04 21:43:07 -070061docker-build: $(VENV)
62 docker build $(DOCKER_BUILD_ARGS) \
63 -t $(DOCKER_IMAGENAME) \
64 --build-arg org_label_schema_version="${VERSION}" \
65 --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \
66 --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \
67 --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \
68 --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \
69 -f docker/Dockerfile .
Shad Ansari47432b62021-09-27 22:46:25 +000070
Shad Ansari5aa73462021-10-04 21:43:07 -070071docker-push:
72 docker push $(DOCKER_IMAGENAME)
73
74docker-run:
75 docker run \
76 -itu root:root \
77 --privileged \
78 --network host \
79 --name $(CONTAINER_NAME) \
80 --rm \
81 $(DOCKER_IMAGENAME)
Shad Ansari47432b62021-09-27 22:46:25 +000082
Shad Ansari341ca3a2021-09-30 12:10:00 -070083run-native-file: $(VENV)
Shad Ansarid80531f2021-09-27 23:15:03 +000084 . ./bin/person_detection.sh -i ./resources/run.mp4
Shad Ansari47432b62021-09-27 22:46:25 +000085
Shad Ansari341ca3a2021-09-30 12:10:00 -070086run-native-gstream: $(VENV)
Shad Ansarid80531f2021-09-27 23:15:03 +000087 . ./bin/person_detection.sh -i gstreamer
Shad Ansari47432b62021-09-27 22:46:25 +000088
Shad Ansarid3654512021-09-29 10:31:53 -070089run-native-cam: $(VENV)
Shad Ansari0119b422021-09-27 23:51:49 +000090 . ./bin/person_detection.sh -i cam
91
Shad Ansarib5808d72021-10-04 12:43:27 -070092lint:
93 flake8 --exclude=.tox person_detection
94
Shad Ansari5aa73462021-10-04 21:43:07 -070095test: docker-build
Shad Ansari47432b62021-09-27 22:46:25 +000096
97
98CLEANUP = *.pyc $(VENV)
99clean:
100 rm -rf ${CLEANUP}
101
102.PHONY: run clean
103