@@ -241,7 +241,7 @@ pub fn generate_asts<'a>(
241
241
let mut has_failure = false ;
242
242
let mut stderr = "" . to_string ( ) ;
243
243
244
- modules
244
+ let results = modules
245
245
. par_iter ( )
246
246
. map ( |( module_name, module) | {
247
247
debug ! ( "Generating AST for module: {}" , module_name) ;
@@ -265,7 +265,7 @@ pub fn generate_asts<'a>(
265
265
) ) ,
266
266
Ok ( None ) ,
267
267
module. deps . to_owned ( ) ,
268
- false ,
268
+ None ,
269
269
)
270
270
}
271
271
@@ -350,19 +350,12 @@ pub fn generate_asts<'a>(
350
350
AHashSet :: new ( )
351
351
} ;
352
352
353
- let has_dirty_namespace = match module. package . namespace . to_owned ( ) {
354
- Some ( namespace) => deleted_modules. contains ( & namespace) ,
355
- None => false ,
356
- } ;
357
-
358
- let has_dirty_deps = !deps. is_disjoint ( deleted_modules) || has_dirty_namespace;
359
-
360
353
(
361
354
module_name. to_owned ( ) ,
362
355
ast_path,
363
356
asti_path,
364
357
deps,
365
- has_dirty_deps ,
358
+ module . package . namespace . to_owned ( ) ,
366
359
)
367
360
}
368
361
}
@@ -372,10 +365,51 @@ pub fn generate_asts<'a>(
372
365
Result < ( String , Option < String > ) , String > ,
373
366
Result < Option < ( String , Option < String > ) > , String > ,
374
367
AHashSet < String > ,
375
- bool ,
376
- ) > > ( )
368
+ Option < String > ,
369
+ ) > > ( ) ;
370
+
371
+ let mut checked_modules = AHashSet :: new ( ) ;
372
+ let mut dirty_modules = deleted_modules. clone ( ) ;
373
+ dirty_modules. extend (
374
+ modules
375
+ . iter ( )
376
+ . filter_map ( |( module_name, module) | {
377
+ if is_dirty ( & module) {
378
+ Some ( module_name. to_string ( ) )
379
+ } else {
380
+ None
381
+ }
382
+ } )
383
+ . collect :: < AHashSet < String > > ( ) ,
384
+ ) ;
385
+
386
+ loop {
387
+ let mut num_checked_modules = 0 ;
388
+ for ( module_name, _ast_path, _iast_path, deps, namespace) in results. iter ( ) {
389
+ if !checked_modules. contains ( module_name) {
390
+ num_checked_modules += 1 ;
391
+ if deps. is_subset ( & checked_modules) {
392
+ checked_modules. insert ( module_name. to_string ( ) ) ;
393
+
394
+ let has_dirty_namespace = match namespace {
395
+ Some ( namespace) => dirty_modules. contains ( namespace) ,
396
+ None => false ,
397
+ } ;
398
+
399
+ if !deps. is_disjoint ( & dirty_modules) || has_dirty_namespace {
400
+ dirty_modules. insert ( module_name. to_string ( ) ) ;
401
+ }
402
+ }
403
+ }
404
+ }
405
+ if num_checked_modules == 0 {
406
+ break ;
407
+ }
408
+ }
409
+
410
+ results
377
411
. into_iter ( )
378
- . for_each ( |( module_name, ast_path, iast_path, deps, has_dirty_deps ) | {
412
+ . for_each ( |( module_name, ast_path, iast_path, deps, _namespace ) | {
379
413
if let Some ( module) = modules. get_mut ( & module_name) {
380
414
module. deps = deps;
381
415
match ast_path {
@@ -437,13 +471,16 @@ pub fn generate_asts<'a>(
437
471
}
438
472
} ;
439
473
440
- if has_dirty_deps {
474
+ if dirty_modules . contains ( & module_name ) {
441
475
match module. source_type {
442
476
SourceType :: SourceFile ( ref mut source_file) => {
443
477
source_file. implementation . dirty = true ;
444
- source_file. interface . as_mut ( ) . map ( |interface| {
445
- interface. dirty = true ;
446
- } ) ;
478
+ match source_file. interface {
479
+ Some ( ref mut interface) => {
480
+ interface. dirty = true ;
481
+ }
482
+ None => ( ) ,
483
+ }
447
484
}
448
485
SourceType :: MlMap ( ref mut mlmap) => {
449
486
mlmap. dirty = true ;
@@ -958,8 +995,8 @@ pub fn build(path: &str) -> Result<AHashMap<std::string::String, Module>, ()> {
958
995
) ;
959
996
let start_compiling = Instant :: now ( ) ;
960
997
961
- // let mut compiled_modules = AHashSet::<String>::new();
962
- let mut compiled_modules = modules
998
+ let mut compiled_modules = AHashSet :: < String > :: new ( ) ;
999
+ let clean_modules = modules
963
1000
. iter ( )
964
1001
. filter_map ( |( module_name, module) | {
965
1002
if is_dirty ( module) {
@@ -970,6 +1007,9 @@ pub fn build(path: &str) -> Result<AHashMap<std::string::String, Module>, ()> {
970
1007
} )
971
1008
. collect :: < AHashSet < String > > ( ) ;
972
1009
1010
+ // always clean build
1011
+ // let clean_modules = AHashSet::<String>::new();
1012
+
973
1013
let mut loop_count = 0 ;
974
1014
let mut files_total_count = compiled_modules. len ( ) ;
975
1015
let mut files_current_loop_count;
@@ -994,6 +1034,9 @@ pub fn build(path: &str) -> Result<AHashMap<std::string::String, Module>, ()> {
994
1034
if module. deps . is_subset ( & compiled_modules)
995
1035
&& !compiled_modules. contains ( module_name)
996
1036
{
1037
+ if clean_modules. contains ( module_name) {
1038
+ return Some ( ( module_name. to_owned ( ) , Ok ( None ) , Some ( Ok ( None ) ) ) ) ;
1039
+ }
997
1040
match module. source_type . to_owned ( ) {
998
1041
SourceType :: MlMap ( _) => {
999
1042
// the mlmap needs to be compiled before the files are compiled
0 commit comments