Skip to content

Commit

Permalink
make the PostgreSQL client optional
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Feb 20, 2024
1 parent fd23930 commit 993fd52
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
7 changes: 5 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ You need:
- a C++20 compliant compiler (e.g. gcc or clang)
- `libfmt <https://fmt.dev/>`__
- `LuaJIT <http://luajit.org/>`__
- `libpq <https://www.postgresql.org/>`__ for PostgreSQL support in
Lua code
- `systemd <https://www.freedesktop.org/wiki/Software/systemd/>`__
- `Meson 0.56 <http://mesonbuild.com/>`__ and `Ninja <https://ninja-build.org/>`__

Optional dependencies:

- `libpq <https://www.postgresql.org/>`__ for PostgreSQL support in
Lua code

Get the source code::

git clone --recursive https://github.com/CM4all/qrelay.git
Expand Down
2 changes: 1 addition & 1 deletion debian/changelog
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cm4all-qrelay (0.27) unstable; urgency=low

*
* make the PostgreSQL client optional

--

Expand Down
16 changes: 13 additions & 3 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ debug = get_option('b_ndebug') != 'true'

compiler = meson.get_compiler('cpp')

conf = configuration_data()

common_flags = [
'-D_GNU_SOURCE',
]
Expand Down Expand Up @@ -120,9 +122,17 @@ subdir('libcommon/src/event/systemd')
subdir('libcommon/src/lua/event')
subdir('libcommon/src/stock')
subdir('libcommon/src/time')
subdir('libcommon/src/pg')
subdir('libcommon/src/lua/io')
subdir('libcommon/src/lua/pg')

libcommon_require_pg = get_option('pg')
subdir('libcommon/src/pg')
if pg_dep.found()
subdir('libcommon/src/lua/pg')
pg_dep = lua_pg_dep
endif

conf.set('HAVE_PG', pg_dep.found())
configure_file(output: 'config.h', configuration: conf)

executable('cm4all-qrelay',
'src/CommandLine.cxx',
Expand All @@ -146,7 +156,7 @@ executable('cm4all-qrelay',
lua_io_dep,
lua_net_dep,
lua_event_dep,
lua_pg_dep,
pg_dep,
event_net_dep,
event_net_djb_dep,
event_systemd_dep,
Expand Down
2 changes: 2 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
option('pg', type: 'feature', description: 'PostgreSQL client for Lua')

option('documentation', type: 'feature',
description: 'Build documentation')
8 changes: 7 additions & 1 deletion src/Main.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
#include "lua/io/CgroupInfo.hxx"
#include "lua/net/SocketAddress.hxx"
#include "lua/event/Init.hxx"
#include "lua/pg/Init.hxx"
#include "util/PrintException.hxx"
#include "util/ScopeExit.hxx"

#ifdef HAVE_PG
#include "lua/pg/Init.hxx"
#endif

extern "C" {
#include <lauxlib.h>
#include <lualib.h>
Expand Down Expand Up @@ -100,7 +103,10 @@ SetupConfigState(lua_State *L, Instance &instance)
luaL_openlibs(L);

Lua::InitEvent(L, instance.GetEventLoop());

#ifdef HAVE_PG
Lua::InitPg(L, instance.GetEventLoop());
#endif

Lua::InitSocketAddress(L);
RegisterLuaResolver(L);
Expand Down

0 comments on commit 993fd52

Please sign in to comment.