Skip to content

Commit 3abde43

Browse files
committed
Add json-c
Signed-off-by: Sourav Moitra <[email protected]>
1 parent fc09e1b commit 3abde43

File tree

11 files changed

+312
-499
lines changed

11 files changed

+312
-499
lines changed

.github/workflows/test.yaml

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ jobs:
2020
distro: ubuntu_latest
2121
steps:
2222
- uses: actions/[email protected]
23-
with:
24-
submodules: true
25-
set-safe-directory: true
2623

2724
- uses: uraimo/[email protected]
2825
name: Build
@@ -33,29 +30,16 @@ jobs:
3330

3431
githubToken: ${{ github.token }}
3532

36-
setup: |
37-
git submodule update --init --recursive
38-
git clone https://github.com/akheron/jansson
39-
# Install jansson
40-
cd jansson;
41-
autoreconf -fi;
42-
./configure;
43-
make;
44-
make install;
45-
cd ..
46-
4733
install: |
4834
apt-get update -q -y
49-
apt-get install -q -y python3 automake libtool autotools-dev git make cmake pkg-config gcc wget xz-utils
35+
apt-get install -q -y python3 automake libtool autotools-dev git make cmake pkg-config gcc wget xz-utils libjson-c-dev
5036
5137
run: |
5238
# Configure and Run libocispec
53-
export JANSSON_CFLAGS=-I/usr/local/include;
54-
export JANSSON_LIBS=/usr/local/lib/libjansson.so
5539
find $(pwd) -name '.git' -exec bash -c 'git config --global --add safe.directory ${0%/.git}' {} \;
5640
./autogen.sh
5741
./configure CFLAGS='-Wall -Wextra -Werror'
58-
make -j $(nproc) distcheck AM_DISTCHECK_DVI_TARGET="" TESTS=""
42+
make -j $(nproc) distcheck AM_DISTCHECK_DVI_TARGET=""
5943
# check that the working dir is clean
6044
git describe --broken --dirty --all | grep -qv dirty
6145
make clean

Containerfile

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:22.04
1+
FROM ubuntu:24.04
22

33
RUN apt-get update && \
44
apt-get install -y \
@@ -7,19 +7,14 @@ RUN apt-get update && \
77
git \
88
libtool \
99
pkg-config \
10-
python3
10+
python3 \
11+
libjson-c-dev
1112

1213

1314
COPY . libocispec
1415

15-
RUN git clone https://github.com/akheron/jansson
16-
17-
RUN cd jansson && autoreconf -fi && ./configure && make && make install
18-
1916
RUN cd libocispec && \
20-
export JANSSON_CFLAGS=-I/usr/local/include && \
21-
export JANSSON_LIBS=/usr/local/lib/libjansson.so && \
2217
./autogen.sh && \
2318
./configure CFLAGS='-Wall -Wextra -Werror' && \
24-
make -j $(nproc) distcheck DISTCHECK_CONFIGURE_FLAGS="--enable-embedded-yajl" AM_DISTCHECK_DVI_TARGET="" TESTS="" && \
25-
make clean
19+
make -j $(nproc) distcheck AM_DISTCHECK_DVI_TARGET="" && \
20+
make clean

configure.ac

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ AM_INIT_AUTOMAKE([1.11 -Wno-portability foreign tar-ustar no-dist-gzip dist-xz s
1212
AM_MAINTAINER_MODE([enable])
1313
AM_SILENT_RULES([yes])
1414

15-
AM_CONDITIONAL([HAVE_EMBEDDED_JANSSON], [test x"$embedded_jansson" = xtrue])
16-
AM_COND_IF([HAVE_EMBEDDED_JANSSON], [], [
17-
AC_SEARCH_LIBS(json_object, [jansson], [AC_DEFINE([HAVE_JANSSON], 1, [Define if libjansson is available])], [AC_MSG_ERROR([*** libjansson headers not found])])
18-
PKG_CHECK_MODULES([JANSSON], [jansson >= 2.14])
19-
])
15+
AC_SEARCH_LIBS(json_c_version, [json-c], [AC_DEFINE([HAVE_JSONC], 1, [Define if json-c is available])], [AC_MSG_ERROR([*** json-c headers not found])])
2016

2117
# Optionally install the library.
2218
AC_ARG_ENABLE(libocispec-install,

image-spec

Submodule image-spec updated 1 file

ocispec.pc.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ includedir=@includedir@
55

66
Name: @PACKAGE_NAME@
77
Description: A library for easily parsing [OCI runtime](https://github.com/opencontainers/runtime-spec) and [OCI image](https://github.com/opencontainers/image-spec) files.
8-
Requires: yajl jansson
8+
Requires: jansson
99
Version: @PACKAGE_VERSION@
1010
Libs: -L${libdir} -locispec
1111
Cflags: -I${includedir}/ocispec

src/ocispec/headers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def append_header_arr(obj, header, prefix):
6060
typename = helpers.get_name_substr(obj.name, prefix)
6161
header.append(f"}}\n{typename};\n\n")
6262
header.append(f"void free_{typename} ({typename} *ptr);\n\n")
63-
header.append(f"{typename} *make_{typename} (json_t *jtree, const struct parser_context *ctx, parser_error *err);\n\n")
63+
header.append(f"{typename} *make_{typename} (json_object *jtree, const struct parser_context *ctx, parser_error *err);\n\n")
6464

6565

6666
def append_header_map_str_obj(obj, header, prefix):
@@ -164,7 +164,7 @@ def append_type_c_header(obj, header, prefix):
164164
else:
165165
append_header_child_others(i, header, prefix)
166166
if obj.children is not None:
167-
header.append(" json_t *_residual;\n")
167+
header.append(" struct json_object *_residual;\n")
168168
if len(present_tags) > 0:
169169
header.append("\n")
170170
for tag in present_tags:
@@ -173,8 +173,8 @@ def append_type_c_header(obj, header, prefix):
173173
header.append(f"}}\n{typename};\n\n")
174174
header.append(f"void free_{typename} ({typename} *ptr);\n\n")
175175
header.append(f"{typename} *clone_{typename} ({typename} *src);\n")
176-
header.append(f"{typename} *make_{typename} (json_t *jtree, const struct parser_context *ctx, parser_error *err);\n\n")
177-
header.append(f"int gen_{typename} (json_t *root, const {typename} *ptr, parser_error *err);\n\n")
176+
header.append(f"{typename} *make_{typename} (json_object *jtree, const struct parser_context *ctx, parser_error *err);\n\n")
177+
header.append(f"int gen_{typename} (json_object *root, const {typename} *ptr, parser_error *err);\n\n")
178178

179179
def header_reflect_top_array(obj, prefix, header):
180180
c_typ = helpers.get_prefixed_pointer(obj.name, obj.subtyp, prefix) or \

0 commit comments

Comments
 (0)