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

Fix port base for non-linux targets #41

Merged
merged 1 commit into from Oct 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 15 additions & 8 deletions freertos-cargo-build/src/lib.rs
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