rusticl: Show an error message if the version of bindgen can't be detected

bindgen 0.69.0 broke the `--version` switch, resulting in misleading errors about requiring at
least bindgen 0.62 or about unexpected arguments.

Ideally the build system would fetch the correct bindgen version automatically like cargo does.
Until then, provide a hopefully more helpful error message to the user.

Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26046>
This commit is contained in:
LingMan 2023-11-04 12:51:51 +01:00 committed by Marge Bot
parent e9f725c741
commit 1f1ec1c6bc

View file

@ -115,11 +115,17 @@ rusticl_bindgen_args = [
'--anon-fields-prefix', 'anon_',
]
if find_program('bindgen').version().version_compare('< 0.62')
bindgen_version = find_program('bindgen').version()
if bindgen_version == 'unknown'
error('Failed to detect bindgen version. If you are using bindgen 0.69.0, please either update to 0.69.1 or downgrade to 0.68.1. You can install the latest version for your user with `cargo install bindgen-cli`.')
endif
if bindgen_version.version_compare('< 0.62')
error('rusticl requires bindgen 0.62 or newer. If your distribution does not ship a recent enough version, you can install the latest version for your user with `cargo install bindgen-cli`.')
endif
if find_program('bindgen').version().version_compare('< 0.65')
if bindgen_version.version_compare('< 0.65')
rusticl_bindgen_args += [
'--size_t-is-usize',
]