-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
68 lines (53 loc) · 1.82 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
DEPLOY_TO ?= nfs # nfs or sd-card
CAM_IP ?= axiscam
CAM_USER ?= root
IMAGE_NAME ?= cam-builder:latest
PYTHON_NAME ?= python
APP_NAME ?= app
APP_DEPLOY_DIR ?= /tmp
ifeq ($(strip ${DEPLOY_TO}),nfs)
# When using NFS we copy direct to the network share
PYTHON_DEPLOY_DIR ?= /samba/tmp/app# Relative to mount point
HOST_MOUNT ?= /mnt/storage
CAM_MOUNT = /var/spool/storage/NetworkShare/
HOST_INSTALL_DIR = ${HOST_MOUNT}/${PYTHON_DEPLOY_DIR}
CAM_INSTALL_DIR=${CAM_MOUNT}/${PYTHON_DEPLOY_DIR}
INSTALL_CMD=tar -C ${HOST_INSTALL_DIR} -xzvf -
else ifeq ($(strip ${DEPLOY_TO}),sd_card)
# When using SD-card we copy the data over ssh
CAM_MOUNT = /var/spool/storage/SD_DISK
CAM_INSTALL_DIR=${CAM_MOUNT}/
INSTALL_CMD=ssh ${CAM_USER}@${CAM_IP} tar -C ${CAM_INSTALL_DIR} -xzvf -
else
$(error Unknwon DEPLOY_TO="${DEPLOY_TO}", should be "nfs" or "sd_card")
endif
DOCKER_RUN = docker run --rm ${IMAGE_NAME}
DOCKER_RUN_MOUNT = docker run --rm -v `pwd`:/opt/app/ ${IMAGE_NAME}
CAM_RUN = ssh -t ${CAM_USER}@${CAM_IP}
CAM_PYTHON = LD_LIBRARY_PATH=${CAM_INSTALL_DIR}/generated/libs \
PYTHONHOME=${CAM_INSTALL_DIR}/generated/usr \
${CAM_INSTALL_DIR}/generated/${PYTHON_NAME}
.PHONY: build-docker
build-docker:
docker build -t ${IMAGE_NAME} .
.PHONY: build-app
build-app:
${DOCKER_RUN_MOUNT} bash -c "cd ${APP_NAME} && ../build_ext.sh"
.PHONY: clean-app
clean-app:
rm ${APP_NAME}/*.so -rf ${APP_NAME}/build
.PHONY: deploy-app
deploy-app:
scp -r ./${APP_NAME} ${CAM_USER}@${CAM_IP}:${APP_DEPLOY_DIR}
.PHONY: deploy-python
deploy-python:
${DOCKER_RUN} tar -czf - /generated | ${INSTALL_CMD}
.PHONY: run-interpreter
run-interpreter:
${CAM_RUN} ${CAM_PYTHON}
.PHONY: run-app
run-app:
${CAM_RUN} "cd ${APP_DEPLOY_DIR}/${APP_NAME} && ${CAM_PYTHON} ${APP_NAME}.py"
.PHONY: mount-exec
mount-exec:
ssh ${CAM_USER}@${CAM_IP} mount -o remount,exec ${CAM_MOUNT}