Makefile 2.41 KB
Newer Older
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
PYVER := 3
VENV := .venv

all: help

help:
	@ echo "USAGE"
	@ echo ""
	@ echo "  make apt-install    --  Uses Debian's apt to install required system tools"
	@ echo ""
	@ echo "  make setup          --  Install Python requirements"
	@ echo ""
	@ echo "  make build          --  Compile the sketch"
	@ echo ""
	@ echo "  make upload         --  Send the compiled sketch to the board"
	@ echo ""
	@ echo "  make serial         --  Enter IPython session with serial opened"
	@ echo ""
	@ echo "  make bu             --  build & upload"
	@ echo "  make bus            --  build & upload & serial"
	@ echo ""
	@ echo "  make sync-rtc       --  Synchronizes the board's clock with the system's"
	@ echo ""
	@ echo "  make run-logger     --  Starts the logger. Results apper on the screen."
	@ echo ""
	@ echo "  make deploy-logger  --  Activate logger daemon. Results apper on logs/execution.log"
	@ echo ""
	@ echo "  make undeploy-logger -- Deactivate logger daemon."
	@ echo ""
	@ echo "  make tail-logger     -- Exibits and follow daemon execution log."

apt-install:
	sudo apt-get install python python3 python3-pip supervisor
	sudo pip${PYVER} install virtualenv

install-ino:
	sudo apt-get install python-pip
	sudo pip2 install ino
	
setup: clean-venv
	@ echo "-------------------------------------------------------"
	virtualenv -v --python='python${PYVER}' ${VENV}
	@ echo "Virtualenv with 'python${PYVER}' interpreter was created at ${VENV}"
	@ echo "-------------------------------------------------------"
	${VENV}/bin/pip install --upgrade pip
	@ echo "-------------------------------------------------------"
	${VENV}/bin/pip install -r logger/app/requirements.pip
	@ echo "-------------------------------------------------------"
	@ echo "Virtualenv is ready at ${VENV}!"
	@ echo " "
	@ echo "TOTAL SIZE: "
	@ du -sh ${VENV}

clean-venv:
	rm -rf ${VENV}

clean:
	rm -rf .build src/*

build:
	mkdir -p .ino
	mkdir -p .ino/src/ .ino/lib/
	cp -rf meteorolog/. .ino/src/
	cp logger/ino.ini .ino/
	cd .ino/ && ino build
	
upload:
	cd .ino/ && ino upload

serial:
	${VENV}/bin/ipython3 -i logger/init_serial.py

bu: build upload

bus: build upload serial

sync-rtc:
	${VENV}/bin/python${PYVER} run.py --syncrtc
 
run-logger:
	${VENV}/bin/python logger/run.py

deploy-logger:
	mkdir -p logger/logs
	sudo ${VENV}/bin/python${PYVER} logger/deploy.py

undeploy-logger:
	sudo ${VENV}/bin/python${PYVER} logger/deploy.py -u

tail-logger:
	tail -F logger/logs/execution.log