summaryrefslogtreecommitdiff
path: root/Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine
diff options
context:
space:
mode:
authorlhauch <lhauch@6f19259b-4bc3-4df7-8a09-765794883524>2006-10-05 23:12:07 +0000
committerlhauch <lhauch@6f19259b-4bc3-4df7-8a09-765794883524>2006-10-05 23:12:07 +0000
commitfeccee87a78e68d575dbdf44b34ca0cb5a21ea8d (patch)
treec70bdaea30cf92a8555e1013fc15565138203134 /Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine
parent214b0d1914b48d651b25e58f321ddb77a46903b8 (diff)
downloadedk2-platforms-feccee87a78e68d575dbdf44b34ca0cb5a21ea8d.tar.xz
Restructuring for better separation of Tool packages.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1674 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine')
-rw-r--r--Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/CommandLineUserDefine.java269
-rw-r--r--Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineArgument.java34
-rw-r--r--Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineCompiler.java45
-rw-r--r--Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineDef.java306
-rw-r--r--Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineMapping.java87
5 files changed, 741 insertions, 0 deletions
diff --git a/Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/CommandLineUserDefine.java b/Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/CommandLineUserDefine.java
new file mode 100644
index 0000000000..56e82de188
--- /dev/null
+++ b/Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/CommandLineUserDefine.java
@@ -0,0 +1,269 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * 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.Map;
+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;
+import org.apache.tools.ant.types.Environment;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.Environment.Variable;
+
+/**
+ *
+ */
+public class CommandLineUserDefine {
+
+ String includePathDelimiter = null;
+
+ String outputDelimiter = null;
+
+ private static String pathName = null;
+
+ public void command(CCTask cctask, UserDefineDef userdefine) {
+ boolean isGccCommand = userdefine.getFamily().equalsIgnoreCase("GCC");
+ File workdir;
+ Project project = cctask.getProject();
+ if (userdefine.getWorkdir() == null) {
+ workdir = new File(".");
+ } else {
+ workdir = userdefine.getWorkdir();
+ }
+
+ //
+ // 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();
+
+ //
+ // get Args.
+ //
+ CommandLineArgument[] argument = userdefine.getActiveProcessorArgs();
+ for (int j = 0; j < argument.length; j++) {
+ if (argument[j].getLocation() == 0) {
+ args.addElement(argument[j].getValue());
+ } else {
+ endargs.addElement(argument[j].getValue());
+ }
+ }
+
+ //
+ // get include path.
+ //
+ String[] incPath = userdefine.getActiveIncludePaths();
+ for (int j = 0; j < incPath.length; j++) {
+ includePath.addElement(includePathDelimiter + incPath[j]);
+ }
+
+ //
+ // 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, " \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, " \t");
+ while (st.hasMoreTokens()) {
+ endargsWithoutSpace.addElement(st.nextToken());
+ }
+ }
+
+ int cmdLen = 0;
+ //
+ // command + args + endargs + includepath + sourcefile
+ //
+ cmdLen = 1 + argsWithoutSpace.size() + endargsWithoutSpace.size()
+ + includePath.size() + 1;
+ String[] libSet = userdefine.getLibset();
+ if (libSet != null && libSet.length > 0) {
+ cmdLen = cmdLen + libSet.length;
+ if (isGccCommand) {
+ cmdLen += 2; // we need -( and -) to group libs for GCC
+ }
+ }
+
+ //
+ // 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)
+ //
+ Vector srcSets = userdefine.getSrcSets();
+
+ //
+ // if have source file append source file in command line.
+ //
+ Set allSrcFiles = new LinkedHashSet();
+
+ for (int i = 0; i < srcSets.size(); i++) {
+ ConditionalFileSet srcSet = (ConditionalFileSet) srcSets
+ .elementAt(i);
+ if (srcSet.isActive()) {
+ //
+ // Find matching source files
+ //
+ DirectoryScanner scanner = srcSet.getDirectoryScanner(project);
+ //
+ // Check each source file - see if it needs compilation
+ //
+ String[] fileNames = scanner.getIncludedFiles();
+ for (int j = 0; j < fileNames.length; j++) {
+ allSrcFiles.add(scanner.getBasedir() + "/" + fileNames[j]);
+ if (isGccCommand) {
+ System.out.println("[" + userdefine.getType() + "] "
+ + 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) {
+ if (isGccCommand) {
+ cmd[index++] = "-(";
+ }
+ for (int k = 0; k < libSet.length; k++) {
+ cmd[index++] = libSet[k];
+ }
+ if (isGccCommand) {
+ cmd[index++] = "-)";
+ }
+ }
+ for (int j = 0; j < fileNames.length; j++) {
+ cmd[index++] = fileNames[j];
+ }
+
+// StringBuffer logLine = new StringBuffer();
+// for(int i = 0; i < cmd.length; i++) {
+// logLine.append(cmd[i] + " ");
+// }
+// project.log(logLine.toString(), Project.MSG_VERBOSE);
+
+ int retval = 0;
+
+ if (userdefine.getDpath() == null || userdefine.getDpath().trim().length() == 0) {
+ retval = runCommand(cctask, workdir, cmd, null);
+ } else {
+ String existPath = System.getenv(getPathName());
+ Environment newEnv = new Environment();
+ Variable var = new Variable();
+ var.setKey(getPathName());
+ var.setPath(new Path(project, userdefine.getDpath() + ";" + existPath));
+ newEnv.addVariable(var);
+ retval = runCommand(cctask, workdir, cmd, newEnv);
+ }
+
+
+ if (retval != 0) {
+ throw new BuildException(userdefine.getCmd()
+ + " failed with return code " + retval, cctask
+ .getLocation());
+ }
+ }
+
+ private String getPathName() {
+ if (pathName != null) {
+ return pathName;
+ }
+ Map allEnv = System.getenv();
+ Iterator iter = allEnv.keySet().iterator();
+ while (iter.hasNext()) {
+ String key = (String)iter.next();
+ if(key.equalsIgnoreCase("PATH")) {
+ pathName = key;
+ break ;
+ }
+ }
+ return pathName;
+ }
+
+ protected int runCommand(CCTask task, File workingDir, String[] cmdline, Environment env)
+ throws BuildException {
+ //
+ // Write command to File
+ //
+ return CUtil.runCommand(task, workingDir, cmdline, false, env);
+
+ }
+}
diff --git a/Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineArgument.java b/Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineArgument.java
new file mode 100644
index 0000000000..96d274ad9a
--- /dev/null
+++ b/Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineArgument.java
@@ -0,0 +1,34 @@
+/*
+ *
+ * Copyright 2002-2006 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.userdefine;
+
+import net.sf.antcontrib.cpptasks.types.CommandLineArgument;
+
+/**
+ * Collect Arguments.
+ *
+ */
+public class UserDefineArgument extends CommandLineArgument {
+
+ public UserDefineArgument() {
+ }
+
+ public void execute() throws org.apache.tools.ant.BuildException {
+ throw new org.apache.tools.ant.BuildException(
+ "Not an actual task, but looks like one for documentation purposes");
+ }
+}
diff --git a/Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineCompiler.java b/Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineCompiler.java
new file mode 100644
index 0000000000..47431e84a0
--- /dev/null
+++ b/Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineCompiler.java
@@ -0,0 +1,45 @@
+/*
+ *
+ * Copyright 2002-2006 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.userdefine;
+
+import net.sf.antcontrib.cpptasks.CCTask;
+
+/**
+ * Adapter for the User-Defined Compiler
+ */
+public class UserDefineCompiler extends CommandLineUserDefine {
+
+ public UserDefineCompiler (CCTask cctask, UserDefineDef userdefineDef) {
+ String cmdType = userdefineDef.getType();
+ String toolchainFamily = userdefineDef.getFamily();
+
+ if (userdefineDef.getIncludePathDelimiter() == null) {
+ includePathDelimiter = UserDefineMapping.getIncludePathDelimiter(
+ toolchainFamily, cmdType);
+ } else {
+ includePathDelimiter = userdefineDef.getIncludePathDelimiter();
+ }
+
+ if (userdefineDef.getOutputDelimiter() == null) {
+ outputDelimiter = UserDefineMapping.getOutputFileFlag(
+ toolchainFamily, cmdType);
+ } else {
+ outputDelimiter = userdefineDef.getOutputDelimiter();
+ }
+
+ }
+}
diff --git a/Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineDef.java b/Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineDef.java
new file mode 100644
index 0000000000..d983880ac7
--- /dev/null
+++ b/Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineDef.java
@@ -0,0 +1,306 @@
+/*
+ *
+ * Copyright 2002-2006 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+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 net.sf.antcontrib.cpptasks.ProcessorDef;
+import net.sf.antcontrib.cpptasks.types.ConditionalPath;
+import net.sf.antcontrib.cpptasks.types.IncludePath;
+import net.sf.antcontrib.cpptasks.types.LibrarySet;
+
+/**
+ * A userdefinedef definition. userdefine elements may be placed either as
+ * children of a cc element or the project element. A userdefine element with an
+ * id attribute may be referenced by userdefine elements with refid or extends
+ * attributes.
+ *
+ */
+public class UserDefineDef extends ProcessorDef {
+
+ public UserDefineDef () {
+ }
+
+ private String type = "CC";
+
+ private String family = "MSFT";
+
+ private String cmd;
+
+ private String includePathDelimiter;
+
+ private String outputDelimiter;
+
+ private File workdir;
+
+ private Vector includePaths = new Vector();
+
+ private String outputFile;
+
+ private Vector allLibraries = new Vector();
+
+ private String dpath = null;
+
+ public void addLibset(LibrarySet libset) {
+ if (isReference()) {
+ throw noChildrenAllowed();
+ }
+ if (libset == null) {
+ throw new NullPointerException("libset");
+ }
+
+ allLibraries.add(libset);
+ }
+
+ public void execute() throws org.apache.tools.ant.BuildException {
+ throw new org.apache.tools.ant.BuildException(
+ "Not an actual task, but looks like one for documentation purposes");
+ }
+
+ public void addConfiguredArgument(UserDefineArgument arg) {
+ if (isReference()) {
+ throw noChildrenAllowed();
+ }
+ addConfiguredProcessorArg(arg);
+ }
+
+ /**
+ * Creates an include path.
+ */
+ public IncludePath createIncludePath() {
+ Project p = getProject();
+ if (isReference()) {
+ throw noChildrenAllowed();
+ }
+ IncludePath path = new IncludePath(p);
+ includePaths.addElement(path);
+ return path;
+ }
+
+ /**
+ * Add a <includepath> if specify the file attribute
+ *
+ * @param activePath
+ * Active Path Vector
+ * @param file
+ * File with multiple path
+ * @throws BuildException
+ * if the specify file not exist
+ */
+ protected void loadFile(Vector activePath, File file) throws BuildException {
+ FileReader fileReader;
+ BufferedReader in;
+ String str;
+ if (!file.exists()) {
+ throw new BuildException("The file " + file + " is not existed");
+ }
+ try {
+ fileReader = new FileReader(file);
+ in = new BufferedReader(fileReader);
+ while ((str = in.readLine()) != null) {
+ if (str.trim().endsWith("")) {
+ continue;
+ }
+ str = getProject().replaceProperties(str);
+ activePath.addElement(str.trim());
+ }
+ } catch (Exception e) {
+ throw new BuildException(e.getMessage());
+ }
+ }
+
+ /**
+ * Returns the specific include path.
+ *
+ * @return All active include paths
+ */
+ public String[] getActiveIncludePaths() {
+ if (isReference()) {
+ return ((UserDefineDef) getCheckedRef(UserDefineDef.class,
+ "UserDefineDef")).getActiveIncludePaths();
+ }
+ return getActivePaths(includePaths);
+ }
+
+ private String[] getActivePaths(Vector paths) {
+ Project p = getProject();
+ Vector activePaths = new Vector(paths.size());
+ int length = paths.size();
+ for (int i = 0; i < length; i++) {
+ ConditionalPath path = (ConditionalPath) paths.elementAt(i);
+ if (path.isActive(p)) {
+ if (path.getFile() == null) {
+ String[] pathEntries = path.list();
+ for (int j = 0; j < pathEntries.length; j++) {
+ activePaths.addElement(pathEntries[j]);
+ }
+ } else {
+ loadFile(activePaths, path.getFile());
+ }
+ }
+ }
+ String[] pathNames = new String[activePaths.size()];
+ activePaths.copyInto(pathNames);
+ return pathNames;
+ }
+
+ /**
+ * Get include path delimiter.
+ *
+ * @return Include Path Delimiter
+ */
+ public String getIncludePathDelimiter() {
+ if (isReference()) {
+ return ((UserDefineDef) getCheckedRef(UserDefineDef.class,
+ "UserDefineDef")).getIncludePathDelimiter();
+ }
+ return includePathDelimiter;
+ }
+
+ /**
+ * Set include path delimiter.
+ *
+ * @param includePathDelimiter
+ * include path delimiter
+ */
+ public void setIncludePathDelimiter(String includePathDelimiter) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ this.includePathDelimiter = includePathDelimiter;
+ }
+
+ /**
+ * Get type.
+ *
+ * @return type
+ */
+ public String getType() {
+ if (isReference()) {
+ return ((UserDefineDef) getCheckedRef(UserDefineDef.class,
+ "UserDefineDef")).getType();
+ }
+ return type;
+ }
+
+ /**
+ * Set type.
+ *
+ * @param type
+ * Type
+ */
+ public void setType(String type) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ this.type = type;
+ }
+
+ public String getCmd() {
+ return cmd;
+ }
+
+ public void setCmd(String cmd) {
+ if (isReference()) {
+ 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;
+ }
+
+ public void setWorkdir(File workdir) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ this.workdir = workdir;
+ }
+
+ public String[] getLibset() {
+ Set libs = new LinkedHashSet();
+ Iterator iter = allLibraries.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 (String[]) libs.toArray(new String[libs.size()]);
+ }
+
+ public String getOutputDelimiter() {
+ return outputDelimiter;
+ }
+
+ public void setOutputDelimiter(String outputDelimiter) {
+ this.outputDelimiter = outputDelimiter;
+ }
+
+ public String getDpath() {
+ return dpath;
+ }
+
+ public void setDpath(String dpath) {
+ this.dpath = dpath;
+ }
+
+}
diff --git a/Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineMapping.java b/Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineMapping.java
new file mode 100644
index 0000000000..491cadd7f5
--- /dev/null
+++ b/Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineMapping.java
@@ -0,0 +1,87 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.userdefine;
+
+/**
+ * Relationship between {family, command type} and flags
+ *
+ */
+public class UserDefineMapping {
+
+ /**
+ * Mapping info: include path delimiter <--> family (vendor) + command type
+ */
+ public static 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" } };
+
+ /**
+ * Mapping info: output file flag <--> family (vendor) + command type
+ */
+ public static final String[][] outputFileFlag = { { "MSFT_CC", "/Fo" },
+ { "GCC_CC", "-o" }, { "INTEL_CC", "/Fo" },
+ { "WINDDK_CC", "/Fo" }, { "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" } };
+
+ /**
+ * Get include delimiter with vendow and command type.
+ *
+ * @param vendor
+ * Vendor
+ * @param commandType
+ * Command Type
+ * @return include path delimiter
+ */
+ public static String getIncludePathDelimiter(String vendor,
+ String commandType) {
+ String key = vendor + "_" + commandType;
+ for (int i = 0; i < includePathFlag.length; i++) {
+ if (includePathFlag[i][0].equalsIgnoreCase(key)) {
+ return includePathFlag[i][1];
+ }
+ }
+ return "/I";
+ }
+
+ /**
+ * Get Output Flag with vendor and command type.
+ *
+ * @param vendor
+ * Vendor
+ * @param commandType
+ * Command Type
+ * @return Output File Flag
+ */
+ public static 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];
+ }
+ }
+ return "/Fo";
+ }
+
+} \ No newline at end of file