X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FSource%2FGenBuild%2Forg%2Ftianocore%2Fbuild%2FGenBuildTask.java;h=c8cc4ad74890729a245d705ac896467b4ca0d5be;hp=1f020b3cc15df0b17b2d66dd247f1901a25b8f4c;hb=2d16dcec6f602d218ae95a823fca6ae542e03a8f;hpb=57cc2ee710e6a12621f879dd5e95dc7d4fb8cba9 diff --git a/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java b/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java index 1f020b3cc1..c8cc4ad748 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java +++ b/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java @@ -1,9 +1,9 @@ /** @file - This file is ANT task GenBuild. - - The file is used to parse a specified Module, and generate its build time + This file is ANT task GenBuild. + + The file is used to parse a specified Module, and generate its build time ANT script build.xml, then call the the ANT script to build the module. - + Copyright (c) 2006, Intel Corporation All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -16,7 +16,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. package org.tianocore.build; import java.io.File; -import java.util.ArrayList; import java.util.Hashtable; import java.util.Iterator; import java.util.LinkedHashSet; @@ -33,6 +32,9 @@ 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.fpd.FpdParserTask; import org.tianocore.build.global.GenBuildLogger; @@ -44,56 +46,57 @@ 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.exception.EdkException; -import org.tianocore.logger.EdkLog; /**

GenBuildTask is an ANT task that can be used in ANT build - system. The main function of this task is to parse module's surface area, + system. + +

The main function of this task is to parse module's surface area (MSA), then generate the corresponding BaseName_build.xml (the real ANT build script) and call this to build the module. The whole process including: - 1. generate AutoGen.c and AutoGen.h; 2. build all dependent library instances; - 3. build all source files inlcude AutoGen.c; 4. generate sections; - 5. generate FFS file if it is driver module while LIB file if it is Library module. -

- +
+  1. generate AutoGen.c and AutoGen.h; 
+  2. build all dependent library instances;
+  3. build all source files inlcude AutoGen.c; 
+  4. generate sections;
+  5. generate FFS file if it is driver module while LIB file if it is Library module.
+  
+ +

The usage is (take module HelloWorld for example):

- +
-   <GenBuild  
-             msaFilename="HelloWorld.msa"/> 
+   <GenBuild
+             msaFilename="HelloWorld.msa"/>
              processTo="ALL"/>
   
- -

processTo provides a way to customize the whole build process. - processTo can be one value of ALL, AUTOGEN, FILES, LIBRARYINSTANCES, SECTIONS, NONE. - Default is ALL, means whole + +

processTo provides a way to customize the whole build process. + processTo can be one value of ALL, AUTOGEN, FILES, LIBRARYINSTANCES, SECTIONS, NONE. + Default is ALL, means whole

- +

This task calls AutoGen to generate AutoGen.c and AutoGen.h. The task also parses the development environment configuration files, such as collecting package information, setting compiler flags and so on.

- - + + @since GenBuild 1.0 **/ public class GenBuildTask extends Ant { - + /// /// Module surface area file. /// File msaFile; - /// - /// - /// - private String type = "all"; // = "build"; + private String type = "all"; /// /// Module's Identification. @@ -103,9 +106,9 @@ public class GenBuildTask extends Ant { private Vector properties = new Vector(); private static Stack backupPropertiesStack = new Stack(); - + private boolean isSingleModuleBuild = false; - + /** Public construct method. It is necessary for ANT task. **/ @@ -113,7 +116,7 @@ public class GenBuildTask extends Ant { } /** - + @throws BuildException From module build, exception from module surface area invalid. **/ @@ -124,8 +127,7 @@ public class GenBuildTask extends Ant { GenBuildLogger logger = new GenBuildLogger(getProject()); EdkLog.setLogLevel(getProject().getProperty("env.LOGLEVEL")); EdkLog.setLogger(logger); - // remove !! - try { + pushProperties(); // // Enable all specified properties @@ -135,7 +137,7 @@ public class GenBuildTask extends Ant { Property item = iter.next(); getProject().setProperty(item.getName(), item.getValue()); } - + // // GenBuild should specify either msaFile or moduleGuid & packageGuid // @@ -145,7 +147,7 @@ public class GenBuildTask extends Ant { String packageGuid = getProject().getProperty("PACKAGE_GUID"); String packageVersion = getProject().getProperty("PACKAGE_VERSION"); if (moduleGuid == null || packageGuid == null) { - throw new BuildException("GenBuild parameters error. "); + throw new BuildException("GenBuild parameter error."); } PackageIdentification packageId = new PackageIdentification(packageGuid, packageVersion); moduleId = new ModuleIdentification(moduleGuid, moduleVersion); @@ -153,8 +155,7 @@ public class GenBuildTask extends Ant { Map doc = GlobalData.getNativeMsa(moduleId); SurfaceAreaQuery.setDoc(doc); moduleId = SurfaceAreaQuery.getMsaHeader(); - } - else { + } else { Map doc = GlobalData.getNativeMsa(msaFile); SurfaceAreaQuery.setDoc(doc); moduleId = SurfaceAreaQuery.getMsaHeader(); @@ -162,11 +163,10 @@ public class GenBuildTask extends Ant { String[] producedLibraryClasses = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED",null); if (producedLibraryClasses.length == 0) { moduleId.setLibrary(false); - } - else { + } else { moduleId.setLibrary(true); } - + // // Judge whether it is single module build or not // @@ -175,8 +175,7 @@ public class GenBuildTask extends Ant { // Single Module build // prepareSingleModuleBuild(); - } - else { + } else { // // Platform build. Restore the platform related info // @@ -184,41 +183,40 @@ public class GenBuildTask extends Ant { PlatformIdentification platformId = GlobalData.getPlatform(filename); getProject().setProperty("PLATFORM_DIR", platformId.getFpdFile().getParent().replaceAll("(\\\\)", "/")); getProject().setProperty("PLATFORM_RELATIVE_DIR", platformId.getPlatformRelativeDir().replaceAll("(\\\\)", "/")); - + String packageGuid = getProject().getProperty("PACKAGE_GUID"); String packageVersion = getProject().getProperty("PACKAGE_VERSION"); PackageIdentification packageId = new PackageIdentification(packageGuid, packageVersion); moduleId.setPackage(packageId); } - + // - // If single module : intersection MSA supported ARCHs and tools def!! - // else, get arch from pass down + // If single module : get arch from pass down, otherwise intersection MSA + // supported ARCHs and tools def // - Set archListSupByToolChain = new LinkedHashSet(); - String[] archs = GlobalData.getToolChainInfo().getArchs(); - + Set archListSupByToolChain = new LinkedHashSet(); + String[] archs = GlobalData.getToolChainInfo().getArchs(); + for (int i = 0; i < archs.length; i ++) { archListSupByToolChain.add(archs[i]); } - + Set archSet = new LinkedHashSet(); - + if ( getProject().getProperty("ARCH") != null) { String[] fpdArchList = getProject().getProperty("ARCH").split(" "); - + for (int i = 0; i < fpdArchList.length; i++) { if (archListSupByToolChain.contains(fpdArchList[i])) { archSet.add(fpdArchList[i]); } } - } - else { + } else { archSet = archListSupByToolChain; } - + String[] archList = archSet.toArray(new String[archSet.size()]); - + // // Judge if arch is all supported by current module. If not, throw Exception. // @@ -226,28 +224,29 @@ public class GenBuildTask extends Ant { if (moduleSupportedArchs != null) { for (int k = 0; k < archList.length; k++) { if ( ! moduleSupportedArchs.contains(archList[k])) { - throw new BuildException("ARCH [" + archList[k] + "] is not supported by " + moduleId + ". " + moduleId + " only supports [" + moduleSupportedArchs + "]."); + throw new BuildException("Specified architecture [" + archList[k] + "] is not supported by " + moduleId + ". The module " + moduleId + " only supports [" + moduleSupportedArchs + "] architectures."); } } } - + for (int k = 0; k < archList.length; k++) { - + getProject().setProperty("ARCH", archList[k]); - + FpdModuleIdentification fpdModuleId = new FpdModuleIdentification(moduleId, archList[k]); - + // // Whether the module is built before // - if ((moduleId.isLibrary() == false && GlobalData.hasFpdModuleSA(fpdModuleId) == false) - || GlobalData.isModuleBuilt(fpdModuleId)) { + if (moduleId.isLibrary() == false && GlobalData.hasFpdModuleSA(fpdModuleId) == false) { + System.out.println("\nWARNING: " + moduleId + " for " + archList[k] + " was not found in current platform FPD file!\n"); continue; - } - else { + } else if (GlobalData.isModuleBuilt(fpdModuleId)) { + return; + } else { GlobalData.registerBuiltModule(fpdModuleId); } - + // // For Every TOOLCHAIN, TARGET // @@ -263,9 +262,9 @@ public class GenBuildTask extends Ant { // // check if any tool is defined for current target + toolchain + arch // don't do anything if no tools found - // + // if (GlobalData.isCommandSet(targetList[i], toolchainList[j], archList[k]) == false) { - System.out.println("Warning: No build issued. No tools found for [target=" + targetList[i] + " toolchain=" + toolchainList[j] + " arch=" + archList[k] + "]\n"); + System.out.println("Warning: No build issued. No tools were found for [target=" + targetList[i] + " toolchain=" + toolchainList[j] + " arch=" + archList[k] + "]\n"); continue; } @@ -278,49 +277,44 @@ public class GenBuildTask extends Ant { System.out.println("Build " + moduleId + " start >>>"); System.out.println("Target: " + targetList[i] + " Tagname: " + toolchainList[j] + " Arch: " + archList[k]); SurfaceAreaQuery.setDoc(GlobalData.getDoc(fpdModuleId)); - + // // Prepare for all other common properties // PACKAGE, PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR // MODULE or BASE_NAME, GUID or FILE_GUID, VERSION, MODULE_TYPE // MODULE_DIR, MODULE_RELATIVE_DIR // SUBSYSTEM, ENTRYPOINT, EBC_TOOL_LIB_PATH - // LIBS, OBJECTS, SDB_FILES // setModuleCommonProperties(archList[k]); - + // - // OutputManage prepare for + // OutputManage prepare for // BIN_DIR, DEST_DIR_DEBUG, DEST_DIR_OUTPUT, BUILD_DIR, FV_DIR // OutputManager.getInstance().update(getProject()); - + if (type.equalsIgnoreCase("all") || type.equalsIgnoreCase("build")) { applyBuild(targetList[i], toolchainList[j], fpdModuleId); - } - else if (type.equalsIgnoreCase("clean")) { + } else if (type.equalsIgnoreCase("clean")) { applyClean(fpdModuleId); - } - else if (type.equalsIgnoreCase("cleanall")) { + } else if (type.equalsIgnoreCase("cleanall")) { applyCleanall(fpdModuleId); } } } } + popProperties(); - }catch (Exception e){ - throw new BuildException(e.getMessage()); - } } /** - This method is used to prepare Platform-related information. - + This method is used to prepare Platform-related information. +

In Single Module Build mode, platform-related information is not ready. - The method read the system environment variable ACTIVE_PLATFORM + The method read the system environment variable ACTIVE_PLATFORM and search in the Framework Database. Note that platform name in the Framework Database must be unique.

- + **/ private void prepareSingleModuleBuild(){ // @@ -328,27 +322,27 @@ public class GenBuildTask extends Ant { // TBD: Enhance it!!!! // PackageIdentification packageId = GlobalData.getPackageForModule(moduleId); - + moduleId.setPackage(packageId); - + // - // Read ACTIVE_PLATFORM's FPD file (Call FpdParserTask's method) + // Read ACTIVE_PLATFORM's FPD file // String filename = getProject().getProperty("PLATFORM_FILE"); - + if (filename == null){ - throw new BuildException("Plese set ACTIVE_PLATFORM if you want to build a single module. "); + throw new BuildException("Please set ACTIVE_PLATFORM in the file: Tools/Conf/target.txt if you want to build a single module!"); } - + PlatformIdentification platformId = GlobalData.getPlatform(filename); - + // - // Read FPD file + // Read FPD file (Call FpdParserTask's method) // FpdParserTask fpdParser = new FpdParserTask(); fpdParser.setProject(getProject()); fpdParser.parseFpdFile(platformId.getFpdFile()); - + // // Prepare for Platform related common properties // PLATFORM, PLATFORM_DIR, PLATFORM_RELATIVE_DIR @@ -361,6 +355,8 @@ public class GenBuildTask extends Ant { /** Set Module-Related information to properties. + + @param arch current build ARCH **/ private void setModuleCommonProperties(String arch) { // @@ -373,7 +369,7 @@ public class GenBuildTask extends Ant { getProject().setProperty("PACKAGE_VERSION", packageId.getVersion()); getProject().setProperty("PACKAGE_DIR", packageId.getPackageDir().replaceAll("(\\\\)", "/")); getProject().setProperty("PACKAGE_RELATIVE_DIR", packageId.getPackageRelativeDir().replaceAll("(\\\\)", "/")); - + // // MODULE or BASE_NAME, GUID or FILE_GUID, VERSION, MODULE_TYPE // MODULE_DIR, MODULE_RELATIVE_DIR @@ -382,8 +378,7 @@ public class GenBuildTask extends Ant { String baseName = SurfaceAreaQuery.getModuleOutputFileBasename(); if (baseName == null) { getProject().setProperty("BASE_NAME", moduleId.getName()); - } - else { + } else { getProject().setProperty("BASE_NAME", baseName); } getProject().setProperty("GUID", moduleId.getGuid()); @@ -392,24 +387,24 @@ public class GenBuildTask extends Ant { getProject().setProperty("MODULE_TYPE", moduleId.getModuleType()); getProject().setProperty("MODULE_DIR", moduleId.getMsaFile().getParent().replaceAll("(\\\\)", "/")); getProject().setProperty("MODULE_RELATIVE_DIR", moduleId.getModuleRelativePath().replaceAll("(\\\\)", "/")); - + // // SUBSYSTEM // String[][] subsystemMap = { { "BASE", "EFI_BOOT_SERVICE_DRIVER"}, - { "SEC", "EFI_BOOT_SERVICE_DRIVER" }, - { "PEI_CORE", "EFI_BOOT_SERVICE_DRIVER" }, - { "PEIM", "EFI_BOOT_SERVICE_DRIVER" }, + { "SEC", "EFI_BOOT_SERVICE_DRIVER" }, + { "PEI_CORE", "EFI_BOOT_SERVICE_DRIVER" }, + { "PEIM", "EFI_BOOT_SERVICE_DRIVER" }, { "DXE_CORE", "EFI_BOOT_SERVICE_DRIVER" }, - { "DXE_DRIVER", "EFI_BOOT_SERVICE_DRIVER" }, - { "DXE_RUNTIME_DRIVER", "EFI_RUNTIME_DRIVER" }, - { "DXE_SAL_DRIVER", "EFI_BOOT_SERVICE_DRIVER" }, - { "DXE_SMM_DRIVER", "EFI_BOOT_SERVICE_DRIVER" }, - { "TOOL", "EFI_BOOT_SERVICE_DRIVER" }, + { "DXE_DRIVER", "EFI_BOOT_SERVICE_DRIVER" }, + { "DXE_RUNTIME_DRIVER", "EFI_RUNTIME_DRIVER" }, + { "DXE_SAL_DRIVER", "EFI_BOOT_SERVICE_DRIVER" }, + { "DXE_SMM_DRIVER", "EFI_BOOT_SERVICE_DRIVER" }, + { "TOOL", "EFI_BOOT_SERVICE_DRIVER" }, { "UEFI_DRIVER", "EFI_BOOT_SERVICE_DRIVER" }, - { "UEFI_APPLICATION", "EFI_APPLICATION" }, - { "USER_DEFINED", "EFI_BOOT_SERVICE_DRIVER"} }; - + { "UEFI_APPLICATION", "EFI_APPLICATION" }, + { "USER_DEFINED", "EFI_BOOT_SERVICE_DRIVER"} }; + String subsystem = "EFI_BOOT_SERVICE_DRIVER"; for (int i = 0; i < subsystemMap.length; i++) { if (moduleId.getModuleType().equalsIgnoreCase(subsystemMap[i][0])) { @@ -418,23 +413,17 @@ public class GenBuildTask extends Ant { } } getProject().setProperty("SUBSYSTEM", subsystem); - + // // ENTRYPOINT // if (arch.equalsIgnoreCase("EBC")) { getProject().setProperty("ENTRYPOINT", "EfiStart"); - } - else { + } else { getProject().setProperty("ENTRYPOINT", "_ModuleEntryPoint"); } - - // - // LIBS, OBJECTS, SDB_FILES - // + getProject().setProperty("OBJECTS", ""); - getProject().setProperty("SDB_FILES", ""); - getProject().setProperty("LIBS", ""); } private void getCompilerFlags(String target, String toolchain, FpdModuleIdentification fpdModuleId) throws EdkException { @@ -444,82 +433,79 @@ public class GenBuildTask extends Ant { // Set cmd, like CC, DLINK // String[] key = new String[]{target, toolchain, fpdModuleId.getArch(), cmd[m], null}; - key[4] = "PATH"; + key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_PATH; String cmdPath = GlobalData.getCommandSetting(key, fpdModuleId); - key[4] = "NAME"; + key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_NAME; String cmdName = GlobalData.getCommandSetting(key, fpdModuleId); File cmdFile = new File(cmdPath + File.separatorChar + cmdName); getProject().setProperty(cmd[m], cmdFile.getPath().replaceAll("(\\\\)", "/")); - + // // set CC_FLAGS // - key[4] = "FLAGS"; + key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_FLAGS; String cmdFlags = GlobalData.getCommandSetting(key, fpdModuleId); Set addset = new LinkedHashSet(); Set subset = new LinkedHashSet(); putFlagsToSet(addset, cmdFlags); getProject().setProperty(cmd[m] + "_FLAGS", getProject().replaceProperties(getFlags(addset, subset))); - + // // Set CC_EXT // - key[4] = "EXT"; + key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_EXT; String extName = GlobalData.getCommandSetting(key, fpdModuleId); if ( extName != null && ! extName.equalsIgnoreCase("")) { getProject().setProperty(cmd[m] + "_EXT", extName); - } - else { + } else { getProject().setProperty(cmd[m] + "_EXT", ""); } - + // // set CC_FAMILY // - key[4] = "FAMILY"; + key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_FAMILY; String toolChainFamily = GlobalData.getCommandSetting(key, fpdModuleId); if (toolChainFamily != null) { getProject().setProperty(cmd[m] + "_FAMILY", toolChainFamily); } - + // // set CC_SPATH // - key[4] = "SPATH"; + key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_SPATH; String spath = GlobalData.getCommandSetting(key, fpdModuleId); if (spath != null) { getProject().setProperty(cmd[m] + "_SPATH", spath.replaceAll("(\\\\)", "/")); - } - else { + } else { getProject().setProperty(cmd[m] + "_SPATH", ""); } - + // // set CC_DPATH // - key[4] = "DPATH"; + key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_DPATH; String dpath = GlobalData.getCommandSetting(key, fpdModuleId); if (dpath != null) { getProject().setProperty(cmd[m] + "_DPATH", dpath.replaceAll("(\\\\)", "/")); - } - else { + } else { getProject().setProperty(cmd[m] + "_DPATH", ""); } } } - + public void setMsaFile(File msaFile) { this.msaFile = msaFile; } /** - Method is for ANT to initialize MSA file. - + Method is for ANT to initialize MSA file. + @param msaFilename MSA file name **/ public void setMsaFile(String msaFilename) { String moduleDir = getProject().getProperty("MODULE_DIR"); - + // // If is Single Module Build, then use the Base Dir defined in build.xml // @@ -528,17 +514,17 @@ public class GenBuildTask extends Ant { } msaFile = new File(moduleDir + File.separatorChar + msaFilename); } - + public void addConfiguredModuleItem(ModuleItem moduleItem) { PackageIdentification packageId = new PackageIdentification(moduleItem.getPackageGuid(), moduleItem.getPackageVersion()); ModuleIdentification moduleId = new ModuleIdentification(moduleItem.getModuleGuid(), moduleItem.getModuleVersion()); moduleId.setPackage(packageId); this.moduleId = moduleId; } - + /** - Add a property. - + Add a property. + @param p property **/ public void addProperty(Property p) { @@ -548,20 +534,25 @@ public class GenBuildTask extends Ant { public void setType(String type) { this.type = type; } - - private void applyBuild(String buildTarget, String buildTagname, FpdModuleIdentification fpdModuleId) throws EdkException{ + + private void applyBuild(String buildTarget, String buildTagname, FpdModuleIdentification fpdModuleId) throws BuildException{ // // AutoGen // - + AutoGen autogen = new AutoGen(getProject().getProperty("FV_DIR"), getProject().getProperty("DEST_DIR_DEBUG"), fpdModuleId.getModule(),fpdModuleId.getArch()); autogen.genAutogen(); - - + + // // Get compiler flags // - getCompilerFlags(buildTarget, buildTagname, fpdModuleId); + try { + getCompilerFlags(buildTarget, buildTagname, fpdModuleId); + } + catch (EdkException ee) { + throw new BuildException(ee.getMessage()); + } // // Prepare LIBS @@ -572,22 +563,20 @@ public class GenBuildTask extends Ant { propertyLibs += " " + getProject().getProperty("BIN_DIR") + File.separatorChar + libinstances[i].getName() + ".lib"; } getProject().setProperty("LIBS", propertyLibs.replaceAll("(\\\\)", "/")); - + // // if it is CUSTOM_BUILD // then call the exist BaseName_build.xml directly. // if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) { GlobalData.log.info("Call user-defined " + moduleId.getName() + "_build.xml"); - Ant ant = new Ant(); - ant.setProject(getProject()); - ant.setAntfile(getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml"); - ant.setInheritAll(true); - ant.init(); - ant.execute(); + + String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml"; + antCall(antFilename, null); + return ; } - + // // Generate ${BASE_NAME}_build.xml // TBD @@ -596,94 +585,76 @@ public class GenBuildTask extends Ant { ModuleBuildFileGenerator fileGenerator = new ModuleBuildFileGenerator(getProject(), ffsKeyword, fpdModuleId); String buildFilename = getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml"; fileGenerator.genBuildFile(buildFilename); - + // // Ant call ${BASE_NAME}_build.xml // - Ant ant = new Ant(); - ant.setProject(getProject()); - ant.setAntfile(getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml"); - ant.setInheritAll(true); - ant.init(); - ant.execute(); + String antFilename = getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml"; + antCall(antFilename, null); } - + private void applyClean(FpdModuleIdentification fpdModuleId){ // // if it is CUSTOM_BUILD // then call the exist BaseName_build.xml directly. // if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) { - GlobalData.log.info("Call user-defined " + moduleId.getName() + "_build.xml"); - Ant ant = new Ant(); - ant.setProject(getProject()); - ant.setAntfile(getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml"); - ant.setTarget("clean"); - ant.setInheritAll(true); - ant.init(); - ant.execute(); + GlobalData.log.info("Calling user-defined " + moduleId.getName() + "_build.xml"); + + String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml"; + antCall(antFilename, "clean"); + return ; } - - Ant ant = new Ant(); - ant.setProject(getProject()); - ant.setAntfile(getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml"); - ant.setTarget("clean"); - ant.setInheritAll(true); - ant.init(); - ant.execute(); - - // - // Delete current module's DEST_DIR_OUTPUT - // TBD + + String antFilename = getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml"; + antCall(antFilename, "clean"); } - + private void applyCleanall(FpdModuleIdentification fpdModuleId){ // // if it is CUSTOM_BUILD // then call the exist BaseName_build.xml directly. // if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) { - GlobalData.log.info("Call user-defined " + moduleId.getName() + "_build.xml"); - Ant ant = new Ant(); - ant.setProject(getProject()); - ant.setAntfile(getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml"); - ant.setTarget("cleanall"); - ant.setInheritAll(true); - ant.init(); - ant.execute(); + GlobalData.log.info("Calling user-defined " + moduleId.getName() + "_build.xml"); + + String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml"; + antCall(antFilename, "cleanall"); + return ; } + String antFilename = getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml"; + antCall(antFilename, "cleanall"); + } + + private void antCall(String antFilename, String target) { Ant ant = new Ant(); ant.setProject(getProject()); - ant.setAntfile(getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml"); - ant.setTarget("cleanall"); + ant.setAntfile(antFilename); + if (target != null) { + ant.setTarget(target); + } ant.setInheritAll(true); ant.init(); ant.execute(); - - // - // Delete current module's DEST_DIR_OUTPUT - // TBD } - - /** Separate the string and instore in set. - -

String is separated by Java Regulation Expression + +

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 **/ @@ -699,10 +670,10 @@ public class GenBuildTask extends Ant { set.add(item); } } - + /** - Generate the final flags string will be used by compile command. - + 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 @@ -718,64 +689,10 @@ public class GenBuildTask extends Ant { return result; } - /** - Generate the flags string with original format. The format is defined by - Java Regulation Expression "[^\\\\]?(\".*?[^\\\\]\")[ \t,]+".

- -

For example:

- -
-        "/nologo", "/W3", "/WX"
-        "/C", "/DSTRING_DEFINES_FILE=\"BdsStrDefs.h\""
-      
- - @param add the add flags set - @param sub the sub flags set - @return flags with original format - **/ - private String getRawFlags(Set add, Set sub) { - String result = null; - add.removeAll(sub); - Iterator iter = add.iterator(); - while (iter.hasNext()) { - String str = (String) iter.next(); - result += "\"" + str.substring(1, str.length() - 1) + "\", "; - } - return result; - } - - private String parseOptionString(String optionString, Set addSet, Set subSet) { - boolean overrideOption = false; - Pattern pattern = Pattern.compile("ADD\\.\\[(.+)\\]"); - Matcher matcher = pattern.matcher(optionString); - - while (matcher.find()) { - overrideOption = true; - String addOption = optionString.substring(matcher.start(1), matcher.end(1)).trim(); - putFlagsToSet(addSet, addOption); - - } - - pattern = Pattern.compile("SUB\\.\\[(.+)\\]"); - matcher = pattern.matcher(optionString); - - while (matcher.find()) { - overrideOption = true; - String subOption = optionString.substring(matcher.start(1), matcher.end(1)).trim(); - putFlagsToSet(subSet, subOption); - } - - if (overrideOption == true) { - return null; - } - - return optionString; - } - private void pushProperties() { backupPropertiesStack.push(getProject().getProperties()); } - + private void popProperties() { Hashtable backupProperties = backupPropertiesStack.pop(); Set keys = backupProperties.keySet();