imgtools/buildrom/tools/externaltools.pm
changeset 590 360bd6b35136
parent 0 044383f39525
child 626 ac03b93ca9c4
equal deleted inserted replaced
588:c7c26511138f 590:360bd6b35136
    23 	loadTools
    23 	loadTools
    24 	runExternalTool
    24 	runExternalTool
    25 		
    25 		
    26 );
    26 );
    27 
    27 
    28 use Modload; # Dynamically loads the module
    28 use flexmodload; # Dynamically loads the module
       
    29 use IPC::Open3;
    29 my %invocations; # Indexed by invocation name;
    30 my %invocations; # Indexed by invocation name;
    30 
       
    31 #Set the Module path to load perl modules
       
    32 {
       
    33 	my $epocToolsPath = $ENV{EPOCROOT}."epoc32\\tools\\";
       
    34 	Load_SetModulePath($epocToolsPath);
       
    35 }
       
    36 
    31 
    37 # Get all the external tool perl module files to load them
    32 # Get all the external tool perl module files to load them
    38 sub loadTools{
    33 sub loadTools{
    39 	
    34 	
    40 	my $toolList = shift;
    35 	my $toolList = shift;
    44 		if ($tool !~ /^([^:]+)(:(.*))?$/) {
    39 		if ($tool !~ /^([^:]+)(:(.*))?$/) {
    45 			print "No tool specified as parameter for external tool invocation\n";
    40 			print "No tool specified as parameter for external tool invocation\n";
    46 		}
    41 		}
    47 		my $toolName = $1;
    42 		my $toolName = $1;
    48 		my $toolCmdLine = $3;
    43 		my $toolCmdLine = $3;
    49 		&Load_ModuleL($toolName);
    44 		if($toolName =~ /configpaging/i){			 
    50 		my $toolDetailsMap = $toolName.'::' . $toolName.'_info';
    45 			my %info = (name=>"configpaging", args=>$toolCmdLine ); 
    51 		update(&$toolDetailsMap, $toolCmdLine);
    46 			push @{$invocations{"invocationpoint2"}}, \%info;
       
    47 		}else{
       
    48 			&FlexLoad_ModuleL($toolName);
       
    49 			my $toolDetailsMap = $toolName.'::' . $toolName.'_info';
       
    50 			update(&$toolDetailsMap, $toolCmdLine);
       
    51 		}
       
    52 		
    52 	}
    53 	}
    53 }
    54 }
    54 
    55 
    55 #Initialises information from external tool
    56 #Initialises information from external tool
    56 sub update 
    57 sub update 
    87 	my ($stageName,$OBYData) = @_;
    88 	my ($stageName,$OBYData) = @_;
    88 	$stageName = lc $stageName;
    89 	$stageName = lc $stageName;
    89 	my @toolInfoList =  @{$invocations{$stageName}}; # Collect Tools with respect to its stagename.
    90 	my @toolInfoList =  @{$invocations{$stageName}}; # Collect Tools with respect to its stagename.
    90 	
    91 	
    91 	foreach my $tool (@toolInfoList) { # Traverse for the tools
    92 	foreach my $tool (@toolInfoList) { # Traverse for the tools
       
    93 		if($tool->{name} eq "configpaging"){
       
    94 			my $pid ; 
       
    95 			my $args = $tool->{args};
       
    96 		
       
    97 			open CONFIG, "| configpaging $args >cfgp_out.oby" or die "* Can't execute cpp";
       
    98 	
       
    99 			foreach (@$OBYData){
       
   100 				chomp ;
       
   101 				print CONFIG $_."\n";				 		
       
   102 			} 
       
   103 			print CONFIG ":q\n";  #terminate the program
    92 
   104 
       
   105 			close CONFIG;
       
   106 	
       
   107 			my $config_status = $?;
       
   108 			die "* configpaging failed\n" if ($config_status != 0 || !-f "cfgp_out.oby");
       
   109 
       
   110 			if(open(INTF,"cfgp_out.oby")){
       
   111 				@$OBYData = <INTF>;
       
   112 				close INTF;
       
   113 			}			
       
   114 			unlink("cfgp_out.oby") or die "cannot delete cfgp_out.oby";	
       
   115 			next ;
       
   116 		}
    93 		if (exists($tool->{single})) {#Check if single invocation exists
   117 		if (exists($tool->{single})) {#Check if single invocation exists
    94 			if (defined ($OBYData)) {
   118 			if (defined ($OBYData)) {
    95 				invoke_single($OBYData, $tool);
   119 				invoke_single($OBYData, $tool);
    96 			}				
   120 			}				
    97 			else {
   121 			else {