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=2265d6ba05cbf2135505727ab0ff75a92b7f62e1;hp=b047fab425d674af9c6c48fa61027b293b0dfc65;hb=98840b104906f4c811868722e6a4bf6ffe102ca1;hpb=47412835e579350c720736e9a51e8b883ab3bf61
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/GenBuildTask.java b/Tools/Java/Source/GenBuild/org/tianocore/build/GenBuildTask.java
index b047fab425..2265d6ba05 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;
/**
@@ -153,6 +151,10 @@ public class GenBuildTask extends Ant {
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;
}
}
@@ -199,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 {
@@ -228,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])) {
@@ -255,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]);
@@ -290,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;
}
@@ -423,8 +429,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
@@ -476,6 +485,8 @@ public class GenBuildTask extends Ant {
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);
@@ -488,10 +499,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
@@ -499,7 +506,6 @@ public class GenBuildTask extends Ant {
getProject().setProperty(cmd[m] + "_FLAGS", "");
}
-
//
// Set CC_EXT
//
@@ -541,6 +547,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", "");
+ }
}
}
@@ -621,10 +649,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 ;
@@ -636,7 +665,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);
//
@@ -694,54 +723,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;
}
@@ -835,4 +816,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 "";
+ }
}