-
Notifications
You must be signed in to change notification settings - Fork 28
/
Makefile.nanopb
31 lines (21 loc) · 955 Bytes
/
Makefile.nanopb
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
# To use install protoc and place nanopb in your $(HOME)
rwildcard = $(strip $(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d)))
# recursively find all the .proto
PROTOS := $(strip $(call rwildcard,src,*.proto))
filter := src/blockchain_block.proto src/blockchain_block_v1.proto
filter := $(filter) $(strip $(call rwildcard,src/service,*.proto))
PROTOS := $(filter-out $(filter),$(PROTOS))
# create C_SRCS which will be our build targets
C_SRCS := $(patsubst src/%.proto,build/%.c, $(PROTOS))
# create list of all directories needed for build output
DIRS := build $(patsubst src%,build%,$(dir $(C_SRCS)))
.PHONY: build clean dirs
PROTOC := protoc -I$(HOME)/nanopb/generator/proto --plugin=protoc-gen-nanopb=$(HOME)/nanopb/generator/protoc-gen-nanopb
OUT := --nanopb_out
build: $(C_SRCS)
dirs:
mkdir -p $(DIRS)
clean:
rm -rf build
build/%.c: src/%.proto dirs
$(PROTOC) $(OUT)=$(@D) $(<F) --proto_path $(<D)