add tests, initial protobuf and rabbitmq support, ...

This commit is contained in:
dragonmuffin 2025-03-04 22:03:00 +05:00
parent 54adfcee2a
commit 7510c2a7b3
13 changed files with 421 additions and 39 deletions

View file

@ -1,19 +1,44 @@
.PHONY: all clean install uninstall
.PHONY: all clean install uninstall test
PROTOBUF=/usr/include/
STARTER=starter
GEN=gen
SRCS=$(STARTER)/cgroup_prepare.c $(STARTER)/ns_exec.c $(STARTER)/util.c $(STARTER)/starter.c
RUNS=runs
PROTO_OUT=$(GEN)/google/protobuf/empty.pb-c.c $(GEN)/google/protobuf/empty.pb-c.h $(GEN)/google/protobuf/timestamp.pb-c.c $(GEN)/google/protobuf/timestamp.pb-c.h $(GEN)/google/protobuf/duration.pb-c.c $(GEN)/google/protobuf/duration.pb-c.h gen/runner/v1/runner.pb-c.c gen/runner/v1/runner.pb-c.c
all: proto $(STARTER)/alpine-make-rootfs $(STARTER)/minrootfs $(STARTER)/starter
proto: /usr/include/google/protobuf/empty.proto proto/runner/v1/runner.proto
all: $(STARTER)/alpine-make-rootfs $(STARTER)/minrootfs $(STARTER)/starter transport/transport $(RUNS)
$(GEN):
mkdir -p $(GEN)
protoc --c_out=$(GEN) runner/v1/runner.proto -I proto
$(GEN)/google/protobuf/empty.pb-c.c $(GEN)/google/protobuf/empty.pb-c.h: $(PROTOBUF)/google/protobuf/empty.proto $(GEN)
protoc --c_out=$(GEN) google/protobuf/empty.proto -I $(PROTOBUF)
$(GEN)/google/protobuf/timestamp.pb-c.c $(GEN)/google/protobuf/timestamp.pb-c.h: $(PROTOBUF)/google/protobuf/timestamp.proto $(GEN)
protoc --c_out=$(GEN) google/protobuf/timestamp.proto -I $(PROTOBUF)
$(GEN)/google/protobuf/duration.pb-c.c $(GEN)/google/protobuf/duration.pb-c.h: $(PROTOBUF)/google/protobuf/duration.proto $(GEN)
protoc --c_out=$(GEN) google/protobuf/duration.proto -I $(PROTOBUF)
gen/runner/v1/runner.pb-c.c gen/runner/v1/runner.pb-c.h: proto/runner/v1/runner.proto $(GEN)
protoc --c_out=$(GEN) runner/v1/runner.proto -I proto
$(STARTER)/alpine-make-rootfs:
git clone https://github.com/alpinelinux/alpine-make-rootfs starter/alpine-make-rootfs
$(STARTER)/minrootfs: $(STARTER)/create_rootfs.sh
$(STARTER)/create_rootfs.sh
$(STARTER)/starter: proto $(STARTER)/starter.c $(STARTER)/cgroup_prepare.c $(STARTER)/ns_exec.c Makefile
$(CC) -o $(STARTER)/starter $(SRCS) -g -fsanitize=address -fsanitize=leak -fno-omit-frame-pointer -lrabbitmq -lprotobuf-c -I gen
$(STARTER)/starter: $(PROTO) $(STARTER)/starter.c $(STARTER)/cgroup_prepare.c $(STARTER)/ns_exec.c Makefile
#$(CC) -shared -o $(STARTER)/starter $(SRCS) -g -fsanitize=address -fsanitize=leak -fno-omit-frame-pointer -lrabbitmq -lprotobuf-c -I gen
$(CC) -fPIC -shared -o $(STARTER)/starter $(SRCS) -lrabbitmq -lprotobuf-c -I gen
#$(CC) $(STARTER)/starter.c -o $(STARTER)/starter
transport/transport: $(PROTO) transport/utils.c transport/transport.c transport/transport.h
$(CC) -o $@ gen/runner/v1/runner.pb-c.c transport/utils.c transport/transport.c -I . -I gen -lrabbitmq -lprotobuf-c -g -fsanitize=address -fsanitize=leak -fno-omit-frame-pointer
$(RUNS):
mkdir $(RUNS)
include tests/Makefile