imgtools/romtools/maksym/maksymrofs.pl
changeset 714 e5a58c351011
parent 654 7c11c3d8d025
--- a/imgtools/romtools/maksym/maksymrofs.pl	Tue Nov 30 14:05:41 2010 +0800
+++ b/imgtools/romtools/maksym/maksymrofs.pl	Tue Nov 30 17:14:57 2010 +0800
@@ -15,8 +15,115 @@
 # Produces symbolic information given a ROFS log file and .map files for relevant binary files
 #
 
-shift @ARGV;
-my $logfile = shift @ARGV;
-my $command = "rofsbuild -loginput=$logfile";
-system ($command);
+require 5.003_07;
+no strict 'vars';
+use English;
+use FindBin;		# for FindBin::Bin
+
+# Version
+my $MajorVersion = 1;
+my $MinorVersion = 1;
+my $PatchVersion = 0;
+
+# Globals
+my $maksym = "";
+my $rofsbuild;
+my $debug = 0;
+
+&args;
+&main;
 exit 0;
+
+#
+# main
+#
+sub main()
+{
+	my $symbolfile = $rofsbuild;
+  	$symbolfile =~ s/\.log$/\.symbol/i;
+  	my @cmdres = `rofsbuild -loginput=$rofsbuild`;
+  	print "@cmdres\n";
+	if(($maksym ne "") && ($maksym ne $symbolfile))
+ 	{
+	 	rename($symbolfile, $maksym);
+  	}
+}
+#
+# args - get command line args
+#
+sub args
+{
+	my $arg;
+	my @args;
+	my $flag;
+
+	&help if (!@ARGV);
+
+	while (@ARGV) 
+	{
+		$arg = shift @ARGV;
+
+		if ($arg=~/^[\-](\S*)$/) 
+		{
+			$flag=$1;
+
+			if ($flag=~/^[\?h]$/i) 
+			{
+				&help;
+			}
+			elsif ($flag=~/^d$/i) 
+			{
+				$debug = 1;
+			}
+		       	else 
+			{
+				print "\nERROR: Unknown flag \"-$flag\"\n";
+				&usage;
+				exit 1;
+			}
+		}
+		else 
+		{
+			push @args,$arg;
+		}
+	}
+
+	if (@args)
+	{
+		$rofsbuild = shift @args;
+		if (@args) 
+		{
+			$maksym = shift @args;
+			if (@args) 
+			{
+				print "\nERROR: Incorrect argument(s) \"@args\"\n";
+				&usage;
+				exit 1;
+			}
+		}
+	}
+}
+
+sub help ()
+{
+	my $build;
+
+	print "\nmaksymrofs - Produce symbolic information given a ROFS image V${MajorVersion}.${MinorVersion}.${PatchVersion}\n";
+	&usage;
+	exit 0;
+}
+
+sub usage ()
+{
+    print <<EOF
+
+Usage:
+  maksymrofs <logfile> [<outfile>]
+
+Where:
+  <logfile>   Log file from rofsbuild tool.
+  <outfile>   Output file. Defaults to imagename.symbol.
+EOF
+    ;
+    exit 0;
+}