parazyd 3 лет назад
Родитель
Сommit
df85da6345
4 измененных файлов с 23 добавлено и 9 удалено
  1. 1 0
      Cargo.lock
  2. 4 1
      bin/drk/Cargo.toml
  3. 7 0
      bin/drk/build.rs
  4. 11 8
      bin/drk/src/cli_util.rs

+ 1 - 0
Cargo.lock

@@ -1583,6 +1583,7 @@ dependencies = [
  "darkfi-money-contract",
  "darkfi-money-contract",
  "darkfi-sdk",
  "darkfi-sdk",
  "darkfi-serial",
  "darkfi-serial",
+ "pkg-config",
  "play",
  "play",
  "prettytable-rs",
  "prettytable-rs",
  "rand",
  "rand",

+ 4 - 1
bin/drk/Cargo.toml

@@ -8,6 +8,9 @@ repository = "https://github.com/darkrenaissance/darkfi"
 license = "AGPL-3.0-only"
 license = "AGPL-3.0-only"
 edition = "2021"
 edition = "2021"
 
 
+[build-dependencies]
+pkg-config = "0.3.26"
+
 [dependencies]
 [dependencies]
 anyhow = "1.0.68"
 anyhow = "1.0.68"
 async-std = {version = "1.12.0", features = ["attributes"]}
 async-std = {version = "1.12.0", features = ["attributes"]}
@@ -26,4 +29,4 @@ signal-hook-async-std = "0.2.2"
 signal-hook = "0.3.14"
 signal-hook = "0.3.14"
 sqlx = {version = "0.6.2", features = ["runtime-async-std-native-tls", "sqlite"]}
 sqlx = {version = "0.6.2", features = ["runtime-async-std-native-tls", "sqlite"]}
 url = "2.3.1"
 url = "2.3.1"
-play = "0.5.3"
+play = {version = "0.5.3", optional = true}

+ 7 - 0
bin/drk/build.rs

@@ -0,0 +1,7 @@
+use pkg_config::probe_library;
+
+fn main() {
+    if probe_library("libout123").is_ok() && probe_library("libmpg123").is_ok() {
+        println!("cargo:rustc-cfg=feature=\"play\"");
+    }
+}

+ 11 - 8
bin/drk/src/cli_util.rs

@@ -62,16 +62,19 @@ pub fn parse_token_pair(s: &str) -> Result<(TokenId, TokenId)> {
 
 
 /// Fun police go away
 /// Fun police go away
 pub async fn kaching() -> Result<()> {
 pub async fn kaching() -> Result<()> {
-    const WALLET_MP3: &[u8] = include_bytes!("../wallet.mp3");
-    const MP3_DROP: &str = "/tmp/wallet.mp3";
+    #[cfg(feature = "play")]
+    {
+        const WALLET_MP3: &[u8] = include_bytes!("../wallet.mp3");
+        const MP3_DROP: &str = "/tmp/wallet.mp3";
 
 
-    if !Path::new(MP3_DROP).exists() {
-        let mut f = File::create(MP3_DROP).await?;
-        f.write_all(WALLET_MP3).await?;
-    }
+        if !Path::new(MP3_DROP).exists() {
+            let mut f = File::create(MP3_DROP).await?;
+            f.write_all(WALLET_MP3).await?;
+        }
 
 
-    if let Err(_) = play::play(MP3_DROP) {
-        return Ok(())
+        if let Err(_) = play::play(MP3_DROP) {
+            return Ok(())
+        }
     }
     }
 
 
     Ok(())
     Ok(())