imgtools/buildrom/tools/externaltools.pm
changeset 626 ac03b93ca9c4
parent 590 360bd6b35136
child 706 5221386d044b
equal deleted inserted replaced
625:a1925fb7753a 626:ac03b93ca9c4
    83 }
    83 }
    84 
    84 
    85 # Called between the buildrom stage to invoke single or multiple invocation
    85 # Called between the buildrom stage to invoke single or multiple invocation
    86 sub runExternalTool {
    86 sub runExternalTool {
    87 	
    87 	
    88 	my ($stageName,$OBYData) = @_;
    88 	my ($stageName,$OBYData,$workdir) = @_;
    89 	$stageName = lc $stageName;
    89 	$stageName = lc $stageName;
    90 	my @toolInfoList =  @{$invocations{$stageName}}; # Collect Tools with respect to its stagename.
    90 	my @toolInfoList =  @{$invocations{$stageName}}; # Collect Tools with respect to its stagename.
    91 	
    91 	
    92 	foreach my $tool (@toolInfoList) { # Traverse for the tools
    92 	foreach my $tool (@toolInfoList) { # Traverse for the tools
    93 		if($tool->{name} eq "configpaging"){
    93 		if($tool->{name} eq "configpaging"){
    94 			my $pid ; 
    94 			my $pid ; 
    95 			my $args = $tool->{args};
    95 			my $args = $tool->{args};
    96 		
    96 			my $outputoby = $workdir."cfgp_out.oby";
    97 			open CONFIG, "| configpaging $args >cfgp_out.oby" or die "* Can't execute cpp";
    97 			open CONFIG, "| configpaging $args >$outputoby" or die "* Can't execute configpaging";
    98 	
    98 	
    99 			foreach (@$OBYData){
    99 			foreach (@$OBYData){
   100 				chomp ;
   100 				chomp ;
   101 				print CONFIG $_."\n";				 		
   101 				print CONFIG $_."\n";				 		
   102 			} 
   102 			} 
   103 			print CONFIG ":q\n";  #terminate the program
   103 			print CONFIG ":q\n";  #terminate the program
   104 
   104 
   105 			close CONFIG;
   105 			close CONFIG;
   106 	
   106 	
   107 			my $config_status = $?;
   107 			my $config_status = $?;
   108 			die "* configpaging failed\n" if ($config_status != 0 || !-f "cfgp_out.oby");
   108 			die "* configpaging failed\n" if ($config_status != 0 || !-f "$outputoby");
   109 
   109 
   110 			if(open(INTF,"cfgp_out.oby")){
   110 			if(open(INTF,"$outputoby")){
   111 				@$OBYData = <INTF>;
   111 				@$OBYData = <INTF>;
   112 				close INTF;
   112 				close INTF;
   113 			}			
   113 			}			
   114 			unlink("cfgp_out.oby") or die "cannot delete cfgp_out.oby";	
   114 			unlink("$outputoby") or die "cannot delete $outputoby";	
   115 			next ;
   115 			next ;
   116 		}
   116 		}
   117 		if (exists($tool->{single})) {#Check if single invocation exists
   117 		if (exists($tool->{single})) {#Check if single invocation exists
   118 			if (defined ($OBYData)) {
   118 			if (defined ($OBYData)) {
   119 				invoke_single($OBYData, $tool);
   119 				invoke_single($OBYData, $tool);