Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add jansson JSON library #139

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ jobs:

run: |
find $(pwd) -name '.git' -exec bash -c 'git config --global --add safe.directory ${0%/.git}' {} \;
./autogen.sh --enable-embedded-yajl
./configure --enable-embedded-yajl CFLAGS='-Wall -Wextra -Werror'
make -j $(nproc) distcheck DISTCHECK_CONFIGURE_FLAGS="--enable-embedded-yajl"
./autogen.sh --enable-embedded-yajl --enable-embedded-jansson
./configure --enable-embedded-yajl --enable-embedded-jansson CFLAGS='-Wall -Wextra -Werror'
make -j $(nproc) distcheck DISTCHECK_CONFIGURE_FLAGS="--enable-embedded-yajl --enable-embedded-jansson" AM_DISTCHECK_DVI_TARGET="" TESTS=""
# check that the working dir is clean
git describe --broken --dirty --all | grep -qv dirty
make clean
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
[submodule "yajl"]
path = yajl
url = https://github.com/containers/yajl.git
[submodule "jansson"]
path = jansson
url = https://github.com/akheron/jansson
14 changes: 12 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
DIST_SUBDIRS = yajl
SUBDIRS = yajl
DIST_SUBDIRS = yajl jansson
SUBDIRS = yajl jansson

AM_CFLAGS = $(WARN_CFLAGS) -I$(top_srcdir)/src -I$(top_builddir)/src

if HAVE_EMBEDDED_YAJL
AM_CFLAGS += -I$(top_srcdir)/yajl/src/headers
endif HAVE_EMBEDDED_YAJL

if HAVE_EMBEDDED_JANSSON
AM_CFLAGS += -I$(top_srcdir)/jansson/src
endif HAVE_EMBEDDED_JANSSON

CLEANFILES = $(man_MANS) src/runtime_spec_stamp src/image_spec_stamp src/image_manifest_stamp src/basic-test_stamp

GITIGNOREFILES = build-aux/ gtk-doc.make config.h.in aclocal.m4
Expand Down Expand Up @@ -161,6 +165,12 @@ else
TESTS_LDADD += $(YAJL_LIBS)
endif

if HAVE_EMBEDDED_JANSSON
TESTS_LDADD += jansson/src/.libs/libjansson.la
else
TESTS_LDADD += $(JANSSON_LIBS)
endif

libocispec_a_SOURCES =

libocispec.a: libocispec.la $(BUILT_SOURCES) src/runtime_spec_stamp src/image_spec_stamp src/image_manifest_stamp src/basic-test_stamp
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ from C, and generate json string from corresponding struct.
The parser is generated directly from the JSON schema in the source repository.

## Installation
Expects [yajl](https://github.com/containers/yajl) to be installed and linkable.
Expects [yajl](https://github.com/containers/yajl) and [jansson](https://github.com/akheron/jansson) to be installed and linkable.
```sh
$ ./autogen.sh
$ ./configure
Expand Down
2 changes: 2 additions & 0 deletions autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ if ! (autoreconf --version >/dev/null 2>&1); then
exit 1
fi

(cd ./jansson; autoreconf -i)

mkdir -p m4

autoreconf --force --install --verbose
Expand Down
19 changes: 17 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ AM_INIT_AUTOMAKE([1.11 -Wno-portability foreign tar-ustar no-dist-gzip dist-xz s
AM_MAINTAINER_MODE([enable])
AM_SILENT_RULES([yes])

AM_EXTRA_RECURSIVE_TARGETS([yajl])
AC_CONFIG_SUBDIRS([yajl])
AM_EXTRA_RECURSIVE_TARGETS([yajl jansson])
AC_CONFIG_SUBDIRS([yajl jansson])

AC_ARG_ENABLE(embedded-yajl,
AS_HELP_STRING([--enable-embedded-yajl], [Statically link a modified yajl version]),
Expand All @@ -30,6 +30,21 @@ AC_SEARCH_LIBS(yajl_tree_get, [yajl], [AC_DEFINE([HAVE_YAJL], 1, [Define if liby
PKG_CHECK_MODULES([YAJL], [yajl >= 2.0.0])
])

AC_ARG_ENABLE(embedded-jansson,
AS_HELP_STRING([--enable-embedded-jansson], [Statically link a jansson version]),
[
case "${enableval}" in
yes) embedded_jansson=true ;;
no) embedded_jansson=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-embedded-jansson) ;;
esac],[embedded_jansson=false])

AM_CONDITIONAL([HAVE_EMBEDDED_JANSSON], [test x"$embedded_jansson" = xtrue])
AM_COND_IF([HAVE_EMBEDDED_JANSSON], [], [
AC_SEARCH_LIBS(json_object, [jansson], [AC_DEFINE([HAVE_JANSSON], 1, [Define if libjansson is available])], [AC_MSG_ERROR([*** libjansson headers not found])])
PKG_CHECK_MODULES([JANSSON], [jansson >= 2.14])
])

# Optionally install the library.
AC_ARG_ENABLE(libocispec-install,
AS_HELP_STRING([--enable-libocispec-install], [Enable libocispec installation]),
Expand Down
1 change: 1 addition & 0 deletions jansson
Submodule jansson added at 684e18
2 changes: 1 addition & 1 deletion ocispec.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ includedir=@includedir@

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