-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfuncs.mk
72 lines (53 loc) · 1.54 KB
/
funcs.mk
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
%.cbor: %.diag ; $(diag2cbor) $< > $@
# $1: label
# $2: cddl fragments
# $3: diag test files
# $4: start string
define cddl_check_template
check-$(1): $(1)-autogen.cddl
$$(cddl) $$< g 1
.PHONY: check-$(1)
$(1)-autogen.cddl: $(2)
$(cddlc) -2tcddl $$^ --start=$(4) > $$@
CLEANFILES += $(1)-autogen.cddl
check-$(1)-examples: $(1)-autogen.cddl $(3:.diag=.cbor)
@for f in $(3:.diag=.cbor); do \
echo ">> validating $$$$f against $$<" ; \
$$(cddl) $$< validate $$$$f &>/dev/null || exit 1 ; \
echo ">> saving prettified CBOR to $$$${f%.cbor}.pretty" ; \
$$(cbor2pretty) $$$$f > $$$${f%.cbor}.pretty ; \
done
.PHONY: check-$(1)-examples
CLEANFILES += $(3:.diag=.cbor)
CLEANFILES += $(3:.diag=.pretty)
endef # cddl_check_template
# $(1) - export label
# $(2) - cddl fragments
# $(3) - export directory
# $(4) - import dependencies
define cddl_exp_template
exp-$(1): $(3)$(1).cddl
echo ">>> Creating exportable cddl file" ;
.PHONY: exp-$(1)
$(3)$(1).cddl: $(2)
echo -e "; This cddl file depends on these cddl files: "$(4)"\n" > $$@
@for f in $$^ ; do \
( grep -v '^;' $$$$f ; echo ) ; \
done >> $$@
CLEANFILES += $(3)$(1).cddl
endef # cddl_exp_template
# $(1) - imported cddl file name without .cddl
# $(2) - github url
# $(3) - download location
# $(4) - cddl-xxxx tag name
define get_cddl_release
get-$(1): $(1).cddl
echo "Fetched cddl-release: " $$^
$(1).cddl:
@{ \
$$(curl) -LO $$(join $(2), $$(join $(3), $$(join $(4)/, $$@))); \
sed -i.bak '/^@\.start\.@/d' $$@; \
}
.PHONY: get-$(1)
CLEANFILES += $(1).cddl.bak
endef # get_cddl_release