]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fixed the issue in multi-msa build in single mode; cleaned the code of re-ordering...
authorjwang36 <jwang36@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 22 Dec 2006 07:55:24 +0000 (07:55 +0000)
committerjwang36 <jwang36@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 22 Dec 2006 07:55:24 +0000 (07:55 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2130 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Java/Source/GenBuild/org/tianocore/build/autogen/AutogenLibOrder.java
Tools/Java/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java

index 9674c5de0882951bb7c66cee794d1968de60ab8c..0ba6825906a116ae298593d73e85b570d26e7573 100644 (file)
@@ -112,30 +112,6 @@ public class AutogenLibOrder {
                 }\r
             }\r
         }\r
                 }\r
             }\r
         }\r
-\r
-        //\r
-        // Check is the library instance list meet the require;\r
-        //\r
-        //for (int s = 0; s < this.libInstanceList.size(); s++) {\r
-        //    String[] libClass = this.libInstanceMap.get(this.libInstanceList\r
-        //            .get(s));\r
-        //    if (libClass != null) {\r
-        //        for (int t = 0; t < libClass.length; t++) {\r
-        //            if (this.libClassMap.get(libClass[t]) == null) {\r
-                        //\r
-                        // Note: There exist a kind of module which depend on \r
-                        // library class with no instance or whose instance will\r
-                        // never be linked into the module. \r
-                        // For this satuation, the module has the description of \r
-                        // library class in MSA file but no description of \r
-                        // corresponding library instance in MBD file. There \r
-                        // will be a warnig message given here after a standard \r
-                        // log way has been decided.\r
-                        //\r
-        //           }\r
-        //       }\r
-        //   }\r
-        //}\r
     }\r
 \r
     /**\r
     }\r
 \r
     /**\r
@@ -146,131 +122,86 @@ public class AutogenLibOrder {
       \r
       @return     List which content the ordered library instance.\r
     **/\r
       \r
       @return     List which content the ordered library instance.\r
     **/\r
