-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakefile
63 lines (49 loc) · 2.46 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
include private.mk
# private.mk content should look something like ...
#
# ADDRESS := $(shell host smartthings.home | head -1 | tr [:space:] \\n | tail -1)
# HUB := xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
# CHANNEL := xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
#
# where
#
# ADDRESS is the IP address of the targeted SmartThings hub
# HUB is the UUID of the targeted SmartThings hub
# CHANNEL is the UUID of the targeted SmartThings distribution channel
# we do not use ...
# ./smartthings edge:drivers:package --build
# because it does not follow the symbolic links in our packages.
# instead, we build our PACKAGES in a way that does, upload them,
# and cache driverId, name, version and packageKey for each in DRIVERS
# which targets depend and rules use for their driverId.
PACKAGES := $(addsuffix /package.zip , $(wildcard driver/*))
DRIVERS := $(addsuffix /driver , $(wildcard driver/*))
LOGCATS := $(addsuffix /logcat , $(wildcard driver/*))
all: $(DRIVERS)
clean:
rm -f $(PACKAGES) $(DRIVERS)
driver/denon-avr/package.zip: $(shell find driver/denon-avr/package -follow -type f)
(cd $(basename $@); zip ../$(@F) $$(find . -follow) > /dev/null)
driver/legrand-rflc/package.zip: $(shell find driver/legrand-rflc/package -follow -type f)
(cd $(basename $@); zip ../$(@F) $$(find . -follow) > /dev/null)
driver/sundial/package.zip: $(shell find driver/sundial/package -follow -type f)
(cd $(basename $@); zip ../$(@F) $$(find . -follow) > /dev/null)
driver/wake-on-lan/package.zip: $(shell find driver/wake-on-lan/package -follow -type f)
(cd $(basename $@); zip ../$(@F) $$(find . -follow) > /dev/null)
driver/bug/package.zip: $(shell find driver/bug/package -follow -type f)
(cd $(basename $@); zip ../$(@F) $$(find . -follow) > /dev/null)
$(DRIVERS):: %/driver: %/package.zip
./smartthings edge:drivers:package --upload $< > /dev/null
./smartthings edge:drivers -y --indent=1 | grep -E '^ (driverId|name|version|packageKey):' | paste - - - - | grep "packageKey: $$(basename $(@D))" | tr \\t \\n | sed 's/^\s*\w*:\s*//' > $@
# install all DRIVERS through $(CHANNEL) on $(HUB)
install: $(DRIVERS)
for driver in $^; do\
./smartthings edge:drivers:install --channel=$(CHANNEL) --hub=$(HUB) $$(head -1 $$driver);\
done
# uninstall all DRIVERS on $(HUB)
uninstall: $(DRIVERS)
for driver in $^; do\
./smartthings edge:drivers:uninstall --hub=$(HUB) $$(head -1 $$driver);\
done
$(LOGCATS):: %/logcat: %/driver
./smartthings edge:drivers:logcat --hub-address=$(ADDRESS) $$(head -1 $<)