@@ -8,7 +8,7 @@ use super::packages;
88use crate :: config;
99use crate :: helpers;
1010use ahash:: { AHashMap , AHashSet } ;
11- use anyhow:: { anyhow, Result } ;
11+ use anyhow:: anyhow;
1212use console:: style;
1313use log:: { debug, trace} ;
1414use rayon:: prelude:: * ;
@@ -22,7 +22,7 @@ pub fn compile(
2222 inc : impl Fn ( ) + std:: marker:: Sync ,
2323 set_length : impl Fn ( u64 ) ,
2424 build_dev_deps : bool ,
25- ) -> Result < ( String , String , usize ) > {
25+ ) -> anyhow :: Result < ( String , String , usize ) > {
2626 let mut compiled_modules = AHashSet :: < String > :: new ( ) ;
2727 let dirty_modules = build_state
2828 . modules
@@ -148,7 +148,7 @@ pub fn compile(
148148 "cmi" ,
149149 ) ;
150150
151- let cmi_digest = helpers:: compute_file_hash ( & cmi_path) ;
151+ let cmi_digest = helpers:: compute_file_hash ( & Path :: new ( & cmi_path) ) ;
152152
153153 let package = build_state
154154 . get_package ( & module. package_name )
@@ -189,7 +189,7 @@ pub fn compile(
189189 & build_state. workspace_root ,
190190 build_dev_deps,
191191 ) ;
192- let cmi_digest_after = helpers:: compute_file_hash ( & cmi_path) ;
192+ let cmi_digest_after = helpers:: compute_file_hash ( & Path :: new ( & cmi_path) ) ;
193193
194194 // we want to compare both the hash of interface and the implementation
195195 // compile assets to verify that nothing changed. We also need to checke the interface
@@ -509,15 +509,14 @@ fn compile_file(
509509 project_root : & str ,
510510 workspace_root : & Option < String > ,
511511 build_dev_deps : bool ,
512- ) -> Result < Option < String > > {
512+ ) -> Result < Option < String > , String > {
513513 let ocaml_build_path_abs = package. get_ocaml_build_path ( ) ;
514514 let build_path_abs = package. get_build_path ( ) ;
515515 let implementation_file_path = match & module. source_type {
516516 SourceType :: SourceFile ( ref source_file) => Ok ( & source_file. implementation . path ) ,
517- sourcetype => Err ( anyhow ! (
517+ sourcetype => Err ( format ! (
518518 "Tried to compile a file that is not a source file ({}). Path to AST: {}. " ,
519- sourcetype,
520- ast_path
519+ sourcetype, ast_path
521520 ) ) ,
522521 } ?;
523522 let module_name = helpers:: file_path_to_module_name ( implementation_file_path, & package. namespace ) ;
@@ -544,12 +543,11 @@ fn compile_file(
544543 Ok ( x) if !x. status . success ( ) => {
545544 let stderr = String :: from_utf8_lossy ( & x. stderr ) ;
546545 let stdout = String :: from_utf8_lossy ( & x. stdout ) ;
547- Err ( anyhow ! ( stderr. to_string( ) + & stdout) )
546+ Err ( stderr. to_string ( ) + & stdout)
548547 }
549- Err ( e) => Err ( anyhow ! (
548+ Err ( e) => Err ( format ! (
550549 "Could not compile file. Error: {}. Path to AST: {:?}" ,
551- e,
552- ast_path
550+ e, ast_path
553551 ) ) ,
554552 Ok ( x) => {
555553 let err = std:: str:: from_utf8 ( & x. stderr )
@@ -598,36 +596,9 @@ fn compile_file(
598596 ocaml_build_path_abs. to_string ( ) + "/" + & module_name + ".cmi" ,
599597 ) ;
600598 }
601- match & module. source_type {
602- SourceType :: SourceFile ( SourceFile {
603- interface : Some ( Interface { path, .. } ) ,
604- ..
605- } )
606- | SourceType :: SourceFile ( SourceFile {
607- implementation : Implementation { path, .. } ,
608- ..
609- } ) => {
610- // we need to copy the source file to the build directory.
611- // editor tools expects the source file in lib/bs for finding the current package
612- // and in lib/ocaml when referencing modules in other packages
613- let _ = std:: fs:: copy (
614- std:: path:: Path :: new ( & package. path ) . join ( path) ,
615- std:: path:: Path :: new ( & package. get_build_path ( ) ) . join ( path) ,
616- )
617- . expect ( "copying source file failed" ) ;
618-
619- let _ = std:: fs:: copy (
620- std:: path:: Path :: new ( & package. path ) . join ( path) ,
621- std:: path:: Path :: new ( & package. get_build_path ( ) )
622- . join ( std:: path:: Path :: new ( path) . file_name ( ) . unwrap ( ) ) ,
623- )
624- . expect ( "copying source file failed" ) ;
625- }
626- _ => ( ) ,
627- }
628599
629600 if helpers:: contains_ascii_characters ( & err) {
630- if package. is_pinned_dep {
601+ if package. is_pinned_dep || package . is_local_dep {
631602 // supress warnings of external deps
632603 Ok ( Some ( err) )
633604 } else {
0 commit comments