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=9a847172f8f0ecfd17f3bc48248db1e34e209dca;hb=e3cc406130b14c020c75e3a169f94ba001bf2128;hpb=c639781ef01dcfa4a66ac00cc0eb79bb34ef911b diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/GenBuildTask.java b/Tools/Java/Source/GenBuild/org/tianocore/build/GenBuildTask.java index 9a847172f8..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; /**

@@ -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]); @@ -321,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); } } } @@ -423,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 @@ -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 // @@ -645,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 ; @@ -660,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); // @@ -670,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 @@ -718,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; } @@ -859,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 ""; + } }