]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java
moved exception and logger classes to org.tianocore.common package
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / autogen / AutoGen.java
index 0704bf44119b1bec734773634e8d9b1f923f1037..c3d371e33991dd9caa4e37f7209bc06d26913aef 100644 (file)
@@ -3,13 +3,13 @@
 \r
  This class is to generate Autogen.h and Autogen.c according to module surface area\r
  or library surface area.\r
\r
+\r
  Copyright (c) 2006, Intel Corporation\r
  All rights reserved. This program and the accompanying materials\r
  are licensed and made available under the terms and conditions of the BSD License\r
  which accompanies this distribution.  The full text of the license may be found at\r
  http://opensource.org/licenses/bsd-license.php\r
\r
+\r
  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
@@ -44,7 +44,8 @@ import org.tianocore.build.global.SurfaceAreaQuery;
 import org.tianocore.build.id.ModuleIdentification;\r
 import org.tianocore.build.id.PackageIdentification;\r
 import org.tianocore.build.pcd.action.PCDAutoGenAction;\r
-import org.tianocore.logger.EdkLog;\r
+\r
+import org.tianocore.common.logger.EdkLog;\r
 \r
 /**\r
  * This class is to generate Autogen.h and Autogen.c according to module surface\r
@@ -55,9 +56,9 @@ public class AutoGen {
        // / The output path of Autogen.h and Autogen.c\r
        // /\r
        private String outputPath;\r
-    /// \r
-    /// The name of FV directory \r
-    /// \r
+    ///\r
+    /// The name of FV directory\r
+    ///\r
     private String fvDir;\r
        // /\r
        // / The base name of module or library.\r
@@ -92,7 +93,7 @@ public class AutoGen {
        // / dependence on library instance surface area.\r
        // /\r
        private Set<String> mGuidList = new HashSet<String>();\r
-    \r
+\r
     //\r
     // The dependence package list which recoreded in module or library surface\r
     // area and it's dependence on library instance surface are.\r
@@ -100,24 +101,24 @@ public class AutoGen {
     private List<PackageIdentification> mDepPkgList = new LinkedList<PackageIdentification>();\r
 \r
        //\r
-       //  For non library module, add its library instance's construct and destructor to \r
+       //  For non library module, add its library instance's construct and destructor to\r
        //  list.\r
-       //  \r
+       //\r
        private List<String> libConstructList = new ArrayList<String>();\r
        private List<String> libDestructList = new ArrayList<String>();\r
 \r
        //\r
-       // List to store SetVirtalAddressMapCallBack, ExitBootServiceCallBack  \r
-       // \r
+       // List to store SetVirtalAddressMapCallBack, ExitBootServiceCallBack\r
+       //\r
        private List<String> setVirtalAddList = new ArrayList<String>();\r
        private List<String> exitBootServiceList = new ArrayList<String>();\r
 \r
-       \r
+\r
        /**\r
         * Construct function\r
-        * \r
+        *\r
         * This function mainly initialize some member variable.\r
-        * \r
+        *\r
         * @param outputPath\r
         *            Output path of AutoGen file.\r
         * @param baseName\r
@@ -135,9 +136,9 @@ public class AutoGen {
 \r
        /**\r
         * saveFile function\r
-        * \r
+        *\r
         * This function save the content in stringBuffer to file.\r
-        * \r
+        *\r
         * @param fileName\r
         *            The name of file.\r
         * @param fileBuffer\r
@@ -176,10 +177,10 @@ public class AutoGen {
 \r
        /**\r
         * genAutogen function\r
-        * \r
+        *\r
         * This function call libGenAutoGen or moduleGenAutogen function, which\r
         * dependence on generate library autogen or module autogen.\r
-        * \r
+        *\r
         * @throws BuildException\r
         *             Failed to creat AutoGen.c & AutoGen.h.\r
         */\r
