tools/repair_obyfile.pl
changeset 9 b5c893269cd5
parent 8 36cb9eb36988
child 57 a44af1db196f
--- a/tools/repair_obyfile.pl	Sat Oct 09 15:55:48 2010 +0100
+++ b/tools/repair_obyfile.pl	Sat Oct 09 18:20:42 2010 +0100
@@ -14,8 +14,17 @@
 # Process file ROM log to make it suitable for re-use by buildrom.pl
 
 use strict;
+use Getopt::Long;
+
+my $featurelist = "syborg_stem_features.iby";
+GetOptions(
+  "f|features=s" => \$featurelist,   # name of featurelist file
+  );
+
+print "ROM_IMAGE[0] {\n";
+print "#include \"$featurelist\"\n";
+
 my $line;
-
 while ($line = <>)
 	{
 	# Put back original auto-btmap statements for any "mbm_rom" derived files
@@ -33,7 +42,7 @@
 		{
 		next;		# discard this line - it will be regenerated by the __ECOM_PLUGIN
 		}
-	
+		
 	$line =~ s/REM processed //;	# re-enable other directives
 	
 	if ($line =~ /^time=/)
@@ -41,5 +50,25 @@
 		$line = "time=##TODAY## 12:00:00\n";
 		}
 	
+	# remove lines added by buildrom for generated files
+	
+	if ($line =~ /^data=\S+\\([^\\]+)\s+"\S+"/)
+		{
+		my $file = $1;
+		if ($file =~ /features.dat|ecom-\d-\d\.s/)
+			{
+			# print STDERR "Discarded: $line";
+			next;
+			}
+		}
+
+	if ($line =~ /^REM (ROM_IMAGE\[\d\])$/)
+		{
+		$line = "$1 {\n";
+		print "}\n";		# close the preceeding ROM_IMAGE
+		}
+
 	print $line;
 	}
+
+print "}\n";