Skip to content

Commit

Permalink
✨ - Copy source files to build directory for better editor tools support
Browse files Browse the repository at this point in the history
  • Loading branch information
jfrolich committed Jul 21, 2023
1 parent 60bef2c commit 41b44a4
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::clean;
use crate::clean::clean_mjs_files;
use crate::helpers;
use crate::helpers::emojis::*;
use crate::helpers::is_interface_ast_file;
use crate::logs;
use crate::package_tree;
use ahash::AHashSet;
Expand Down Expand Up @@ -139,7 +138,7 @@ fn filter_ppx_flags(ppx_flags: &Option<Vec<OneOrMore<String>>>) -> Option<Vec<On

fn path_to_ast_extension(path: &Path) -> &str {
let extension = path.extension().unwrap().to_str().unwrap();
return if is_interface_ast_file(extension) {
return if helpers::is_interface_ast_file(extension) {
".iast"
} else {
".ast"
Expand Down Expand Up @@ -1018,6 +1017,47 @@ pub fn compile_file(
.join(module_name.to_owned() + ".cmti"),
);
}
match &module.source_type {
SourceType::SourceFile(SourceFile {
interface: Some(Interface { path, .. }),
..
}) => {
let _ = std::fs::copy(
std::path::Path::new(&helpers::get_package_path(root_path, &package.name))
.join(path),
std::path::Path::new(&helpers::get_bs_build_path(root_path, &package.name))
.join(path),
)
.expect("copying interface file failed");
let _ = std::fs::copy(
std::path::Path::new(&helpers::get_package_path(root_path, &package.name))
.join(path),
std::path::Path::new(&helpers::get_build_path(root_path, &package.name))
.join(std::path::Path::new(path).file_name().unwrap()),
)
.expect("copying interface file failed");
}
SourceType::SourceFile(SourceFile {
implementation: Implementation { path, .. },
..
}) => {
let _ = std::fs::copy(
std::path::Path::new(&helpers::get_package_path(root_path, &package.name))
.join(path),
std::path::Path::new(&helpers::get_bs_build_path(root_path, &package.name))
.join(path),
)
.expect("copying implementation file failed");
let _ = std::fs::copy(
std::path::Path::new(&helpers::get_package_path(root_path, &package.name))
.join(path),
std::path::Path::new(&helpers::get_build_path(root_path, &package.name))
.join(std::path::Path::new(path).file_name().unwrap()),
)
.expect("copying implementation file failed");
}
_ => (),
}

if helpers::contains_ascii_characters(&err) {
if package.is_pinned_dep {
Expand Down

0 comments on commit 41b44a4

Please sign in to comment.