- fileBuffer.append(this.myPcdAutogen.OutputH());\r
- }\r
-\r
- //\r
- // Append the #endif at AutoGen.h\r
- //\r
- fileBuffer.append("#endif\r\n");\r
-\r
- //\r
- // Save content of string buffer to AutoGen.h file.\r
- //\r
- if (!saveFile(outputPath + File.separatorChar + "AutoGen.h", fileBuffer)) {\r
- throw new BuildException("Failed to generate AutoGen.h !!!");\r
- }\r
- }\r
-\r
- /**\r
- * libGenAutogenC\r
- *\r
- * This function generates AutoGen.h for library.\r
- *\r
- * @throws BuildException\r
- * Failed to generate AutoGen.c.\r
- */\r
- void libGenAutogenC() throws BuildException, PcdAutogenException {\r
- StringBuffer fileBuffer = new StringBuffer(10240);\r
-\r
- //\r
- // Write Autogen.c header notation\r
- //\r
- fileBuffer.append(CommonDefinition.autogenCNotation);\r
-\r
- fileBuffer.append(CommonDefinition.autoGenCLine1);\r
- fileBuffer.append("\r\n");\r
-\r
- //\r
- // Call pcd autogen.\r
- //\r
- this.myPcdAutogen = new PCDAutoGenAction(this.moduleId,\r
- this.arch,\r
- true,\r
- SurfaceAreaQuery.getModulePcdEntryNameArray());\r
- try {\r
- this.myPcdAutogen.execute();\r
- } catch (Exception e) {\r
- throw new PcdAutogenException(e.getMessage());\r
- }\r
-\r
- if (this.myPcdAutogen != null) {\r
- fileBuffer.append("\r\n");\r
- fileBuffer.append(this.myPcdAutogen.OutputC());\r
- }\r
-\r
- if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) {\r
- throw new BuildException("Failed to generate AutoGen.c !!!");\r
- }\r
- }\r
-\r
- /**\r
- * LibraryClassToAutogenH\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
- * @param libClassList\r
- * List of library class which consumed or produce by current\r
- * build module or library.\r
- * @return includeStrList List of *.h file.\r
- */\r
- Set<String> LibraryClassToAutogenH(String[] libClassList)\r
- throws AutoGenException {\r
- Set<String> includStrList = new LinkedHashSet<String>();\r
- String includerName[];\r
- String str = "";\r
-\r
- //\r
- // Get include file from GlobalData's SPDTable according to\r
- // library class name.\r
- //\r
-\r
- for (int i = 0; i < libClassList.length; i++) {\r
- includerName = GlobalData.getLibraryClassHeaderFiles(\r
- SurfaceAreaQuery.getDependencePkg(this.arch),\r
- libClassList[i]);\r
- if (includerName == null) {\r
- throw new AutoGenException("Can not find library class ["\r
- + libClassList[i] + "] declaration in any SPD package. ");\r
- }\r
- for (int j = 0; j < includerName.length; j++) {\r
- String includeNameStr = includerName[j];\r
- if (includeNameStr != null) {\r
- str = CommonDefinition.include + " " + "<";\r
- str = str + includeNameStr + ">\r\n";\r
- includStrList.add(str);\r
- includeNameStr = null;\r
- }\r
- }\r
- }\r
- return includStrList;\r
- }\r
-\r
- /**\r
- * IncludesToAutogenH\r
- *\r
- * This function add include file in AutoGen.h file.\r
- *\r
- * @param packageNameList\r
- * List of module depended package.\r
- * @param moduleType\r
- * Module type.\r
- * @return\r
- */\r
- List<String> depPkgToAutogenH(PackageIdentification[] packageNameList,\r
- String moduleType) throws AutoGenException {\r
-\r
- List<String> includeStrList = new LinkedList<String>();\r
- String pkgHeader;\r
- String includeStr = "";\r
-\r
- //\r
- // Get include file from moduleInfo file\r
- //\r
- for (int i = 0; i < packageNameList.length; i++) {\r
- pkgHeader = GlobalData.getPackageHeaderFiles(packageNameList[i],\r
- moduleType);\r
- if (pkgHeader == null) {\r
- throw new AutoGenException("Can not find package ["\r
- + packageNameList[i]\r
- + "] declaration in any SPD package. ");\r
- } else if (!pkgHeader.equalsIgnoreCase("")) {\r
- includeStr = CommonDefinition.include + " <" + pkgHeader\r
- + ">\r\n";\r
- includeStrList.add(includeStr);\r
- }\r
- }\r
-\r
- return includeStrList;\r
- }\r
-\r
- /**\r
- * EntryPointToAutoGen\r
- *\r
- * This function convert <ModuleEntryPoint> & <ModuleUnloadImage>\r
- * information in mas to AutoGen.c\r
- *\r
- * @param entryPointList\r
- * List of entry point.\r
- * @param fileBuffer\r
- * String buffer fo AutoGen.c.\r
- * @throws Exception\r
- */\r
- void EntryPointToAutoGen(String[] entryPointList, StringBuffer fileBuffer)\r
- throws BuildException {\r
-\r
- String typeStr = SurfaceAreaQuery.getModuleType();\r
-\r
- //\r
- // The parameters and return value of entryPoint is difference\r
- // for difference module type.\r
- //\r
- switch (CommonDefinition.getModuleType(typeStr)) {\r
-\r
- case CommonDefinition.ModuleTypePeiCore:\r
- if (entryPointList == null ||entryPointList.length != 1 ) {\r
- throw new BuildException(\r
- "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\r
- .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");\r
- fileBuffer\r
- .append(" IN VOID *OldCoreData\r\n");\r
- fileBuffer.append(" );\r\n\r\n");\r
-\r
- fileBuffer.append("EFI_STATUS\r\n");\r
- fileBuffer.append("EFIAPI\r\n");\r
- fileBuffer.append("ProcessModuleEntryPointList (\r\n");\r
- fileBuffer\r
- .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");\r
- fileBuffer\r
- .append(" IN VOID *OldCoreData\r\n");\r
- fileBuffer.append(" )\r\n\r\n");\r
- fileBuffer.append("{\r\n");\r
- fileBuffer.append(" return ");\r
- fileBuffer.append(entryPointList[0]);\r
- fileBuffer.append(" (PeiStartupDescriptor, OldCoreData);\r\n");\r
- fileBuffer.append("}\r\n\r\n");\r
- }\r
- break;\r
-\r
- case CommonDefinition.ModuleTypeDxeCore:\r
- fileBuffer.append("const UINT32 _gUefiDriverRevision = 0;\r\n");\r
- if (entryPointList == null || entryPointList.length != 1) {\r
- throw new BuildException(\r
- "Module type = 'DXE_CORE', can have only one module entry point!");\r
- } else {\r
-\r
- fileBuffer.append("VOID\r\n");\r
- fileBuffer.append("EFIAPI\r\n");\r
- fileBuffer.append(entryPointList[0]);\r
- fileBuffer.append(" (\n");\r
- fileBuffer.append(" IN VOID *HobStart\r\n");\r
- fileBuffer.append(" );\r\n\r\n");\r
-\r
- fileBuffer.append("VOID\r\n");\r
- fileBuffer.append("EFIAPI\r\n");\r
- fileBuffer.append("ProcessModuleEntryPointList (\r\n");\r
- fileBuffer.append(" IN VOID *HobStart\r\n");\r
- fileBuffer.append(" )\r\n\r\n");\r
- fileBuffer.append("{\r\n");\r
- fileBuffer.append(" ");\r
- fileBuffer.append(entryPointList[0]);\r
- fileBuffer.append(" (HobStart);\r\n");\r
- fileBuffer.append("}\r\n\r\n");\r
- }\r
- break;\r
-\r
- case CommonDefinition.ModuleTypePeim:\r
- int entryPointCount = 0;\r
- fileBuffer\r
- .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision = 0;\r\n");\r
- if (entryPointList == null || entryPointList.length == 0) {\r
- fileBuffer.append("EFI_STATUS\r\n");\r
- fileBuffer.append("EFIAPI\r\n");\r
- fileBuffer.append("ProcessModuleEntryPointList (\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\n");\r
- fileBuffer.append("{\r\n");\r
- fileBuffer.append(" return EFI_SUCCESS;\r\n");\r
- fileBuffer.append("}\r\n\r\n");\r
- 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\r
- .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");\r
- fileBuffer\r
- .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");\r
- fileBuffer.append(" );\r\n");\r
- entryPointCount++;\r
-\r
- }\r
-\r
- fileBuffer.append("EFI_STATUS\r\n");\r
- fileBuffer.append("EFIAPI\r\n");\r
- fileBuffer.append("ProcessModuleEntryPointList (\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\n");\r
- fileBuffer.append("{\r\n");\r
- if (entryPointCount == 1) {\r
- fileBuffer.append(" return ");\r
- fileBuffer.append(entryPointList[0]);\r
- fileBuffer.append(" (FfsHeader, PeiServices);\r\n");\r
- } else {\r
- fileBuffer.append(" EFI_STATUS Status;\r\n");\r
- fileBuffer.append(" EFI_STATUS CombinedStatus;\r\n\r\n");\r
- fileBuffer.append(" CombinedStatus = EFI_LOAD_ERROR;\r\n\r\n");\r
- for (int i = 0; i < entryPointList.length; i++) {\r
- if (!entryPointList[i].equals("")) {\r
- fileBuffer.append(" Status = ");\r
- fileBuffer.append(entryPointList[i]);\r
- fileBuffer.append(" (FfsHeader, PeiServices);\r\n");\r
- fileBuffer\r
- .append(" if (!EFI_ERROR (Status) || EFI_ERROR (CombinedStatus)) {\r\n");\r
- fileBuffer.append(" CombinedStatus = Status;\r\n");\r
- fileBuffer.append(" }\r\n\r\n");\r
- } else {\r
- break;\r
- }\r
- }\r
- fileBuffer.append(" return CombinedStatus;\r\n");\r
- }\r
- fileBuffer.append("}\r\n\r\n");\r
- break;\r
-\r
- case CommonDefinition.ModuleTypeDxeSmmDriver:\r
- entryPointCount = 0;\r
- //\r
- // If entryPoint is null, create an empty ProcessModuleEntryPointList\r
- // function.\r
- //\r
- if (entryPointList == null || entryPointList.length == 0){\r
- fileBuffer\r
- .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");\r
- fileBuffer.append(Integer.toString(entryPointCount));\r
- fileBuffer.append(";\r\n");\r
- fileBuffer.append("EFI_STATUS\r\n");\r
- fileBuffer.append("EFIAPI\r\n");\r
- fileBuffer.append("ProcessModuleEntryPointList (\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\n");\r
- fileBuffer.append("{\r\n");\r
- fileBuffer.append(" return EFI_SUCCESS;\r\n");\r
- fileBuffer.append("}\r\n\r\n");\r
-\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
- entryPointCount++;\r
+ fileBuffer.append(this.myPcdAutogen.getHAutoGenString());\r
+ }\r
+\r
+ //\r
+ // Append the #endif at AutoGen.h\r
+ //\r
+ fileBuffer.append("#endif\r\n");\r
+\r
+ //\r
+ // Save content of string buffer to AutoGen.h file.\r
+ //\r
+ if (!saveFile(outputPath + File.separatorChar + "AutoGen.h", fileBuffer)) {\r
+ throw new BuildException("Failed to generate AutoGen.h !!!");\r
+ }\r
+ }\r
+\r
+ /**\r
+ * libGenAutogenC\r
+ *\r
+ * This function generates AutoGen.h for library.\r
+ *\r
+ * @throws BuildException\r
+ * Failed to generate AutoGen.c.\r
+ */\r
+ void libGenAutogenC() throws BuildException, PcdAutogenException {\r
+ StringBuffer fileBuffer = new StringBuffer(10240);\r
+\r
+ //\r
+ // Write Autogen.c header notation\r
+ //\r
+ fileBuffer.append(CommonDefinition.autogenCNotation);\r
+\r
+ fileBuffer.append(CommonDefinition.autoGenCLine1);\r
+ fileBuffer.append("\r\n");\r
+\r
+ //\r
+ // Call pcd autogen.\r
+ //\r
+ this.myPcdAutogen = new PCDAutoGenAction(moduleId,\r
+ arch,\r
+ true,\r
+ SurfaceAreaQuery.getModulePcdEntryNameArray(),\r
+ pcdDriverType);\r
+ try {\r
+ this.myPcdAutogen.execute();\r
+ } catch (Exception e) {\r
+ throw new PcdAutogenException(e.getMessage());\r
+ }\r
+\r
+ if (this.myPcdAutogen != null) {\r
+ fileBuffer.append("\r\n");\r
+ fileBuffer.append(this.myPcdAutogen.getCAutoGenString());\r
+ }\r
+\r
+ if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) {\r
+ throw new BuildException("Failed to generate AutoGen.c !!!");\r
+ }\r
+ }\r
+\r
+ /**\r
+ * LibraryClassToAutogenH\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
+ * @param libClassList\r
+ * List of library class which consumed or produce by current\r
+ * build module or library.\r
+ * @return includeStrList List of *.h file.\r
+ */\r
+ Set<String> LibraryClassToAutogenH(String[] libClassList)\r
+ throws AutoGenException {\r
+ Set<String> includStrList = new LinkedHashSet<String>();\r
+ String includerName[];\r
+ String str = "";\r
+\r
+ //\r
+ // Get include file from GlobalData's SPDTable according to\r
+ // library class name.\r
+ //\r
+\r
+ for (int i = 0; i < libClassList.length; i++) {\r
+ includerName = GlobalData.getLibraryClassHeaderFiles(\r
+ SurfaceAreaQuery.getDependencePkg(this.arch),\r
+ libClassList[i]);\r
+ if (includerName == null) {\r
+ throw new AutoGenException("Can not find library class ["\r
+ + libClassList[i] + "] declaration in any SPD package. ");\r
+ }\r
+ for (int j = 0; j < includerName.length; j++) {\r
+ String includeNameStr = includerName[j];\r
+ if (includeNameStr != null) {\r
+ str = CommonDefinition.include + " " + "<";\r
+ str = str + includeNameStr + ">\r\n";\r
+ includStrList.add(str);\r
+ includeNameStr = null;\r