Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some minor target-gen improvements #2592

Merged
merged 5 commits into from
Jun 29, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Slight rework of extract_families
  • Loading branch information
bugadani committed Jun 29, 2024
commit a87fac8b5008702b2e653a19dcd4b82edae86918
15 changes: 5 additions & 10 deletions target-gen/src/generate.rs
Original file line number Diff line number Diff line change
@@ -75,7 +75,6 @@ where
T: std::io::Seek + std::io::Read,
{
// Forge a definition file for each device in the .pdsc file.
let pack_file_release = Some(pdsc.releases.latest_release().version.clone());
let mut devices = pdsc.devices.0.into_iter().collect::<Vec<_>>();
devices.sort_by(|a, b| a.0.cmp(&b.0));

@@ -106,7 +105,7 @@ where
manufacturer: None,
generated_from_pack: true,
chip_detection: vec![],
pack_file_release: pack_file_release.clone(),
pack_file_release: Some(pdsc.releases.latest_release().version.clone()),
variants: Vec::new(),
flash_algorithms: Vec::new(),
source: TargetDescriptionSource::BuiltIn,
@@ -116,19 +115,20 @@ where
};

// Extract the flash algorithm, block & sector size and the erased byte value from the ELF binary.
let variant_flash_algorithms = device
let flash_algorithm_names = device
.algorithms
.iter()
.filter_map(|flash_algorithm| {
match process_flash_algo(flash_algorithm, &mut kind) {
Ok(algo) => {
// We add this algo directly to the algos of the family if it's not already added.
// Make sure we never add an algo twice to save file size.
let algo_name = algo.name.clone();
if !family.flash_algorithms.contains(&algo) {
family.flash_algorithms.push(algo.clone());
family.flash_algorithms.push(algo);
}

Some(algo)
Some(algo_name)
}
Err(e) => {
log::warn!(
@@ -142,11 +142,6 @@ where
})
.collect::<Vec<_>>();

let flash_algorithm_names = variant_flash_algorithms
.iter()
.map(|fa| fa.name.to_string())
.collect::<Vec<_>>();

// Sometimes the algos are referenced twice, for example in the multicore H7s
// Deduplicate while keeping order.
let flash_algorithm_names = flash_algorithm_names