Support two more attribute LIBPATH and INCLUDEPATH in tools_def file.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1761 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
wuyizhong 2006-10-16 09:24:08 +00:00
parent 8270b34d9d
commit c639781ef0
2 changed files with 52 additions and 18 deletions

View File

@ -45,8 +45,6 @@ public class CommandLineUserDefine {
String outputDelimiter = null;
private static String pathName = null;
public void command(CCTask cctask, UserDefineDef userdefine) {
boolean isGccCommand = userdefine.getFamily().equalsIgnoreCase("GCC");
File workdir;
@ -222,30 +220,48 @@ public class CommandLineUserDefine {
Environment newEnv = new Environment();
//
// Prepare for environment variable PATH
//
if (userdefine.getDpath() != null && userdefine.getDpath().trim().length() != 0) {
String existPath = System.getenv(getPathName("PATH"));
String pathName = getPathName("PATH");
String existPath = System.getenv(pathName);
Variable var = new Variable();
var.setKey(getPathName("PATH"));
var.setKey(pathName);
var.setPath(new Path(project, userdefine.getDpath() + ";" + existPath));
newEnv.addVariable(var);
}
//
// Prepare for environment variable LIB
//
if (userdefine.getLibpath() != null && userdefine.getLibpath().trim().length() != 0) {
String existPath = System.getenv(getPathName("LIB"));
String pathName = getPathName("LIB");
String existPath = System.getenv(pathName);
Variable var = new Variable();
var.setKey(getPathName("LIB"));
var.setPath(new Path(project, userdefine.getLibpath() + ";" + existPath));
var.setKey(pathName);
if (existPath == null) {
var.setPath(new Path(project, userdefine.getLibpath()));
} else {
var.setPath(new Path(project, userdefine.getLibpath() + ";" + existPath));
}
newEnv.addVariable(var);
}
//
// Prepare for environment variable INCLUDE
//
if (userdefine.getInclude() != null && userdefine.getInclude().trim().length() != 0) {
String existPath = System.getenv(getPathName("INCLUDE"));
String pathName = getPathName("INCLUDE");
String existPath = System.getenv(pathName);
Variable var = new Variable();
var.setKey(getPathName("INCLUDE"));
var.setPath(new Path(project, userdefine.getInclude() + ";" + existPath));
var.setKey(pathName);
if (existPath == null) {
var.setPath(new Path(project, userdefine.getInclude()));
} else {
var.setPath(new Path(project, userdefine.getInclude() + ";" + existPath));
}
newEnv.addVariable(var);
}
@ -259,19 +275,15 @@ public class CommandLineUserDefine {
}
private String getPathName(String variableName) {
if (pathName != null) {
return pathName;
}
Map allEnv = System.getenv();
Iterator iter = allEnv.keySet().iterator();
while (iter.hasNext()) {
String key = (String)iter.next();
if(key.equalsIgnoreCase(variableName)) {
pathName = key;
break ;
return key;
}
}
return pathName;
return variableName;
}
protected int runCommand(CCTask task, File workingDir, String[] cmdline, Environment env)

View File

@ -543,6 +543,28 @@ public class GenBuildTask extends Ant {
} else {
getProject().setProperty(cmd[m] + "_DPATH", "");
}
//
// Set CC_LIBPATH
//
key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_LIBPATH;
String libpath = GlobalData.getCommandSetting(key, fpdModuleId);
if (libpath != null) {
getProject().setProperty(cmd[m] + "_LIBPATH", libpath.replaceAll("(\\\\)", "/"));
} else {
getProject().setProperty(cmd[m] + "_LIBPATH", "");
}
//
// Set CC_INCLUDEPATH
//
key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_INCLUDEPATH;
String includepath = GlobalData.getCommandSetting(key, fpdModuleId);
if (dpath != null) {
getProject().setProperty(cmd[m] + "_INCLUDEPATH", includepath.replaceAll("(\\\\)", "/"));
} else {
getProject().setProperty(cmd[m] + "_INCLUDEPATH", "");
}
}
}