@@ -8,7 +8,7 @@ use super::packages;
8
8
use crate :: config;
9
9
use crate :: helpers;
10
10
use ahash:: { AHashMap , AHashSet } ;
11
- use anyhow:: { anyhow, Result } ;
11
+ use anyhow:: anyhow;
12
12
use console:: style;
13
13
use log:: { debug, trace} ;
14
14
use rayon:: prelude:: * ;
@@ -22,7 +22,7 @@ pub fn compile(
22
22
inc : impl Fn ( ) + std:: marker:: Sync ,
23
23
set_length : impl Fn ( u64 ) ,
24
24
build_dev_deps : bool ,
25
- ) -> Result < ( String , String , usize ) > {
25
+ ) -> anyhow :: Result < ( String , String , usize ) > {
26
26
let mut compiled_modules = AHashSet :: < String > :: new ( ) ;
27
27
let dirty_modules = build_state
28
28
. modules
@@ -148,7 +148,7 @@ pub fn compile(
148
148
"cmi" ,
149
149
) ;
150
150
151
- let cmi_digest = helpers:: compute_file_hash ( & cmi_path) ;
151
+ let cmi_digest = helpers:: compute_file_hash ( & Path :: new ( & cmi_path) ) ;
152
152
153
153
let package = build_state
154
154
. get_package ( & module. package_name )
@@ -189,7 +189,7 @@ pub fn compile(
189
189
& build_state. workspace_root ,
190
190
build_dev_deps,
191
191
) ;
192
- let cmi_digest_after = helpers:: compute_file_hash ( & cmi_path) ;
192
+ let cmi_digest_after = helpers:: compute_file_hash ( & Path :: new ( & cmi_path) ) ;
193
193
194
194
// we want to compare both the hash of interface and the implementation
195
195
// compile assets to verify that nothing changed. We also need to checke the interface
@@ -509,15 +509,14 @@ fn compile_file(
509
509
project_root : & str ,
510
510
workspace_root : & Option < String > ,
511
511
build_dev_deps : bool ,
512
- ) -> Result < Option < String > > {
512
+ ) -> Result < Option < String > , String > {
513
513
let ocaml_build_path_abs = package. get_ocaml_build_path ( ) ;
514
514
let build_path_abs = package. get_build_path ( ) ;
515
515
let implementation_file_path = match & module. source_type {
516
516
SourceType :: SourceFile ( ref source_file) => Ok ( & source_file. implementation . path ) ,
517
- sourcetype => Err ( anyhow ! (
517
+ sourcetype => Err ( format ! (
518
518
"Tried to compile a file that is not a source file ({}). Path to AST: {}. " ,
519
- sourcetype,
520
- ast_path
519
+ sourcetype, ast_path
521
520
) ) ,
522
521
} ?;
523
522
let module_name = helpers:: file_path_to_module_name ( implementation_file_path, & package. namespace ) ;
@@ -544,12 +543,11 @@ fn compile_file(
544
543
Ok ( x) if !x. status . success ( ) => {
545
544
let stderr = String :: from_utf8_lossy ( & x. stderr ) ;
546
545
let stdout = String :: from_utf8_lossy ( & x. stdout ) ;
547
- Err ( anyhow ! ( stderr. to_string( ) + & stdout) )
546
+ Err ( stderr. to_string ( ) + & stdout)
548
547
}
549
- Err ( e) => Err ( anyhow ! (
548
+ Err ( e) => Err ( format ! (
550
549
"Could not compile file. Error: {}. Path to AST: {:?}" ,
551
- e,
552
- ast_path
550
+ e, ast_path
553
551
) ) ,
554
552
Ok ( x) => {
555
553
let err = std:: str:: from_utf8 ( & x. stderr )
@@ -598,36 +596,9 @@ fn compile_file(
598
596
ocaml_build_path_abs. to_string ( ) + "/" + & module_name + ".cmi" ,
599
597
) ;
600
598
}
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
- }
628
599
629
600
if helpers:: contains_ascii_characters ( & err) {
630
- if package. is_pinned_dep {
601
+ if package. is_pinned_dep || package . is_local_dep {
631
602
// supress warnings of external deps
632
603
Ok ( Some ( err) )
633
604
} else {
0 commit comments