Skip to content

Commit

Permalink
Formatted orchestrater
Browse files Browse the repository at this point in the history
  • Loading branch information
platinumxy committed Nov 25, 2024
1 parent 694fca6 commit 2860825
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions lib/debugger/src/orchestrater.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
use std::{env, path::{Path, PathBuf}, process::Command};
use std::{
env,
path::{Path, PathBuf},
process::Command,
};

pub type OrchestrationResult<T> = Result<T, OrchestrationError>;
pub type OrchestrationError = Box<dyn std::error::Error>;
Expand All @@ -14,8 +18,16 @@ pub fn flash_with_flags(project: &Path, flags: &[&str]) -> OrchestrationResult<(
let res = build_in_wd(flags);

println!("[i] Moving current working directory back to original");
change_dir(&cwd).expect("Unable to recover to old CWD");
Ok(())
change_dir(&cwd).expect("Unable to recover to old CWD");
match res {
Ok(exec) => {
println!("[i] Flashing board");
flash_board(&exec)?;
println!("[+] Board flashed successfully");
Ok(())
}
Err(e) => Err(e),
}
}

fn change_dir(pth: &Path) -> OrchestrationResult<()> {
Expand Down Expand Up @@ -61,13 +73,13 @@ fn build_in_wd(flags: &[&str]) -> OrchestrationResult<PathBuf> {
Ok(PathBuf::from(exec))
}

fn build_board(flags: &[&str]) -> OrchestrationResult<String> {
fn build_board(flags: &[&str]) -> OrchestrationResult<String> {
// Do not atempt to use the Cargo create to build the board as it will result in

Check warning on line 77 in lib/debugger/src/orchestrater.rs

View workflow job for this annotation

GitHub Actions / Spell check with typos

"atempt" should be "attempt".
// nothing but pain, corte-x has issues with running the cargo build command
// because it failes to find the correct target board platform
// nothing but pain, corte-x has issues with running the cargo build command
// because it failes to find the correct target board platform

Check warning on line 79 in lib/debugger/src/orchestrater.rs

View workflow job for this annotation

GitHub Actions / Spell check with typos

"failes" should be "fails" or "failed".
// Hence we need to change ot CWD into the correct location and build from there

Check warning on line 80 in lib/debugger/src/orchestrater.rs

View workflow job for this annotation

GitHub Actions / Spell check with typos

"ot" should be "to" or "of" or "or" or "not".
// This forces our hand to use --message-format=json to get the output of the build
// and then use the archain chants that are in
// and then use the archain chants that are in
let mut cargo = Command::new("cargo");
let mut command = cargo
.arg("build")
Expand Down Expand Up @@ -113,4 +125,9 @@ fn extract_bin_path_from_logs(log: &String) -> OrchestrationResult<PathBuf> {
.find('"')
.ok_or_else(|| OrchestrationError::from("Failed to find end of executable in build log"))?;
Ok(PathBuf::from(&log[exec_start..exec_start + exec_end]))
}


fn flash_board(pth: &Path) -> OrchestrationResult<()>{
Ok(())
}

0 comments on commit 2860825

Please sign in to comment.