Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ed9d044

Browse files
committed
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
1 parent eb6765d commit ed9d044

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

meson.build

+17-6
Original file line numberDiff line numberDiff line change
@@ -1149,15 +1149,26 @@ endif
11491149

11501150
if not get_option('readline').disabled()
11511151
libedit_preferred = get_option('libedit_preferred')
1152-
# Set the order of readline dependencies
1153-
check_readline_deps = libedit_preferred ? \
1154-
['libedit', 'readline'] : ['readline', 'libedit']
1152+
# Set the order of readline dependencies.
1153+
# cc.find_library breaks and throws on the first dependency which
1154+
# is marked as required=true and can't be found. Thus, we only mark
1155+
# the last dependency to look up as required, to not throw too early.
1156+
check_readline_deps = [
1157+
{
1158+
'name': libedit_preferred ? 'libedit' : 'readline',
1159+
'required': false
1160+
},
1161+
{
1162+
'name': libedit_preferred ? 'readline' : 'libedit',
1163+
'required': get_option('readline')
1164+
}
1165+
]
11551166

11561167
foreach readline_dep : check_readline_deps
1157-
readline = dependency(readline_dep, required: false)
1168+
readline = dependency(readline_dep['name'], required: false)
11581169
if not readline.found()
1159-
readline = cc.find_library(readline_dep,
1160-
required: get_option('readline'),
1170+
readline = cc.find_library(readline_dep['name'],
1171+
required: readline_dep['required'],
11611172
dirs: test_lib_d)
11621173
endif
11631174
if readline.found()

0 commit comments

Comments
 (0)