gen_path_callouts: Add non strict mode

The targets generated from an MRW XML file may initially have some
structural problems, such as a unit target not having a parent chip
target.  It's easier to find all of the problems at once when the script
doesn't just die on the first one, so add a '-n' non strict mode where
it will continue on.

Change-Id: I7ca8097d6ad3c0dc44c661a474be63a727515457
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/gen_path_callouts.pl b/gen_path_callouts.pl
index 163ad22..a739072 100755
--- a/gen_path_callouts.pl
+++ b/gen_path_callouts.pl
@@ -220,6 +220,7 @@
 
 my $mrwFile = "";
 my $outFile = "";
+my $nonStrict = 0;
 my $printSegments = 0;
 
 # Not supporting priorites A, B, or C until necessary
@@ -231,6 +232,7 @@
 GetOptions(
     "m=s" => \$mrwFile,
     "o=s" => \$outFile,
+    "n" => \$nonStrict,
     "segments" => \$printSegments
 )
     or printUsage();
@@ -303,7 +305,15 @@
             $segment{SourceChip} = getParentByClass($target, "CHIP");
             if ($segment{SourceChip} eq "")
             {
-                die "Warning: Could not get parent chip for source $target\n";
+                if ($nonStrict)
+                {
+                    print "Warning: Could not get parent chip for source $target\n";
+                    next;
+                }
+                else
+                {
+                    die "Error: Could not get parent chip for source $target\n";
+                }
             }
 
             $segment{DestUnit} = $dest;
@@ -321,7 +331,15 @@
 
             if ($segment{DestChip} eq "")
             {
-                die "Warning: Could not get parent chip for dest $dest\n";
+                if ($nonStrict)
+                {
+                    print "Warning: Could not get parent chip for dest $dest\n";
+                    next;
+                }
+                else
+                {
+                    die "Error: Could not get parent chip for dest $dest\n";
+                }
             }
 
             my $fruPath = $targets->getBusAttribute(
@@ -870,6 +888,7 @@
     print "$0 -m <MRW file> -o <Output filename> [--segments] [-n]\n" .
     "        -m <MRW file> = The MRW XML\n" .
     "        -o <Output filename> = The output JSON\n" .
+    "        -n = Non-strict - Don't fail on some MRW structure problems\n" .
     "        [--segments] = Optionally create a segments.json file\n";
     exit(1);
 }