Skip to content

Commit

Permalink
main/rust-bindgen: unbreak --version flag
Browse files Browse the repository at this point in the history
this is rust-lang/rust-bindgen#3040

this also unbreaks the mesa-asahi build
  • Loading branch information
omni committed Dec 7, 2024
1 parent b843062 commit ff261eb
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 1 deletion.
7 changes: 6 additions & 1 deletion main/rust-bindgen/APKBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
maintainer="team/rust <[email protected]>"
pkgname=rust-bindgen
pkgver=0.71.0
pkgrel=0
pkgrel=1
pkgdesc="automatically generates Rust FFI bindings to C (and some C++) libraries"
url="https://github.com/rust-lang/rust-bindgen"
makedepends="cargo clang cargo-auditable"
Expand All @@ -13,6 +13,7 @@ license="BSD-3-Clause"
options="net"
source="$pkgname-$pkgver.tar.gz::https://github.com/rust-lang/rust-bindgen/archive/v$pkgver.tar.gz
disable-test_wrap_static_fns-patch
unbreak-shell-completion-and--version-without-leader.patch
"

prepare() {
Expand All @@ -33,6 +34,9 @@ build() {

check() {
cargo test --frozen

# silly, but in case upstream would break this again
./target/release/bindgen --version
}

package() {
Expand All @@ -42,4 +46,5 @@ package() {
sha512sums="
87213c8c8f362d11cd88a0570b8aaa188e9e51197d9aeb7f9cfbae0a7539f4e1ed40a36c11e15bd9bf5fb78938c571f08b40f250419fe018fdee19733b5eb433 rust-bindgen-0.71.0.tar.gz
1c5578b0935e84f75ebd04f2c4186d835d2e6363f16439ef4ea29c9448d803779ad40cc577b4b1c0f8757d08e7d0013f3a1267ca00410ca39e86e3ad199826a5 disable-test_wrap_static_fns-patch
38b21b4778e676baaa75a623cabb98d0efae8dc9cb71191c9080fd0f2860af778926e2a5b09e29bc30c5219eb185897213e8a1ab710fa2c8f11cb8a912b166c5 unbreak-shell-completion-and--version-without-leader.patch
"
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
From 2e154e7e2af2f5c40f195c3ec5b468ae2259c1c7 Mon Sep 17 00:00:00 2001
From: "Jan Alexander Steffens (heftig)" <[email protected]>
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 9d5cea3dc6..8c4c05bc84 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,

0 comments on commit ff261eb

Please sign in to comment.