99290058722899f23596533d21210dbcb2e4de2a
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / pcd / action / CollectPCDAction.java
1 /** @file
2 CollectPCDAction class.
3
4 This action class is to collect PCD information from MSA, SPD, FPD xml file.
5 This class will be used for wizard and build tools, So it can *not* inherit
6 from buildAction or wizardAction.
7
8 Copyright (c) 2006, Intel Corporation
9 All rights reserved. This program and the accompanying materials
10 are licensed and made available under the terms and conditions of the BSD License
11 which accompanies this distribution. The full text of the license may be found at
12 http://opensource.org/licenses/bsd-license.php
13
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16
17 **/
18 package org.tianocore.build.pcd.action;
19
20 import java.io.File;
21 import java.io.IOException;
22 import java.util.ArrayList;
23 import java.util.HashMap;
24 import java.util.List;
25 import java.util.Map;
26 import java.util.UUID;
27
28 import org.apache.xmlbeans.XmlException;
29 import org.apache.xmlbeans.XmlObject;
30 import org.tianocore.FrameworkPlatformDescriptionDocument;
31 import org.tianocore.ModuleSADocument;
32 import org.tianocore.PackageSurfaceAreaDocument;
33 import org.tianocore.PcdBuildDeclarationsDocument.PcdBuildDeclarations.PcdBuildData;
34 import org.tianocore.PcdDefinitionsDocument.PcdDefinitions;
35 import org.tianocore.build.autogen.CommonDefinition;
36 import org.tianocore.build.global.GlobalData;
37 import org.tianocore.build.global.SurfaceAreaQuery;
38 import org.tianocore.build.pcd.action.ActionMessage;
39 import org.tianocore.build.pcd.entity.MemoryDatabaseManager;
40 import org.tianocore.build.pcd.entity.SkuInstance;
41 import org.tianocore.build.pcd.entity.Token;
42 import org.tianocore.build.pcd.entity.UsageInstance;
43 import org.tianocore.build.pcd.exception.EntityException;
44
45 /** This action class is to collect PCD information from MSA, SPD, FPD xml file.
46 This class will be used for wizard and build tools, So it can *not* inherit
47 from buildAction or UIAction.
48 **/
49 public class CollectPCDAction {
50 /// memoryDatabase hold all PCD information collected from SPD, MSA, FPD.
51 private MemoryDatabaseManager dbManager;
52
53 /// Workspacepath hold the workspace information.
54 private String workspacePath;
55
56 /// FPD file is the root file.
57 private String fpdFilePath;
58
59 /// Message level for CollectPCDAction.
60 private int originalMessageLevel;
61
62 /**
63 Set WorkspacePath parameter for this action class.
64
65 @param workspacePath parameter for this action
66 **/
67 public void setWorkspacePath(String workspacePath) {
68 this.workspacePath = workspacePath;
69 }
70
71 /**
72 Set action message level for CollectPcdAction tool.
73
74 The message should be restored when this action exit.
75
76 @param actionMessageLevel parameter for this action
77 **/
78 public void setActionMessageLevel(int actionMessageLevel) {
79 originalMessageLevel = ActionMessage.messageLevel;
80 ActionMessage.messageLevel = actionMessageLevel;
81 }
82
83 /**
84 Set FPDFileName parameter for this action class.
85
86 @param fpdFilePath fpd file path
87 **/
88 public void setFPDFilePath(String fpdFilePath) {
89 this.fpdFilePath = fpdFilePath;
90 }
91
92 /**
93 Common function interface for outer.
94
95 @param workspacePath The path of workspace of current build or analysis.
96 @param fpdFilePath The fpd file path of current build or analysis.
97 @param messageLevel The message level for this Action.
98
99 @throws Exception The exception of this function. Because it can *not* be predict
100 where the action class will be used. So only Exception can be throw.
101
102 **/
103 public void perform(String workspacePath, String fpdFilePath,
104 int messageLevel) throws Exception {
105 setWorkspacePath(workspacePath);
106 setFPDFilePath(fpdFilePath);
107 setActionMessageLevel(messageLevel);
108 checkParameter();
109 execute();
110 ActionMessage.messageLevel = originalMessageLevel;
111 }
112
113 /**
114 Core execution function for this action class.
115
116 This function work flows will be:
117 1) Get all token's platform information from FPD, and create token object into memory database.
118 2) Get all token's module information from MSA, and create usage instance for every module's PCD entry.
119 3) Get all token's inherited information from MSA's library, and create usage instance
120 for module who consume this library and create usage instance for library for building.
121 4) Collect token's package information from SPD, update these information for token in memory
122 database.
123
124 @throws EntityException Exception indicate failed to execute this action.
125
126 **/
127 private void execute() throws EntityException {
128 FrameworkPlatformDescriptionDocument fpdDoc = null;
129 Object[][] modulePCDArray = null;
130 Map<String, XmlObject> docMap = null;
131 ModuleSADocument.ModuleSA[] moduleSAs = null;
132 UsageInstance usageInstance = null;
133 String packageName = null;
134 String packageFullPath = null;
135 int index = 0;
136 int libraryIndex = 0;
137 int pcdArrayIndex = 0;
138 List<String> listLibraryInstance = null;
139 String componentTypeStr = null;
140
141 //
142 // Collect all PCD information defined in FPD file.
143 // Evenry token defind in FPD will be created as an token into
144 // memory database.
145 //
146 fpdDoc = createTokenInDBFromFPD();
147
148 //
149 // Searching MSA and SPD document.
150 // The information of MSA will be used to create usage instance into database.
151 // The information of SPD will be used to update the token information in database.
152 //
153
154 HashMap<String, XmlObject> map = new HashMap<String, XmlObject>();
155 map.put("FrameworkPlatformDescription", fpdDoc);
156 SurfaceAreaQuery.setDoc(map);
157
158 moduleSAs = SurfaceAreaQuery.getFpdModules();
159 for(index = 0; index < moduleSAs.length; index ++) {
160 //
161 // Get module document and use SurfaceAreaQuery to get PCD information
162 //
163 docMap = GlobalData.getDoc(moduleSAs[index].getModuleName());
164 SurfaceAreaQuery.setDoc(docMap);
165 modulePCDArray = SurfaceAreaQuery.getModulePCDTokenArray();
166 componentTypeStr = SurfaceAreaQuery.getComponentType();
167 packageName =
168 GlobalData.getPackageNameForModule(moduleSAs[index].getModuleName());
169 packageFullPath = this.workspacePath + File.separator +
170 GlobalData.getPackagePath(packageName) +
171 packageName + ".spd";
172
173 if(modulePCDArray != null) {
174 //
175 // If current MSA contains <PCDs> information, then create usage
176 // instance for PCD information from MSA
177 //
178 for(pcdArrayIndex = 0; pcdArrayIndex < modulePCDArray.length;
179 pcdArrayIndex ++) {
180 usageInstance =
181 createUsageInstanceFromMSA(moduleSAs[index].getModuleName(),
182 modulePCDArray[pcdArrayIndex]);
183
184 if(usageInstance == null) {
185 continue;
186 }
187 //
188 // Get remaining PCD information from the package which this module belongs to
189 //
190 updateTokenBySPD(usageInstance, packageFullPath);
191 }
192 }
193
194 //
195 // Get inherit PCD information which inherit from library instance of this module.
196 //
197 listLibraryInstance =
198 SurfaceAreaQuery.getLibraryInstance(moduleSAs[index].getArch().toString(),
199 CommonDefinition.AlwaysConsumed);
200 if(listLibraryInstance != null) {
201 for(libraryIndex = 0; libraryIndex < listLibraryInstance.size();
202 libraryIndex ++) {
203 inheritPCDFromLibraryInstance(listLibraryInstance.get(libraryIndex),
204 moduleSAs[index].getModuleName(),
205 packageName,
206 componentTypeStr);
207 }
208 }
209 }
210 }
211
212 /**
213 This function will collect inherit PCD information from library for a module.
214
215 This function will create two usage instance for inherited PCD token, one is
216 for module and another is for library.
217 For module, if it inherited a PCD token from library, this PCD token's value
218 should be instanced in module level, and belongs to module.
219 For library, it also need a usage instance for build.
220
221 @param libraryName The name of library instance.
222 @param moduleName The name of module.
223 @param packageName The name of package while module belongs to.
224 @param parentcomponentType The component type of module.
225
226 @throws EntityException If the token does *not* exist in memory database.
227
228 **/
229 private void inheritPCDFromLibraryInstance(String libraryName,
230 String moduleName,
231 String packageName,
232 String parentcomponentType)
233 throws EntityException {
234 Map<String, XmlObject> docMap = null;
235 String primaryKeyString = null;
236 Object[][] libPcdDataArray = null;
237 UUID nullUUID = new UUID(0,0);
238 UUID platformUUID = nullUUID;
239 UUID tokenSpaceGuid = null;
240 int tokenIndex = 0;
241 Token token = null;
242 Token.PCD_TYPE pcdType = Token.PCD_TYPE.UNKNOWN;
243 UsageInstance usageInstance = null;
244 String packageFullPath = null;
245
246 //
247 // Query PCD information from library's document.
248 //
249 docMap = GlobalData.getDoc(libraryName);
250 SurfaceAreaQuery.setDoc(docMap);
251 libPcdDataArray = SurfaceAreaQuery.getModulePCDTokenArray();
252
253 if(libPcdDataArray == null) {
254 return;
255 }
256
257 for(tokenIndex = 0; tokenIndex < libPcdDataArray.length; tokenIndex ++) {
258 tokenSpaceGuid =((UUID)libPcdDataArray[tokenIndex][2] == null) ?
259 nullUUID :(UUID)libPcdDataArray[tokenIndex][2];
260
261 //
262 // Get token from memory database. The token must be created from FPD already.
263 //
264 primaryKeyString = Token.getPrimaryKeyString((String)libPcdDataArray[tokenIndex][0],
265 tokenSpaceGuid,
266 platformUUID
267 );
268
269 if(dbManager.isTokenInDatabase(primaryKeyString)) {
270 token = dbManager.getTokenByKey(primaryKeyString);
271 } else {
272 throw new EntityException("The PCD token " + primaryKeyString +
273 " defined in module " + moduleName +
274 " does not exist in FPD file!");
275 }
276
277 //
278 // Create usage instance for module.
279 //
280 pcdType = Token.getpcdTypeFromString((String)libPcdDataArray[tokenIndex][1]);
281 usageInstance = new UsageInstance(token,
282 Token.PCD_USAGE.ALWAYS_CONSUMED,
283 pcdType,
284 CommonDefinition.getComponentType(parentcomponentType),
285 libPcdDataArray[tokenIndex][3],
286 null,
287 (String) libPcdDataArray[tokenIndex][5],
288 "",
289 moduleName,
290 packageName,
291 true);
292 if(Token.PCD_USAGE.UNKNOWN == token.isUsageInstanceExist(moduleName)) {
293 token.addUsageInstance(usageInstance);
294
295 packageFullPath = this.workspacePath + File.separator +
296 GlobalData.getPackagePath(packageName) +
297 packageName + ".spd";
298 updateTokenBySPD(usageInstance, packageFullPath);
299 }
300
301 //
302 // We need create second usage instance for inherited case, which
303 // add library as an usage instance, because when build a module, and
304 // if module inherited from base library, then build process will build
305 // library at first.
306 //
307 if(Token.PCD_USAGE.UNKNOWN == token.isUsageInstanceExist(libraryName)) {
308 packageName = GlobalData.getPackageNameForModule(libraryName);
309 usageInstance = new UsageInstance(token,
310 Token.PCD_USAGE.ALWAYS_CONSUMED,
311 pcdType,
312 CommonDefinition.ComponentTypeLibrary,
313 libPcdDataArray[tokenIndex][3],
314 null,
315 (String)libPcdDataArray[tokenIndex][5],
316 "",
317 libraryName,
318 packageName,
319 false);
320 token.addUsageInstance(usageInstance);
321 }
322 }
323 }
324
325 /**
326 Create usage instance for PCD token defined in MSA document
327
328 A PCD token maybe used by many modules, and every module is one of usage
329 instance of this token. For ALWAY_CONSUMED, SOMETIMES_CONSUMED, it is
330 consumer type usage instance of this token, and for ALWAYS_PRODUCED,
331 SOMETIMES_PRODUCED, it is produce type usage instance.
332
333 @param moduleName The name of module
334 @param tokenInfoInMsa The PCD token information array retrieved from MSA.
335
336 @return UsageInstance The usage instance created in memroy database.
337
338 @throws EntityException If token did not exist in database yet.
339
340 **/
341 private UsageInstance createUsageInstanceFromMSA(String moduleName,
342 Object[] tokenInfoInMsa)
343 throws EntityException {
344 String packageName = null;
345 UsageInstance usageInstance = null;
346 UUID tokenSpaceGuid = null;
347 UUID nullUUID = new UUID(0,0);
348 String primaryKeyString = null;
349 UUID platformTokenSpace = nullUUID;
350 Token token = null;
351 Token.PCD_TYPE pcdType = Token.PCD_TYPE.UNKNOWN;
352 Token.PCD_USAGE pcdUsage = Token.PCD_USAGE.UNKNOWN;
353
354 tokenSpaceGuid =((UUID)tokenInfoInMsa[2] == null) ? nullUUID :(UUID)tokenInfoInMsa[2];
355
356 primaryKeyString = Token.getPrimaryKeyString((String)tokenInfoInMsa[0],
357 tokenSpaceGuid,
358 platformTokenSpace);
359
360 //
361 // Get token object from memory database firstly.
362 //
363 if(dbManager.isTokenInDatabase(primaryKeyString)) {
364 token = dbManager.getTokenByKey(primaryKeyString);
365 } else {
366 throw new EntityException("The PCD token " + primaryKeyString + " defined in module " +
367 moduleName + " does not exist in FPD file!" );
368 }
369 pcdType = Token.getpcdTypeFromString((String)tokenInfoInMsa[1]);
370 pcdUsage = Token.getUsageFromString((String)tokenInfoInMsa[4]);
371
372 packageName = GlobalData.getPackageNameForModule(moduleName);
373
374 if(Token.PCD_USAGE.UNKNOWN != token.isUsageInstanceExist(moduleName)) {
375 //
376 // BUGBUG: It should *not* throw exception here. Becaues in MdePkg.fpd,
377 // more than on BaseLib exist. But why? need confirmation.
378 //
379 //throw new EntityException(
380 // "In module " + moduleName + " exist more than one PCD token " + token.cName
381 // );
382 ActionMessage.warning(this,
383 "In module " + moduleName + " exist more than one PCD token " + token.cName
384 );
385 return null;
386 }
387
388 //
389 // BUGBUG: following code could be enabled at current schema. Because
390 // current schema does not provide usage information.
391 //
392 // For FEATRURE_FLAG, FIXED_AT_BUILD, PATCH_IN_MODULE type PCD token, his
393 // usage is always ALWAYS_CONSUMED
394 //
395 //if((pcdType != Token.PCD_TYPE.DYNAMIC) &&
396 // (pcdType != Token.PCD_TYPE.DYNAMIC_EX)) {
397 pcdUsage = Token.PCD_USAGE.ALWAYS_CONSUMED;
398 //}
399
400 usageInstance = new UsageInstance(token,
401 pcdUsage,
402 pcdType,
403 CommonDefinition.getComponentType(SurfaceAreaQuery.getComponentType()),
404 tokenInfoInMsa[3],
405 null,
406 (String) tokenInfoInMsa[5],
407 "",
408 moduleName,
409 packageName,
410 false);
411
412 //
413 // Use default value defined in MSA to update datum of token,
414 // if datum of token does not defined in FPD file.
415 //
416 if((token.datum == null) &&(tokenInfoInMsa[3] != null)) {
417 token.datum = tokenInfoInMsa[3];
418 }
419
420 token.addUsageInstance(usageInstance);
421
422 return usageInstance;
423 }
424
425 /**
426 Create token instance object into memory database, the token information
427 comes for FPD file. Normally, FPD file will contain all token platform
428 informations.
429
430 This fucntion should be executed at firsly before others collection work
431 such as searching token information from MSA, SPD.
432
433 @return FrameworkPlatformDescriptionDocument The FPD document instance for furture usage.
434
435 @throws EntityException Failed to parse FPD xml file.
436
437 **/
438 private FrameworkPlatformDescriptionDocument createTokenInDBFromFPD()
439 throws EntityException {
440 XmlObject doc = null;
441 FrameworkPlatformDescriptionDocument fpdDoc = null;
442 int index = 0;
443 List<PcdBuildData> pcdBuildDataArray = new ArrayList<PcdBuildData>();
444 PcdBuildData pcdBuildData = null;
445 Token token = null;
446 UUID nullUUID = new UUID(0,0);
447 UUID platformTokenSpace= nullUUID;
448 List skuDataArray = new ArrayList();
449 SkuInstance skuInstance = null;
450 int skuIndex = 0;
451
452 //
453 // Get all tokens from FPD file and create token into database.
454 //
455
456 try {
457 doc = XmlObject.Factory.parse(new File(fpdFilePath));
458 } catch(IOException ioE) {
459 throw new EntityException("Can't find the FPD xml fle:" + fpdFilePath);
460 } catch(XmlException xmlE) {
461 throw new EntityException("Can't parse the FPD xml fle:" + fpdFilePath);
462 }
463
464 //
465 // Get memoryDatabaseManager instance from GlobalData.
466 //
467 if((dbManager = GlobalData.getPCDMemoryDBManager()) == null) {
468 throw new EntityException("The instance of PCD memory database manager is null");
469 }
470
471 dbManager = new MemoryDatabaseManager();
472
473 if(!(doc instanceof FrameworkPlatformDescriptionDocument)) {
474 throw new EntityException("File " + fpdFilePath +
475 " is not a FrameworkPlatformDescriptionDocument");
476 }
477
478 fpdDoc =(FrameworkPlatformDescriptionDocument)doc;
479
480 //
481 // Add all tokens in FPD into Memory Database.
482 //
483 pcdBuildDataArray =
484 fpdDoc.getFrameworkPlatformDescription().getPcdBuildDeclarations().getPcdBuildDataList();
485 for(index = 0;
486 index < fpdDoc.getFrameworkPlatformDescription().getPcdBuildDeclarations().sizeOfPcdBuildDataArray();
487 index ++) {
488 pcdBuildData = pcdBuildDataArray.get(index);
489 token = new Token(pcdBuildData.getCName(), new UUID(0, 0), new UUID(0, 0));
490 //
491 // BUGBUG: in FPD, <defaultValue> should be defined as <Value>
492 //
493 token.datum = pcdBuildData.getDefaultValue();
494 token.hiiEnabled = pcdBuildData.getHiiEnable();
495 token.variableGuid = Token.getGUIDFromSchemaObject(pcdBuildData.getVariableGuid());
496 token.variableName = pcdBuildData.getVariableName();
497 token.variableOffset = Integer.decode(pcdBuildData.getDataOffset());
498 token.skuEnabled = pcdBuildData.getSkuEnable();
499 token.maxSkuCount = Integer.decode(pcdBuildData.getMaxSku());
500 token.skuId = Integer.decode(pcdBuildData.getSkuId());
501 token.skuDataArrayEnabled = pcdBuildData.getSkuDataArrayEnable();
502 token.assignedtokenNumber = Integer.decode(pcdBuildData.getToken().getStringValue());
503 skuDataArray = pcdBuildData.getSkuDataArray1();
504 token.datumType = Token.getdatumTypeFromString(pcdBuildData.getDatumType().toString());
505
506 if(skuDataArray != null) {
507 for(skuIndex = 0; skuIndex < skuDataArray.size(); skuIndex ++) {
508 //
509 // BUGBUG: Now in current schema, The value is defined as String type,
510 // it is not correct, the type should be same as the datumType
511 //
512 skuInstance = new SkuInstance(((PcdBuildData.SkuData)skuDataArray.get(skuIndex)).getId(),
513 ((PcdBuildData.SkuData)skuDataArray.get(skuIndex)).getValue());
514 token.skuData.add(skuInstance);
515 }
516 }
517
518 if(dbManager.isTokenInDatabase(Token.getPrimaryKeyString(token.cName,
519 token.tokenSpaceName,
520 platformTokenSpace))) {
521 //
522 // If found duplicate token, Should tool be hold?
523 //
524 ActionMessage.warning(this,
525 "Token " + token.cName + " exists in token database");
526 continue;
527 }
528 token.pcdType = Token.getpcdTypeFromString(pcdBuildData.getItemType().toString());
529 dbManager.addTokenToDatabase(Token.getPrimaryKeyString(token.cName,
530 token.tokenSpaceName,
531 platformTokenSpace),
532 token);
533 }
534
535 return fpdDoc;
536 }
537
538 /**
539 Update PCD token in memory database by help information in SPD.
540
541 After create token from FPD and create usage instance from MSA, we should collect
542 PCD package level information from SPD and update token information in memory
543 database.
544
545 @param usageInstance The usage instance defined in MSA and want to search in SPD.
546 @param packageFullPath The SPD file path.
547
548 @throws EntityException Failed to parse SPD xml file.
549
550 **/
551 private void updateTokenBySPD(UsageInstance usageInstance,
552 String packageFullPath)
553 throws EntityException {
554 PackageSurfaceAreaDocument pkgDoc = null;
555 PcdDefinitions pcdDefinitions = null;
556 List<PcdDefinitions.PcdEntry> pcdEntryArray = new ArrayList<PcdDefinitions.PcdEntry>();
557 int index = 0;
558 boolean isFoundInSpd = false;
559 Token.DATUM_TYPE datumType = Token.DATUM_TYPE.UNKNOWN;
560
561 try {
562 pkgDoc =(PackageSurfaceAreaDocument)XmlObject.Factory.parse(new File(packageFullPath));
563 } catch(IOException ioE) {
564 throw new EntityException("Can't find the FPD xml fle:" + packageFullPath);
565 } catch(XmlException xmlE) {
566 throw new EntityException("Can't parse the FPD xml fle:" + packageFullPath);
567 }
568 pcdDefinitions = pkgDoc.getPackageSurfaceArea().getPcdDefinitions();
569 //
570 // It is illege for SPD file does not contains any PCD information.
571 //
572 if (pcdDefinitions == null) {
573 return;
574 }
575
576 pcdEntryArray = pcdDefinitions.getPcdEntryList();
577 if (pcdEntryArray == null) {
578 return;
579 }
580 for(index = 0; index < pcdEntryArray.size(); index ++) {
581 if(pcdEntryArray.get(index).getCName().equalsIgnoreCase(
582 usageInstance.parentToken.cName)) {
583 isFoundInSpd = true;
584 //
585 // From SPD file , we can get following information.
586 // Token: Token number defined in package level.
587 // PcdItemType: This item does not single one. It means all supported item type.
588 // datumType: UINT8, UNIT16, UNIT32, UINT64, VOID*, BOOLEAN
589 // datumSize: The size of default value or maxmine size.
590 // defaultValue: This value is defined in package level.
591 // HelpText: The help text is provided in package level.
592 //
593
594 usageInstance.parentToken.tokenNumber = Integer.decode(pcdEntryArray.get(index).getToken());
595
596 if(pcdEntryArray.get(index).getDatumType() != null) {
597 datumType = Token.getdatumTypeFromString(
598 pcdEntryArray.get(index).getDatumType().toString());
599 if(usageInstance.parentToken.datumType == Token.DATUM_TYPE.UNKNOWN) {
600 usageInstance.parentToken.datumType = datumType;
601 } else {
602 if(datumType != usageInstance.parentToken.datumType) {
603 throw new EntityException("Different datum types are defined for Token :" +
604 usageInstance.parentToken.cName);
605 }
606 }
607
608 } else {
609 throw new EntityException("The datum type for token " + usageInstance.parentToken.cName +
610 " is not defind in SPD file " + packageFullPath);
611 }
612
613 usageInstance.defaultValueInSPD = pcdEntryArray.get(index).getDefaultValue();
614 usageInstance.helpTextInSPD = "Help Text in SPD";
615
616 //
617 // If token's datum is not valid, it indicate that datum is not provided
618 // in FPD and defaultValue is not provided in MSA, then use defaultValue
619 // in SPD as the datum of token.
620 //
621 if(usageInstance.parentToken.datum == null) {
622 if(pcdEntryArray.get(index).getDefaultValue() != null) {
623 usageInstance.parentToken.datum = pcdEntryArray.get(index).getDefaultValue();
624 } else {
625 throw new EntityException("FPD does not provide datum for token " + usageInstance.parentToken.cName +
626 ", MSA and SPD also does not provide <defaultValue> for this token!");
627 }
628 }
629 }
630 }
631 }
632
633 /**
634 check parameter for this action.
635
636 @throws EntityException Bad parameter.
637 **/
638 private void checkParameter() throws EntityException {
639 File file = null;
640
641 if((fpdFilePath == null) ||(workspacePath == null)) {
642 throw new EntityException("WorkspacePath and FPDFileName should be blank for CollectPCDAtion!");
643 }
644
645 if(fpdFilePath.length() == 0 || workspacePath.length() == 0) {
646 throw new EntityException("WorkspacePath and FPDFileName should be blank for CollectPCDAtion!");
647 }
648
649 file = new File(workspacePath);
650 if(!file.exists()) {
651 throw new EntityException("WorkpacePath " + workspacePath + " does not exist!");
652 }
653
654 file = new File(fpdFilePath);
655
656 if(!file.exists()) {
657 throw new EntityException("FPD File " + fpdFilePath + " does not exist!");
658 }
659 }
660
661 /**
662 Test case function
663
664 @param argv parameter from command line
665 **/
666 public static void main(String argv[]) throws EntityException {
667 CollectPCDAction ca = new CollectPCDAction();
668 ca.setWorkspacePath("G:/mdk");
669 ca.setFPDFilePath("G:/mdk/EdkNt32Pkg/build/Nt32.fpd");
670 ca.setActionMessageLevel(ActionMessage.MAX_MESSAGE_LEVEL);
671 GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db",
672 "G:/mdk");
673 ca.execute();
674 }
675 }