-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers.mak
162 lines (141 loc) · 3.99 KB
/
helpers.mak
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#
# Various helper targets for deployment and debugging
# Source setuptarget.sh to use them!
#
#==============================================================================#
# Deployment targets
# Deploy bin to target:
.PHONY: deploy
deploy: build
ifdef TARGET_IP
@sshpass -p $(TARGET_PWD) scp $(PROGS) $(TARGET_USR)@$(TARGET_IP):$(TARGET_DIR)
else
$(error Please source setuptarget.sh first)
endif
# Deploy web:
.PHONY: deployweb
deployweb: web
ifdef TARGET_IP
@sshpass -p $(TARGET_PWD) ssh $(TARGET_USR)@$(TARGET_IP) 'rm -rf $(TARGET_DIR)/html/*'
@sshpass -p $(TARGET_PWD) scp -r ./html/* $(TARGET_USR)@$(TARGET_IP):$(TARGET_DIR)/html
else
$(error Please source setuptarget.sh first)
endif
# Deploy shell profile to target:
.PHONY: deployprofile
deployprofile:
ifdef TARGET_IP
@sshpass -p $(TARGET_PWD) scp ./scripts/profile $(TARGET_USR)@$(TARGET_IP):/$(TARGET_USR)/.profile
@sshpass -p $(TARGET_PWD) ssh -t $(TARGET_USR)@$(TARGET_IP) 'sed -i "s/xxxxxx/$(PROGS)/g" /$(TARGET_USR)/.profile'
else
$(error Please source setuptarget.sh first)
endif
# Deploy gdbserver to target:
.PHONY: deploygdb
deploygdb:
ifdef TARGET_IP
ifeq ($(APPTYPE), aarch64)
@sshpass -p $(TARGET_PWD) scp ./gdb/gdbserver $(TARGET_USR)@$(TARGET_IP):/tmp/gdbserver
else
@echo "Error: Unsupported APPTYPE"
@exit 1
endif
else
$(error Please source setuptarget.sh first)
endif
#==============================================================================#
# Miscellaneous targets
# Logon to ACAP dir:
.PHONY: logon
logon:
ifdef TARGET_IP
@sshpass -p $(TARGET_PWD) ssh -t $(TARGET_USR)@$(TARGET_IP) "cd $(TARGET_DIR) && sh"
else
$(error Please source setuptarget.sh first)
endif
# Kill the app:
.PHONY: kill
kill:
ifdef TARGET_IP
@sshpass -p $(TARGET_PWD) ssh $(TARGET_USR)@$(TARGET_IP) 'kill -KILL $$(pidof $(PROGS))'
else
$(error Please source setuptarget.sh first)
endif
# Check target embedded SDK info:
.PHONY: checksdk
checksdk:
ifdef TARGET_IP
@curl --anyauth --noproxy "*" -u $(TARGET_USR):$(TARGET_PWD) \
'$(TARGET_IP)/axis-cgi/admin/param.cgi?action=list&group=Properties.EmbeddedDevelopment'
else
$(error Please source setuptarget.sh first)
endif
# Open apps web (Linux):
.PHONY: openweb
openweb:
ifdef TARGET_IP
@xdg-open http://$(TARGET_IP)/camera/index.html#/apps > /dev/null 2>&1
else
$(error Please source setuptarget.sh first)
endif
# Trace logs on target:
.PHONY: log
log:
ifdef TARGET_IP
@./scripts/log.py
else
$(error Please source setuptarget.sh first)
endif
# Build ACAP release for all arch and put in a build dir:
.PHONY: release
release:
@./scripts/make_acap_release.sh
# Extract ACAP SDK from Docker image (needs to be run as root):
.PHONY: getsdk
getsdk: checkdocker
ifeq ($(APPTYPE), aarch64)
@$(call setup_aarch64)
@./scripts/copylib.sh $(DOCKER_X64_IMG) /opt/axis/acapsdk
else
@echo "Error: Unsupported APPTYPE"
@exit 1
endif
#==============================================================================#
# Docker helpers
# Remove all stopped containers (not images):
.PHONY: dockerprune
dockerprune: checkdocker
@docker container prune
# List all Docker images:
.PHONY: dockerlist
dockerlist: checkdocker
@docker image list $(DOCKER_X32_IMG)
@echo
@docker image list $(DOCKER_X64_IMG)
# Run current Docker image:
.PHONY: dockerrun
dockerrun: checkdocker
ifeq ($(APPTYPE), aarch64)
@$(DOCKER_CMD) $(DOCKER_X64_IMG)
else
@echo "Error: Unsupported APPTYPE"
@exit 1
endif
#==============================================================================#
# Code helpers
# Static code analysis using cppcheck:
.PHONY: cppcheck
cppcheck:
@$(ECHO) "${PURPLE}*** Static code analysis${NC}"
@cppcheck $(shell find . -name "*.[ch]") \
--verbose --enable=all -DDEBUG=1 \
--suppress=missingIncludeSystem \
--suppress=unknownMacro \
--suppress=unusedFunction
# Format code using clang-format:
.PHONY: indent
indent:
@$(ECHO) "${PURPLE}*** Formatting code${NC}"
@clang-format $(shell find . -name "*.[ch]") \
-style=file -i -fallback-style=none
#==============================================================================#