History

rust: rust_is_available: remove warning for `bindgen` 0.66.[01]

It is not possible anymore to fall into the issue that this warning was alerting about given the `bindgen` version bump. Thus simplify by removing the machinery behind it, including tests.

Miguel Ojeda committed 7 months ago

Commit 41cfbb41 parent c3a00a33 files · +3 −38Browse files

Unified · Split

3 files
  1. scripts/rust_is_available.sh +0 −13
  2. scripts/rust_is_available_bindgen_0_66.h +0 −2
  3. scripts/rust_is_available_test.py +3 −23
scripts/rust_is_available.sh+0−13
@@ -163,19 +163,6 @@ if [ "$rust_bindings_generator_cversion" -lt "$rust_bindings_generator_min_cvers · 162 unmodified lines
163 echo >&2 "***"163 echo >&2 "***"
164 exit 1164 exit 1
165fi165fi
166if [ "$rust_bindings_generator_cversion" -eq 6600 ] ||
167 [ "$rust_bindings_generator_cversion" -eq 6601 ]; then
168 # Distributions may have patched the issue (e.g. Debian did).
169 if ! "$BINDGEN" $(dirname $0)/rust_is_available_bindgen_0_66.h >/dev/null; then
170 echo >&2 "***"
171 echo >&2 "*** Rust bindings generator '$BINDGEN' versions 0.66.0 and 0.66.1 may not"
172 echo >&2 "*** work due to a bug (https://github.com/rust-lang/rust-bindgen/pull/2567),"
173 echo >&2 "*** unless patched (like Debian's)."
174 echo >&2 "*** Your version: $rust_bindings_generator_version"
175 echo >&2 "***"
176 warning=1
177 fi
178fi
179 166
180# Check that the `libclang` used by the Rust bindings generator is suitable.167# Check that the `libclang` used by the Rust bindings generator is suitable.
181#168#
scripts/rust_is_available_bindgen_0_66.h+0−2
@@ -1,2 +0,0 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2#define A "\0"
scripts/rust_is_available_test.py+3−23
@@ -54,17 +54,12 @@ else: · 53 unmodified lines
54""")54""")
55 55
56 @classmethod56 @classmethod
57 def generate_bindgen(cls, version_stdout, libclang_stderr, version_0_66_patched=False, libclang_concat_patched=False):57 def generate_bindgen(cls, version_stdout, libclang_stderr, libclang_concat_patched=False):
58 if libclang_stderr is None:58 if libclang_stderr is None:
59 libclang_case = f"raise SystemExit({cls.bindgen_default_bindgen_libclang_failure_exit_code})"59 libclang_case = f"raise SystemExit({cls.bindgen_default_bindgen_libclang_failure_exit_code})"
60 else:60 else:
61 libclang_case = f"print({repr(libclang_stderr)}, file=sys.stderr)"61 libclang_case = f"print({repr(libclang_stderr)}, file=sys.stderr)"
62 62
63 if version_0_66_patched:
64 version_0_66_case = "pass"
65 else:
66 version_0_66_case = "raise SystemExit(1)"
67
68 if libclang_concat_patched:63 if libclang_concat_patched:
69 libclang_concat_case = "print('pub static mut foofoo: ::std::os::raw::c_int;')"64 libclang_concat_case = "print('pub static mut foofoo: ::std::os::raw::c_int;')"
70 else:65 else:
@@ -74,8 +69,6 @@ else: · 3 unmodified lines
74import sys69import sys
75if "rust_is_available_bindgen_libclang.h" in " ".join(sys.argv):70if "rust_is_available_bindgen_libclang.h" in " ".join(sys.argv):
76 {libclang_case}71 {libclang_case}
77elif "rust_is_available_bindgen_0_66.h" in " ".join(sys.argv):
78 {version_0_66_case}
79elif "rust_is_available_bindgen_libclang_concat.h" in " ".join(sys.argv):72elif "rust_is_available_bindgen_libclang_concat.h" in " ".join(sys.argv):
80 {libclang_concat_case}73 {libclang_concat_case}
81else:74else:
@@ -83,8 +76,8 @@ else: · 1 unmodified line
83""")76""")
84 77
85 @classmethod78 @classmethod
86 def generate_bindgen_version(cls, stdout, version_0_66_patched=False):79 def generate_bindgen_version(cls, stdout):
87 return cls.generate_bindgen(stdout, cls.bindgen_default_bindgen_libclang_stderr, version_0_66_patched)80 return cls.generate_bindgen(stdout, cls.bindgen_default_bindgen_libclang_stderr)
88 81
89 @classmethod82 @classmethod
90 def generate_bindgen_libclang_failure(cls):83 def generate_bindgen_libclang_failure(cls):
@@ -245,19 +238,6 @@ else: · 154 unmodified lines
245 result = self.run_script(self.Expected.FAILURE, { "BINDGEN": bindgen })238 result = self.run_script(self.Expected.FAILURE, { "BINDGEN": bindgen })
246 self.assertIn(f"Rust bindings generator '{bindgen}' is too old.", result.stderr)239 self.assertIn(f"Rust bindings generator '{bindgen}' is too old.", result.stderr)
247 240
248 def test_bindgen_bad_version_0_66_0_and_0_66_1(self):
249 for version in ("0.66.0", "0.66.1"):
250 with self.subTest(version=version):
251 bindgen = self.generate_bindgen_version(f"bindgen {version}")
252 result = self.run_script(self.Expected.SUCCESS_WITH_WARNINGS, { "BINDGEN": bindgen })
253 self.assertIn(f"Rust bindings generator '{bindgen}' versions 0.66.0 and 0.66.1 may not", result.stderr)
254
255 def test_bindgen_bad_version_0_66_0_and_0_66_1_patched(self):
256 for version in ("0.66.0", "0.66.1"):
257 with self.subTest(version=version):
258 bindgen = self.generate_bindgen_version(f"bindgen {version}", True)
259 result = self.run_script(self.Expected.SUCCESS, { "BINDGEN": bindgen })
260
261 def test_bindgen_libclang_failure(self):241 def test_bindgen_libclang_failure(self):
262 bindgen = self.generate_bindgen_libclang_failure()242 bindgen = self.generate_bindgen_libclang_failure()
263 result = self.run_script(self.Expected.FAILURE, { "BINDGEN": bindgen })243 result = self.run_script(self.Expected.FAILURE, { "BINDGEN": bindgen })