Skip to content

Commit

Permalink
fixed export paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr Gadorek authored and Hahihula committed Sep 10, 2024
1 parent 9900cdf commit 5c192e0
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion src/wizard/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ mod prompts;
use prompts::*;

fn get_tools_export_paths(
// TODO: move to library
tools_file: ToolsFile,
selected_chip: Vec<String>,
tools_install_path: &str,
) -> Vec<String> {
let bin_dirs = find_bin_directories(Path::new(tools_install_path));
debug!("Bin directories: {:?}", bin_dirs);

let list = idf_im_lib::idf_tools::filter_tools_by_target(tools_file.tools, &selected_chip);
// debug!("Creating export paths for: {:?}", list);
let mut paths = vec![];
Expand All @@ -47,9 +51,38 @@ fn get_tools_export_paths(
paths.push(p.to_str().unwrap().to_string());
});
}
for bin_dir in bin_dirs {
let str_p = bin_dir.to_str().unwrap().to_string();
if paths.contains(&str_p) {
trace!("Skipping duplicate export path: {}", str_p);
} else {
trace!("Adding export path: {}", str_p);
paths.push(str_p);
}
}
debug!("Export paths: {:?}", paths);
paths
}

fn find_bin_directories(path: &Path) -> Vec<PathBuf> {
let mut result = Vec::new();

if let Ok(entries) = fs::read_dir(path) {
for entry in entries.flatten() {
let path = entry.path();
if path.is_dir() {
if path.file_name().and_then(|n| n.to_str()) == Some("bin") {
result.push(path.clone());
} else {
result.extend(find_bin_directories(&path));
}
}
}
}

result
}

async fn download_tools(
tools_file: ToolsFile,
selected_chip: Vec<String>,
Expand Down Expand Up @@ -685,7 +718,7 @@ pub async fn run_wizzard_run(mut config: Settings) -> Result<(), String> {
let export_paths = get_tools_export_paths(
tools,
config.target.clone().unwrap().clone(),
tool_install_directory.to_str().unwrap(),
tool_install_directory.join("tools").to_str().unwrap(),
);

single_version_post_install(
Expand Down

0 comments on commit 5c192e0

Please sign in to comment.