Initial import.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -0,0 +1,389 @@
|
||||
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
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
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>();
|
||||
public void command(CCTask cctask, UserDefineDef userdefine){
|
||||
File workdir;
|
||||
File outdir;
|
||||
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();
|
||||
|
||||
/*
|
||||
* Generate cmdline = command +
|
||||
* general args +
|
||||
* outputflag + outputfile
|
||||
* subsystemFlag + subsystemValue +
|
||||
* includeFlag + includeFile +
|
||||
* includeFileincludpath +
|
||||
* entryPointFlag + entryPointValue +
|
||||
* mapFlag + mapValue +
|
||||
* pdbFlag + pdbValue +
|
||||
* endargs +
|
||||
*
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* 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++) {
|
||||
if(incPath[j].indexOf(' ') >= 0) {
|
||||
includePath.addElement( includePathDelimiter + incPath[j]);
|
||||
//includePath.addElement( includePathDelimiter + "\"" + incPath[j] + "\"");
|
||||
}
|
||||
else {
|
||||
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);
|
||||
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);
|
||||
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;
|
||||
}
|
||||
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")){
|
||||
cmdLen = cmdLen + 2;
|
||||
}else {
|
||||
cmdLen++;
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* 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());
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// if have source file append source file in command land.
|
||||
//
|
||||
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++){
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected int runCommand(CCTask task, File workingDir, String[] cmdline)
|
||||
throws BuildException {
|
||||
return CUtil.runCommand(task, workingDir, cmdline, false, null);
|
||||
|
||||
}
|
||||
|
||||
protected String getInputFileArgument(File outputDir, String filename,
|
||||
int index) {
|
||||
//
|
||||
// if there is an embedded space,
|
||||
// must enclose in quotes
|
||||
if (filename.indexOf(' ') >= 0) {
|
||||
StringBuffer buf = new StringBuffer("\"");
|
||||
buf.append(filename);
|
||||
buf.append("\"");
|
||||
return buf.toString();
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
*
|
||||
* 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;
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,219 @@
|
||||
/*
|
||||
*
|
||||
* 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 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");
|
||||
}
|
||||
} 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();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,497 @@
|
||||
/*
|
||||
*
|
||||
* 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.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;
|
||||
|
||||
public class UserDefineDef extends ProcessorDef{
|
||||
|
||||
public UserDefineDef () {}
|
||||
|
||||
private String type = "CC";
|
||||
private String includepathDelimiter;
|
||||
|
||||
private File outdir;
|
||||
private File workdir;
|
||||
|
||||
private String inputSuffix;
|
||||
private String outputSuffix;
|
||||
|
||||
private Vector<IncludePath> includePaths= new Vector<IncludePath>();
|
||||
private Vector<FileList> fileSetList = new Vector<FileList>();
|
||||
|
||||
/**
|
||||
* 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 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>();
|
||||
|
||||
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 (p == null) {
|
||||
throw new java.lang.IllegalStateException("project must be set");
|
||||
}
|
||||
if (isReference()) {
|
||||
throw noChildrenAllowed();
|
||||
}
|
||||
IncludePath path = new IncludePath(p);
|
||||
includePaths.addElement(path);
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a <includepath> if specify the file attribute
|
||||
*
|
||||
* @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() == "") {
|
||||
continue;
|
||||
}
|
||||
str = getProject().replaceProperties(str);
|
||||
activePath.addElement(str.trim());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new BuildException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the specific include path.
|
||||
*/
|
||||
public String[] getActiveIncludePaths() {
|
||||
if (isReference()) {
|
||||
return ((UserDefineDef) getCheckedRef(UserDefineDef.class,
|
||||
"UserDefineDef")).getActiveIncludePaths();
|
||||
}
|
||||
return getActivePaths(includePaths);
|
||||
}
|
||||
|
||||
private String[] getActivePaths(Vector paths) {
|
||||
Project p = getProject();
|
||||
if (p == null) {
|
||||
throw new java.lang.IllegalStateException("project not set");
|
||||
}
|
||||
Vector activePaths = new Vector(paths.size());
|
||||
for (int i = 0; i < paths.size(); 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;
|
||||
}
|
||||
|
||||
public String getIncludepathDelimiter() {
|
||||
if (isReference()) {
|
||||
return ((UserDefineDef) getCheckedRef(UserDefineDef.class,
|
||||
"UserDefineDef")).getIncludepathDelimiter();
|
||||
}
|
||||
return includepathDelimiter;
|
||||
}
|
||||
|
||||
public void setIncludepathDelimiter(String includepathDelimiter) {
|
||||
if (isReference()) {
|
||||
throw tooManyAttributes();
|
||||
}
|
||||
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,
|
||||
"UserDefineDef")).getType();
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
if (isReference()) {
|
||||
throw tooManyAttributes();
|
||||
}
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public File getWorkdir() {
|
||||
if (isReference()) {
|
||||
return ((UserDefineDef) getCheckedRef(UserDefineDef.class,
|
||||
"UserDefineDef")).getWorkdir();
|
||||
}
|
||||
return workdir;
|
||||
}
|
||||
|
||||
public void setWorkdir(File workdir) {
|
||||
if (isReference()) {
|
||||
throw tooManyAttributes();
|
||||
}
|
||||
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] + " ";
|
||||
}
|
||||
}
|
||||
return libString;
|
||||
}
|
||||
|
||||
public Vector<LibrarySet> getLibSet(){
|
||||
return this.libSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package net.sf.antcontrib.cpptasks.userdefine;
|
||||
|
||||
public class UserDefineElement {
|
||||
String flag = null;
|
||||
String value = null;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
public void setFlag(String flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,186 @@
|
||||
/*
|
||||
*
|
||||
* 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;
|
||||
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 Command Type: CC, LIB, LINK, ASL, ASM, ASMLINK
|
||||
public final static String[] commandType = { "CC", "LIB", "LINK", "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" },
|
||||
{ "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" },
|
||||
{ "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_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,
|
||||
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 null;
|
||||
}
|
||||
|
||||
public static String getOutputFileFlag(String vendor, String arch, String commandType) {
|
||||
/*
|
||||
* First find outputfileFlag by vendor_arch_commandType
|
||||
*/
|
||||
String key = vendor + "_" + arch + "_" + 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;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user