tools/filter_obyfile.pl
changeset 22 76c5e260003e
parent 19 b1cc137d8adb
child 27 c29882e1d694
equal deleted inserted replaced
21:4a02a61ca23a 22:76c5e260003e
    42 
    42 
    43 	$cmd = lc $cmd;
    43 	$cmd = lc $cmd;
    44 	if ($cmd eq "stem")
    44 	if ($cmd eq "stem")
    45 		{
    45 		{
    46 		$stem_substitutions{$romfile} = $hostfile;
    46 		$stem_substitutions{$romfile} = $hostfile;
       
    47 		$must_have{$romfile} = 1;
    47 		next;
    48 		next;
    48 		}
    49 		}
    49 	
    50 	
    50 	if ($cmd eq "out")
    51 	if ($cmd eq "out")
    51 		{
    52 		{
    66 	scalar keys %deletions, 
    67 	scalar keys %deletions, 
    67 	scalar keys %must_have;
    68 	scalar keys %must_have;
    68 
    69 
    69 # read static dependencies file
    70 # read static dependencies file
    70 my %exe_to_romfile;
    71 my %exe_to_romfile;
       
    72 my %exe_dependencies;
    71 my %lc_romfiles;
    73 my %lc_romfiles;
    72 
    74 
    73 my $line;
    75 my $line;
    74 open STATIC_DEPENDENCIES, "<$static_dependencies_txt" or die ("Cannot read $static_dependencies_txt: $!\n");
    76 open STATIC_DEPENDENCIES, "<$static_dependencies_txt" or die ("Cannot read $static_dependencies_txt: $!\n");
    75 while ($line = <STATIC_DEPENDENCIES>)
    77 while ($line = <STATIC_DEPENDENCIES>)
    76 	{
    78 	{
    77 	chomp $line;
    79 	chomp $line;
    78 	last if ($line eq "");	# blank line between the two sections
       
    79 	my ($romfile, $hostfile, $stuff) = split /\t/, $line;
    80 	my ($romfile, $hostfile, $stuff) = split /\t/, $line;
       
    81 
       
    82 	next if ($romfile eq "x");	# pre-inverted dependency information
       
    83 	
       
    84 	if (defined $stem_substitutions{$romfile})
       
    85 		{
       
    86 		if ($hostfile !~ /\/stem_/)
       
    87 			{
       
    88 			print STDERR "Ignoring dependencies of $hostfile because of stem substitution of $romfile\n";
       
    89 			next;
       
    90 			}
       
    91 		}
    80 
    92 
    81 	$lc_romfiles{lc $romfile} = $romfile;
    93 	$lc_romfiles{lc $romfile} = $romfile;
    82 	
    94 	
    83 	if ($romfile =~ /^sys.bin.(.*)$/i)
    95 	if ($romfile =~ /^sys.bin.(.*)$/i)
    84 		{
    96 		{
    85 		my $exe = lc $1;
    97 		my $exe = lc $1;
    86 		$exe_to_romfile{$exe} = $romfile;
    98 		$exe_to_romfile{$exe} = $romfile;
    87 		}
    99 		}
    88 	}
   100 
    89 my %exe_dependencies;
   101 	foreach my $dependent (split /:/,$stuff)
    90 while ($line = <STATIC_DEPENDENCIES>)
   102 		{
    91 	{
   103 		next if ($dependent =~ /^sid=/);
    92 	chomp $line;
   104 		$dependent = lc $dependent;
    93 	my ($x, $exename, @dependencies) = split /\t/,$line;
   105 		
    94 	$exe_dependencies{$exename} = \@dependencies;
   106 		$dependent =~ s/^sys\\bin\\//;	# no directory => sys\bin anyway
       
   107 		$dependent =~ s/\[\S+\]//;	# ignore the UIDs for now
       
   108 		
       
   109 		if (!defined $exe_dependencies{$dependent})
       
   110 			{
       
   111 			my @dependents = ($romfile);
       
   112 			$exe_dependencies{$dependent} = \@dependents;
       
   113 			}
       
   114 		else
       
   115 			{
       
   116 			push @{$exe_dependencies{$dependent}}, $romfile;
       
   117 			}
       
   118 		}
    95 	}
   119 	}
    96 close STATIC_DEPENDENCIES;
   120 close STATIC_DEPENDENCIES;
    97 
   121 
    98 # Create static dependencies for aliases
   122 # Add static dependencies for aliases
    99 
   123 
   100 my @obylines = <>;	# read the oby file
   124 my @obylines = <>;	# read the oby file
   101 
   125 
   102 foreach my $line (@obylines)
   126 foreach my $line (@obylines)
   103 	{
   127 	{
   105 		{
   129 		{
   106 		my $romfile = $1;
   130 		my $romfile = $1;
   107 		my $newname = $2;
   131 		my $newname = $2;
   108 
   132 
   109 		$romfile =~ s/^\\sys/sys/;	# remove leading \, to match $romfile convention
   133 		$romfile =~ s/^\\sys/sys/;	# remove leading \, to match $romfile convention
   110 		next if (!defined $lc_romfiles{lc $romfile});		# aliases to non-executables
   134 		next if (!defined $lc_romfiles{lc $romfile});		# ignore aliases to non-executables
   111 		$romfile = $lc_romfiles{lc $romfile};
   135 		$romfile = $lc_romfiles{lc $romfile};
   112 
   136 
   113 		$newname =~ s/^\\sys/sys/;	# remove leading \, to match $romfile convention
   137 		$newname =~ s/^\\sys/sys/;	# remove leading \, to match $romfile convention
   114 		$lc_romfiles{lc $newname} = $newname;
   138 		$lc_romfiles{lc $newname} = $newname;
   115 		
   139