flua: add ucl library

libucl comes with a Lua library binding.  Build it into flua.

This lets us parse/generate config files in the various formats supported by
libucl with flua.  For example, the following script will detect the format of
an object written to stdin as one of UCL config, JSON, or YAML and write it to
stdout as pretty-printed JSON:

local ucl = require('ucl')
local parser = ucl.parser()
parser:parse_string(io.read('*a'))
local obj = parser:get_object()
print(ucl.to_format(obj, 'json'))

Reviewed by:	kevans, pstef
Approved by:	mmacy (mentor)
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D25009
This commit is contained in:
Ryan Moeller 2020-06-22 03:14:43 +00:00
parent f82d3b3988
commit 94a8266684
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=362477
4 changed files with 11 additions and 2 deletions

View File

@ -2112,8 +2112,8 @@ ${_bt}-lib/libdwarf: ${_bt_m4_depend}
# 13.0-CURRENT cycle, thus needs to be built on -older releases and stable # 13.0-CURRENT cycle, thus needs to be built on -older releases and stable
# branches. # branches.
.if ${BOOTSTRAPPING} < 1300059 .if ${BOOTSTRAPPING} < 1300059
${_bt}-libexec/flua: ${_bt}-lib/liblua ${_bt}-libexec/flua: ${_bt}-lib/liblua ${_bt}-lib/libucl
_flua= lib/liblua libexec/flua _flua= lib/liblua lib/libucl libexec/flua
.endif .endif
# r245440 mtree -N support added # r245440 mtree -N support added

View File

@ -32,4 +32,10 @@ CFLAGS+= -I${SRCTOP}/lib/libedit -I${SRCTOP}/contrib/libedit
LIBADD+= edit LIBADD+= edit
.endif .endif
UCLSRC?= ${SRCTOP}/contrib/libucl
.PATH: ${UCLSRC}/lua
SRCS+= lua_ucl.c
CFLAGS+= -I${UCLSRC}/include -I${UCLSRC}/src -I${UCLSRC}/uthash
LIBADD+= ucl
.include <bsd.prog.mk> .include <bsd.prog.mk>

View File

@ -36,6 +36,7 @@
#include "lauxlib.h" #include "lauxlib.h"
#include "lfs.h" #include "lfs.h"
#include "lposix.h" #include "lposix.h"
#include "lua_ucl.h"
/* /*
** these libs are loaded by lua.c and are readily available to any Lua ** these libs are loaded by lua.c and are readily available to any Lua
@ -59,6 +60,7 @@ static const luaL_Reg loadedlibs[] = {
{"lfs", luaopen_lfs}, {"lfs", luaopen_lfs},
{"posix.sys.stat", luaopen_posix_sys_stat}, {"posix.sys.stat", luaopen_posix_sys_stat},
{"posix.unistd", luaopen_posix_unistd}, {"posix.unistd", luaopen_posix_unistd},
{"ucl", luaopen_ucl},
{NULL, NULL} {NULL, NULL}
}; };

View File

@ -149,6 +149,7 @@ INSTALLDIR_LIST= \
lib/casper \ lib/casper \
lib/geom \ lib/geom \
usr/include/casper \ usr/include/casper \
usr/include/private/ucl \
usr/include/private/zstd \ usr/include/private/zstd \
usr/lib \ usr/lib \
usr/libexec usr/libexec