mirror of https://github.com/acidanthera/audk.git
Added to fix the issue of many property override warning when build with -v option; and also improve the build performance.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1318 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
b1cfb8a503
commit
471e8e4c3d
|
@ -0,0 +1,100 @@
|
|||
package org.tianocore.build.global;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
import org.apache.tools.ant.Project;
|
||||
import org.apache.tools.ant.PropertyHelper;
|
||||
|
||||
public class PropertyManager {
|
||||
private static Stack<HashMap<String, String>> propertyTableStack = new Stack<HashMap<String, String>>();
|
||||
private static HashMap<String, String> orgPropertyTable = null;
|
||||
private static HashMap<String, String> oldPropertyTable = null;
|
||||
private static HashMap<String, String> bakPropertyTable = null;
|
||||
private static Project prj = null;
|
||||
|
||||
public static void save() {
|
||||
if (orgPropertyTable == null) {
|
||||
Hashtable prjProperties = prj.getProperties();
|
||||
orgPropertyTable = new HashMap<String, String>();
|
||||
|
||||
Set keys = prjProperties.keySet();
|
||||
Iterator iter = keys.iterator();
|
||||
while (iter.hasNext()) {
|
||||
String item = (String)iter.next();
|
||||
orgPropertyTable.put(item, (String)prjProperties.get(item));
|
||||
}
|
||||
}
|
||||
|
||||
if (bakPropertyTable != null) {
|
||||
propertyTableStack.push(bakPropertyTable);
|
||||
oldPropertyTable = bakPropertyTable;
|
||||
} else {
|
||||
oldPropertyTable = orgPropertyTable;
|
||||
}
|
||||
bakPropertyTable = new HashMap<String, String>();
|
||||
}
|
||||
|
||||
public static void restore() {
|
||||
if (bakPropertyTable == null) {
|
||||
return;
|
||||
}
|
||||
Set keys = bakPropertyTable.keySet();
|
||||
|
||||
Iterator iter = keys.iterator();
|
||||
while (iter.hasNext()) {
|
||||
String name = (String)iter.next();
|
||||
String value = (String)bakPropertyTable.get(name);
|
||||
setProperty(prj, name, value);
|
||||
}
|
||||
|
||||
if (propertyTableStack.size() > 0) {
|
||||
bakPropertyTable = (HashMap<String, String>)propertyTableStack.pop();
|
||||
} else {
|
||||
bakPropertyTable = null;
|
||||
}
|
||||
|
||||
if (propertyTableStack.size() == 0) {
|
||||
oldPropertyTable = orgPropertyTable;
|
||||
} else {
|
||||
oldPropertyTable = (HashMap<String, String>)propertyTableStack.peek();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setProject(Project prj) {
|
||||
PropertyManager.prj = prj;
|
||||
}
|
||||
|
||||
public static void setProperty(String name, String value) {
|
||||
if (prj == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
setProperty(prj, name, value);
|
||||
|
||||
if (oldPropertyTable == null || bakPropertyTable == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String oldValue = oldPropertyTable.get(name);
|
||||
if (oldValue == null) {
|
||||
oldValue = value;
|
||||
}
|
||||
bakPropertyTable.put(name, oldValue);
|
||||
}
|
||||
|
||||
public static void setProperty(Project project, String name, String value) {
|
||||
if (project == null) {
|
||||
if (prj == null) {
|
||||
return;
|
||||
}
|
||||
project = prj;
|
||||
}
|
||||
|
||||
PropertyHelper.getPropertyHelper(project).setProperty(null, name, value, false);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue