Skip to content

Commit

Permalink
feat(system_headers): Avoiding check the fs for system headers to see…
Browse files Browse the repository at this point in the history
… if they are already built if there's no header declared by the user. This closes #116
  • Loading branch information
TheRustifyer committed Jun 24, 2024
1 parent ffd6648 commit f7c928c
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion zork++/src/lib/cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use std::{
fs::File,

Check failure on line 12 in zork++/src/lib/cache/mod.rs

View workflow job for this annotation

GitHub Actions / Verify code formatting

Diff in /home/runner/work/Zork/Zork/zork++/src/lib/cache/mod.rs
path::{Path, PathBuf},
};
use std::borrow::Cow;

use crate::bounds::TranslationUnit;
use crate::cache::compile_commands::CompileCommands;
Expand Down Expand Up @@ -148,7 +149,8 @@ impl<'a> ZorkCache<'a> {
msvc::load_metadata(self, program_data)?

Check failure on line 149 in zork++/src/lib/cache/mod.rs

View workflow job for this annotation

GitHub Actions / Verify code formatting

Diff in /home/runner/work/Zork/Zork/zork++/src/lib/cache/mod.rs
}

if compiler != CppCompiler::MSVC {
if compiler != CppCompiler::MSVC && helpers::user_declared_system_headers_to_build(program_data)
{
let i = Self::track_system_modules(program_data);
self.compilers_metadata.system_modules.clear();
self.compilers_metadata.system_modules.extend(i);
Expand Down Expand Up @@ -543,3 +545,16 @@ mod msvc {
Ok(env_vars)
}
}

Check failure on line 547 in zork++/src/lib/cache/mod.rs

View workflow job for this annotation

GitHub Actions / Verify code formatting

Diff in /home/runner/work/Zork/Zork/zork++/src/lib/cache/mod.rs

mod helpers {
use std::borrow::Cow;
use crate::project_model::ZorkModel;

pub(crate) fn user_declared_system_headers_to_build(program_data: &ZorkModel<'_>) -> bool {
program_data
.modules
.as_ref()
.map(|mods| mods.sys_modules.as_ref())
.is_some_and(|sys_modules: &Vec<Cow<str>>| !sys_modules.is_empty())
}
}

0 comments on commit f7c928c

Please sign in to comment.