Skip to content

Commit ae477a4

Browse files
committed
Use OUT_DIR when building
1 parent cd0f055 commit ae477a4

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ ureq = "2.1"
2222
bitcoin_hashes = "0.10"
2323
flate2 = "1.0"
2424
tar = "0.4"
25-
home = "0.5.3"
2625

2726
[features]
2827
"0_21_1" = []

build.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use bitcoin_hashes::{sha256, Hash};
22
use flate2::read::GzDecoder;
33
use std::fs::File;
44
use std::io::{BufRead, BufReader, Read};
5-
use std::path::PathBuf;
5+
use std::path::Path;
66
use std::str::FromStr;
77
use tar::Archive;
88

@@ -36,14 +36,15 @@ fn main() {
3636
}
3737
let download_filename = download_filename();
3838
let expected_hash = get_expected_sha256(&download_filename).unwrap();
39-
let bitcoin_exe_home = format!(
40-
"{}/bitcoin",
41-
home::cargo_home()
42-
.expect("cannot determine CARGO_HOME")
43-
.display()
44-
);
45-
let existing_filename: PathBuf =
46-
format!("{}/bitcoin-{}/bin/bitcoind", &bitcoin_exe_home, VERSION).into();
39+
let out_dir = std::env::var_os("OUT_DIR").unwrap();
40+
let bitcoin_exe_home = Path::new(&out_dir).join("bitcoin");
41+
if !bitcoin_exe_home.exists() {
42+
std::fs::create_dir(&bitcoin_exe_home).unwrap();
43+
}
44+
let existing_filename = bitcoin_exe_home
45+
.join(format!("bitcoin-{}", VERSION))
46+
.join("bin")
47+
.join("bicoind");
4748

4849
if !existing_filename.exists() {
4950
println!(

src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,10 @@ impl From<bitcoincore_rpc::Error> for Error {
279279

280280
/// Provide the bitcoind executable path if a version feature has been specified
281281
pub fn downloaded_exe_path() -> Option<String> {
282-
// CARGO_HOME surely available only in `build.rs` here we need to get from home_dir
283282
if versions::HAS_FEATURE {
284283
Some(format!(
285284
"{}/bitcoin/bitcoin-{}/bin/bitcoind",
286-
home::cargo_home().ok()?.display(),
285+
env!("OUT_DIR"),
287286
versions::VERSION
288287
))
289288
} else {

0 commit comments

Comments
 (0)