X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FJava%2FSource%2FGenBuild%2Forg%2Ftianocore%2Fbuild%2FGenBuildTask.java;h=5aa717fbdd05882ddb58efde7afddf6b7e45471a;hp=99767ab4f2278c156867ca00905797c630369bba;hb=e3cc406130b14c020c75e3a169f94ba001bf2128;hpb=feccee87a78e68d575dbdf44b34ca0cb5a21ea8d
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/GenBuildTask.java b/Tools/Java/Source/GenBuild/org/tianocore/build/GenBuildTask.java
index 99767ab4f2..5aa717fbdd 100644
--- a/Tools/Java/Source/GenBuild/org/tianocore/build/GenBuildTask.java
+++ b/Tools/Java/Source/GenBuild/org/tianocore/build/GenBuildTask.java
@@ -23,19 +23,14 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Vector;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.BuildListener;
+import org.apache.tools.ant.Location;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Ant;
import org.apache.tools.ant.taskdefs.Property;
import org.apache.xmlbeans.XmlObject;
-
-import org.tianocore.common.definitions.ToolDefinitions;
-import org.tianocore.common.exception.EdkException;
-import org.tianocore.common.logger.EdkLog;
import org.tianocore.build.autogen.AutoGen;
import org.tianocore.build.exception.AutoGenException;
import org.tianocore.build.exception.GenBuildException;
@@ -50,6 +45,9 @@ import org.tianocore.build.id.ModuleIdentification;
import org.tianocore.build.id.PackageIdentification;
import org.tianocore.build.id.PlatformIdentification;
import org.tianocore.build.tools.ModuleItem;
+import org.tianocore.common.definitions.ToolDefinitions;
+import org.tianocore.common.exception.EdkException;
+import org.tianocore.common.logger.EdkLog;
/**
@@ -134,30 +132,29 @@ public class GenBuildTask extends Ant {
try {
processGenBuild();
} catch (PcdAutogenException e) {
- //
- // Add more logic process here
- //
- throw new BuildException(e.getMessage());
+ BuildException buildException = new BuildException(e.getMessage());
+ buildException.setStackTrace(e.getStackTrace());
+ throw buildException;
} catch (AutoGenException e) {
- //
- // Add more logic process here
- //
- throw new BuildException(e.getMessage());
+ BuildException buildException = new BuildException(e.getMessage());
+ buildException.setStackTrace(e.getStackTrace());
+ throw buildException;
} catch (PlatformPcdPreprocessBuildException e) {
- //
- // Add more logic process here
- //
- throw new BuildException(e.getMessage());
+ BuildException buildException = new BuildException(e.getMessage());
+ buildException.setStackTrace(e.getStackTrace());
+ throw buildException;
} catch (GenBuildException e) {
- //
- // Add more logic process here
- //
- throw new BuildException(e.getMessage());
+ BuildException buildException = new BuildException(e.getMessage());
+ buildException.setStackTrace(e.getStackTrace());
+ throw buildException;
} catch (EdkException e) {
- //
- // Add more logic process here
- //
- throw new BuildException(e.getMessage());
+ BuildException buildException = new BuildException(e.getMessage());
+ buildException.setStackTrace(e.getStackTrace());
+ throw buildException;
+ } catch (Exception e) {
+ BuildException buildException = new BuildException(e.getMessage());
+ buildException.setStackTrace(e.getStackTrace());
+ throw buildException;
}
}
@@ -204,7 +201,7 @@ public class GenBuildTask extends Ant {
moduleId.setMsaFile(msaFile);
}
- String[] producedLibraryClasses = saq.getLibraryClasses("ALWAYS_PRODUCED",null);
+ String[] producedLibraryClasses = saq.getLibraryClasses("ALWAYS_PRODUCED", null, null);
if (producedLibraryClasses.length == 0) {
moduleId.setLibrary(false);
} else {
@@ -233,9 +230,9 @@ public class GenBuildTask extends Ant {
}
Set archSet = new LinkedHashSet();
-
- if ( getProject().getProperty("ARCH") != null) {
- String[] fpdArchList = getProject().getProperty("ARCH").split(" ");
+ String archString = getProject().getProperty("ARCH");
+ if (archString != null) {
+ String[] fpdArchList = archString.split(" ");
for (int i = 0; i < fpdArchList.length; i++) {
if (archListSupByToolChain.contains(fpdArchList[i])) {
@@ -260,6 +257,10 @@ public class GenBuildTask extends Ant {
}
}
+ if (archList.length == 0) {
+ EdkLog.log(this, EdkLog.EDK_WARNING, "Warning: " + "[" + archString + "] is not supported for " + moduleId + " in this build!\n");
+ }
+
for (int k = 0; k < archList.length; k++) {
getProject().setProperty("ARCH", archList[k]);
@@ -295,7 +296,7 @@ public class GenBuildTask extends Ant {
// don't do anything if no tools found
//
if (GlobalData.isCommandSet(targetList[i], toolchainList[j], archList[k]) == false) {
- EdkLog.log(this, EdkLog.EDK_WARNING, "Warning: No build issued. No tools were found for [target=" + targetList[i] + " toolchain=" + toolchainList[j] + " arch=" + archList[k] + "]\n");
+ EdkLog.log(this, EdkLog.EDK_WARNING, "Warning: No build issued. No tools found for [target=" + targetList[i] + " toolchain=" + toolchainList[j] + " arch=" + archList[k] + "]\n");
continue;
}
@@ -326,10 +327,8 @@ public class GenBuildTask extends Ant {
if (type.equalsIgnoreCase("all") || type.equalsIgnoreCase("build")) {
applyBuild(targetList[i], toolchainList[j], fpdModuleId);
- } else if (type.equalsIgnoreCase("clean")) {
- applyClean(fpdModuleId);
- } else if (type.equalsIgnoreCase("cleanall")) {
- applyCleanall(fpdModuleId);
+ } else {
+ applyNonBuildTarget(fpdModuleId);
}
}
}
@@ -428,8 +427,11 @@ public class GenBuildTask extends Ant {
getProject().setProperty("FILE_GUID", moduleId.getGuid());
getProject().setProperty("VERSION", moduleId.getVersion());
getProject().setProperty("MODULE_TYPE", moduleId.getModuleType());
- getProject().setProperty("MODULE_DIR", moduleId.getMsaFile().getParent().replaceAll("(\\\\)", "/"));
- getProject().setProperty("MODULE_RELATIVE_DIR", moduleId.getModuleRelativePath().replaceAll("(\\\\)", "/"));
+ File msaFile = moduleId.getMsaFile();
+ String msaFileName = msaFile.getName();
+ getProject().setProperty("MODULE_DIR", msaFile.getParent().replaceAll("(\\\\)", "/"));
+ getProject().setProperty("MODULE_RELATIVE_DIR", moduleId.getModuleRelativePath().replaceAll("(\\\\)", "/")
+ + File.separatorChar + msaFileName.substring(0, msaFileName.lastIndexOf('.')));
//
// SUBSYSTEM
@@ -480,6 +482,11 @@ public class GenBuildTask extends Ant {
String cmdPath = GlobalData.getCommandSetting(key, fpdModuleId);
key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_NAME;
String cmdName = GlobalData.getCommandSetting(key, fpdModuleId);
+ if (cmdName.length() == 0) {
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, "Warning: " + cmd[m] + " hasn't been defined!");
+ getProject().setProperty(cmd[m], "");
+ continue;
+ }
File cmdFile = new File(cmdPath + File.separatorChar + cmdName);
getProject().setProperty(cmd[m], cmdFile.getPath().replaceAll("(\\\\)", "/"));
@@ -490,10 +497,6 @@ public class GenBuildTask extends Ant {
String cmdFlags = GlobalData.getCommandSetting(key, fpdModuleId);
if (cmdFlags != null)
{
-// Set addset = new LinkedHashSet();
-// Set subset = new LinkedHashSet();
-// putFlagsToSet(addset, cmdFlags);
-// getProject().setProperty(cmd[m] + "_FLAGS", getProject().replaceProperties(getFlags(addset, subset)));
getProject().setProperty(cmd[m] + "_FLAGS", cmdFlags);
}
else
@@ -501,7 +504,6 @@ public class GenBuildTask extends Ant {
getProject().setProperty(cmd[m] + "_FLAGS", "");
}
-
//
// Set CC_EXT
//
@@ -543,6 +545,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", "");
+ }
}
}
@@ -623,10 +647,11 @@ public class GenBuildTask extends Ant {
// if it is CUSTOM_BUILD
// then call the exist BaseName_build.xml directly.
//
- if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
- EdkLog.log(this, "Call user-defined " + moduleId.getName() + "_build.xml");
+ String buildFilename = "";
+ if ((buildFilename = GetCustomizedBuildFile(fpdModuleId.getArch())) != "") {
+ EdkLog.log(this, "Call user-defined " + buildFilename);
- String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml";
+ String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + buildFilename;
antCall(antFilename, null);
return ;
@@ -638,7 +663,7 @@ public class GenBuildTask extends Ant {
//
String ffsKeyword = saq.getModuleFfsKeyword();
ModuleBuildFileGenerator fileGenerator = new ModuleBuildFileGenerator(getProject(), ffsKeyword, fpdModuleId, includes, saq);
- String buildFilename = getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml";
+ buildFilename = getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml";
fileGenerator.genBuildFile(buildFilename);
//
@@ -648,6 +673,24 @@ public class GenBuildTask extends Ant {
antCall(antFilename, null);
}
+ private void applyNonBuildTarget(FpdModuleIdentification fpdModuleId){
+ //
+ // if it is CUSTOM_BUILD
+ // then call the exist BaseName_build.xml directly.
+ //
+ if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
+ EdkLog.log(this, "Calling user-defined " + moduleId.getName() + "_build.xml");
+
+ String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml";
+ antCall(antFilename, this.type);
+
+ return ;
+ }
+
+ String antFilename = getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml";
+ antCall(antFilename, this.type);
+ }
+
private void applyClean(FpdModuleIdentification fpdModuleId){
//
// if it is CUSTOM_BUILD
@@ -696,54 +739,6 @@ public class GenBuildTask extends Ant {
ant.execute();
}
-
- /**
- Separate the string and instore in set.
-
- String is separated by Java Regulation Expression
- "[^\\\\]?(\".*?[^\\\\]\")[ \t,]+".
-
- For example:
-
-
- "/nologo", "/W3", "/WX"
- "/C", "/DSTRING_DEFINES_FILE=\"BdsStrDefs.h\""
-
-
- @param set store the separated string
- @param str string to separate
- **/
- private void putFlagsToSet(Set set, String str) {
- if (str == null || str.length() == 0) {
- return;
- }
-
- Pattern myPattern = Pattern.compile("[^\\\\]?(\".*?[^\\\\]\")[ \t,]+");
- Matcher matcher = myPattern.matcher(str + " ");
- while (matcher.find()) {
- String item = str.substring(matcher.start(1), matcher.end(1));
- set.add(item);
- }
- }
-
- /**
- Generate the final flags string will be used by compile command.
-
- @param add the add flags set
- @param sub the sub flags set
- @return final flags after add set substract sub set
- **/
- private String getFlags(Set add, Set sub) {
- String result = "";
- add.removeAll(sub);
- Iterator iter = add.iterator();
- while (iter.hasNext()) {
- String str = (String) iter.next();
- result += str.substring(1, str.length() - 1) + " ";
- }
- return result;
- }
-
public void setSingleModuleBuild(boolean isSingleModuleBuild) {
this.isSingleModuleBuild = isSingleModuleBuild;
}
@@ -837,4 +832,15 @@ public class GenBuildTask extends Ant {
public void setExternalProperties(Vector v) {
this.properties = v;
}
+
+ private String GetCustomizedBuildFile(String arch) {
+ String[][] files = saq.getSourceFiles(arch);
+ for (int i = 0; i < files.length; ++i) {
+ if (files[i][1].endsWith("build.xml")) {
+ return files[i][1];
+ }
+ }
+
+ return "";
+ }
}