libblkio: Add %build_rustflags
[fedora-reviews.git] / libblkio / 44652d6c7fe9c61ac417db9dd05ec27e3c6e20f9.patch
1 From 44652d6c7fe9c61ac417db9dd05ec27e3c6e20f9 Mon Sep 17 00:00:00 2001
2 From: Stefan Hajnoczi <stefanha@redhat.com>
3 Date: Mon, 12 Dec 2022 14:58:07 -0500
4 Subject: [PATCH] cargo-build.sh: inherit $RUSTFLAGS
5
6 When a packaging system like rpm invokes "meson build" in meson 0.64.0
7 or later, it can use buildtype "plain" to control compiler flags itself
8 via the CFLAGS, CXXFLAGS, and, in our case, RUSTFLAGS environment
9 variables.
10
11 Don't clobber RUSTFLAGS in src/cargo-build.sh. Simply append our own
12 options to RUSTFLAGS. That way src/cargo-build.sh still controls
13 compiler options when necessary, but inherits them from the build
14 environment (especially in the buildtype "plain" case).
15
16 See https://bugzilla.redhat.com/show_bug.cgi?id=2124697#c67 for Fedora
17 packaging discussion around this topic.
18
19 Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
20 ---
21  src/cargo-build.sh | 4 ++--
22  1 file changed, 2 insertions(+), 2 deletions(-)
23
24 diff --git a/src/cargo-build.sh b/src/cargo-build.sh
25 index 9879d44..d4785ce 100755
26 --- a/src/cargo-build.sh
27 +++ b/src/cargo-build.sh
28 @@ -50,10 +50,10 @@ then
29  fi
30  
31  if [[ "${profile}" == "debug" ]] && command -v cargo-clippy >/dev/null; then
32 -    ( set -x && RUSTFLAGS="${rustflags[*]}" cargo clippy "${args[@]}" --color always \
33 +    ( set -x && RUSTFLAGS="$RUSTFLAGS ${rustflags[*]}" cargo clippy "${args[@]}" --color always \
34          --locked --all-features --all-targets --workspace -- --deny warnings )
35  fi
36  
37 -( set -x && RUSTFLAGS="${rustflags[*]}" cargo build "${args[@]}" --color always \
38 +( set -x && RUSTFLAGS="$RUSTFLAGS ${rustflags[*]}" cargo build "${args[@]}" --color always \
39      --locked )
40  cp "src/target/${profile}/libblkio.so" "src/libblkio.so.${version}"
41 -- 
42 GitLab
43