libnbd/0001-generator-Handle-.-configure-disable-rust.patch
Richard W.M. Jones 704cc15c49 New upstream development version 1.17.3
Disable Rust bindings.
2023-08-04 15:14:10 +01:00

68 lines
2.3 KiB
Diff

From 473d78fb70c4ee6adb5e3596d699cf7b5a95f028 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 4 Aug 2023 15:10:52 +0100
Subject: [PATCH] generator: Handle ./configure --disable-rust
If this option is used, then "@RUSTFMT@" is expanded to "" (not "no").
Let's change the Config.rustfmt value to be an option type, while also
fixing this problem.
Fixes: commit b2511d640bc12b0116e6c013a17aefb4e772a058
---
generator/config.ml.in | 2 +-
generator/config.mli | 2 +-
generator/utils.ml | 17 ++++++++++-------
3 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/generator/config.ml.in b/generator/config.ml.in
index 7ac5237c5d..d0e6760e4f 100644
--- a/generator/config.ml.in
+++ b/generator/config.ml.in
@@ -18,4 +18,4 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*)
-let rustfmt = "@RUSTFMT@"
+let rustfmt = match "@RUSTFMT@" with "" | "no" -> None | s -> Some s
diff --git a/generator/config.mli b/generator/config.mli
index 5f1a46a6b1..8fb0c672ed 100644
--- a/generator/config.mli
+++ b/generator/config.mli
@@ -17,4 +17,4 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*)
-val rustfmt : string
+val rustfmt : string option
diff --git a/generator/utils.ml b/generator/utils.ml
index 3302b309ae..8ce4240c31 100644
--- a/generator/utils.ml
+++ b/generator/utils.ml
@@ -432,13 +432,16 @@ let
chan := NoOutput;
(match formatter with
| Some Rustfmt ->
- if Config.rustfmt <> "no" then (
- let cmd = sprintf "%s %s" Config.rustfmt filename_new in
- match system cmd with
- | WEXITED 0 -> ()
- | WEXITED i -> failwithf "rustfmt failed with exit code %d" i
- | WSIGNALED i | WSTOPPED i ->
- failwithf "rustfmt was killed or stopped by signal %d" i
+ (match Config.rustfmt with
+ | Some rustfmt ->
+ (let cmd = sprintf "%s %s" rustfmt filename_new in
+ match system cmd with
+ | WEXITED 0 -> ()
+ | WEXITED i -> failwithf "rustfmt failed with exit code %d" i
+ | WSIGNALED i | WSTOPPED i ->
+ failwithf "rustfmt was killed or stopped by signal %d" i
+ )
+ | None -> ()
);
| None -> ());
(* Is the new file different from the current file? *)
--
2.41.0