Skip to content

Commit

Permalink
Fix port base for non-linux targets
Browse files Browse the repository at this point in the history
  • Loading branch information
schteve committed Oct 27, 2022
1 parent a6721d3 commit a539289
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions freertos-cargo-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ pub struct Builder {
freertos_config_dir: PathBuf,
freertos_shim: PathBuf,
freertos_port: Option<PathBuf>,
freertos_port_base: Option<PathBuf>,
// name of the heap_?.c file
heap_c: PathBuf,
cc: Build,
freertos_port_base: PathBuf,
}

pub struct Error {
Expand Down Expand Up @@ -63,16 +63,15 @@ impl Builder {
let freertos_path = env::var(ENV_KEY_FREERTOS_SRC).unwrap_or_default();
let freertos_config_path = env::var(ENV_KEY_FREERTOS_CONFIG).unwrap_or_default();
let freertos_shim = env::var(ENV_KEY_FREERTOS_SHIM).unwrap_or_default();
let freertos_port_base = PathBuf::from(&freertos_path).join("portable");

let b = Builder {
freertos_dir: PathBuf::from(freertos_path),
freertos_config_dir: PathBuf::from(freertos_config_path),
freertos_shim: PathBuf::from(freertos_shim),
freertos_port: None,
freertos_port_base: None,
cc: cc::Build::new(),
heap_c: PathBuf::from("heap_4.c"),
freertos_port_base: PathBuf::from(freertos_port_base),
};
return b;
}
Expand Down Expand Up @@ -170,12 +169,8 @@ impl Builder {
self.freertos_port = Some(port_dir.as_ref().to_path_buf());
}

pub fn freertos_port_base<P: AsRef<Path>>(&mut self, base_dir: P) {
self.freertos_port_base = base_dir.as_ref().to_path_buf();
}

fn get_freertos_port_dir(&self) -> PathBuf {
let base = &self.freertos_port_base;
let base = self.get_freertos_port_base();
if self.freertos_port.is_some() {
return base.join(self.freertos_port.as_ref().unwrap());
}
Expand All @@ -201,6 +196,18 @@ impl Builder {
return base.join(port);
}

pub fn freertos_port_base<P: AsRef<Path>>(&mut self, base_dir: P) {
self.freertos_port_base = Some(base_dir.as_ref().to_path_buf());
}

fn get_freertos_port_base(&self) -> PathBuf {
if let Some(base) = &self.freertos_port_base {
base.clone()
} else {
PathBuf::from(&self.freertos_dir).join("portable")
}
}

fn heap_c_file(&self) -> PathBuf {
self.freertos_dir.join("portable/MemMang").join(&self.heap_c)
}
Expand Down

0 comments on commit a539289

Please sign in to comment.