From 8b7bd4559c54dbfc4ee9b083e047cd3b63fe71aa Mon Sep 17 00:00:00 2001 From: klu2 Date: Fri, 4 Aug 2006 18:22:21 +0000 Subject: [PATCH] 1, Make exception string friendly, readable. 2, Add new PlatformPcdPreprocessBuildException and PlatformPcdPreprocessException for catching PlatformPcdPreprocessAction. 3, Clean up some code for pcd's action package. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1189 6f19259b-4bc3-4df7-8a09-765794883524 --- .../org/tianocore/build/autogen/AutoGen.java | 6 +- .../build/exception/PcdAutogenException.java | 2 +- .../PlatformPcdPreprocessBuildException.java | 36 +++ .../tianocore/build/fpd/FpdParserTask.java | 8 +- .../tianocore/build/global/GlobalData.java | 4 +- .../build/pcd/action/PCDAutoGenAction.java | 15 +- ...latformPcdPreprocessActionForBuilding.java | 130 +++++----- .../tianocore/pcd/action/ActionMessage.java | 1 - .../action/PlatformPcdPreprocessAction.java | 223 ++++++++++-------- .../pcd/entity/DynamicTokenValue.java | 16 +- .../org/tianocore/pcd/entity/Token.java | 26 +- .../pcd/exception/EntityException.java | 2 +- .../PlatformPcdPreprocessException.java | 36 +++ 13 files changed, 282 insertions(+), 223 deletions(-) create mode 100644 Tools/Source/GenBuild/org/tianocore/build/exception/PlatformPcdPreprocessBuildException.java create mode 100644 Tools/Source/PcdTools/org/tianocore/pcd/exception/PlatformPcdPreprocessException.java diff --git a/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java b/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java index a8ec270355..d8249dd86c 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java +++ b/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java @@ -462,7 +462,7 @@ public class AutoGen { try { this.myPcdAutogen.execute(); } catch (Exception exp) { - throw new BuildException (exp.getMessage()); + throw new PcdAutogenException (exp.getMessage()); } if (this.myPcdAutogen != null) { @@ -594,7 +594,7 @@ public class AutoGen { * @throws BuildException * Failed to generate AutoGen.c. */ - void libGenAutogenC() throws BuildException { + void libGenAutogenC() throws BuildException, PcdAutogenException { StringBuffer fileBuffer = new StringBuffer(10240); // @@ -615,7 +615,7 @@ public class AutoGen { try { this.myPcdAutogen.execute(); } catch (Exception e) { - throw new BuildException(e.getMessage()); + throw new PcdAutogenException(e.getMessage()); } if (this.myPcdAutogen != null) { diff --git a/Tools/Source/GenBuild/org/tianocore/build/exception/PcdAutogenException.java b/Tools/Source/GenBuild/org/tianocore/build/exception/PcdAutogenException.java index d11e041695..558cff990e 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/exception/PcdAutogenException.java +++ b/Tools/Source/GenBuild/org/tianocore/build/exception/PcdAutogenException.java @@ -26,7 +26,7 @@ public class PcdAutogenException extends AutoGenException { @param expStr exception message string. **/ public PcdAutogenException(String expStr) { - super("[PcdAutogenException]:" + expStr); + super("\r\n[PcdAutogenException] #############################\r\n" + expStr); } public PcdAutogenException() { diff --git a/Tools/Source/GenBuild/org/tianocore/build/exception/PlatformPcdPreprocessBuildException.java b/Tools/Source/GenBuild/org/tianocore/build/exception/PlatformPcdPreprocessBuildException.java new file mode 100644 index 0000000000..894f25e034 --- /dev/null +++ b/Tools/Source/GenBuild/org/tianocore/build/exception/PlatformPcdPreprocessBuildException.java @@ -0,0 +1,36 @@ +/** @file + PlatformPcdPreprocessBuildException class. + + The class handle the exception throwed by PlatformPcdPreprocessActionForBuilding class. + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ +package org.tianocore.build.exception; + +public class PlatformPcdPreprocessBuildException extends GenBuildException { + /** + serial version ID + **/ + private static final long serialVersionUID = -1014589090055424954L; + + /** + Constructure function + + @param expStr exception message string. + **/ + public PlatformPcdPreprocessBuildException(String expStr) { + super("\r\n[PlatformPcdPreprocess Failure] #############################\r\n" + expStr); + } + + public PlatformPcdPreprocessBuildException() { + super(); + } +} diff --git a/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java b/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java index 37e05fd627..23be3307e1 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java +++ b/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java @@ -375,12 +375,8 @@ public class FpdParserTask extends Task { // // Pcd Collection. Call CollectPCDAction to collect pcd info. // - try { - PlatformPcdPreprocessActionForBuilding ca = new PlatformPcdPreprocessActionForBuilding(); - ca.perform(GlobalData.getWorkspacePath(),platformId.getFpdFile().getPath(),ActionMessage.NULL_MESSAGE_LEVEL); - } catch (Exception e){ - throw new BuildException(e.getMessage()); - } + PlatformPcdPreprocessActionForBuilding ca = new PlatformPcdPreprocessActionForBuilding(); + ca.perform(platformId.getFpdFile().getPath(), ActionMessage.NULL_MESSAGE_LEVEL); } catch (Exception e) { throw new BuildException("Load FPD file [" + fpdFile.getPath() + "] error. \n" + e.getMessage()); } diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java b/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java index b02af3df66..d078002bfe 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java +++ b/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java @@ -107,7 +107,7 @@ public class GlobalData { /// /// PCD memory database stored all PCD information which collected from FPD,MSA and SPD. /// -// private static final MemoryDatabaseManager pcdDbManager = new MemoryDatabaseManager(); + private static final MemoryDatabaseManager pcdDbManager = new MemoryDatabaseManager(); /// /// build target + tool chain family/tag name + arch + command types + command options @@ -130,8 +130,6 @@ public class GlobalData { private static Map moduleToolChainOption = new HashMap(); private static Map moduleToolChainFamilyOption = new HashMap(); - private static final MemoryDatabaseManager pcdDbManager = new MemoryDatabaseManager(); - /** Parse framework database (DB) and all SPD files listed in DB to initialize the environment for next build. This method will only be executed only once diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java index 5a429e4117..614bd9e485 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java +++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java @@ -31,6 +31,7 @@ import org.tianocore.pcd.exception.BuildActionException; import org.tianocore.pcd.entity.UsageIdentification; import org.tianocore.pcd.action.BuildAction; import org.tianocore.pcd.action.ActionMessage; +import org.tianocore.build.exception.PcdAutogenException; /** This class is to manage how to generate the PCD information into Autogen.c and Autogen.h. @@ -142,7 +143,7 @@ public class PCDAutoGenAction extends BuildAction { } /** - check the parameter for action class. + Override function: check the parameter for action class. @throws BuildActionException Bad parameter. **/ @@ -162,12 +163,6 @@ public class PCDAutoGenAction extends BuildAction { public void performAction() { ActionMessage.debug(this, "Starting PCDAutoGenAction to generate autogen.h and autogen.c!..."); - // - // Check the PCD memory database manager is valid. - // - if(GlobalData.getPCDMemoryDBManager() == null) { - throw new BuildActionException("Memory database has not been initlizated!"); - } dbManager = GlobalData.getPCDMemoryDBManager(); @@ -233,7 +228,7 @@ public class PCDAutoGenAction extends BuildAction { // All library's PCD should instanted in module's who // use this library instance. If not, give errors. // - throw new BuildActionException (String.format("[PCD Autogen Error] Module %s use library instance %s, the PCD %s " + + throw new BuildActionException (String.format("Module %s use library instance %s, the PCD %s " + "is required by this library instance, but can not find " + "it in the %s's in FPD file!", MemoryDatabaseManager.CurrentModuleName, @@ -336,9 +331,7 @@ public class PCDAutoGenAction extends BuildAction { WorkSpace,null); try { - collectionAction.perform(WorkSpace, - logFilePath, - ActionMessage.MAX_MESSAGE_LEVEL); + collectionAction.perform(logFilePath, ActionMessage.MAX_MESSAGE_LEVEL); } catch(Exception e) { e.printStackTrace(); } diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PlatformPcdPreprocessActionForBuilding.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PlatformPcdPreprocessActionForBuilding.java index 2e50531d7e..fd1ae56eb6 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PlatformPcdPreprocessActionForBuilding.java +++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PlatformPcdPreprocessActionForBuilding.java @@ -39,6 +39,8 @@ import org.tianocore.pcd.entity.Token; import org.tianocore.pcd.entity.UsageIdentification; import org.tianocore.pcd.exception.EntityException; import org.tianocore.pcd.action.PlatformPcdPreprocessAction; +import org.tianocore.build.exception.PlatformPcdPreprocessBuildException; +import org.tianocore.pcd.exception.PlatformPcdPreprocessException; /** This action class is to collect PCD information from MSA, SPD, FPD xml file. @@ -46,11 +48,6 @@ import org.tianocore.pcd.action.PlatformPcdPreprocessAction; from buildAction or UIAction. **/ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreprocessAction { - /// - /// Workspacepath hold the workspace information. - /// - private String workspacePath; - /// /// FPD file is the root file. /// @@ -66,15 +63,6 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces /// private PlatformSurfaceAreaDocument fpdDocInstance; - /** - Set WorkspacePath parameter for this action class. - - @param workspacePath parameter for this action - **/ - public void setWorkspacePath(String workspacePath) { - this.workspacePath = workspacePath; - } - /** Set action message level for CollectPcdAction tool. @@ -99,17 +87,16 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces /** Common function interface for outer. - @param workspacePath The path of workspace of current build or analysis. - @param fpdFilePath The fpd file path of current build or analysis. - @param messageLevel The message level for this Action. + @param fpdFilePath The fpd file path of current build or analysis. + @param messageLevel The message level for this Action. - @throws Exception The exception of this function. Because it can *not* be predict - where the action class will be used. So only Exception can be throw. + @throws PlatformPreprocessBuildException + The exception of this function. Because it can *not* be predict + where the action class will be used. So only Exception can be throw. **/ - public void perform(String workspacePath, String fpdFilePath, - int messageLevel) throws Exception { - setWorkspacePath(workspacePath); + public void perform(String fpdFilePath, int messageLevel) + throws PlatformPcdPreprocessBuildException { setFPDFilePath(fpdFilePath); setActionMessageLevel(messageLevel); checkParameter(); @@ -132,32 +119,34 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces @throws EntityException Exception indicate failed to execute this action. **/ - public void execute() throws EntityException { - MemoryDatabaseManager pcdDbManager = null; - + public void execute() throws PlatformPcdPreprocessBuildException { + String errorMessageHeader = "Fail to initialize Pcd memory database for building. Because:"; // // Get memoryDatabaseManager instance from GlobalData. - // The memoryDatabaseManager should be initialized for whatever build - // tools or wizard tools + // The memoryDatabaseManager should be initialized as static variable + // in some Pre-process class. // - if((pcdDbManager = GlobalData.getPCDMemoryDBManager()) == null) { - throw new EntityException("The instance of PCD memory database manager is null"); - } - - this.setPcdDbManager(pcdDbManager); + setPcdDbManager(GlobalData.getPCDMemoryDBManager()); // // Collect all PCD information defined in FPD file. // Evenry token defind in FPD will be created as an token into // memory database. // - initPcdMemoryDbWithPlatformInfo(); + try { + initPcdMemoryDbWithPlatformInfo(); + } catch (PlatformPcdPreprocessException exp) { + throw new PlatformPcdPreprocessBuildException(errorMessageHeader + exp.getMessage()); + } // // Generate for PEI, DXE PCD DATABASE's definition and initialization. // - genPcdDatabaseSourceCode (); - + try { + genPcdDatabaseSourceCode (); + } catch (EntityException exp) { + throw new PlatformPcdPreprocessBuildException(errorMessageHeader + exp.getMessage()); + } } /** @@ -166,13 +155,15 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces @param guidCName Guid CName string. @return String[] Guid information from SPD file. + @throws PlatformPcdPreprocessException + Fail to get Guid information from SPD file. **/ - public String[] getGuidInfoFromSpd(String guidCName) throws EntityException { + public String[] getGuidInfoFromSpd(String guidCName) throws PlatformPcdPreprocessException { String[] tokenSpaceStrRet = null; try { tokenSpaceStrRet = GlobalData.getGuidInfoFromCname(guidCName); } catch ( Exception e ) { - throw new EntityException ("Failed get Guid CName " + guidCName + "from SPD file!"); + throw new PlatformPcdPreprocessException ("Failed get Guid CName " + guidCName + "from SPD file!"); } return tokenSpaceStrRet; } @@ -180,7 +171,6 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces /** This function generates source code for PCD Database. - @param void @throws EntityException If the token does *not* exist in memory database. **/ @@ -210,11 +200,12 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces This function maybe provided by some Global class. - @return List the component array. + @return List the component array. + @throws PlatformPcdPreprocessException get all modules in in FPD file. - */ + **/ public List getComponentsFromFpd() - throws EntityException { + throws PlatformPcdPreprocessException { List allModules = new ArrayList(); Map pcdBuildDefinitions = null; UsageIdentification usageId = null; @@ -246,15 +237,14 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces Override function: Verify the datum value according its datum size and datum type, this function maybe moved to FPD verification tools in future. - @param cName - @param moduleName - @param datum - @param datumType - @param maxDatumSize + @param cName The token name + @param moduleName The module who use this PCD token + @param datum The PCD's datum + @param datumType The PCD's datum type + @param maxDatumSize The max size for PCD's Datum. - @return String + @return String exception strings. */ - /***/ public String verifyDatum(String cName, String moduleName, String datum, @@ -584,7 +574,7 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces **/ public DynamicPcdBuildDefinitions.PcdBuildData getDynamicInfoFromFpd(Token token, String moduleName) - throws EntityException { + throws PlatformPcdPreprocessException { int index = 0; String exceptionString = null; String dynamicPrimaryKey = null; @@ -600,9 +590,9 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces try { fpdDocInstance = (PlatformSurfaceAreaDocument)XmlObject.Factory.parse(new File(fpdFilePath)); } catch(IOException ioE) { - throw new EntityException("File IO error for xml file:" + fpdFilePath + "\n" + ioE.getMessage()); + throw new PlatformPcdPreprocessException("File IO error for xml file:" + fpdFilePath + "\n" + ioE.getMessage()); } catch(XmlException xmlE) { - throw new EntityException("Can't parse the FPD xml fle:" + fpdFilePath + "\n" + xmlE.getMessage()); + throw new PlatformPcdPreprocessException("Can't parse the FPD xml fle:" + fpdFilePath + "\n" + xmlE.getMessage()); } } @@ -612,7 +602,7 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces "PCD entry %s in module %s!", token.cName, moduleName); - throw new EntityException(exceptionString); + throw new PlatformPcdPreprocessException(exceptionString); } dynamicPcdBuildDataArray = dynamicPcdBuildDefinitions.getPcdBuildDataList(); @@ -620,11 +610,11 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces try { tokenSpaceStrRet = GlobalData.getGuidInfoFromCname(dynamicPcdBuildDataArray.get(index).getTokenSpaceGuidCName()); } catch (Exception e) { - throw new EntityException ("Fail to get token space guid for token " + dynamicPcdBuildDataArray.get(index).getCName()); + throw new PlatformPcdPreprocessException ("Fail to get token space guid for token " + dynamicPcdBuildDataArray.get(index).getCName()); } if (tokenSpaceStrRet == null) { - throw new EntityException ("Fail to get token space guid for token " + dynamicPcdBuildDataArray.get(index).getCName()); + throw new PlatformPcdPreprocessException ("Fail to get token space guid for token " + dynamicPcdBuildDataArray.get(index).getCName()); } dynamicPrimaryKey = Token.getPrimaryKeyString(dynamicPcdBuildDataArray.get(index).getCName(), @@ -640,11 +630,13 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces /** Override function: get all from FPD file. - @return List + @return List All DYNAMIC PCD list in in FPD file. + @throws PlatformPcdPreprocessBuildException Failure to get dynamic information list. + **/ public List getAllDynamicPcdInfoFromFpd() - throws EntityException { + throws PlatformPcdPreprocessException { DynamicPcdBuildDefinitions dynamicPcdBuildDefinitions = null; // @@ -655,9 +647,9 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces try { fpdDocInstance = (PlatformSurfaceAreaDocument)XmlObject.Factory.parse(new File(fpdFilePath)); } catch(IOException ioE) { - throw new EntityException("File IO error for xml file:" + fpdFilePath + "\n" + ioE.getMessage()); + throw new PlatformPcdPreprocessException("File IO error for xml file:" + fpdFilePath + "\n" + ioE.getMessage()); } catch(XmlException xmlE) { - throw new EntityException("Can't parse the FPD xml fle:" + fpdFilePath + "\n" + xmlE.getMessage()); + throw new PlatformPcdPreprocessException("Can't parse the FPD xml fle:" + fpdFilePath + "\n" + xmlE.getMessage()); } } @@ -672,28 +664,23 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces /** check parameter for this action. - @throws EntityException Bad parameter. + @throws PlatformPcdPreprocessBuildException Bad parameter. **/ - private void checkParameter() throws EntityException { + private void checkParameter() throws PlatformPcdPreprocessBuildException { File file = null; - if((fpdFilePath == null) ||(workspacePath == null)) { - throw new EntityException("WorkspacePath and FPDFileName should be blank for CollectPCDAtion!"); + if (fpdFilePath == null) { + throw new PlatformPcdPreprocessBuildException("WorkspacePath and FPDFileName should be blank for CollectPCDAtion!"); } - if(fpdFilePath.length() == 0 || workspacePath.length() == 0) { - throw new EntityException("WorkspacePath and FPDFileName should be blank for CollectPCDAtion!"); - } - - file = new File(workspacePath); - if(!file.exists()) { - throw new EntityException("WorkpacePath " + workspacePath + " does not exist!"); + if (fpdFilePath.length() == 0) { + throw new PlatformPcdPreprocessBuildException("WorkspacePath and FPDFileName should be blank for CollectPCDAtion!"); } file = new File(fpdFilePath); if(!file.exists()) { - throw new EntityException("FPD File " + fpdFilePath + " does not exist!"); + throw new PlatformPcdPreprocessBuildException("FPD File " + fpdFilePath + " does not exist!"); } } @@ -702,10 +689,9 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces @param argv parameter from command line **/ - public static void main(String argv[]) throws EntityException { + public static void main(String argv[]) throws PlatformPcdPreprocessBuildException { PlatformPcdPreprocessActionForBuilding ca = new PlatformPcdPreprocessActionForBuilding(); String projectDir = "x:/edk2"; - ca.setWorkspacePath(projectDir); ca.setFPDFilePath(projectDir + "/EdkNt32Pkg/Nt32.fpd"); ca.setActionMessageLevel(ActionMessage.MAX_MESSAGE_LEVEL); GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db", diff --git a/Tools/Source/PcdTools/org/tianocore/pcd/action/ActionMessage.java b/Tools/Source/PcdTools/org/tianocore/pcd/action/ActionMessage.java index 3c4b467f7f..1e26eff26b 100644 --- a/Tools/Source/PcdTools/org/tianocore/pcd/action/ActionMessage.java +++ b/Tools/Source/PcdTools/org/tianocore/pcd/action/ActionMessage.java @@ -17,7 +17,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. package org.tianocore.pcd.action; import org.apache.tools.ant.Task; -import org.tianocore.logger.EdkLog; /** ActionMessage class take over all message for loging and waning. This class should dispatch message into different Action class according to instance diff --git a/Tools/Source/PcdTools/org/tianocore/pcd/action/PlatformPcdPreprocessAction.java b/Tools/Source/PcdTools/org/tianocore/pcd/action/PlatformPcdPreprocessAction.java index 90c9ca0f31..04ebf89684 100644 --- a/Tools/Source/PcdTools/org/tianocore/pcd/action/PlatformPcdPreprocessAction.java +++ b/Tools/Source/PcdTools/org/tianocore/pcd/action/PlatformPcdPreprocessAction.java @@ -25,10 +25,10 @@ import java.util.regex.Pattern; import org.tianocore.DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions; import org.tianocore.PcdBuildDefinitionDocument.PcdBuildDefinition; -import org.tianocore.pcd.entity.MemoryDatabaseManager; -import org.tianocore.pcd.exception.EntityException; import org.tianocore.pcd.entity.*; import org.tianocore.pcd.entity.Token; +import org.tianocore.pcd.entity.MemoryDatabaseManager; +import org.tianocore.pcd.exception.PlatformPcdPreprocessException; /** The abstract parent class PlatformPcdPreprocessAction, This class is to collect platform's @@ -53,7 +53,7 @@ public abstract class PlatformPcdPreprocessAction { /** Get parameter pcdDbManager - + @return MemoryDatabaseManager **/ public MemoryDatabaseManager getPcdDbManager() { @@ -64,10 +64,12 @@ public abstract class PlatformPcdPreprocessAction { In building environement, this function will be implementated by FpdParserTask. - @return List + @return List the component array. + @throws PlatformPcdPreprocessException get all modules in in FPD file. + **/ public abstract List getComponentsFromFpd() - throws EntityException; + throws PlatformPcdPreprocessException; /** Abstract function to get GUID string from SPD file. @@ -76,10 +78,12 @@ public abstract class PlatformPcdPreprocessAction { @param guidCName the CName of GUID - @return String[] Guid Info array contains CName and Guid String + @return String[] Guid information from SPD file. + @throws PlatformPcdPreprocessException + Fail to get Guid information from SPD file. **/ public abstract String[] getGuidInfoFromSpd(String guidCName) - throws EntityException; + throws PlatformPcdPreprocessException; /** Abstract function: Verification the PCD data. @@ -87,13 +91,14 @@ public abstract class PlatformPcdPreprocessAction { In different environment, such as building environment and wizard environment, it has different implementation according to optimization. - @param cName - @param moduleName - @param datum - @param datumType - @param maxDatumSize + @param cName The token name + @param moduleName The module who use this PCD token + @param datum The PCD's datum + @param datumType The PCD's datum type + @param maxDatumSize The max size for PCD's Datum. + + @return String exception strings. - @return String **/ public abstract String verifyDatum(String cName, String moduleName, @@ -112,23 +117,25 @@ public abstract class PlatformPcdPreprocessAction { public abstract DynamicPcdBuildDefinitions.PcdBuildData getDynamicInfoFromFpd(Token token, String moduleName) - throws EntityException; + throws PlatformPcdPreprocessException; /** Abstract function: Get all dynamic PCD information from FPD file. - @return List + @return List All DYNAMIC PCD list in in FPD file. + @throws PlatformPcdPreprocessBuildException Failure to get dynamic information list. + **/ public abstract List getAllDynamicPcdInfoFromFpd() - throws EntityException; + throws PlatformPcdPreprocessException; /** Collect all PCD information from FPD file into PCD memory database. **/ public void initPcdMemoryDbWithPlatformInfo() - throws EntityException { + throws PlatformPcdPreprocessException { int index = 0; int pcdIndex = 0; List pcdBuildDataArray = new ArrayList(); @@ -154,7 +161,8 @@ public abstract class PlatformPcdPreprocessAction { modules = getComponentsFromFpd(); if (modules == null) { - throw new EntityException("[FPD file error] No modules in FPD file, Please check whether there are elements in in FPD file!"); + throw new PlatformPcdPreprocessException( + "No modules in FPD file, Please check whether there are elements in in FPD file!"); } // @@ -185,7 +193,9 @@ public abstract class PlatformPcdPreprocessAction { tokenSpaceStrRet = getGuidInfoFromSpd(pcdBuildData.getTokenSpaceGuidCName()); if (tokenSpaceStrRet == null) { - throw new EntityException ("Fail to get Token space guid for token" + pcdBuildData.getCName()); + throw new PlatformPcdPreprocessException( + "Fail to get Token space guid for token" + pcdBuildData.getCName() + + " from all SPD files. You must have an for this token space Guid"); } primaryKey = Token.getPrimaryKeyString(pcdBuildData.getCName(), tokenSpaceStrRet[1]); @@ -201,11 +211,11 @@ public abstract class PlatformPcdPreprocessAction { if ((pcdType == Token.PCD_TYPE.FEATURE_FLAG) && (datumType != Token.DATUM_TYPE.BOOLEAN)){ - exceptionString = String.format("[FPD file error] For PCD %s in module %s, the PCD type is FEATRUE_FLAG but "+ + exceptionString = String.format("In FPD file, for PCD %s in module %s, the PCD type is FEATRUE_FLAG but "+ "datum type of this PCD entry is not BOOLEAN!", pcdBuildData.getCName(), moduleName); - throw new EntityException(exceptionString); + throw new PlatformPcdPreprocessException(exceptionString); } // @@ -218,10 +228,10 @@ public abstract class PlatformPcdPreprocessAction { // Value is required. // if (datum == null) { - exceptionString = String.format("[FPD file error] There is no value for PCD entry %s in module %s!", + exceptionString = String.format("In FPD file, there is no value for PCD entry %s in module %s!", pcdBuildData.getCName(), moduleName); - throw new EntityException(exceptionString); + throw new PlatformPcdPreprocessException(exceptionString); } // @@ -232,7 +242,7 @@ public abstract class PlatformPcdPreprocessAction { datum, datumType, maxDatumSize)) != null) { - throw new EntityException(exceptionString); + throw new PlatformPcdPreprocessException(exceptionString); } } @@ -253,32 +263,32 @@ public abstract class PlatformPcdPreprocessAction { // modules. // if (token.datumType != datumType) { - exceptionString = String.format("[FPD file error] The datum type of PCD entry %s is %s, which is different with %s defined in before!", + exceptionString = String.format("In FPD file, the datum type of PCD entry %s is %s, which is different with %s defined in before!", pcdBuildData.getCName(), pcdBuildData.getDatumType().toString(), Token.getStringOfdatumType(token.datumType)); - throw new EntityException(exceptionString); + throw new PlatformPcdPreprocessException(exceptionString); } // // Check token number is valid // if (tokenNumber != token.tokenNumber) { - exceptionString = String.format("[FPD file error] The token number of PCD entry %s in module %s is different with same PCD entry in other modules!", + exceptionString = String.format("In FPD file, the token number of PCD entry %s in module %s is different with same PCD entry in other modules!", pcdBuildData.getCName(), moduleName); - throw new EntityException(exceptionString); + throw new PlatformPcdPreprocessException(exceptionString); } // // For same PCD used in different modules, the PCD type should all be dynamic or non-dynamic. // if (token.isDynamicPCD != Token.isDynamic(pcdType)) { - exceptionString = String.format("[FPD file error] For PCD entry %s in module %s, you define dynamic or non-dynamic PCD type which"+ - "is different with others module's", + exceptionString = String.format("In FPD file, for PCD entry %s in module %s, you define dynamic or non-dynamic PCD type which"+ + " is different with others module's", token.cName, moduleName); - throw new EntityException(exceptionString); + throw new PlatformPcdPreprocessException(exceptionString); } if (token.isDynamicPCD) { @@ -291,24 +301,24 @@ public abstract class PlatformPcdPreprocessAction { (token.getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.DEFAULT_TYPE) && (datum != null)) { if (!datum.equalsIgnoreCase(token.getDefaultSku().value)) { - exceptionString = String.format("[FPD file error] For dynamic PCD %s in module %s, the datum in is "+ + exceptionString = String.format("In FPD file, for dynamic PCD %s in module %s, the datum in is "+ "not equal to the datum in , it is "+ "illega! You could no set in for a dynamic PCD!", token.cName, moduleName); - throw new EntityException(exceptionString); + throw new PlatformPcdPreprocessException(exceptionString); } } if ((maxDatumSize != 0) && (maxDatumSize != token.datumSize)){ - exceptionString = String.format("[FPD file error] For dynamic PCD %s in module %s, the max datum size is %d which "+ + exceptionString = String.format("In FPD file, for dynamic PCD %s in module %s, the max datum size is %d which "+ "is different with %d defined in !", token.cName, moduleName, maxDatumSize, token.datumSize); - throw new EntityException(exceptionString); + throw new PlatformPcdPreprocessException(exceptionString); } } @@ -320,7 +330,10 @@ public abstract class PlatformPcdPreprocessAction { tokenSpaceStrRet = this.getGuidInfoFromSpd(pcdBuildData.getTokenSpaceGuidCName()); if (tokenSpaceStrRet == null) { - throw new EntityException("Fail to get token space guid for token " + token.cName); + throw new PlatformPcdPreprocessException( + "Fail to get Token space guid for token" + token.cName + + " from all SPD files. You must have an for this token space Guid"); + } token = new Token(pcdBuildData.getCName(), tokenSpaceStrRet[1]); @@ -361,7 +374,14 @@ public abstract class PlatformPcdPreprocessAction { pcdType, datum, maxDatumSize); - token.addUsageInstance(usageInstance); + if (!token.addUsageInstance(usageInstance)) { + throw new PlatformPcdPreprocessException( + String.format("PCD %s for module %s has already exist in database, Please check all PCD build entries "+ + "in modules %s in to make sure no duplicated definitions in FPD file!", + token.cName, + moduleName, + moduleName)); + } } } @@ -396,7 +416,7 @@ public abstract class PlatformPcdPreprocessAction { Token token, String datum, int maxDatumSize) - throws EntityException { + throws PlatformPcdPreprocessException { int index = 0; int offset; String exceptionString = null; @@ -412,12 +432,12 @@ public abstract class PlatformPcdPreprocessAction { dynamicInfo = getDynamicInfoFromFpd(token, moduleName); if (dynamicInfo == null) { - exceptionString = String.format("[FPD file error] For Dynamic PCD %s used by module %s, "+ + exceptionString = String.format("In FPD file, for Dynamic PCD %s used by module %s, "+ "there is no dynamic information in "+ "in FPD file, but it is required!", token.cName, moduleName); - throw new EntityException(exceptionString); + throw new PlatformPcdPreprocessException(exceptionString); } token.datumSize = dynamicInfo.getMaxDatumSize(); @@ -428,28 +448,28 @@ public abstract class PlatformPcdPreprocessAction { token.datumType, token.datumSize); if (exceptionString != null) { - throw new EntityException(exceptionString); + throw new PlatformPcdPreprocessException(exceptionString); } if ((maxDatumSize != 0) && (maxDatumSize != token.datumSize)) { - exceptionString = String.format("FPD file error] For dynamic PCD %s, the datum size in module %s is %d, but "+ + exceptionString = String.format("In FPD file, for dynamic PCD %s, the datum size in module %s is %d, but "+ "the datum size in is %d, they are not match!", token.cName, moduleName, maxDatumSize, dynamicInfo.getMaxDatumSize()); - throw new EntityException(exceptionString); + throw new PlatformPcdPreprocessException(exceptionString); } tokenNumber = Long.decode(dynamicInfo.getToken().toString()); if (tokenNumber != token.tokenNumber) { - exceptionString = String.format("[FPD file error] For dynamic PCD %s, the token number in module %s is 0x%x, but"+ + exceptionString = String.format("In FPD file, for dynamic PCD %s, the token number in module %s is 0x%x, but"+ "in , the token number is 0x%x, they are not match!", token.cName, moduleName, token.tokenNumber, tokenNumber); - throw new EntityException(exceptionString); + throw new PlatformPcdPreprocessException(exceptionString); } token.dynamicExTokenNumber = tokenNumber; @@ -479,7 +499,7 @@ public abstract class PlatformPcdPreprocessAction { skuInfoList.get(index).getValue().toString(), token.datumType, token.datumSize)) != null) { - throw new EntityException(exceptionString); + throw new PlatformPcdPreprocessException(exceptionString); } token.skuData.add(skuInstance); @@ -491,10 +511,10 @@ public abstract class PlatformPcdPreprocessAction { if (datum != null) { if ((skuInstance.id == 0) && !datum.toString().equalsIgnoreCase(skuInfoList.get(index).getValue().toString())) { - exceptionString = "[FPD file error] For dynamic PCD " + token.cName + ", the value in module " + moduleName + " is " + datum.toString() + " but the "+ + exceptionString = "In FPD file, for dynamic PCD " + token.cName + ", the value in module " + moduleName + " is " + datum.toString() + " but the "+ "value of sku 0 data in is " + skuInstance.value.value + ". They are must be same!"+ " or you could not define value for a dynamic PCD in every !"; - throw new EntityException(exceptionString); + throw new PlatformPcdPreprocessException(exceptionString); } } continue; @@ -506,32 +526,32 @@ public abstract class PlatformPcdPreprocessAction { if (skuInfoList.get(index).getVariableName() != null) { exceptionString = null; if (skuInfoList.get(index).getVariableGuid() == null) { - exceptionString = String.format("[FPD file error] For dynamic PCD %s in section in FPD "+ + exceptionString = String.format("In FPD file, for dynamic PCD %s in section in FPD "+ "file, who use HII, but there is no defined for Sku %d data!", token.cName, index); if (exceptionString != null) { - throw new EntityException(exceptionString); + throw new PlatformPcdPreprocessException(exceptionString); } } if (skuInfoList.get(index).getVariableOffset() == null) { - exceptionString = String.format("[FPD file error] For dynamic PCD %s in section in FPD "+ + exceptionString = String.format("In FPD file, for dynamic PCD %s in section in FPD "+ "file, who use HII, but there is no defined for Sku %d data!", token.cName, index); if (exceptionString != null) { - throw new EntityException(exceptionString); + throw new PlatformPcdPreprocessException(exceptionString); } } if (skuInfoList.get(index).getHiiDefaultValue() == null) { - exceptionString = String.format("[FPD file error] For dynamic PCD %s in section in FPD "+ + exceptionString = String.format("In FPD file, for dynamic PCD %s in section in FPD "+ "file, who use HII, but there is no defined for Sku %d data!", token.cName, index); if (exceptionString != null) { - throw new EntityException(exceptionString); + throw new PlatformPcdPreprocessException(exceptionString); } } @@ -546,15 +566,16 @@ public abstract class PlatformPcdPreprocessAction { hiiDefaultValue, token.datumType, token.datumSize)) != null) { - throw new EntityException(exceptionString); + throw new PlatformPcdPreprocessException(exceptionString); } offset = Integer.decode(skuInfoList.get(index).getVariableOffset()); if (offset > 0xFFFF) { - throw new EntityException(String.format("[FPD file error] For dynamic PCD %s , the variable offset defined in sku %d data "+ - "exceed 64K, it is not allowed!", - token.cName, - index)); + throw new PlatformPcdPreprocessException( + String.format("In FPD file, for dynamic PCD %s , the variable offset defined in sku %d data "+ + "exceed 64K, it is not allowed!", + token.cName, + index)); } // @@ -562,17 +583,18 @@ public abstract class PlatformPcdPreprocessAction { // variableGuidString = getGuidInfoFromSpd(skuInfoList.get(index).getVariableGuid().toString()); if (variableGuidString == null) { - throw new EntityException(String.format("[GUID Error] For dynamic PCD %s, the variable guid %s can be found in all SPD file!", - token.cName, - skuInfoList.get(index).getVariableGuid().toString())); + throw new PlatformPcdPreprocessException( + String.format("In FPD file, for dynamic PCD %s, the variable guid %s can be found in all SPD file!", + token.cName, + skuInfoList.get(index).getVariableGuid().toString())); } String variableStr = skuInfoList.get(index).getVariableName(); Pattern pattern = Pattern.compile("0x([a-fA-F0-9]){4}"); Matcher matcher = pattern.matcher(variableStr); List varNameList = new ArrayList(); while (matcher.find()){ - String str = variableStr.substring(matcher.start(),matcher.end()); - varNameList.add(str); + String str = variableStr.substring(matcher.start(),matcher.end()); + varNameList.add(str); } skuInstance.value.setHiiData(varNameList, @@ -589,29 +611,29 @@ public abstract class PlatformPcdPreprocessAction { continue; } - exceptionString = String.format("[FPD file error] For dynamic PCD %s, the dynamic info must "+ + exceptionString = String.format("In FPD file, for dynamic PCD %s, the dynamic info must "+ "be one of 'DefaultGroup', 'HIIGroup', 'VpdGroup'.", token.cName); - throw new EntityException(exceptionString); + throw new PlatformPcdPreprocessException(exceptionString); } if (!hasSkuId0) { - exceptionString = String.format("[FPD file error] For dynamic PCD %s in , there are "+ + exceptionString = String.format("In FPD file, for dynamic PCD %s in , there are "+ "no sku id = 0 data, which is required for every dynamic PCD", token.cName); - throw new EntityException(exceptionString); + throw new PlatformPcdPreprocessException(exceptionString); } return token; } /** - Get all dynamic PCD defined in which unreferenced by + Get all dynamic PCD defined in which unreferenced by any in FPD file. - - @return List Return PCD token + + @return List Return PCD token **/ - private List getUnreferencedDynamicPcd () throws EntityException { + private List getUnreferencedDynamicPcd () throws PlatformPcdPreprocessException { List tokenArray = new ArrayList(); Token token = null; List dynamicPcdBuildDataArray = null; @@ -638,7 +660,7 @@ public abstract class PlatformPcdPreprocessAction { tokenSpaceStrRet = this.getGuidInfoFromSpd(pcdBuildData.getTokenSpaceGuidCName()); if (tokenSpaceStrRet == null) { - throw new EntityException ("Fail to get Token space guid for token" + pcdBuildData.getCName()); + throw new PlatformPcdPreprocessException("Fail to get Token space guid for token" + pcdBuildData.getCName()); } primaryKey = Token.getPrimaryKeyString(pcdBuildData.getCName(), @@ -650,8 +672,9 @@ public abstract class PlatformPcdPreprocessAction { pcdType = Token.getPcdTypeFromString(pcdBuildData.getItemType().toString()); if (pcdType != Token.PCD_TYPE.DYNAMIC_EX) { - throw new EntityException (String.format("[FPD file error] It not allowed for DYNAMIC PCD %s who is no used by any module", - pcdBuildData.getCName())); + throw new PlatformPcdPreprocessException( + String.format("In FPD file, it not allowed for DYNAMIC PCD %s who is no used by any module", + pcdBuildData.getCName())); } // @@ -673,7 +696,7 @@ public abstract class PlatformPcdPreprocessAction { token.datumType, token.datumSize); if (exceptionString != null) { - throw new EntityException(exceptionString); + throw new PlatformPcdPreprocessException(exceptionString); } skuInfoList = pcdBuildData.getSkuInfoList(); @@ -701,7 +724,7 @@ public abstract class PlatformPcdPreprocessAction { skuInfoList.get(index).getValue().toString(), token.datumType, token.datumSize)) != null) { - throw new EntityException(exceptionString); + throw new PlatformPcdPreprocessException(exceptionString); } token.skuData.add(skuInstance); @@ -715,32 +738,32 @@ public abstract class PlatformPcdPreprocessAction { if (skuInfoList.get(index).getVariableName() != null) { exceptionString = null; if (skuInfoList.get(index).getVariableGuid() == null) { - exceptionString = String.format("[FPD file error] For dynamic PCD %s in section in FPD "+ + exceptionString = String.format("In FPD file, for dynamic PCD %s in section in FPD "+ "file, who use HII, but there is no defined for Sku %d data!", token.cName, index); if (exceptionString != null) { - throw new EntityException(exceptionString); + throw new PlatformPcdPreprocessException(exceptionString); } } if (skuInfoList.get(index).getVariableOffset() == null) { - exceptionString = String.format("[FPD file error] For dynamic PCD %s in section in FPD "+ + exceptionString = String.format("In FPD file, for dynamic PCD %s in section in FPD "+ "file, who use HII, but there is no defined for Sku %d data!", token.cName, index); if (exceptionString != null) { - throw new EntityException(exceptionString); + throw new PlatformPcdPreprocessException(exceptionString); } } if (skuInfoList.get(index).getHiiDefaultValue() == null) { - exceptionString = String.format("[FPD file error] For dynamic PCD %s in section in FPD "+ + exceptionString = String.format("In FPD file, for dynamic PCD %s in section in FPD "+ "file, who use HII, but there is no defined for Sku %d data!", token.cName, index); if (exceptionString != null) { - throw new EntityException(exceptionString); + throw new PlatformPcdPreprocessException(exceptionString); } } @@ -755,15 +778,16 @@ public abstract class PlatformPcdPreprocessAction { hiiDefaultValue, token.datumType, token.datumSize)) != null) { - throw new EntityException(exceptionString); + throw new PlatformPcdPreprocessException(exceptionString); } offset = Integer.decode(skuInfoList.get(index).getVariableOffset()); if (offset > 0xFFFF) { - throw new EntityException(String.format("[FPD file error] For dynamic PCD %s , the variable offset defined in sku %d data "+ - "exceed 64K, it is not allowed!", - token.cName, - index)); + throw new PlatformPcdPreprocessException( + String.format("In FPD file, for dynamic PCD %s , the variable offset defined in sku %d data "+ + "exceed 64K, it is not allowed!", + token.cName, + index)); } // @@ -771,17 +795,18 @@ public abstract class PlatformPcdPreprocessAction { // variableGuidString = this.getGuidInfoFromSpd(skuInfoList.get(index).getVariableGuid().toString()); if (variableGuidString == null) { - throw new EntityException(String.format("[GUID Error] For dynamic PCD %s, the variable guid %s can be found in all SPD file!", - token.cName, - skuInfoList.get(index).getVariableGuid().toString())); + throw new PlatformPcdPreprocessException( + String.format("In FPD file, for dynamic PCD %s, the variable guid %s can be found in all SPD file!", + token.cName, + skuInfoList.get(index).getVariableGuid().toString())); } String variableStr = skuInfoList.get(index).getVariableName(); Pattern pattern = Pattern.compile("0x([a-fA-F0-9]){4}"); Matcher matcher = pattern.matcher(variableStr); List varNameList = new ArrayList(); while (matcher.find()){ - String str = variableStr.substring(matcher.start(),matcher.end()); - varNameList.add(str); + String str = variableStr.substring(matcher.start(),matcher.end()); + varNameList.add(str); } skuInstance.value.setHiiData(varNameList, @@ -798,17 +823,17 @@ public abstract class PlatformPcdPreprocessAction { continue; } - exceptionString = String.format("[FPD file error] For dynamic PCD %s, the dynamic info must "+ + exceptionString = String.format("In FPD file, for dynamic PCD %s, the dynamic info must "+ "be one of 'DefaultGroup', 'HIIGroup', 'VpdGroup'.", token.cName); - throw new EntityException(exceptionString); + throw new PlatformPcdPreprocessException(exceptionString); } if (!hasSkuId0) { - exceptionString = String.format("[FPD file error] For dynamic PCD %s in , there are "+ + exceptionString = String.format("In FPD file, for dynamic PCD %s in , there are "+ "no sku id = 0 data, which is required for every dynamic PCD", token.cName); - throw new EntityException(exceptionString); + throw new PlatformPcdPreprocessException(exceptionString); } tokenArray.add(token); @@ -834,7 +859,7 @@ public abstract class PlatformPcdPreprocessAction { @return UUID UUID instance **/ private UUID translateSchemaStringToUUID(String uuidString) - throws EntityException { + throws PlatformPcdPreprocessException { String temp; String[] splitStringArray; int index; @@ -864,7 +889,7 @@ public abstract class PlatformPcdPreprocessAction { if ((uuidString.charAt(0) == '0') && ((uuidString.charAt(1) == 'x') || (uuidString.charAt(1) == 'X'))) { splitStringArray = uuidString.split("," ); if (splitStringArray.length != 11) { - throw new EntityException ("[FPD file error] Wrong format for UUID string: " + uuidString); + throw new PlatformPcdPreprocessException ("Wrong format for UUID string: " + uuidString); } // diff --git a/Tools/Source/PcdTools/org/tianocore/pcd/entity/DynamicTokenValue.java b/Tools/Source/PcdTools/org/tianocore/pcd/entity/DynamicTokenValue.java index 2de993d511..0ed76b3ebe 100644 --- a/Tools/Source/PcdTools/org/tianocore/pcd/entity/DynamicTokenValue.java +++ b/Tools/Source/PcdTools/org/tianocore/pcd/entity/DynamicTokenValue.java @@ -20,7 +20,7 @@ import java.util.UUID; import org.tianocore.pcd.exception.EntityException; -/** +/** This class is to descript a value type of dynamic PCD. For a dynamic or dynamicEx type PCD data, the value type can be: 1) Hii type: the value of dynamic or dynamicEx is stored into a variable. @@ -33,19 +33,19 @@ public class DynamicTokenValue { /// /// Enumeration macro defintion for value type. /// - public enum VALUE_TYPE {HII_TYPE, VPD_TYPE, DEFAULT_TYPE} + public static enum VALUE_TYPE {HII_TYPE, VPD_TYPE, DEFAULT_TYPE} /// /// The value type maybe: /// HII_TYPE: the value stored into variable area. /// VPD_TYPE: the value stored into OEM specific area. /// DEFAULT_TYPE: the value stored into PCD runtime database. - /// + /// public VALUE_TYPE type; /// /// --------------------------------------------------------------------- - /// Following member is for HII case. The value of HII case will be put + /// Following member is for HII case. The value of HII case will be put /// into variable area in flash. /// --------------------------------------------------------------------- /// @@ -87,12 +87,12 @@ public class DynamicTokenValue { /// /// The default value of this PCD in default case. - /// + /// public String value; /** Constructor function for DynamicTokenValue class. - + **/ public DynamicTokenValue() { type = VALUE_TYPE.DEFAULT_TYPE; @@ -107,7 +107,7 @@ public class DynamicTokenValue { /** Set the HII case data. - @param variableName The variable name + @param variableName The variable name @param variableGuid The variable guid @param variableOffset The offset of value in this variable @param hiiDefaultValue Default value for this PCD @@ -130,7 +130,7 @@ public class DynamicTokenValue { BUGBUG: In fact, it is not correctly, variable name should be treated as unicode UINT16 array. - @return String + @return String **/ public String getStringOfVariableName() throws EntityException { diff --git a/Tools/Source/PcdTools/org/tianocore/pcd/entity/Token.java b/Tools/Source/PcdTools/org/tianocore/pcd/entity/Token.java index d1867fba5b..1038cb021c 100644 --- a/Tools/Source/PcdTools/org/tianocore/pcd/entity/Token.java +++ b/Tools/Source/PcdTools/org/tianocore/pcd/entity/Token.java @@ -21,9 +21,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.tianocore.pcd.entity.UsageIdentification; -import org.tianocore.pcd.exception.EntityException; - /** This class is to descript a PCD token object. The information of a token mainly comes from MSA, SPD and setting produced by platform developer. @@ -32,7 +29,7 @@ public class Token { /// /// Enumeration macro defintion for PCD type. /// - public enum PCD_TYPE {FEATURE_FLAG, FIXED_AT_BUILD, PATCHABLE_IN_MODULE, DYNAMIC, + public static enum PCD_TYPE {FEATURE_FLAG, FIXED_AT_BUILD, PATCHABLE_IN_MODULE, DYNAMIC, DYNAMIC_EX, UNKNOWN} /// @@ -40,12 +37,12 @@ public class Token { /// Wizard maybe expand this type as "int, unsigned int, short, unsigned short etc" in /// prompt dialog. /// - public enum DATUM_TYPE {UINT8, UINT16, UINT32, UINT64, BOOLEAN, POINTER, UNKNOWN} + public static enum DATUM_TYPE {UINT8, UINT16, UINT32, UINT64, BOOLEAN, POINTER, UNKNOWN} /// /// Enumeration macor defintion for usage of PCD /// - public enum PCD_USAGE {ALWAYS_PRODUCED, ALWAYS_CONSUMED, SOMETIMES_PRODUCED, + public static enum PCD_USAGE {ALWAYS_PRODUCED, ALWAYS_CONSUMED, SOMETIMES_PRODUCED, SOMETIMES_CONSUMED, UNKNOWN} /// @@ -169,7 +166,7 @@ public class Token { /** The pcd type is DynamicEx? - + @retval true Is DynamicEx type @retval false not DynamicEx type **/ @@ -285,16 +282,9 @@ public class Token { @retval TRUE - Success to add usage instance. @retval FALSE - Fail to add usage instance **/ - public boolean addUsageInstance(UsageInstance usageInstance) throws EntityException { - String exceptionStr; - + public boolean addUsageInstance(UsageInstance usageInstance) { if (isUsageInstanceExist(usageInstance.usageId)) { - exceptionStr = String.format("[PCD Collection Tool Exception] PCD %s for module %s has already exist in database, Please check all PCD build entries "+ - "in modules %s in to make sure no duplicated definitions in FPD file!", - usageInstance.parentToken.cName, - usageInstance.usageId.moduleName, - usageInstance.usageId.moduleName); - throw new EntityException(exceptionStr); + return false; } // @@ -631,7 +621,7 @@ public class Token { } /** - Judge whether a DYNAMIC PCD has default value. + Judge whether a DYNAMIC PCD has default value. @return whether a DYNAMIC PCD has default value. **/ @@ -832,7 +822,7 @@ public class Token { /** Get string value for ANSIC string type - + @return String the string value **/ public String getStringTypeString () { diff --git a/Tools/Source/PcdTools/org/tianocore/pcd/exception/EntityException.java b/Tools/Source/PcdTools/org/tianocore/pcd/exception/EntityException.java index ca25810855..77d4518a55 100644 --- a/Tools/Source/PcdTools/org/tianocore/pcd/exception/EntityException.java +++ b/Tools/Source/PcdTools/org/tianocore/pcd/exception/EntityException.java @@ -26,6 +26,6 @@ public class EntityException extends Exception { @param expStr exception message string. **/ public EntityException(String expStr) { - super("[PCD EntityException]:" + expStr); + super("[PCD tools Internal Errors]:" + expStr); } } diff --git a/Tools/Source/PcdTools/org/tianocore/pcd/exception/PlatformPcdPreprocessException.java b/Tools/Source/PcdTools/org/tianocore/pcd/exception/PlatformPcdPreprocessException.java new file mode 100644 index 0000000000..69b50c8f2f --- /dev/null +++ b/Tools/Source/PcdTools/org/tianocore/pcd/exception/PlatformPcdPreprocessException.java @@ -0,0 +1,36 @@ +/** @file + PlatformPcdPreprocessException class. + + The class handle the exception throwed by PlatformPcdPreprocessAction class. + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ +package org.tianocore.pcd.exception; + +public class PlatformPcdPreprocessException extends Exception { + /** + serial version ID + **/ + private static final long serialVersionUID = 2858398552845888282L; + + /** + Constructure function + + @param expStr exception message string. + **/ + public PlatformPcdPreprocessException(String expStr) { + super("\r\n[PlatformPcdPreprocess Failure] #############################\r\n" + expStr); + } + + public PlatformPcdPreprocessException() { + super(); + } +} -- 2.39.2