git » rust-bindgen.git » commit a73873f

0.71.0-2: Unbreak --version

author Jan Alexander Steffens (heftig)
2024-12-07 17:57:03 UTC
committer Jan Alexander Steffens (heftig)
2024-12-07 17:57:03 UTC
parent 3894e9f1e17bc3be793d919ac7c49e0f6a60a063

0.71.0-2: Unbreak --version

.SRCINFO +3 -1
0001-Unbreak-shell-completion-and-version-without-header.patch +93 -0
PKGBUILD +16 -7

diff --git a/.SRCINFO b/.SRCINFO
index ba87880..d42d554 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,7 +1,7 @@
 pkgbase = rust-bindgen
 	pkgdesc = Automatically generates Rust FFI bindings to C (and some C++) libraries
 	pkgver = 0.71.0
-	pkgrel = 1
+	pkgrel = 2
 	url = https://github.com/rust-lang/rust-bindgen
 	arch = x86_64
 	license = BSD
@@ -9,6 +9,8 @@ pkgbase = rust-bindgen
 	depends = gcc-libs
 	depends = clang
 	source = rust-bindgen-0.71.0.tar.gz::https://github.com/rust-lang/rust-bindgen/archive/v0.71.0.tar.gz
+	source = 0001-Unbreak-shell-completion-and-version-without-header.patch
 	sha512sums = 87213c8c8f362d11cd88a0570b8aaa188e9e51197d9aeb7f9cfbae0a7539f4e1ed40a36c11e15bd9bf5fb78938c571f08b40f250419fe018fdee19733b5eb433
+	sha512sums = 87662d6542ce442d39207ad47b61bef868d069f0a6b75e813005c874e66087c55b3bc67012da1858f64c8196ef6d66d65b871d36bfa172c0c36b2505b64e98a4
 
 pkgname = rust-bindgen
