Skip to content
Merged
Changes from all commits
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
38 changes: 37 additions & 1 deletion src/build/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,29 @@ pub fn generate_asts(
namespaces::compile_mlmap(package, module_name, &build_state.bsc_path);
let mlmap_hash_after = helpers::compute_file_hash(&compile_path);

let suffix = package
.namespace
.to_suffix()
.expect("namespace should be set for mlmap module");
// copy the mlmap to the bs build path for editor tooling
let base_build_path = package.get_build_path() + "/" + &suffix;
let base_bs_build_path = package.get_bs_build_path() + "/" + &suffix;
let _ = std::fs::copy(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be time to introduce something like anyhow or another way to do nice error handling - more of a note for the future

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah cool anyhow looks nice. This stuff also reminds me to refactor the string based paths to proper paths :)

base_build_path.to_string() + ".cmi",
base_bs_build_path.to_string() + ".cmi",
);
let _ = std::fs::copy(
base_build_path.to_string() + ".cmt",
base_bs_build_path.to_string() + ".cmt",
);
let _ = std::fs::copy(
base_build_path.to_string() + ".cmj",
base_bs_build_path.to_string() + ".cmj",
);
let _ = std::fs::copy(
base_build_path.to_string() + ".mlmap",
base_bs_build_path.to_string() + ".mlmap",
);
match (mlmap_hash, mlmap_hash_after) {
(Some(digest), Some(digest_after)) => !digest.eq(&digest_after),
_ => true,
Expand Down Expand Up @@ -299,7 +322,7 @@ fn generate_ast(
);

/* Create .ast */
if let Some(res_to_ast) = Some(
let result = if let Some(res_to_ast) = Some(
Command::new(bsc_path)
.current_dir(&build_path_abs)
.args(parser_args)
Expand All @@ -322,7 +345,20 @@ fn generate_ast(
"Could not find canonicalize_string_path for file {} in package {}",
filename, package.name
))
};
match &result {
Ok((ast_path, _)) => {
let dir = std::path::Path::new(filename).parent().unwrap();
let _ = std::fs::copy(
build_path_abs.to_string() + "/" + ast_path,
std::path::Path::new(&package.get_bs_build_path())
.join(dir)
.join(ast_path),
);
}
Err(_) => (),
}
result
}

fn path_to_ast_extension(path: &Path) -> &str {
Expand Down