blob: 2aca763d43bd34f2ca31279d7b2dc080ae09f929 [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 Ansari5aa73462021-10-04 21:43:07 -070058docker-build: $(VENV)
59 docker build $(DOCKER_BUILD_ARGS) \
60 -t $(DOCKER_IMAGENAME) \
61 --build-arg org_label_schema_version="${VERSION}" \
62 --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \
63 --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \
64 --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \
65 --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \
66 -f docker/Dockerfile .
Shad Ansari47432b62021-09-27 22:46:25 +000067
Shad Ansari5aa73462021-10-04 21:43:07 -070068docker-push:
69 docker push $(DOCKER_IMAGENAME)
70
71docker-run:
72 docker run \
73 -itu root:root \
74 --privileged \
75 --network host \
76 --name $(CONTAINER_NAME) \
77 --rm \
78 $(DOCKER_IMAGENAME)
Shad Ansari47432b62021-09-27 22:46:25 +000079
Shad Ansari341ca3a2021-09-30 12:10:00 -070080run-native-file: $(VENV)
Shad Ansarid80531f2021-09-27 23:15:03 +000081 . ./bin/person_detection.sh -i ./resources/run.mp4
Shad Ansari47432b62021-09-27 22:46:25 +000082
Shad Ansari341ca3a2021-09-30 12:10:00 -070083run-native-gstream: $(VENV)
Shad Ansarid80531f2021-09-27 23:15:03 +000084 . ./bin/person_detection.sh -i gstreamer
Shad Ansari47432b62021-09-27 22:46:25 +000085
Shad Ansarid3654512021-09-29 10:31:53 -070086run-native-cam: $(VENV)
Shad Ansari0119b422021-09-27 23:51:49 +000087 . ./bin/person_detection.sh -i cam
88
Shad Ansarib5808d72021-10-04 12:43:27 -070089lint:
90 flake8 --exclude=.tox person_detection
91
Shad Ansari5aa73462021-10-04 21:43:07 -070092test: docker-build
Shad Ansari47432b62021-09-27 22:46:25 +000093
94
95CLEANUP = *.pyc $(VENV)
96clean:
97 rm -rf ${CLEANUP}
98
99.PHONY: run clean
100