1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 09:46:02 +02:00

crecoski Nov 23, 2005

- MBS support for spaces in resource names
This commit is contained in:
Chris Recoskie 2005-11-23 19:19:08 +00:00
parent ad33e2b6d6
commit 847a638e03
33 changed files with 547 additions and 192 deletions

View file

@ -45,12 +45,12 @@ public class ManagedCommandLineGeneratorTest extends TestCase {
private static String INPUTS_VAL = "[inputs]"; private static String INPUTS_VAL = "[inputs]";
private static String[] INPUTS_ARRAY_VAL = INPUTS_VAL.split( "\\s" ); private static String[] INPUTS_ARRAY_VAL = INPUTS_VAL.split( "\\s" );
private static String[] commandLineEtalonesForPatterns = { private static String[] commandLineEtalonesForPatterns = {
COMMAND_VAL + " " + FLAGS_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL + OUTPUT_VAL + " " + INPUTS_VAL, COMMAND_VAL + " " + FLAGS_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL + "'" + OUTPUT_VAL + "'" + " " + "'" + INPUTS_VAL + "'",
COMMAND_VAL, COMMAND_VAL + " " + FLAGS_VAL, COMMAND_VAL + " " + FLAGS_VAL + " " + OUTPUT_FLAG_VAL, COMMAND_VAL, COMMAND_VAL + " " + FLAGS_VAL, COMMAND_VAL + " " + FLAGS_VAL + " " + OUTPUT_FLAG_VAL,
COMMAND_VAL + " " + FLAGS_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL, COMMAND_VAL + " " + FLAGS_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL,
COMMAND_VAL + " " + FLAGS_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL + OUTPUT_VAL, COMMAND_VAL + " " + FLAGS_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL + "'" + OUTPUT_VAL + "'",
COMMAND_VAL + " " + FLAGS_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL + OUTPUT_VAL + " " + INPUTS_VAL, COMMAND_VAL + " " + FLAGS_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL + "'" + OUTPUT_VAL + "'" + " " + "'" + INPUTS_VAL + "'",
COMMAND_VAL + " " + FLAGS_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL + OUTPUT_VAL + " " + "${WRONG_VAR_NAME}" }; COMMAND_VAL + " " + FLAGS_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL + "'" + OUTPUT_VAL + "'" + " " + "${WRONG_VAR_NAME}" };
private static String[] commandLineEtalonesForParameters = { private static String[] commandLineEtalonesForParameters = {
FLAGS_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL + OUTPUT_VAL + " " + INPUTS_VAL, FLAGS_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL + OUTPUT_VAL + " " + INPUTS_VAL,
COMMAND_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL + OUTPUT_VAL + " " + INPUTS_VAL, COMMAND_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL + OUTPUT_VAL + " " + INPUTS_VAL,

View file

@ -80,6 +80,7 @@ public class ManagedProject30MakefileTests extends TestCase {
suite.addTest(new ManagedProject30MakefileTests("CDTFortranTest2")); suite.addTest(new ManagedProject30MakefileTests("CDTFortranTest2"));
suite.addTest(new ManagedProject30MakefileTests("TestATO")); suite.addTest(new ManagedProject30MakefileTests("TestATO"));
suite.addTest(new ManagedProject30MakefileTests("testMacroSupportInBuildDefinitions")); suite.addTest(new ManagedProject30MakefileTests("testMacroSupportInBuildDefinitions"));
suite.addTest(new ManagedProject30MakefileTests("testSpaces"));
return suite; return suite;
} }
@ -429,6 +430,7 @@ public class ManagedProject30MakefileTests extends TestCase {
buildProjects(projects, makefiles); buildProjects(projects, makefiles);
} }
/* (non-Javadoc) /* (non-Javadoc)
* tests 3.0 style tool integration: create pre-build and post-build steps and verify that * tests 3.0 style tool integration: create pre-build and post-build steps and verify that
* the proper commands are generated in the makefile which is created by the managedbuild system * the proper commands are generated in the makefile which is created by the managedbuild system
@ -596,5 +598,18 @@ public class ManagedProject30MakefileTests extends TestCase {
buildProjects(projects, makefiles); buildProjects(projects, makefiles);
} }
/**
* (non-Javadoc)
* tests managed build system with a project which has resources with spaces in their paths
*/
public void testSpaces()
{
IPath[] makefiles = {
Path.fromOSString("makefile"),
Path.fromOSString("objects.mk"),
Path.fromOSString("sources.mk"),
Path.fromOSString("subdir.mk")};
IProject[] projects = createProjects("test with spaces", null, null, true);
buildProjects(projects, makefiles);
}
} }

View file

