Skip to content

Commit 7015ef0

Browse files
committed
netutils: Add BARE
BARE is a simple binary representation for structured application data. cbare, the BARE implementation ported by this commit, is an I/O agnostic C implementation of the BARE message encoding. Signed-off-by: Jiri Vlasak <jvlasak@elektroline.cz>
1 parent 57ced95 commit 7015ef0

4 files changed

Lines changed: 135 additions & 0 deletions

File tree

netutils/bare/Kconfig

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
config NETUTILS_BARE
2+
bool "Binary Application Record Encoding (BARE)"
3+
default n
4+
depends on ALLOW_MIT_COMPONENTS
5+
---help---
6+
BARE is a simple binary representation for structured
7+
application data.
8+
9+
See https://baremessages.org/
10+
11+
cbare is an MIT-licensed I/O agnostic C implementation of the
12+
BARE message encoding that is used when this option is enabled.
13+
14+
if NETUTILS_BARE
15+
16+
config NETUTILS_BARE_TEST
17+
bool "Enable baretest"
18+
default n
19+
---help---
20+
Enable baretest -- BARE test application.
21+
22+
endif

netutils/bare/Make.defs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
############################################################################
2+
# apps/netutils/bare/Make.defs
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more
7+
# contributor license agreements. See the NOTICE file distributed with
8+
# this work for additional information regarding copyright ownership. The
9+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
# "License"); you may not use this file except in compliance with the
11+
# License. You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations
19+
# under the License.
20+
#
21+
############################################################################
22+
23+
ifneq ($(CONFIG_NETUTILS_BARE),)
24+
CONFIGURED_APPS += $(APPDIR)/netutils/bare
25+
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/netutils/bare/cbare/src
26+
CXXFLAGS += ${INCDIR_PREFIX}$(APPDIR)/netutils/bare/cbare/src
27+
endif

netutils/bare/Makefile

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
############################################################################
2+
# apps/netutils/bare/Makefile
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more
7+
# contributor license agreements. See the NOTICE file distributed with
8+
# this work for additional information regarding copyright ownership. The
9+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
# "License"); you may not use this file except in compliance with the
11+
# License. You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations
19+
# under the License.
20+
#
21+
############################################################################
22+
23+
include $(APPDIR)/Make.defs
24+
25+
BARE_CBARE_DIR = cbare
26+
27+
DEPPATH += --dep-path $(BARE_CBARE_DIR)$(DELIM)src
28+
VPATH += :$(BARE_CBARE_DIR)$(DELIM)src
29+
30+
CFLAGS += -I$(BARE_CBARE_DIR)/src
31+
32+
CSRCS = $(BARE_CBARE_DIR)/src/alloc.c
33+
CSRCS += $(BARE_CBARE_DIR)/src/cbare.c
34+
CSRCS += $(BARE_CBARE_DIR)/src/die.c
35+
36+
ifneq ($(CONFIG_NETUTILS_BARE_TEST),)
37+
38+
PROGNAME = baretest
39+
PRIORITY = 100
40+
STACKSIZE = 2048
41+
MODULE = y
42+
43+
MAINSRC = $(BARE_CBARE_DIR)/test/baretest.c
44+
45+
endif
46+
47+
$(BARE_CBARE_DIR):
48+
$(Q) echo "Cloning cbare repo..."
49+
$(Q) git clone --depth=1 https://git.sr.ht/~fsx/cbare
50+
$(Q) patch -p1 --directory=cbare < cbare_porting_for_nuttx.patch
51+
$(Q) touch $(BARE_CBARE_DIR)
52+
53+
context:: $(BARE_CBARE_DIR)
54+
55+
distclean::
56+
$(call DELDIR, $(BARE_CBARE_DIR))
57+
58+
include $(APPDIR)/Application.mk
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
diff --git i/src/cbare.c w/src/cbare.c
2+
index 208639f..a3081fb 100644
3+
--- i/src/cbare.c
4+
+++ w/src/cbare.c
5+
@@ -4,7 +4,9 @@
6+
#include "cbare.h"
7+
#include "utf8.h"
8+
9+
+#ifndef UNUSED
10+
#define UNUSED(x) (void)(x)
11+
+#endif
12+
13+
enum {
14+
U8SZ = 1,
15+
diff --git i/test/baretest.c w/test/baretest.c
16+
index 1561f4c..9df740f 100644
17+
--- i/test/baretest.c
18+
+++ w/test/baretest.c
19+
@@ -10,7 +10,9 @@
20+
#include "alloc.h"
21+
#include "die.h"
22+
23+
+#ifndef UNUSED
24+
#define UNUSED(x) (void)(x)
25+
+#endif
26+
27+
#define ARRLEN(a) sizeof(a)/sizeof(a[0])
28+

0 commit comments

Comments
 (0)