Files
Pagerino_Portainer/AppServer/Makefile
2025-09-11 22:26:30 +02:00

41 lines
985 B
Makefile

# Makefile for compiling all proto files into Go
PROTO_IN := src/app_comm/proto
PROTO_OUT := src/app_comm/api
# Find all .proto files recursively
PROTO_FILES := $(shell find $(PROTO_IN) -name "*.proto")
GO_FILES := $(shell find ./src/** -name "*.go")
# Default target
all: proto
# Go build
go: $(GO_FILES)
@echo "Building Go application..."
go build -o ../build/app_server -C src
@echo "Done."
# Compile all proto files
proto: $(PROTO_FILES)
@echo "Generating Go code from proto files..."
@for f in $(PROTO_FILES); do \
base=$${f##*/}; \
name=$${base%%.*}; \
echo "Generating $$f -> $(PROTO_OUT)/$$name"; \
mkdir -p $(PROTO_OUT)/$$name; \
protoc -I=$(PROTO_IN) \
--go_out=$(PROTO_OUT)/$$name --go_opt=paths=source_relative \
--go-grpc_out=$(PROTO_OUT)/$$name --go-grpc_opt=paths=source_relative \
$$f || exit 1; \
done
@echo "Done."
# Clean builds
clean:
@echo "Deleting built files..."
rm -rf $(PROTO_OUT)/* build/*
@echo "Done."
.PHONY: all clean