build: Rework path construction to reliably add prefix

There were a couple of custom paths which could end up being relative,
rather than absolute, due to not properly prefixing them with
`get_option('prefix')`.

The use of `join_paths()` here correctly drops all path components
before the final absolute path in the list of arguments. So if someone
configures GLib with an absolute path for `gio_module_dir`, that will be
used unprefixed; but if someone configures with a relative path, it will
be prefixed by `get_option('prefix)`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #1919
This commit is contained in:
Philip Withnall 2020-02-07 16:34:13 +00:00
parent 0f264eb97e
commit 65be80c3ed
5 changed files with 18 additions and 15 deletions

View File

@ -24,7 +24,7 @@ gdbus_codegen = configure_file(input : 'gdbus-codegen.in',
# Provide tools for others when we're a subproject and they use the Meson GNOME module
meson.override_find_program('gdbus-codegen', gdbus_codegen)
codegen_dir = join_paths(get_option('datadir'), 'glib-2.0/codegen')
codegen_dir = join_paths(glib_datadir, 'glib-2.0', 'codegen')
gdbus_codegen_built_files = []
gdbus_codegen_built_files += configure_file(input : 'config.py.in',

View File

@ -811,9 +811,10 @@ libgio = library('gio-2.0',
link_args : [noseh_link_args, glib_link_flags],
)
giomodulesdir = get_option('gio_module_dir')
if giomodulesdir == ''
giomodulesdir = join_paths('${libdir}', 'gio', 'modules')
if get_option('gio_module_dir') != ''
pkgconfig_giomodulesdir = join_paths('${prefix}', get_option('gio_module_dir'))
else
pkgconfig_giomodulesdir = join_paths('${libdir}', 'gio', 'modules')
endif
schemas_subdir = join_paths('glib-2.0', 'schemas')
@ -824,7 +825,7 @@ pkg.generate(libgio,
variables : ['datadir=' + join_paths('${prefix}', get_option('datadir')),
'schemasdir=' + join_paths('${datadir}', schemas_subdir),
'bindir=' + join_paths('${prefix}', get_option('bindir')),
'giomoduledir=' + giomodulesdir,
'giomoduledir=' + pkgconfig_giomodulesdir,
'gio=' + join_paths('${bindir}', 'gio'),
'gio_querymodules=' + join_paths('${bindir}', 'gio-querymodules'),
'glib_compile_schemas=' + join_paths('${bindir}', 'glib-compile-schemas'),

View File

@ -338,6 +338,6 @@ gnulib_lib = static_library('gnulib', gnulib_sources,
dependencies : [libm],
include_directories : [configinc, glibinc, include_directories ('.')],
pic : true,
c_args : ['-DGCC_LINT=1', '-DLIBDIR="@0@"'.format(get_option('libdir')), '-DGLIB_COMPILATION', '-DG_LOG_DOMAIN="GLib"' ] + glib_hidden_visibility_args + extra_gnulib_args)
c_args : ['-DGCC_LINT=1', '-DLIBDIR="@0@"'.format(glib_libdir), '-DGLIB_COMPILATION', '-DG_LOG_DOMAIN="GLib"' ] + glib_hidden_visibility_args + extra_gnulib_args)
gnulib_libm_dependency = [libm]

View File

@ -1,9 +1,4 @@
charsetalias_dir = get_option('charsetalias_dir')
if charsetalias_dir == ''
charsetalias_dir = get_option('libdir')
endif
charset_lib = static_library('charset', 'localcharset.c',
include_directories : configinc,
pic : true,
c_args : [ '-DGLIB_CHARSETALIAS_DIR="@0@"'.format(charsetalias_dir) ] + glib_hidden_visibility_args)
c_args : [ '-DGLIB_CHARSETALIAS_DIR="@0@"'.format(glib_charsetaliasdir) ] + glib_hidden_visibility_args)

View File

@ -63,13 +63,20 @@ glib_libexecdir = join_paths(glib_prefix, get_option('libexecdir'))
glib_datadir = join_paths(glib_prefix, get_option('datadir'))
glib_pkgdatadir = join_paths(glib_datadir, 'glib-2.0')
glib_includedir = join_paths(glib_prefix, get_option('includedir'))
glib_giomodulesdir = get_option('gio_module_dir')
if glib_giomodulesdir == ''
if get_option('gio_module_dir') != ''
glib_giomodulesdir = join_paths(glib_prefix, get_option('gio_module_dir'))
else
glib_giomodulesdir = join_paths(glib_libdir, 'gio', 'modules')
endif
glib_pkgconfigreldir = join_paths(glib_libdir, 'pkgconfig')
if get_option('charsetalias_dir') != ''
glib_charsetaliasdir = join_paths(glib_prefix, get_option('charsetalias_dir'))
else
glib_charsetaliasdir = glib_libdir
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')
@ -2216,7 +2223,7 @@ if get_option('man')
'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl',
'@INPUT@',
]
man1_dir = get_option('mandir') + '/man1'
man1_dir = join_paths(glib_prefix, get_option('mandir'), 'man1')
endif
gnome = import('gnome')