mirror of
https://github.com/chirpstack/chirpstack.git
synced 2025-05-19 09:13:16 +00:00
api: Add C support (#549)
This commit is contained in:
parent
d5929e0523
commit
87c918bc35
16
api/Dockerfile-c
vendored
Normal file
16
api/Dockerfile-c
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
FROM alpine:latest
|
||||||
|
|
||||||
|
ENV PROJECT_PATH=/chirpstack/api
|
||||||
|
RUN apk add --no-cache make git bash protobuf protobuf-dev pkgconfig autoconf automake libtool gcc g++
|
||||||
|
|
||||||
|
# Install protobuf implementation for C
|
||||||
|
RUN git clone --depth=1 https://github.com/protobuf-c/protobuf-c.git /protobuf-c
|
||||||
|
RUN cd /protobuf-c && ./autogen.sh && ./configure && make && make install
|
||||||
|
|
||||||
|
|
||||||
|
# Proto dependencies stuff
|
||||||
|
RUN git clone --depth=1 https://github.com/protocolbuffers/protobuf.git /protobuf
|
||||||
|
RUN git clone --depth=1 https://github.com/googleapis/googleapis.git /googleapis
|
||||||
|
|
||||||
|
RUN mkdir -p PROJECT_PATH
|
||||||
|
WORKDIR $PROJECT_PATH
|
7
api/Makefile
vendored
7
api/Makefile
vendored
@ -1,6 +1,6 @@
|
|||||||
.PHONY: rust grpc-web go js python md java kotlin csharp php
|
.PHONY: rust grpc-web go js python md java kotlin csharp php c
|
||||||
|
|
||||||
all: rust grpc-web go js python md java kotlin csharp php
|
all: rust grpc-web go js python md java kotlin csharp php c
|
||||||
|
|
||||||
rust:
|
rust:
|
||||||
cd rust && make
|
cd rust && make
|
||||||
@ -31,3 +31,6 @@ csharp:
|
|||||||
|
|
||||||
php:
|
php:
|
||||||
docker compose run --rm chirpstack-api-php
|
docker compose run --rm chirpstack-api-php
|
||||||
|
|
||||||
|
c:
|
||||||
|
docker compose run --rm chirpstack-api-c
|
||||||
|
2
api/c/.gitignore
vendored
Normal file
2
api/c/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/src/
|
||||||
|
/proto/
|
34
api/c/Makefile
vendored
Normal file
34
api/c/Makefile
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
.PHONY: all pre-build
|
||||||
|
|
||||||
|
PROTOC := protoc-c
|
||||||
|
PROTOC_ARGS := -I=proto -I=proto/chirpstack-api --c_out=./src
|
||||||
|
|
||||||
|
GOOGLE_PROTOBUF_REQUIREMENTS =
|
||||||
|
GOOGLE_PROTOBUF_REQUIREMENTS += timestamp.proto
|
||||||
|
GOOGLE_PROTOBUF_REQUIREMENTS += duration.proto
|
||||||
|
GOOGLE_PROTOBUF_REQUIREMENTS += struct.proto
|
||||||
|
GOOGLE_PROTOBUF_REQUIREMENTS += empty.proto
|
||||||
|
GOOGLE_PROTOBUF_REQUIREMENTS += descriptor.proto
|
||||||
|
GOOGLE_PROTOBUF_OUTPUT = $(patsubst %.proto, src/google/protobuf/%.pb-c.h, $(GOOGLE_PROTOBUF_REQUIREMENTS))
|
||||||
|
|
||||||
|
all: pre-build $(GOOGLE_PROTOBUF_OUTPUT) build
|
||||||
|
|
||||||
|
pre-build:
|
||||||
|
rm -rf proto src
|
||||||
|
mkdir -p proto/chirpstack-api
|
||||||
|
mkdir -p proto/google/protobuf
|
||||||
|
cp -r ../proto/* proto/chirpstack-api/
|
||||||
|
mv proto/chirpstack-api/google/api proto/google/api
|
||||||
|
mkdir -p src
|
||||||
|
sed -i \
|
||||||
|
-r 's/(\s+bytes std)(in|out|err)(\s+=.*)/\1_\2\3/' \
|
||||||
|
proto/chirpstack-api/gw/gw.proto
|
||||||
|
|
||||||
|
src/google/protobuf/%.pb-c.h: /protobuf/src/google/protobuf/%.proto
|
||||||
|
cp $< proto/google/protobuf/
|
||||||
|
|
||||||
|
build:
|
||||||
|
find proto \
|
||||||
|
-name '*.proto' \
|
||||||
|
-type f \
|
||||||
|
-exec $(PROTOC) $(PROTOC_ARGS) {} \;
|
7
api/docker-compose.yml
vendored
7
api/docker-compose.yml
vendored
@ -49,3 +49,10 @@ services:
|
|||||||
command: bash -c "cd php && make all"
|
command: bash -c "cd php && make all"
|
||||||
volumes:
|
volumes:
|
||||||
- ./:/chirpstack/api
|
- ./:/chirpstack/api
|
||||||
|
chirpstack-api-c:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile-c
|
||||||
|
command: bash -c "cd c && make all"
|
||||||
|
volumes:
|
||||||
|
- ./:/chirpstack/api
|
||||||
|
Loading…
x
Reference in New Issue
Block a user