-    List<ModuleIdentification> orderLibInstance1() {\r
-        List<ModuleIdentification> orderList = new ArrayList<ModuleIdentification>();\r
-        //\r
-        // Stack of node which track the library instance name ant its visiting\r
-        // flag.\r
-        //\r
-        List<Node> stackList = new ArrayList<Node>();\r
-        int stackSize = 0;\r
-        ModuleIdentification libInstanceId = null;\r
-        if (libInstanceList.size() < 0) {\r
-            return null;\r
-        }\r
-\r
-        //\r
-        // Reorder the library instance.\r
-        //\r
-        for (int i = 0; i < libInstanceList.size(); i++) {\r
-            //\r
-            // If library instance is already in the order list skip it.\r
-            //\r
-            if (isInLibInstance(orderList, libInstanceList.get(i).libId)) {\r
-                continue;\r
-            }\r
-            \r
-            Node node = new Node(libInstanceList.get(i).libId, false);\r
-            //\r
-            // Use stack to reorder library instance.\r
-            // Push node to stack.\r
-            //\r
-            stackList.add(node);\r
-            while (stackList.size() > 0) {\r
-                stackSize = stackList.size() - 1;\r
-                //\r
-                // Pop the first node in stack. If the node flag has been visited\r
-                // add this node to orderlist and remove it from stack.\r
-                //\r
-                if (stackList.get(stackSize).isVisit) {\r
-                    if (!isInLibInstance(orderList,\r
-                            stackList.get(stackSize).nodeId)) {\r
-                        orderList.add(stackList.get(stackSize).nodeId);\r
-                        stackList.remove(stackSize);\r
-                    }\r
-                    \r
-                } else {\r
-                    //\r
-                    // Get the node value and set visit flag as true.\r
-                    //\r
-                    stackList.get(stackList.size() - 1).isVisit = true;\r
-                    String[] libClassList = this.libInstanceMap.get(stackList\r
-                            .get(stackSize).nodeId);\r
-                    //\r
-                    // Push the node dependence library instance to the stack.\r
-                    //\r
-                    if (libClassList != null) {\r
-                        for (int j = 0; j < libClassList.length; j++) {\r
-                            libInstanceId = this.libClassMap.get(libClassList[j]);\r
-                            if (libInstanceId != null\r
-                                    && !isInLibInstance(orderList, libInstanceId)) {\r
-                                //\r
-                                // If and only if the currently library instance\r
-                                // is not in stack and it have constructor or \r
-                                // destructor function, push this library \r
-                                // instacne in stack.\r
-                                //\r
-                                if (!isInStackList(stackList, this.libClassMap\r
-                                        .get(libClassList[j])) /* && isHaveConsDestructor(libInstanceId) */) {\r
-                                    stackList.add(new Node(this.libClassMap\r
-                                            .get(libClassList[j]), false));\r
-                                }\r
-                            }\r
-                        }\r
-                    }\r
-                }\r
-                System.out.println("################################################");\r
-                for (int ii = 0; ii < orderList.size(); ++ii) {\r
-                    System.out.println("  " + orderList.get(ii));\r
-                }\r
-            }\r
-        }\r
-        return orderList;\r
-    }\r
-\r
     List<ModuleIdentification> orderLibInstance() {\r
         LinkedList<ModuleIdentification> orderList = new LinkedList<ModuleIdentification>();\r
         for (int i = 0; i < libInstanceList.size(); ++i) {\r
             ModuleIdentification current = libInstanceList.get(i).libId;\r
             int insertPoint = orderList.size();\r
     List<ModuleIdentification> orderLibInstance() {\r
         LinkedList<ModuleIdentification> orderList = new LinkedList<ModuleIdentification>();\r
         for (int i = 0; i < libInstanceList.size(); ++i) {\r
             ModuleIdentification current = libInstanceList.get(i).libId;\r
             int insertPoint = orderList.size();\r
+            //\r
+            // check current library instance against orderred ones in orderList\r
+            // \r
             for (int j = 0; j < orderList.size(); ++j) {\r
                 ModuleIdentification old = orderList.get(j);\r
             for (int j = 0; j < orderList.size(); ++j) {\r
                 ModuleIdentification old = orderList.get(j);\r
-                //System.out.println("### old = " + old);\r
                 if (consumes(current, old)) {\r
                 if (consumes(current, old)) {\r
+                    //\r
+                    // if current library instance consumes the one in orderList\r
+                    // it must be put after\r
+                    // \r
                     insertPoint = j + 1;\r
                 } else if (consumes(old, current)) {\r
                     insertPoint = j + 1;\r
                 } else if (consumes(old, current)) {\r
+                    //\r
+                    // if current library instance is consumed by the one in orderList\r
+                    // it must be put before. And no further check is needed.\r
+                    // \r
                     insertPoint = j;\r
                     break;\r
                 }\r
             }\r
             orderList.add(insertPoint, current);\r
                     insertPoint = j;\r
                     break;\r
                 }\r
             }\r
             orderList.add(insertPoint, current);\r
-//             System.out.println("################################################");\r
-//             for (int ii = 0; ii < orderList.size(); ++ii) {\r
-//                 System.out.println("  " + orderList.get(ii));\r
-//             }\r
         }\r
 \r
         return orderList;\r
     }\r
 \r
         }\r
 \r
         return orderList;\r
     }\r
 \r
