-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
209 lines (163 loc) · 4.74 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
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#!/bin/make -f
# -*- makefile -*-
# SPDX-License-Identifier: MPL-2.0
#{
# Copyright 2018-present Samsung Electronics France SAS, and other contributors
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/# .
#}
default: help
@echo "log: $@: $^"
project?=twins
runtime?=iotjs
webthing_url?=http://${project}.glitch.me
example_file=index.js
run_args?=
target_port?=8888
target_host?=localhost
target_url?=http://${target_host}:${target_port}
export target_url
simulator_port=42088
simulator_host?=localhost
simulator_url?=http://${target_host}:${simulator_port}/?useWs=no
lib_srcs?=$(wildcard *.js lib/*.js | sort | uniq)
srcs?=${lib_srcs}
iotjs_modules_dir ?= ${CURDIR}/iotjs_modules
export iotjs_modules_dir
webthing-iotjs_url ?= https://github.com/rzr/webthing-iotjs
webthing-iotjs_revision ?= webthing-iotjs-0.12.1-1
webthing-iotjs_dir ?= ${iotjs_modules_dir}/webthing-iotjs
iotjs_modules_dirs += ${webthing-iotjs_dir}
deploy_modules_dir?=${CURDIR}/tmp/deploy/iotjs_modules
deploy_module_dir?= ${deploy_modules_dir}/${project}
deploy_dirs+= ${deploy_module_dir}
deploy_dirs+= ${deploy_modules_dir}/webthing-iotjs
deploy_srcs+= $(addprefix ${deploy_module_dir}/, ${srcs})
curl?=curl \
-H "Accept: application/json" \
-H "Content-type: application/json" \
${curl_args}
sleep_secs?=1
%: ${runtime}/%
@echo "log: $@: $^"
run: ${runtime}/start
@echo "log: $@: $^"
help:
@echo "# Usage:"
@echo "# make runtime=${runtime} start"
setup: Makefile
@echo "# log: $@: $^"
@iotjs -h 2>&1 | grep -o 'Usage: iotjs' > /dev/null || echo "Error: iotjs not usable"
check:
@echo "TODO: implements $@"
test:
@echo "TODO: implements $@"
modules: ${runtime}/modules
@echo "log: $@: $^"
node/modules: package.json
npm install
node/start: ${example_file} modules
${@D} $< ${run_args}
iotjs/start: ${example_file} ${iotjs_modules_dirs}
iotjs $< ${run_args}
iotjs/client:
curl -i ${target_url}
curl -i ${target_url}/properties
iotjs/client/web:
curl -i ${webthing_url}
curl -i ${webthing_url}/properties
LICENSE: /usr/share/common-licenses/MPL-2.0
cp -a $< $@
iotjs/modules: ${iotjs_modules_dirs}
ls $^
${webthing-iotjs_dir}: Makefile
@echo "log: $@: $^"
git clone --recursive --depth=1 \
--branch "${webthing-iotjs_revision}" \
"${webthing-iotjs_url}" \
"$@"
${MAKE} -C $@ ${runtime}/modules
deploy: ${deploy_srcs} ${deploy_dirs}
ls $<
${deploy_module_dir}/%: %
@echo "# TODO: minify: $< to $@"
install -d ${@D}
install $< $@
${deploy_modules_dir}/webthing-iotjs: ${iotjs_modules_dir}/webthing-iotjs
make -C $< deploy deploy_modules_dir="${deploy_modules_dir}" project="${@F}"
property/%:
${curl} ${target_url}/properties/${@F}
@echo ""
${curl} -X PUT -d '{ "${@F}": ${value} }' ${target_url}/properties/${@F}
@echo ""
sleep ${sleep_secs}
properties:
${curl} -i ${target_url}/properties
zero:
${MAKE} property/torso value=0
${MAKE} property/shoulder value=0
${MAKE} property/arm value=0
${MAKE} property/hand value=0
hand: # [0 45]
${MAKE} property/${@F} value=0
${MAKE} property/${@F} value=10
${MAKE} property/${@F} value=20
${MAKE} property/${@F} value=30
${MAKE} property/${@F} value=40
${MAKE} property/${@F} value=10
${MAKE} property/${@F} value=0
${MAKE} property/${@F} value=-5
${MAKE} property/${@F} value=0
arm: # [-45 +45]
${MAKE} property/${@F} value=0
${MAKE} property/${@F} value=45
${MAKE} property/${@F} value=-45
${MAKE} property/${@F} value=0
shoulder: #[ -45, 45]
${MAKE} property/shoulder value=-45
${MAKE} property/shoulder value=0
${MAKE} property/shoulder value=45
${MAKE} property/shoulder value=0
demo: zero
${MAKE} property/hand value=40
${MAKE} property/arm value=-15
${MAKE} property/shoulder value=20
${MAKE} property/arm value=-20
${MAKE} property/shoulder value=45
${MAKE} property/hand value=20
${MAKE} property/hand value=0
${MAKE} property/arm value=0
${MAKE} property/arm value=15
${MAKE} property/shoulder value=0
${MAKE} property/shoulder value=-45
${MAKE} property/shoulder value=0
${MAKE} property/arm value=-20
${MAKE} property/shoulder value=20
${MAKE} property/shoulder value=45
${MAKE} property/arm value=-20
${MAKE} property/hand value=10
${MAKE} property/hand value=20
${MAKE} property/hand value=30
${MAKE} property/hand value=40
${MAKE} zero
remote:
${MAKE} demo
simulate:
${MAKE} start runtime=node
view: aframe
cd $< && \
npm install && \
PORT=${simulator_port} npm start
devel:
xterm -e "make simulate" &
xterm -e "make view" &
x-www-browser ${simulator_url} &
make rule/front rule/back
rule/back:
${MAKE} property/shoulder value=-45
${MAKE} property/arm value=45
rule/front:
${MAKE} property/arm value=-45
${MAKE} property/shoulder value=45