Page MenuHomeFreeBSD

flua: add ucl library
ClosedPublic

Authored by freqlabs on May 26 2020, 2:33 AM.

Details

Summary

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.

Test Plan
local ucl = require('ucl')
local parser = ucl.parser()
local res, err = parser:parse_string(io.read('*a'))
if not res then
        print('parser error: ' .. err)
        return 1
end
local obj = parser:get_object()
print(ucl.to_format(obj, 'config'))
print(ucl.to_format(obj, 'json'))
print(ucl.to_format(obj, 'json-compact'))
print(ucl.to_format(obj, 'yaml'))

/usr/libexec/flua test.lua </etc/rc.conf

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

This revision is now accepted and ready to land.Jun 21 2020, 8:00 AM

Drop the ifndef BOOTSTRAPPING part, so we have UCL in the bootstrap flua, too.

This revision now requires review to proceed.Jun 21 2020, 8:47 PM

Just FYI I'm planning to add module loading support to flua soon, although the current plan is not to have it enabled under BOOTSTRAPPING.

Just FYI I'm planning to add module loading support to flua soon, although the current plan is not to have it enabled under BOOTSTRAPPING.

Awesome :)

This will need a little bit of ^/Makefile.inc1 work to make sure libucl is built for bootstrap flua:

<incorrect statements>

  • _prebuild_libs should have a ${_lib_libucl} added to it
  • Define _lib_libucl where _flua is defined, so that we prebuild libucl only if we're building bootstrap flua
  • Make sure libucl depends on msun properly with the proper libname__L line, as can be seen later with libdialog; this would also go in the BOOTSTRAPPING block

</incorrect statements>

  • Add libucl to _flua and make sure it's on the dependency line above it as well

Off the top of my head, I think that's it. You can bump the BOOTSTRAPPING version to later than your running system to test bootstrap flua, which we may want to do anyways to make sure we've got a flua with libucl if I rewrite generate-ucl.sh with it.

Add libucl to bootstrap.
When something actually uses it we can bump the BOOTSTRAPPING version in Makefile.inc1.

This revision is now accepted and ready to land.Jun 22 2020, 2:02 AM
This revision was automatically updated to reflect the committed changes.