Change to new XML Schema.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@682 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
wuyizhong 2006-06-30 17:57:58 +00:00
parent 5fc17c922b
commit 509693ccfd
5 changed files with 228 additions and 917 deletions

View File

@ -1,19 +1,3 @@
package net.sf.antcontrib.cpptasks.userdefine;
import java.io.File;
import java.util.Iterator;
import java.util.StringTokenizer;
import java.util.Vector;
import net.sf.antcontrib.cpptasks.CCTask;
import net.sf.antcontrib.cpptasks.CUtil;
import net.sf.antcontrib.cpptasks.types.CommandLineArgument;
import net.sf.antcontrib.cpptasks.types.ConditionalFileSet;
import net.sf.antcontrib.cpptasks.types.LibrarySet;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
/*
*
* Copyright 2001-2004 The Ant-Contrib project
@ -30,30 +14,32 @@ import org.apache.tools.ant.Project;
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.sf.antcontrib.cpptasks.userdefine;
import java.io.File;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.Vector;
import net.sf.antcontrib.cpptasks.CCTask;
import net.sf.antcontrib.cpptasks.CUtil;
import net.sf.antcontrib.cpptasks.types.CommandLineArgument;
import net.sf.antcontrib.cpptasks.types.ConditionalFileSet;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
public class CommandLineUserDefine {
String command;
/*
* The follows variable set at child class.
*/
String includeFileFlag = null;
String entryPointFlag = null;
String subSystemFlag = null;
String mapFlag = null;
String pdbFlag = null;
String outputFileFlag = null;
String includePathDelimiter = null;
/*
* get lib string if Vendor = "gcc", it should respectively aadd "-(" and ")-"
* at library set before and end. This value set at userDefineCompiler class.
*/
Vector<String> libSetList = new Vector<String>();
Vector<String> fileList = new Vector<String>();
String outputDelimiter = null;
public void command(CCTask cctask, UserDefineDef userdefine){
File workdir;
File outdir;
Project project = cctask.getProject();
if(userdefine.getWorkdir() == null) {
workdir = new File(".");
@ -62,32 +48,26 @@ public class CommandLineUserDefine {
workdir = userdefine.getWorkdir();
}
/*
* generate cmdline= command + args + includepath + endargs + outfile
*/
//
// generate cmdline= command + args + includepath + endargs + outfile
//
Vector args = new Vector();
Vector argsWithoutSpace = new Vector();
Vector endargs = new Vector();
Vector endargsWithoutSpace = new Vector();
Vector includePath = new Vector();
/*
* Generate cmdline = command +
* general args +
* outputflag + outputfile
* subsystemFlag + subsystemValue +
* includeFlag + includeFile +
* includeFileincludpath +
* entryPointFlag + entryPointValue +
* mapFlag + mapValue +
* pdbFlag + pdbValue +
* endargs +
*
*
*/
/*
* get Args.
*/
//
// Generate cmdline = command +
// general args +
// outputflag + outputfile
// includpath +
// endargs +
//
//
// get Args.
//
CommandLineArgument[] argument = userdefine.getActiveProcessorArgs();
for (int j = 0; j < argument.length; j++) {
if (argument[j].getLocation() == 0) {
@ -96,9 +76,10 @@ public class CommandLineUserDefine {
endargs.addElement(argument[j].getValue());
}
}
/*
* get include path.
*/
//
// get include path.
//
String[] incPath = userdefine.getActiveIncludePaths();
for (int j = 0; j < incPath.length; j++) {
if(incPath[j].indexOf(' ') >= 0) {
@ -109,170 +90,58 @@ public class CommandLineUserDefine {
includePath.addElement( includePathDelimiter + incPath[j]);
}
}
/*
* Remove space in args and endargs.
*/
//
// Remove space in args and endargs.
//
for ( int i=0; i < args.size(); i++) {
String str = (String)args.get(i);
StringTokenizer st = new StringTokenizer(str);
StringTokenizer st = new StringTokenizer(str, " \t");
while(st.hasMoreTokens()) {
argsWithoutSpace.addElement(st.nextToken());
}
}
for ( int i=0; i < endargs.size(); i++) {
String str = (String)endargs.get(i);
StringTokenizer st = new StringTokenizer(str);
StringTokenizer st = new StringTokenizer(str, " \t");
while(st.hasMoreTokens()) {
endargsWithoutSpace.addElement(st.nextToken());
}
}
int cmdLen = 0;
if(userdefine.getOutdir() == null) {
outdir = new File(".");
/*
* command + args + endargs + includepath + sourcefile
*/
cmdLen = 1 + argsWithoutSpace.size() + endargsWithoutSpace.size() + includePath.size() + 1;
//
// command + args + endargs + includepath + sourcefile
//
cmdLen = 1 + argsWithoutSpace.size() + endargsWithoutSpace.size() + includePath.size() + 1;
String[] libSet = userdefine.get_libset();
if (libSet != null && libSet.length > 0){
cmdLen = cmdLen + libSet.length;
}
else {
outdir = userdefine.getOutdir();
/*
* command + args + endargs + includepath + sourcefile + outfile
*/
cmdLen = 1 + argsWithoutSpace.size() + endargsWithoutSpace.size() + includePath.size() + 2;
}
if (includeFileFlag != null && includeFileFlag.trim().length() > 0){
cmdLen++;
}
if (entryPointFlag != null && entryPointFlag.trim().length() > 0){
cmdLen++;
}
if (subSystemFlag != null && subSystemFlag.trim().length() > 0){
cmdLen++;
}
if (mapFlag != null && mapFlag.trim().length() > 0){
cmdLen++;
}
if (pdbFlag != null && pdbFlag.trim().length() > 0){
cmdLen++;
}
if (libSetList != null && libSetList.size() > 0){
cmdLen = cmdLen + libSetList.size();
}
if (fileList != null){
cmdLen = cmdLen + fileList.size();
}
/*
* In gcc the "cr" flag should follow space then add outputfile name, otherwise
* it will pop error.
*/
if (outputFileFlag != null && outputFileFlag.trim().length() > 0){
if (outputFileFlag.trim().equalsIgnoreCase("-cr")){
//
// In gcc the "cr" flag should follow space then add outputfile name, otherwise
// it will pop error.
// TBD
if (outputDelimiter != null && userdefine.getOutputFile() != null && outputDelimiter.trim().length() > 0){
if (outputDelimiter.trim().equalsIgnoreCase("-cr")){
cmdLen = cmdLen + 2;
}else {
cmdLen++;
}
}
/*
* for every source file
* if file is header file, just skip it (add later)
*/
//
// for every source file
// if file is header file, just skip it (add later)
//
Vector srcSets = userdefine.getSrcSets();
if (srcSets.size() == 0) {
String[] cmd = new String[cmdLen - 1];
int index = 0;
cmd[index++] = this.command;
Iterator iter = argsWithoutSpace.iterator();
while (iter.hasNext()) {
cmd[index++] = project.replaceProperties((String)iter.next());
//cmd[index++] = (String)iter.next();
}
iter = endargsWithoutSpace.iterator();
while (iter.hasNext()) {
cmd[index++] = (String)iter.next();
}
/*
* "OutputFlag + outputFile" as first option follow command.exe.
*/
if (outputFileFlag != null && outputFileFlag.trim().length() > 0){
if (outputFileFlag.trim().equalsIgnoreCase("-cr")){
cmd[index++] = outputFileFlag;
cmd[index++] = userdefine.getOutputFile();
}else {
cmd[index++] = outputFileFlag + userdefine.getOutputFile();
}
}
/*
* Add fileList to cmd
*/
if (fileList != null && fileList.size()> 0){
for (int i = 0; i < fileList.size(); i++){
cmd[index++] = fileList.get(i);
}
}
if (subSystemFlag != null && subSystemFlag.trim().length() > 0){
cmd[index++] = subSystemFlag + userdefine.getSubSystemvalue();
}
if (includeFileFlag != null && includeFileFlag.trim().length() > 0){
cmd[index++] = includeFileFlag + userdefine.getIncludeFile();
}
iter = includePath.iterator();
while (iter.hasNext()) {
cmd[index++] = (String)iter.next();
}
if (entryPointFlag != null && entryPointFlag.trim().length() > 0){
//
// If GCC link use __ModuleEntrypoint instead of _ModuleEntryPoint;
//
if (entryPointFlag.equalsIgnoreCase("-e")){
cmd[index++] = entryPointFlag + "_" + userdefine.getEntryPointvalue();
} else {
cmd[index++] = entryPointFlag + userdefine.getEntryPointvalue();
}
}
if (mapFlag != null && mapFlag.trim().length() > 0){
cmd[index++] = mapFlag + userdefine.getMapvalue();
}
if (pdbFlag != null && pdbFlag.trim().length() > 0){
cmd[index++] = pdbFlag + userdefine.getPdbvalue();
}
if (userdefine.getOutdir() != null){
// will add code to generate outfile name and flag
cmd[index++] = "/nologo";
}
if (libSetList != null && libSetList.size() > 0){
for (int i = 0; i < libSetList.size(); i++){
cmd[index++] = libSetList.get(i);
}
}
// execute the command
int retval = runCommand(cctask, workdir, cmd);
// if with monitor, add more code
if (retval != 0) {
throw new BuildException(this.command
+ " failed with return code " + retval,
cctask.getLocation());
}
}
// System.out.println("##" + userdefine.getSrcSets());
//
// if have source file append source file in command land.
//
Set allSrcFiles = new LinkedHashSet();
for (int i = 0; i < srcSets.size(); i++) {
ConditionalFileSet srcSet = (ConditionalFileSet) srcSets
.elementAt(i);
@ -282,88 +151,61 @@ public class CommandLineUserDefine {
// Check each source file - see if it needs compilation
String[] fileNames = scanner.getIncludedFiles();
for (int j = 0; j < fileNames.length; j++){
String[] cmd = new String[cmdLen];
int index = 0;
cmd[index++] = this.command;
Iterator iter = argsWithoutSpace.iterator();
while (iter.hasNext()) {
cmd[index++] = (String)iter.next();
}
iter = endargsWithoutSpace.iterator();
while (iter.hasNext()) {
cmd[index++] = (String)iter.next();
}
/*
* Add outputFileFlag and output file to cmd
*/
if (outputFileFlag != null && outputFileFlag.length()> 0){
if (outputFileFlag.trim().equalsIgnoreCase("-cr")){
cmd[index++] = outputFileFlag;
cmd[index++] = userdefine.getOutputFile();
}else {
cmd[index++] = outputFileFlag + userdefine.getOutputFile();
}
}
/*
* Add fileList to cmd
*/
if (fileList != null && fileList.size()> 0){
for (int s = 0; s < fileList.size(); s++){
cmd[index++] = fileList.get(s);
}
}
if (subSystemFlag != null && subSystemFlag.length()> 0){
cmd[index++] = subSystemFlag + userdefine.getSubSystemvalue();
}
if (includeFileFlag != null && includeFileFlag.length()> 0){
cmd[index++] = includeFileFlag + userdefine.getIncludeFile();
}
iter = includePath.iterator();
while (iter.hasNext()) {
cmd[index++] = (String)iter.next();
}
if (userdefine.getOutdir() != null){
// will add code to generate outfile name and flag
cmd[index++] = "/nologo";
}
if (entryPointFlag != null && entryPointFlag.length()> 0){
cmd[index++] = entryPointFlag + userdefine.getEntryPointvalue();
}
if (mapFlag != null && mapFlag.length() > 0){
cmd[index++] = mapFlag + userdefine.getMapvalue();
}
if (pdbFlag != null && pdbFlag.length() > 0){
cmd[index++] = pdbFlag + userdefine.getPdbvalue();
}
if (libSetList != null && libSetList.size() > 0){
for (int k = 0; k < libSetList.size(); k++){
cmd[index++] = libSetList.get(k);
}
}
// execute the command
cmd[index++] = scanner.getBasedir() + "/" + fileNames[j];
for (int k = 0; k < cmd.length; k++){
}
int retval = runCommand(cctask, workdir, cmd);
// if with monitor, add more code
if (retval != 0) {
throw new BuildException(this.command
+ " failed with return code " + retval,
cctask.getLocation());
}
allSrcFiles.add(scanner.getBasedir() + "/" + fileNames[j]);
}
}
}
String[] fileNames = (String[])allSrcFiles.toArray(new String[allSrcFiles.size()]);
String[] cmd = new String[cmdLen - 1 + fileNames.length];
int index = 0;
cmd[index++] = userdefine.getCmd();
Iterator iter = argsWithoutSpace.iterator();
while (iter.hasNext()) {
cmd[index++] = project.replaceProperties((String)iter.next());
}
iter = endargsWithoutSpace.iterator();
while (iter.hasNext()) {
cmd[index++] = project.replaceProperties((String)iter.next());
}
//
// Add outputFileFlag and output file to cmd
//
if (outputDelimiter != null && userdefine.getOutputFile() != null && outputDelimiter.length()> 0){
if (outputDelimiter.trim().equalsIgnoreCase("-cr")){
cmd[index++] = outputDelimiter;
cmd[index++] = userdefine.getOutputFile();
}else {
cmd[index++] = outputDelimiter + userdefine.getOutputFile();
}
}
iter = includePath.iterator();
while (iter.hasNext()) {
cmd[index++] = (String)iter.next();
}
if (libSet != null && libSet.length > 0){
for (int k = 0; k < libSet.length ; k++){
cmd[index++] = libSet[k];
}
}
for (int j = 0; j < fileNames.length; j++){
// execute the command
cmd[index++] = fileNames[j];
}
int retval = runCommand(cctask, workdir, cmd);
// if with monitor, add more code
if (retval != 0) {
throw new BuildException(userdefine.getCmd()
+ " failed with return code " + retval,
cctask.getLocation());
}
}
protected int runCommand(CCTask task, File workingDir, String[] cmdline)

View File

@ -27,5 +27,4 @@ public class UserDefineArgument extends CommandLineArgument {
throw new org.apache.tools.ant.BuildException(
"Not an actual task, but looks like one for documentation purposes");
}
}

View File

@ -16,204 +16,26 @@
*/
package net.sf.antcontrib.cpptasks.userdefine;
import org.apache.tools.ant.Project;
import net.sf.antcontrib.cpptasks.CCTask;
import org.tianocore.build.toolchain.*;
public class UserDefineCompiler extends CommandLineUserDefine {
public UserDefineCompiler(CCTask cctask, UserDefineDef userdefineDef) {
String arch = null;
String os = null;
String vendor = null;
String commandType = null;
Project project = cctask.getProject();
// get command string
if (cctask.getArch() == null) {
arch = project.getProperty("ARCH");
if (arch == null) {
arch = System.getProperty("os.arch");
}
String cmdType = userdefineDef.getType();
String toolchainFamily = userdefineDef.getFamily();
UserDefineMapping mapping = new UserDefineMapping();
if (userdefineDef.getIncludepathDelimiter() == null) {
includePathDelimiter = mapping.getIncludePathDelimiter(toolchainFamily, cmdType);
} else {
arch = cctask.getArch();
}
arch = arch.toUpperCase();
if (cctask.getOs() == null) {
os = project.getProperty("OS");
if (os == null) {
os = System.getProperty("os.name");
}
} else {
os = cctask.getOs();
}
commandType = userdefineDef.getType();
if (commandType != null) {
if (ToolChainFactory.getValue(arch + "_" + commandType + "_VENDOR") != null
&& ToolChainFactory.getValue(
arch + "_" + commandType + "_VENDOR").trim()
.length() > 0) {
vendor = ToolChainFactory.getValue(arch + "_" + commandType
+ "_VENDOR");
} else if (ToolChainFactory.getValue(arch + "_VENDOR") != null) {
vendor = ToolChainFactory.getValue(arch + "_VENDOR");
}
}
// look if ARCH_VENDOR_OS_COMMANDTYPE is existed
if (arch != null && vendor != null && os != null && commandType != null) {
command = project.getProperty(arch + "_" + vendor + "_" + os + "_"
+ commandType);
}
// look if ARCH_VENDOR_COMMANDTYPE is existed
if (command == null) {
if (arch != null && vendor != null && commandType != null) {
command = project.getProperty(arch + "_" + vendor + "_"
+ commandType);
}
}
// look if ARCH_COMMANDTYPE is existed
if (command == null) {
if (arch != null && commandType != null) {
command = project.getProperty(arch + "_" + commandType);
}
}
// look if COMMANDTYPE is existed
if (command == null) {
if (commandType != null) {
command = project.getProperty(commandType);
}
}
// using the default value from VENDOR_OS_COMMANDTYPE or
// VENDOR_COMMANDTYPE
if (command == null) {
if (vendor != null && os != null && commandType != null) {
String str = vendor + "_" + os + "_" + commandType;
command = UserDefineMapping.getDefaultCommand(str);
}
}
// VENDOR_COMMANDTYPE
if (command == null) {
if (vendor != null && commandType != null) {
String str = vendor + "_" + commandType;
command = UserDefineMapping.getDefaultCommand(str);
}
}
// just give the name whatever
if (command == null) {
command = "cl";
}
// initialize the includePathDelimiter
if (userdefineDef.getIncludepathDelimiter() != null) {
includePathDelimiter = userdefineDef.getIncludepathDelimiter();
}
// else find VENDOR
else {
if (vendor != null) {
includePathDelimiter = UserDefineMapping
.getIncludePathDelimiter(vendor, commandType);
}
}
if (includePathDelimiter == null) {
includePathDelimiter = "-I";
}
/*
* Set libSet.
*/
if (userdefineDef.getLibSet() != null
&& userdefineDef.getLibSet().size() > 0) {
String[] libList;
if (vendor.equalsIgnoreCase("GCC")) {
libSetList.add("-(");
for (int i = 0; i < userdefineDef.getLibSet().size(); i++) {
libList = userdefineDef.getLibSet().get(i).getLibs();
for (int j = 0; j < libList.length; j++) {
libSetList.add(libList[j]);
}
}
libSetList.add("-)");
} else {
for (int i = 0; i < userdefineDef.getLibSet().size(); i++) {
libList = userdefineDef.getLibSet().get(i).getLibs();
for (int j = 0; j < libList.length; j++) {
libSetList.add(libList[j]);
}
}
}
}
/*
* set includeFileFlag
*/
if (userdefineDef.getIncludeFile() != null) {
if (userdefineDef.getIncludeFileFlag() != null) {
includeFileFlag = userdefineDef.getIncludeFileFlag();
} else {
includeFileFlag = UserDefineMapping.getCompellingIncFileFlag(
vendor, commandType);
}
}
/*
* set entryPointFlag
*/
if (userdefineDef.getEntryPointvalue() != null) {
if (userdefineDef.getEntryPointFlag() != null) {
entryPointFlag = userdefineDef.getEntryPointFlag();
} else {
entryPointFlag = UserDefineMapping.getEntryPointFlag(vendor,
commandType);
}
}
/*
* set subSystemFlag
*/
if (userdefineDef.getSubSystemvalue() != null) {
if (userdefineDef.getSubSystemFlag() != null) {
subSystemFlag = userdefineDef.getSubSystemFlag();
} else {
subSystemFlag = UserDefineMapping.getSubSystemFlag(vendor,
commandType);
}
}
/*
* set mapFlag
*/
if (userdefineDef.getMapvalue() != null) {
if (userdefineDef.getMapFlag() != null) {
mapFlag = userdefineDef.getMapFlag();
} else {
mapFlag = UserDefineMapping.getMapFlag(vendor, commandType);
}
}
/*
* set pdbFlag
*/
if (userdefineDef.getPdbvalue() != null) {
if (userdefineDef.getPdbFlag() != null) {
pdbFlag = userdefineDef.getPdbFlag();
} else {
pdbFlag = UserDefineMapping.getPdbFlag(vendor, commandType);
}
}
/*
* set outputFileFlag
*/
if (userdefineDef.getOutputFile() != null) {
if (userdefineDef.getOutPutFlag() != null) {
outputFileFlag = userdefineDef.getOutPutFlag();
} else {
outputFileFlag = UserDefineMapping.getOutputFileFlag(vendor,
arch, commandType);
}
}
/*
* set fileList
*/
if (userdefineDef.getFileList() != null) {
fileList = userdefineDef.getFileList();
if (userdefineDef.getOutputDelimiter() == null) {
outputDelimiter = mapping.getOutputFileFlag(toolchainFamily, cmdType);
} else {
outputDelimiter = userdefineDef.getOutputDelimiter();
}
}
}

View File

@ -19,17 +19,15 @@ package net.sf.antcontrib.cpptasks.userdefine;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.FileList;
import org.apache.tools.ant.types.FileSet;
import sun.nio.cs.ext.TIS_620;
import net.sf.antcontrib.cpptasks.ProcessorDef;
import net.sf.antcontrib.cpptasks.types.AslcompilerArgument;
import net.sf.antcontrib.cpptasks.types.ConditionalPath;
import net.sf.antcontrib.cpptasks.types.IncludePath;
import net.sf.antcontrib.cpptasks.types.LibrarySet;
@ -39,31 +37,33 @@ public class UserDefineDef extends ProcessorDef{
public UserDefineDef () {}
private String type = "CC";
private String family = "MSFT";
private String cmd;
private String includepathDelimiter;
private File outdir;
private String outputDelimiter;
private File workdir;
private String inputSuffix;
private String outputSuffix;
private Vector<IncludePath> includePaths= new Vector<IncludePath>();
private Vector<FileList> fileSetList = new Vector<FileList>();
private Vector includePaths= new Vector();
/**
* New adding for support GCC toolchain.
* Most of those only have one value for example :
* entryPoint, mapFile, pdbFile, define those as element because
* if attribut too much the command line is not good-lookinng.
*/
private String outputFile;
private Vector<UserDefineElement> includeFiles = new Vector<UserDefineElement>();
private Vector<UserDefineElement> outPutFiles = new Vector<UserDefineElement>();
private Vector<UserDefineElement> subSystem = new Vector<UserDefineElement>();
private Vector<UserDefineElement> entryPoint = new Vector<UserDefineElement>();
private Vector<UserDefineElement> map = new Vector<UserDefineElement>();
private Vector<UserDefineElement> pdb = new Vector<UserDefineElement>();
private Vector<LibrarySet> libSet = new Vector<LibrarySet>();
private Vector _libset = new Vector();
public void addLibset(LibrarySet libset) {
if (isReference()) {
throw noChildrenAllowed();
}
if (libset == null) {
throw new NullPointerException("libset");
}
_libset.add(libset);
}
public void execute() throws org.apache.tools.ant.BuildException {
throw new org.apache.tools.ant.BuildException(
@ -173,51 +173,6 @@ public class UserDefineDef extends ProcessorDef{
this.includepathDelimiter = includepathDelimiter;
}
public String getInputSuffix() {
if (isReference()) {
return ((UserDefineDef) getCheckedRef(UserDefineDef.class,
"UserDefineDef")).getInputSuffix();
}
return inputSuffix;
}
public void setInputSuffix(String inputSuffix) {
if (isReference()) {
throw tooManyAttributes();
}
this.inputSuffix = inputSuffix;
}
public File getOutdir() {
if (isReference()) {
return ((UserDefineDef) getCheckedRef(UserDefineDef.class,
"UserDefineDef")).getOutdir();
}
return outdir;
}
public void setOutdir(File outdir) {
if (isReference()) {
throw tooManyAttributes();
}
this.outdir = outdir;
}
public String getOutputSuffix() {
if (isReference()) {
return ((UserDefineDef) getCheckedRef(UserDefineDef.class,
"UserDefineDef")).getOutputSuffix();
}
return outputSuffix;
}
public void setOutputSuffix(String outputSuffix) {
if (isReference()) {
throw tooManyAttributes();
}
this.outputSuffix = outputSuffix;
}
public String getType() {
if (isReference()) {
return ((UserDefineDef) getCheckedRef(UserDefineDef.class,
@ -233,11 +188,40 @@ public class UserDefineDef extends ProcessorDef{
this.type = type;
}
public File getWorkdir() {
public String getCmd() {
return cmd;
}
public void setCmd(String cmd) {
if (isReference()) {
return ((UserDefineDef) getCheckedRef(UserDefineDef.class,
"UserDefineDef")).getWorkdir();
throw tooManyAttributes();
}
this.cmd = cmd;
}
public String getFamily() {
return family;
}
public void setFamily(String family) {
if (isReference()) {
throw tooManyAttributes();
}
this.family = family;
}
public String getOutputFile() {
return outputFile;
}
public void setOutputFile(String outputFile) {
if (isReference()) {
throw tooManyAttributes();
}
this.outputFile = outputFile;
}
public File getWorkdir() {
return workdir;
}
@ -247,251 +231,38 @@ public class UserDefineDef extends ProcessorDef{
}
this.workdir = workdir;
}
/**
* Add an libSet.
*/
public LibrarySet createLibset() {
if (isReference()){
throw noChildrenAllowed();
}
LibrarySet lib = new LibrarySet();
libSet.addElement(lib);
return lib;
}
public String getLibSetString(){
String libString = null;
for (int i = 0; i < libSet.size(); i++){
String[] libList = libSet.get(i).getLibs();
for (int j = 0; j < libList.length; j++){
libString = libString + libList[j] + " ";
public String[] get_libset() {
Set libs = new LinkedHashSet();
Iterator iter = _libset.iterator();
while (iter.hasNext()) {
LibrarySet librarySet = (LibrarySet)iter.next();
File basedir = librarySet.getDir(getProject());
String[] libStrArray = librarySet.getLibs();
for (int i = 0 ; i < libStrArray.length; i ++) {
if (basedir != null) {
File libFile = new File(libStrArray[i]);
if (libFile.isAbsolute()) {
libs.add(libFile.getPath());
}
else {
libs.add(basedir.getPath() + File.separatorChar + libFile.getPath());
}
}
else {
libs.add(libStrArray[i]);
}
}
}
return libString;
return (String[])libs.toArray(new String[libs.size()]);
}
public Vector<LibrarySet> getLibSet(){
return this.libSet;
public String getOutputDelimiter() {
return outputDelimiter;
}
/**
* Add map element
*/
public void addMap(UserDefineElement mapElement){
if (isReference()){
throw noChildrenAllowed();
}else{
this.map.addElement(mapElement);
}
}
public Vector<UserDefineElement> getMap (){
return this.map;
}
public String getMapvalue (){
if (this.map.size() > 0){
/*
* If user set more than one map use the first one.
*/
return this.map.get(0).value;
}
return null;
}
public String getMapFlag(){
if (this.map.size() > 0){
/*
* If user set more than one map use the first one.
*/
return this.map.get(0).flag;
}
return null;
}
/**
* Add pdb element
*/
public void addPdb(UserDefineElement pdbElement){
if (isReference()){
throw noChildrenAllowed();
}
this.pdb.addElement(pdbElement);
}
public Vector<UserDefineElement> getPdb(){
return this.pdb;
}
public String getPdbvalue (){
if (this.pdb.size() > 0){
/*
* If user set more than one pdb use the first one.
*
*/
return this.pdb.get(0).value;
}
return null;
}
public String getPdbFlag(){
if (this.pdb.size() > 0){
/*
* If user set more than one pdb use the first one.
*/
return this.pdb.get(0).flag;
}
return null;
}
/**
* add entryPoint element.
*/
public void addEntryPoint(UserDefineElement entryPointElement){
if (isReference()){
throw noChildrenAllowed();
}
this.entryPoint.addElement(entryPointElement);
}
public Vector<UserDefineElement> getEntryPoint(){
return this.entryPoint;
}
public String getEntryPointvalue (){
if (this.entryPoint.size() > 0){
/*
* If user set more than one entryPoint use the first one.
*/
return this.entryPoint.get(0).value;
}
return null;
}
public String getEntryPointFlag(){
if (this.entryPoint.size() > 0){
/*
* If user set more than one entry point use the first one.
*/
return this.entryPoint.get(0).flag;
}
return null;
}
/**
* Add subSystem element.
*/
public void addSubSystem (UserDefineElement subSystem){
if (isReference()){
throw noChildrenAllowed();
}
this.subSystem.addElement(subSystem);
}
public Vector<UserDefineElement> getSubSystem (){
return this.subSystem;
}
public String getSubSystemvalue (){
if (this.subSystem.size() > 0){
/*
* If user set more than one subsystem use the first one.
*/
return this.subSystem.get(0).value;
}
return null;
}
public String getSubSystemFlag(){
if (this.subSystem.size() > 0){
/*
* If user set more than one subsystem use the first one.
*/
return this.subSystem.get(0).flag;
}
return null;
}
/**
* Add includeFile element
*/
public void addIncludeFile (UserDefineElement includeFile){
if (isReference()){
throw noChildrenAllowed();
}
this.includeFiles.addElement(includeFile);
}
public Vector<UserDefineElement> getIncludeFiles(){
return this.includeFiles;
}
public String getIncludeFile (){
if (this.includeFiles.size() > 0){
/*
* If user set more than one map use the first one.
*/
return this.includeFiles.get(0).value;
}
return null;
}
public String getIncludeFileFlag(){
if (this.includeFiles.size() > 0){
/*
* If user set more than one map use the first one.
*/
return this.includeFiles.get(0).flag;
}
return null;
}
/**
* Add OutputFile element
*/
public void addOutputFile (UserDefineElement outPutFile){
if (isReference()){
throw noChildrenAllowed();
}
this.outPutFiles.addElement(outPutFile);
}
public Vector<UserDefineElement> getOutputFiles(){
return this.outPutFiles;
}
public String getOutputFile (){
if (this.outPutFiles.size() > 0){
/*
* If user set more than one map use the first one.
*/
return this.outPutFiles.get(0).value;
}
return null;
}
public String getOutPutFlag(){
if (this.outPutFiles.size() > 0){
/*
* If user set more than one map use the first one.
*/
return this.outPutFiles.get(0).flag;
}
return null;
}
/**
* Add fileSet list
*/
public void addFileList(FileList fileSet){
this.fileSetList.addElement(fileSet);
}
public Vector<String> getFileList(){
Project p = getProject();
Vector<String> fileListVector = new Vector<String>();
for (int i = 0; i < this.fileSetList.size(); i++){
String[] tempStrList = this.fileSetList.get(i).getFiles(p);
for (int j = 0; j < tempStrList.length; j++){
fileListVector .addElement(tempStrList[j]);
}
}
return fileListVector;
public void setOutputDelimiter(String outputDelimiter) {
this.outputDelimiter = outputDelimiter;
}
}

View File

@ -16,71 +16,30 @@
*/
package net.sf.antcontrib.cpptasks.userdefine;
public class UserDefineMapping {
// list of Arch: EBC, ARM, IA32, X64, IPF, PPC, NT32
public final static String[] arch = { "EBC", "ARM", "IA32", "X64", "IPF",
"PPC", "NT32" };
// list of OS: Linux, Windows
public final static String[] os = { "WINDOWS", "LINUX" };
// list of Vendor: Microsoft, Intel, Cygwin, Gcc
public final static String[] vendor = { "MSFT", "INTEL", "GCC", "CYGWIN" };
// list of Vendor: Microsoft, Intel, Gcc
public final String[] families = { "MSFT", "INTEL", "GCC"};
// list of Command Type: CC, LIB, LINK, ASL, ASM, ASMLINK
public final static String[] commandType = { "CC", "LIB", "LINK", "ASL",
// list of Command Type: CC, SLINK, DLINK, ASL, ASM, ASMLINK, PP
public final String[] commandType = { "CC", "SLINK", "DLINK", "ASL",
"ASM", "ASMLINK", "PP" };
//
// flags mapping (Include compellingIncFileFlag,Path Delimiter, Output file
// flag,
// includepathfalge,
// )
// Examples: '/I' for MSFT cl.exe while '-I' for GCC
// '/Fo' for MSFT cl.exe while '-o' for GCC
//
public final static String[][] compellingIncFileFlag = {
{ "MSFT_CC", "/FI" }, { "GCC_CC", "-include" },
{ "INTEL_CC", "-FI" }, { "WINDDK_CC", "/FI" },
{ "MSFT_ASM", "/FI" }, { "GCC_ASM", "-include" },
{ "WINDDK_ASM", "/FI" } };
public final static String[][] includePathFlag = { { "MSFT_CC", "/I" },
public final String[][] includePathFlag = { { "MSFT_CC", "/I" },
{ "GCC_CC", "-I" }, { "INTEL_CC", "/I" }, { "WINDDK_CC", "/I" },
{ "MSFT_ASM", "/I" }, { "GCC_ASM", "-I" }, { "WINDDK_CC", "/I" },
{ "MSFT_PP", "/I" }, { "GCC_PP", "-I" }, { "WINDDK_PP", "/I" } };
public final static String[][] outputFileFlag = { { "MSFT_CC", "/Fo" },
public final String[][] outputFileFlag = { { "MSFT_CC", "/Fo" },
{ "GCC_CC", "-o" }, { "INTEL_CC", "/Fo" }, { "WINDDK_CC", "/Fo" },
{ "MSFT_LIB", "/OUT:" }, { "GCC_LIB", "-cr" },
{ "INTEL_LIB", "/OUT:" }, { "WINDDK_LIB", "/OUT:" },
{ "MSFT_LINK", "/OUT:" }, { "GCC_LINK", "-o" },
{ "INTEL_LINK", "/OUT:" }, { "WINDDK_LINK", "/OUT:" },
{ "MSFT_SLINK", "/OUT:" }, { "GCC_SLINK", "-cr" },
{ "INTEL_SLINK", "/OUT:" }, { "WINDDK_SLINK", "/OUT:" },
{ "MSFT_DLINK", "/OUT:" }, { "GCC_DLINK", "-o" },
{ "INTEL_DLINK", "/OUT:" }, { "WINDDK_DLINK", "/OUT:" },
{ "MSFT_ASM", "/Fo" }, { "GCC_ASM", "-o" },
{ "WINDDK_ASM", "/Fo" },{"WINDDK_IPF_ASM", "-o"} };
public final static String[][] subSystemFlag = {
{ "MSFT_LIB", "/SUBSYSTEM:" }, { "GCC_LIB", "--subsystem=" },
{ "WINDDk_LIB", "/SUBSYSTEM:" }, { "INTEL_LIB", "/SUBSYSTEM:" },
{ "MSFT_LINK", "/SUBSYSTEM:" }, { "GCC_LINK", "--subsystem=" },
{ "INTEL_LINK", "/SUBSYSTEM:" }, { "WINDDK_LINK", "/SUBSYSTEM:" } };
public final static String[][] outputFileSuffix = {
{ "WINDOWS_ASM", ".obj" }, { "WINDOWS_CC", ".obj" },
{ "LINUX_ASM", ".o" }, { "LINUX_CC", ".o" } };
public final static String[][] entryPointFlag = {
{ "MSFT_LINK", "/ENTRY:" }, { "GCC_LINK", "-e" },
{ "INTEL_LINK", "/ENTRY:" },
{ "WINDDK_LINK", "/ENTRY:" } };
public final static String[][] mapFlag = { { "MSFT_LINK", "/MAP:" },
{ "GCC_LINK", "" }, { "INTEL_LINK", "/MAP:" },
{ "WINDDK_LINK", "/MAP:" } };
public final static String[][] pdbFlag = { { "MSFT_LINK", "/PDB:" },
{ "GCC_LINK", "" }, { "INTEL_LINK", "" }, { "WINDDK_LINK", "/PDB:"} };
public static String getIncludePathDelimiter(String vendor,
public String getIncludePathDelimiter(String vendor,
String commandType) {
String key = vendor + "_" + commandType;
for (int i = 0; i < includePathFlag.length; i++) {
@ -88,99 +47,17 @@ public class UserDefineMapping {
return includePathFlag[i][1];
}
}
return null;
return "/I";
}
public static String getOutputFileFlag(String vendor, String arch, String commandType) {
/*
* First find outputfileFlag by vendor_arch_commandType
*/
String key = vendor + "_" + arch + "_" + commandType;
public String getOutputFileFlag(String vendor, String commandType) {
String key = vendor + "_" + commandType;
for (int i = 0; i < outputFileFlag.length; i++) {
if (outputFileFlag[i][0].equalsIgnoreCase(key)) {
return outputFileFlag[i][1];
}
}
key = vendor + "_" + commandType;
for (int i = 0; i < outputFileFlag.length; i++) {
if (outputFileFlag[i][0].equalsIgnoreCase(key)) {
return outputFileFlag[i][1];
}
}
return null;
}
public static String getCompellingIncFileFlag(String vendor,
String commandType) {
String key = vendor + "_" + commandType;
for (int i = 0; i < compellingIncFileFlag.length; i++) {
if (compellingIncFileFlag[i][0].equalsIgnoreCase(key)) {
return compellingIncFileFlag[i][1];
}
}
return null;
}
public static String getSubSystemFlag(String vendor, String commandType) {
String key = vendor + "_" + commandType;
for (int i = 0; i < subSystemFlag.length; i++) {
if (subSystemFlag[i][0].equalsIgnoreCase(key)) {
return subSystemFlag[i][1];
}
}
return null;
}
public static String getEntryPointFlag(String vendor, String commandType) {
String key = vendor + "_" + commandType;
for (int i = 0; i < entryPointFlag.length; i++) {
if (entryPointFlag[i][0].equalsIgnoreCase(key)) {
return entryPointFlag[i][1];
}
}
return null;
}
public static String getMapFlag(String vendor, String commandType) {
String key = vendor + "_" + commandType;
for (int i = 0; i < mapFlag.length; i++) {
if (mapFlag[i][0].equalsIgnoreCase(key)) {
return mapFlag[i][1];
}
}
return null;
}
public static String getPdbFlag(String vendor, String commandType) {
String key = vendor + "_" + commandType;
for (int i = 0; i < pdbFlag.length; i++) {
if (pdbFlag[i][0].equalsIgnoreCase(key)) {
return pdbFlag[i][1];
}
}
return null;
}
//
// Well-known source file suffix and output file suffix relationship
// sourceExtension(Multiple),
// headExtension(Multiple) and outputSuffix(Single)
//
//
// Default command string such as 'cl' in MSFT while 'gcc' in GCC
//
public final static String[][] defaultCommand = { { "GCC", "gcc" },
{ "MSFT_CC", "cl" }, { "MSFT_LIB", "lib" },
{ "MSFT_LINK", "link" }, };
public static String getDefaultCommand(String toolchain) {
for (int i = 0; i < defaultCommand.length; i++) {
if (defaultCommand[i][0].equalsIgnoreCase(toolchain)) {
return defaultCommand[i][1];
}
}
return null;
return "/Fo";
}
}