summaryrefslogtreecommitdiff
path: root/Tools/Java/Source/GenBuild/org/tianocore/build/global
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/Java/Source/GenBuild/org/tianocore/build/global')
-rw-r--r--Tools/Java/Source/GenBuild/org/tianocore/build/global/DpFile.java130
-rw-r--r--Tools/Java/Source/GenBuild/org/tianocore/build/global/DpFileList.java64
-rw-r--r--Tools/Java/Source/GenBuild/org/tianocore/build/global/GenBuildLogger.java283
-rw-r--r--Tools/Java/Source/GenBuild/org/tianocore/build/global/GlobalData.java948
-rw-r--r--Tools/Java/Source/GenBuild/org/tianocore/build/global/OnDependency.java145
-rw-r--r--Tools/Java/Source/GenBuild/org/tianocore/build/global/OutputManager.java201
-rw-r--r--Tools/Java/Source/GenBuild/org/tianocore/build/global/Spd.java273
-rw-r--r--Tools/Java/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java2356
-rw-r--r--Tools/Java/Source/GenBuild/org/tianocore/build/global/VariableTask.java71
9 files changed, 0 insertions, 4471 deletions
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/global/DpFile.java b/Tools/Java/Source/GenBuild/org/tianocore/build/global/DpFile.java
deleted file mode 100644
index af6590f5b6..0000000000
--- a/Tools/Java/Source/GenBuild/org/tianocore/build/global/DpFile.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/** @file
-This file is used to define class which represents dependency file in ANT task
-
-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.global;
-
-import org.apache.tools.ant.types.DataType;
-import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.BuildException;
-
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.LineNumberReader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- DpFile is a ANT DataType which can be used to specify dependency files from
- a file list file, from file list string separated by space, comma or semi-comma,
- or from file name with absolute path
- **/
-public class DpFile extends DataType {
- ///
- /// keep the list of files path
- ///
- private List<String> nameList = new ArrayList<String>();
-
- /**
- Empty constructor just in case
- **/
- public DpFile() {
- }
-
- /**
- Empty execute method of ANT task, just in case
- **/
- public void execute() {
- }
-
- /**
- Standard set method of ANT task/datatype, for ListFile attribute. It simply
- fetch one file path a line from specified list file, and put them in nameList
-
- @param fileListFile file which contains a file list, one file a line,
- with full path
- **/
- public void setListFile(String fileListFile) {
- File file = new File(fileListFile);
- if (!file.exists()) {
- return;
- }
-
- try {
- FileReader fileReader = new FileReader(file);
- LineNumberReader lineReader = new LineNumberReader(fileReader);
-
- String filePath = null;
- while ((filePath = lineReader.readLine()) != null) {
- filePath = filePath.trim();
- if (filePath.length() == 0) {
- continue;
- }
- this.nameList.add(filePath);
- }
-
- lineReader.close();
- fileReader.close();
- } catch (IOException e) {
- throw new BuildException(e.getMessage());
- }
- }
-
- /**
- Standard set method of ANT task/datatype, for List attribute.
-
- @param fileList string with file pathes separated by space, comma,
- or semi-comma
- **/
- public void setList(String fileList) {
- //
- // space, comma or semi-comma separated files list
- //
- Pattern pattern = Pattern.compile("([^ ,;\n\r]++)[ ,;\n\r]*+");
- Matcher matcher = pattern.matcher(fileList);
-
- while (matcher.find()) {
- //
- // keep each file name before " ,;\n\r"
- //
- String filePath = fileList.substring(matcher.start(1), matcher.end(1)).trim();
- if (filePath.length() == 0) {
- continue;
- }
- nameList.add(Path.translateFile(filePath));
- }
-
- }
-
- /**
- Standard set method of ANT task/datatype, for Name attribute.
-
- @param fileName string of a file full path
- **/
- public void setName(String fileName) {
- this.nameList.add(fileName);
- }
-
- /**
- Fetch the file name list.
-
- @returns A string list which contains file names specified to check dependnecy
- **/
- public List<String> getList() {
- return this.nameList;
- }
-}
-
-
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/global/DpFileList.java b/Tools/Java/Source/GenBuild/org/tianocore/build/global/DpFileList.java
deleted file mode 100644
index dd032526d8..0000000000
--- a/Tools/Java/Source/GenBuild/org/tianocore/build/global/DpFileList.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/** @file
-This file is used to nest elements corresponding to DpFile
-
-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.global;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.tools.ant.DirectoryScanner;
-import org.apache.tools.ant.types.DataType;
-import org.apache.tools.ant.types.FileSet;
-
-/**
- DpFileList is a container of Dpfile at the point of ANT task/datatype
- **/
-public class DpFileList extends DataType {
- ///
- /// Keep all the file names from all nested DpFile
- ///
- List<String> nameList = new ArrayList<String>();
-
- /**
- Empty constructor just in case
- **/
- public DpFileList() {
- }
-
- /**
- Empty execute method of ANT task. ANT will call it even we don't need it.
- **/
- public void execute() {
- }
-
- /**
- Standard add method of ANT task, for nested DpFile type of elements. It just
- simply fetch the files list from DpFile and put them in its own nameList.
-
- @param f a DpFile object which will be instantiated by ANT
- **/
- public void addConfiguredFile(DpFile f) {
- this.nameList.addAll(f.getList());
- }
-
- public void addConfiguredFileSet(FileSet fileSet) {
- DirectoryScanner ds = fileSet.getDirectoryScanner(getProject());
- String dir = fileSet.getDir(getProject()).getAbsolutePath();
- String[] files = ds.getIncludedFiles();
-
- for (int i = 0; i < files.length; ++i) {
- nameList.add(dir + "/" + files[i]);
- }
- }
-}
-
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/global/GenBuildLogger.java b/Tools/Java/Source/GenBuild/org/tianocore/build/global/GenBuildLogger.java
deleted file mode 100644
index b1e119a501..0000000000
--- a/Tools/Java/Source/GenBuild/org/tianocore/build/global/GenBuildLogger.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/*++
-
- 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.
-
- Module Name:
- GenBuildLogger.java
-
- Abstract:
-
- --*/
-
-package org.tianocore.build.global;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-
-import org.apache.tools.ant.BuildEvent;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.DefaultLogger;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.util.StringUtils;
-
-import org.tianocore.build.id.FpdModuleIdentification;
-import org.tianocore.common.logger.EdkLog;
-import org.tianocore.common.logger.LogMethod;
-
-public class GenBuildLogger extends DefaultLogger implements LogMethod {
-
- Project project = null;
-
- ///
- /// flag to present whether cache all msg or not
- /// true means to cache.
- ///
- private static boolean flag = false;
-
- private static Map<FpdModuleIdentification, List<String>> map = new LinkedHashMap<FpdModuleIdentification, List<String> >(256);
-
- private FpdModuleIdentification id = null;
- //
- // semaroph for multi thread
- //
- public static Object semaphore = new Object();
-
- public GenBuildLogger () {
-
- }
-
- public GenBuildLogger (Project project) {
- this.project = project;
- }
-
- /**
- Rules: flag = false: means no cache Action: Print it to console
-
- flag = true: mean cache all msg exception some special Action: loglevel
- is EDK_ALWAYS -- Print but no cache loglevel is EDK_ERROR -- Print and
- cache the msg others -- No print and cache the msg
- **/
- public synchronized void putMessage(Object msgSource, int msgLevel, String msg) {
- if (this.project == null) {
- return;
- }
-
- //
- // If msgLevel is always print, then print it
- //
- switch (msgLevel) {
- case EdkLog.EDK_ALWAYS:
- //
- // Do some special
- //
- log(msgSource, msg, Project.MSG_ERR);
- break;
- case EdkLog.EDK_ERROR:
- log(msgSource, msg, Project.MSG_ERR);
- break;
- case EdkLog.EDK_WARNING:
- log(msgSource, msg, Project.MSG_WARN);
- break;
- case EdkLog.EDK_INFO:
- log(msgSource, msg, Project.MSG_INFO);
- break;
- case EdkLog.EDK_VERBOSE:
- log(msgSource, msg, Project.MSG_VERBOSE);
- break;
- case EdkLog.EDK_DEBUG:
- log(msgSource, msg, Project.MSG_DEBUG);
- break;
- }
- }
-
- public static void flushErrorModuleLog(FpdModuleIdentification errorModuleId) {
- List<String> errorLogs = map.get(errorModuleId);
- if (errorLogs != null) {
- EdkLog.log("ErrorLog", EdkLog.EDK_ERROR, errorModuleId + " error logs: ");
- for(int i = 0; i < errorLogs.size(); i++) {
- EdkLog.log(EdkLog.EDK_ERROR, errorLogs.get(i));
- }
- }
- }
-
- public void flushToFile(File file) {
- //
- // Put all messages in map to file
- //
- String msg = "Writing log to file [" + file.getPath() + "]";
- log("Logging", msg, Project.MSG_INFO);
- try {
- BufferedWriter bw = new BufferedWriter(new FileWriter(file));
- Iterator<FpdModuleIdentification> iter = map.keySet().iterator();
- List<String> mainLogs = null;
- while (iter.hasNext()) {
- FpdModuleIdentification item = iter.next();
- if(item == null) {
- mainLogs = map.get(item);
- continue ;
- }
- bw.write(">>>>>>>>>>>>>");
- bw.write(" " + item + " Build Log ");
- bw.write(">>>>>>>>>>>>>");
- bw.newLine();
- List<String> allMessages = map.get(item);
- for(int i = 0; i < allMessages.size(); i++) {
- bw.write(allMessages.get(i));
- bw.newLine();
- }
- }
- if (mainLogs != null) {
- bw.write(">>>>>>>>>>>>>");
- bw.write(" Main Logs (already print to command) ");
- bw.write(">>>>>>>>>>>>>");
- bw.newLine();
- for(int i = 0; i < mainLogs.size(); i++) {
- bw.write(mainLogs.get(i));
- bw.newLine();
- }
- }
- bw.flush();
- bw.close();
- } catch (IOException e) {
- new BuildException("Writing log error. " + e.getMessage());
- }
-
- }
-
- private void log(Object msgSource, String msg, int level) {
- if (msgSource instanceof Task) {
- ((Task)msgSource).getProject().log((Task)msgSource, msg, level);
- } else if (msgSource instanceof String){
- //
- // Pad 12 space to keep message in unify format
- //
- msg = msg.replaceAll("\n", "\n ");
- this.project.log(String.format("%12s", "[" + msgSource + "] ") + msg, level);
- } else {
- this.project.log(msg, level);
- }
- }
- public void targetStarted(BuildEvent event) {
- if (!flag) {
- super.targetStarted(event);
- }
- }
-
- public void messageLogged(BuildEvent event) {
-
- int currentLevel = event.getPriority();
- //
- // If current level is upper than Ant Level, skip it
- //
- if (currentLevel <= this.msgOutputLevel) {
- String originalMessage = event.getMessage();
-
- StringBuffer message = new StringBuffer();
- if (!emacsMode && event.getTask() != null) {
- String label = String.format("%12s", "[" + event.getTask().getTaskName() + "] ");
- //
- // Append label first
- //
- message.append(label);
-
- //
- // Format all output message's line separator
- //
- try {
- BufferedReader r = new BufferedReader(new StringReader(originalMessage));
- boolean ifFirstLine = true;
- String line = null;
- while ((line = r.readLine()) != null) {
- if (!ifFirstLine) {
- message.append(StringUtils.LINE_SEP);
- }
- ifFirstLine = false;
- message.append(line);
- }
- } catch (IOException e) {
- message.append(originalMessage);
- }
- } else {
- message.append(originalMessage);
- }
-
- String msg = message.toString();
- if (currentLevel == Project.MSG_ERR) {
- printMessage(msg, err, currentLevel);
- } else if(currentLevel == Project.MSG_WARN) {
- printMessage(msg, out, currentLevel);
- } else if(!flag) {
- printMessage(msg, out, currentLevel);
- }
- log(msg);
- }
- }
-
- public static void setCacheEnable(boolean enable) {
- flag = enable;
- }
-
- protected synchronized void log(String message) {
- //
- // cache log
- //
- if (map.containsKey(this.id)) {
- map.get(this.id).add(message);
- } else {
- List<String> list = new Vector<String>(1024);
- list.add(message);
- map.put(this.id, list);
- }
- }
-
- public Object clone() {
- GenBuildLogger newLogger = new GenBuildLogger();
- //
- // Transfer emacs mode, out, err, level to new Logger
- //
- newLogger.setEmacsMode(this.emacsMode);
- newLogger.setOutputPrintStream(this.out);
- newLogger.setErrorPrintStream(this.err);
- newLogger.setMessageOutputLevel(this.msgOutputLevel);
-
- //
- // Transfer project
- //
- newLogger.project = this.project;
- return newLogger;
- }
-
- public void setId(FpdModuleIdentification id) {
- this.id = id;
- }
-
- public void buildFinished(BuildEvent event) {
- if (this.msgOutputLevel >= Project.MSG_VERBOSE) {
- int level = this.msgOutputLevel;
- synchronized(semaphore){
- this.msgOutputLevel = this.msgOutputLevel - 1;
- super.buildFinished(event);
- this.msgOutputLevel = level;
- }
- } else {
- super.buildFinished(event);
- }
- }
-} \ No newline at end of file
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/global/GlobalData.java b/Tools/Java/Source/GenBuild/org/tianocore/build/global/GlobalData.java
deleted file mode 100644
index b5605d4cb1..0000000000
--- a/Tools/Java/Source/GenBuild/org/tianocore/build/global/GlobalData.java
+++ /dev/null
@@ -1,948 +0,0 @@
-/** @file
- GlobalData class.
-
- GlobalData provide initializing, instoring, querying and update global data.
- It is a bridge to intercommunicate between multiple component, such as AutoGen,
- PCD and so on.
-
-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.global;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.tools.ant.Project;
-import org.apache.xmlbeans.XmlException;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlOptions;
-import org.tianocore.DbPathAndFilename;
-import org.tianocore.FrameworkDatabaseDocument;
-import org.tianocore.ModuleSurfaceAreaDocument;
-import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
-import org.tianocore.build.id.FpdModuleIdentification;
-import org.tianocore.build.id.ModuleIdentification;
-import org.tianocore.build.id.PackageIdentification;
-import org.tianocore.build.id.PlatformIdentification;
-import org.tianocore.build.toolchain.ToolChainConfig;
-import org.tianocore.build.toolchain.ToolChainElement;
-import org.tianocore.build.toolchain.ToolChainInfo;
-import org.tianocore.build.toolchain.ToolChainKey;
-import org.tianocore.build.toolchain.ToolChainMap;
-import org.tianocore.common.definitions.ToolDefinitions;
-import org.tianocore.common.exception.EdkException;
-import org.tianocore.common.logger.EdkLog;
-import org.tianocore.pcd.entity.MemoryDatabaseManager;
-
-/**
- GlobalData provide initializing, instoring, querying and update global data.
- It is a bridge to intercommunicate between multiple component, such as AutoGen,
- PCD and so on.
-
- <p>Note that all global information are initialized incrementally. All data will
- parse and record only of necessary during build time. </p>
-
- @since GenBuild 1.0
-**/
-public class GlobalData {
- ///
- /// Record current WORKSPACE Directory
- ///
- private static String workspaceDir = "";
-
- ///
- /// Be used to ensure Global data will be initialized only once.
- ///
- private static boolean globalFlag = false;
-
- ///
- /// Framework Database information: package list and platform list
- ///
- private static Set<PackageIdentification> packageList = new HashSet<PackageIdentification>();
-
- private static Set<PlatformIdentification> platformList = new HashSet<PlatformIdentification>();
-
- ///
- /// Every detail SPD informations: Module list, Library class definition,
- /// Package header file, GUID/PPI/Protocol definitions
- ///
- private static final Map<PackageIdentification, Spd> spdTable = new HashMap<PackageIdentification, Spd>();
-
- ///
- /// Build informations are divided into three parts:
- /// 1. From MSA 2. From FPD 3. From FPD' ModuleSA
- ///
- private static Map<ModuleIdentification, Map<String, XmlObject>> nativeMsa = new HashMap<ModuleIdentification, Map<String, XmlObject>>();
-
- private static Map<FpdModuleIdentification, Map<String, XmlObject>> fpdModuleSA= new HashMap<FpdModuleIdentification, Map<String, XmlObject>>();
-
- private static Map<String, XmlObject> fpdBuildOptionsMap = new HashMap<String, XmlObject>();
-
- private static XmlObject fpdBuildOptions;
-
- private static XmlObject fpdDynamicPcds;
-
- ///
- /// Parsed modules list
- ///
- private static Map<FpdModuleIdentification, Map<String, XmlObject>> parsedModules = new HashMap<FpdModuleIdentification, Map<String, XmlObject>>();
-
- ///
- /// built modules list with ARCH, TARGET, TOOLCHAIN
- ///
- private static Set<FpdModuleIdentification> builtModules = new HashSet<FpdModuleIdentification>();
-
- ///
- /// PCD memory database stored all PCD information which collected from FPD,MSA and SPD.
- ///
- private static final MemoryDatabaseManager pcdDbManager = new MemoryDatabaseManager();
-
- ///
- /// build target + tool chain family/tag name + arch + command types + command options
- ///
- ///
- /// Tool Chain Data
- /// toolsDef - build tool program information
- /// fpdBuildOption - all modules's build options for tool tag or tool chain families
- /// moduleSaBuildOption - build options for a specific module
- ///
- private static ToolChainConfig toolsDef;
-
- private static ToolChainInfo toolChainInfo;
- private static ToolChainInfo toolChainEnvInfo;
- private static ToolChainInfo toolChainPlatformInfo;
-
- private static ToolChainMap platformToolChainOption;
- private static ToolChainMap platformToolChainFamilyOption;
-
- private static Map<FpdModuleIdentification, ToolChainMap> moduleToolChainOption = new HashMap<FpdModuleIdentification, ToolChainMap>();
- private static Map<FpdModuleIdentification, ToolChainMap> moduleToolChainFamilyOption = new HashMap<FpdModuleIdentification, ToolChainMap>();
-
- private static Map<ModuleIdentification, ToolChainMap> msaBuildOption = new HashMap<ModuleIdentification, ToolChainMap>();
- private static Map<ModuleIdentification, ToolChainMap> msaFamilyBuildOption = new HashMap<ModuleIdentification, ToolChainMap>();
-
- /**
- 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
- in the whole build process.
-
- @param workspaceDatabaseFile the file name of framework database
- @param workspaceDir current workspace directory path
- @throws BuildException
- Framework Dababase or SPD or MSA file is not valid
- **/
- public synchronized static void initInfo(Project prj, String workspaceDatabaseFile, String workspaceDir, String toolsDefFilename ) throws EdkException {
- //
- // ensure this method will be revoked only once
- //
- if (globalFlag) {
- return;
- }
- globalFlag = true;
-
- //
- // Backup workspace directory. It will be used by other method
- //
- GlobalData.workspaceDir = workspaceDir.replaceAll("(\\\\)", "/");
-
- //
- // Parse tools definition file
- //
- //
- // If ToolChain has been set up before, do nothing.
- // CONF dir + tools definition file name
- //
- File toolsDefFile = new File(workspaceDir + File.separatorChar + toolsDefFilename);
- EdkLog.log("Init", EdkLog.EDK_ALWAYS, "Using tool definition file [" + toolsDefFile.getPath() + "].");
- toolsDef = new ToolChainConfig(prj, toolsDefFile);
-
- //
- // Parse Framework Database
- //
- File dbFile = new File(workspaceDir + File.separatorChar + workspaceDatabaseFile);
- FrameworkDatabaseDocument db = null;
- try {
- db = (FrameworkDatabaseDocument)parseXmlFile(dbFile);
- //
- // Get package list
- //
- if (db.getFrameworkDatabase().getPackageList() != null ) {
- List<DbPathAndFilename> packages = db.getFrameworkDatabase().getPackageList().getFilenameList();
- Iterator<DbPathAndFilename> iter = packages.iterator();
- while (iter.hasNext()) {
- String fileName = iter.next().getStringValue().trim();
- Spd spd = new Spd(new File(workspaceDir + File.separatorChar + fileName));
- packageList.add(spd.getPackageId());
- //
- // Report warning if existing two packages with same GUID and Version
- //
- if (spdTable.containsKey(spd.getPackageId())) {
- //
- // BUGBUG
- //
- EdkLog.log("Init", EdkLog.EDK_WARNING, "Warning: Existing two packages with same GUID and Version. They are ... " + spd.getPackageId().getSpdFile().getPath());
- }
- spdTable.put(spd.getPackageId(), spd);
- }
- }
- } catch(IOException ex) {
- EdkException edkException = new EdkException("Parse of WORKSPACE Database file [" + dbFile.getPath() + "] failed!\n" + ex.getMessage());
- edkException.setStackTrace(ex.getStackTrace());
- throw edkException;
- } catch(XmlException ex) {
- EdkException edkException = new EdkException("Parse of WORKSPACE Database file [" + dbFile.getPath() + "] failed!\n" + ex.getMessage());
- edkException.setStackTrace(ex.getStackTrace());
- throw edkException;
- }
-
- File fpdFile = null;
- try {
- //
- // Get platform list
- //
- if (db.getFrameworkDatabase().getPlatformList() != null) {
- List<DbPathAndFilename> platforms = db.getFrameworkDatabase().getPlatformList().getFilenameList();
- Iterator<DbPathAndFilename> iter = platforms.iterator();
- while (iter.hasNext()) {
- String fileName = iter.next().getStringValue().trim();
- fpdFile = new File(workspaceDir + File.separatorChar + fileName);
- if ( !fpdFile.exists() ) {
- throw new EdkException("Platform file [" + fpdFile.getPath() + "] not exists. ");
- }
- XmlObject fpdDoc = parseXmlFile(fpdFile);
- //
- // We can change Map to XmlObject
- //
- Map<String, XmlObject> fpdDocMap = new HashMap<String, XmlObject>();
- fpdDocMap.put("PlatformSurfaceArea", fpdDoc);
- SurfaceAreaQuery saq = new SurfaceAreaQuery(fpdDocMap);
- PlatformIdentification platformId = saq.getFpdHeader();
- platformId.setFpdFile(fpdFile);
- //
- // Report warning if existing two platfrom with same GUID and Version
- //
- if (platformList.contains(platformId)) {
- //
- // BUGBUG
- //
- EdkLog.log("Init", EdkLog.EDK_WARNING, "Warning: Existing two platforms with same GUID and Version. They are ... " + fpdFile.getPath());
- }
- platformList.add(platformId);
- }
- }
- } catch(IOException ex) {
- EdkException edkException = new EdkException("Parse of platform definition file [" + fpdFile.getPath() + "] failed!\n" + ex.getMessage());
- edkException.setStackTrace(ex.getStackTrace());
- throw edkException;
- } catch(XmlException ex) {
- EdkException edkException = new EdkException("Parse of platform definition file [" + fpdFile.getPath() + "] failed!\n" + ex.getMessage());
- edkException.setStackTrace(ex.getStackTrace());
- throw edkException;
- }
- }
-
- /**
- Get the current WORKSPACE Directory.
-
- @return current workspace directory
- **/
- public synchronized static String getWorkspacePath() {
- return workspaceDir;
- }
-
-
- /**
- Get the MSA file name with absolute path
- */
- public synchronized static File getMsaFile(ModuleIdentification moduleId) throws EdkException {
- File msaFile = null;
- //
- // TBD. Do only when package is null.
- //
- Iterator iter = packageList.iterator();
- while (iter.hasNext()) {
- PackageIdentification packageId = (PackageIdentification)iter.next();
- Spd spd = spdTable.get(packageId);
- msaFile = spd.getModuleFile(moduleId);
- if (msaFile != null ) {
- break ;
- }
- }
- if (msaFile == null){
- throw new EdkException("Can't find Module [" + moduleId.getName() + "] in any SPD package!");
- } else {
- return msaFile;
- }
- }
-
- public synchronized static PackageIdentification getPackageForModule(ModuleIdentification moduleId) throws EdkException {
- //
- // If package already defined in module
- //
- if (moduleId.getPackage() != null) {
- return moduleId.getPackage();
- }
-
- PackageIdentification packageId = null;
- Iterator iter = packageList.iterator();
- while (iter.hasNext()) {
- PackageIdentification pid = (PackageIdentification)iter.next();
- moduleId.setPackage(pid);
- Spd spd = spdTable.get(pid);
- File tempMsaFile = null;
- if ((tempMsaFile = spd.getModuleFile(moduleId)) != null ) {
- if (tempMsaFile.getParent().equalsIgnoreCase(moduleId.getMsaFile().getParent())) {
- packageId = pid;
- break ;
- }
- tempMsaFile = null;
- }
- }
- if (packageId == null){
- throw new EdkException("Can't find Module [" + moduleId.getName() + "] in any package!");
- } else {
- return packageId;
- }
- }
-
- /**
- Difference between build and parse: ToolChain and Target
- **/
- public synchronized static boolean isModuleBuilt(FpdModuleIdentification moduleId) {
- return builtModules.contains(moduleId);
- }
-
- public synchronized static void registerBuiltModule(FpdModuleIdentification fpdModuleId) {
- builtModules.add(fpdModuleId);
- }
-
-
- public synchronized static void registerFpdModuleSA(FpdModuleIdentification fpdModuleId, Map<String, XmlObject> doc) throws EdkException{
- Map<String, XmlObject> result = new HashMap<String, XmlObject>();
- Set keySet = doc.keySet();
- Iterator iter = keySet.iterator();
- while (iter.hasNext()){
- String key = (String)iter.next();
- XmlObject item = cloneXmlObject(doc.get(key), true);
- result.put(key, item);
- }
- fpdModuleSA.put(fpdModuleId, result);
- }
-
- public synchronized static boolean hasFpdModuleSA(FpdModuleIdentification fpdModuleId) {
- return fpdModuleSA.containsKey(fpdModuleId);
- }
-
- /**
- Query module surface area information.
-
- <p>Note that surface area parsing is incremental. That means the method will
- only parse the MSA files if necessary. </p>
-
- @param fpdModuleId Module ID with arch
- @return ModuleSA info and MSA info for fpdModuleId
- @throws BuildException Can't find MSA
- **/
- public synchronized static Map<String, XmlObject> getDoc(FpdModuleIdentification fpdModuleId) throws EdkException{
- if (parsedModules.containsKey(fpdModuleId)) {
- return parsedModules.get(fpdModuleId);
- }
- Map<String, XmlObject> doc = new HashMap<String, XmlObject>();
- ModuleIdentification moduleId = fpdModuleId.getModule();
- //
- // First part: get the MSA files info
- //
- doc.putAll(getNativeMsa(moduleId));
-
- //
- // Second part: put build options
- //
- doc.put("BuildOptions", fpdBuildOptions);
-
- //
- // Third part: get Module info from FPD, such as Library instances, PCDs
- //
- if (fpdModuleSA.containsKey(fpdModuleId)){
- //
- // merge module info in FPD to final Doc
- // For Library Module, do nothing here
- //
- doc.putAll(fpdModuleSA.get(fpdModuleId));
- }
- parsedModules.put(fpdModuleId, doc);
- return doc;
- }
-
- public synchronized static Map<String, XmlObject> getDoc(ModuleIdentification moduleId, String arch) throws EdkException{
- FpdModuleIdentification fpdModuleId = new FpdModuleIdentification(moduleId, arch);
- return getDoc(fpdModuleId);
- }
-
- /**
- Query the native MSA information with module base name.
-
- <p>Note that MSA parsing is incremental. That means the method will
- only to parse the MSA files when never parsed before. </p>
-
- @param moduleName the base name of the module
- @return the native MSA information
- @throws BuildException
- MSA file is not valid
- **/
- public synchronized static Map<String, XmlObject> getNativeMsa(ModuleIdentification moduleId) throws EdkException {
- if (nativeMsa.containsKey(moduleId)) {
- return nativeMsa.get(moduleId);
- }
- File msaFile = getMsaFile(moduleId);
- Map<String, XmlObject> msaMap = getNativeMsa(msaFile);
- nativeMsa.put(moduleId, msaMap);
- return msaMap;
- }
-
- public synchronized static Map<String, XmlObject> getNativeMsa(File msaFile) throws EdkException {
- if (!msaFile.exists()) {
- throw new EdkException("Module Surface Area file [" + msaFile.getPath() + "] can't be found!");
- }
- try {
- ModuleSurfaceAreaDocument doc = (ModuleSurfaceAreaDocument)parseXmlFile(msaFile);
- //
- // parse MSA file
- //
- ModuleSurfaceArea msa= doc.getModuleSurfaceArea();
- Map<String, XmlObject> msaMap = new HashMap<String, XmlObject>();
- msaMap.put("MsaHeader", cloneXmlObject(msa.getMsaHeader(), true));
- msaMap.put("ModuleDefinitions", cloneXmlObject(msa.getModuleDefinitions(), true));
- msaMap.put("LibraryClassDefinitions", cloneXmlObject(msa.getLibraryClassDefinitions(), true));
- msaMap.put("SourceFiles", cloneXmlObject(msa.getSourceFiles(), true));
- msaMap.put("PackageDependencies", cloneXmlObject(msa.getPackageDependencies(), true));
- msaMap.put("Protocols", cloneXmlObject(msa.getProtocols(), true));
- msaMap.put("PPIs", cloneXmlObject(msa.getPPIs(), true));
- msaMap.put("Guids", cloneXmlObject(msa.getGuids(), true));
- msaMap.put("Events", cloneXmlObject(msa.getEvents(), true));
- msaMap.put("Hobs", cloneXmlObject(msa.getHobs(), true));
- msaMap.put("Variables", cloneXmlObject(msa.getVariables(), true));
- msaMap.put("SystemTables", cloneXmlObject(msa.getSystemTables(), true));
- msaMap.put("DataHubs", cloneXmlObject(msa.getDataHubs(), true));
- msaMap.put("HiiPackages", cloneXmlObject(msa.getHiiPackages(), true));
- msaMap.put("Externs", cloneXmlObject(msa.getExterns(), true));
- msaMap.put("PcdCoded", cloneXmlObject(msa.getPcdCoded(), true));
- msaMap.put("ModuleBuildOptions", cloneXmlObject(msa.getModuleBuildOptions(), true));
- return msaMap;
- } catch(IOException ex) {
- EdkException edkException = new EdkException("Parse of MSA file [" + msaFile.getPath() + "] failed!\n" + ex.getMessage());
- edkException.setStackTrace(ex.getStackTrace());
- throw edkException;
- } catch(XmlException ex) {
- EdkException edkException = new EdkException("Parse of MSA file [" + msaFile.getPath() + "] failed!\n" + ex.getMessage());
- edkException.setStackTrace(ex.getStackTrace());
- throw edkException;
- }
- }
-
- public static Map<String, XmlObject> getFpdBuildOptionsMap() {
- return fpdBuildOptionsMap;
- }
-
- public static void setFpdBuildOptions(XmlObject fpdBuildOptions) throws EdkException {
- GlobalData.fpdBuildOptions = cloneXmlObject(fpdBuildOptions, true);
- fpdBuildOptionsMap.put("BuildOptions", GlobalData.fpdBuildOptions);
- }
-
- public static XmlObject getFpdDynamicPcds() {
- return fpdDynamicPcds;
- }
-
- public static void setFpdDynamicPcds(XmlObject fpdDynamicPcds) {
- GlobalData.fpdDynamicPcds = fpdDynamicPcds;
- }
-
- public static Set<ModuleIdentification> getModules(PackageIdentification packageId){
- Spd spd = spdTable.get(packageId);
- if (spd == null ) {
- Set<ModuleIdentification> dummy = new HashSet<ModuleIdentification>();
- return dummy;
- } else {
- return spd.getModules();
- }
- }
-
- /**
- * The header file path is relative to workspace dir
- */
- public static String[] getLibraryClassHeaderFiles(
- PackageIdentification[] packages, String name) throws EdkException{
- if (packages == null) {
- // throw Exception or not????
- return new String[0];
- }
- String[] result = null;
- for (int i = 0; i < packages.length; i++) {
- Spd spd = spdTable.get(packages[i]);
- //
- // If find one package defined the library class
- //
- if ((result = spd.getLibClassIncluder(name)) != null) {
- return result;
- }
- }
- //
- // If can't find library class declaration in every package
- //
- throw new EdkException("Can not find library class [" + name
- + "] declaration in any SPD package!");
- }
-
- /**
- * The header file path is relative to workspace dir
- */
- public static String getPackageHeaderFiles(PackageIdentification packages,
- String moduleType) {
- if (packages == null) {
- return new String("");
- }
- Spd spd = spdTable.get(packages);
- //
- // If can't find package header file, skip it
- //
- String temp = null;
- if (spd != null) {
- if ((temp = spd.getPackageIncluder(moduleType)) != null) {
- return temp;
- } else {
- temp = "";
- return temp;
- }
- } else {
- return null;
- }
- }
-
- /**
- * return two values: {cName, GuidValue}
- */
- public static String[] getGuid(List<PackageIdentification> packages, String name) {
- if (packages == null) {
- // throw Exception or not????
- return new String[0];
- }
- String[] result = null;
- Iterator item = packages.iterator();
- while (item.hasNext()){
- Spd spd = spdTable.get(item.next());
- //
- // If find one package defined the GUID
- //
- if ((result = spd.getGuid(name)) != null) {
- return result;
- }
- }
-
- return null;
- }
-
- /**
- * return two values: {cName, GuidValue}
- */
- public static String[] getPpiGuid(List<PackageIdentification> packages,
- String name) {
- if (packages == null) {
- return new String[0];
- }
- String[] result = null;
- Iterator item = packages.iterator();
- while (item.hasNext()){
- Spd spd = spdTable.get(item.next());
- //
- // If find one package defined the Ppi GUID
- //
- if ((result = spd.getPpi(name)) != null) {
- return result;
- }
- }
- return null;
- }
-
- /**
- * return two values: {cName, GuidValue}
- */
- public static String[] getProtocolGuid(List<PackageIdentification> packages,
- String name) {
- if (packages == null) {
- return new String[0];
- }
- String[] result = null;
- Iterator item = packages.iterator();
- while (item.hasNext()){
- Spd spd = spdTable.get(item.next());
- //
- // If find one package defined the protocol GUID
- //
- if ((result = spd.getProtocol(name))!= null){
- return result;
- }
- }
- return null;
-
- }
-
- public synchronized static PlatformIdentification getPlatformByName(String name) throws EdkException {
- Iterator iter = platformList.iterator();
- while(iter.hasNext()){
- PlatformIdentification platformId = (PlatformIdentification)iter.next();
- if (platformId.getName().equalsIgnoreCase(name)) {
- return platformId;
- }
- }
- throw new EdkException("Can't find platform [" + name + "] in the current WORKSPACE database!");
- }
-
- public synchronized static PlatformIdentification getPlatform(String filename) throws EdkException {
- File file = new File(workspaceDir + File.separatorChar + filename);
- Iterator iter = platformList.iterator();
- while(iter.hasNext()){
- PlatformIdentification platformId = (PlatformIdentification)iter.next();
- if (platformId.getFpdFile().getPath().equalsIgnoreCase(file.getPath())) {
- return platformId;
- }
- }
- throw new EdkException("Can't find platform file [" + filename + "] in the current WORKSPACE database!");
- }
-
- public synchronized static PackageIdentification refreshPackageIdentification(PackageIdentification packageId) throws EdkException {
- Iterator iter = packageList.iterator();
- while(iter.hasNext()){
- PackageIdentification packageItem = (PackageIdentification)iter.next();
- if (packageItem.equals(packageId)) {
- packageId.setName(packageItem.getName());
- packageId.setSpdFile(packageItem.getSpdFile());
- return packageId;
- }
- }
- throw new EdkException("Can't find package GUID value " + packageId.toGuidString() + " in the current workspace!");
- }
-
- public synchronized static ModuleIdentification refreshModuleIdentification(ModuleIdentification moduleId) throws EdkException {
- PackageIdentification packageId = getPackageForModule(moduleId);
- moduleId.setPackage(packageId);
- Spd spd = spdTable.get(packageId);
- if (spd == null) {
- throw new EdkException("Can't find package GUID value " + packageId.toGuidString() + " in the current workspace!");
- }
- Set<ModuleIdentification> modules = spd.getModules();
- Iterator<ModuleIdentification> iter = modules.iterator();
- while (iter.hasNext()) {
- ModuleIdentification item = iter.next();
- if (item.equals(moduleId)) {
- moduleId.setName(item.getName());
- moduleId.setModuleType(item.getModuleType());
- moduleId.setMsaFile(item.getMsaFile());
- return moduleId;
- }
- }
- throw new EdkException("Can't find " + moduleId + " under the current workspace!");
- }
-
- public synchronized static Set<PackageIdentification> getPackageList(){
- return packageList;
- }
-
- /**
- BUGBUG: It is a walk around method. If do not clone, can't query info with
- XPath correctly.
-
- @param object XmlObject
- @param deep flag for deep clone
- @return XmlObject after clone
- @throws BuildException parse original XmlObject error.
- **/
- private static XmlObject cloneXmlObject(XmlObject object, boolean deep) throws EdkException {
- if ( object == null) {
- return null;
- }
- XmlObject result = null;
- try {
- result = XmlObject.Factory.parse(object.getDomNode()
- .cloneNode(deep));
- } catch (XmlException ex) {
- EdkException edkException = new EdkException(ex.getMessage());
- edkException.setStackTrace(ex.getStackTrace());
- throw edkException;
- }
- return result;
- }
-
- ///
- /// Tool Chain Related, try to refine and put some logic process to ToolChainFactory
- ///
- public synchronized static ToolChainInfo getToolChainInfo() {
- if (toolChainInfo == null) {
- toolChainInfo = toolsDef.getConfigInfo().intersection(toolChainEnvInfo);
- if (toolChainPlatformInfo != null) {
- toolChainInfo = toolChainInfo.intersection(toolChainPlatformInfo);
- }
- toolChainInfo.addCommands(toolsDef.getConfigInfo().getCommands());
- toolChainInfo.normalize();
-
- EdkLog.log("Init", EdkLog.EDK_ALWAYS, "Current build tool chain information summary: ");
- EdkLog.log("Init", EdkLog.EDK_ALWAYS, toolChainInfo + "");
- }
- return toolChainInfo;
- }
-
- public static void setPlatformToolChainFamilyOption(ToolChainMap map) {
- platformToolChainFamilyOption = map;
- }
-
- public static void setPlatformToolChainOption(ToolChainMap map) {
- platformToolChainOption = map;
- }
-
- public static void addModuleToolChainOption(FpdModuleIdentification fpdModuleId,
- ToolChainMap toolChainOption) {
- moduleToolChainOption.put(fpdModuleId, toolChainOption);
- }
-
- public static void addModuleToolChainFamilyOption(FpdModuleIdentification fpdModuleId,
- ToolChainMap toolChainOption) {
- moduleToolChainFamilyOption.put(fpdModuleId, toolChainOption);
- }
-
- public static void addMsaBuildOption(ModuleIdentification moduleId,
- ToolChainMap toolChainOption) {
- msaBuildOption.put(moduleId, toolChainOption);
- }
-
- public static void addMsaFamilyBuildOption(ModuleIdentification moduleId,
- ToolChainMap toolChainOption) {
- msaFamilyBuildOption.put(moduleId, toolChainOption);
- }
-
- public static boolean isCommandSet(String target, String toolchain, String arch) throws EdkException {
- String[] commands = getToolChainInfo().getCommands();
-
- for (int i = 0; i < commands.length; ++i) {
- String cmdName = toolsDef.getConfig().get(new String[] {target, toolchain, arch, commands[i], ToolDefinitions.TOOLS_DEF_ATTRIBUTE_NAME});
- if (cmdName != null && cmdName.length() != 0) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- Except FLAGS, all attribute are from TOOLS_DEF file.
-
- For FLAGS, information from four places, they are:
- <pre>
- 1. tools_def.txt
- 2. MSA &lt;BuildOptions&gt;/&lt;Options&gt;
- 3. FPD &lt;BuildOptions&gt;/&lt;Options&gt;
- 4. FPD &lt;FrameworkModules&gt;/&lt;ModuleSaBuildOptions&gt;/&lt;Options&gt;
- </pre>
-
- @param commandDescription Key: TARGET, TAGNAME, ARCH, COMMANDTYPE, ATTRIBUTE
- @param fpdModuleId Module Identification with Arch
- @return The corresponding String
- @throws EdkException If build option definition error
- **/
- public synchronized static String getCommandSetting(String[] commandDescription, FpdModuleIdentification fpdModuleId) throws EdkException {
- ToolChainKey toolChainKey = new ToolChainKey(commandDescription);
- ToolChainMap toolChainConfig = toolsDef.getConfig();
- String setting = null;
-
- //
- // Default in tools_def.txt
- //
- setting = toolChainConfig.get(toolChainKey);
- if (setting == null) {
- setting = "";
- }
- if (!commandDescription[ToolChainElement.ATTRIBUTE.value].equals(ToolDefinitions.TOOLS_DEF_ATTRIBUTE_FLAGS)) {
- return setting;
- }
-
- Set<String> flagSet = new LinkedHashSet<String>();
- flagSet.add(setting);
-
- //
- // Tool's option can be in .fpd and/or .msa file
- //
- String optionString;
- ToolChainMap option = null;
- ToolChainKey toolChainFamilyKey = new ToolChainKey(commandDescription);
-
- toolChainFamilyKey.setKey(ToolDefinitions.TOOLS_DEF_ATTRIBUTE_FAMILY, ToolChainElement.ATTRIBUTE.value);
- String family = toolChainConfig.get(toolChainFamilyKey);
- toolChainFamilyKey.setKey(family, ToolChainElement.TOOLCHAIN.value);
- toolChainFamilyKey.setKey(ToolDefinitions.TOOLS_DEF_ATTRIBUTE_FLAGS, ToolChainElement.ATTRIBUTE.value);
-
- //
- // MSA's tool chain family option
- //
- option = msaFamilyBuildOption.get(fpdModuleId.getModule());
- if (option != null && (optionString = option.get(toolChainFamilyKey)) != null) {
- flagSet.add(optionString);
- }
-
- //
- // MSA's tool chain option
- //
- option = msaBuildOption.get(fpdModuleId.getModule());
- if (option != null && (optionString = option.get(toolChainKey)) != null) {
- flagSet.add(optionString);
- }
-
- //
- // Platform's tool chain family option
- //
- optionString = platformToolChainFamilyOption.get(toolChainFamilyKey);
- if (optionString != null) {
- flagSet.add(optionString);
- }
-
- //
- // Platform's tool chain tag option
- //
- optionString = platformToolChainOption.get(toolChainKey);
- if (optionString != null) {
- flagSet.add(optionString);
- }
-
- //
- // Module's tool chain family option
- //
- option = moduleToolChainFamilyOption.get(fpdModuleId);
- if (option != null && (optionString = option.get(toolChainFamilyKey)) != null) {
- flagSet.add(optionString);
- }
-
- //
- // Module's tool chain tag option
- //
- option = moduleToolChainOption.get(fpdModuleId);
- if (option != null && (optionString = option.get(toolChainKey)) != null) {
- flagSet.add(optionString);
- }
-
- setting = "";
- for(Iterator<String> iter = flagSet.iterator(); iter.hasNext();) {
- setting += iter.next() +" ";
- }
- return setting;
- }
-
- public static void setToolChainEnvInfo(ToolChainInfo envInfo) {
- toolChainEnvInfo = envInfo;
- }
- public static void setToolChainPlatformInfo(ToolChainInfo platformInfo) {
- toolChainPlatformInfo = platformInfo;
- }
-
- //
- // for PCD
- //
- public synchronized static MemoryDatabaseManager getPCDMemoryDBManager() {
- return pcdDbManager;
- }
-
- //
- // For PCD get tokenSpaceGUid
- //
- public synchronized static String getGuidInfoFromCname(String cName){
- String cNameGuid = null;
- String guid = null;
- Set set = spdTable.keySet();
- Iterator iter = set.iterator();
-
- if (iter == null) {
- return null;
- }
-
- while (iter.hasNext()){
- Spd spd = (Spd) spdTable.get(iter.next());
- guid = spd.getGuidFromCname(cName);
- if (guid != null){
- cNameGuid = guid;
- break;
- }
- }
- return cNameGuid;
- }
-
- //
- // For PCD
- //
- public synchronized static Map<FpdModuleIdentification, XmlObject>
- getFpdModuleSaXmlObject(String xmlObjectName) {
- Set<FpdModuleIdentification> fpdModuleSASet = fpdModuleSA.keySet();
- Iterator item = fpdModuleSASet.iterator();
-
-
- Map<FpdModuleIdentification, XmlObject> SAPcdBuildDef = new HashMap<FpdModuleIdentification, XmlObject>();
- Map<String, XmlObject> SANode = new HashMap<String, XmlObject>();
- FpdModuleIdentification moduleId;
- while (item.hasNext()) {
-
- moduleId = (FpdModuleIdentification) item.next();
- SANode = fpdModuleSA.get(moduleId);
- try{
- if (SANode.get(xmlObjectName)!= null){
- SAPcdBuildDef.put(moduleId,
- (XmlObject) SANode.get(xmlObjectName));
-
- }
- } catch (Exception e){
- EdkLog.log(EdkLog.EDK_INFO, e.getMessage());
- }
- }
- return SAPcdBuildDef;
- }
-
- public synchronized static Map<FpdModuleIdentification,XmlObject> getFpdPcdBuildDefinitions() {
- Map<FpdModuleIdentification,XmlObject> pcdBuildDef = getFpdModuleSaXmlObject ("PcdBuildDefinition");
-
- return pcdBuildDef;
- }
-
- public static XmlObject parseXmlFile(File xmlFile) throws IOException, XmlException {
- Collection errors = new ArrayList();
- XmlOptions opt = new XmlOptions();
-
- opt.setLoadLineNumbers();
- opt.setLoadMessageDigest();
- opt.setErrorListener(errors);
-
- XmlObject doc = XmlObject.Factory.parse(xmlFile, opt);
- //
- // Validate File if they accord with XML Schema
- //
- if (!doc.validate(opt)){
- StringBuilder errorMessage = new StringBuilder(1024);
- for (Iterator it = errors.iterator(); it.hasNext(); ) {
- errorMessage.append(it.next());
- errorMessage.append("\n");
- }
- throw new XmlException(errorMessage.toString());
- }
-
- return doc;
- }
-}
-
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/global/OnDependency.java b/Tools/Java/Source/GenBuild/org/tianocore/build/global/OnDependency.java
deleted file mode 100644
index 678bfb869b..0000000000
--- a/Tools/Java/Source/GenBuild/org/tianocore/build/global/OnDependency.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/** @file
-This file is to define OnDependency 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.global;
-
-import java.io.File;
-import java.util.Iterator;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.taskdefs.Sequential;
-import org.tianocore.common.logger.EdkLog;
-import org.tianocore.common.cache.FileTimeStamp;
-
-/**
- Class OnDepdendency is used to check the timestamp between source files and
- target files, which can be used to determine if the target files are needed to
- be re-generated from source files.
- **/
-public class OnDependency extends Task {
- //
- // source files list
- //
- private DpFileList sources = null;
-
- //
- // target files list
- //
- private DpFileList targets = null;
-
- //
- // tasks to be performed to generate target files
- //
- private Sequential task = null;
-
- /**
- An empty constructor for an ANT task can avoid some potential issues
- **/
- public OnDependency(){
- }
-
- /**
- Standard execute method of ANT task
- **/
- public void execute() throws BuildException {
- if (isOutOfDate() && task != null) {
- task.perform();
- }
-
- //
- // Update the time stamp of target files since they are just re-generated
- //
- for (Iterator dstIt = targets.nameList.iterator(); dstIt.hasNext();) {
- FileTimeStamp.update((String)dstIt.next());
- }
- }
-
- //
- // check if the target files are outofdate
- //
- private boolean isOutOfDate() {
- ///
- /// if no source files specified, take it as a fresh start
- ///
- if (sources.nameList.size() == 0) {
- EdkLog.log(this, EdkLog.EDK_VERBOSE, "No source file spcified!");
- return true;
- }
-
- if (targets.nameList.size() == 0) {
- EdkLog.log(this, EdkLog.EDK_VERBOSE, "No target file found!");
- return true;
- }
-
- Iterator dstIt = targets.nameList.iterator();
- while (dstIt.hasNext()) {
- String dstFileName = (String)dstIt.next();
- File dstFile = new File(dstFileName);
- if (!dstFile.exists()) {
- EdkLog.log(this, EdkLog.EDK_VERBOSE, "Target file [" + dstFileName + "] doesn't exist!");
- return true;
- }
-
- long dstTimeStamp = FileTimeStamp.get(dstFileName);
- Iterator srcIt = sources.nameList.iterator();
- while (srcIt.hasNext()) {
- String srcFileName = (String)srcIt.next();
- long srcTimeStamp = FileTimeStamp.get(srcFileName);
-
- if (srcTimeStamp == 0) {
- //
- // time stamp 0 means that the file doesn't exist
- //
- throw new BuildException("Source File name: " + srcFileName + " doesn't exist!!!");
- }
-
- if (dstTimeStamp < srcTimeStamp) {
- EdkLog.log(this, EdkLog.EDK_VERBOSE, "Source file [" + srcFileName + "] has been changed since last build!");
- return true;
- }
- }
- }
-
- EdkLog.log(this, EdkLog.EDK_VERBOSE, "Target files are up-to-date!");
- return false;
- }
-
- /**
- Add method of ANT task for nested element with Sequential type
-
- @param task Sequential object which contains tasks for generating target files
- **/
- public void addSequential(Sequential task) {
- this.task = task;
- }
-
- /**
- Add method of ANT task for nested element with DpFileList type
-
- @param sources DpFileList object which contains the list of source files
- **/
- public void addSourcefiles(DpFileList sources) {
- this.sources = sources;
- }
-
- /**
- Add method of ANT task for nested element with DpFileList type
-
- @param targets DpFileList object which contains the list of target files
- **/
- public void addTargetfiles(DpFileList targets) {
- this.targets = targets;
- }
-}
-
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/global/OutputManager.java b/Tools/Java/Source/GenBuild/org/tianocore/build/global/OutputManager.java
deleted file mode 100644
index 2c70326202..0000000000
--- a/Tools/Java/Source/GenBuild/org/tianocore/build/global/OutputManager.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/** @file
- OutputManager class.
-
- OutputManager class set output directories for every module by BUILD_MODE.
-
-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.global;
-
-import org.apache.tools.ant.Project;
-import java.io.File;
-
-/**
- OutputManager class is used to setup output directories (BIN_DIR, DEST_DIR_OUTPUT,
- DEST_DIR_DEBUG).
-
- @since GenBuild 1.0
-**/
-public class OutputManager {
-
- ///
- /// means intermediate files will put under Module's dir
- ///
- private String MODULE = "MODULE";
-
- ///
- /// mean intermediate files will put under a unify dir
- ///
- private String UNIFIED = "UNIFIED";
-
-
- private String userdir;
-
- private String type;
- ///
- /// Singleton Design Pattern
- ///
- private static OutputManager object;
-
- public synchronized static OutputManager getInstance() {
- if ( object == null ) {
- object = new OutputManager();
- }
- return object;
- }
-
- public void setup(String userdir, String type) {
- this.userdir = userdir;
- this.type = type;
- }
-
- /**
- Setup BIN_DIR, DEST_DIR_OUTPUT and DEST_DIR_OUTPUT, following are the rules:
-
- <p>Divide all output files into two types: one is final files, such as FFS
- file for driver module while LIB file for library module; another is
- intermediate files, such AutoGen.c, OBJ files, Section files and so on.
-
- <p>In FPD, OutputDirectory element is used to specify where to put the output
- files to. There are two mode (MODULE | UNIFIED). MODULE mode means that all
- output files will put to the module directory while UNIFIED mode means that
- all output files will put together. Default is UNIFIED mode.
-
- <p>BUILD_DIR is the base directory for current module build. By default,
- BUILD_DIR is PLATFORM_DIR/Build in UNIFIED mode while is MODULE_DIR/Build
- in MODULE mode. Of course, user can customize BUILD_DIR. If user-defined
- BUILD_DIR is relative path, then look as related to WORKSPACE_DIR.
-
- <p>Then, BIN_DIR is BUILD_DIR/TARGET/TOOLCHAIN/ARCH;
-
- <p>FV_DIR is BUILD_DIR/TARGET/TOOLCHAIN/FV;
-
- <p>DEST_DIR_DEBUG | DEST_DIR_OUTPUT is:
- BIN_DIR/PACKAGE_RELATIVE_DIR/MODULE_RELATIVE_DIR/DEBUG | OUTPUT
-
-
- @param project current ANT build Project
- @param userdir user-defined directory
- @param type the module build type (MODULE or UNIFIED)
- **/
- public void update(Project project) {
- //
- // Default mode is UNIFIED.
- //
- if (type != null && type.equalsIgnoreCase(MODULE)) {
- type = MODULE;
- }
- else {
- type = UNIFIED;
- }
-
- //
- // default BUILD_DIR value
- //
- String buildDir;
- if(type.equals(MODULE)){
- buildDir = project.getProperty("MODULE_DIR") + File.separatorChar + "Build";
- }
- else {
- buildDir = project.getProperty("PLATFORM_DIR") + File.separatorChar + "Build";
- }
-
- //
- // If user define BUILD_DIR
- //
- if (userdir != null && ! userdir.equals("")) {
- File buildFile = new File(userdir);
- if (buildFile.isAbsolute()){
- buildDir = userdir;
- }
- //
- // If path is not absolute, then look as related to WORKSPACE_DIR
- //
- else {
- buildDir = GlobalData.getWorkspacePath() + File.separatorChar + userdir;
- }
- }
-
- //
- // Define TARGET_DIR
- //
- String targetDir = buildDir + File.separatorChar + project.getProperty("TARGET")
- + "_" + project.getProperty("TOOLCHAIN");
-
- //
- // Define BIN_DIR and FV_DIR
- //
- String binDir = targetDir + File.separatorChar + project.getProperty("ARCH") ;
-
- String fvDir = targetDir + File.separatorChar + "FV";
-
- //
- // Define DEST_DIR_OUTPUT and DEST_DIR_DEBUG
- //
- String destDir = binDir + File.separatorChar + project.getProperty("PACKAGE_RELATIVE_DIR")
- + File.separatorChar + project.getProperty("MODULE_RELATIVE_DIR");
-
- //
- // Set properties
- //
- project.setProperty("BUILD_DIR", buildDir.replaceAll("(\\\\)", "/"));
- project.setProperty("TARGET_DIR", targetDir.replaceAll("(\\\\)", "/"));
- project.setProperty("FV_DIR", fvDir.replaceAll("(\\\\)", "/"));
- project.setProperty("BIN_DIR", binDir.replaceAll("(\\\\)", "/"));
- project.setProperty("DEST_DIR_DEBUG", (destDir + File.separatorChar + "DEBUG").replaceAll("(\\\\)", "/"));
- project.setProperty("DEST_DIR_OUTPUT", (destDir + File.separatorChar + "OUTPUT").replaceAll("(\\\\)", "/"));
-
- //
- // Create all directory if necessary
- //
- (new File(buildDir)).mkdirs();
- (new File(fvDir)).mkdirs();
- (new File(binDir)).mkdirs();
- (new File(destDir + File.separatorChar + "DEBUG")).mkdirs();
- (new File(destDir + File.separatorChar + "OUTPUT")).mkdirs();
- }
-
- public boolean prepareBuildDir(Project project){
- boolean isUnified = true;
-
- if (type.equalsIgnoreCase("MODULE")) {
- isUnified = false;
- }
-
- String buildDir = project.getProperty("PLATFORM_DIR") + File.separatorChar + "Build";
- //
- // If user define BUILD_DIR
- //
- if (userdir != null && ! userdir.equals("")) {
- File buildFile = new File(userdir);
- if (buildFile.isAbsolute()){
- buildDir = userdir;
- }
- //
- // If path is not absolute, then look as related to WORKSPACE_DIR
- //
- else {
- buildDir = GlobalData.getWorkspacePath() + File.separatorChar + userdir;
- }
- }
-
- //
- // Set to property
- //
- project.setProperty("BUILD_DIR", buildDir.replaceAll("(\\\\)", "/"));
-
- //
- // Create all directory if necessary
- //
- (new File(buildDir)).mkdirs();
- return isUnified;
- }
-
-} \ No newline at end of file
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/global/Spd.java b/Tools/Java/Source/GenBuild/org/tianocore/build/global/Spd.java
deleted file mode 100644
index 951817f64c..0000000000
--- a/Tools/Java/Source/GenBuild/org/tianocore/build/global/Spd.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/** @file
- Spd class.
-
- This class is to generate a global table for the content of spd file.
-
- 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.global;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.xmlbeans.XmlException;
-import org.apache.xmlbeans.XmlObject;
-import org.tianocore.build.id.ModuleIdentification;
-import org.tianocore.build.id.PackageIdentification;
-import org.tianocore.common.exception.EdkException;
-
-/**
-
- This class is to generate a global table for the content of spd file.
-
-**/
-public class Spd {
- ///
- ///
- ///
- Map<ModuleIdentification, File> msaInfo = new HashMap<ModuleIdentification, File>();
-
- ///
- /// Map of module info.
- /// Key : moduletype
- /// Value: moduletype related include file
- ///
- Map<String, String> packageHeaderInfo = new HashMap<String, String>();
-
- ///
- /// Map of PPI info.
- /// Key : PPI name
- /// value: String[] a. PPI C_NAME; b. PPI GUID;
- ///
- Map<String, String[]> ppiInfo = new HashMap<String, String[]>();
-
- ///
- /// Map of Protocol info.
- /// Key : Protocol name
- /// value: String[] a. Protocol C_NAME; b. Protocol GUID;
- ///
- Map<String, String[]> protocolInfo = new HashMap<String, String[]>();
-
- ///
- /// Map of Guid info.
- /// Key : Guid name
- /// value: String[] a. Guid C_NAME; b. Guid's GUID;
- ///
- Map<String, String[]> guidInfo = new HashMap<String, String[]>();
-
- ///
- /// Map of Guid info
- /// Key: GuidCName
- /// value: String Guid's GUID
- ///
- Map<String, String> guidCnameInfo = new HashMap<String, String>();
-
- /// Map of library class and its exposed header file.
- /// Key : library class name
- /// value : library class corresponding header file
- ///
- Map<String, String[]> libClassHeaderList = new HashMap<String, String[]>();
-
- ///
- /// Package path.
- ///
- PackageIdentification packageId;
-
- /**
- Constructor function
-
- This function mainly initialize some member variables.
- **/
- Spd(File packageFile) throws EdkException {
- //
- // If specified package file not exists
- //
- if ( ! packageFile.exists()) {
- throw new EdkException("Package file [" + packageFile.getPath() + "] does not exist!");
- }
- try {
- XmlObject spdDoc = GlobalData.parseXmlFile(packageFile);
- //
- // We can change Map to XmlObject
- //
- Map<String, XmlObject> spdDocMap = new HashMap<String, XmlObject>();
- spdDocMap.put("PackageSurfaceArea", spdDoc);
- SurfaceAreaQuery saq = new SurfaceAreaQuery(spdDocMap);
-
- packageId = saq.getSpdHeader();
- packageId.setSpdFile(packageFile);
-
- //
- // initialize Msa Files
- // MSA file is absolute file path
- //
- String[] msaFilenames = saq.getSpdMsaFile();
- for (int i = 0; i < msaFilenames.length; i++){
- File msaFile = new File(packageId.getPackageDir() + File.separatorChar + msaFilenames[i]);
- Map<String, XmlObject> msaDoc = GlobalData.getNativeMsa( msaFile );
- saq.push(msaDoc);
- ModuleIdentification moduleId = saq.getMsaHeader();
- saq.pop();
- moduleId.setPackage(packageId);
- moduleId.setMsaFile(msaFile);
- if (msaInfo.containsKey(moduleId)) {
- throw new EdkException("Found two modules with the same GUID and Version in package " + packageId + ".\nThey are module [" + msaInfo.get(moduleId) + "] and MSA file [" + msaFile + "]!");
- }
- msaInfo.put(moduleId, msaFile);
- }
-
- //
- // initialize Package header files
- //
- Map<String, String> packageHeaders = saq.getSpdPackageHeaderFiles();
- Set keys = packageHeaders.keySet();
- Iterator iter = keys.iterator();
- while (iter.hasNext()){
- String moduleType = (String)iter.next();
- String header = packageId.getPackageRelativeDir() + File.separatorChar + packageHeaders.get(moduleType);
-
- //
- // Change path seperator to system-dependent path separator
- //
- File file = new File (header);
- header = file.getPath();
- packageHeaderInfo.put(moduleType, header);
- }
-
- //
- // initialize Guid Info
- //
- guidInfo.putAll(saq.getSpdGuid());
-
- //
- // For Pcd get TokenSpaceGuid
- //
- Set<String> key = guidInfo.keySet();
- Iterator item = key.iterator();
- String [] nameValue = new String[2];
- while(item.hasNext()){
- nameValue = guidInfo.get(item.next());
- guidCnameInfo.put(nameValue[0], nameValue[1]);
- }
-
- //
- // initialize PPI info
- //
- ppiInfo.putAll(saq.getSpdPpi());
-
- //
- // initialize Protocol info
- //
- protocolInfo.putAll(saq.getSpdProtocol());
-
- //
- // initialize library class declaration
- //
- Map<String, String[]> libraryClassHeaders = saq.getSpdLibraryClasses();
- keys = libraryClassHeaders.keySet();
- iter = keys.iterator();
- while (iter.hasNext()){
- String libraryClassName = (String)iter.next();
- String[] headerFiles = libraryClassHeaders.get(libraryClassName);
- for (int i = 0; i < headerFiles.length; i++){
- headerFiles[i] = packageId.getPackageRelativeDir() + File.separatorChar + headerFiles[i];
-
- //
- // Change path separator to system system-dependent path separator.
- //
- File file = new File (headerFiles[i]);
- headerFiles[i] = file.getPath();
- }
- libClassHeaderList.put(libraryClassName, headerFiles);
- }
- } catch (IOException ex) {
- EdkException edkException = new EdkException("Parse of the package description file [" + packageFile.getPath() + "] failed!\n" + ex.getMessage());
- edkException.setStackTrace(ex.getStackTrace());
- throw edkException;
- } catch (XmlException ex) {
- EdkException edkException = new EdkException("Parse of the package description file [" + packageFile.getPath() + "] failed!\n" + ex.getMessage());
- edkException.setStackTrace(ex.getStackTrace());
- throw edkException;
- }
- }
-
- public PackageIdentification getPackageId() {
- return packageId;
- }
-
- public File getModuleFile(ModuleIdentification moduleId) {
- return msaInfo.get(moduleId);
- }
-
- public Set<ModuleIdentification> getModules(){
- return msaInfo.keySet();
- }
-
- /**
- return two value {CName, Guid}. If not found, return null.
- **/
- public String[] getPpi(String ppiName) {
- return ppiInfo.get(ppiName);
- }
-
- /**
- return two value {CName, Guid}. If not found, return null.
- **/
- public String[] getProtocol(String protocolName) {
- return protocolInfo.get(protocolName);
- }
-
- /**
- return two value {CName, Guid}. If not found, return null.
- **/
- public String[] getGuid(String guidName) {
- return guidInfo.get(guidName);
- }
-
- /**
- * return Guid Value.
- */
- public String getGuidFromCname(String cName){
- return guidCnameInfo.get(cName);
- }
-
- /**
- getLibClassInclude
-
- This function is to get the library exposed header file name according
- library class name.
-
- @param libName Name of library class
- @return Name of header file
- **/
- String[] getLibClassIncluder(String libName) {
- return libClassHeaderList.get(libName);
- }
-
- /**
- getModuleTypeIncluder
-
- This function is to get the header file name from module info map
- according to module type.
-
- @param moduleType Module type.
- @return Name of header file.
- **/
- String getPackageIncluder(String moduleType) {
- return packageHeaderInfo.get(moduleType);
- }
-
-
-}
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java b/Tools/Java/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java
deleted file mode 100644
index acd8182d3b..0000000000
--- a/Tools/Java/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java
+++ /dev/null
@@ -1,2356 +0,0 @@
-/** @file
- This file is for surface area information retrieval.
-
- 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.global;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Stack;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlString;
-import org.tianocore.*;
-import org.tianocore.ExternsDocument.Externs.Extern;
-import org.tianocore.FilenameDocument.Filename;
-import org.tianocore.ModuleDefinitionsDocument.ModuleDefinitions;
-import org.tianocore.MsaHeaderDocument.MsaHeader;
-import org.tianocore.ProtocolsDocument.Protocols.Protocol;
-import org.tianocore.ProtocolsDocument.Protocols.ProtocolNotify;
-import org.tianocore.build.autogen.CommonDefinition;
-import org.tianocore.build.id.FpdModuleIdentification;
-import org.tianocore.build.id.ModuleIdentification;
-import org.tianocore.build.id.PackageIdentification;
-import org.tianocore.build.id.PlatformIdentification;
-import org.tianocore.build.toolchain.ToolChainInfo;
-import org.tianocore.common.definitions.EdkDefinitions;
-import org.tianocore.common.exception.EdkException;
-import org.w3c.dom.Node;
-
-/**
- * SurfaceAreaQuery class is used to query Surface Area information from msa,
- * mbd, spd and fpd files.
- *
- * This class should not instantiated. All the public interfaces is static.
- *
- * @since GenBuild 1.0
- */
-public class SurfaceAreaQuery {
-
- public String prefix = "http://www.TianoCore.org/2006/Edk2.0";
-
- //
- // Contains name/value pairs of Surface Area document object. The name is
- // always the top level element name.
- //
- private Map<String, XmlObject> map = null;
-
- //
- // mapStack is used to do nested query
- //
- private Stack<Map<String, XmlObject>> mapStack = new Stack<Map<String, XmlObject>>();
-
- //
- // prefix of name space
- //
- private String nsPrefix = "sans";
-
- //
- // xmlbeans needs a name space for each Xpath element
- //
- private String ns = null;
-
- //
- // keep the namep declaration for xmlbeans Xpath query
- //
- private String queryDeclaration = null;
- private StringBuffer normQueryString = new StringBuffer(4096);
- private Pattern xPathPattern = Pattern.compile("([^/]*)(/|//)([^/]+)");
-
- /**
- * Set a Surface Area document for query later
- *
- * @param map
- * A Surface Area document in TopLevelElementName/XmlObject
- * format.
- */
- public SurfaceAreaQuery(Map<String, XmlObject> map) {
- ns = prefix;
- queryDeclaration = "declare namespace " + nsPrefix + "='" + ns + "'; ";
- this.map = map;
- }
-
- /**
- * Push current used Surface Area document into query stack. The given new
- * document will be used for any immediately followed getXXX() callings,
- * untill pop() is called.
- *
- * @param newMap
- * The TopLevelElementName/XmlObject format of a Surface Area
- * document.
- */
- public void push(Map<String, XmlObject> newMap) {
- mapStack.push(this.map);
- this.map = newMap;
- }
-
- /**
- * Discard current used Surface Area document and use the top document in
- * stack instead.
- */
- public void pop() {
- this.map = mapStack.pop();
- }
-
- // /
- // / Convert xPath to be namespace qualified, which is necessary for
- // XmlBeans
- // / selectPath(). For example, converting /MsaHeader/ModuleType to
- // / /ns:MsaHeader/ns:ModuleType
- // /
- private String normalizeQueryString(String[] exp, String from) {
- normQueryString.setLength(0);
-
- int i = 0;
- while (i < exp.length) {
- String newExp = from + exp[i];
- Matcher matcher = xPathPattern.matcher(newExp);
-
- while (matcher.find()) {
- String starter = newExp.substring(matcher.start(1), matcher
- .end(1));
- String seperator = newExp.substring(matcher.start(2), matcher
- .end(2));
- String token = newExp.substring(matcher.start(3), matcher
- .end(3));
-
- normQueryString.append(starter);
- normQueryString.append(seperator);
- normQueryString.append(nsPrefix);
- normQueryString.append(":");
- normQueryString.append(token);
- }
-
- ++i;
- if (i < exp.length) {
- normQueryString.append(" | ");
- }
- }
-
- return normQueryString.toString();
- }
-
- /**
- * Search all XML documents stored in "map" for the specified xPath, using
- * relative path (starting with '$this')
- *
- * @param xPath
- * xpath query string array
- * @returns An array of XmlObject if elements are found at the specified
- * xpath
- * @returns NULL if nothing is at the specified xpath
- */
- public Object[] get(String[] xPath) {
- if (map == null) {
- return null;
- }
-
- String[] keys = (String[]) map.keySet().toArray(new String[map.size()]);
- List<Object> result = new ArrayList<Object>();
- for (int i = 0; i < keys.length; ++i) {
- XmlObject rootNode = (XmlObject) map.get(keys[i]);
- if (rootNode == null) {
- continue;
- }
-
- String query = queryDeclaration
- + normalizeQueryString(xPath, "$this/" + keys[i]);
- XmlObject[] tmp = rootNode.selectPath(query);
- for (int j = 0; j < tmp.length; ++j) {
- result.add((Object)tmp[j]);
- }
- }
-
- int size = result.size();
- if (size <= 0) {
- return null;
- }
-
- return (Object[]) result.toArray(new Object[size]);
- }
-
- /**
- * Search XML documents named by "rootName" for the given xPath, using
- * relative path (starting with '$this')
- *
- * @param rootName
- * The top level element name
- * @param xPath
- * The xpath query string array
- * @returns An array of XmlObject if elements are found at the given xpath
- * @returns NULL if nothing is found at the given xpath
- */
- public Object[] get(String rootName, String[] xPath) {
- if (map == null) {
- return null;
- }
-
- XmlObject root = (XmlObject) map.get(rootName);
- if (root == null) {
- return null;
- }
-
- String query = queryDeclaration
- + normalizeQueryString(xPath, "$this/" + rootName);
- XmlObject[] result = root.selectPath(query);
- if (result.length > 0) {
- return (Object[])result;
- }
-
- query = queryDeclaration + normalizeQueryString(xPath, "/" + rootName);
- result = root.selectPath(query);
- if (result.length > 0) {
- return (Object[])result;
- }
-
- return null;
- }
-
- /**
- * Retrieve SourceFiles/Filename for specified ARCH type
- *
- * @param arch
- * architecture name
- * @returns An 2 dimension string array if elements are found at the known
- * xpath
- * @returns NULL if nothing is found at the known xpath
- */
- public String[][] getSourceFiles(String arch) {
- String[] xPath;
- Object[] returns;
-
- xPath = new String[] { "/Filename" };
-
- returns = get("SourceFiles", xPath);
-
- if (returns == null || returns.length == 0) {
- return new String[0][3];
- }
-
- Filename[] sourceFileNames = (Filename[]) returns;
- List<String[]> outputList = new ArrayList<String[]>();
- for (int i = 0; i < sourceFileNames.length; i++) {
- List archList = sourceFileNames[i].getSupArchList();
- if (arch == null || arch.trim().equalsIgnoreCase("") || archList == null || contains(archList, arch)) {
- outputList.add(new String[] {sourceFileNames[i].getToolCode(), sourceFileNames[i].getStringValue(), sourceFileNames[i].getToolChainFamily()});
- }
- }
-
- String[][] outputString = new String[outputList.size()][3];
- for (int index = 0; index < outputList.size(); index++) {
- //
- // ToolCode (FileType)
- //
- outputString[index][0] = outputList.get(index)[0];
- //
- // File name (relative to MODULE_DIR)
- //
- outputString[index][1] = outputList.get(index)[1];
- //
- // Tool chain family
- //
- outputString[index][2] = outputList.get(index)[2];
- }
- return outputString;
- }
-
- /**
- * Retrieve /PlatformDefinitions/OutputDirectory from FPD
- *
- * @returns Directory names array if elements are found at the known xpath
- * @returns Empty if nothing is found at the known xpath
- */
- public String getFpdOutputDirectory() {
- String[] xPath = new String[] { "/PlatformDefinitions" };
-
- Object[] returns = get("PlatformSurfaceArea", xPath);
- if (returns == null || returns.length == 0) {
- return null;
- }
- PlatformDefinitionsDocument.PlatformDefinitions item = (PlatformDefinitionsDocument.PlatformDefinitions)returns[0];
- return item.getOutputDirectory();
- }
-
- public String getFpdIntermediateDirectories() {
- String[] xPath = new String[] { "/PlatformDefinitions" };
-
- Object[] returns = get("PlatformSurfaceArea", xPath);
- if (returns == null || returns.length == 0) {
- return "UNIFIED";
- }
- PlatformDefinitionsDocument.PlatformDefinitions item = (PlatformDefinitionsDocument.PlatformDefinitions)returns[0];
- if(item.getIntermediateDirectories() == null) {
- return null;
- }
- else {
- return item.getIntermediateDirectories().toString();
- }
- }
-
- public String getModuleFfsKeyword() {
- String[] xPath = new String[] { "/" };
-
- Object[] returns = get("ModuleSaBuildOptions", xPath);
- if (returns == null || returns.length == 0) {
- return null;
- }
- ModuleSaBuildOptionsDocument.ModuleSaBuildOptions item = (ModuleSaBuildOptionsDocument.ModuleSaBuildOptions)returns[0];
- return item.getFfsFormatKey();
- }
-
- public String getModuleFvBindingKeyword() {
- String[] xPath = new String[] { "/" };
-
- Object[] returns = get("ModuleSaBuildOptions", xPath);
- if (returns == null || returns.length == 0) {
- return null;
- }
- ModuleSaBuildOptionsDocument.ModuleSaBuildOptions item = (ModuleSaBuildOptionsDocument.ModuleSaBuildOptions)returns[0];
- return item.getFvBinding();
- }
-
- public List getModuleSupportedArchs() {
- String[] xPath = new String[] { "/" };
-
- Object[] returns = get("ModuleDefinitions", xPath);
- if (returns == null || returns.length == 0) {
- return null;
- }
- ModuleDefinitionsDocument.ModuleDefinitions item = (ModuleDefinitionsDocument.ModuleDefinitions)returns[0];
- return item.getSupportedArchitectures();
- }
-
- public BuildOptionsDocument.BuildOptions.Ffs[] getFpdFfs() {
- String[] xPath = new String[] {"/Ffs"};
-
- Object[] returns = get("BuildOptions", xPath);
- if (returns == null || returns.length == 0) {
- return new BuildOptionsDocument.BuildOptions.Ffs[0];
- }
- return (BuildOptionsDocument.BuildOptions.Ffs[])returns;
- }
-
- public String getModuleOutputFileBasename() {
- String[] xPath = new String[] { "/" };
-
- Object[] returns = get("ModuleDefinitions", xPath);
- if (returns == null || returns.length == 0) {
- return null;
- }
- ModuleDefinitionsDocument.ModuleDefinitions item = (ModuleDefinitionsDocument.ModuleDefinitions)returns[0];
- return item.getOutputFileBasename();
- }
-
- /**
- * Retrieve BuildOptions/Option or Arch/Option
- *
- * @param toolChainFamilyFlag
- * if true, retrieve options for toolchain family; otherwise for
- * toolchain
- *
- * @returns String[][5] name, target, toolchain, arch, coommand of options
- * if elements are found at the known xpath. String[0][] if dont
- * find element.
- *
- * @returns Empty array if nothing is there
- */
- public String[][] getOptions(String from, String[] xPath, boolean toolChainFamilyFlag) {
- String target = null;
- String toolchain = null;
- String toolchainFamily = null;
- List<String> archList = null;
- String cmd = null;
- String optionName = null;
-
- Object[] returns = get(from, xPath);
- if (returns == null) {
- return new String[0][5];
- }
-
- List<String[]> optionList = new ArrayList<String[]>();
- OptionDocument.Option option;
-
- for (int i = 0; i < returns.length; i++) {
- option = (OptionDocument.Option) returns[i];
-
- //
- // Get Target, ToolChain(Family), Arch, Cmd, and Option from Option,
- // then
- // put to result[][5] array in above order.
- //
- String[] targetList;
- if (option.getBuildTargets() == null) {
- target = null;
- }
- else {
- target = option.getBuildTargets().toString();
- }
- if (target != null) {
- targetList = target.split(" ");
- } else {
- targetList = new String[1];
- targetList[0] = null;
- }
-
- if (toolChainFamilyFlag) {
- toolchainFamily = option.getToolChainFamily();
- if (toolchainFamily != null) {
- toolchain = toolchainFamily.toString();
- } else {
- toolchain = null;
- }
- } else {
- toolchain = option.getTagName();
- }
-
- archList = new ArrayList<String>();
- List archEnumList = option.getSupArchList();
- if (archEnumList == null) {
- archList.add(null);
- } else {
- //archList.addAll(archEnumList);
- Iterator it = archEnumList.iterator();
- while (it.hasNext()) {
- String archType = (String)it.next();
- archList.add(archType);
- }
- }
-
- cmd = option.getToolCode();
-
- optionName = option.getStringValue();
- for (int t = 0; t < targetList.length; t++) {
- for (int j = 0; j < archList.size(); j++) {
- optionList.add(new String[] { targetList[t],
- toolchain, archList.get(j), cmd, optionName});
- }
- }
- }
-
- String[][] result = new String[optionList.size()][5];
- for (int i = 0; i < optionList.size(); i++) {
- result[i][0] = optionList.get(i)[0];
- result[i][1] = optionList.get(i)[1];
- result[i][2] = optionList.get(i)[2];
- result[i][3] = optionList.get(i)[3];
- result[i][4] = optionList.get(i)[4];
- }
- return result;
- }
-
- public String[][] getModuleBuildOptions(boolean toolChainFamilyFlag) {
- String[] xPath;
-
- if (toolChainFamilyFlag == true) {
- xPath = new String[] {
- "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
- "/Options/Option[@ToolChainFamily]", };
- } else {
- xPath = new String[] {
- "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
- "/Options/Option[@TagName]", };
- }
- return getOptions("ModuleSaBuildOptions", xPath, toolChainFamilyFlag);
- }
-
- public String[][] getPlatformBuildOptions(boolean toolChainFamilyFlag) {
- String[] xPath;
-
- if (toolChainFamilyFlag == true) {
- xPath = new String[] {
- "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
- "/BuildOptions/Options/Option[@ToolChainFamily]", };
- } else {
- xPath = new String[] {
- "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
- "/BuildOptions/Options/Option[@TagName]", };
- }
-
- return getOptions("PlatformSurfaceArea", xPath, toolChainFamilyFlag);
- }
-
- public String[][] getMsaBuildOptions(boolean toolChainFamilyFlag) {
- String[] xPath;
-
- if (toolChainFamilyFlag == true) {
- xPath = new String[] {
- "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
- "/Options/Option[@ToolChainFamily]", };
- } else {
- xPath = new String[] {
- "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
- "/Options/Option[@TagName]", };
- }
-
- return getOptions("ModuleBuildOptions", xPath, toolChainFamilyFlag);
- }
-
- public ToolChainInfo getFpdToolChainInfo() {
- String[] xPath = new String[] { "/PlatformDefinitions" };
-
- Object[] returns = get("PlatformSurfaceArea", xPath);
- if (returns == null || returns.length == 0) {
- return null;
- }
-
- PlatformDefinitionsDocument.PlatformDefinitions item = (PlatformDefinitionsDocument.PlatformDefinitions)returns[0];
- ToolChainInfo toolChainInfo = new ToolChainInfo();
- toolChainInfo.addTargets(item.getBuildTargets().toString());
- toolChainInfo.addArchs(item.getSupportedArchitectures().toString());
- toolChainInfo.addTagnames((String)null);
- return toolChainInfo;
- }
-
- /**
- * Retrieve <xxxHeader>/ModuleType
- *
- * @returns The module type name if elements are found at the known xpath
- * @returns null if nothing is there
- */
- public String getModuleType() {
- String[] xPath = new String[] { "/ModuleType" };
-
- Object[] returns = get(xPath);
- if (returns != null && returns.length > 0) {
- ModuleTypeDef type = (ModuleTypeDef) returns[0];
- return type.enumValue().toString();
- }
-
- return null;
- }
-
- /**
- * Retrieve <ModuleDefinitions>/<BinaryModule>
- *
- * @returns The module type name if elements are found at the known xpath
- * @returns null if nothing is there
- */
- public boolean getBinaryModule() {
- String[] xPath = new String[] { "/" };
-
- Object[] returns = get("ModuleDefinitions", xPath);
- if (returns != null && returns.length > 0) {
- ModuleDefinitionsDocument.ModuleDefinitions def = (ModuleDefinitionsDocument.ModuleDefinitions)returns[0];
- return def.getBinaryModule();
- }
-
- return false;
- }
-
- /**
- * Retrieve PackageDependencies/Package
- *
- * @param arch
- * Architecture name
- *
- * @returns package name list if elements are found at the known xpath
- * @returns null if nothing is there
- */
- public PackageIdentification[] getDependencePkg(String arch) throws EdkException {
- String[] xPath;
- String packageGuid = null;
- String packageVersion = null;
-
-
- xPath = new String[] { "/Package" };
-
- Object[] returns = get("PackageDependencies", xPath);
- if (returns == null) {
- return new PackageIdentification[0];
- }
-
- //
- // Get packageIdentification
- //
- List<PackageIdentification> packageIdList = new ArrayList<PackageIdentification>();
- for (int i = 0; i < returns.length; i++) {
- PackageDependenciesDocument.PackageDependencies.Package item = (PackageDependenciesDocument.PackageDependencies.Package) returns[i];
- List archList = item.getSupArchList();
- if (arch == null || archList == null || contains(archList, arch)) {
- packageGuid = item.getPackageGuid();
- packageVersion = item.getPackageVersion();
- PackageIdentification pkgId = new PackageIdentification(null, packageGuid, packageVersion);
- GlobalData.refreshPackageIdentification(pkgId);
- packageIdList.add(pkgId);
- }
- }
-
- return packageIdList.toArray(new PackageIdentification[packageIdList.size()]);
- }
-
- /**
- * Retrieve LibraryClassDefinitions/LibraryClass for specified usage
- *
- * @param usage
- * Library class usage
- *
- * @returns LibraryClass objects list if elements are found at the known
- * xpath
- * @returns null if nothing is there
- */
- public String[] getLibraryClasses(String usage, String arch, String moduleType) {
- String[] xPath;
- if (usage == null || usage.equals("")) {
- xPath = new String[] { "/LibraryClass" };
- } else {
- xPath = new String[] { "/LibraryClass[@Usage='" + usage + "']" };
- }
-
- Object[] returns = get("LibraryClassDefinitions", xPath);
- if (returns == null || returns.length == 0) {
- return new String[0];
- }
-
- LibraryClassDocument.LibraryClass[] libraryClassList = (LibraryClassDocument.LibraryClass[]) returns;
- List<String> libraryClassName = new ArrayList<String>();
- for (int i = 0; i < libraryClassList.length; i++) {
- List archList = libraryClassList[i].getSupArchList();
- List moduleTypeList = libraryClassList[i].getSupModuleList();
- if ((arch == null || contains(archList, arch))
- && (moduleType == null || contains(moduleTypeList, moduleType))) {
- libraryClassName.add(libraryClassList[i].getKeyword());
- }
- }
-
- String[] libraryArray = new String[libraryClassName.size()];
- libraryClassName.toArray(libraryArray);
- return libraryArray;
- }
-
- /**
- * Retrieve ModuleEntryPoint names
- *
- * @returns ModuleEntryPoint name list if elements are found at the known
- * xpath
- * @returns null if nothing is there
- */
- public String[] getModuleEntryPointArray() {
- String[] xPath = new String[] { "/Extern/ModuleEntryPoint" };
-
- Object[] returns = get("Externs", xPath);
-
- if (returns != null && returns.length > 0) {
- String[] entryPoints = new String[returns.length];
-
- for (int i = 0; i < returns.length; ++i) {
- entryPoints[i] = ((CNameType) returns[i]).getStringValue();
- }
-
- return entryPoints;
- }
-
- return null;
- }
-
- /**
- * retrieve Protocol for specified usage
- *
- * @param usage
- * Protocol usage arch Architecture
- *
- * @returns Protocol String list if elements are found at the known xpath
- * @returns String[0] if nothing is there
- */
- public String[] getProtocolArray(String arch, String usage) {
- String[] xPath;
- String usageXpath = "";
- String archXpath = "";
-
- if (arch == null || arch.equals("")) {
- return new String[0];
- } else {
- archXpath = "/Protocol";
- if (usage != null && !usage.equals("")) {
- usageXpath = "/Protocol[@Usage='" + usage + "']";
- xPath = new String[] { usageXpath, archXpath };
- } else {
- return getProtocolArray(arch);
- }
-
- }
-
- Object[] returns = get("Protocols", xPath);
- if (returns == null) {
- return new String[0];
- }
- Protocol[] protocolList = (Protocol[]) returns;
-
- String[] protocolArray = new String[returns.length];
- for (int i = 0; i < returns.length; i++) {
- protocolArray[i] = protocolList[i].getProtocolCName();
- }
- return protocolArray;
- }
-
- /**
- * retrieve Protocol for specified usage
- *
- * @param arch
- * Architecture
- *
- * @returns Protocol String list if elements are found at the known xpath
- * @returns String[0] if nothing is there
- */
- public String[] getProtocolArray(String arch) {
- String[] xPath;
-
- if (arch == null || arch.equals("")) {
- return new String[0];
- } else {
- xPath = new String[] { "/Protocol" };
- }
-
- Object[] returns = get("Protocols", xPath);
- if (returns == null) {
- return new String[0];
- }
- Protocol[] returnlList = (Protocol[]) returns;
-
- List<String> protocolList = new ArrayList<String>();
-
- for (int i = 0; i < returns.length; i++) {
- List archList = returnlList[i].getSupArchList();
- if (archList == null || contains(archList, arch)){
- protocolList.add(returnlList[i].getProtocolCName());
- }
- }
- String[] protocolArray = new String[protocolList.size()];
- for (int i = 0; i < protocolList.size(); i++) {
- protocolArray[i] = protocolList.get(i);
- }
- return protocolArray;
- }
-
- /**
- * Retrieve ProtocolNotify for specified usage
- *
- * @param usage
- * ProtocolNotify usage
- *
- * @returns String[] if elements are found at the known xpath
- * @returns String[0] if nothing is there
- */
- public String[] getProtocolNotifyArray(String arch) {
- String[] xPath;
-
- if (arch == null || arch.equals("")) {
- return new String[0];
- } else {
- xPath = new String[] { "/ProtocolNotify" };
- }
-
- Object[] returns = get("Protocols", xPath);
- if (returns == null) {
- return new String[0];
- }
-
- List<String> protocolNotifyList = new ArrayList<String>();
-
- for (int i = 0; i < returns.length; i++) {
- List archList = ((ProtocolNotify) returns[i]).getSupArchList();
- if (archList == null || contains(archList, arch)){
- protocolNotifyList.add(((ProtocolNotify) returns[i]).getProtocolNotifyCName());
- }
-
- }
- String[] protocolNotifyArray = new String[protocolNotifyList.size()];
- for (int i = 0; i < protocolNotifyList.size(); i++) {
- protocolNotifyArray[i] = protocolNotifyList.get(i);
- }
- return protocolNotifyArray;
- }
-
- /**
- * Retrieve ProtocolNotify for specified usage
- *
- * @param usage
- * ProtocolNotify usage
- *
- * @returns String[] if elements are found at the known xpath
- * @returns String[0] if nothing is there
- */
- public String[] getProtocolNotifyArray(String arch, String usage) {
-
- String[] xPath;
- String usageXpath;
- String archXpath;
-
- if (arch == null || arch.equals("")) {
- return new String[0];
- } else {
- archXpath = "/ProtocolNotify";
- if (usage != null && !usage.equals("")) {
- usageXpath = "/ProtocolNotify[@Usage='" + arch + "']";
- xPath = new String[] { archXpath, usageXpath };
- } else {
- return getProtocolNotifyArray(arch);
- }
- }
-
- Object[] returns = get("Protocols", xPath);
- if (returns == null) {
- return new String[0];
- }
-
- String[] protocolNotifyList = new String[returns.length];
-
- for (int i = 0; i < returns.length; i++) {
- protocolNotifyList[i] = ((ProtocolNotify) returns[i]).getProtocolNotifyCName();
- }
- return protocolNotifyList;
- }
-
- /**
- * Retrieve ModuleUnloadImage names
- *
- * @returns ModuleUnloadImage name list if elements are found at the known
- * xpath
- * @returns null if nothing is there
- */
- public String[] getModuleUnloadImageArray() {
- String[] xPath = new String[] { "/Extern/ModuleUnloadImage" };
-
- Object[] returns = get("Externs", xPath);
- if (returns != null && returns.length > 0) {
- String[] stringArray = new String[returns.length];
- CNameType[] doc = (CNameType[]) returns;
-
- for (int i = 0; i < returns.length; ++i) {
- stringArray[i] = doc[i].getStringValue();
- }
-
- return stringArray;
- }
-
- return null;
- }
-
- /**
- * Retrieve Extern
- *
- * @returns Extern objects list if elements are found at the known xpath
- * @returns null if nothing is there
- */
- public ExternsDocument.Externs.Extern[] getExternArray() {
- String[] xPath = new String[] { "/Extern" };
-
- Object[] returns = get("Externs", xPath);
- if (returns != null && returns.length > 0) {
- return (ExternsDocument.Externs.Extern[]) returns;
- }
-
- return null;
- }
-
- /**
- * Retrieve PpiNotify for specified arch
- *
- * @param arch
- * PpiNotify arch
- *
- * @returns String[] if elements are found at the known xpath
- * @returns String[0] if nothing is there
- */
- public String[] getPpiNotifyArray(String arch) {
- String[] xPath;
-
- if (arch == null || arch.equals("")) {
- return new String[0];
- } else {
- xPath = new String[] { "/PpiNotify" };
- }
-
- Object[] returns = get("PPIs", xPath);
- if (returns == null) {
- return new String[0];
- }
-
-
- List<String> ppiNotifyList = new ArrayList<String>();
- for (int i = 0; i < returns.length; i++) {
- List archList = ((PPIsDocument.PPIs.PpiNotify) returns[i]).getSupArchList();
- if (archList == null || contains(archList, arch)){
- ppiNotifyList.add(((PPIsDocument.PPIs.PpiNotify) returns[i]).getPpiNotifyCName());
- }
-
- }
- String[] ppiNotifyArray = new String[ppiNotifyList.size()];
- for (int i = 0; i < ppiNotifyList.size(); i++) {
- ppiNotifyArray[i] = ppiNotifyList.get(i);
- }
-
- return ppiNotifyArray;
- }
-
- /**
- * Retrieve PpiNotify for specified usage and arch
- *
- * @param arch
- * PpiNotify arch usage PpiNotify usage
- *
- *
- * @returns String[] if elements are found at the known xpath
- * @returns String[0] if nothing is there
- */
- public String[] getPpiNotifyArray(String arch, String usage) {
-
- String[] xPath;
- String usageXpath;
- String archXpath;
-
- if (arch == null || arch.equals("")) {
- return new String[0];
- } else {
- archXpath = "/PpiNotify";
- if (usage != null && !usage.equals("")) {
- usageXpath = "/PpiNotify[@Usage='" + arch + "']";
- xPath = new String[] { archXpath, usageXpath };
- } else {
- return getProtocolNotifyArray(arch);
- }
- }
-
- Object[] returns = get("PPIs", xPath);
- if (returns == null) {
- return new String[0];
- }
-
- String[] ppiNotifyList = new String[returns.length];
-
- for (int i = 0; i < returns.length; i++) {
- ppiNotifyList[i] = ((PPIsDocument.PPIs.PpiNotify) returns[i]).getPpiNotifyCName();
- }
- return ppiNotifyList;
- }
-
- /**
- * Retrieve Ppi for specified arch
- *
- * @param arch
- * Ppi arch
- *
- * @returns String[] if elements are found at the known xpath
- * @returns String[0] if nothing is there
- */
- public String[] getPpiArray(String arch) {
- String[] xPath;
-
- if (arch == null || arch.equals("")) {
- return new String[0];
- } else {
- xPath = new String[] { "/Ppi" };
- }
-
- Object[] returns = get("PPIs", xPath);
- if (returns == null) {
- return new String[0];
- }
-
- List<String> ppiList = new ArrayList<String>();
- for (int i = 0; i < returns.length; i++) {
- List archList = ((PPIsDocument.PPIs.Ppi) returns[i]).getSupArchList();
- if (archList == null || contains(archList, arch)){
- ppiList.add(((PPIsDocument.PPIs.Ppi) returns[i]).getPpiCName());
- }
-
- }
- String[] ppiArray = new String[ppiList.size()];
- for (int i = 0; i < ppiList.size(); i++) {
- ppiArray[i] = ppiList.get(i);
- }
- return ppiArray;
- }
-
- /**
- * Retrieve PpiNotify for specified usage and arch
- *
- * @param arch
- * PpiNotify arch usage PpiNotify usage
- *
- *
- * @returns String[] if elements are found at the known xpath
- * @returns String[0] if nothing is there
- */
- public String[] getPpiArray(String arch, String usage) {
-
- String[] xPath;
- String usageXpath;
- String archXpath;
-
- if (arch == null || arch.equals("")) {
- return new String[0];
- } else {
- archXpath = "/Ppi";
- if (usage != null && !usage.equals("")) {
- usageXpath = "/Ppi[@Usage='" + arch + "']";
- xPath = new String[] { archXpath, usageXpath };
- } else {
- return getProtocolNotifyArray(arch);
- }
- }
-
- Object[] returns = get("PPIs", xPath);
- if (returns == null) {
- return new String[0];
- }
-
- String[] ppiList = new String[returns.length];
-
- for (int i = 0; i < returns.length; i++) {
- ppiList[i] = ((PPIsDocument.PPIs.Ppi) returns[i]).getPpiCName();
- }
- return ppiList;
- }
-
- /**
- * Retrieve GuidEntry information for specified usage
- *
- * @param arch
- * GuidEntry arch
- *
- * @returns GuidEntry objects list if elements are found at the known xpath
- * @returns null if nothing is there
- */
- public String[] getGuidEntryArray(String arch) {
- String[] xPath;
-
- if (arch == null || arch.equals("")) {
- xPath = new String[] { "/GuidCNames" };
- } else {
- xPath = new String[] { "/GuidCNames" };
- }
-
- Object[] returns = get("Guids", xPath);
- if (returns == null) {
- return new String[0];
- }
-
- List<String> guidList = new ArrayList<String>();
- for (int i = 0; i < returns.length; i++) {
- List archList = ((GuidsDocument.Guids.GuidCNames) returns[i]).getSupArchList();
- if (archList == null || contains(archList, arch)){
- guidList.add(((GuidsDocument.Guids.GuidCNames) returns[i]).getGuidCName());
- }
-
- }
- String[] guidArray = new String[guidList.size()];
- for (int i = 0; i < guidList.size(); i++) {
- guidArray[i] = guidList.get(i);
- }
- return guidArray;
-
- }
-
- /**
- * Retrieve GuidEntry information for specified usage
- *
- * @param arch
- * GuidEntry arch usage GuidEntry usage
- *
- * @returns GuidEntry objects list if elements are found at the known xpath
- * @returns null if nothing is there
- */
- public String[] getGuidEntryArray(String arch, String usage) {
- String[] xPath;
- String archXpath;
- String usageXpath;
-
- if (arch == null || arch.equals("")) {
- return new String[0];
- } else {
- archXpath = "/GuidEntry";
- if (usage != null && !usage.equals("")) {
- usageXpath = "/GuidEntry[@Usage='" + arch + "']";
- xPath = new String[] { archXpath, usageXpath };
- } else {
- return getGuidEntryArray(arch);
- }
- }
-
- Object[] returns = get("Guids", xPath);
- if (returns == null) {
- return new String[0];
- }
-
- String[] guidList = new String[returns.length];
-
- for (int i = 0; i < returns.length; i++) {
- guidList[i] = ((GuidsDocument.Guids.GuidCNames) returns[i]).getGuidCName();
- }
- return guidList;
- }
-
- public String[] getEventCNameArray(String arch) {
- String[] xPath = null;
-
- if (arch == null || arch.equals("")) {
- xPath = new String[]{
- "/CreateEvents/EventTypes[@EventGuidCName]",
- "/SignalEvents/EventTypes[@EventGuidCName]",
- };
- } else {
- xPath = new String[]{
- "/CreateEvents/EventTypes[@EventGuidCName and not(@SupArchList)]",
- "/SignalEvents/EventTypes[@EventGuidCName and not(@SupArchList)]",
- "/CreateEvents/EventTypes[@EventGuidCName and contains(@SupArchList,'" + arch + "')]",
- "/SignalEvents/EventTypes[@EventGuidCName and contains(@SupArchList,'" + arch + "')]",
- };
- }
-
- Object[] returns = get("Events", xPath);
- if (returns == null) {
- return new String[0];
- }
-
- String[] cnameList = new String[returns.length];
- for (int i = 0; i < returns.length; i++) {
- if (returns[i] instanceof EventsDocument.Events.CreateEvents.EventTypes) {
- cnameList[i] = ((EventsDocument.Events.CreateEvents.EventTypes) returns[i]).getEventGuidCName();
- } else {
- cnameList[i] = ((EventsDocument.Events.SignalEvents.EventTypes) returns[i]).getEventGuidCName();
- }
- }
- return cnameList;
- }
-
- public String[] getHobCNameArray(String arch) {
- String[] xPath = null;
-
- if (arch == null || arch.equals("")) {
- xPath = new String[]{"/HobTypes[@HobGuidCName]"};
- } else {
- xPath = new String[]{
- "/HobTypes[@HobGuidCName and not(@SupArchList)]",
- "/HobTypes[@HobGuidCName and contains(@SupArchList,'" + arch + "')]",
- };
- }
-
- Object[] returns = get("Hobs", xPath);
- if (returns == null) {
- return new String[0];
- }
-
- String[] cnameList = new String[returns.length];
- for (int i = 0; i < returns.length; i++) {
- cnameList[i] = ((HobsDocument.Hobs.HobTypes) returns[i]).getHobGuidCName();
- }
- return cnameList;
- }
-
- public String[] getVariableCNameArray(String arch) {
- String[] xPath = null;
-
- if (arch == null || arch.equals("")) {
- xPath = new String[]{"/Variable"};
- } else {
- xPath = new String[]{"/Variable[not(@SupArchList) or contains(@SupArchList,'" + arch + "')]"};
- }
-
- Object[] returns = get("Variables", xPath);
- if (returns == null) {
- return new String[0];
- }
-
- String[] cnameList = new String[returns.length];
- for (int i = 0; i < returns.length; i++) {
- cnameList[i] = ((VariablesDocument.Variables.Variable) returns[i]).getGuidCName();
- }
- return cnameList;
- }
-
- public String[] getSystemTableCNameArray(String arch) {
- String[] xPath = null;
-
- if (arch == null || arch.equals("")) {
- xPath = new String[]{"/SystemTableCNames"};
- } else {
- xPath = new String[]{
- "/SystemTableCNames[not(@SupArchList) or contains(@SupArchList,'" + arch + "')]"
- };
- }
-
- Object[] returns = get("SystemTables", xPath);
- if (returns == null) {
- return new String[0];
- }
-
- String[] cnameList = new String[returns.length];
- for (int i = 0; i < returns.length; i++) {
- cnameList[i] = ((SystemTablesDocument.SystemTables.SystemTableCNames) returns[i]).getSystemTableCName();
- }
- return cnameList;
- }
-
- public String[] getDataHubCNameArray(String arch) {
- String[] xPath = null;
-
- if (arch == null || arch.equals("")) {
- xPath = new String[]{"/DataHubRecord"};
- } else {
- xPath = new String[]{"/DataHubRecord[not(@SupArchList) or contains(@SupArchList,'" + arch + "')]"};
- }
-
- Object[] returns = get("DataHubs", xPath);
- if (returns == null) {
- return new String[0];
- }
-
- String[] cnameList = new String[returns.length];
- for (int i = 0; i < returns.length; i++) {
- cnameList[i] = ((DataHubsDocument.DataHubs.DataHubRecord) returns[i]).getDataHubCName();
- }
- return cnameList;
- }
-
- public String[] getHiiPackageCNameArray(String arch) {
- String[] xPath = null;
-
- if (arch == null || arch.equals("")) {
- xPath = new String[]{"/HiiPackage"};
- } else {
- xPath = new String[]{"/HiiPackage[not(@SupArchList) or contains(@SupArchList,'" + arch + "')]"};
- }
-
- Object[] returns = get("HiiPackages", xPath);
- if (returns == null) {
- return new String[0];
- }
-
- String[] cnameList = new String[returns.length];
- for (int i = 0; i < returns.length; i++) {
- cnameList[i] = ((HiiPackagesDocument.HiiPackages.HiiPackage) returns[i]).getHiiCName();
- }
- return cnameList;
- }
-
- public String[] getCNameArray(String arch) {
- List<String> cnameList = new ArrayList<String>(100);
- String[] result = null;
- //
- // "/Guids/GuidCNames/GuidCName",
- //
- result = getGuidEntryArray(arch);
- for (int i = 0; i < result.length; ++i) {
- cnameList.add(result[i]);
- }
- //
- // "/Protocols/Protocol/ProtocolCName",
- //
- result = getProtocolArray(arch);
- for (int i = 0; i < result.length; ++i) {
- cnameList.add(result[i]);
- }
- //
- // "/Protocols/ProtocolNotify/ProtocolNotifyCName",
- //
- result = getProtocolNotifyArray(arch);
- for (int i = 0; i < result.length; ++i) {
- cnameList.add(result[i]);
- }
- //
- // "/Events/CreateEvents/EventTypes[@EventGuidCName]",
- // "/Events/SignalEvents/EventTypes[@EventGuidCName]",
- //
- result = getEventCNameArray(arch);
- for (int i = 0; i < result.length; ++i) {
- cnameList.add(result[i]);
- }
- //
- // "/Hobs/HobTypes[@HobGuidCName]",
- //
- result = getHobCNameArray(arch);
- for (int i = 0; i < result.length; ++i) {
- cnameList.add(result[i]);
- }
- //
- // "/PPIs/Ppi/PpiCName",
- //
- result = getPpiArray(arch);
- for (int i = 0; i < result.length; ++i) {
- cnameList.add(result[i]);
- }
- //
- // "/PPIs/PpiNotify/PpiNotifyCName",
- //
- result = getPpiNotifyArray(arch);
- for (int i = 0; i < result.length; ++i) {
- cnameList.add(result[i]);
- }
- //
- // "/Variables/Variable/GuidC_Name",
- //
- result = getVariableCNameArray(arch);
- for (int i = 0; i < result.length; ++i) {
- cnameList.add(result[i]);
- }
- //
- // "/SystemTables/SystemTableCNames/SystemTableCName",
- //
- result = getSystemTableCNameArray(arch);
- for (int i = 0; i < result.length; ++i) {
- cnameList.add(result[i]);
- }
- //
- // "/DataHubs/DataHubRecord/DataHubCName",
- //
- result = getDataHubCNameArray(arch);
- for (int i = 0; i < result.length; ++i) {
- cnameList.add(result[i]);
- }
- //
- // "/HiiPackages/HiiPackage/HiiCName",
- //
- result = getHiiPackageCNameArray(arch);
- for (int i = 0; i < result.length; ++i) {
- cnameList.add(result[i]);
- }
-
- return cnameList.toArray(new String[cnameList.size()]);
- }
-
- /**
- * Retrieve Library instance information
- *
- * @param arch
- * Architecture name
- * @param usage
- * Library instance usage
- *
- * @returns library instance name list if elements are found at the known
- * xpath
- * @returns null if nothing is there
- */
- public ModuleIdentification[] getLibraryInstance(String arch) throws EdkException {
- String[] xPath;
- String saGuid = null;
- String saVersion = null;
- String pkgGuid = null;
- String pkgVersion = null;
-
- if (arch == null || arch.equalsIgnoreCase("")) {
- xPath = new String[] { "/Instance" };
- } else {
- //
- // Since Schema don't have SupArchList now, so the follow Xpath is
- // equal to "/Instance" and [not(@SupArchList) or @SupArchList= arch]
- // don't have effect.
- //
- xPath = new String[] { "/Instance[not(@SupArchList) or @SupArchList='"
- + arch + "']" };
- }
-
- Object[] returns = get("Libraries", xPath);
- if (returns == null || returns.length == 0) {
- return new ModuleIdentification[0];
- }
-
- ModuleIdentification[] saIdList = new ModuleIdentification[returns.length];
- for (int i = 0; i < returns.length; i++) {
- LibrariesDocument.Libraries.Instance library = (LibrariesDocument.Libraries.Instance) returns[i];
- saGuid = library.getModuleGuid();
- saVersion = library.getModuleVersion();
-
- pkgGuid = library.getPackageGuid();
- pkgVersion = library.getPackageVersion();
-
- ModuleIdentification saId = new ModuleIdentification(null, saGuid,
- saVersion);
- PackageIdentification pkgId = new PackageIdentification(null,
- pkgGuid, pkgVersion);
- GlobalData.refreshPackageIdentification(pkgId);
- saId.setPackage(pkgId);
- GlobalData.refreshModuleIdentification(saId);
-
- saIdList[i] = saId;
-
- }
- return saIdList;
- }
-
- // /
- // / This method is used for retrieving the elements information which has
- // / CName sub-element
- // /
- private String[] getCNames(String from, String xPath[]) {
- Object[] returns = get(from, xPath);
- if (returns == null || returns.length == 0) {
- return null;
- }
-
- String[] strings = new String[returns.length];
- for (int i = 0; i < returns.length; ++i) {
- // TBD
- strings[i] = ((CNameType) returns[i]).getStringValue();
- }
-
- return strings;
- }
-
- /**
- * Retrive library's constructor name
- *
- * @returns constructor name list if elements are found at the known xpath
- * @returns null if nothing is there
- */
- public String getLibConstructorName() {
- String[] xPath = new String[] { "/Extern/Constructor" };
-
- Object[] returns = get("Externs", xPath);
- if (returns != null && returns.length > 0) {
- CNameType constructor = ((CNameType) returns[0]);
- return constructor.getStringValue();
- }
-
- return null;
- }
-
- /**
- * Retrive library's destructor name
- *
- * @returns destructor name list if elements are found at the known xpath
- * @returns null if nothing is there
- */
- public String getLibDestructorName() {
- String[] xPath = new String[] { "/Extern/Destructor" };
-
- Object[] returns = get("Externs", xPath);
- if (returns != null && returns.length > 0) {
- //
- // Only support one Destructor function.
- //
- CNameType destructor = (CNameType) returns[0];
- return destructor.getStringValue();
- }
-
- return null;
- }
-
- /**
- * Retrive DriverBinding names
- *
- * @returns DriverBinding name list if elements are found at the known xpath
- * @returns null if nothing is there
- */
- public String[] getDriverBindingArray() {
- String[] xPath = new String[] { "/Extern/DriverBinding" };
- return getCNames("Externs", xPath);
- }
-
- /**
- * Retrive ComponentName names
- *
- * @returns ComponentName name list if elements are found at the known xpath
- * @returns null if nothing is there
- */
- public String[] getComponentNameArray() {
- String[] xPath = new String[] { "/Extern/ComponentName" };
- return getCNames("Externs", xPath);
- }
-
- /**
- * Retrive DriverConfig names
- *
- * @returns DriverConfig name list if elements are found at the known xpath
- * @returns null if nothing is there
- */
- public String[] getDriverConfigArray() {
- String[] xPath = new String[] { "/Extern/DriverConfig" };
- return getCNames("Externs", xPath);
- }
-
- /**
- * Retrive DriverDiag names
- *
- * @returns DriverDiag name list if elements are found at the known xpath
- * @returns null if nothing is there
- */
- public String[] getDriverDiagArray() {
- String[] xPath = new String[] { "/Extern/DriverDiag" };
- return getCNames("Externs", xPath);
- }
-
- /**
- * Retrive DriverBinding, ComponentName, DriverConfig,
- * DriverDiag group array
- *
- * @returns DriverBinding group name list if elements are found
- * at the known xpath
- * @returns null if nothing is there
- */
- public String[][] getExternProtocolGroup() {
- String[] xPath = new String[] {"/Extern"};
- Object[] returns = get("Externs",xPath);
-
- if (returns == null) {
- return new String[0][4];
- }
- List<Extern> externList = new ArrayList<Extern>();
- for (int i = 0; i < returns.length; i++) {
- org.tianocore.ExternsDocument.Externs.Extern extern = (org.tianocore.ExternsDocument.Externs.Extern)returns[i];
- if (extern.getDriverBinding() != null) {
- externList.add(extern);
- }
- }
-
- String[][] externGroup = new String[externList.size()][4];
- for (int i = 0; i < externList.size(); i++) {
- String driverBindingStr = externList.get(i).getDriverBinding();
- if ( driverBindingStr != null){
- externGroup[i][0] = driverBindingStr;
- } else {
- externGroup[i][0] = null;
- }
-
- String componentNameStr = externList.get(i).getComponentName();
- if (componentNameStr != null) {
- externGroup[i][1] = componentNameStr;
- } else {
- externGroup[i][1] = null;
- }
-
- String driverConfigStr = externList.get(i).getDriverConfig();
- if (driverConfigStr != null) {
- externGroup[i][2] = driverConfigStr;
- } else {
- externGroup[i][2] = null;
- }
-
- String driverDiagStr = externList.get(i).getDriverDiag();
- if (driverDiagStr != null) {
- externGroup[i][3] = driverDiagStr;
- } else {
- externGroup[i][3] = null;
- }
- }
- return externGroup;
- }
-
- /**
- * Retrive SetVirtualAddressMapCallBack names
- *
- * @returns SetVirtualAddressMapCallBack name list if elements are found at
- * the known xpath
- * @returns null if nothing is there
- */
- public String[] getSetVirtualAddressMapCallBackArray() {
- String[] xPath = new String[] { "/Extern/SetVirtualAddressMapCallBack" };
- return getCNames("Externs", xPath);
- }
-
- /**
- * Retrive ExitBootServicesCallBack names
- *
- * @returns ExitBootServicesCallBack name list if elements are found at the
- * known xpath
- * @returns null if nothing is there
- */
- public String[] getExitBootServicesCallBackArray() {
- String[] xPath = new String[] { "/Extern/ExitBootServicesCallBack" };
- return getCNames("Externs", xPath);
- }
-
- /**
- Judge whether current driver is PEI_PCD_DRIVER or DXE_PCD_DRIVER or
- NOT_PCD_DRIVER.
-
- @return CommonDefinition.PCD_DRIVER_TYPE the type of current driver
- **/
- public CommonDefinition.PCD_DRIVER_TYPE getPcdDriverType() {
- String[] xPath = new String[] {"/PcdIsDriver"};
- Object[] results = get ("Externs", xPath);
-
- if (results != null && results.length != 0) {
- PcdDriverTypes type = (PcdDriverTypes) results[0];
- String typeStr = type.enumValue().toString();
- if (typeStr.equals(CommonDefinition.PCD_DRIVER_TYPE.PEI_PCD_DRIVER.toString())) {
- return CommonDefinition.PCD_DRIVER_TYPE.PEI_PCD_DRIVER;
- } else if (typeStr.equals(CommonDefinition.PCD_DRIVER_TYPE.DXE_PCD_DRIVER.toString())) {
- return CommonDefinition.PCD_DRIVER_TYPE.DXE_PCD_DRIVER;
- }
- return CommonDefinition.PCD_DRIVER_TYPE.UNKNOWN_PCD_DRIVER;
- }
-
- return CommonDefinition.PCD_DRIVER_TYPE.NOT_PCD_DRIVER;
- }
-
- /**
- * Retrieve module surface area file information
- *
- * @returns ModuleSA objects list if elements are found at the known xpath
- * @returns Empty ModuleSA list if nothing is there
- */
- public Map<FpdModuleIdentification, Map<String, XmlObject>> getFpdModules() throws EdkException {
- String[] xPath = new String[] { "/FrameworkModules/ModuleSA" };
- Object[] result = get("PlatformSurfaceArea", xPath);
- String arch = null;
- String fvBinding = null;
- String saGuid = null;
- String saVersion = null;
- String pkgGuid = null;
- String pkgVersion = null;
-
- Map<FpdModuleIdentification, Map<String, XmlObject>> fpdModuleMap = new LinkedHashMap<FpdModuleIdentification, Map<String, XmlObject>>();
-
- if (result == null) {
- return fpdModuleMap;
- }
-
- for (int i = 0; i < result.length; i++) {
- //
- // Get Fpd SA Module element node and add to ObjectMap.
- //
- Map<String, XmlObject> ObjectMap = new HashMap<String, XmlObject>();
- ModuleSADocument.ModuleSA moduleSA = (ModuleSADocument.ModuleSA) result[i];
- if (((ModuleSADocument.ModuleSA) result[i]).getLibraries() != null) {
- ObjectMap.put("Libraries", moduleSA.getLibraries());
- }
- if (((ModuleSADocument.ModuleSA) result[i]).getPcdBuildDefinition() != null) {
- ObjectMap.put("PcdBuildDefinition", moduleSA.getPcdBuildDefinition());
- }
- if (((ModuleSADocument.ModuleSA) result[i]).getModuleSaBuildOptions() != null) {
- ObjectMap.put("ModuleSaBuildOptions", moduleSA.getModuleSaBuildOptions());
- }
-
- //
- // Get Fpd SA Module attribute and create FpdMoudleIdentification.
- //
- if (moduleSA.isSetSupArchList()) {
- arch = moduleSA.getSupArchList().toString();
- } else {
- arch = null;
- }
-
- // TBD
- fvBinding = null;
- saVersion = ((ModuleSADocument.ModuleSA) result[i]).getModuleVersion();
-
- saGuid = moduleSA.getModuleGuid();
- pkgGuid = moduleSA.getPackageGuid();
- pkgVersion = moduleSA.getPackageVersion();
-
- //
- // Create Module Identification which have class member of package
- // identification.
- //
- PackageIdentification pkgId = new PackageIdentification(null, pkgGuid, pkgVersion);
- GlobalData.refreshPackageIdentification(pkgId);
-
- ModuleIdentification saId = new ModuleIdentification(null, saGuid, saVersion);
- saId.setPackage(pkgId);
- GlobalData.refreshModuleIdentification(saId);
-
-
-
- //
- // Create FpdModule Identification which have class member of module
- // identification
- //
- String[] archList = new String[0];
- if (arch == null || arch.trim().length() == 0) {
- archList = GlobalData.getToolChainInfo().getArchs();
- } else {
- archList = arch.split(" ");
- }
- for (int j = 0; j < archList.length; j++) {
- FpdModuleIdentification fpdSaId = new FpdModuleIdentification(saId, archList[j]);
-
- if (fvBinding != null) {
- fpdSaId.setFvBinding(fvBinding);
- }
-
- //
- // Put element to Map<FpdModuleIdentification, Map<String,
- // Object>>.
- //
- fpdModuleMap.put(fpdSaId, ObjectMap);
- }
- }
- return fpdModuleMap;
- }
-
- /**
- * Retrieve valid image names
- *
- * @returns valid iamges name list if elements are found at the known xpath
- * @returns empty list if nothing is there
- */
- public String[] getFpdValidImageNames() {
- String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='ImageName']/FvImageNames" };
-
- Object[] queryResult = get("PlatformSurfaceArea", xPath);
- if (queryResult == null) {
- return new String[0];
- }
-
- String[] result = new String[queryResult.length];
- for (int i = 0; i < queryResult.length; i++) {
- result[i] = ((XmlString) queryResult[i]).getStringValue();
- }
-
- return result;
- }
-
- public Node getFpdUserExtensionPreBuild() {
- String[] xPath = new String[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='0']" };
-
- Object[] queryResult = get("PlatformSurfaceArea", xPath);
- if (queryResult == null || queryResult.length == 0) {
- return null;
- }
- UserExtensionsDocument.UserExtensions a = (UserExtensionsDocument.UserExtensions)queryResult[0];
-
- return a.getDomNode();
- }
-
- public Node getFpdUserExtensionPostBuild() {
- String[] xPath = new String[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='1']" };
-
- Object[] queryResult = get("PlatformSurfaceArea", xPath);
- if (queryResult == null || queryResult.length == 0) {
- return null;
- }
- UserExtensionsDocument.UserExtensions a = (UserExtensionsDocument.UserExtensions)queryResult[0];
-
- return a.getDomNode();
- }
-
- public Node[] getFpdUserExtensions() {
- String[] xPath = new String[] { "/UserExtensions[@UserID='TianoCore' and not(@Identifier='1') and not(@Identifier='0')]" };
-
- Object[] queryResult = get("PlatformSurfaceArea", xPath);
- if (queryResult == null || queryResult.length == 0) {
- return new Node[0];
- }
-
- Node[] nodeList = new Node[queryResult.length];
- for (int i = 0; i < queryResult.length; ++i) {
- UserExtensionsDocument.UserExtensions a = (UserExtensionsDocument.UserExtensions)queryResult[i];
- nodeList[i] = a.getDomNode();
- }
-
- return nodeList;
- }
- /**
- * Retrieve FV image option information
- *
- * @param fvName
- * FV image name
- *
- * @returns option name/value list if elements are found at the known xpath
- * @returns empty list if nothing is there
- */
- public String[][] getFpdOptions(String fvName) {
- String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='Options' and ./FvImageNames='"
- + fvName + "']/FvImageOptions" };
- Object[] queryResult = get("PlatformSurfaceArea", xPath);
- if (queryResult == null) {
- return new String[0][];
- }
- ArrayList<String[]> list = new ArrayList<String[]>();
- for (int i = 0; i < queryResult.length; i++) {
- FvImagesDocument.FvImages.FvImage.FvImageOptions item = (FvImagesDocument.FvImages.FvImage.FvImageOptions) queryResult[i];
- List<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> namevalues = item
- .getNameValueList();
- Iterator iter = namevalues.iterator();
- while (iter.hasNext()) {
- FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nvItem = (FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue) iter
- .next();
- list.add(new String[] { nvItem.getName(), nvItem.getValue() });
- }
- }
- String[][] result = new String[list.size()][2];
- for (int i = 0; i < list.size(); i++) {
- result[i][0] = list.get(i)[0];
- result[i][1] = list.get(i)[1];
- }
- return result;
-
- }
-
- public XmlObject getFpdBuildOptions() {
- String[] xPath = new String[] { "/BuildOptions" };
-
- Object[] queryResult = get("PlatformSurfaceArea", xPath);
-
- if (queryResult == null || queryResult.length == 0) {
- return null;
- }
- return (XmlObject)queryResult[0];
- }
-
- public PlatformIdentification getFpdHeader() {
- String[] xPath = new String[] { "/PlatformHeader" };
-
- Object[] returns = get("PlatformSurfaceArea", xPath);
-
- if (returns == null || returns.length == 0) {
- return null;
- }
- PlatformHeaderDocument.PlatformHeader header = (PlatformHeaderDocument.PlatformHeader) returns[0];
-
- String name = header.getPlatformName();
-
- String guid = header.getGuidValue();
-
- String version = header.getVersion();
-
- return new PlatformIdentification(name, guid, version);
- }
-
- /**
- * Retrieve FV image attributes information
- *
- * @param fvName
- * FV image name
- *
- * @returns attribute name/value list if elements are found at the known
- * xpath
- * @returns empty list if nothing is there
- */
- public String[][] getFpdAttributes(String fvName) {
- String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='Attributes' and ./FvImageNames='"
- + fvName + "']/FvImageOptions" };
- Object[] queryResult = get("PlatformSurfaceArea", xPath);
- if (queryResult == null) {
- return new String[0][];
- }
- ArrayList<String[]> list = new ArrayList<String[]>();
- for (int i = 0; i < queryResult.length; i++) {
-
- FvImagesDocument.FvImages.FvImage.FvImageOptions item = (FvImagesDocument.FvImages.FvImage.FvImageOptions) queryResult[i];
- List<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> namevalues = item.getNameValueList();
- Iterator iter = namevalues.iterator();
- while (iter.hasNext()) {
- FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nvItem = (FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue) iter
- .next();
- list.add(new String[] { nvItem.getName(), nvItem.getValue() });
- }
- }
- String[][] result = new String[list.size()][2];
- for (int i = 0; i < list.size(); i++) {
- result[i][0] = list.get(i)[0];
- result[i][1] = list.get(i)[1];
- }
- return result;
- }
-
- /**
- * Retrieve flash definition file name
- *
- * @returns file name if elements are found at the known xpath
- * @returns null if nothing is there
- */
- public String getFlashDefinitionFile() {
- String[] xPath = new String[] { "/PlatformDefinitions/FlashDeviceDefinitions/FlashDefinitionFile" };
-
- Object[] queryResult = get("PlatformSurfaceArea", xPath);
- if (queryResult == null || queryResult.length == 0) {
- return null;
- }
-
- FileNameConvention filename = (FileNameConvention) queryResult[queryResult.length - 1];
- return filename.getStringValue();
- }
-
- public String[][] getFpdGlobalVariable() {
- String[] xPath = new String[] { "/Flash/FvImages/NameValue" };
- Object[] queryResult = get("PlatformSurfaceArea", xPath);
- if (queryResult == null) {
- return new String[0][];
- }
-
- String[][] result = new String[queryResult.length][2];
-
- for (int i = 0; i < queryResult.length; i++) {
- FvImagesDocument.FvImages.NameValue item = (FvImagesDocument.FvImages.NameValue)queryResult[i];
- result[i][0] = item.getName();
- result[i][1] = item.getValue();
- }
- return result;
- }
-
- /**
- * Retrieve FV image component options
- *
- * @param fvName
- * FV image name
- *
- * @returns name/value pairs list if elements are found at the known xpath
- * @returns empty list if nothing is there
- */
- public String[][] getFpdComponents(String fvName) {
- String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='Components' and ./FvImageNames='"+ fvName + "']/FvImageOptions" };
- Object[] queryResult = get("PlatformSurfaceArea", xPath);
- if (queryResult == null) {
- return new String[0][];
- }
-
- ArrayList<String[]> list = new ArrayList<String[]>();
- for (int i = 0; i < queryResult.length; i++) {
- FvImagesDocument.FvImages.FvImage.FvImageOptions item = (FvImagesDocument.FvImages.FvImage.FvImageOptions) queryResult[i];
- List<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> namevalues = item.getNameValueList();
- Iterator iter = namevalues.iterator();
- while (iter.hasNext()) {
- FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nvItem = (FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue) iter
- .next();
- list.add(new String[] { nvItem.getName(), nvItem.getValue() });
- }
- }
- String[][] result = new String[list.size()][2];
- for (int i = 0; i < list.size(); i++) {
- result[i][0] = list.get(i)[0];
- result[i][1] = list.get(i)[1];
- }
- return result;
- }
-
- /**
- * Retrieve PCD tokens
- *
- * @returns CName/ItemType pairs list if elements are found at the known
- * xpath
- * @returns null if nothing is there
- */
- public String[][] getPcdTokenArray() {
- String[] xPath = new String[] { "/PcdData" };
-
- Object[] returns = get("PCDs", xPath);
- if (returns == null || returns.length == 0) {
- return null;
- }
-
- return null;
- }
-
- /**
- * Retrieve MAS header
- *
- * @return
- * @return
- */
- public ModuleIdentification getMsaHeader() {
- String[] xPath = new String[] { "/" };
- Object[] returns = get("MsaHeader", xPath);
-
- if (returns == null || returns.length == 0) {
- return null;
- }
-
- MsaHeader msaHeader = (MsaHeader) returns[0];
- //
- // Get BaseName, ModuleType, GuidValue, Version
- // which in MsaHeader.
- //
- String name = msaHeader.getModuleName();
- String moduleType = msaHeader.getModuleType().toString();
- String guid = msaHeader.getGuidValue();
- String version = msaHeader.getVersion();
-
- ModuleIdentification moduleId = new ModuleIdentification(name, guid,
- version);
-
- moduleId.setModuleType(moduleType);
-
- return moduleId;
- }
-
- /**
- * Retrieve Extern Specification
- *
- * @param
- *
- * @return String[] If have specification element in the <extern> String[0]
- * If no specification element in the <extern>
- *
- */
-
- public String[] getExternSpecificaiton() {
- String[] xPath = new String[] { "/Specification" };
-
- Object[] queryResult = get("Externs", xPath);
- if (queryResult == null) {
- return new String[0];
- }
-
- String[] specificationList = new String[queryResult.length];
- for (int i = 0; i < queryResult.length; i++) {
- specificationList[i] = ((Sentence)queryResult[i])
- .getStringValue();
- }
- return specificationList;
- }
-
- /**
- * Retreive MsaFile which in SPD
- *
- * @param
- * @return String[][3] The string sequence is ModuleName, ModuleGuid,
- * ModuleVersion, MsaFile String[0][] If no msafile in SPD
- */
- public String[] getSpdMsaFile() {
- String[] xPath = new String[] { "/MsaFiles" };
-
- Object[] returns = get("PackageSurfaceArea", xPath);
- if (returns == null) {
- return new String[0];
- }
-
- List<String> filenameList = ((MsaFilesDocument.MsaFiles) returns[0])
- .getFilenameList();
- return filenameList.toArray(new String[filenameList.size()]);
- }
-
- /**
- * Reteive
- */
- public Map<String, String[]> getSpdLibraryClasses() {
- String[] xPath = new String[] { "/LibraryClassDeclarations/LibraryClass" };
-
- Object[] returns = get("PackageSurfaceArea", xPath);
-
- //
- // Create Map, Key - LibraryClass, String[] - LibraryClass Header file.
- //
- Map<String, String[]> libClassHeaderMap = new HashMap<String, String[]>();
-
- if (returns == null) {
- return libClassHeaderMap;
- }
-
- for (int i = 0; i < returns.length; i++) {
- LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass library = (LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass) returns[i];
- libClassHeaderMap.put(library.getName(), new String[] { library
- .getIncludeHeader() });
- }
- return libClassHeaderMap;
- }
-
- /**
- * Reteive
- */
- public Map<String, String> getSpdPackageHeaderFiles() {
- String[] xPath = new String[] { "/PackageHeaders/IncludePkgHeader" };
-
- Object[] returns = get("PackageSurfaceArea", xPath);
-
- //
- // Create Map, Key - ModuleType, String - PackageInclude Header file.
- //
- Map<String, String> packageIncludeMap = new HashMap<String, String>();
-
- if (returns == null) {
- return packageIncludeMap;
- }
-
- for (int i = 0; i < returns.length; i++) {
- PackageHeadersDocument.PackageHeaders.IncludePkgHeader includeHeader = (PackageHeadersDocument.PackageHeaders.IncludePkgHeader) returns[i];
- packageIncludeMap.put(includeHeader.getModuleType().toString(),
- includeHeader.getStringValue());
- }
- return packageIncludeMap;
- }
-
- public PackageIdentification getSpdHeader() {
- String[] xPath = new String[] { "/SpdHeader" };
-
- Object[] returns = get("PackageSurfaceArea", xPath);
-
- if (returns == null || returns.length == 0) {
- return null;
- }
-
- SpdHeaderDocument.SpdHeader header = (SpdHeaderDocument.SpdHeader) returns[0];
-
- String name = header.getPackageName();
-
- String guid = header.getGuidValue();
-
- String version = header.getVersion();
-
- return new PackageIdentification(name, guid, version);
- }
-
- /**
- * Reteive
- */
- public Map<String, String[]> getSpdGuid() {
- String[] xPath = new String[] { "/GuidDeclarations/Entry" };
-
- Object[] returns = get("PackageSurfaceArea", xPath);
-
- //
- // Create Map, Key - GuidName, String[] - C_NAME & GUID value.
- //
- Map<String, String[]> guidDeclMap = new HashMap<String, String[]>();
- if (returns == null) {
- return guidDeclMap;
- }
-
- for (int i = 0; i < returns.length; i++) {
- GuidDeclarationsDocument.GuidDeclarations.Entry entry = (GuidDeclarationsDocument.GuidDeclarations.Entry) returns[i];
- String[] guidPair = new String[2];
- guidPair[0] = entry.getCName();
- guidPair[1] = entry.getGuidValue();
- guidDeclMap.put(entry.getCName(), guidPair);
- }
- return guidDeclMap;
- }
-
- /**
- * Reteive
- */
- public Map<String, String[]> getSpdProtocol() {
- String[] xPath = new String[] { "/ProtocolDeclarations/Entry" };
-
- Object[] returns = get("PackageSurfaceArea", xPath);
-
- //
- // Create Map, Key - protocolName, String[] - C_NAME & GUID value.
- //
- Map<String, String[]> protoclMap = new HashMap<String, String[]>();
-
- if (returns == null) {
- return protoclMap;
- }
-
- for (int i = 0; i < returns.length; i++) {
- ProtocolDeclarationsDocument.ProtocolDeclarations.Entry entry = (ProtocolDeclarationsDocument.ProtocolDeclarations.Entry) returns[i];
- String[] protocolPair = new String[2];
-
- protocolPair[0] = entry.getCName();
- protocolPair[1] = entry.getGuidValue();
- protoclMap.put(entry.getCName(), protocolPair);
- }
- return protoclMap;
- }
-
- /**
- * getSpdPpi() Retrieve the SPD PPI Entry
- *
- * @param
- * @return Map<String, String[2]> if get the PPI entry from SPD. Key - PPI
- * Name String[0] - PPI CNAME String[1] - PPI Guid Null if no PPI
- * entry in SPD.
- */
- public Map<String, String[]> getSpdPpi() {
- String[] xPath = new String[] { "/PpiDeclarations/Entry" };
-
- Object[] returns = get("PackageSurfaceArea", xPath);
-
- //
- // Create Map, Key - protocolName, String[] - C_NAME & GUID value.
- //
- Map<String, String[]> ppiMap = new HashMap<String, String[]>();
-
- if (returns == null) {
- return ppiMap;
- }
-
- for (int i = 0; i < returns.length; i++) {
- PpiDeclarationsDocument.PpiDeclarations.Entry entry = (PpiDeclarationsDocument.PpiDeclarations.Entry) returns[i];
- String[] ppiPair = new String[2];
- ppiPair[0] = entry.getCName();
- ppiPair[1] = entry.getGuidValue();
- ppiMap.put(entry.getCName(), ppiPair);
- }
- return ppiMap;
- }
-
- /**
- * Retrieve module Guid string
- *
- * @returns GUILD string if elements are found at the known xpath
- * @returns null if nothing is there
- */
- public String getModuleGuid() {
- String[] xPath = new String[] { "" };
-
- Object[] returns = get("MsaHeader", xPath);
- if (returns != null && returns.length > 0) {
- String guid = ((MsaHeaderDocument.MsaHeader) returns[0])
- .getGuidValue();
- return guid;
- }
-
- return null;
- }
-
- //
- // For new Pcd
- //
- public ModuleSADocument.ModuleSA[] getFpdModuleSAs() {
- String[] xPath = new String[] { "/FrameworkModules/ModuleSA" };
- Object[] result = get("PlatformSurfaceArea", xPath);
- if (result != null) {
- return (ModuleSADocument.ModuleSA[]) result;
- }
- return new ModuleSADocument.ModuleSA[0];
-
- }
-
- /**
- Get name array who contains all PCDs in a module according to specified arch.
-
- @param arch The specified architecture type.
-
- @return String[] return all PCDs name into array, if no any PCD used by
- this module, a String[0] array is returned.
- **/
- public String[] getModulePcdEntryNameArray(String arch) {
- PcdCodedDocument.PcdCoded.PcdEntry[] pcdEntries = null;
- java.util.List archList = null;
- java.util.List<String> results = new java.util.ArrayList<String> ();
- int index;
- String[] xPath = new String[] {"/PcdEntry"};
- Object[] returns = get ("PcdCoded", xPath);
-
- if (returns == null) {
- return new String[0];
- }
-
- pcdEntries = (PcdCodedDocument.PcdCoded.PcdEntry[])returns;
-
- for (index = 0; index < pcdEntries.length; index ++) {
- archList = pcdEntries[index].getSupArchList();
- //
- // If the ArchList is specified in MSA for this PCD, need check
- // current arch whether can support by this PCD.
- //
- if (archList != null) {
- if (archList.contains(arch)) {
- results.add(new String(pcdEntries[index].getCName()));
- }
- } else {
- //
- // If no ArchList is specificied in MSA for this PCD, that means
- // this PCD support all architectures.
- //
- results.add(new String(pcdEntries[index].getCName()));
- }
- }
-
- if (results.size() == 0) {
- return new String[0];
- }
-
- String[] retArray = new String[results.size()];
- results.toArray(retArray);
-
- return retArray;
- }
-
- /**
- Search in a List for a given string
-
- @return boolean
- **/
- public boolean contains(List list, String str) {
- if (list == null || list.size()== 0) {
- return true;
- }
-
- return list.contains(str);
- }
-
- public boolean isHaveTianoR8FlashMap(){
- String[] xPath = new String[] {"/"};
- Object[] returns = get ("Externs", xPath);
-
- if (returns == null) {
- return false;
- }
-
- ExternsDocument.Externs ext = (ExternsDocument.Externs)returns[0];
-
- if (ext.getTianoR8FlashMapH()){
- return true;
- }else {
- return false;
- }
- }
-
- public Node getPeiApriori(String fvName) {
- String[] xPath = new String[] { "/BuildOptions/UserExtensions[@UserID='APRIORI' and @Identifier='0' and ./FvName='" + fvName + "']" };
- Object[] result = get("PlatformSurfaceArea", xPath);
-
- if (result == null || result.length == 0) {
- return null;
- }
-
- UserExtensionsDocument.UserExtensions a = (UserExtensionsDocument.UserExtensions)result[0];
-
- return a.getDomNode();
- }
-
- public Node getDxeApriori(String fvName) {
- String[] xPath = new String[] { "/BuildOptions/UserExtensions[@UserID='APRIORI' and @Identifier='1' and ./FvName='" + fvName + "']" };
- Object[] result = get("PlatformSurfaceArea", xPath);
-
- if (result == null || result.length == 0) {
- return null;
- }
-
- UserExtensionsDocument.UserExtensions a = (UserExtensionsDocument.UserExtensions)result[0];
-
- return a.getDomNode();
- }
-
- public Node getFpdModuleSequence(String fvName) {
- String[] xPath = new String[] { "/BuildOptions/UserExtensions[@UserID='IMAGES' and @Identifier='1' and ./FvName='" + fvName + "']" };
- Object[] result = get("PlatformSurfaceArea", xPath);
-
- if (result == null || result.length == 0) {
- return null;
- }
-
- UserExtensionsDocument.UserExtensions a = (UserExtensionsDocument.UserExtensions)result[0];
-
- return a.getDomNode();
- }
-
- /**
- Get the value of PCD by PCD cName
-
- @return PcdValue String of PcdComponentName
- null If don't find ComponentName Pcd
- **/
- public String getPcdValueBycName(String cName){
- String[] xPath = new String[] { "/PcdData" };
- Object[] returns = get("PcdBuildDefinition", xPath);
- if (returns == null || returns.length == 0) {
- return null;
- }
- for (int i = 0; i < returns.length; i++) {
- PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)returns[i];
- if (pcdData.getCName().equalsIgnoreCase(cName)){
- return pcdData.getValue();
- }
- }
- return null;
- }
-}
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/global/VariableTask.java b/Tools/Java/Source/GenBuild/org/tianocore/build/global/VariableTask.java
deleted file mode 100644
index 021b8d5b00..0000000000
--- a/Tools/Java/Source/GenBuild/org/tianocore/build/global/VariableTask.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/** @file
- * This file is ANT task VariableTask.
- *
- * VariableTask task implements part of ANT property task. The difference is
- * this task will override variable with same name, but ANT property task do not.
- *
- * 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.global;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-
-/**
- * VariableTask task implements part of ANT property task. The difference is
- * this task will override variable with same name, but ANT property task do not.
- *
- * @since GenBuild 1.0
- */
-public class VariableTask extends Task {
-
- /**
- * property value
- */
- private String value;
-
- /**
- * property name
- */
- private String name;
-
- /**
- * Set property name.
- *
- * @param name property name
- */
- public void setName( String name ) {
- this.name = name;
- }
-
-
- /**
- * Set property value.
- *
- * @param value property value
- */
- public void setValue( String value ) {
- this.value = value;
- }
-
- /**
- * ANT task's entry point, will be called after init().
- *
- * @exception BuildException
- * If name or value is null
- */
- public void execute() throws BuildException {
- if (name == null || value == null) {
- throw new BuildException("Name or value cannot be null.");
- }
- getProject().setProperty(name, value);
- }
-}
-