]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Java/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java
- Move global declarations from AutoGen.c to AutoGen.h
[mirror_edk2.git] / Tools / Java / Source / GenBuild / org / tianocore / build / autogen / AutoGen.java
index ce6ff6184221a37cb793dd21b9eee2feb51234c0..2d9178cfdf7aa5e68316e2c4b554dffad812a13a 100644 (file)
@@ -120,6 +120,7 @@ public class AutoGen {
     private List<String> exitBootServiceList = new ArrayList<String>();\r
 \r
     private StringBuffer functionDeclarations = new StringBuffer(10240);\r
+    private StringBuffer globalDeclarations = new StringBuffer(10240);\r
 \r
     //\r
     // flag of PcdComponentNameDisable, PcdDriverDiagnosticDisable \r
@@ -384,6 +385,7 @@ public class AutoGen {
             fileBuffer.append(this.myPcdAutogen.getHAutoGenString());\r
         }\r
 \r
+        fileBuffer.append(globalDeclarations);\r
         fileBuffer.append(functionDeclarations);\r
         //\r
         // Append the #endif at AutoGen.h\r
@@ -673,10 +675,6 @@ public class AutoGen {
             fileBuffer.append(ToolDefinitions.LINE_SEPARATOR);\r
             fileBuffer.append(this.myPcdAutogen.getCAutoGenString());\r
         }\r
-\r
-        if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) {\r
-            throw new AutoGenException("Failed to generate AutoGen.c !!!");\r
-        }\r
     }\r
 \r
     /**\r
@@ -788,13 +786,13 @@ public class AutoGen {
             if (entryPointList == null ||entryPointList.length != 1 ) {\r
                 throw new AutoGenException("Module type = 'PEI_CORE', can have only one module entry point!");\r
             } else {\r
-                fileBuffer.append("EFI_STATUS\r\n");\r
-                fileBuffer.append("EFIAPI\r\n");\r
-                fileBuffer.append(entryPointList[0]);\r
-                fileBuffer.append(" (\r\n");\r
-                fileBuffer.append("  IN EFI_PEI_STARTUP_DESCRIPTOR  *PeiStartupDescriptor,\r\n");\r
-                fileBuffer.append("  IN VOID                        *OldCoreData\r\n");\r
-                fileBuffer.append("  );\r\n\r\n");\r
+                functionDeclarations.append("EFI_STATUS\r\n");\r
+                functionDeclarations.append("EFIAPI\r\n");\r
+                functionDeclarations.append(entryPointList[0]);\r
+                functionDeclarations.append(" (\r\n");\r
+                functionDeclarations.append("  IN EFI_PEI_STARTUP_DESCRIPTOR  *PeiStartupDescriptor,\r\n");\r
+                functionDeclarations.append("  IN VOID                        *OldCoreData\r\n");\r
+                functionDeclarations.append("  );\r\n\r\n");\r
 \r
                 fileBuffer.append("EFI_STATUS\r\n");\r
                 fileBuffer.append("EFIAPI\r\n");\r
@@ -815,12 +813,12 @@ public class AutoGen {
             if (entryPointList == null || entryPointList.length != 1) {\r
                 throw new AutoGenException("Module type = 'DXE_CORE', can have only one module entry point!");\r
             } else {\r
-                fileBuffer.append("VOID\r\n");\r
-                fileBuffer.append("EFIAPI\r\n");\r
-                fileBuffer.append(entryPointList[0]);\r
-                fileBuffer.append(" (\r\n");\r
-                fileBuffer.append("  IN VOID  *HobStart\r\n");\r
-                fileBuffer.append("  );\r\n\r\n");\r
+                functionDeclarations.append("VOID\r\n");\r
+                functionDeclarations.append("EFIAPI\r\n");\r
+                functionDeclarations.append(entryPointList[0]);\r
+                functionDeclarations.append(" (\r\n");\r
+                functionDeclarations.append("  IN VOID  *HobStart\r\n");\r
+                functionDeclarations.append("  );\r\n\r\n");\r
 \r
                 fileBuffer.append("VOID\r\n");\r
                 fileBuffer.append("EFIAPI\r\n");\r
@@ -851,13 +849,13 @@ public class AutoGen {
                 break;\r
             }\r
             for (int i = 0; i < entryPointList.length; i++) {\r
-                fileBuffer.append("EFI_STATUS\r\n");\r
-                fileBuffer.append("EFIAPI\r\n");\r
-                fileBuffer.append(entryPointList[i]);\r
-                fileBuffer.append(" (\r\n");\r
-                fileBuffer.append("  IN EFI_FFS_FILE_HEADER  *FfsHeader,\r\n");\r
-                fileBuffer.append("  IN EFI_PEI_SERVICES     **PeiServices\r\n");\r
-                fileBuffer.append("  );\r\n");\r
+                functionDeclarations.append("EFI_STATUS\r\n");\r
+                functionDeclarations.append("EFIAPI\r\n");\r
+                functionDeclarations.append(entryPointList[i]);\r
+                functionDeclarations.append(" (\r\n");\r
+                functionDeclarations.append("  IN EFI_FFS_FILE_HEADER  *FfsHeader,\r\n");\r
+                functionDeclarations.append("  IN EFI_PEI_SERVICES     **PeiServices\r\n");\r
+                functionDeclarations.append("  );\r\n");\r
                 entryPointCount++;\r
             }\r
 \r
@@ -917,13 +915,13 @@ public class AutoGen {
 \r
             } else {\r
                 for (int i = 0; i < entryPointList.length; i++) {\r
-                    fileBuffer.append("EFI_STATUS\r\n");\r
-                    fileBuffer.append("EFIAPI\r\n");\r
-                    fileBuffer.append(entryPointList[i]);\r
-                    fileBuffer.append(" (\r\n");\r
-                    fileBuffer.append("  IN EFI_HANDLE        ImageHandle,\r\n");\r
-                    fileBuffer.append("  IN EFI_SYSTEM_TABLE  *SystemTable\r\n");\r
-                    fileBuffer.append("  );\r\n");\r
+                    functionDeclarations.append("EFI_STATUS\r\n");\r
+                    functionDeclarations.append("EFIAPI\r\n");\r
+                    functionDeclarations.append(entryPointList[i]);\r
+                    functionDeclarations.append(" (\r\n");\r
+                    functionDeclarations.append("  IN EFI_HANDLE        ImageHandle,\r\n");\r
+                    functionDeclarations.append("  IN EFI_SYSTEM_TABLE  *SystemTable\r\n");\r
+                    functionDeclarations.append("  );\r\n");\r
                     entryPointCount++;\r
                 }\r
                 fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED  const UINT8  _gDriverEntryPointCount = ");\r
@@ -974,11 +972,11 @@ public class AutoGen {
             unloadImageCount = 0;\r
             if (unloadImageList != null) {\r
                 for (int i = 0; i < unloadImageList.length; i++) {\r
-                    fileBuffer.append("EFI_STATUS\r\n");\r
-                    fileBuffer.append(unloadImageList[i]);\r
-                    fileBuffer.append(" (\r\n");\r
-                    fileBuffer.append("  IN EFI_HANDLE        ImageHandle\r\n");\r
-                    fileBuffer.append("  );\r\n");\r
+                    functionDeclarations.append("EFI_STATUS\r\n");\r
+                    functionDeclarations.append(unloadImageList[i]);\r
+                    functionDeclarations.append(" (\r\n");\r
+                    functionDeclarations.append("  IN EFI_HANDLE        ImageHandle\r\n");\r
+                    functionDeclarations.append("  );\r\n");\r
                     unloadImageCount++;\r
                 }\r
             }\r
@@ -1049,13 +1047,13 @@ public class AutoGen {
 \r
             } else {\r
                 for (int i = 0; i < entryPointList.length; i++) {\r
-                    fileBuffer.append("EFI_STATUS\r\n");\r
-                    fileBuffer.append("EFIAPI\r\n");\r
-                    fileBuffer.append(entryPointList[i]);\r
-                    fileBuffer.append(" (\r\n");\r
-                    fileBuffer.append("  IN EFI_HANDLE        ImageHandle,\r\n");\r
-                    fileBuffer.append("  IN EFI_SYSTEM_TABLE  *SystemTable\r\n");\r
-                    fileBuffer.append("  );\r\n");\r
+                    functionDeclarations.append("EFI_STATUS\r\n");\r
+                    functionDeclarations.append("EFIAPI\r\n");\r
+                    functionDeclarations.append(entryPointList[i]);\r
+                    functionDeclarations.append(" (\r\n");\r
+                    functionDeclarations.append("  IN EFI_HANDLE        ImageHandle,\r\n");\r
+                    functionDeclarations.append("  IN EFI_SYSTEM_TABLE  *SystemTable\r\n");\r
+                    functionDeclarations.append("  );\r\n");\r
                     entryPointCount++;\r
                 }\r
 \r
@@ -1133,12 +1131,12 @@ public class AutoGen {
             unloadImageCount = 0;\r
             if (unloadImageList != null) {\r
                 for (int i = 0; i < unloadImageList.length; i++) {\r
-                    fileBuffer.append("EFI_STATUS\r\n");\r
-                    fileBuffer.append("EFIAPI\r\n");\r
-                    fileBuffer.append(unloadImageList[i]);\r
-                    fileBuffer.append(" (\r\n");\r
-                    fileBuffer.append("  IN EFI_HANDLE        ImageHandle\r\n");\r
-                    fileBuffer.append("  );\r\n");\r
+                    functionDeclarations.append("EFI_STATUS\r\n");\r
+                    functionDeclarations.append("EFIAPI\r\n");\r
+                    functionDeclarations.append(unloadImageList[i]);\r
+                    functionDeclarations.append(" (\r\n");\r
+                    functionDeclarations.append("  IN EFI_HANDLE        ImageHandle\r\n");\r
+                    functionDeclarations.append("  );\r\n");\r
                     unloadImageCount++;\r
                 }\r
             }\r
@@ -1802,9 +1800,9 @@ public class AutoGen {
         //\r
         for (int i = 0; i < driverBindingGroup.length; i++) {\r
             if (driverBindingGroup[i][0] != null) {\r
-                fileBuffer.append("extern EFI_DRIVER_BINDING_PROTOCOL ");\r
-                fileBuffer.append(driverBindingGroup[i][0]);\r
-                fileBuffer.append(";\r\n");\r
+                globalDeclarations.append("extern EFI_DRIVER_BINDING_PROTOCOL ");\r
+                globalDeclarations.append(driverBindingGroup[i][0]);\r
+                globalDeclarations.append(";\r\n");\r
             }\r
         }\r
 \r
@@ -1816,9 +1814,9 @@ public class AutoGen {
                 if (driverBindingGroup[i][1]!= null) {\r
                     if (driverBindingGroup[i][0] != null) {\r
                         BitMask |= 0x01;\r
-                        fileBuffer.append("extern EFI_COMPONENT_NAME_PROTOCOL ");\r
-                        fileBuffer.append(driverBindingGroup[i][1]);\r
-                        fileBuffer.append(";\r\n");\r
+                        globalDeclarations.append("extern EFI_COMPONENT_NAME_PROTOCOL ");\r
+                        globalDeclarations.append(driverBindingGroup[i][1]);\r
+                        globalDeclarations.append(";\r\n");\r
                     } else {\r
                         throw new AutoGenException("DriverBinding can't be empty!!");\r
                     }\r
@@ -1833,9 +1831,9 @@ public class AutoGen {
             if (driverBindingGroup[i][2] != null) {\r
                 if (driverBindingGroup[i][0] != null) {\r
                     BitMask |= 0x02;\r
-                    fileBuffer.append("extern EFI_DRIVER_CONFIGURATION_PROTOCOL ");\r
-                    fileBuffer.append(driverBindingGroup[i][2]);\r
-                    fileBuffer.append(";\r\n");\r
+                    globalDeclarations.append("extern EFI_DRIVER_CONFIGURATION_PROTOCOL ");\r
+                    globalDeclarations.append(driverBindingGroup[i][2]);\r
+                    globalDeclarations.append(";\r\n");\r
                 } else {\r
                     throw new AutoGenException("DriverBinding can't be empty!!");\r
                 }\r
@@ -1850,9 +1848,9 @@ public class AutoGen {
                 if (driverBindingGroup[i][3] != null) {\r
                     if (driverBindingGroup[i][0] != null) {\r
                         BitMask |= 0x04;\r
-                        fileBuffer.append("extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL ");\r
-                        fileBuffer.append(driverBindingGroup[i][3]);\r
-                        fileBuffer.append(";\r\n");\r
+                        globalDeclarations.append("extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL ");\r
+                        globalDeclarations.append(driverBindingGroup[i][3]);\r
+                        globalDeclarations.append(";\r\n");\r
                     } else {\r
                         throw new AutoGenException("DriverBinding can't be empty!!");\r
                     }\r