X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=Tools%2FSource%2FGenBuild%2Forg%2Ftianocore%2Fbuild%2FModuleBuildFileGenerator.java;h=1bdae21245f594cadb2a82ebd24582d542d86527;hb=83fba802560b3446de68ac1c280773cf1a4271be;hp=df1af186bf8960b4b4748e1d4b14c7db40d33a93;hpb=391dbbb1c00daefe78e7e44499d048943ca866ae;p=mirror_edk2.git diff --git a/Tools/Source/GenBuild/org/tianocore/build/ModuleBuildFileGenerator.java b/Tools/Source/GenBuild/org/tianocore/build/ModuleBuildFileGenerator.java index df1af186bf..1bdae21245 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/ModuleBuildFileGenerator.java +++ b/Tools/Source/GenBuild/org/tianocore/build/ModuleBuildFileGenerator.java @@ -13,9 +13,7 @@ package org.tianocore.build; import java.io.File; import java.util.LinkedHashMap; -import java.util.LinkedHashSet; import java.util.Map; -import java.util.Set; import java.io.FileOutputStream; import java.io.OutputStreamWriter; @@ -32,8 +30,8 @@ import javax.xml.transform.stream.StreamResult; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.tianocore.build.fpd.FpdParserTask; -import org.tianocore.build.global.GlobalData; import org.tianocore.build.global.SurfaceAreaQuery; +import org.tianocore.build.global.PropertyManager; import org.tianocore.build.id.FpdModuleIdentification; import org.tianocore.build.id.ModuleIdentification; import org.tianocore.build.id.PackageIdentification; @@ -65,10 +63,16 @@ public class ModuleBuildFileGenerator { private String ffsKeyword; - public ModuleBuildFileGenerator(Project project, String ffsKeyword, FpdModuleIdentification fpdModuleId) { + private String[] includes; + + private SurfaceAreaQuery saq = null; + + public ModuleBuildFileGenerator(Project project, String ffsKeyword, FpdModuleIdentification fpdModuleId, String[] includes, SurfaceAreaQuery saq) { this.project = project; this.fpdModuleId = fpdModuleId; this.ffsKeyword = ffsKeyword; + this.includes = includes; + this.saq = saq; } /** @@ -87,7 +91,7 @@ public class ModuleBuildFileGenerator { Error throws during BaseName_build.xml generating. **/ public void genBuildFile(String buildFilename) throws BuildException { - FfsProcess fp = new FfsProcess(); + FfsProcess fp = new FfsProcess(saq); DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance(); try { DocumentBuilder dombuilder = domfac.newDocumentBuilder(); @@ -292,7 +296,7 @@ public class ModuleBuildFileGenerator { @param root Root element for current **/ private void applyLibraryInstance(Document document, Node root) { - ModuleIdentification[] libinstances = SurfaceAreaQuery.getLibraryInstance(fpdModuleId.getArch()); + ModuleIdentification[] libinstances = saq.getLibraryInstance(fpdModuleId.getArch()); for (int i = 0; i < libinstances.length; i++) { // // Put package file path to module identification @@ -329,20 +333,6 @@ public class ModuleBuildFileGenerator { root.appendChild(ele); } } - - /** - Return the name of the directory that corresponds to the architecture. - This is a translation from the XML Schema tag to a directory that - corresponds to our directory name coding convention. - - **/ - private String archDir(String arch) { - return arch.replaceFirst("X64", "x64") - .replaceFirst("IPF", "Ipf") - .replaceFirst("IA32", "Ia32") - .replaceFirst("ARM", "Arm") - .replaceFirst("EBC", "Ebc"); - } /** Generate the build source files elements for BaseName_build.xml. @@ -351,66 +341,10 @@ public class ModuleBuildFileGenerator { @param root Root element for current **/ private void applyCompileElement(Document document, Node root) { - // - // Prepare the includes: PackageDependencies and Output debug direactory - // - Set includes = new LinkedHashSet(); - String arch = project.getProperty("ARCH"); - - // - // WORKSPACE - // - includes.add("${WORKSPACE_DIR}" + File.separatorChar); - - // - // Module iteself - // - includes.add("${MODULE_DIR}"); - includes.add("${MODULE_DIR}" + File.separatorChar + archDir(arch)); - - // - // Packages in PackageDenpendencies - // - PackageIdentification[] packageDependencies = SurfaceAreaQuery.getDependencePkg(fpdModuleId.getArch()); - for (int i = 0; i < packageDependencies.length; i++) { - GlobalData.refreshPackageIdentification(packageDependencies[i]); - File packageFile = packageDependencies[i].getSpdFile(); - includes.add(packageFile.getParent() + File.separatorChar + "Include"); - includes.add(packageFile.getParent() + File.separatorChar + "Include" + File.separatorChar + archDir(arch)); - } - - // - // All Dependency Library Instance's PackageDependencies - // - ModuleIdentification[] libinstances = SurfaceAreaQuery.getLibraryInstance(fpdModuleId.getArch()); - for (int i = 0; i < libinstances.length; i++) { - SurfaceAreaQuery.push(GlobalData.getDoc(libinstances[i], fpdModuleId.getArch())); - PackageIdentification[] libraryPackageDependencies = SurfaceAreaQuery.getDependencePkg(fpdModuleId.getArch()); - for (int j = 0; j < libraryPackageDependencies.length; j++) { - GlobalData.refreshPackageIdentification(libraryPackageDependencies[j]); - File packageFile = libraryPackageDependencies[j].getSpdFile(); - includes.add(packageFile.getParent() + File.separatorChar + "Include"); - includes.add(packageFile.getParent() + File.separatorChar + "Include" + File.separatorChar + archDir(arch)); - } - SurfaceAreaQuery.pop(); - } - - - // - // The package which the module belongs to - // TBD - includes.add(fpdModuleId.getModule().getPackage().getPackageDir() + File.separatorChar + "Include"); - includes.add(fpdModuleId.getModule().getPackage().getPackageDir() + File.separatorChar + "Include" + File.separatorChar + archDir(arch)); - - // - // Debug files output directory - // - includes.add("${DEST_DIR_DEBUG}"); - // // sourceFiles[][0] is FileType, [][1] is File name relative to Module_Dir // - String[][] sourceFiles = SurfaceAreaQuery.getSourceFiles(fpdModuleId.getArch()); + String[][] sourceFiles = saq.getSourceFiles(fpdModuleId.getArch()); FileProcess fileProcess = new FileProcess(); fileProcess.init(project, includes, document); @@ -446,11 +380,10 @@ public class ModuleBuildFileGenerator { Element ele = document.createElement("Build_Unicode_Database"); ele.setAttribute("FILEPATH", "."); ele.setAttribute("FILENAME", "${BASE_NAME}"); - String[] includePaths = includes.toArray(new String[includes.size()]); Element includesEle = document.createElement("EXTRA.INC"); - for (int i = 0; i < includePaths.length; i++) { + for (int i = 0; i < includes.length; i++) { Element includeEle = document.createElement("includepath"); - includeEle.setAttribute("path", includePaths[i]); + includeEle.setAttribute("path", includes[i]); includesEle.appendChild(includeEle); } ele.appendChild(includesEle); @@ -483,7 +416,7 @@ public class ModuleBuildFileGenerator { for (int i = 0; i < sourceFiles.length; i++) { str += " " + sourceFiles[i][1]; } - project.setProperty("SOURCE_FILES", str.replaceAll("(\\\\)", "/")); + PropertyManager.setProperty(project, "SOURCE_FILES", str.replaceAll("(\\\\)", "/")); } /**