Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions src/boot_fake_node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() })
Expand Down Expand Up @@ -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?
Expand All @@ -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!(
Expand Down Expand Up @@ -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(
Expand Down
8 changes: 8 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ async fn execute(
let fake_node_name = boot_matches.get_one::<String>("NODE_NAME").unwrap();
let password = boot_matches.get_one::<String>("PASSWORD").unwrap();
let is_persist = boot_matches.get_one::<bool>("PERSIST").unwrap();
let release = boot_matches.get_one::<bool>("RELEASE").unwrap();

boot_fake_node::execute(
runtime_path,
Expand All @@ -70,6 +71,7 @@ async fn execute(
fake_node_name,
password,
*is_persist,
*release,
vec![],
).await
},
Expand Down Expand Up @@ -319,6 +321,12 @@ async fn make_app(current_dir: &std::ffi::OsString) -> anyhow::Result<Command> {
.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)
Expand Down
1 change: 1 addition & 0 deletions src/run_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/run_tests/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Test>,
}

Expand Down