\r
String outputDelimiter = null;\r
\r
- private static String pathName = null;\r
- \r
public void command(CCTask cctask, UserDefineDef userdefine) {\r
boolean isGccCommand = userdefine.getFamily().equalsIgnoreCase("GCC");\r
File workdir;\r
// }\r
// project.log(logLine.toString(), Project.MSG_VERBOSE);\r
\r
- int retval = 0;\r
+ Environment newEnv = new Environment();\r
\r
- if (userdefine.getDpath() == null || userdefine.getDpath().trim().length() == 0) {\r
- retval = runCommand(cctask, workdir, cmd, null);\r
- } else {\r
- String existPath = System.getenv(getPathName());\r
- Environment newEnv = new Environment();\r
+ //\r
+ // Prepare for environment variable PATH\r
+ //\r
+ if (userdefine.getDpath() != null && userdefine.getDpath().trim().length() != 0) {\r
+ String pathName = getPathName("PATH");\r
+ String existPath = System.getenv(pathName);\r
+ \r
Variable var = new Variable();\r
- var.setKey(getPathName());\r
+ var.setKey(pathName);\r
var.setPath(new Path(project, userdefine.getDpath() + ";" + existPath));\r
newEnv.addVariable(var);\r
- retval = runCommand(cctask, workdir, cmd, newEnv);\r
}\r
\r
+ //\r
+ // Prepare for environment variable LIB\r
+ //\r
+ if (userdefine.getLibpath() != null && userdefine.getLibpath().trim().length() != 0) {\r
+ String pathName = getPathName("LIB");\r
+ String existPath = System.getenv(pathName);\r
+ Variable var = new Variable();\r
+ var.setKey(pathName);\r
+ if (existPath == null) {\r
+ var.setPath(new Path(project, userdefine.getLibpath()));\r
+ } else {\r
+ var.setPath(new Path(project, userdefine.getLibpath() + ";" + existPath));\r
+ }\r
+ newEnv.addVariable(var);\r
+ }\r
+ \r
+ //\r
+ // Prepare for environment variable INCLUDE\r
+ //\r
+ if (userdefine.getInclude() != null && userdefine.getInclude().trim().length() != 0) {\r
+ String pathName = getPathName("INCLUDE");\r
+ String existPath = System.getenv(pathName);\r
+ Variable var = new Variable();\r
+ var.setKey(pathName);\r
+ if (existPath == null) {\r
+ var.setPath(new Path(project, userdefine.getInclude()));\r
+ } else {\r
+ var.setPath(new Path(project, userdefine.getInclude() + ";" + existPath));\r
+ }\r
+ newEnv.addVariable(var);\r
+ }\r
+ \r
+ int retval = runCommand(cctask, workdir, cmd, newEnv);\r
\r
if (retval != 0) {\r
throw new BuildException(userdefine.getCmd()\r
}\r
}\r
\r
- private String getPathName() {\r
- if (pathName != null) {\r
- return pathName;\r
- }\r
+ private String getPathName(String variableName) {\r
Map allEnv = System.getenv();\r
Iterator iter = allEnv.keySet().iterator();\r
while (iter.hasNext()) {\r
String key = (String)iter.next();\r
- if(key.equalsIgnoreCase("PATH")) {\r
- pathName = key;\r
- break ;\r
+ if(key.equalsIgnoreCase(variableName)) {\r
+ return key;\r
}\r
}\r
- return pathName;\r
+ return variableName;\r
}\r
\r
protected int runCommand(CCTask task, File workingDir, String[] cmdline, Environment env)\r