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
.common
.Identifications
.OpeningPackageType
;
43 import org
.tianocore
.frameworkwizard
.far
.FarHeader
;
44 import org
.tianocore
.frameworkwizard
.far
.FarIdentification
;
45 import org
.tianocore
.frameworkwizard
.module
.Identifications
.ModuleIdentification
;
46 import org
.tianocore
.frameworkwizard
.module
.Identifications
.PcdCoded
.PcdIdentification
;
47 import org
.tianocore
.frameworkwizard
.module
.Identifications
.PcdCoded
.PcdVector
;
48 import org
.tianocore
.frameworkwizard
.packaging
.PackageIdentification
;
49 import org
.tianocore
.frameworkwizard
.platform
.PlatformIdentification
;
51 public class WorkspaceTools
{
53 public void addFarToDb(List
<String
> packageList
, List
<String
> platformList
, FarHeader far
) {
54 //FrameworkDatabase fdb = openFrameworkDb();
56 for (int i
= 0; i
< packageList
.size(); i
++) {
57 DbPathAndFilename item
= DbPathAndFilename
.Factory
.newInstance();
58 item
.setFarGuid(far
.getGuidValue());
59 item
.setStringValue(packageList
.get(i
));
60 GlobalData
.fdb
.getPackageList().getFilenameList().add(item
);
63 for (int i
= 0; i
< platformList
.size(); i
++) {
64 DbPathAndFilename item
= DbPathAndFilename
.Factory
.newInstance();
65 item
.setFarGuid(far
.getGuidValue());
66 item
.setStringValue(platformList
.get(i
));
67 GlobalData
.fdb
.getPlatformList().getFilenameList().add(item
);
70 DbPathAndFilename farItem
= DbPathAndFilename
.Factory
.newInstance();
71 farItem
.setFarGuid(far
.getGuidValue());
72 farItem
.setStringValue(far
.getFarName());
73 GlobalData
.fdb
.getFarList().getFilenameList().add(farItem
);
75 String strFrameworkDbFilePath
= Workspace
.getCurrentWorkspace() + Workspace
.getStrWorkspaceDatabaseFile();
76 strFrameworkDbFilePath
= Tools
.convertPathToCurrentOsType(strFrameworkDbFilePath
);
79 SaveFile
.saveDbFile(strFrameworkDbFilePath
, GlobalData
.fdb
);
80 } catch (Exception e
) {
81 Log
.err("Save Database File", e
.getMessage());
85 public void removeFarFromDb(FarIdentification far
) {
89 XmlCursor cursor
= GlobalData
.fdb
.getPackageList().newCursor();
90 cursor
.toFirstChild();
92 DbPathAndFilename item
= (DbPathAndFilename
) cursor
.getObject();
94 if (item
.getFarGuid() != null && item
.getFarGuid().equalsIgnoreCase(far
.getGuid())) {
97 } while (cursor
.toNextSibling());
103 cursor
= GlobalData
.fdb
.getPlatformList().newCursor();
104 cursor
.toFirstChild();
106 DbPathAndFilename item
= (DbPathAndFilename
) cursor
.getObject();
107 if (item
.getFarGuid() != null && item
.getFarGuid().equalsIgnoreCase(far
.getGuid())) {
110 } while (cursor
.toNextSibling());
115 cursor
= GlobalData
.fdb
.getFarList().newCursor();
116 cursor
.toFirstChild();
118 DbPathAndFilename item
= (DbPathAndFilename
) cursor
.getObject();
119 if (item
.getFarGuid() != null && item
.getFarGuid().equalsIgnoreCase(far
.getGuid())) {
122 } while (cursor
.toNextSibling());
125 String strFrameworkDbFilePath
= Workspace
.getCurrentWorkspace() + Workspace
.getStrWorkspaceDatabaseFile();
126 strFrameworkDbFilePath
= Tools
.convertPathToCurrentOsType(strFrameworkDbFilePath
);
128 SaveFile
.saveDbFile(strFrameworkDbFilePath
, GlobalData
.fdb
);
129 } catch (Exception e
) {
130 Log
.err("Save Database File", e
.getMessage());
134 public String
getPackageFarGuid(Identification packageId
) {
135 for (int index
= 0; index
< GlobalData
.fdb
.getPackageList().getFilenameList().size(); index
++) {
136 DbPathAndFilename item
= GlobalData
.fdb
.getPackageList().getFilenameArray(index
);
137 String path
= Workspace
.getCurrentWorkspace() + DataType
.FILE_SEPARATOR
+ item
.getStringValue();
138 File tempFile
= new File(path
);
139 if (tempFile
.getPath().equalsIgnoreCase(packageId
.getPath())) {
140 return GlobalData
.fdb
.getPackageList().getFilenameArray(index
).getFarGuid();
147 public String
getPlatformFarGuid(Identification platformId
) {
148 for (int index
= 0; index
< GlobalData
.fdb
.getPlatformList().getFilenameList().size(); index
++) {
149 DbPathAndFilename item
= GlobalData
.fdb
.getPlatformList().getFilenameArray(index
);
150 String path
= Workspace
.getCurrentWorkspace() + DataType
.FILE_SEPARATOR
+ item
.getStringValue();
151 File tempFile
= new File(path
);
152 if (tempFile
.getPath().equalsIgnoreCase(platformId
.getPath())) {
153 return GlobalData
.fdb
.getPlatformList().getFilenameArray(index
).getFarGuid();
160 public String
getModuleFarGuid(Identification moduleId
) {
161 PackageIdentification packageId
= getPackageIdByModuleId(moduleId
);
162 if (packageId
!= null) {
163 return getPackageFarGuid(packageId
);
170 Get all modules' paths from one package
172 @return a Vector with all modules' path
175 public Vector
<String
> getAllModulesOfPackage(String path
) {
176 Vector
<String
> modulePath
= new Vector
<String
>();
177 PackageIdentification id
= new PackageIdentification(null, null, null, path
);
178 MsaFiles files
= GlobalData
.openingPackageList
.getPackageSurfaceAreaFromId(id
).getMsaFiles();
180 for (int index
= 0; index
< files
.getFilenameList().size(); index
++) {
181 String msaPath
= files
.getFilenameList().get(index
);
182 msaPath
= Tools
.addFileSeparator(Tools
.getFilePathOnly(path
)) + msaPath
;
183 msaPath
= Tools
.convertPathToCurrentOsType(msaPath
);
184 modulePath
.addElement(msaPath
);
192 Get all Industry Std Includes' paths from one package
194 @return a Vector with all paths
197 public Vector
<String
> getAllIndustryStdIncludesOfPackage(String path
) {
198 Vector
<String
> includePath
= new Vector
<String
>();
199 PackageIdentification id
= new PackageIdentification(null, null, null, path
);
200 IndustryStdIncludes files
= GlobalData
.openingPackageList
.getPackageSurfaceAreaFromId(id
)
201 .getIndustryStdIncludes();
203 for (int index
= 0; index
< files
.getIndustryStdHeaderList().size(); index
++) {
204 String temp
= files
.getIndustryStdHeaderList().get(index
).getIncludeHeader();
205 temp
= Tools
.addFileSeparator(Tools
.getFilePathOnly(path
)) + temp
;
206 temp
= Tools
.convertPathToCurrentOsType(temp
);
207 includePath
.addElement(temp
);
214 Get all package basic information form the FrameworkDatabase.db file
216 @return vPackageList A vector includes all packages' basic information
219 public Vector
<PackageIdentification
> getAllPackages() {
220 return GlobalData
.vPackageList
;
224 Get all package which match parameter isRepackagable
226 @param isRepackagable
230 public Vector
<PackageIdentification
> getAllRepackagbalePackages() {
231 Vector
<PackageIdentification
> v
= new Vector
<PackageIdentification
>();
232 for (int index
= 0; index
< GlobalData
.openingPackageList
.size(); index
++) {
233 OpeningPackageType opt
= GlobalData
.openingPackageList
.getOpeningPackageByIndex(index
);
234 if (opt
.getXmlSpd() != null) {
235 if (opt
.getXmlSpd().getPackageDefinitions() != null) {
236 if (opt
.getXmlSpd().getPackageDefinitions().getRePackage()) {
237 v
.addElement(opt
.getId());
240 v
.addElement(opt
.getId());
243 v
.addElement(opt
.getId());
249 public Vector
<FarIdentification
> getAllFars() {
251 Vector
<FarIdentification
> v
= new Vector
<FarIdentification
>();
252 for (int index
= 0; index
< GlobalData
.fdb
.getFarList().getFilenameList().size(); index
++) {
253 DbPathAndFilename item
= GlobalData
.fdb
.getFarList().getFilenameList().get(index
);
254 FarIdentification far
= new FarIdentification(item
.getFarGuid(), item
.getMd5Sum(), item
.getStringValue());
260 public Vector
<PackageIdentification
> getPackagesByFar(FarIdentification far
) {
261 Identification id
= null;
263 Vector
<PackageIdentification
> v
= new Vector
<PackageIdentification
>();
265 for (int index
= 0; index
< GlobalData
.fdb
.getPackageList().getFilenameList().size(); index
++) {
266 DbPathAndFilename item
= GlobalData
.fdb
.getPackageList().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())) {
273 id
= Tools
.getId(path
, OpenFile
.openSpdFile(path
));
274 v
.addElement(new PackageIdentification(id
));
275 } catch (IOException e
) {
276 Log
.err("Open Package Surface Area " + path
, e
.getMessage());
277 } catch (XmlException e
) {
278 Log
.err("Open Package Surface Area " + path
, e
.getMessage());
279 } catch (Exception e
) {
280 Log
.err("Open Package Surface Area " + path
, "Invalid file type");
287 public Vector
<PlatformIdentification
> getPlatformsByFar(FarIdentification far
) {
288 Identification id
= null;
290 Vector
<PlatformIdentification
> v
= new Vector
<PlatformIdentification
>();
292 for (int index
= 0; index
< GlobalData
.fdb
.getPlatformList().getFilenameList().size(); index
++) {
293 DbPathAndFilename item
= GlobalData
.fdb
.getPlatformList().getFilenameArray(index
);
294 String path
= Workspace
.getCurrentWorkspace() + DataType
.FILE_SEPARATOR
+ item
.getStringValue();
295 path
= Tools
.convertPathToCurrentOsType(path
);
297 if (item
.getFarGuid() != null && item
.getFarGuid().equalsIgnoreCase(far
.getGuid())) {
299 id
= Tools
.getId(path
, OpenFile
.openFpdFile(path
));
300 v
.addElement(new PlatformIdentification(id
));
301 } catch (IOException e
) {
302 Log
.err("Open Platform Surface Area " + path
, e
.getMessage());
303 } catch (XmlException e
) {
304 Log
.err("Open Platform Surface Area " + path
, e
.getMessage());
305 } catch (Exception e
) {
306 Log
.err("Open Platform Surface Area " + path
, "Invalid file type");
314 Get all module basic information from a package
317 @return A vector includes all modules' basic information
320 public Vector
<ModuleIdentification
> getAllModules(PackageIdentification pid
) {
321 Vector
<ModuleIdentification
> v
= new Vector
<ModuleIdentification
>();
322 Vector
<String
> modulePaths
= this.getAllModulesOfPackage(pid
.getPath());
323 String modulePath
= null;
325 for (int index
= 0; index
< modulePaths
.size(); index
++) {
326 modulePath
= modulePaths
.get(index
);
327 ModuleIdentification id
= GlobalData
.openingModuleList
.getIdByPath(modulePath
);
332 Sort
.sortModules(v
, DataType
.SORT_TYPE_ASCENDING
);
337 Get all module basic information from a platform
340 @return A vector includes all modules' basic information
343 public Vector
<ModuleIdentification
> getAllModules(PlatformIdentification fid
) {
344 Vector
<ModuleIdentification
> v
= new Vector
<ModuleIdentification
>();
345 PlatformSurfaceArea fpd
= GlobalData
.openingPlatformList
.getOpeningPlatformById(fid
).getXmlFpd();
346 if (fpd
.getFrameworkModules() != null) {
347 for (int index
= 0; index
< fpd
.getFrameworkModules().getModuleSAList().size(); index
++) {
348 String guid
= fpd
.getFrameworkModules().getModuleSAList().get(index
).getModuleGuid();
349 String version
= fpd
.getFrameworkModules().getModuleSAList().get(index
).getModuleVersion();
350 ModuleIdentification id
= GlobalData
.openingModuleList
.getIdByGuidVersion(guid
, version
);
352 boolean isFind
= false;
353 for (int indexOfModules
= 0; indexOfModules
< v
.size(); indexOfModules
++) {
354 if (v
.elementAt(indexOfModules
).equals(id
)) {
365 Sort
.sortModules(v
, DataType
.SORT_TYPE_ASCENDING
);
370 Get all module basic information form the FrameworkDatabase.db file
372 @return vModuleList A vector includes all modules' basic information
375 public Vector
<ModuleIdentification
> getAllModules() {
376 return GlobalData
.vModuleList
;
380 Get all platform basic information form the FrameworkDatabase.db file
382 @return vplatformList A vector includes all platforms' basic information
385 public Vector
<PlatformIdentification
> getAllPlatforms() {
386 return GlobalData
.vPlatformList
;
390 Get all Library Class Definitions from a package
394 public Vector
<String
> getAllLibraryClassDefinitionsFromPackage(PackageSurfaceArea spd
) {
395 Vector
<String
> vector
= new Vector
<String
>();
396 if (spd
.getLibraryClassDeclarations() != null) {
397 if (spd
.getLibraryClassDeclarations().getLibraryClassList().size() > 0) {
398 for (int index
= 0; index
< spd
.getLibraryClassDeclarations().getLibraryClassList().size(); index
++) {
399 vector
.addElement(spd
.getLibraryClassDeclarations().getLibraryClassList().get(index
).getName());
403 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
408 Get all Protocol Definitions from a package
412 public Vector
<String
> getAllProtocolDeclarationsFromPackage(PackageSurfaceArea spd
) {
413 Vector
<String
> vector
= new Vector
<String
>();
414 if (spd
.getProtocolDeclarations() != null) {
415 if (spd
.getProtocolDeclarations().getEntryList().size() > 0) {
416 for (int index
= 0; index
< spd
.getProtocolDeclarations().getEntryList().size(); index
++) {
417 vector
.addElement(spd
.getProtocolDeclarations().getEntryList().get(index
).getCName());
421 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
426 Get all Ppi Definitions from a package
430 public Vector
<String
> getAllPpiDeclarationsFromPackage(PackageSurfaceArea spd
) {
431 Vector
<String
> vector
= new Vector
<String
>();
432 if (spd
.getPpiDeclarations() != null) {
433 if (spd
.getPpiDeclarations().getEntryList().size() > 0) {
434 for (int index
= 0; index
< spd
.getPpiDeclarations().getEntryList().size(); index
++) {
435 vector
.addElement(spd
.getPpiDeclarations().getEntryList().get(index
).getCName());
439 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
444 Get all Guid Definitions from a package
448 public Vector
<String
> getAllGuidDeclarationsFromPackage(PackageSurfaceArea spd
, String type
) {
449 Vector
<String
> vector
= new Vector
<String
>();
450 boolean isFound
= false;
451 if (spd
.getGuidDeclarations() != null) {
452 if (spd
.getGuidDeclarations().getEntryList().size() > 0) {
453 for (int index
= 0; index
< spd
.getGuidDeclarations().getEntryList().size(); index
++) {
454 Vector
<String
> vArch
= Tools
.convertListToVector(spd
.getGuidDeclarations().getEntryList()
455 .get(index
).getGuidTypeList());
456 for (int indexOfArch
= 0; indexOfArch
< vArch
.size(); indexOfArch
++) {
457 if (vArch
.get(indexOfArch
).equals(type
)) {
462 if ((isFound
) || (vArch
== null) || (vArch
.size() < 1)) {
463 vector
.addElement(spd
.getGuidDeclarations().getEntryList().get(index
).getCName());
469 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
474 Get all Pcd Definitions from a package
478 public PcdVector
getAllPcdDeclarationsFromPackage(PackageSurfaceArea spd
) {
479 PcdVector vector
= new PcdVector();
480 if (spd
.getPcdDeclarations() != null) {
481 if (spd
.getPcdDeclarations().getPcdEntryList().size() > 0) {
482 for (int index
= 0; index
< spd
.getPcdDeclarations().getPcdEntryList().size(); index
++) {
483 String name
= spd
.getPcdDeclarations().getPcdEntryList().get(index
).getCName();
484 String guidCName
= spd
.getPcdDeclarations().getPcdEntryList().get(index
).getTokenSpaceGuidCName();
485 String help
= spd
.getPcdDeclarations().getPcdEntryList().get(index
).getHelpText();
486 Vector
<String
> type
= Tools
.convertListToVector(spd
.getPcdDeclarations().getPcdEntryList()
487 .get(index
).getValidUsage());
489 // The algorithm for PCD of msa should be:
490 // 1. If the type of PCD from Spd is FEATURE_FLAG,
491 // the type of Msa only can be FEATURE_FLAG.
492 // 2. If the type of PCD from Spd is not FEATURE_FLAG,
493 // the type of Msa could be selected from the PCD's all types and "DYNAMIC" type.
495 boolean hasFEATURE_FLAG
= false;
496 boolean hasDYNAMIC
= false;
497 for (int indexOfType
= 0; indexOfType
< type
.size(); indexOfType
++) {
498 if (type
.elementAt(indexOfType
).equals(DataType
.PCD_ITEM_TYPE_DYNAMIC
)) {
501 if (type
.elementAt(indexOfType
).equals(DataType
.PCD_ITEM_TYPE_FEATURE_FLAG
)) {
502 hasFEATURE_FLAG
= true;
505 if (hasFEATURE_FLAG
) {
506 type
.removeAllElements();
507 type
.addElement(DataType
.PCD_ITEM_TYPE_FEATURE_FLAG
);
510 type
.addElement(DataType
.PCD_ITEM_TYPE_DYNAMIC
);
513 vector
.addPcd(new PcdIdentification(name
, guidCName
, help
, type
));
517 Sort
.sortPcds(vector
, DataType
.SORT_TYPE_ASCENDING
);
521 public Vector
<String
> getAllLibraryClassDefinitionsFromWorkspace() {
522 Vector
<String
> vector
= new Vector
<String
>();
523 for (int index
= 0; index
< GlobalData
.vPackageList
.size(); index
++) {
524 Vector
<String
> v
= getAllLibraryClassDefinitionsFromPackage(GlobalData
.openingPackageList
525 .getPackageSurfaceAreaFromId(GlobalData
.vPackageList
527 if (v
!= null && v
.size() > 0) {
532 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
536 public Vector
<String
> getAllLibraryClassDefinitionsFromPackages(Vector
<PackageIdentification
> vpid
) {
537 Vector
<String
> vector
= new Vector
<String
>();
538 for (int index
= 0; index
< vpid
.size(); index
++) {
539 Vector
<String
> v
= getAllLibraryClassDefinitionsFromPackage(GlobalData
.openingPackageList
540 .getPackageSurfaceAreaFromId(vpid
542 if (v
!= null && v
.size() > 0) {
547 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
551 public Vector
<String
> getAllProtocolDeclarationsFromWorkspace() {
552 Vector
<String
> vector
= new Vector
<String
>();
553 for (int index
= 0; index
< GlobalData
.vPackageList
.size(); index
++) {
554 Vector
<String
> v
= getAllProtocolDeclarationsFromPackage(GlobalData
.openingPackageList
555 .getPackageSurfaceAreaFromId(GlobalData
.vPackageList
557 if (v
!= null && v
.size() > 0) {
561 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
565 public Vector
<String
> getAllProtocolDeclarationsFromPackages(Vector
<PackageIdentification
> vpid
) {
566 Vector
<String
> vector
= new Vector
<String
>();
567 for (int index
= 0; index
< vpid
.size(); index
++) {
568 Vector
<String
> v
= getAllProtocolDeclarationsFromPackage(GlobalData
.openingPackageList
569 .getPackageSurfaceAreaFromId(vpid
571 if (v
!= null && v
.size() > 0) {
575 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
579 public Vector
<String
> getAllPpiDeclarationsFromWorkspace() {
580 Vector
<String
> vector
= new Vector
<String
>();
581 for (int index
= 0; index
< GlobalData
.vPackageList
.size(); index
++) {
582 Vector
<String
> v
= getAllPpiDeclarationsFromPackage(GlobalData
.openingPackageList
583 .getPackageSurfaceAreaFromId(GlobalData
.vPackageList
585 if (v
!= null && v
.size() > 0) {
589 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
593 public Vector
<String
> getAllPpiDeclarationsFromPackages(Vector
<PackageIdentification
> vpid
) {
594 Vector
<String
> vector
= new Vector
<String
>();
595 for (int index
= 0; index
< vpid
.size(); index
++) {
596 Vector
<String
> v
= getAllPpiDeclarationsFromPackage(GlobalData
.openingPackageList
597 .getPackageSurfaceAreaFromId(vpid
599 if (v
!= null && v
.size() > 0) {
603 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
607 public Vector
<String
> getAllGuidDeclarationsFromWorkspace(String type
) {
608 Vector
<String
> vector
= new Vector
<String
>();
609 for (int index
= 0; index
< GlobalData
.vPackageList
.size(); index
++) {
610 Vector
<String
> v
= getAllGuidDeclarationsFromPackage(
611 GlobalData
.openingPackageList
612 .getPackageSurfaceAreaFromId(GlobalData
.vPackageList
615 if (v
!= null && v
.size() > 0) {
620 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
624 public Vector
<String
> getAllGuidDeclarationsFromPackages(Vector
<PackageIdentification
> vpid
, String type
) {
625 Vector
<String
> vector
= new Vector
<String
>();
626 for (int index
= 0; index
< vpid
.size(); index
++) {
627 Vector
<String
> v
= getAllGuidDeclarationsFromPackage(
628 GlobalData
.openingPackageList
629 .getPackageSurfaceAreaFromId(vpid
632 if (v
!= null && v
.size() > 0) {
637 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
641 public PcdVector
getAllPcdDeclarationsFromWorkspace() {
642 PcdVector vector
= new PcdVector();
643 for (int index
= 0; index
< GlobalData
.openingPackageList
.size(); index
++) {
644 PcdVector v
= getAllPcdDeclarationsFromPackage(GlobalData
.openingPackageList
645 .getPackageSurfaceAreaFromId(GlobalData
.vPackageList
647 if (v
!= null && v
.size() > 0) {
652 Sort
.sortPcds(vector
, DataType
.SORT_TYPE_ASCENDING
);
656 public PcdVector
getAllPcdDeclarationsFromPackages(Vector
<PackageIdentification
> vpid
) {
657 PcdVector vector
= new PcdVector();
658 for (int index
= 0; index
< vpid
.size(); index
++) {
659 PcdVector v
= getAllPcdDeclarationsFromPackage(GlobalData
.openingPackageList
660 .getPackageSurfaceAreaFromId(vpid
662 if (v
!= null && v
.size() > 0) {
667 Sort
.sortPcds(vector
, DataType
.SORT_TYPE_ASCENDING
);
672 Find a module's package's id
674 @param id input module id
678 public PackageIdentification
getPackageIdByModuleId(Identification id
) {
679 Vector
<String
> modulePaths
= new Vector
<String
>();
680 Identification mid
= null;
681 String packagePath
= null;
682 String modulePath
= null;
685 // For each package, get all modules list
687 for (int indexI
= 0; indexI
< GlobalData
.vPackageList
.size(); indexI
++) {
688 packagePath
= GlobalData
.vPackageList
.elementAt(indexI
).getPath();
689 modulePaths
= this.getAllModulesOfPackage(packagePath
);
690 for (int indexJ
= 0; indexJ
< modulePaths
.size(); indexJ
++) {
691 modulePath
= modulePaths
.get(indexJ
);
692 mid
= GlobalData
.openingModuleList
.getIdByPath(modulePath
);
697 if (mid
.equals(id
)) {
698 return GlobalData
.vPackageList
.elementAt(indexI
);
708 Add module information to package surface area
716 public void addModuleToPackage(ModuleIdentification mid
, PackageSurfaceArea spd
) throws IOException
, XmlException
,
718 String packagePath
= mid
.getPackageId().getPath();
719 String modulePath
= mid
.getPath();
721 spd
= OpenFile
.openSpdFile(packagePath
);
723 MsaFiles msaFile
= spd
.getMsaFiles();
724 if (msaFile
== null) {
725 msaFile
= MsaFiles
.Factory
.newInstance();
727 packagePath
= packagePath
.substring(0, packagePath
.lastIndexOf(DataType
.FILE_SEPARATOR
));
728 String fn
= Tools
.getRelativePath(modulePath
, packagePath
);
729 msaFile
.addNewFilename();
730 msaFile
.setFilenameArray(msaFile
.getFilenameList().size() - 1, fn
);
731 spd
.setMsaFiles(msaFile
);
732 SaveFile
.saveSpdFile(mid
.getPackageId().getPath(), spd
);
736 GlobalData
.openingPackageList
.getPackageSurfaceAreaFromId(mid
.getPackageId()).setMsaFiles(msaFile
);
740 Add input package into database
746 public void addPackageToDatabase(PackageIdentification id
) throws Exception
{
747 String path
= id
.getPath();
748 path
= Tools
.getRelativePath(path
, Workspace
.getCurrentWorkspace());
750 DbPathAndFilename filename
= DbPathAndFilename
.Factory
.newInstance();
751 filename
.setStringValue(path
);
752 GlobalData
.fdb
.getPackageList().addNewFilename();
753 GlobalData
.fdb
.getPackageList().setFilenameArray(GlobalData
.fdb
.getPackageList().sizeOfFilenameArray() - 1,
755 String strFrameworkDbFilePath
= Workspace
.getCurrentWorkspace() + Workspace
.getStrWorkspaceDatabaseFile();
756 strFrameworkDbFilePath
= Tools
.convertPathToCurrentOsType(strFrameworkDbFilePath
);
757 SaveFile
.saveDbFile(strFrameworkDbFilePath
, GlobalData
.fdb
);
761 Add input package into database
767 public void addPlatformToDatabase(PlatformIdentification id
) throws Exception
{
768 String path
= id
.getPath();
769 path
= Tools
.getRelativePath(path
, Workspace
.getCurrentWorkspace());
771 DbPathAndFilename filename
= DbPathAndFilename
.Factory
.newInstance();
772 filename
.setStringValue(path
);
773 GlobalData
.fdb
.getPlatformList().addNewFilename();
774 GlobalData
.fdb
.getPlatformList().setFilenameArray(GlobalData
.fdb
.getPlatformList().sizeOfFilenameArray() - 1,
776 String strFrameworkDbFilePath
= Workspace
.getCurrentWorkspace() + Workspace
.getStrWorkspaceDatabaseFile();
777 strFrameworkDbFilePath
= Tools
.convertPathToCurrentOsType(strFrameworkDbFilePath
);
778 SaveFile
.saveDbFile(strFrameworkDbFilePath
, GlobalData
.fdb
);
782 Get all file's path from one module
791 public Vector
<String
> getAllFilesPathOfModule(String path
) {
792 Vector
<String
> v
= new Vector
<String
>();
793 path
= Tools
.convertPathToCurrentOsType(path
);
796 // First add msa file's path
800 ModuleSurfaceArea msa
= GlobalData
.openingModuleList
801 .getModuleSurfaceAreaFromId(GlobalData
.openingModuleList
804 // Get common defined files of module
808 // Get all files' path of a module
810 SourceFiles sf
= msa
.getSourceFiles();
812 for (int index
= 0; index
< sf
.getFilenameList().size(); index
++) {
813 String temp
= sf
.getFilenameList().get(index
).getStringValue();
814 temp
= Tools
.addFileSeparator(Tools
.getFilePathOnly(path
)) + temp
;
815 v
.addElement(Tools
.convertPathToCurrentOsType(temp
));
821 // Get include header files for this module
823 if (msa
.getLibraryClassDefinitions() != null) {
824 LibraryClassDefinitions lcd
= msa
.getLibraryClassDefinitions();
825 for (int index
= 0; index
< lcd
.sizeOfLibraryClassArray(); index
++) {
826 if (lcd
.getLibraryClassList().get(index
).getUsage().toString()
827 .equals(DataType
.USAGE_TYPE_ALWAYS_PRODUCED
)
828 || lcd
.getLibraryClassList().get(index
).getUsage().toString()
829 .equals(DataType
.USAGE_TYPE_SOMETIMES_PRODUCED
)) {
831 // Get library class name
833 String name
= lcd
.getLibraryClassList().get(index
).getKeyword();
836 // Find file path for this class
838 PackageIdentification pid
= GlobalData
.openingModuleList
.getIdByPath(path
).getPackageId();
839 PackageSurfaceArea spd
= GlobalData
.openingPackageList
.getPackageSurfaceAreaFromId(pid
);
840 String headerFile
= getHeaderFileFromPackageByLibraryClassName(spd
, name
);
841 if (!Tools
.isEmpty(headerFile
)) {
842 v
.addElement(Tools
.convertPathToCurrentOsType(Tools
.getFilePathOnly(pid
.getPath())
843 + DataType
.FILE_SEPARATOR
+ headerFile
));
853 Get all file's path from one package
862 public Vector
<String
> getAllFilesPathOfPakcage(String path
) {
863 Vector
<String
> v
= new Vector
<String
>();
864 path
= Tools
.convertPathToCurrentOsType(path
);
871 // Add the package's industry std includes one by one
873 Vector
<String
> f1
= new Vector
<String
>();
874 f1
= getAllIndustryStdIncludesOfPackage(path
);
875 for (int index
= 0; index
< f1
.size(); index
++) {
876 v
.addElement(f1
.get(index
));
880 // Add module's files one by one
882 f1
= new Vector
<String
>();
883 f1
= getAllModulesOfPackage(path
);
884 for (int indexI
= 0; indexI
< f1
.size(); indexI
++) {
885 Vector
<String
> f2
= getAllFilesPathOfModule(f1
.get(indexI
));
886 for (int indexJ
= 0; indexJ
< f2
.size(); indexJ
++) {
887 v
.addElement(f2
.get(indexJ
));
895 Get a module's all package dependencies
897 @param mid The module id
898 @return A vector of all package dependency ids
901 public Vector
<PackageIdentification
> getPackageDependenciesOfModule(ModuleIdentification mid
) {
902 Vector
<PackageIdentification
> vpid
= new Vector
<PackageIdentification
>();
903 ModuleSurfaceArea msa
= GlobalData
.openingModuleList
.getModuleSurfaceAreaFromId(mid
);
905 PackageDependencies pd
= msa
.getPackageDependencies();
907 for (int index
= 0; index
< pd
.getPackageList().size(); index
++) {
908 String guid
= pd
.getPackageList().get(index
).getPackageGuid();
909 String version
= pd
.getPackageList().get(index
).getPackageVersion();
910 PackageIdentification pid
= GlobalData
.openingPackageList
.getIdByGuidVersion(guid
, version
);
912 vpid
.addElement(pid
);
920 public Vector
<String
> getAllModuleGuidXref() {
921 Vector
<String
> v
= new Vector
<String
>();
922 for (int index
= 0; index
< GlobalData
.openingModuleList
.size(); index
++) {
923 ModuleIdentification id
= GlobalData
.openingModuleList
.getOpeningModuleByIndex(index
).getId();
924 v
.addElement(id
.getGuid() + " " + id
.getName());
929 public Vector
<String
> getModuleArch(ModuleIdentification id
) {
930 Vector
<String
> v
= new Vector
<String
>();
931 ModuleSurfaceArea msa
= null;
933 msa
= GlobalData
.openingModuleList
.getModuleSurfaceAreaFromId(id
);
936 if (msa
.getModuleDefinitions() != null) {
937 v
= Tools
.convertListToVector(msa
.getModuleDefinitions().getSupportedArchitectures());
943 public String
getHeaderFileFromPackageByLibraryClassName(PackageSurfaceArea spd
, String name
) {
944 String headerFile
= "";
946 if (spd
.getLibraryClassDeclarations() != null) {
947 LibraryClassDeclarations lcdl
= spd
.getLibraryClassDeclarations();
948 for (int indexOfLibOfSpd
= 0; indexOfLibOfSpd
< lcdl
.sizeOfLibraryClassArray(); indexOfLibOfSpd
++) {
949 if (lcdl
.getLibraryClassList().get(indexOfLibOfSpd
).getName().equals(name
)) {
950 return lcdl
.getLibraryClassList().get(indexOfLibOfSpd
).getIncludeHeader();