-    boolean consumes(ModuleIdentification lib1, ModuleIdentification lib2) {\r
-        //System.out.println("$$$ lib1 = " + lib1);\r
+    //\r
+    // Test if one library consumes another library\r
+    // \r
+    private boolean consumes(ModuleIdentification lib1, ModuleIdentification lib2) {\r
         LinkedList<ModuleIdentification> stack = new LinkedList<ModuleIdentification>();\r
         LinkedList<ModuleIdentification> stack = new LinkedList<ModuleIdentification>();\r
+\r
         stack.add(lib1);\r
         int j = 0;\r
         while (j < stack.size()) {\r
         stack.add(lib1);\r
         int j = 0;\r
         while (j < stack.size()) {\r
+            //\r
+            // get the last library instance in stack, which hasn't been checked\r
+            // \r
             ModuleIdentification lib = stack.get(j++);\r
             ModuleIdentification lib = stack.get(j++);\r
+            //\r
+            // get the library classes consumed by it\r
+            // \r
             String[] consumedClasses = libInstanceMap.get(lib);\r
             for (int i = 0; i < consumedClasses.length; ++i) {\r
             String[] consumedClasses = libInstanceMap.get(lib);\r
             for (int i = 0; i < consumedClasses.length; ++i) {\r
+                //\r
+                // for each library class, find its corresponding library instance\r
+                // \r
                 ModuleIdentification consumedLib = libClassMap.get(consumedClasses[i]);\r
                 ModuleIdentification consumedLib = libClassMap.get(consumedClasses[i]);\r
-                //System.out.println("$$$ class = " + consumedClasses[i]);\r
-                //System.out.println("$$$ insta = " + consumedLib);\r
+                //\r
+                // if the corresponding instance is the "lib2", we can say that\r
+                // "lib1"  consumes "lib2"\r
+                // \r
                 if (consumedLib == lib2) {\r
                 if (consumedLib == lib2) {\r
-                    //System.out.println(lib1 + "\n   consumes\n" + lib2 + "\n");\r
+                    EdkLog.log(EdkLog.EDK_DEBUG, lib1 + "\n   consumes\n" + lib2 + "\n");\r
                     return true;\r
                 }\r
                     return true;\r
                 }\r
+                //\r
+                // otherwise, we put it back into the stack to check it later\r
+                // to see if it consumes "lib2" or not. If the library instance\r
+                // consumed by "lib1" consumes "lib2", we can also say that "lib1"\r
+                // consumes "lib2"\r
+                // \r
                 if (consumedLib != null && !stack.contains(consumedLib)) {\r
                     stack.offer(consumedLib);\r
                 if (consumedLib != null && !stack.contains(consumedLib)) {\r
                     stack.offer(consumedLib);\r
+                } else if (consumedLib == lib1) {\r
+                    //\r
+                    // found circular consume, do nothing now but just print\r
+                    // out message for debugging\r
+                    // \r
+                    String msg = "!!! Library consumes circularly: ";\r
+                    for (int k = 0; k < j; k++) {\r
+                        msg += stack.get(k).getName() + "->";\r
+                    }\r
+                    msg += lib1.getName();\r
+                    EdkLog.log(EdkLog.EDK_DEBUG, msg);\r
                 }\r
             }\r
         }\r
                 }\r
             }\r
         }\r
index e28ac19eca828986a16440a12ab11ccd82d81b4a..325dc437b673154290160a574a6cef8fc059bf14 100644 (file)
@@ -75,6 +75,11 @@ import org.w3c.dom.NodeList;
 **/\r
 public class FpdParserTask extends Task {\r
 \r
 **/\r
 public class FpdParserTask extends Task {\r
 \r
+    ///\r
+    /// Be used to ensure Global data will be initialized only once.\r
+    ///\r
+    private static boolean parsed = false;\r
+\r
     private File fpdFile = null;\r
 \r
     PlatformIdentification platformId;\r
     private File fpdFile = null;\r
 \r
     PlatformIdentification platformId;\r
@@ -494,8 +499,10 @@ public class FpdParserTask extends Task {
             //\r
             // Pcd Collection. Call CollectPCDAction to collect pcd info.\r
             //\r
             //\r
             // Pcd Collection. Call CollectPCDAction to collect pcd info.\r
             //\r
-            PlatformPcdPreprocessActionForBuilding ca = new PlatformPcdPreprocessActionForBuilding();\r
-            ca.perform(platformId.getFpdFile().getPath());\r
+            if (!parsed) {\r
+                PlatformPcdPreprocessActionForBuilding ca = new PlatformPcdPreprocessActionForBuilding();\r
+                ca.perform(platformId.getFpdFile().getPath());\r
+            }\r
         } catch (IOException ex) {\r
             BuildException buildException = new BuildException("Parsing of the FPD file [" + fpdFile.getPath() + "] failed!\n" + ex.getMessage());\r
             buildException.setStackTrace(ex.getStackTrace());\r
         } catch (IOException ex) {\r
             BuildException buildException = new BuildException("Parsing of the FPD file [" + fpdFile.getPath() + "] failed!\n" + ex.getMessage());\r
             buildException.setStackTrace(ex.getStackTrace());\r
@@ -509,6 +516,9 @@ public class FpdParserTask extends Task {
             buildException.setStackTrace(ex.getStackTrace());\r
             throw buildException;\r
         }\r
             buildException.setStackTrace(ex.getStackTrace());\r
             throw buildException;\r
         }\r
+        if (!parsed) {\r
+            parsed = true;\r
+        }\r
     }\r
 \r
     /**\r
     }\r
 \r
     /**\r