diff --git a/src/boot_fake_node/mod.rs b/src/boot_fake_node/mod.rs index 7329e7f4..b86ec4a6 100644 --- a/src/boot_fake_node/mod.rs +++ b/src/boot_fake_node/mod.rs @@ -68,19 +68,23 @@ fn extract_zip(archive_path: &Path) -> anyhow::Result<()> { } #[autocontext::autocontext] -pub fn compile_runtime(path: &Path, verbose: bool) -> anyhow::Result<()> { +pub fn compile_runtime(path: &Path, verbose: bool, release: bool) -> anyhow::Result<()> { println!("Compiling Kinode runtime..."); + let mut args = vec![ + "+nightly", + "build", + "-p", + "kinode", + "--features", + "simulation-mode", + ]; + if release { + args.push("--release"); + } + build::run_command(Command::new("cargo") - .args(&[ - "+nightly", - "build", - "--release", - "-p", - "kinode", - "--features", - "simulation-mode", - ]) + .args(&args) .current_dir(path) .stdout(if verbose { Stdio::inherit() } else { Stdio::null() }) .stderr(if verbose { Stdio::inherit() } else { Stdio::null() }) @@ -350,6 +354,7 @@ pub async fn execute( fake_node_name: &str, password: &str, is_persist: bool, + release: bool, mut args: Vec<&str>, ) -> anyhow::Result<()> { let detached = false; // TODO: to argument? @@ -365,7 +370,7 @@ pub async fn execute( } if runtime_path.is_dir() { // Compile the runtime binary - compile_runtime(&runtime_path, true)?; + compile_runtime(&runtime_path, true, release)?; runtime_path.join("target/release/kinode") } else { return Err(anyhow::anyhow!( @@ -424,7 +429,7 @@ pub async fn execute( args.extend_from_slice(&["--fake-node-name", fake_node_name]); args.extend_from_slice(&["--password", password]); if is_testnet { - args.extend_from_slice(&["--testnet"]); + args.push("--testnet"); } let (mut runtime_process, master_fd) = run_runtime( diff --git a/src/main.rs b/src/main.rs index 027d31ee..3660380f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -58,6 +58,7 @@ async fn execute( let fake_node_name = boot_matches.get_one::("NODE_NAME").unwrap(); let password = boot_matches.get_one::("PASSWORD").unwrap(); let is_persist = boot_matches.get_one::("PERSIST").unwrap(); + let release = boot_matches.get_one::("RELEASE").unwrap(); boot_fake_node::execute( runtime_path, @@ -70,6 +71,7 @@ async fn execute( fake_node_name, password, *is_persist, + *release, vec![], ).await }, @@ -319,6 +321,12 @@ async fn make_app(current_dir: &std::ffi::OsString) -> anyhow::Result { .help("Password to login") .default_value("secret") ) + .arg(Arg::new("RELEASE") + .action(ArgAction::SetTrue) + .long("release") + .help("If set and given --runtime-path, compile release build [default: debug build]") + .required(false) + ) .arg(Arg::new("help") .long("help") .action(ArgAction::Help) diff --git a/src/run_tests/mod.rs b/src/run_tests/mod.rs index d1ebb8d4..2306615b 100644 --- a/src/run_tests/mod.rs +++ b/src/run_tests/mod.rs @@ -442,6 +442,7 @@ pub async fn execute(config_path: &str) -> anyhow::Result<()> { compile_runtime( &runtime_path, config.runtime_build_verbose, + config.runtime_build_release, )?; runtime_path.join("target/release/kinode") } else { diff --git a/src/run_tests/types.rs b/src/run_tests/types.rs index 137f1db2..b56c1332 100644 --- a/src/run_tests/types.rs +++ b/src/run_tests/types.rs @@ -11,6 +11,7 @@ use serde::{Serialize, Deserialize}; pub struct Config { pub runtime: Runtime, pub runtime_build_verbose: bool, + pub runtime_build_release: bool, pub tests: Vec, }