diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2024-07-27 13:53:16 +0300 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2024-07-27 13:54:16 +0300 |
commit | ed9d0446320050b5506861c0b583e0a24c7cb9d7 (patch) | |
tree | b49fec9995a0e81dc2f0cb01c5c9118bb555ebde | |
parent | eb6765d57cfabc63bdb02375ec2e788783b88a0f (diff) | |
download | postgresql-ed9d0446320050b5506861c0b583e0a24c7cb9d7.tar.gz postgresql-ed9d0446320050b5506861c0b583e0a24c7cb9d7.zip |
Support falling back to non-preferred readline implementation with meson
To build with -Dreadline=enabled one can use either readline or
libedit. The -Dlibedit_preferred flag is supposed to control the order
of names to lookup. This works fine when either both libraries are
present or -Dreadline is set to auto. However, explicitly enabling
readline with only libedit present, but not setting libedit_preferred,
or alternatively enabling readline with only readline present, but
setting libedit_preferred, too, are both broken. This is because
cc.find_library will throw an error for a not found dependency as soon
as the first required dependency is checked, thus it's impossible to
fallback to the alternative.
Here we only check the second of the two dependencies for
requiredness, thus we only fail when none of the two can be found.
Author: Wolfgang Walther
Reviewed-by: Nazir Bilal Yavuz, Alvaro Herrera, Peter Eisentraut
Reviewed-by: Tristan Partin
Discussion: https://www.postgresql.org/message-id/ca8f37e1-a2c3-40e2-91f6-59c3d3652ad4@technowledgy.de
Backpatch: 16-, where meson support was added
-rw-r--r-- | meson.build | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/meson.build b/meson.build index 4da082e541a..d31ecef9160 100644 --- a/meson.build +++ b/meson.build @@ -1149,15 +1149,26 @@ endif if not get_option('readline').disabled() libedit_preferred = get_option('libedit_preferred') - # Set the order of readline dependencies - check_readline_deps = libedit_preferred ? \ - ['libedit', 'readline'] : ['readline', 'libedit'] + # Set the order of readline dependencies. + # cc.find_library breaks and throws on the first dependency which + # is marked as required=true and can't be found. Thus, we only mark + # the last dependency to look up as required, to not throw too early. + check_readline_deps = [ + { + 'name': libedit_preferred ? 'libedit' : 'readline', + 'required': false + }, + { + 'name': libedit_preferred ? 'readline' : 'libedit', + 'required': get_option('readline') + } + ] foreach readline_dep : check_readline_deps - readline = dependency(readline_dep, required: false) + readline = dependency(readline_dep['name'], required: false) if not readline.found() - readline = cc.find_library(readline_dep, - required: get_option('readline'), + readline = cc.find_library(readline_dep['name'], + required: readline_dep['required'], dirs: test_lib_d) endif if readline.found() |