Skip to content

Commit

Permalink
fix: build script
Browse files Browse the repository at this point in the history
  • Loading branch information
rymnc committed Nov 26, 2024
1 parent 9dd03c7 commit e99cae0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
15 changes: 14 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions fuel-zkvm-primitives-test-fixtures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ tempfile = "3.14.0"
tokio = { workspace = true }
clap = { version = "^4.0", features = ["derive"], optional = true }
enum-iterator = { version = "2.1.0", optional = true }
which = "7.0.0"

[build-dependencies]
which = "7.0.0"

[dev-dependencies]
paste = "1.0"
Expand Down
21 changes: 18 additions & 3 deletions fuel-zkvm-primitives-test-fixtures/build.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
use std::env;
use std::path::Path;
use std::process::Command;

pub fn main() {
Command::new("forc")
// Check if `forc` is available in the system PATH
let forc_binary = which::which("forc").unwrap_or_else(|_| {
// If `forc` is not found in PATH, check $HOME/.fuelup/bin/forc
let home_dir = env::var("HOME").expect("Failed to get $HOME directory");
let fallback_path = Path::new(&home_dir).join(".fuelup/bin/forc");
if fallback_path.exists() {
fallback_path
} else {
panic!("`forc` binary not found in PATH or at $HOME/.fuelup/bin/forc");
}
});

// Use the determined `forc` binary to build the contract
Command::new(forc_binary)
.arg("build")
.arg("--path")
.arg("src/fixtures/counter_contract")
.spawn()
.expect("failed to build contract");
}
.expect("Failed to build contract");
}

0 comments on commit e99cae0

Please sign in to comment.