@@ -68,14 +68,20 @@ def print_notify_verbose(event):
68
68
print_notify (event ) # standard handle
69
69
70
70
def compile_worker (job ):
71
- _ , stderr , rc = run_cmd (job ['command' ], job ['work_dir' ])
71
+ results = []
72
+ for command in job ['commands' ]:
73
+ _ , stderr , rc = run_cmd (command , job ['work_dir' ])
74
+ results .append ({
75
+ 'code' : rc ,
76
+ 'output' : stderr ,
77
+ 'command' : command
78
+ })
72
79
73
80
return {
74
- 'code' : rc ,
75
- 'output' : stderr ,
76
- 'command' : job ['command' ],
77
81
'source' : job ['source' ],
78
- 'object' : job ['object' ]
82
+ 'object' : job ['object' ],
83
+ 'commands' : job ['commands' ],
84
+ 'results' : results
79
85
}
80
86
81
87
class Resources :
@@ -481,12 +487,12 @@ def compile_sources(self, resources, build_path, inc_dirs=None):
481
487
mkdir (work_dir )
482
488
483
489
# Queue mode (multiprocessing)
484
- command = self ._compile_command (source , object , inc_paths )
485
- if command is not None :
490
+ commands = self ._compile_command (source , object , inc_paths )
491
+ if commands is not None :
486
492
queue .append ({
487
493
'source' : source ,
488
494
'object' : object ,
489
- 'command ' : command ,
495
+ 'commands ' : commands ,
490
496
'work_dir' : work_dir ,
491
497
'chroot' : self .CHROOT
492
498
})
@@ -498,10 +504,23 @@ def compile_sources(self, resources, build_path, inc_dirs=None):
498
504
if jobs > CPU_COUNT_MIN and len (queue ) > jobs :
499
505
return self .compile_queue (queue , objects )
500
506
else :
501
- for item in queue :
502
- self .compile (item ['source' ], item ['object' ], inc_paths )
503
- objects .append (item ['object' ])
504
- return objects
507
+ return self .compile_seq (queue , objects )
508
+
509
+ def compile_seq (self , queue , objects ):
510
+ for item in queue :
511
+ result = compile_worker (item )
512
+
513
+ self .compiled += 1
514
+ self .progress ("compile" , item ['source' ], build_update = True )
515
+ for res in result ['results' ]:
516
+ self .debug ("Command: %s" % ' ' .join (res ['command' ]))
517
+ self ._compile_output ([
518
+ res ['code' ],
519
+ res ['output' ],
520
+ res ['command' ]
521
+ ])
522
+ objects .append (result ['object' ])
523
+ return objects
505
524
506
525
def compile_queue (self , queue , objects ):
507
526
jobs_count = int (self .jobs if self .jobs else cpu_count ())
@@ -525,15 +544,16 @@ def compile_queue(self, queue, objects):
525
544
try :
526
545
result = r .get ()
527
546
results .remove (r )
528
-
547
+
529
548
self .compiled += 1
530
- self .progress ("compile" , result ['source' ], build_update = True )
531
- self .debug ("Command: %s" % ' ' .join (result ['command' ]))
532
- self ._compile_output ([
533
- result ['code' ],
534
- result ['output' ],
535
- result ['command' ]
536
- ])
549
+ self .progress ("compile" , result ['source' ], build_update = True )
550
+ for res in result ['results' ]:
551
+ self .debug ("Command: %s" % ' ' .join (res ['command' ]))
552
+ self ._compile_output ([
553
+ res ['code' ],
554
+ res ['output' ],
555
+ res ['command' ]
556
+ ])
537
557
objects .append (result ['object' ])
538
558
except ToolException , err :
539
559
p .terminate ()
@@ -555,42 +575,25 @@ def compile_queue(self, queue, objects):
555
575
p .join ()
556
576
557
577
return objects
558
-
578
+
559
579
def _compile_command (self , source , object , includes ):
560
580
# Check dependencies
561
581
_ , ext = splitext (source )
562
582
ext = ext .lower ()
563
- base , _ = splitext (object )
564
- dep_path = base + '.d'
565
- asm_mode = False
566
583
567
- if ext == '.c' :
568
- cc = self .cc
569
- elif ext == '.cpp' :
570
- cc = self .cppc
584
+ if ext == '.c' or ext == '.cpp' :
585
+ base , _ = splitext (object )
586
+ dep_path = base + '.d'
587
+ deps = self .parse_dependencies (dep_path ) if (exists (dep_path )) else []
588
+ if len (deps ) == 0 or self .need_update (object , deps ):
589
+ return self ._compile (source , object , includes )
571
590
elif ext == '.s' :
572
- cc = self .asm
573
- asm_mode = True
591
+ deps = [source ]
592
+ if self .need_update (object , deps ):
593
+ return self ._assemble (source , object , includes )
574
594
else :
575
595
return False
576
596
577
- deps = []
578
- if asm_mode :
579
- deps = [source ]
580
- elif exists (dep_path ):
581
- deps = self .parse_dependencies (dep_path )
582
-
583
- if len (deps ) == 0 or self .need_update (object , deps ):
584
- command = cc + ['-D%s' % s for s in self .get_symbols ()] + ["-I%s" % i for i in includes ] + ["-o" , object , source ]
585
-
586
- if asm_mode is False and hasattr (self , "get_dep_opt" ):
587
- command .extend (self .get_dep_opt (dep_path ))
588
-
589
- if hasattr (self , "cc_extra" ):
590
- command .extend (self .cc_extra (base ))
591
-
592
- return command
593
-
594
597
return None
595
598
596
599
def _compile_output (self , output = []):
@@ -607,16 +610,31 @@ def _compile_output(self, output=[]):
607
610
if rc != 0 :
608
611
raise ToolException (stderr )
609
612
613
+ def _compile (self , source , object , includes ):
614
+ _ , ext = splitext (source )
615
+ ext = ext .lower ()
616
+
617
+ cc = self .cppc if ext == ".cpp" else self .cc
618
+ command = cc + ['-D%s' % s for s in self .get_symbols ()] + ["-I%s" % i for i in includes ] + ["-o" , object , source ]
619
+
620
+ if hasattr (self , "get_dep_opt" ):
621
+ base , _ = splitext (object )
622
+ dep_path = base + '.d'
623
+ command .extend (self .get_dep_opt (dep_path ))
624
+
625
+ if hasattr (self , "cc_extra" ):
626
+ command .extend (self .cc_extra (base ))
627
+
628
+ return [command ]
629
+
610
630
def compile (self , source , object , includes ):
611
- self .compiled += 1
612
631
self .progress ("compile" , source , build_update = True )
613
632
614
- command = self ._compile_command (source , object , includes )
615
- if command is None : return True
616
-
617
- self .debug ("Command: %s" % ' ' .join (command ))
618
- _ , stderr , rc = run_cmd (command , dirname (object ))
619
- self ._compile_output ([rc , stderr , command ])
633
+ commands = self ._compile (source , object , includes )
634
+ for command in commands :
635
+ self .debug ("Command: %s" % ' ' .join (command ))
636
+ _ , stderr , rc = run_cmd (command , dirname (object ))
637
+ self ._compile_output ([rc , stderr , command ])
620
638
621
639
def compile_c (self , source , object , includes ):
622
640
self .compile (source , object , includes )
0 commit comments