build: Add runtime_dir option to set runstatedir path

This will be used in upcoming commits to allow the previously-hardcoded
`/run` path to be set at configure time.

Most people will not want to change it from `/run`, even when building
test builds, as otherwise interaction with system mounts and services
will not work.

Inspired by equivalent changes in dbus.git in their commit
ff92efa389a57a5250c6996df6614234d4d462e0.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
Philip Withnall 2022-11-30 13:45:34 +00:00
parent 3bbe96ca89
commit 30995f9dd7
2 changed files with 21 additions and 0 deletions

View File

@ -125,6 +125,17 @@ endif
glib_localstatedir = glib_prefix / get_option('localstatedir')
if get_option('runtime_dir') != ''
glib_runstatedir = glib_prefix / get_option('runtime_dir')
else
# While wed normally prefix directories like this with, for example,
# glib_localstatedir, `/run` is a bit different in that its for runtime state
# rather than data files, so its typically functionally useless to use a
# prefixed version. No other processes will be using it. So we default to the
# unprefixed system `/run` directory.
glib_runstatedir = '/run'
endif
installed_tests_metadir = join_paths(glib_datadir, 'installed-tests', meson.project_name())
installed_tests_execdir = join_paths(glib_libexecdir, 'installed-tests', meson.project_name())
installed_tests_enabled = get_option('installed_tests')
@ -2106,6 +2117,7 @@ glib_conf.set('HAVE_GETTEXT', 1)
glib_conf.set_quoted('GLIB_LOCALE_DIR', join_paths(glib_datadir, 'locale'))
glib_conf.set_quoted('GLIB_LOCALSTATEDIR', glib_localstatedir)
glib_conf.set_quoted('GLIB_RUNSTATEDIR', glib_runstatedir)
# libmount is only used by gio, but we need to fetch the libs to generate the
# pkg-config file below
@ -2446,6 +2458,7 @@ summary({
'includedir' : glib_includedir,
'giomodulesdir' : glib_giomodulesdir,
'localstatedir' : glib_localstatedir,
'runstatedir' : glib_runstatedir,
}, section: 'Directories')
if get_option('multiarch')

View File

@ -14,6 +14,14 @@ option('gio_module_dir',
value : '',
description : 'load gio modules from this directory (default to \'libdir/gio/modules\' if unset)')
# FIXME: Deliberately not named runstatedir to avoid colliding with
# https://github.com/mesonbuild/meson/issues/4141; port to that when Meson
# supports it
option('runtime_dir',
type: 'string',
value: '',
description: 'Directory for transient runtime state [default: /run]')
option('selinux',
type : 'feature',
value : 'auto',