@ -720,11 +720,36 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
String cmd = tool.getToolCommand(); String cmd = tool.getToolCommand();
//try to resolve the build macros in the tool command //try to resolve the build macros in the tool command
try{ try{
String resolvedCommand = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(cmd, String resolvedCommand = null;
if ((inputLocation != null && inputLocation.toString().indexOf(" ") != -1) || //$NON-NLS-1$
(outputLocation != null && outputLocation.toString().indexOf(" ") != -1) ) //$NON-NLS-1$
{
resolvedCommand = ManagedBuildManager
.getBuildMacroProvider().resolveValue(
cmd,
"", //$NON-NLS-1$ "", //$NON-NLS-1$
" ", //$NON-NLS-1$ " ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_FILE, IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(inputLocation,outputLocation,null,getDefaultConfiguration().getToolChain())); new FileContextData(inputLocation,
outputLocation, null,
getDefaultConfiguration()
.getToolChain()));
}
else {
resolvedCommand = ManagedBuildManager
.getBuildMacroProvider()
.resolveValueToMakefileFormat(
cmd,
"", //$NON-NLS-1$
" ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(inputLocation,
outputLocation, null,
getDefaultConfiguration()
.getToolChain()));
}
if((resolvedCommand = resolvedCommand.trim()).length() > 0) if((resolvedCommand = resolvedCommand.trim()).length() > 0)
cmd = resolvedCommand; cmd = resolvedCommand;

View file

@ -27,6 +27,7 @@ public class ManagedCommandLineGenerator implements
public final String OUT_MACRO = "$@"; //$NON-NLS-1$ public final String OUT_MACRO = "$@"; //$NON-NLS-1$
public final String SEPARATOR = "/"; //$NON-NLS-1$ public final String SEPARATOR = "/"; //$NON-NLS-1$
public final String SINGLE_QUOTE = "'"; //$NON-NLS-1$ public final String SINGLE_QUOTE = "'"; //$NON-NLS-1$
public final String DOUBLE_QUOTE = "\""; //$NON-NLS-1$
public final String TAB = "\t"; //$NON-NLS-1$ public final String TAB = "\t"; //$NON-NLS-1$
public final String WHITESPACE = " "; //$NON-NLS-1$ public final String WHITESPACE = " "; //$NON-NLS-1$
public final String WILDCARD = "%"; //$NON-NLS-1$ public final String WILDCARD = "%"; //$NON-NLS-1$
@ -89,8 +90,38 @@ public class ManagedCommandLineGenerator implements
else if( varName.compareToIgnoreCase( FLAGS_PRM_NAME ) == 0 ) sb.append( stringArrayToString( flags ) ); else if( varName.compareToIgnoreCase( FLAGS_PRM_NAME ) == 0 ) sb.append( stringArrayToString( flags ) );
else if( varName.compareToIgnoreCase( OUTPUT_FLAG_PRM_NAME ) == 0 ) sb.append( outputFlag.trim() ); else if( varName.compareToIgnoreCase( OUTPUT_FLAG_PRM_NAME ) == 0 ) sb.append( outputFlag.trim() );
else if( varName.compareToIgnoreCase( OUTPUT_PREFIX_PRM_NAME ) == 0 ) sb.append( outputPrefix.trim() ); else if( varName.compareToIgnoreCase( OUTPUT_PREFIX_PRM_NAME ) == 0 ) sb.append( outputPrefix.trim() );
else if( varName.compareToIgnoreCase( OUTPUT_PRM_NAME ) == 0 ) sb.append( outputName.trim() ); else if( varName.compareToIgnoreCase( OUTPUT_PRM_NAME ) == 0 )
else if( varName.compareToIgnoreCase( INPUTS_PRM_NAME ) == 0 ) sb.append( stringArrayToString( inputResources ) ); {
StringBuffer tempBuffer = new StringBuffer("");
if(!outputName.equals("")) //$NON-NLS-1$
{
// if the output name isn't a variable then quote it
if(outputName.indexOf("$(") != 0) //$NON-NLS-1$
tempBuffer.append( SINGLE_QUOTE + outputName + SINGLE_QUOTE);
else
tempBuffer.append(outputName);
}
sb.append(tempBuffer.toString().trim());
}
else if( varName.compareToIgnoreCase( INPUTS_PRM_NAME ) == 0 ){
StringBuffer tempBuffer = new StringBuffer(""); //$NON-NLS-1$
for(int k = 0; k < inputResources.length; k++)
{
if(!inputResources[k].equals("")) //$NON-NLS-1$
{
// if the input resource isn't a variable then quote it
if(inputResources[k].indexOf("$(") != 0) //$NON-NLS-1$
tempBuffer.append(SINGLE_QUOTE + inputResources[k] + SINGLE_QUOTE + WHITESPACE); //$NON-NLS-1$ //$NON-NLS-2$
else
tempBuffer.append(inputResources[k] + WHITESPACE);
}
}
sb.append(tempBuffer.toString().trim());
}
else sb.append( VAR_FIRST_CHAR + VAR_SECOND_CHAR + varName + VAR_FINAL_CHAR ); else sb.append( VAR_FIRST_CHAR + VAR_SECOND_CHAR + varName + VAR_FINAL_CHAR );
} catch( Exception ex ) { } catch( Exception ex ) {
// do nothing for a while // do nothing for a while

View file

@ -52,7 +52,7 @@ public interface IManagedBuilderMakefileGenerator {
public final String NEWLINE = System.getProperty("line.separator"); //$NON-NLS-1$ public final String NEWLINE = System.getProperty("line.separator"); //$NON-NLS-1$
public final String OBJECTS_MAKFILE = "objects.mk"; //$NON-NLS-1$ public final String OBJECTS_MAKFILE = "objects.mk"; //$NON-NLS-1$
public final String OUT_MACRO = "$@"; //$NON-NLS-1$ public final String OUT_MACRO = "$@"; //$NON-NLS-1$
public final String ROOT = "$(ROOT)"; //$NON-NLS-1$ public final String ROOT = ".."; //$NON-NLS-1$
public final String SEPARATOR = "/"; //$NON-NLS-1$ public final String SEPARATOR = "/"; //$NON-NLS-1$
public final String SINGLE_QUOTE = "'"; //$NON-NLS-1$ public final String SINGLE_QUOTE = "'"; //$NON-NLS-1$
public final String SRCSFILE_NAME = "sources.mk"; //$NON-NLS-1$ public final String SRCSFILE_NAME = "sources.mk"; //$NON-NLS-1$

View file

@ -86,11 +86,11 @@ public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerat
// Calculate the dependency rule // Calculate the dependency rule
// <path>/$(@:%.<out_ext>=%.d) // <path>/$(@:%.<out_ext>=%.d)
String depRule = "$(@:%." + //$NON-NLS-1$ String depRule = "'$(@:%." + //$NON-NLS-1$
outputExtension + outputExtension +
"=%." + //$NON-NLS-1$ "=%." + //$NON-NLS-1$
IManagedBuilderMakefileGenerator.DEP_EXT + IManagedBuilderMakefileGenerator.DEP_EXT +
")"; //$NON-NLS-1$ ")'"; //$NON-NLS-1$
// Add the rule that will actually create the right format for the dep // Add the rule that will actually create the right format for the dep
buffer.append(IManagedBuilderMakefileGenerator.TAB + buffer.append(IManagedBuilderMakefileGenerator.TAB +
@ -122,12 +122,38 @@ public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerat
ITool tool = tools[0]; ITool tool = tools[0];
String cmd = tool.getToolCommand(); String cmd = tool.getToolCommand();
//try to resolve the build macros in the tool command //try to resolve the build macros in the tool command
try{ try {
String resolvedCommand = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(cmd, String resolvedCommand = null;
// does the resource have spaces in its name?
if (resource.getProjectRelativePath().toString().indexOf(" ") != -1) {
// use fully qualified strings
resolvedCommand = ManagedBuildManager
.getBuildMacroProvider()
.resolveValueToMakefileFormat(
cmd,
"", //$NON-NLS-1$ "", //$NON-NLS-1$
" ", //$NON-NLS-1$ " ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_FILE, IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(resource.getLocation(),null,null,info.getDefaultConfiguration().getToolChain())); new FileContextData(resource.getLocation(),
null, null, info
.getDefaultConfiguration()
.getToolChain()));
} else {
// use builder variables
resolvedCommand = ManagedBuildManager
.getBuildMacroProvider()
.resolveValueToMakefileFormat(
cmd,
"", //$NON-NLS-1$
" ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(resource.getLocation(),
null, null, info
.getDefaultConfiguration()
.getToolChain()));
}
if((resolvedCommand = resolvedCommand.trim()).length() > 0) if((resolvedCommand = resolvedCommand.trim()).length() > 0)
cmd = resolvedCommand; cmd = resolvedCommand;
@ -155,12 +181,37 @@ public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerat
buildCmd = cmdLInfo.getCommandLine(); buildCmd = cmdLInfo.getCommandLine();
// resolve any remaining macros in the command after it has been generated // resolve any remaining macros in the command after it has been generated
try{ try {
String resolvedCommand = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(buildCmd, String resolvedCommand = null;
EMPTY_STRING,
WHITESPACE, // does the resource have spaces in its name?
if (resource.getProjectRelativePath().toString().indexOf(" ") != -1) {
// use fully qualified strings
resolvedCommand = ManagedBuildManager
.getBuildMacroProvider()
.resolveValueToMakefileFormat(
buildCmd,
"", //$NON-NLS-1$
" ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_FILE, IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(resource.getLocation(), null, null, info.getDefaultConfiguration().getToolChain())); new FileContextData(resource.getLocation(),
null, null, info
.getDefaultConfiguration()
.getToolChain()));
} else {
// use builder variables
resolvedCommand = ManagedBuildManager
.getBuildMacroProvider()
.resolveValueToMakefileFormat(
buildCmd,
"", //$NON-NLS-1$
" ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(resource.getLocation(),
null, null, info
.getDefaultConfiguration()
.getToolChain()));
}
if((resolvedCommand = resolvedCommand.trim()).length() > 0) if((resolvedCommand = resolvedCommand.trim()).length() > 0)
buildCmd = resolvedCommand; buildCmd = resolvedCommand;
@ -202,16 +253,36 @@ public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerat
// resolve any remaining macros in the command after it has been // resolve any remaining macros in the command after it has been
// generated // generated
try { try {
String resolvedCommand = ManagedBuildManager String resolvedCommand = null;
.getBuildMacroProvider().resolveValueToMakefileFormat(
// does the resource have spaces in its name?
if (resource.getProjectRelativePath().toString().indexOf(" ") != -1) {
// use fully qualified strings
resolvedCommand = ManagedBuildManager
.getBuildMacroProvider()
.resolveValueToMakefileFormat(
buildCmd, buildCmd,
EMPTY_STRING, "", //$NON-NLS-1$
WHITESPACE, " ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_FILE, IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(resource.getLocation(), new FileContextData(resource.getLocation(),
null, null, info null, null, info
.getDefaultConfiguration() .getDefaultConfiguration()
.getToolChain())); .getToolChain()));
} else {
// use builder variables
resolvedCommand = ManagedBuildManager
.getBuildMacroProvider()
.resolveValueToMakefileFormat(
buildCmd,
"", //$NON-NLS-1$
" ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(resource.getLocation(),
null, null, info
.getDefaultConfiguration()
.getToolChain()));
}
if ((resolvedCommand = resolvedCommand.trim()).length() > 0) if ((resolvedCommand = resolvedCommand.trim()).length() > 0)
buildCmd = resolvedCommand; buildCmd = resolvedCommand;
@ -223,8 +294,7 @@ public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerat
buildCmd + buildCmd +
IManagedBuilderMakefileGenerator.WHITESPACE + IManagedBuilderMakefileGenerator.WHITESPACE +
">>" + //$NON-NLS-1$ ">>" + //$NON-NLS-1$
IManagedBuilderMakefileGenerator.WHITESPACE + IManagedBuilderMakefileGenerator.WHITESPACE + depRule );
depRule);
return buffer.toString(); return buffer.toString();
} }

View file

@ -119,7 +119,31 @@ public class GnuLinkOutputNameProvider implements IManagedOutputNameProvider {
if (config != null) { if (config != null) {
boolean explicitRuleRequired = false;
// if any input files have spaces in the name, then we must
// not use builder variables
for(int k = 0; k < primaryInputNames.length; k++)
{
if(primaryInputNames[k].toString().indexOf(" ") != -1) //$NON-NLS-1$
explicitRuleRequired = true;
}
try { try {
if(explicitRuleRequired)
{
outputPrefix = ManagedBuildManager
.getBuildMacroProvider()
.resolveValue(
outputPrefix,
"", //$NON-NLS-1$
" ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_CONFIGURATION,
config);
}
else {
outputPrefix = ManagedBuildManager outputPrefix = ManagedBuildManager
.getBuildMacroProvider() .getBuildMacroProvider()
.resolveValueToMakefileFormat( .resolveValueToMakefileFormat(
@ -129,6 +153,7 @@ public class GnuLinkOutputNameProvider implements IManagedOutputNameProvider {
IBuildMacroProvider.CONTEXT_CONFIGURATION, IBuildMacroProvider.CONTEXT_CONFIGURATION,
config); config);
} }
}
catch (BuildMacroException e) { catch (BuildMacroException e) {
} }

View file

@ -554,6 +554,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
new String(), new String(),
null); null);
// Add a new status for each of the bad folders // Add a new status for each of the bad folders
// TODO: fix error message
iter = getInvalidDirList().iterator(); iter = getInvalidDirList().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
status.add(new Status ( status.add(new Status (
@ -714,6 +715,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
new String(), new String(),
null); null);
// Add a new status for each of the bad folders // Add a new status for each of the bad folders
// TODO: fix error message
iter = getInvalidDirList().iterator(); iter = getInvalidDirList().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
status.add(new Status ( status.add(new Status (
@ -1101,11 +1103,11 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
// Add the ROOT macro // Add the ROOT macro
buffer.append("ROOT := .." + NEWLINE); //$NON-NLS-1$ //buffer.append("ROOT := .." + NEWLINE); //$NON-NLS-1$
buffer.append(NEWLINE); //buffer.append(NEWLINE);
// include makefile.init supplementary makefile // include makefile.init supplementary makefile
buffer.append("-include $(ROOT)" + SEPARATOR + MAKEFILE_INIT + NEWLINE); //$NON-NLS-1$ buffer.append("-include " + ROOT + SEPARATOR + MAKEFILE_INIT + NEWLINE); //$NON-NLS-1$
buffer.append(NEWLINE); buffer.append(NEWLINE);
// Get the clean command from the build model // Get the clean command from the build model
@ -1116,14 +1118,27 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// Now add the source providers // Now add the source providers
buffer.append(COMMENT_SYMBOL + WHITESPACE + ManagedMakeMessages.getResourceString(SRC_LISTS) + NEWLINE); buffer.append(COMMENT_SYMBOL + WHITESPACE + ManagedMakeMessages.getResourceString(SRC_LISTS) + NEWLINE);
buffer.append("-include sources.mk" + NEWLINE); //$NON-NLS-1$ buffer.append("-include sources.mk" + NEWLINE); //$NON-NLS-1$
buffer.append("-include $(SUBDIRS:%=%/subdir.mk)" + NEWLINE); //$NON-NLS-1$
// add an include for each subdir
buffer.append("-include subdir.mk" + NEWLINE); //$NON-NLS-1$
Iterator subDirIterator = getSubdirList().iterator();
while(subDirIterator.hasNext())
{
IContainer subDir = (IContainer)subDirIterator.next();
IPath projectRelativePath = subDir.getProjectRelativePath();
if(!projectRelativePath.toString().equals("")) //$NON-NLS-1$
buffer.append("-include " + escapeWhitespaces(projectRelativePath.toString()) + SEPARATOR + "subdir.mk"+ NEWLINE); //$NON-NLS-1$
}
buffer.append("-include objects.mk" + NEWLINE); //$NON-NLS-1$ buffer.append("-include objects.mk" + NEWLINE); //$NON-NLS-1$
// Include DEPS makefiles if non-empty // Include DEPS makefiles if non-empty
buffer.append("ifneq ($(strip $(" + DEPS_MACRO + ")),)" + NEWLINE); //$NON-NLS-1$ //$NON-NLS-2$ buffer.append("ifneq ($(strip $(" + DEPS_MACRO + ")),)" + NEWLINE); //$NON-NLS-1$ //$NON-NLS-2$
buffer.append("-include $(" + DEPS_MACRO + ")" + NEWLINE); //$NON-NLS-1$ //$NON-NLS-2$ buffer.append("-include $(" + DEPS_MACRO + ")" + NEWLINE); //$NON-NLS-1$ //$NON-NLS-2$
buffer.append("endif" + NEWLINE + NEWLINE); //$NON-NLS-1$ buffer.append("endif" + NEWLINE + NEWLINE); //$NON-NLS-1$
// Include makefile.defs supplemental makefile // Include makefile.defs supplemental makefile
buffer.append("-include $(ROOT)" + SEPARATOR + MAKEFILE_DEFS + NEWLINE); //$NON-NLS-1$ buffer.append("-include " + ROOT + SEPARATOR + MAKEFILE_DEFS + NEWLINE); //$NON-NLS-1$
return (buffer.append(NEWLINE)); return (buffer.append(NEWLINE));
@ -1364,7 +1379,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
buffer.append(NEWLINE); buffer.append(NEWLINE);
// Include makefile.targets supplemental makefile // Include makefile.targets supplemental makefile
buffer.append("-include $(ROOT)" + SEPARATOR + MAKEFILE_TARGETS + NEWLINE); //$NON-NLS-1$ buffer.append("-include " + ROOT + SEPARATOR + MAKEFILE_TARGETS + NEWLINE); //$NON-NLS-1$
return buffer; return buffer;
} }
@ -1771,7 +1786,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
buffer.append(DOT + WHITESPACE + LINEBREAK); buffer.append(DOT + WHITESPACE + LINEBREAK);
} else { } else {
IPath path = container.getProjectRelativePath(); IPath path = container.getProjectRelativePath();
buffer.append(path.toString() + WHITESPACE + LINEBREAK); buffer.append(escapeWhitespaces(path.toString()) + WHITESPACE + LINEBREAK);
} }
} }
@ -1804,7 +1819,6 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
IPath moduleRelativePath = module.getProjectRelativePath(); IPath moduleRelativePath = module.getProjectRelativePath();
String relativePath = moduleRelativePath.toString(); String relativePath = moduleRelativePath.toString();
relativePath += relativePath.length() == 0 ? "" : SEPARATOR; //$NON-NLS-1$ relativePath += relativePath.length() == 0 ? "" : SEPARATOR; //$NON-NLS-1$
relativePath = escapeWhitespaces(relativePath);
// For build macros in the configuration, create a map which will map them // For build macros in the configuration, create a map which will map them
// to a string which holds its list of sources. // to a string which holds its list of sources.
@ -1825,8 +1839,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
String macroName = (String)entry.getKey(); String macroName = (String)entry.getKey();
addMacroAdditionPrefix(buildVarToRuleStringMap, macroName, "./" + relativePath, false); //$NON-NLS-1$ addMacroAdditionPrefix(buildVarToRuleStringMap, macroName, "./" + relativePath, false); //$NON-NLS-1$
} }
// Create an entry for the DEPS macro // Create an entry for the DEPS macro
addMacroAdditionPrefix(buildVarToRuleStringMap, DEPS_MACRO, "./" + relativePath, true); //$NON-NLS-1$ addMacroAdditionPrefix(buildVarToRuleStringMap, DEPS_MACRO, "./" + relativePath, false); //$NON-NLS-1$
// String buffers // String buffers
StringBuffer buffer = new StringBuffer(); // Return buffer StringBuffer buffer = new StringBuffer(); // Return buffer
@ -1908,7 +1923,11 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// If the rule generates a dependency file, add the file to the DEPS variable // If the rule generates a dependency file, add the file to the DEPS variable
if (generatedDepFile.length() > 0) { if (generatedDepFile.length() > 0) {
addMacroAdditionFile(buildVarToRuleStringMap, DEPS_MACRO, generatedDepFile.toString()); addMacroAdditionFile(
buildVarToRuleStringMap,
DEPS_MACRO,
"./" + (relativePath.equals("") ? relativePath : relativePath + "/") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ generatedDepFile.toString());
} }
// If the generated outputs of this tool are input to another tool, // If the generated outputs of this tool are input to another tool,
@ -2022,7 +2041,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
* *
* This is an example of a pattern rule: * This is an example of a pattern rule:
* *
* <relative_path>/%.<outputExtension>: $(ROOT)/<relative_path>/%.<inputExtension> * <relative_path>/%.<outputExtension>: ../<relative_path>/%.<inputExtension>
* @echo 'Building file: $<' * @echo 'Building file: $<'
* @echo 'Invoking tool xxx' * @echo 'Invoking tool xxx'
* @echo <tool> <flags> <output_flag><output_prefix>$@ $< * @echo <tool> <flags> <output_flag><output_prefix>$@ $<
@ -2035,7 +2054,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
* Note that the macros all come from the build model and are * Note that the macros all come from the build model and are
* resolved to a real command before writing to the module * resolved to a real command before writing to the module
* makefile, so a real command might look something like: * makefile, so a real command might look something like:
* source1/%.o: $(ROOT)/source1/%.cpp * source1/%.o: ../source1/%.cpp
* @echo 'Building file: $<' * @echo 'Building file: $<'
* @echo 'Invoking tool xxx' * @echo 'Invoking tool xxx'
* @echo g++ -g -O2 -c -I/cygdrive/c/eclipse/workspace/Project/headers -o$@ $< * @echo g++ -g -O2 -c -I/cygdrive/c/eclipse/workspace/Project/headers -o$@ $<
@ -2098,13 +2117,13 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
enumeratedOutputs.addAll(enumeratedSecondaryOutputs); enumeratedOutputs.addAll(enumeratedSecondaryOutputs);
String primaryOutputName = null; String primaryOutputName = null;
if (enumeratedPrimaryOutputs.size() > 0) { if (enumeratedPrimaryOutputs.size() > 0) {
primaryOutputName = ((IPath)enumeratedPrimaryOutputs.get(0)).toString(); primaryOutputName = escapeWhitespaces(((IPath)enumeratedPrimaryOutputs.get(0)).toString());
} else { } else {
primaryOutputName = relativePath + fileName + OptDotExt; primaryOutputName = escapeWhitespaces(relativePath + fileName + OptDotExt);
} }
String otherPrimaryOutputs = EMPTY_STRING; String otherPrimaryOutputs = EMPTY_STRING;
for (int i=1; i<enumeratedPrimaryOutputs.size(); i++) { // Starting a 1 is intentional for (int i=1; i<enumeratedPrimaryOutputs.size(); i++) { // Starting a 1 is intentional
otherPrimaryOutputs += WHITESPACE + ((IPath)enumeratedPrimaryOutputs.get(i)).toString(); otherPrimaryOutputs += WHITESPACE + escapeWhitespaces(((IPath)enumeratedPrimaryOutputs.get(i)).toString());
} }
// Figure out the path to the input resource // Figure out the path to the input resource
@ -2124,24 +2143,52 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
} }
// A separate rule is needed for the resource in case the explicit file-specific macros // A separate rule is needed for the resource in case the explicit file-specific macros
// are referenced // are referenced, or if the resource contains special characters in its path
boolean fileExplicitMacrosReferenced = MacroResolver.getReferencedExplitFileMacros(tool).length > 0 || boolean needExplicitRuleForFile = containsSpecialCharacters(sourceLocation.toString()) || //$NON-NLS-1$
MacroResolver.getReferencedExplitFileMacros(tool.getToolCommand(),IBuildMacroProvider.CONTEXT_FILE, MacroResolver.getReferencedExplitFileMacros(tool).length > 0
new FileContextData(sourceLocation, outputLocation, null, config.getToolChain())).length > 0; || MacroResolver.getReferencedExplitFileMacros(tool
.getToolCommand(), IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation, outputLocation,
null, config.getToolChain())).length > 0;
//get and resolve command //get and resolve command
String cmd = tool.getToolCommand(); String cmd = tool.getToolCommand();
try{
String resolvedCommand = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(cmd, try {
String resolvedCommand = null;
if (!needExplicitRuleForFile) {
resolvedCommand = ManagedBuildManager.getBuildMacroProvider()
.resolveValueToMakefileFormat(
cmd,
EMPTY_STRING, EMPTY_STRING,
WHITESPACE, WHITESPACE,
IBuildMacroProvider.CONTEXT_FILE, IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation, outputLocation, null, info.getDefaultConfiguration().getToolChain())); new FileContextData(sourceLocation,
if((resolvedCommand = resolvedCommand.trim()).length() > 0) outputLocation, null, info
.getDefaultConfiguration()
.getToolChain()));
} else {
// if we need an explicit rule then don't use any builder
// variables, resolve everything
// to explicit strings
resolvedCommand = ManagedBuildManager.getBuildMacroProvider()
.resolveValue(
cmd,
EMPTY_STRING,
WHITESPACE,
IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation,
outputLocation, null, info
.getDefaultConfiguration()
.getToolChain()));
}
if ((resolvedCommand = resolvedCommand.trim()).length() > 0)
cmd = resolvedCommand; cmd = resolvedCommand;
} catch (BuildMacroException e){ } catch (BuildMacroException e) {
} }
String defaultOutputName = EMPTY_STRING; String defaultOutputName = EMPTY_STRING;
String primaryDependencyName = EMPTY_STRING; String primaryDependencyName = EMPTY_STRING;
String home = (generatedSource)? DOT : ROOT; String home = (generatedSource)? DOT : ROOT;
@ -2155,17 +2202,17 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
resourcePath = sourceLocation.toString(); resourcePath = sourceLocation.toString();
// Need a hardcoded rule, not a pattern rule, as a linked file // Need a hardcoded rule, not a pattern rule, as a linked file
// can reside in any path // can reside in any path
defaultOutputName = relativePath + fileName + OptDotExt; defaultOutputName = escapeWhitespaces(relativePath + fileName + OptDotExt);
primaryDependencyName = resourcePath; primaryDependencyName = escapeWhitespaces(resourcePath);
patternRule = false; patternRule = false;
} else { } else {
// use the relative path (not really needed to store per se but in the future someone may want this) // use the relative path (not really needed to store per se but in the future someone may want this)
resourcePath = relativePath; resourcePath = relativePath;
// The rule and command to add to the makefile // The rule and command to add to the makefile
if( resConfig != null || fileExplicitMacrosReferenced) { if( resConfig != null || needExplicitRuleForFile) {
// Need a hardcoded rule, not a pattern rule // Need a hardcoded rule, not a pattern rule
defaultOutputName = resourcePath + fileName + OptDotExt; defaultOutputName = escapeWhitespaces(resourcePath + fileName + OptDotExt);
primaryDependencyName = home + SEPARATOR + resourcePath + fileName + DOT + inputExtension; primaryDependencyName = escapeWhitespaces(home + SEPARATOR + resourcePath + fileName + DOT + inputExtension);
patternRule = false; patternRule = false;
} else { } else {
defaultOutputName = relativePath + WILDCARD + OptDotExt; defaultOutputName = relativePath + WILDCARD + OptDotExt;
@ -2186,7 +2233,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
} }
if (!patternRule) { if (!patternRule) {
// Need to reset the primary dependency to be a filename rather than a pattern // Need to reset the primary dependency to be a filename rather than a pattern
primaryDependencyName = home + SEPARATOR + resourcePath + fileName + DOT + inputExtension; primaryDependencyName = escapeWhitespaces(home + SEPARATOR + resourcePath + fileName + DOT + inputExtension);
} }
} }
@ -2230,7 +2277,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
} }
} }
} }
buildRule += WHITESPACE + addlPath.toString(); buildRule += WHITESPACE + escapeWhitespaces(addlPath.toString());
} }
// No duplicates in a makefile. If we already have this rule, don't add it or the commands to build the file // No duplicates in a makefile. If we already have this rule, don't add it or the commands to build the file
@ -2251,7 +2298,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
String outflag = null; String outflag = null;
String outputPrefix = null; String outputPrefix = null;
if( resConfig != null || fileExplicitMacrosReferenced) { if( resConfig != null || needExplicitRuleForFile) {
buffer.append(TAB + AT + ECHO + WHITESPACE + SINGLE_QUOTE + tool.getAnnouncement() + SINGLE_QUOTE + NEWLINE); buffer.append(TAB + AT + ECHO + WHITESPACE + SINGLE_QUOTE + tool.getAnnouncement() + SINGLE_QUOTE + NEWLINE);
outflag = tool.getOutputFlag(); outflag = tool.getOutputFlag();
outputPrefix = tool.getOutputPrefix(); outputPrefix = tool.getOutputPrefix();
@ -2290,8 +2337,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// resolve any remaining macros in the command after it has been // resolve any remaining macros in the command after it has been
// generated // generated
try { try {
String resolvedCommand = ManagedBuildManager String resolvedCommand = null;
.getBuildMacroProvider() if (!needExplicitRuleForFile) {
resolvedCommand = ManagedBuildManager.getBuildMacroProvider()
.resolveValueToMakefileFormat( .resolveValueToMakefileFormat(
buildCmd, buildCmd,
EMPTY_STRING, EMPTY_STRING,
@ -2301,6 +2349,22 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
outputLocation, null, info outputLocation, null, info
.getDefaultConfiguration() .getDefaultConfiguration()
.getToolChain())); .getToolChain()));
} else {
// if we need an explicit rule then don't use any builder
// variables, resolve everything
// to explicit strings
resolvedCommand = ManagedBuildManager.getBuildMacroProvider()
.resolveValue(
buildCmd,
EMPTY_STRING,
WHITESPACE,
IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation,
outputLocation, null, info
.getDefaultConfiguration()
.getToolChain()));
}
if ((resolvedCommand = resolvedCommand.trim()).length() > 0) if ((resolvedCommand = resolvedCommand.trim()).length() > 0)
buildCmd = resolvedCommand; buildCmd = resolvedCommand;
@ -2350,8 +2414,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// resolve any remaining macros in the command after it has been // resolve any remaining macros in the command after it has been
// generated // generated
try { try {
String resolvedCommand = ManagedBuildManager String resolvedCommand = null;
.getBuildMacroProvider() if (!needExplicitRuleForFile) {
resolvedCommand = ManagedBuildManager.getBuildMacroProvider()
.resolveValueToMakefileFormat( .resolveValueToMakefileFormat(
buildCmd, buildCmd,
EMPTY_STRING, EMPTY_STRING,
@ -2361,6 +2426,22 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
outputLocation, null, info outputLocation, null, info
.getDefaultConfiguration() .getDefaultConfiguration()
.getToolChain())); .getToolChain()));
} else {
// if we need an explicit rule then don't use any builder
// variables, resolve everything
// to explicit strings
resolvedCommand = ManagedBuildManager.getBuildMacroProvider()
.resolveValue(
buildCmd,
EMPTY_STRING,
WHITESPACE,
IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation,
outputLocation, null, info
.getDefaultConfiguration()
.getToolChain()));
}
if ((resolvedCommand = resolvedCommand.trim()).length() > 0) if ((resolvedCommand = resolvedCommand.trim()).length() > 0)
buildCmd = resolvedCommand; buildCmd = resolvedCommand;
@ -2384,17 +2465,31 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// Resolve any macros in the dep command after it has been generated. // Resolve any macros in the dep command after it has been generated.
// Note: do not trim the result because it will strip out necessary tab characters. // Note: do not trim the result because it will strip out necessary tab characters.
try { try {
depCmd = ManagedBuildManager if (!needExplicitRuleForFile) {
.getBuildMacroProvider() depCmd = ManagedBuildManager.getBuildMacroProvider()
.resolveValueToMakefileFormat( .resolveValueToMakefileFormat(
depCmd, depCmd,
EMPTY_STRING, EMPTY_STRING,
WHITESPACE, WHITESPACE,
IBuildMacroProvider.CONTEXT_FILE, IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation, new FileContextData(sourceLocation,
outputLocation, null, info outputLocation, null,
.getDefaultConfiguration() info.getDefaultConfiguration()
.getToolChain())); .getToolChain()));
}
else {
depCmd = ManagedBuildManager.getBuildMacroProvider()
.resolveValue(
depCmd,
EMPTY_STRING,
WHITESPACE,
IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation,
outputLocation, null,
info.getDefaultConfiguration()
.getToolChain()));
}
} catch (BuildMacroException e) { } catch (BuildMacroException e) {
} }
@ -2659,6 +2754,19 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
if (config != null) { if (config != null) {
try { try {
if(containsSpecialCharacters(sourceLocation.toString()))
{
outputPrefix = ManagedBuildManager
.getBuildMacroProvider()
.resolveValue(
outputPrefix,
"", //$NON-NLS-1$
" ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_CONFIGURATION,
config);
}
else {
outputPrefix = ManagedBuildManager outputPrefix = ManagedBuildManager
.getBuildMacroProvider() .getBuildMacroProvider()
.resolveValueToMakefileFormat( .resolveValueToMakefileFormat(
@ -2668,6 +2776,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
IBuildMacroProvider.CONTEXT_CONFIGURATION, IBuildMacroProvider.CONTEXT_CONFIGURATION,
config); config);
} }
}
catch (BuildMacroException e) { catch (BuildMacroException e) {
} }
@ -2705,14 +2814,42 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
} }
for (int j=0; j<outputList.size(); j++) { for (int j=0; j<outputList.size(); j++) {
String outputName = (String)outputList.get(j); String outputName = (String)outputList.get(j);
try{
//try to resolve the build macros in the output names
String resolved = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
// try to resolve the build macros in the output
// names
try {
String resolved = null;
if (containsSpecialCharacters(sourceLocation.toString()))
{
resolved = ManagedBuildManager
.getBuildMacroProvider()
.resolveValue(
outputName, outputName,
"", //$NON-NLS-1$ "", //$NON-NLS-1$
" ", //$NON-NLS-1$ " ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_FILE, IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation, null, option, tool)); new FileContextData(
sourceLocation,
null, option, tool));
}
else {
resolved = ManagedBuildManager
.getBuildMacroProvider()
.resolveValueToMakefileFormat(
outputName,
"", //$NON-NLS-1$
" ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(
sourceLocation,
null, option, tool));
}
if((resolved = resolved.trim()).length() > 0) if((resolved = resolved.trim()).length() > 0)
outputName = resolved; outputName = resolved;
} catch (BuildMacroException e){ } catch (BuildMacroException e){
@ -2741,17 +2878,43 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
for (int j=0; j<outPaths.length; j++) { for (int j=0; j<outPaths.length; j++) {
IPath outPath = outPaths[j]; IPath outPath = outPaths[j];
String outputName = outPaths[j].toString(); String outputName = outPaths[j].toString();
try{
//try to resolve the build macros in the output names
String resolved = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat( // try to resolve the build macros in the output names
try {
String resolved = null;
if (containsSpecialCharacters(sourceLocation.toString()))
{
resolved = ManagedBuildManager
.getBuildMacroProvider()
.resolveValue(
outputName, outputName,
"", //$NON-NLS-1$ "", //$NON-NLS-1$
" ", //$NON-NLS-1$ " ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_FILE, IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation, null, option, tool)); new FileContextData(
if((resolved = resolved.trim()).length() > 0) sourceLocation, null,
outPath = Path.fromOSString(resolved); option, tool));
} catch (BuildMacroException e){ }
else {
resolved = ManagedBuildManager
.getBuildMacroProvider()
.resolveValueToMakefileFormat(
outputName,
"", //$NON-NLS-1$
" ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(
sourceLocation, null,
option, tool));
}
if ((resolved = resolved.trim()).length() > 0)
outputName = resolved;
} catch (BuildMacroException e) {
} }
// If only a file name is specified, add the relative path of this output directory // If only a file name is specified, add the relative path of this output directory
@ -2984,6 +3147,11 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
buffer.append(NEWLINE); buffer.append(NEWLINE);
} }
protected boolean containsSpecialCharacters(String path)
{
return path.matches(".*(\\s|[\\{\\}\\(\\)\\$\\@%=;]).*");
}
/* (non-Javadoc) /* (non-Javadoc)
* Answers the argument with all whitespaces replaced with an escape sequence. * Answers the argument with all whitespaces replaced with an escape sequence.
* *
@ -3012,6 +3180,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
* C_SRCS += \ * C_SRCS += \
* ${addprefix $(ROOT)/, \ * ${addprefix $(ROOT)/, \
*/ */
// TODO fix comment
protected void addMacroAdditionPrefix(LinkedHashMap map, String macroName, String relativePath, boolean addPrefix) { protected void addMacroAdditionPrefix(LinkedHashMap map, String macroName, String relativePath, boolean addPrefix) {
// there is no entry in the map, so create a buffer for this macro // there is no entry in the map, so create a buffer for this macro
StringBuffer tempBuffer = new StringBuffer(); StringBuffer tempBuffer = new StringBuffer();
@ -3032,6 +3201,10 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
protected void addMacroAdditionFile(HashMap map, String macroName, String filename) { protected void addMacroAdditionFile(HashMap map, String macroName, String filename) {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
buffer.append(map.get(macroName)); buffer.append(map.get(macroName));
// escape whitespace in the filename
filename = escapeWhitespaces(filename);
buffer.append(filename + WHITESPACE + LINEBREAK); buffer.append(filename + WHITESPACE + LINEBREAK);
// re-insert string in the map // re-insert string in the map
map.put(macroName, buffer.toString()); map.put(macroName, buffer.toString());
@ -3056,7 +3229,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
if (generatedSource) { if (generatedSource) {
srcName = "./" + srcPath.toString(); //$NON-NLS-1$ srcName = "./" + srcPath.toString(); //$NON-NLS-1$
} else { } else {
srcName = "$(ROOT)/" + srcPath.toString(); //$NON-NLS-1$ srcName = ROOT + "/" + srcPath.toString(); //$NON-NLS-1$
} }
} else { } else {
if (generatedSource && !sourceLocation.isAbsolute()) { if (generatedSource && !sourceLocation.isAbsolute()) {
@ -3102,22 +3275,21 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
String macroString = collectionIterator.next().toString(); String macroString = collectionIterator.next().toString();
// Check if we added any files to the rule // Check if we added any files to the rule
// Currently, we do this by comparing the end of the rule buffer to MACRO_ADDITION_PREFIX_SUFFIX // Currently, we do this by comparing the end of the rule buffer to MACRO_ADDITION_PREFIX_SUFFIX
if (!(macroString.endsWith(MACRO_ADDITION_PREFIX_SUFFIX)) && if (!(macroString.endsWith(MACRO_ADDITION_PREFIX_SUFFIX))) {
!(macroString.endsWith(MACRO_ADDITION_ADDPREFIX_SUFFIX))) {
StringBuffer currentBuffer = new StringBuffer(); StringBuffer currentBuffer = new StringBuffer();
// Close off the rule
if (macroString.indexOf(MACRO_ADDITION_ADDPREFIX_HEADER) >= 0) {
currentBuffer.append(macroString + "}" + NEWLINE); //$NON-NLS-1$
} else {
// Remove the final "/" // Remove the final "/"
if (macroString.endsWith(LINEBREAK)) { if (macroString.endsWith(LINEBREAK)) {
macroString = macroString.substring(0, (macroString.length() - 2)) + NEWLINE; macroString = macroString.substring(0, (macroString
.length() - 2))
+ NEWLINE;
} }
currentBuffer.append(macroString); currentBuffer.append(macroString);
}
currentBuffer.append(NEWLINE); currentBuffer.append(NEWLINE);
// append the contents of the buffer to the master buffer for the whole file // append the contents of the buffer to the master buffer for
// the whole file
buffer.append(currentBuffer); buffer.append(currentBuffer);
} }
} }
@ -3394,19 +3566,11 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
*/ */
protected void appendBuildSubdirectory(IResource resource) { protected void appendBuildSubdirectory(IResource resource) {
IContainer container = resource.getParent(); IContainer container = resource.getParent();
// If the path contains a space relative to the project, reject it from the build
if (resource.getProjectRelativePath().toString().indexOf(" ") != -1) { //$NON-NLS-1$
// Only add the container once
if (!getInvalidDirList().contains(container)) {
getInvalidDirList().add(container);
}
} else {
// Only add the container once // Only add the container once
if (!getSubdirList().contains(container)) { if (!getSubdirList().contains(container)) {
getSubdirList().add(container); getSubdirList().add(container);
} }
} }
}
/** /**
* Adds the container of the argument to a list of subdirectories that are to be * Adds the container of the argument to a list of subdirectories that are to be
@ -3445,18 +3609,11 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
*/ */
protected void appendModifiedSubdirectory(IResource resource) { protected void appendModifiedSubdirectory(IResource resource) {
IContainer container = resource.getParent(); IContainer container = resource.getParent();
// If the path contains a space relative to the project, reject it from the build
if (resource.getProjectRelativePath().toString().indexOf(" ") != -1) { //$NON-NLS-1$
// Only add the container once
if (!getInvalidDirList().contains(container)) {
getInvalidDirList().add(container);
}
} else {
if (!getModifiedList().contains(container)) { if (!getModifiedList().contains(container)) {
getModifiedList().add(container); getModifiedList().add(container);
} }
} }
}
/************************************************************************* /*************************************************************************

View file

@ -193,17 +193,49 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
} }
for (int j=0; j<inputs.size(); j++) { for (int j=0; j<inputs.size(); j++) {
String inputName = (String)inputs.get(j); String inputName = (String)inputs.get(j);
try{
//try to resolve the build macros in the output names
String resolved = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat( try {
// try to resolve the build macros in the output
// names
String resolved = null;
// does the input name contain spaces?
// TODO: support other special characters
if (inputName.indexOf(" ") != -1) //$NON-NLS-1$
{
// resolve to string
resolved = ManagedBuildManager
.getBuildMacroProvider()
.resolveValue(
inputName, inputName,
"", //$NON-NLS-1$ "", //$NON-NLS-1$
" ", //$NON-NLS-1$ " ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_OPTION, IBuildMacroProvider.CONTEXT_OPTION,
new OptionContextData(option, config.getToolChain())); new OptionContextData(
if((resolved = resolved.trim()).length() > 0) option,
config
.getToolChain()));
} else {
// resolve to makefile variable format
resolved = ManagedBuildManager
.getBuildMacroProvider()
.resolveValueToMakefileFormat(
inputName,
"", //$NON-NLS-1$
" ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_OPTION,
new OptionContextData(
option,
config
.getToolChain()));
}
if ((resolved = resolved.trim()).length() > 0)
inputName = resolved; inputName = resolved;
} catch (BuildMacroException e){ } catch (BuildMacroException e) {
} }
if (primaryInput) { if (primaryInput) {
@ -938,10 +970,10 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
OptDotExt = DOT + tool.getOutputExtension(srcExtensionName); OptDotExt = DOT + tool.getOutputExtension(srcExtensionName);
// create rule of the form // create rule of the form
// OBJS = $(macroName1: $(ROOT)/%.input1=%.output1) ... $(macroNameN: $(ROOT)/%.inputN=%.outputN) // OBJS = $(macroName1: ../%.input1=%.output1) ... $(macroNameN: ../%.inputN=%.outputN)
StringBuffer objectsBuffer = new StringBuffer(); StringBuffer objectsBuffer = new StringBuffer();
objectsBuffer.append(IManagedBuilderMakefileGenerator.WHITESPACE + "$(" + macroName + //$NON-NLS-1$ objectsBuffer.append(IManagedBuilderMakefileGenerator.WHITESPACE + "$(" + macroName + //$NON-NLS-1$
IManagedBuilderMakefileGenerator.COLON + "$(ROOT)" + //$NON-NLS-1$ IManagedBuilderMakefileGenerator.COLON + IManagedBuilderMakefileGenerator.ROOT + //$NON-NLS-1$
IManagedBuilderMakefileGenerator.SEPARATOR + IManagedBuilderMakefileGenerator.WILDCARD + IManagedBuilderMakefileGenerator.SEPARATOR + IManagedBuilderMakefileGenerator.WILDCARD +
DOT + srcExtensionName + "=" + wildcard + OptDotExt + ")" ); //$NON-NLS-1$ //$NON-NLS-2$ DOT + srcExtensionName + "=" + wildcard + OptDotExt + ")" ); //$NON-NLS-1$ //$NON-NLS-2$
return objectsBuffer.toString(); return objectsBuffer.toString();