diff --git a/0001-Unbreak-shell-completion-and-version-without-header.patch b/0001-Unbreak-shell-completion-and-version-without-header.patch
new file mode 100644
index 0000000..8f79340
--- /dev/null
+++ b/0001-Unbreak-shell-completion-and-version-without-header.patch
@@ -0,0 +1,93 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: "Jan Alexander Steffens (heftig)" <heftig@archlinux.org>
+Date: Sat, 7 Dec 2024 18:54:51 +0100
+Subject: [PATCH] Unbreak shell completion and --version without header
+
+This regressed again in #2984. Partially revert d75fe271418e and
+42a86e288c43 and restore the previous behavior.
+
+Fixes: https://github.com/rust-lang/rust-bindgen/issues/3037
+Fixes: https://github.com/rust-lang/rust-bindgen/issues/3039
+---
+ bindgen/options/cli.rs | 52 +++++++++++++++++++++++-------------------
+ 1 file changed, 28 insertions(+), 24 deletions(-)
+
+diff --git a/bindgen/options/cli.rs b/bindgen/options/cli.rs
+index 9d5cea3dc653..8c4c05bc847d 100644
+--- a/bindgen/options/cli.rs
++++ b/bindgen/options/cli.rs
+@@ -146,7 +146,7 @@ fn parse_custom_attribute(
+ #[allow(clippy::doc_markdown)]
+ struct BindgenCommand {
+     /// C or C++ header file.
+-    header: String,
++    header: Option<String>,
+     /// Path to write depfile to.
+     #[arg(long)]
+     depfile: Option<String>,
+@@ -657,6 +657,33 @@ where
+         clang_args,
+     } = command;
+ 
++    if let Some(shell) = generate_shell_completions {
++        clap_complete::generate(
++            shell,
++            &mut BindgenCommand::command(),
++            "bindgen",
++            &mut io::stdout(),
++        );
++
++        exit(0)
++    }
++
++    if version {
++        println!(
++            "bindgen {}",
++            option_env!("CARGO_PKG_VERSION").unwrap_or("unknown")
++        );
++        if verbose {
++            println!("Clang: {}", crate::clang_version().full);
++        }
++
++        exit(0)
++    }
++
++    if header.is_none() {
++        return Err(io::Error::new(io::ErrorKind::Other, "Header not found"));
++    }
++
+     let mut builder = builder();
+ 
+     #[derive(Debug)]
+@@ -804,31 +831,8 @@ where
+         }
+     }
+ 
+-    let header = Some(header);
+-
+     builder = apply_args!(
+         builder {
+-            generate_shell_completions => |_, shell| {
+-                clap_complete::generate(
+-                    shell,
+-                    &mut BindgenCommand::command(),
+-                    "bindgen",
+-                    &mut io::stdout(),
+-                );
+-
+-                exit(0)
+-            },
+-            version => |_, _| {
+-                println!(
+-                    "bindgen {}",
+-                    option_env!("CARGO_PKG_VERSION").unwrap_or("unknown")
+-                );
+-                if verbose {
+-                    println!("Clang: {}", crate::clang_version().full);
+-                }
+-
+-                exit(0)
+-            },
+             header,
+             rust_target,
+             rust_edition,
diff --git a/PKGBUILD b/PKGBUILD
index 84c8d1d..519f102 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -4,18 +4,28 @@
 pkgname=rust-bindgen
 _pkgname=bindgen
 pkgver=0.71.0
-pkgrel=1
+pkgrel=2
 pkgdesc='Automatically generates Rust FFI bindings to C (and some C++) libraries'
 url='https://github.com/rust-lang/rust-bindgen'
 depends=('gcc-libs' 'clang')
 makedepends=('cargo')
 arch=('x86_64')
 license=('BSD')
-source=("$pkgname-$pkgver.tar.gz::https://github.com/rust-lang/rust-bindgen/archive/v$pkgver.tar.gz")
-sha512sums=('87213c8c8f362d11cd88a0570b8aaa188e9e51197d9aeb7f9cfbae0a7539f4e1ed40a36c11e15bd9bf5fb78938c571f08b40f250419fe018fdee19733b5eb433')
+source=(
+  "$pkgname-$pkgver.tar.gz::https://github.com/rust-lang/rust-bindgen/archive/v$pkgver.tar.gz"
+  0001-Unbreak-shell-completion-and-version-without-header.patch
+)
+sha512sums=('87213c8c8f362d11cd88a0570b8aaa188e9e51197d9aeb7f9cfbae0a7539f4e1ed40a36c11e15bd9bf5fb78938c571f08b40f250419fe018fdee19733b5eb433'
+            '87662d6542ce442d39207ad47b61bef868d069f0a6b75e813005c874e66087c55b3bc67012da1858f64c8196ef6d66d65b871d36bfa172c0c36b2505b64e98a4')
 
 prepare() {
   cd $pkgname-$pkgver
+
+  # Revert argument parsing regression
+  # https://github.com/rust-lang/rust-bindgen/issues/3037
+  # https://github.com/rust-lang/rust-bindgen/issues/3039
+  patch -Np1 -i ../0001-Unbreak-shell-completion-and-version-without-header.patch
+
   cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"
   mkdir -p completions
 }
@@ -24,10 +34,9 @@ build() {
   cd $pkgname-$pkgver
   cargo build --release --frozen
   local _completion="target/release/$_pkgname --generate-shell-completions"
-  # https://github.com/rust-lang/rust-bindgen/issues/3037
-  $_completion bash "dummy" >"completions/$_pkgname"
-  $_completion fish "dummy" >"completions/$_pkgname.fish"
-  $_completion zsh "dummy" >"completions/_$_pkgname"
+  $_completion bash >"completions/$_pkgname"
+  $_completion fish >"completions/$_pkgname.fish"
+  $_completion zsh >"completions/_$_pkgname"
 }
 
 package() {