@@ -2,7 +2,6 @@ use crate::bsconfig;
2
2
use crate :: bsconfig:: OneOrMore ;
3
3
use crate :: helpers;
4
4
use crate :: helpers:: get_bs_build_path;
5
- use crate :: helpers:: get_build_path;
6
5
use crate :: helpers:: get_package_path;
7
6
use crate :: package_tree;
8
7
use crate :: package_tree:: Package ;
@@ -15,7 +14,6 @@ use log::{debug, error};
15
14
use log:: { info, log_enabled} ;
16
15
use rayon:: prelude:: * ;
17
16
use std:: fs;
18
- use std:: fs:: File ;
19
17
use std:: io:: stdout;
20
18
use std:: io:: Write ;
21
19
use std:: io:: { self , BufRead } ;
@@ -54,6 +52,11 @@ pub struct Module {
54
52
pub interface_last_modified : Option < SystemTime > ,
55
53
}
56
54
55
+ fn read_lines ( filename : String ) -> io:: Result < io:: Lines < io:: BufReader < fs:: File > > > {
56
+ let file = fs:: File :: open ( filename) ?;
57
+ Ok ( io:: BufReader :: new ( file) . lines ( ) )
58
+ }
59
+
57
60
fn get_res_path_from_ast ( ast_file : & str ) -> Option < String > {
58
61
if let Ok ( lines) = read_lines ( ast_file. to_string ( ) ) {
59
62
// we skip the first line with is some null characters
@@ -75,50 +78,6 @@ fn get_res_path_from_ast(ast_file: &str) -> Option<String> {
75
78
return None ;
76
79
}
77
80
78
- fn get_compiler_asset (
79
- source_file : & str ,
80
- package_name : & str ,
81
- namespace : & Option < String > ,
82
- root_path : & str ,
83
- extension : & str ,
84
- ) -> String {
85
- let namespace = match extension {
86
- "ast" | "asti" => & None ,
87
- _ => namespace,
88
- } ;
89
-
90
- get_build_path ( root_path, package_name)
91
- + "/"
92
- + & helpers:: file_path_to_compiler_asset_basename ( source_file, namespace)
93
- + "."
94
- + extension
95
- }
96
-
97
- fn get_bs_compiler_asset (
98
- source_file : & str ,
99
- package_name : & str ,
100
- namespace : & Option < String > ,
101
- root_path : & str ,
102
- extension : & str ,
103
- ) -> String {
104
- let namespace = match extension {
105
- "ast" | "iast" => & None ,
106
- _ => namespace,
107
- } ;
108
- let dir = std:: path:: Path :: new ( source_file)
109
- . strip_prefix ( get_package_path ( root_path, & package_name) )
110
- . unwrap ( )
111
- . parent ( )
112
- . unwrap ( ) ;
113
-
114
- std:: path:: Path :: new ( & get_bs_build_path ( root_path, & package_name) )
115
- . join ( dir)
116
- . join ( helpers:: file_path_to_compiler_asset_basename ( source_file, namespace) + extension)
117
- . to_str ( )
118
- . unwrap ( )
119
- . to_owned ( )
120
- }
121
-
122
81
fn remove_compile_assets (
123
82
source_file : & str ,
124
83
package_name : & str ,
@@ -129,15 +88,15 @@ fn remove_compile_assets(
129
88
// optimization
130
89
// only issue cmti if htere is an interfacce file
131
90
for extension in & [ "cmj" , "cmi" , "cmt" , "cmti" , "ast" , "iast" ] {
132
- let _ = std:: fs:: remove_file ( get_compiler_asset (
91
+ let _ = std:: fs:: remove_file ( helpers :: get_compiler_asset (
133
92
source_file,
134
93
package_name,
135
94
namespace,
136
95
root_path,
137
96
extension,
138
97
) ) ;
139
98
if [ "cmj" , "cmi" , "cmt" , "cmti" ] . contains ( & extension) {
140
- let _ = std:: fs:: remove_file ( get_bs_compiler_asset (
99
+ let _ = std:: fs:: remove_file ( helpers :: get_bs_compiler_asset (
141
100
source_file,
142
101
package_name,
143
102
namespace,
@@ -343,11 +302,6 @@ fn generate_ast(
343
302
ast_path
344
303
}
345
304
346
- fn read_lines ( filename : String ) -> io:: Result < io:: Lines < io:: BufReader < File > > > {
347
- let file = File :: open ( filename) ?;
348
- Ok ( io:: BufReader :: new ( file) . lines ( ) )
349
- }
350
-
351
305
// Namespaces work like the following: The build system will generate a file
352
306
// called `MyModule.mlmap` which contains all modules that are in the namespace
353
307
//
0 commit comments