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>
(cherry picked from commit 1f1ec1c6bc)
This commit is contained in:
LingMan 2023-11-04 12:51:51 +01:00 committed by Eric Engestrom
parent bfbd6f22c3
commit 5443e66190
2 changed files with 9 additions and 3 deletions

View file

@ -4,7 +4,7 @@
"description": "rusticl: Show an error message if the version of bindgen can't be detected",
"nominated": false,
"nomination_type": 3,
"resolution": 4,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -114,11 +114,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',
]