3 The file is used to init workspace and get basic information of workspace
5 Copyright (c) 2006, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 package org
.tianocore
.frameworkwizard
.workspace
;
18 import java
.io
.IOException
;
19 import java
.util
.List
;
20 import java
.util
.Vector
;
22 import org
.apache
.xmlbeans
.XmlCursor
;
23 import org
.apache
.xmlbeans
.XmlException
;
24 import org
.tianocore
.DbPathAndFilename
;
25 import org
.tianocore
.IndustryStdIncludesDocument
.IndustryStdIncludes
;
26 import org
.tianocore
.LibraryClassDeclarationsDocument
.LibraryClassDeclarations
;
27 import org
.tianocore
.LibraryClassDefinitionsDocument
.LibraryClassDefinitions
;
28 import org
.tianocore
.ModuleSurfaceAreaDocument
.ModuleSurfaceArea
;
29 import org
.tianocore
.MsaFilesDocument
.MsaFiles
;
30 import org
.tianocore
.PackageDependenciesDocument
.PackageDependencies
;
31 import org
.tianocore
.PackageSurfaceAreaDocument
.PackageSurfaceArea
;
32 import org
.tianocore
.PlatformSurfaceAreaDocument
.PlatformSurfaceArea
;
33 import org
.tianocore
.SourceFilesDocument
.SourceFiles
;
34 import org
.tianocore
.frameworkwizard
.common
.DataType
;
35 import org
.tianocore
.frameworkwizard
.common
.GlobalData
;
36 import org
.tianocore
.frameworkwizard
.common
.Log
;
37 import org
.tianocore
.frameworkwizard
.common
.OpenFile
;
38 import org
.tianocore
.frameworkwizard
.common
.SaveFile
;
39 import org
.tianocore
.frameworkwizard
.common
.Sort
;
40 import org
.tianocore
.frameworkwizard
.common
.Tools
;
41 import org
.tianocore
.frameworkwizard
.common
.Identifications
.Identification
;
42 import org
.tianocore
.frameworkwizard
.far
.FarHeader
;
43 import org
.tianocore
.frameworkwizard
.far
.FarIdentification
;
44 import org
.tianocore
.frameworkwizard
.module
.Identifications
.ModuleIdentification
;
45 import org
.tianocore
.frameworkwizard
.module
.Identifications
.PcdCoded
.PcdIdentification
;
46 import org
.tianocore
.frameworkwizard
.module
.Identifications
.PcdCoded
.PcdVector
;
47 import org
.tianocore
.frameworkwizard
.packaging
.PackageIdentification
;
48 import org
.tianocore
.frameworkwizard
.platform
.PlatformIdentification
;
50 public class WorkspaceTools
{
52 public void addFarToDb(List
<String
> packageList
, List
<String
> platformList
, FarHeader far
) {
53 //FrameworkDatabase fdb = openFrameworkDb();
55 for (int i
= 0; i
< packageList
.size(); i
++) {
56 DbPathAndFilename item
= DbPathAndFilename
.Factory
.newInstance();
57 item
.setFarGuid(far
.getGuidValue());
58 item
.setStringValue(packageList
.get(i
));
59 GlobalData
.fdb
.getPackageList().getFilenameList().add(item
);
62 for (int i
= 0; i
< platformList
.size(); i
++) {
63 DbPathAndFilename item
= DbPathAndFilename
.Factory
.newInstance();
64 item
.setFarGuid(far
.getGuidValue());
65 item
.setStringValue(platformList
.get(i
));
66 GlobalData
.fdb
.getPlatformList().getFilenameList().add(item
);
69 DbPathAndFilename farItem
= DbPathAndFilename
.Factory
.newInstance();
70 farItem
.setFarGuid(far
.getGuidValue());
71 farItem
.setStringValue(far
.getFarName());
72 GlobalData
.fdb
.getFarList().getFilenameList().add(farItem
);
74 String strFrameworkDbFilePath
= Workspace
.getCurrentWorkspace() + Workspace
.getStrWorkspaceDatabaseFile();
75 strFrameworkDbFilePath
= Tools
.convertPathToCurrentOsType(strFrameworkDbFilePath
);
78 SaveFile
.saveDbFile(strFrameworkDbFilePath
, GlobalData
.fdb
);
79 } catch (Exception e
) {
80 Log
.err("Save Database File", e
.getMessage());
84 public void removeFarFromDb(FarIdentification far
) {
88 XmlCursor cursor
= GlobalData
.fdb
.getPackageList().newCursor();
89 cursor
.toFirstChild();
91 DbPathAndFilename item
= (DbPathAndFilename
) cursor
.getObject();
93 if (item
.getFarGuid() != null && item
.getFarGuid().equalsIgnoreCase(far
.getGuid())) {
96 } while (cursor
.toNextSibling());
102 cursor
= GlobalData
.fdb
.getPlatformList().newCursor();
103 cursor
.toFirstChild();
105 DbPathAndFilename item
= (DbPathAndFilename
) cursor
.getObject();
106 if (item
.getFarGuid() != null && item
.getFarGuid().equalsIgnoreCase(far
.getGuid())) {
109 } while (cursor
.toNextSibling());
114 cursor
= GlobalData
.fdb
.getFarList().newCursor();
115 cursor
.toFirstChild();
117 DbPathAndFilename item
= (DbPathAndFilename
) cursor
.getObject();
118 if (item
.getFarGuid() != null && item
.getFarGuid().equalsIgnoreCase(far
.getGuid())) {
121 } while (cursor
.toNextSibling());
124 String strFrameworkDbFilePath
= Workspace
.getCurrentWorkspace() + Workspace
.getStrWorkspaceDatabaseFile();
125 strFrameworkDbFilePath
= Tools
.convertPathToCurrentOsType(strFrameworkDbFilePath
);
127 SaveFile
.saveDbFile(strFrameworkDbFilePath
, GlobalData
.fdb
);
128 } catch (Exception e
) {
129 Log
.err("Save Database File", e
.getMessage());
133 public String
getPackageFarGuid(Identification packageId
) {
134 for (int index
= 0; index
< GlobalData
.fdb
.getPackageList().getFilenameList().size(); index
++) {
135 DbPathAndFilename item
= GlobalData
.fdb
.getPackageList().getFilenameArray(index
);
136 String path
= Workspace
.getCurrentWorkspace() + DataType
.FILE_SEPARATOR
+ item
.getStringValue();
137 File tempFile
= new File(path
);
138 if (tempFile
.getPath().equalsIgnoreCase(packageId
.getPath())) {
139 return GlobalData
.fdb
.getPackageList().getFilenameArray(index
).getFarGuid();
146 public String
getPlatformFarGuid(Identification platformId
) {
147 for (int index
= 0; index
< GlobalData
.fdb
.getPlatformList().getFilenameList().size(); index
++) {
148 DbPathAndFilename item
= GlobalData
.fdb
.getPlatformList().getFilenameArray(index
);
149 String path
= Workspace
.getCurrentWorkspace() + DataType
.FILE_SEPARATOR
+ item
.getStringValue();
150 File tempFile
= new File(path
);
151 if (tempFile
.getPath().equalsIgnoreCase(platformId
.getPath())) {
152 return GlobalData
.fdb
.getPlatformList().getFilenameArray(index
).getFarGuid();
159 public String
getModuleFarGuid(Identification moduleId
) {
160 PackageIdentification packageId
= getPackageIdByModuleId(moduleId
);
161 if (packageId
!= null) {
162 return getPackageFarGuid(packageId
);
169 Get all modules' paths from one package
171 @return a Vector with all modules' path
174 public Vector
<String
> getAllModulesOfPackage(String path
) {
175 Vector
<String
> modulePath
= new Vector
<String
>();
176 PackageIdentification id
= new PackageIdentification(null, null, null, path
);
177 MsaFiles files
= GlobalData
.openingPackageList
.getPackageSurfaceAreaFromId(id
).getMsaFiles();
179 for (int index
= 0; index
< files
.getFilenameList().size(); index
++) {
180 String msaPath
= files
.getFilenameList().get(index
);
181 msaPath
= Tools
.addFileSeparator(Tools
.getFilePathOnly(path
)) + msaPath
;
182 msaPath
= Tools
.convertPathToCurrentOsType(msaPath
);
183 modulePath
.addElement(msaPath
);
191 Get all Industry Std Includes' paths from one package
193 @return a Vector with all paths
196 public Vector
<String
> getAllIndustryStdIncludesOfPackage(String path
) {
197 Vector
<String
> includePath
= new Vector
<String
>();
198 PackageIdentification id
= new PackageIdentification(null, null, null, path
);
199 IndustryStdIncludes files
= GlobalData
.openingPackageList
.getPackageSurfaceAreaFromId(id
)
200 .getIndustryStdIncludes();
202 for (int index
= 0; index
< files
.getIndustryStdHeaderList().size(); index
++) {
203 String temp
= files
.getIndustryStdHeaderList().get(index
).getIncludeHeader();
204 temp
= Tools
.addFileSeparator(Tools
.getFilePathOnly(path
)) + temp
;
205 temp
= Tools
.convertPathToCurrentOsType(temp
);
206 includePath
.addElement(temp
);
213 Get all package basic information form the FrameworkDatabase.db file
215 @return vPackageList A vector includes all packages' basic information
218 public Vector
<PackageIdentification
> getAllPackages() {
219 return GlobalData
.vPackageList
;
222 public Vector
<FarIdentification
> getAllFars() {
224 Vector
<FarIdentification
> v
= new Vector
<FarIdentification
>();
225 for (int index
= 0; index
< GlobalData
.fdb
.getFarList().getFilenameList().size(); index
++) {
226 DbPathAndFilename item
= GlobalData
.fdb
.getFarList().getFilenameList().get(index
);
227 FarIdentification far
= new FarIdentification(item
.getFarGuid(), item
.getMd5Sum(), item
.getStringValue());
233 public Vector
<PackageIdentification
> getPackagesByFar(FarIdentification far
) {
234 Identification id
= null;
236 Vector
<PackageIdentification
> v
= new Vector
<PackageIdentification
>();
238 for (int index
= 0; index
< GlobalData
.fdb
.getPackageList().getFilenameList().size(); index
++) {
239 DbPathAndFilename item
= GlobalData
.fdb
.getPackageList().getFilenameArray(index
);
240 String path
= Workspace
.getCurrentWorkspace() + DataType
.FILE_SEPARATOR
+ item
.getStringValue();
241 path
= Tools
.convertPathToCurrentOsType(path
);
243 if (item
.getFarGuid() != null && item
.getFarGuid().equalsIgnoreCase(far
.getGuid())) {
246 id
= Tools
.getId(path
, OpenFile
.openSpdFile(path
));
247 v
.addElement(new PackageIdentification(id
));
248 } catch (IOException e
) {
249 Log
.err("Open Package Surface Area " + path
, e
.getMessage());
250 } catch (XmlException e
) {
251 Log
.err("Open Package Surface Area " + path
, e
.getMessage());
252 } catch (Exception e
) {
253 Log
.err("Open Package Surface Area " + path
, "Invalid file type");
260 public Vector
<PlatformIdentification
> getPlatformsByFar(FarIdentification far
) {
261 Identification id
= null;
263 Vector
<PlatformIdentification
> v
= new Vector
<PlatformIdentification
>();
265 for (int index
= 0; index
< GlobalData
.fdb
.getPlatformList().getFilenameList().size(); index
++) {
266 DbPathAndFilename item
= GlobalData
.fdb
.getPlatformList().getFilenameArray(index
);
267 String path
= Workspace
.getCurrentWorkspace() + DataType
.FILE_SEPARATOR
+ item
.getStringValue();
268 path
= Tools
.convertPathToCurrentOsType(path
);
270 if (item
.getFarGuid() != null && item
.getFarGuid().equalsIgnoreCase(far
.getGuid())) {
272 id
= Tools
.getId(path
, OpenFile
.openFpdFile(path
));
273 v
.addElement(new PlatformIdentification(id
));
274 } catch (IOException e
) {
275 Log
.err("Open Platform Surface Area " + path
, e
.getMessage());
276 } catch (XmlException e
) {
277 Log
.err("Open Platform Surface Area " + path
, e
.getMessage());
278 } catch (Exception e
) {
279 Log
.err("Open Platform Surface Area " + path
, "Invalid file type");
287 Get all module basic information from a package
290 @return A vector includes all modules' basic information
293 public Vector
<ModuleIdentification
> getAllModules(PackageIdentification pid
) {
294 Vector
<ModuleIdentification
> v
= new Vector
<ModuleIdentification
>();
295 Vector
<String
> modulePaths
= this.getAllModulesOfPackage(pid
.getPath());
296 String modulePath
= null;
298 for (int index
= 0; index
< modulePaths
.size(); index
++) {
299 modulePath
= modulePaths
.get(index
);
300 ModuleIdentification id
= GlobalData
.openingModuleList
.getIdByPath(modulePath
);
305 Sort
.sortModules(v
, DataType
.SORT_TYPE_ASCENDING
);
310 Get all module basic information from a platform
313 @return A vector includes all modules' basic information
316 public Vector
<ModuleIdentification
> getAllModules(PlatformIdentification fid
) {
317 Vector
<ModuleIdentification
> v
= new Vector
<ModuleIdentification
>();
318 PlatformSurfaceArea fpd
= GlobalData
.openingPlatformList
.getOpeningPlatformById(fid
).getXmlFpd();
319 if (fpd
.getFrameworkModules() != null) {
320 for (int index
= 0; index
< fpd
.getFrameworkModules().getModuleSAList().size(); index
++) {
321 String guid
= fpd
.getFrameworkModules().getModuleSAList().get(index
).getModuleGuid();
322 String version
= fpd
.getFrameworkModules().getModuleSAList().get(index
).getModuleVersion();
323 ModuleIdentification id
= GlobalData
.openingModuleList
.getIdByGuidVersion(guid
, version
);
325 boolean isFind
= false;
326 for (int indexOfModules
= 0; indexOfModules
< v
.size(); indexOfModules
++) {
327 if (v
.elementAt(indexOfModules
).equals(id
)) {
338 Sort
.sortModules(v
, DataType
.SORT_TYPE_ASCENDING
);
343 Get all module basic information form the FrameworkDatabase.db file
345 @return vModuleList A vector includes all modules' basic information
348 public Vector
<ModuleIdentification
> getAllModules() {
349 return GlobalData
.vModuleList
;
353 Get all platform basic information form the FrameworkDatabase.db file
355 @return vplatformList A vector includes all platforms' basic information
358 public Vector
<PlatformIdentification
> getAllPlatforms() {
359 return GlobalData
.vPlatformList
;
363 Get all Library Class Definitions from a package
367 public Vector
<String
> getAllLibraryClassDefinitionsFromPackage(PackageSurfaceArea spd
) {
368 Vector
<String
> vector
= new Vector
<String
>();
369 if (spd
.getLibraryClassDeclarations() != null) {
370 if (spd
.getLibraryClassDeclarations().getLibraryClassList().size() > 0) {
371 for (int index
= 0; index
< spd
.getLibraryClassDeclarations().getLibraryClassList().size(); index
++) {
372 vector
.addElement(spd
.getLibraryClassDeclarations().getLibraryClassList().get(index
).getName());
376 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
381 Get all Protocol Definitions from a package
385 public Vector
<String
> getAllProtocolDeclarationsFromPackage(PackageSurfaceArea spd
) {
386 Vector
<String
> vector
= new Vector
<String
>();
387 if (spd
.getProtocolDeclarations() != null) {
388 if (spd
.getProtocolDeclarations().getEntryList().size() > 0) {
389 for (int index
= 0; index
< spd
.getProtocolDeclarations().getEntryList().size(); index
++) {
390 vector
.addElement(spd
.getProtocolDeclarations().getEntryList().get(index
).getCName());
394 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
399 Get all Ppi Definitions from a package
403 public Vector
<String
> getAllPpiDeclarationsFromPackage(PackageSurfaceArea spd
) {
404 Vector
<String
> vector
= new Vector
<String
>();
405 if (spd
.getPpiDeclarations() != null) {
406 if (spd
.getPpiDeclarations().getEntryList().size() > 0) {
407 for (int index
= 0; index
< spd
.getPpiDeclarations().getEntryList().size(); index
++) {
408 vector
.addElement(spd
.getPpiDeclarations().getEntryList().get(index
).getCName());
412 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
417 Get all Guid Definitions from a package
421 public Vector
<String
> getAllGuidDeclarationsFromPackage(PackageSurfaceArea spd
, String type
) {
422 Vector
<String
> vector
= new Vector
<String
>();
423 boolean isFound
= false;
424 if (spd
.getGuidDeclarations() != null) {
425 if (spd
.getGuidDeclarations().getEntryList().size() > 0) {
426 for (int index
= 0; index
< spd
.getGuidDeclarations().getEntryList().size(); index
++) {
427 Vector
<String
> vArch
= Tools
.convertListToVector(spd
.getGuidDeclarations().getEntryList()
428 .get(index
).getGuidTypeList());
429 for (int indexOfArch
= 0; indexOfArch
< vArch
.size(); indexOfArch
++) {
430 if (vArch
.get(indexOfArch
).equals(type
)) {
435 if ((isFound
) || (vArch
== null) || (vArch
.size() < 1)) {
436 vector
.addElement(spd
.getGuidDeclarations().getEntryList().get(index
).getCName());
442 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
447 Get all Pcd Definitions from a package
451 public PcdVector
getAllPcdDeclarationsFromPackage(PackageSurfaceArea spd
) {
452 PcdVector vector
= new PcdVector();
453 if (spd
.getPcdDeclarations() != null) {
454 if (spd
.getPcdDeclarations().getPcdEntryList().size() > 0) {
455 for (int index
= 0; index
< spd
.getPcdDeclarations().getPcdEntryList().size(); index
++) {
456 String name
= spd
.getPcdDeclarations().getPcdEntryList().get(index
).getCName();
457 String guidCName
= spd
.getPcdDeclarations().getPcdEntryList().get(index
).getTokenSpaceGuidCName();
458 String help
= spd
.getPcdDeclarations().getPcdEntryList().get(index
).getHelpText();
459 Vector
<String
> type
= Tools
.convertListToVector(spd
.getPcdDeclarations().getPcdEntryList()
460 .get(index
).getValidUsage());
462 // The algorithm for PCD of msa should be:
463 // 1. If the type of PCD from Spd is FEATURE_FLAG,
464 // the type of Msa only can be FEATURE_FLAG.
465 // 2. If the type of PCD from Spd is not FEATURE_FLAG,
466 // the type of Msa could be selected from the PCD's all types and "DYNAMIC" type.
468 boolean hasFEATURE_FLAG
= false;
469 boolean hasDYNAMIC
= false;
470 for (int indexOfType
= 0; indexOfType
< type
.size(); indexOfType
++) {
471 if (type
.elementAt(indexOfType
).equals(DataType
.PCD_ITEM_TYPE_DYNAMIC
)) {
474 if(type
.elementAt(indexOfType
).equals(DataType
.PCD_ITEM_TYPE_FEATURE_FLAG
)) {
475 hasFEATURE_FLAG
= true;
478 if (hasFEATURE_FLAG
) {
479 type
.removeAllElements();
480 type
.addElement(DataType
.PCD_ITEM_TYPE_FEATURE_FLAG
);
483 type
.addElement(DataType
.PCD_ITEM_TYPE_DYNAMIC
);
486 vector
.addPcd(new PcdIdentification(name
, guidCName
, help
, type
));
490 Sort
.sortPcds(vector
, DataType
.SORT_TYPE_ASCENDING
);
494 public Vector
<String
> getAllLibraryClassDefinitionsFromWorkspace() {
495 Vector
<String
> vector
= new Vector
<String
>();
496 for (int index
= 0; index
< GlobalData
.vPackageList
.size(); index
++) {
497 Vector
<String
> v
= getAllLibraryClassDefinitionsFromPackage(GlobalData
.openingPackageList
498 .getPackageSurfaceAreaFromId(GlobalData
.vPackageList
500 if (v
!= null && v
.size() > 0) {
505 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
509 public Vector
<String
> getAllLibraryClassDefinitionsFromPackages(Vector
<PackageIdentification
> vpid
) {
510 Vector
<String
> vector
= new Vector
<String
>();
511 for (int index
= 0; index
< vpid
.size(); index
++) {
512 Vector
<String
> v
= getAllLibraryClassDefinitionsFromPackage(GlobalData
.openingPackageList
513 .getPackageSurfaceAreaFromId(vpid
515 if (v
!= null && v
.size() > 0) {
520 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
524 public Vector
<String
> getAllProtocolDeclarationsFromWorkspace() {
525 Vector
<String
> vector
= new Vector
<String
>();
526 for (int index
= 0; index
< GlobalData
.vPackageList
.size(); index
++) {
527 Vector
<String
> v
= getAllProtocolDeclarationsFromPackage(GlobalData
.openingPackageList
528 .getPackageSurfaceAreaFromId(GlobalData
.vPackageList
530 if (v
!= null && v
.size() > 0) {
534 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
538 public Vector
<String
> getAllProtocolDeclarationsFromPackages(Vector
<PackageIdentification
> vpid
) {
539 Vector
<String
> vector
= new Vector
<String
>();
540 for (int index
= 0; index
< vpid
.size(); index
++) {
541 Vector
<String
> v
= getAllProtocolDeclarationsFromPackage(GlobalData
.openingPackageList
542 .getPackageSurfaceAreaFromId(vpid
544 if (v
!= null && v
.size() > 0) {
548 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
552 public Vector
<String
> getAllPpiDeclarationsFromWorkspace() {
553 Vector
<String
> vector
= new Vector
<String
>();
554 for (int index
= 0; index
< GlobalData
.vPackageList
.size(); index
++) {
555 Vector
<String
> v
= getAllPpiDeclarationsFromPackage(GlobalData
.openingPackageList
556 .getPackageSurfaceAreaFromId(GlobalData
.vPackageList
558 if (v
!= null && v
.size() > 0) {
562 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
566 public Vector
<String
> getAllPpiDeclarationsFromPackages(Vector
<PackageIdentification
> vpid
) {
567 Vector
<String
> vector
= new Vector
<String
>();
568 for (int index
= 0; index
< vpid
.size(); index
++) {
569 Vector
<String
> v
= getAllPpiDeclarationsFromPackage(GlobalData
.openingPackageList
570 .getPackageSurfaceAreaFromId(vpid
572 if (v
!= null && v
.size() > 0) {
576 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
580 public Vector
<String
> getAllGuidDeclarationsFromWorkspace(String type
) {
581 Vector
<String
> vector
= new Vector
<String
>();
582 for (int index
= 0; index
< GlobalData
.vPackageList
.size(); index
++) {
583 Vector
<String
> v
= getAllGuidDeclarationsFromPackage(
584 GlobalData
.openingPackageList
585 .getPackageSurfaceAreaFromId(GlobalData
.vPackageList
588 if (v
!= null && v
.size() > 0) {
593 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
597 public Vector
<String
> getAllGuidDeclarationsFromPackages(Vector
<PackageIdentification
> vpid
, String type
) {
598 Vector
<String
> vector
= new Vector
<String
>();
599 for (int index
= 0; index
< vpid
.size(); index
++) {
600 Vector
<String
> v
= getAllGuidDeclarationsFromPackage(
601 GlobalData
.openingPackageList
602 .getPackageSurfaceAreaFromId(vpid
605 if (v
!= null && v
.size() > 0) {
610 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
614 public PcdVector
getAllPcdDeclarationsFromWorkspace() {
615 PcdVector vector
= new PcdVector();
616 for (int index
= 0; index
< GlobalData
.openingPackageList
.size(); index
++) {
617 PcdVector v
= getAllPcdDeclarationsFromPackage(GlobalData
.openingPackageList
618 .getPackageSurfaceAreaFromId(GlobalData
.vPackageList
620 if (v
!= null && v
.size() > 0) {
625 Sort
.sortPcds(vector
, DataType
.SORT_TYPE_ASCENDING
);
629 public PcdVector
getAllPcdDeclarationsFromPackages(Vector
<PackageIdentification
> vpid
) {
630 PcdVector vector
= new PcdVector();
631 for (int index
= 0; index
< vpid
.size(); index
++) {
632 PcdVector v
= getAllPcdDeclarationsFromPackage(GlobalData
.openingPackageList
633 .getPackageSurfaceAreaFromId(vpid
635 if (v
!= null && v
.size() > 0) {
640 Sort
.sortPcds(vector
, DataType
.SORT_TYPE_ASCENDING
);
645 Find a module's package's id
647 @param id input module id
651 public PackageIdentification
getPackageIdByModuleId(Identification id
) {
652 Vector
<String
> modulePaths
= new Vector
<String
>();
653 Identification mid
= null;
654 String packagePath
= null;
655 String modulePath
= null;
658 // For each package, get all modules list
660 for (int indexI
= 0; indexI
< GlobalData
.vPackageList
.size(); indexI
++) {
661 packagePath
= GlobalData
.vPackageList
.elementAt(indexI
).getPath();
662 modulePaths
= this.getAllModulesOfPackage(packagePath
);
663 for (int indexJ
= 0; indexJ
< modulePaths
.size(); indexJ
++) {
664 modulePath
= modulePaths
.get(indexJ
);
665 mid
= GlobalData
.openingModuleList
.getIdByPath(modulePath
);
669 if (mid
.equals(id
)) {
670 return GlobalData
.vPackageList
.elementAt(indexI
);
680 Add module information to package surface area
688 public void addModuleToPackage(ModuleIdentification mid
, PackageSurfaceArea spd
) throws IOException
, XmlException
,
690 String packagePath
= mid
.getPackageId().getPath();
691 String modulePath
= mid
.getPath();
693 spd
= OpenFile
.openSpdFile(packagePath
);
695 MsaFiles msaFile
= spd
.getMsaFiles();
696 if (msaFile
== null) {
697 msaFile
= MsaFiles
.Factory
.newInstance();
699 packagePath
= packagePath
.substring(0, packagePath
.lastIndexOf(DataType
.FILE_SEPARATOR
));
700 String fn
= Tools
.getRelativePath(modulePath
, packagePath
);
701 msaFile
.addNewFilename();
702 msaFile
.setFilenameArray(msaFile
.getFilenameList().size() - 1, fn
);
703 spd
.setMsaFiles(msaFile
);
704 SaveFile
.saveSpdFile(mid
.getPackageId().getPath(), spd
);
708 GlobalData
.openingPackageList
.getPackageSurfaceAreaFromId(mid
.getPackageId()).setMsaFiles(msaFile
);
712 Add input package into database
718 public void addPackageToDatabase(PackageIdentification id
) throws Exception
{
719 String path
= id
.getPath();
720 path
= Tools
.getRelativePath(path
, Workspace
.getCurrentWorkspace());
722 DbPathAndFilename filename
= DbPathAndFilename
.Factory
.newInstance();
723 filename
.setStringValue(path
);
724 GlobalData
.fdb
.getPackageList().addNewFilename();
725 GlobalData
.fdb
.getPackageList().setFilenameArray(GlobalData
.fdb
.getPackageList().sizeOfFilenameArray() - 1,
727 String strFrameworkDbFilePath
= Workspace
.getCurrentWorkspace() + Workspace
.getStrWorkspaceDatabaseFile();
728 strFrameworkDbFilePath
= Tools
.convertPathToCurrentOsType(strFrameworkDbFilePath
);
729 SaveFile
.saveDbFile(strFrameworkDbFilePath
, GlobalData
.fdb
);
733 Add input package into database
739 public void addPlatformToDatabase(PlatformIdentification id
) throws Exception
{
740 String path
= id
.getPath();
741 path
= Tools
.getRelativePath(path
, Workspace
.getCurrentWorkspace());
743 DbPathAndFilename filename
= DbPathAndFilename
.Factory
.newInstance();
744 filename
.setStringValue(path
);
745 GlobalData
.fdb
.getPlatformList().addNewFilename();
746 GlobalData
.fdb
.getPlatformList().setFilenameArray(GlobalData
.fdb
.getPlatformList().sizeOfFilenameArray() - 1,
748 String strFrameworkDbFilePath
= Workspace
.getCurrentWorkspace() + Workspace
.getStrWorkspaceDatabaseFile();
749 strFrameworkDbFilePath
= Tools
.convertPathToCurrentOsType(strFrameworkDbFilePath
);
750 SaveFile
.saveDbFile(strFrameworkDbFilePath
, GlobalData
.fdb
);
754 Get all file's path from one module
763 public Vector
<String
> getAllFilesPathOfModule(String path
) {
764 Vector
<String
> v
= new Vector
<String
>();
765 path
= Tools
.convertPathToCurrentOsType(path
);
768 // First add msa file's path
772 ModuleSurfaceArea msa
= GlobalData
.openingModuleList
773 .getModuleSurfaceAreaFromId(GlobalData
.openingModuleList
776 // Get common defined files of module
780 // Get all files' path of a module
782 SourceFiles sf
= msa
.getSourceFiles();
784 for (int index
= 0; index
< sf
.getFilenameList().size(); index
++) {
785 String temp
= sf
.getFilenameList().get(index
).getStringValue();
786 temp
= Tools
.addFileSeparator(Tools
.getFilePathOnly(path
)) + temp
;
787 v
.addElement(Tools
.convertPathToCurrentOsType(temp
));
793 // Get include header files for this module
795 if (msa
.getLibraryClassDefinitions() != null) {
796 LibraryClassDefinitions lcd
= msa
.getLibraryClassDefinitions();
797 for (int index
= 0; index
< lcd
.sizeOfLibraryClassArray(); index
++) {
798 if (lcd
.getLibraryClassList().get(index
).getUsage().toString()
799 .equals(DataType
.USAGE_TYPE_ALWAYS_PRODUCED
)
800 || lcd
.getLibraryClassList().get(index
).getUsage().toString()
801 .equals(DataType
.USAGE_TYPE_SOMETIMES_PRODUCED
)) {
803 // Get library class name
805 String name
= lcd
.getLibraryClassList().get(index
).getKeyword();
808 // Find file path for this class
810 PackageIdentification pid
= GlobalData
.openingModuleList
.getIdByPath(path
).getPackageId();
811 PackageSurfaceArea spd
= GlobalData
.openingPackageList
.getPackageSurfaceAreaFromId(pid
);
813 if (spd
.getLibraryClassDeclarations() != null) {
814 LibraryClassDeclarations lcdl
= spd
.getLibraryClassDeclarations();
815 for (int indexOfLibOfSpd
= 0; indexOfLibOfSpd
< lcdl
.sizeOfLibraryClassArray(); indexOfLibOfSpd
++) {
816 if (lcdl
.getLibraryClassList().get(indexOfLibOfSpd
).getName().equals(name
)) {
817 v
.addElement(Tools
.convertPathToCurrentOsType(Tools
.getFilePathOnly(pid
.getPath())
818 + DataType
.FILE_SEPARATOR
819 + lcdl
.getLibraryClassList()
820 .get(indexOfLibOfSpd
)
821 .getIncludeHeader()));
834 Get all file's path from one package
843 public Vector
<String
> getAllFilesPathOfPakcage(String path
) {
844 Vector
<String
> v
= new Vector
<String
>();
845 path
= Tools
.convertPathToCurrentOsType(path
);
852 // Add the package's industry std includes one by one
854 Vector
<String
> f1
= new Vector
<String
>();
855 f1
= getAllIndustryStdIncludesOfPackage(path
);
856 for (int index
= 0; index
< f1
.size(); index
++) {
857 v
.addElement(f1
.get(index
));
861 // Add module's files one by one
863 f1
= new Vector
<String
>();
864 f1
= getAllModulesOfPackage(path
);
865 for (int indexI
= 0; indexI
< f1
.size(); indexI
++) {
866 Vector
<String
> f2
= getAllFilesPathOfModule(f1
.get(indexI
));
867 for (int indexJ
= 0; indexJ
< f2
.size(); indexJ
++) {
868 v
.addElement(f2
.get(indexJ
));
876 Get a module's all package dependencies
878 @param mid The module id
879 @return A vector of all package dependency ids
882 public Vector
<PackageIdentification
> getPackageDependenciesOfModule(ModuleIdentification mid
) {
883 Vector
<PackageIdentification
> vpid
= new Vector
<PackageIdentification
>();
884 ModuleSurfaceArea msa
= GlobalData
.openingModuleList
.getModuleSurfaceAreaFromId(mid
);
886 PackageDependencies pd
= msa
.getPackageDependencies();
888 for (int index
= 0; index
< pd
.getPackageList().size(); index
++) {
889 String guid
= pd
.getPackageList().get(index
).getPackageGuid();
890 String version
= pd
.getPackageList().get(index
).getPackageVersion();
891 PackageIdentification pid
= GlobalData
.openingPackageList
.getIdByGuidVersion(guid
, version
);
893 vpid
.addElement(pid
);
901 public Vector
<String
> getAllModuleGuidXref() {
902 Vector
<String
> v
= new Vector
<String
>();
903 for (int index
= 0; index
< GlobalData
.openingModuleList
.size(); index
++) {
904 ModuleIdentification id
= GlobalData
.openingModuleList
.getOpeningModuleByIndex(index
).getId();
905 v
.addElement(id
.getGuid() + " " + id
.getName());
910 public Vector
<String
> getModuleArch(ModuleIdentification id
) {
911 Vector
<String
> v
= new Vector
<String
>();
912 ModuleSurfaceArea msa
= null;
914 msa
= GlobalData
.openingModuleList
.getModuleSurfaceAreaFromId(id
);
917 if (msa
.getModuleDefinitions() != null) {
918 v
= Tools
.convertListToVector(msa
.getModuleDefinitions().getSupportedArchitectures());