@@ -210,9 +211,9 @@ public class AutoGen {
 \r
        /**\r
         * moduleGenAutogen function\r
-        * \r
+        *\r
         * This function generates AutoGen.c & AutoGen.h for module.\r
-        * \r
+        *\r
         * @throws BuildException\r
         *             Faile to create module AutoGen.c & AutoGen.h.\r
         */\r
@@ -231,9 +232,9 @@ public class AutoGen {
 \r
        /**\r
         * libGenAutogen function\r
-        * \r
+        *\r
         * This function generates AutoGen.c & AutoGen.h for library.\r
-        * \r
+        *\r
         * @throws BuildException\r
         *             Faile to create library AutoGen.c & AutoGen.h\r
         */\r
@@ -250,9 +251,9 @@ public class AutoGen {
 \r
        /**\r
         * moduleGenAutogenH\r
-        * \r
+        *\r
         * This function generates AutoGen.h for module.\r
-        * \r
+        *\r
         * @throws BuildException\r
         *             Failed to generate AutoGen.h.\r
         */\r
@@ -340,9 +341,9 @@ public class AutoGen {
                fileBuffer.append("\r\n");\r
 \r
         //\r
-        //  If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to \r
+        //  If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to\r
         // {DEST_DIR_DRBUG}/FlashMap.h\r
-        // \r
+        //\r
         if (SurfaceAreaQuery.isHaveTianoR8FlashMap()) {\r
             fileBuffer.append(CommonDefinition.include);\r
             fileBuffer.append("  <");\r
@@ -372,9 +373,9 @@ public class AutoGen {
 \r
        /**\r
         * moduleGenAutogenC\r
-        * \r
+        *\r
         * This function generates AutoGen.c for module.\r
-        * \r
+        *\r
         * @throws BuildException\r
         *             Failed to generate AutoGen.c.\r
         */\r
@@ -452,7 +453,7 @@ public class AutoGen {
                // autogen.c\r
                //\r
         LibInstanceToAutogenC(fileBuffer);\r
-        \r
+\r
         //\r
         // Get module dependent Package identification.\r
         //\r
@@ -461,9 +462,9 @@ public class AutoGen {
             if (!this.mDepPkgList.contains(packages[i])){\r
                 this.mDepPkgList.add(packages[i]);\r
             }\r
-            \r
+\r
         }\r
-      \r
+\r
                //\r
                // Write consumed ppi, guid, protocol to autogen.c\r
                //\r
@@ -472,7 +473,7 @@ public class AutoGen {
                GuidGuidToAutogenC(fileBuffer);\r
 \r
                //\r
-               // Call pcd autogen. \r
+               // Call pcd autogen.\r
                //\r
                 this.myPcdAutogen = new PCDAutoGenAction(moduleId, this.arch, false, null);\r
                 try {\r
@@ -480,7 +481,7 @@ public class AutoGen {
                 } catch (Exception exp) {\r
                     throw new PcdAutogenException (exp.getMessage());\r
                 }\r
-               \r
+\r
                if (this.myPcdAutogen != null) {\r
                     fileBuffer.append("\r\n");\r
                     fileBuffer.append(this.myPcdAutogen.OutputC());\r
@@ -494,9 +495,9 @@ public class AutoGen {
 \r
        /**\r
         * libGenAutogenH\r
-        * \r
+        *\r
         * This function generates AutoGen.h for library.\r
-        * \r
+        *\r
         * @throws BuildException\r
         *             Failed to generate AutoGen.c.\r
         */\r
@@ -537,7 +538,7 @@ public class AutoGen {
 \r
                //\r
                // Write consumed package's mdouleInfo related *.h file to autogen.h.\r
-               // \r
+               //\r
                moduleType = SurfaceAreaQuery.getModuleType();\r
                PackageIdentification[] cosumedPkglist = SurfaceAreaQuery\r
                                .getDependencePkg(this.arch);\r
@@ -571,9 +572,9 @@ public class AutoGen {
                fileBuffer.append("\r\n");\r
 \r
         //\r
-        //  If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to \r
+        //  If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to\r
         // {DEST_DIR_DRBUG}/FlashMap.h\r
-        // \r
+        //\r
         if (SurfaceAreaQuery.isHaveTianoR8FlashMap()) {\r
             fileBuffer.append(CommonDefinition.include);\r
             fileBuffer.append("  <");\r
@@ -604,9 +605,9 @@ public class AutoGen {
 \r
        /**\r
         * libGenAutogenC\r
-        * \r
+        *\r
         * This function generates AutoGen.h for library.\r
-        * \r
+        *\r
         * @throws BuildException\r
         *             Failed to generate AutoGen.c.\r
         */\r
@@ -622,11 +623,11 @@ public class AutoGen {
                fileBuffer.append("\r\n");\r
 \r
                //\r
-               // Call pcd autogen. \r
+               // Call pcd autogen.\r
                //\r
                 this.myPcdAutogen = new PCDAutoGenAction(this.moduleId,\r
                                                          this.arch,\r
-                                                         true, \r
+                                                         true,\r
                                                          SurfaceAreaQuery.getModulePcdEntryNameArray());\r
                try {\r
                     this.myPcdAutogen.execute();\r
@@ -646,10 +647,10 @@ public class AutoGen {
 \r
        /**\r
         * LibraryClassToAutogenH\r
-        * \r
+        *\r
         * This function returns *.h files declared by library classes which are\r
         * consumed or produced by current build module or library.\r
-        * \r
+        *\r
         * @param libClassList\r
         *            List of library class which consumed or produce by current\r
         *            build module or library.\r
@@ -689,9 +690,9 @@ public class AutoGen {
 \r
        /**\r
         * IncludesToAutogenH\r
-        * \r
+        *\r
         * This function add include file in AutoGen.h file.\r
-        * \r
+        *\r
         * @param packageNameList\r
         *            List of module depended package.\r
         * @param moduleType\r
@@ -727,10 +728,10 @@ public class AutoGen {
 \r
        /**\r
         * EntryPointToAutoGen\r
-        * \r
+        *\r
         * This function convert <ModuleEntryPoint> & <ModuleUnloadImage>\r
         * information in mas to AutoGen.c\r
-        * \r
+        *\r
         * @param entryPointList\r
         *            List of entry point.\r
         * @param fileBuffer\r
@@ -833,7 +834,7 @@ public class AutoGen {
                                                        .append("  IN EFI_PEI_SERVICES     **PeiServices\r\n");\r
                                        fileBuffer.append("  );\r\n");\r
                                        entryPointCount++;\r
-                       \r
+\r
                        }\r
 \r
                        fileBuffer.append("EFI_STATUS\r\n");\r
@@ -918,7 +919,7 @@ public class AutoGen {
                 fileBuffer.append("  )\r\n\r\n");\r
                 fileBuffer.append("{\r\n");\r
 \r
-                \r
+\r
                 for (int i = 0; i < entryPointList.length; i++) {\r
                     fileBuffer\r
                             .append("  if (SetJump (&mJumpContext) == 0) {\r\n");\r
@@ -927,7 +928,7 @@ public class AutoGen {
                     fileBuffer.append(" (ImageHandle, SystemTable));\r\n");\r
                     fileBuffer.append("    ASSERT (FALSE);\r\n");\r
                     fileBuffer.append("  }\r\n");\r
-                \r
+\r
                 }\r
                 fileBuffer.append("  return mDriverEntryPointStatus;\r\n");\r
                 fileBuffer.append("}\r\n\r\n");\r
@@ -945,10 +946,10 @@ public class AutoGen {
                 fileBuffer.append("  LongJump (&mJumpContext, (UINTN)-1);\r\n");\r
                 fileBuffer.append("  ASSERT (FALSE);\r\n");\r
                 fileBuffer.append("}\r\n\r\n");\r
-    \r
+\r
             }\r
-                \r
-                       \r
+\r
+\r
                        //\r
                        // Add "ModuleUnloadImage" for DxeSmmDriver module type;\r
                        //\r
@@ -1034,10 +1035,10 @@ public class AutoGen {
                                fileBuffer.append("{\r\n");\r
                                fileBuffer.append("  return EFI_SUCCESS;\r\n");\r
                                fileBuffer.append("}\r\n");\r
-                               \r
+\r
                        }else {\r
                 for (int i = 0; i < entryPointList.length; i++) {\r
-                    \r
+\r
                     fileBuffer.append("EFI_STATUS\r\n");\r
                     fileBuffer.append("EFIAPI\r\n");\r
                     fileBuffer.append(entryPointList[i]);\r
@@ -1114,7 +1115,7 @@ public class AutoGen {
                 fileBuffer.append("}\r\n\r\n");\r
 \r
             }\r
-                       \r
+\r
                        //\r
                        // Add ModuleUnloadImage for DxeDriver and UefiDriver module type.\r
                        //\r
@@ -1184,10 +1185,10 @@ public class AutoGen {
 \r
        /**\r
         * PpiGuidToAutogenc\r
-        * \r
+        *\r
         * This function gets GUIDs from SPD file accrodeing to <PPIs> information\r
         * and write those GUIDs to AutoGen.c.\r
-        * \r
+        *\r
         * @param fileBuffer\r
         *            String Buffer for Autogen.c file.\r
         * @throws BuildException\r
@@ -1200,7 +1201,7 @@ public class AutoGen {
                // Get the all PPI adn PPI Notify from MSA file,\r
                // then add those PPI ,and PPI Notify name to list.\r
                //\r
-               \r
+\r
                String[] ppiList = SurfaceAreaQuery.getPpiArray(this.arch);\r
                for (int i = 0; i < ppiList.length; i++) {\r
                        this.mPpiList.add(ppiList[i]);\r
@@ -1238,10 +1239,10 @@ public class AutoGen {
 \r
        /**\r
         * ProtocolGuidToAutogenc\r
-        * \r
+        *\r
         * This function gets GUIDs from SPD file accrodeing to <Protocol>\r
         * information and write those GUIDs to AutoGen.c.\r
-        * \r
+        *\r
         * @param fileBuffer\r
         *            String Buffer for Autogen.c file.\r
         * @throws BuildException\r
@@ -1271,8 +1272,8 @@ public class AutoGen {
                //\r
                Iterator protocolIterator = this.mProtocolList.iterator();\r
                String protocolKeyWord = null;\r
-               \r
-      \r
+\r
+\r
                while (protocolIterator.hasNext()) {\r
                        protocolKeyWord = protocolIterator.next().toString();\r
                        cNameGuid = GlobalData.getProtocolGuid(this.mDepPkgList, protocolKeyWord);\r
@@ -1295,13 +1296,13 @@ public class AutoGen {
 \r
        /**\r
         * GuidGuidToAutogenc\r
-        * \r
+        *\r
         * This function gets GUIDs from SPD file accrodeing to <Guids> information\r
         * and write those GUIDs to AutoGen.c.\r
-        * \r
+        *\r
         * @param fileBuffer\r
         *            String Buffer for Autogen.c file.\r
-        * \r
+        *\r
         */\r
        void GuidGuidToAutogenC(StringBuffer fileBuffer) throws AutoGenException {\r
                String[] cNameGuid = null;\r
@@ -1339,11 +1340,11 @@ public class AutoGen {
 \r
        /**\r
         * LibInstanceToAutogenC\r
-        * \r
+        *\r
         * This function adds dependent library instance to autogen.c,which\r
         * includeing library's constructor, destructor, and library dependent ppi,\r
         * protocol, guid, pcd information.\r
-        * \r
+        *\r
         * @param fileBuffer\r
         *            String buffer for AutoGen.c\r
         * @throws BuildException\r
@@ -1367,10 +1368,10 @@ public class AutoGen {
 \r
        /**\r
         * LibConstructorToAutogenc\r
-        * \r
+        *\r
         * This function writes library constructor list to AutoGen.c. The library\r
         * constructor's parameter and return value depend on module type.\r
-        * \r
+        *\r
         * @param libInstanceList\r
         *            List of library construct name.\r
         * @param moduleType\r
@@ -1508,10 +1509,10 @@ public class AutoGen {
 \r
        /**\r
         * LibDestructorToAutogenc\r
-        * \r
+        *\r
         * This function writes library destructor list to AutoGen.c. The library\r
         * destructor's parameter and return value depend on module type.\r
-        * \r
+        *\r
         * @param libInstanceList\r
         *            List of library destructor name.\r
         * @param moduleType\r
@@ -1588,7 +1589,7 @@ public class AutoGen {
             //\r
             // If no library destructor function, return EFI_SUCCESS.\r
             //\r
-            \r
+\r
                        for (int i = 0; i < libInstanceList.size(); i++) {\r
                                if (isFirst) {\r
                                        fileBuffer.append("  EFI_STATUS  Status;\r\n");\r
@@ -1608,10 +1609,10 @@ public class AutoGen {
 \r
        /**\r
         * ExternsDriverBindingToAutoGenC\r
-        * \r
+        *\r
         * This function is to write DRIVER_BINDING, COMPONENT_NAME,\r
         * DRIVER_CONFIGURATION, DRIVER_DIAGNOSTIC in AutoGen.c.\r
-        * \r
+        *\r
         * @param fileBuffer\r
         *            String buffer for AutoGen.c\r
         */\r
@@ -1762,10 +1763,10 @@ public class AutoGen {
 \r
        /**\r
         * ExternCallBackToAutoGenC\r
-        * \r
+        *\r
         * This function adds <SetVirtualAddressMapCallBack> and\r
         * <ExitBootServicesCallBack> infomation to AutoGen.c\r
-        * \r
+        *\r
         * @param fileBuffer\r
         *            String buffer for AutoGen.c\r
         * @throws BuildException\r
@@ -1773,10 +1774,10 @@ public class AutoGen {
        void ExternCallBackToAutoGenC(StringBuffer fileBuffer)\r
                        throws BuildException {\r
                //\r
-               // Collect module's <SetVirtualAddressMapCallBack> and \r
-               // <ExitBootServiceCallBack> and add to setVirtualAddList \r
+               // Collect module's <SetVirtualAddressMapCallBack> and\r
+               // <ExitBootServiceCallBack> and add to setVirtualAddList\r
                //  exitBootServiceList.\r
-               // \r
+               //\r
         String[] setVirtuals = SurfaceAreaQuery.getSetVirtualAddressMapCallBackArray();\r
         String[] exitBoots = SurfaceAreaQuery.getExitBootServicesCallBackArray();\r
         if (setVirtuals != null) {\r
@@ -1791,8 +1792,8 @@ public class AutoGen {
                }\r
                //\r
                //  Add c code in autogen.c which relate to <SetVirtualAddressMapCallBack>\r
-               //  and <ExitBootServicesCallBack> \r
-               // \r
+               //  and <ExitBootServicesCallBack>\r
+               //\r
                String moduleType = this.moduleId.getModuleType();\r
                boolean UefiOrDxeModule = false;\r
                int Count = 0;\r
@@ -1879,8 +1880,8 @@ public class AutoGen {
                        }\r
                        //\r
                        //  If module is not DXE_DRIVER, DXE_RUNTIME_DIRVER, UEFI_DRIVER\r
-                       //  UEFI_APPLICATION and DXE_SAL_DRIVER add the NULL at the end of \r
-                       //  _gDriverSetVirtualAddressMapEvent list. \r
+                       //  UEFI_APPLICATION and DXE_SAL_DRIVER add the NULL at the end of\r
+                       //  _gDriverSetVirtualAddressMapEvent list.\r
                        //\r
                        if (!UefiOrDxeModule) {\r
                                fileBuffer.append(",\r\n  NULL");\r
@@ -1966,15 +1967,15 @@ public class AutoGen {
        }\r
 \r
     private void copyFlashMapHToDebugDir() throws  AutoGenException{\r
-        \r
+\r
         File inFile = new File(fvDir + File.separatorChar + CommonDefinition.flashMapH);\r
         int size = (int)inFile.length();\r
         byte[] buffer = new byte[size];\r
         File outFile = new File (this.outputPath + File.separatorChar + CommonDefinition.tianoR8FlashMapH);\r
                //\r
-               //  If TianoR8FlashMap.h existed and the flashMap.h don't change, \r
+               //  If TianoR8FlashMap.h existed and the flashMap.h don't change,\r
                //  do nothing.\r
-               // \r
+               //\r
         if ((!outFile.exists()) ||(inFile.lastModified() - outFile.lastModified()) >= 0) {\r
                    try{\r
                 if (inFile.exists()) {\r
@@ -1992,7 +1993,7 @@ public class AutoGen {
             }\r
                }\r
     }\r
-    \r
+\r
     /**\r
     *This function first order the library instances, then collect\r
     *library instance 's PPI, Protocol, GUID,\r
@@ -2094,9 +2095,9 @@ public class AutoGen {
                                                                .getLibDestructorName();\r
 \r
                                                //\r
-                                               // Collect SetVirtualAddressMapCallBack and \r
+                                               // Collect SetVirtualAddressMapCallBack and\r
                                                // ExitBootServiceCallBack.\r
-                                               // \r
+                                               //\r
                         setVirtuals = SurfaceAreaQuery.getSetVirtualAddressMapCallBackArray();\r
                         exitBoots = SurfaceAreaQuery.getExitBootServicesCallBackArray();\r
                         if (setVirtuals != null) {\r