Skip to content

Commit

Permalink
🚧 - Tmp Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandpeelen committed Apr 16, 2024
1 parent dcd708b commit 8acea99
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 31 deletions.
68 changes: 37 additions & 31 deletions src/build/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub fn generate_asts(
SourceType::SourceFile(source_file) => {
let root_package = build_state.get_package(&build_state.root_config_name).unwrap();

let (ast_path, iast_path, dirty) = if source_file.implementation.parse_dirty
let (ast_result, iast_result, dirty) = if source_file.implementation.parse_dirty
|| source_file
.interface
.as_ref()
Expand Down Expand Up @@ -80,18 +80,18 @@ pub fn generate_asts(
)
};

(module_name.to_owned(), ast_path, iast_path, dirty)
(module_name.to_owned(), ast_result, iast_result, dirty)
}
}
})
.collect::<Vec<(
String,
Result<(String, Option<String>), String>,
Result<Option<(String, Option<String>)>, String>,
Result<(String, Option<helpers::StdErr>), String>,
Result<Option<(String, Option<helpers::StdErr>)>, String>,
bool,
)>>()
.into_iter()
.for_each(|(module_name, ast_path, iast_path, is_dirty)| {
.for_each(|(module_name, ast_result, iast_result, is_dirty)| {
if let Some(module) = build_state.modules.get_mut(&module_name) {
// if the module is dirty, mark it also compile_dirty
// do NOT set to false if the module is not parse_dirty, it needs to keep
Expand All @@ -104,16 +104,16 @@ pub fn generate_asts(
.get(&module.package_name)
.expect("Package not found");
if let SourceType::SourceFile(ref mut source_file) = module.source_type {
match ast_path {
match ast_result {
// supress warnings in non-pinned deps
Ok((_path, Some(err))) if package.is_pinned_dep => {
Ok((_path, Some(stderr_output))) if package.is_pinned_dep => {
source_file.implementation.parse_state = ParseState::Warning;
source_file.implementation.parse_dirty = true;
if let Some(interface) = source_file.interface.as_mut() {
interface.parse_dirty = false;
}
logs::append(package, &err);
stderr.push_str(&err);
logs::append(package, &stderr_output);
stderr.push_str(&stderr_output);
}
Ok((_path, None)) => {
source_file.implementation.parse_state = ParseState::Success;
Expand All @@ -129,32 +129,38 @@ pub fn generate_asts(
has_failure = true;
stderr.push_str(&err);
}
_ => (),
Ok((_path, Some(_))) => {
// Allright Path, but some StdErr
}
};
}

match (iast_path, module.source_type.to_owned()) {
(Ok(Some((_path, Some(err)))), SourceType::SourceFile(ref mut source_file))
if package.is_pinned_dep =>
{
// supress warnings in non-pinned deps
if let Some(interface) = source_file.interface.as_mut() {
interface.parse_state = ParseState::Warning;
interface.parse_dirty = true;
match iast_result {
Ok(Some((_path, Some(stderr_output)))) if package.is_pinned_dep => {
// supress warnings in non-pinned deps
if let Some(interface) = source_file.interface.as_mut() {
interface.parse_state = ParseState::Warning;
interface.parse_dirty = true;
}
logs::append(package, &stderr_output);
stderr.push_str(&stderr_output);
}
logs::append(package, &err);
stderr.push_str(&err);
}
(Err(err), SourceType::SourceFile(ref mut source_file)) => {
if let Some(interface) = source_file.interface.as_mut() {
interface.parse_state = ParseState::ParseError;
interface.parse_dirty = true;
Err(err) => {
if let Some(interface) = source_file.interface.as_mut() {
interface.parse_state = ParseState::ParseError;
interface.parse_dirty = true;
}
logs::append(package, &err);
has_failure = true;
stderr.push_str(&err);
}
Ok(None) | Ok(Some((_, None))) | Ok(Some((_, Some(_)))) => {
// Either
// - No interface file
// - Some interfacefile, no StdErr
// - Some interfacefile, some StdErr output
()
}
logs::append(package, &err);
has_failure = true;
stderr.push_str(&err);
}
_ => (),
};
}
});
Expand Down Expand Up @@ -263,7 +269,7 @@ fn generate_ast(
version: &str,
bsc_path: &str,
workspace_root: &Option<String>,
) -> Result<(String, Option<String>), String> {
) -> Result<(String, Option<helpers::StdErr>), String> {
let file_path = PathBuf::from(&package.path).join(filename);
let contents = helpers::read_file(&file_path).expect("Error reading file");

Expand Down
2 changes: 2 additions & 0 deletions src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use std::path::{Component, Path, PathBuf};
use std::process::Command;
use std::time::{SystemTime, UNIX_EPOCH};

pub type StdErr = String;

pub mod emojis {
use console::Emoji;
pub static COMMAND: Emoji<'_, '_> = Emoji("🏃 ", "");
Expand Down

0 comments on commit 8acea99

Please sign in to comment.