import java.util.regex.Matcher;\r
import java.util.regex.Pattern;\r
\r
+import org.tianocore.build.autogen.CommonDefinition;\r
+import org.tianocore.build.exception.PcdAutogenException;\r
import org.tianocore.build.global.GlobalData;\r
import org.tianocore.build.id.ModuleIdentification;\r
+import org.tianocore.pcd.action.ActionMessage;\r
+import org.tianocore.pcd.action.BuildAction;\r
import org.tianocore.pcd.entity.MemoryDatabaseManager;\r
import org.tianocore.pcd.entity.Token;\r
+import org.tianocore.pcd.entity.UsageIdentification;\r
import org.tianocore.pcd.entity.UsageInstance;\r
import org.tianocore.pcd.exception.BuildActionException;\r
-import org.tianocore.pcd.entity.UsageIdentification;\r
-import org.tianocore.pcd.action.BuildAction;\r
-import org.tianocore.pcd.action.ActionMessage;\r
-import org.tianocore.build.exception.PcdAutogenException;\r
\r
-/** This class is to manage how to generate the PCD information into Autogen.c and\r
- Autogen.h.\r
+/**\r
+ This class is to manage how to generate the PCD information into Autogen.c\r
+ and Autogen.h.\r
**/\r
public class PCDAutoGenAction extends BuildAction {\r
///\r
///\r
private boolean isBuildUsedLibrary;\r
\r
+ ///\r
+ /// One of PEI_PCD_DRIVER, DXE_PCD_DRIVER, NOT_PCD_DRIVER \r
+ /// \r
+ private CommonDefinition.PCD_DRIVER_TYPE pcdDriverType;\r
+\r
///\r
/// The generated string for header file.\r
///\r
this.usageId = usageId;\r
}\r
\r
+ /**\r
+ Set paramter pcdDriverType\r
+ \r
+ @param pcdDriverType the driver type for PCD\r
+ **/\r
+ public void setPcdDriverType(CommonDefinition.PCD_DRIVER_TYPE pcdDriverType) {\r
+ this.pcdDriverType = pcdDriverType;\r
+ }\r
/**\r
set isBuildUsedLibrary parameter.\r
\r
\r
@return the string of header file for PCD\r
**/\r
- public String OutputH() {\r
+ public String getHAutoGenString() {\r
return hAutoGenString;\r
}\r
\r
\r
@return the string of C code file for PCD\r
**/\r
- public String OutputC() {\r
+ public String getCAutoGenString() {\r
return cAutoGenString;\r
}\r
\r
@param arch the architecture for module\r
@param isBuildUsedLibary Is the current module library.\r
@param pcdNameArrayInMsa the pcd name array got from MSA file.\r
+ @param pcdDriverType one of PEI_PCD_DRIVER, DXE_PCD_DRIVER,\r
+ NOT_PCD_DRIVER\r
**/\r
public PCDAutoGenAction(ModuleIdentification moduleId,\r
String arch,\r
boolean isBuildUsedLibrary,\r
- String[] pcdNameArrayInMsa) {\r
+ String[] pcdNameArrayInMsa,\r
+ CommonDefinition.PCD_DRIVER_TYPE pcdDriverType) {\r
dbManager = null;\r
hAutoGenString = "";\r
cAutoGenString = "";\r
moduleId.getModuleType()));\r
setIsBuildUsedLibrary(isBuildUsedLibrary);\r
setPcdNameArrayInMsa(pcdNameArrayInMsa);\r
+ setPcdDriverType(pcdDriverType);\r
}\r
\r
/**\r
}\r
\r
ActionMessage.debug(this,\r
- "PCD memory database contains " + dbManager.getDBSize() + " PCD tokens");\r
+ "PCD memory database contains " + dbManager.getDBSize() + " PCD tokens.");\r
\r
generateAutogenForModule();\r
}\r
// All library's PCD should instanted in module's <ModuleSA> who\r
// use this library instance. If not, give errors.\r
//\r
- throw new BuildActionException (String.format("Module %s use library instance %s, the PCD %s " +\r
- "is required by this library instance, but can not find " +\r
- "it in the %s's <ModuleSA> in FPD file!",\r
+ throw new BuildActionException (String.format("Module %s using library instance %s; the PCD %s " +\r
+ "is required by this library instance, but can not be found " +\r
+ "in the %s's <ModuleSA> in the FPD file!",\r
MemoryDatabaseManager.CurrentModuleName,\r
moduleName,\r
pcdNameArrayInMsa[index],\r
cAutoGenString += usageInstance.getCAutogenStr();\r
}\r
\r
- //\r
- // Work around code, In furture following code should be modified that get\r
- // these information from Uplevel Autogen tools.\r
- //\r
- if (moduleName.equalsIgnoreCase("PcdPeim")) {\r
+ if (pcdDriverType == CommonDefinition.PCD_DRIVER_TYPE.PEI_PCD_DRIVER) {\r
hAutoGenString += MemoryDatabaseManager.PcdPeimHString;\r
cAutoGenString += MemoryDatabaseManager.PcdPeimCString;\r
- } else if (moduleName.equalsIgnoreCase("PcdDxe")) {\r
+ } else if (pcdDriverType == CommonDefinition.PCD_DRIVER_TYPE.DXE_PCD_DRIVER) {\r
hAutoGenString += MemoryDatabaseManager.PcdDxeHString;\r
cAutoGenString += MemoryDatabaseManager.PcdDxeCString;\r
}\r
}\r
-\r
- /**\r
- Test case function\r
-\r
- @param argv paramter from command line\r
- **/\r
- public static void main(String argv[]) {\r
-\r
- String WorkSpace = "X:/edk2";\r
- String logFilePath = WorkSpace + "/EdkNt32Pkg/Nt32.fpd";\r
-\r
- //\r
- // At first, CollectPCDAction should be invoked to collect\r
- // all PCD information from SPD, MSA, FPD.\r
- //\r
- PlatformPcdPreprocessActionForBuilding collectionAction = new PlatformPcdPreprocessActionForBuilding();\r
- GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db",\r
- WorkSpace,null);\r
-\r
- try {\r
- collectionAction.perform(logFilePath, ActionMessage.MAX_MESSAGE_LEVEL);\r
- } catch(Exception e) {\r
- e.printStackTrace();\r
- }\r
- }\r
}\r