From 2fb178d9aadaa04d6b9ba6b1d13c8e2ea6f43555 Mon Sep 17 00:00:00 2001
From: librelois <c@elo.tf>
Date: Sun, 23 May 2021 21:43:58 +0200
Subject: [PATCH] deps: include gva module in x86_64 arch only

---
 Cargo.toml                                           | 9 +++------
 rust-bins/duniter-cli/src/duniter_ts_args.rs         | 2 +-
 rust-bins/duniter-cli/src/main.rs                    | 6 +++---
 rust-libs/duniter-server/Cargo.toml                  | 7 ++-----
 rust-libs/duniter-server/src/lib.rs                  | 4 ++--
 rust-libs/tests/duniter-integration-tests/Cargo.toml | 2 +-
 6 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index 03ce6084a..f3b123ba7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -19,7 +19,6 @@ ctrlc = "3.1.6"
 daemonize-me = "0.3.1"
 dirs = "3.0.1"
 duniter-core = { git = "https://git.duniter.org/nodes/rust/duniter-core", features = ["bc-writer"] }
-duniter-gva-conf = { git = "https://git.duniter.org/nodes/rust/modules/duniter-gva", optional = true }
 log = "0.4.11"
 logwatcher = "0.1.1"
 nix = "0.17.0"
@@ -27,14 +26,12 @@ read_input = "0.8.4"
 serde_json = "1.0.53"
 structopt = "0.3.18"
 
+[target.'cfg(target_arch = "x86_64")'.dependencies]
+duniter-gva-conf = { git = "https://git.duniter.org/nodes/rust/modules/duniter-gva" }
+
 [dev-dependencies]
 rusty-hook = "0.11.2"
 
-[features]
-default = ["gva"]
-
-gva = ["duniter-gva-conf"]
-
 [workspace]
 members = [
     "neon/native",
diff --git a/rust-bins/duniter-cli/src/duniter_ts_args.rs b/rust-bins/duniter-cli/src/duniter_ts_args.rs
index 765630419..13e45445a 100644
--- a/rust-bins/duniter-cli/src/duniter_ts_args.rs
+++ b/rust-bins/duniter-cli/src/duniter_ts_args.rs
@@ -82,7 +82,7 @@ pub(crate) fn gen_duniter_ts_args(
             gen_start_args(start_args, &mut duniter_ts_args);
             gen_webstart_args(webstart_args, &mut duniter_ts_args);
         }
-        #[cfg(feature = "gva")]
+        #[cfg(target_arch = "x86_64")]
         DuniterCommand::Gva(_) => unreachable!(),
         DuniterCommand::Start(ref start_args) => {
             duniter_ts_args.push("direct_start".to_owned());
diff --git a/rust-bins/duniter-cli/src/main.rs b/rust-bins/duniter-cli/src/main.rs
index cdab0d8d3..ccc106439 100644
--- a/rust-bins/duniter-cli/src/main.rs
+++ b/rust-bins/duniter-cli/src/main.rs
@@ -32,7 +32,7 @@ mod sync;
 
 use anyhow::{anyhow, Result};
 use daemonize_me::Daemon;
-#[cfg(feature = "gva")]
+#[cfg(target_arch = "x86_64")]
 use duniter_gva_conf::GvaCommand;
 use logwatcher::{LogWatcher, LogWatcherAction};
 use nix::{errno::Errno, sys::signal::Signal, unistd::Pid, Error};
@@ -82,7 +82,7 @@ enum DuniterCommand {
         after_help("Some advanced options are hidden for readability.")
     )]
     Config(Box<config::DuniterCoreConfigArgs>),
-    #[cfg(feature = "gva")]
+    #[cfg(target_arch = "x86_64")]
     #[structopt(display_order(1))]
     Gva(GvaCommand),
     /// Launch the configuration wizard.
@@ -219,7 +219,7 @@ fn main() -> Result<()> {
         let log_level_filter = get_log_level(args.log)?;
         let profile_path = get_profile_path(args.profile.as_deref())?;
 
-        #[cfg(feature = "gva")]
+        #[cfg(target_arch = "x86_64")]
         if let DuniterCommand::Gva(gva_command) = args.command {
             return gva_command.command(profile_path);
         }
diff --git a/rust-libs/duniter-server/Cargo.toml b/rust-libs/duniter-server/Cargo.toml
index 6f59c577a..ef8e2425c 100644
--- a/rust-libs/duniter-server/Cargo.toml
+++ b/rust-libs/duniter-server/Cargo.toml
@@ -9,17 +9,14 @@ edition = "2018"
 anyhow = "1.0.34"
 cfg-if = "1.0.0"
 duniter-core = { git = "https://git.duniter.org/nodes/rust/duniter-core", features = ["bc-writer"] }
-duniter-gva = { git = "https://git.duniter.org/nodes/rust/modules/duniter-gva", optional = true } 
 fast-threadpool = "0.2.3"
 flume = "0.10.0"
 log = "0.4.11"
 paste = "1.0.2"
 resiter = "0.4.0"
 
-[features]
-default = ["gva"]
-
-gva = ["duniter-gva"]
+[target.'cfg(target_arch = "x86_64")'.dependencies]
+duniter-gva = { git = "https://git.duniter.org/nodes/rust/modules/duniter-gva" }
 
 [dev-dependencies]
 duniter-core = { git = "https://git.duniter.org/nodes/rust/duniter-core", features = ["bc-writer", "mem"] }
diff --git a/rust-libs/duniter-server/src/lib.rs b/rust-libs/duniter-server/src/lib.rs
index 2b8826ee5..4d016b03e 100644
--- a/rust-libs/duniter-server/src/lib.rs
+++ b/rust-libs/duniter-server/src/lib.rs
@@ -30,7 +30,7 @@ use duniter_core::dbs::databases::{bc_v2::BcV2DbReadable, network_v1::NetworkV1D
 pub use duniter_core::dbs::{
     kv_typed::prelude::KvResult, smallvec, DunpHeadDbV1, DunpNodeIdV1Db, PeerCardDbV1,
 };
-#[cfg(feature = "gva")]
+#[cfg(target_arch = "x86_64")]
 pub use duniter_gva::GvaModule;
 
 use anyhow::Context;
@@ -61,7 +61,7 @@ use duniter_core::conf as duniter_conf;
 use duniter_core::global as duniter_global;
 use duniter_core::mempools as duniter_mempools;
 cfg_if::cfg_if! {
-    if #[cfg(feature = "gva")] {
+    if #[cfg(target_arch = "x86_64")] {
         use duniter_core::module::DuniterModule;
         plug_duniter_modules!([GvaModule], TxsHistoryForBma);
     } else {
diff --git a/rust-libs/tests/duniter-integration-tests/Cargo.toml b/rust-libs/tests/duniter-integration-tests/Cargo.toml
index 876792c21..3fe9c0184 100644
--- a/rust-libs/tests/duniter-integration-tests/Cargo.toml
+++ b/rust-libs/tests/duniter-integration-tests/Cargo.toml
@@ -9,7 +9,7 @@ edition = "2018"
 anyhow = "1.0.34"
 chrono = "0.4"
 duniter-core = { git = "https://git.duniter.org/nodes/rust/duniter-core", features = ["bc-writer"] }
-duniter-server = { path = "../../duniter-server", features = ["gva"] }
+duniter-server = { path = "../../duniter-server" }
 fast-threadpool = "0.2.3"
 flume = "0.10.0"
 log = "0.4.11"
-- 
GitLab