diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/oldTypeProjects/1.2/test12.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/oldTypeProjects/1.2/test12.zip index 0aded75cb78..1da3f7f9c7d 100644 Binary files a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/oldTypeProjects/1.2/test12.zip and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/oldTypeProjects/1.2/test12.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/oldTypeProjects/2.0/test20.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/oldTypeProjects/2.0/test20.zip index 4ea455c5a2f..c372d2a0b1e 100644 Binary files a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/oldTypeProjects/2.0/test20.zip and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/oldTypeProjects/2.0/test20.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/oldTypeProjects/2.1/test21.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/oldTypeProjects/2.1/test21.zip index e3f47d3f715..0b1270a81c8 100644 Binary files a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/oldTypeProjects/2.1/test21.zip and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/oldTypeProjects/2.1/test21.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/oldTypeProjects/2.1CPP/Test21CXX.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/oldTypeProjects/2.1CPP/Test21CXX.zip index 3b9c6a7ef35..85fa12caede 100644 Binary files a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/oldTypeProjects/2.1CPP/Test21CXX.zip and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/oldTypeProjects/2.1CPP/Test21CXX.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/linkedLib/linkedLib.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/linkedLib/linkedLib.zip index cdb5bbfca62..8c423b59eb6 100644 Binary files a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/linkedLib/linkedLib.zip and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/linkedLib/linkedLib.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/multiResConfig/testResCfg.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/multiResConfig/testResCfg.zip index 5241ddb45c8..0fd7d9c5caa 100644 Binary files a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/multiResConfig/testResCfg.zip and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/multiResConfig/testResCfg.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/singleFileExe/testSingleExe.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/singleFileExe/testSingleExe.zip index ae5db45fbc7..bd4783a07d8 100644 Binary files a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/singleFileExe/testSingleExe.zip and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/singleFileExe/testSingleExe.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/twoFileSO/testDoubleSO.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/twoFileSO/testDoubleSO.zip index fc7299dea31..fb99e7fd7a6 100644 Binary files a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/twoFileSO/testDoubleSO.zip and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/twoFileSO/testDoubleSO.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/CDTFortranTest1/CDTFortranTest1.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/CDTFortranTest1/CDTFortranTest1.zip index e863ae7b986..b92612420d9 100644 Binary files a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/CDTFortranTest1/CDTFortranTest1.zip and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/CDTFortranTest1/CDTFortranTest1.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/CDTFortranTest2/CDTFortranTest2.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/CDTFortranTest2/CDTFortranTest2.zip index a6ec951580f..c42f9ae35f9 100644 Binary files a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/CDTFortranTest2/CDTFortranTest2.zip and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/CDTFortranTest2/CDTFortranTest2.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/TestATO/TestATO.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/TestATO/TestATO.zip index 06f064520f8..a0c5a351486 100644 Binary files a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/TestATO/TestATO.zip and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/TestATO/TestATO.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/copyandDeploy/copyandDeploy.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/copyandDeploy/copyandDeploy.zip index c101f99023f..326e5abe6b2 100644 Binary files a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/copyandDeploy/copyandDeploy.zip and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/copyandDeploy/copyandDeploy.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/deleteFile/deleteFile.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/deleteFile/deleteFile.zip index 3a56ebc758f..91883e7a119 100644 Binary files a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/deleteFile/deleteFile.zip and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/deleteFile/deleteFile.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedLib/linkedLib.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedLib/linkedLib.zip index 4b4a5ce9e9d..ce01ebc6dc1 100644 Binary files a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedLib/linkedLib.zip and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedLib/linkedLib.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/multiResConfig/multiResConfig.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/multiResConfig/multiResConfig.zip index 1101a419c65..3155d37b6d3 100644 Binary files a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/multiResConfig/multiResConfig.zip and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/multiResConfig/multiResConfig.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/preAndPostBuildSteps/preAndPostBuildSteps.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/preAndPostBuildSteps/preAndPostBuildSteps.zip index 3c6979b1d82..3504025ef12 100644 Binary files a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/preAndPostBuildSteps/preAndPostBuildSteps.zip and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/preAndPostBuildSteps/preAndPostBuildSteps.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/rcbsBasicTest/rcbsBasicTest.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/rcbsBasicTest/rcbsBasicTest.zip index a063e57f950..9f9fbc8b7a9 100644 Binary files a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/rcbsBasicTest/rcbsBasicTest.zip and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/rcbsBasicTest/rcbsBasicTest.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/singleFileExe/singleFileExe.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/singleFileExe/singleFileExe.zip index f6968935b31..47787cb0b8b 100644 Binary files a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/singleFileExe/singleFileExe.zip and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/singleFileExe/singleFileExe.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/test with spaces/test with spaces.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/test with spaces/test with spaces.zip new file mode 100644 index 00000000000..f78c1d632e8 Binary files /dev/null and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/test with spaces/test with spaces.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/test30_1/test30_1.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/test30_1/test30_1.zip index 352e9de68c4..eb52f1cd66c 100644 Binary files a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/test30_1/test30_1.zip and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/test30_1/test30_1.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/test30_2/test30_2.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/test30_2/test30_2.zip index b52c97b3f63..d4f2235c225 100644 Binary files a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/test30_2/test30_2.zip and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/test30_2/test30_2.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/testFileWithNoExtension/testFileWithNoExtension.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/testFileWithNoExtension/testFileWithNoExtension.zip index 0a4dc3ae662..959c126f720 100644 Binary files a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/testFileWithNoExtension/testFileWithNoExtension.zip and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/testFileWithNoExtension/testFileWithNoExtension.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/testMacroSupportInBuildDefinitions/testMacroSupportInBuildDefinitions.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/testMacroSupportInBuildDefinitions/testMacroSupportInBuildDefinitions.zip index 1911c0bd888..18205095c18 100644 Binary files a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/testMacroSupportInBuildDefinitions/testMacroSupportInBuildDefinitions.zip and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/testMacroSupportInBuildDefinitions/testMacroSupportInBuildDefinitions.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/twoFileSO/twoFileSO.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/twoFileSO/twoFileSO.zip index db19d13728c..ac24de644a1 100644 Binary files a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/twoFileSO/twoFileSO.zip and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/twoFileSO/twoFileSO.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedCommandLineGeneratorTest.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedCommandLineGeneratorTest.java index 520301c8f04..56485305269 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedCommandLineGeneratorTest.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedCommandLineGeneratorTest.java @@ -45,12 +45,12 @@ public class ManagedCommandLineGeneratorTest extends TestCase { private static String INPUTS_VAL = "[inputs]"; private static String[] INPUTS_ARRAY_VAL = INPUTS_VAL.split( "\\s" ); 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 + " " + 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 + " " + 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 + "'", + 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}" }; private static String[] commandLineEtalonesForParameters = { FLAGS_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL + OUTPUT_VAL + " " + INPUTS_VAL, COMMAND_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL + OUTPUT_VAL + " " + INPUTS_VAL, diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedProject30MakefileTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedProject30MakefileTests.java index 4ebf96f7439..9868711fccd 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedProject30MakefileTests.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedProject30MakefileTests.java @@ -80,6 +80,7 @@ public class ManagedProject30MakefileTests extends TestCase { suite.addTest(new ManagedProject30MakefileTests("CDTFortranTest2")); suite.addTest(new ManagedProject30MakefileTests("TestATO")); suite.addTest(new ManagedProject30MakefileTests("testMacroSupportInBuildDefinitions")); + suite.addTest(new ManagedProject30MakefileTests("testSpaces")); return suite; } @@ -429,6 +430,7 @@ public class ManagedProject30MakefileTests extends TestCase { buildProjects(projects, makefiles); } + /* (non-Javadoc) * 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 @@ -596,5 +598,18 @@ public class ManagedProject30MakefileTests extends TestCase { 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); + } } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java index cb97f812614..dccf2b1d1fd 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java @@ -720,11 +720,36 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo { String cmd = tool.getToolCommand(); //try to resolve the build macros in the tool command try{ - String resolvedCommand = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(cmd, - "", //$NON-NLS-1$ - " ", //$NON-NLS-1$ - IBuildMacroProvider.CONTEXT_FILE, - new FileContextData(inputLocation,outputLocation,null,getDefaultConfiguration().getToolChain())); + 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$ + IBuildMacroProvider.CONTEXT_FILE, + 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) cmd = resolvedCommand; diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedCommandLineGenerator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedCommandLineGenerator.java index 23c26847076..2e17549baf6 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedCommandLineGenerator.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedCommandLineGenerator.java @@ -27,6 +27,7 @@ public class ManagedCommandLineGenerator implements public final String OUT_MACRO = "$@"; //$NON-NLS-1$ public final String SEPARATOR = "/"; //$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 WHITESPACE = " "; //$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( 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_PRM_NAME ) == 0 ) sb.append( outputName.trim() ); - else if( varName.compareToIgnoreCase( INPUTS_PRM_NAME ) == 0 ) sb.append( stringArrayToString( inputResources ) ); + else if( varName.compareToIgnoreCase( OUTPUT_PRM_NAME ) == 0 ) + { + 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 ); } catch( Exception ex ) { // do nothing for a while diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedBuilderMakefileGenerator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedBuilderMakefileGenerator.java index b74b8353b24..f44480a861e 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedBuilderMakefileGenerator.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedBuilderMakefileGenerator.java @@ -52,7 +52,7 @@ public interface IManagedBuilderMakefileGenerator { public final String NEWLINE = System.getProperty("line.separator"); //$NON-NLS-1$ public final String OBJECTS_MAKFILE = "objects.mk"; //$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 SINGLE_QUOTE = "'"; //$NON-NLS-1$ public final String SRCSFILE_NAME = "sources.mk"; //$NON-NLS-1$ diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator.java index 8bb37d4370f..fa13da2ac47 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator.java @@ -86,11 +86,11 @@ public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerat // Calculate the dependency rule // /$(@:%.=%.d) - String depRule = "$(@:%." + //$NON-NLS-1$ + String depRule = "'$(@:%." + //$NON-NLS-1$ outputExtension + "=%." + //$NON-NLS-1$ IManagedBuilderMakefileGenerator.DEP_EXT + - ")"; //$NON-NLS-1$ + ")'"; //$NON-NLS-1$ // Add the rule that will actually create the right format for the dep buffer.append(IManagedBuilderMakefileGenerator.TAB + @@ -122,12 +122,38 @@ public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerat ITool tool = tools[0]; String cmd = tool.getToolCommand(); //try to resolve the build macros in the tool command - try{ - String resolvedCommand = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(cmd, - "", //$NON-NLS-1$ - " ", //$NON-NLS-1$ - IBuildMacroProvider.CONTEXT_FILE, - new FileContextData(resource.getLocation(),null,null,info.getDefaultConfiguration().getToolChain())); + try { + 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$ + IBuildMacroProvider.CONTEXT_FILE, + 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) cmd = resolvedCommand; @@ -155,12 +181,37 @@ public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerat buildCmd = cmdLInfo.getCommandLine(); // resolve any remaining macros in the command after it has been generated - try{ - String resolvedCommand = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(buildCmd, - EMPTY_STRING, - WHITESPACE, - IBuildMacroProvider.CONTEXT_FILE, - new FileContextData(resource.getLocation(), null, null, info.getDefaultConfiguration().getToolChain())); + try { + 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( + buildCmd, + "", //$NON-NLS-1$ + " ", //$NON-NLS-1$ + IBuildMacroProvider.CONTEXT_FILE, + 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) buildCmd = resolvedCommand; @@ -201,17 +252,37 @@ public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerat // resolve any remaining macros in the command after it has been // generated - try { - String resolvedCommand = ManagedBuildManager - .getBuildMacroProvider().resolveValueToMakefileFormat( - buildCmd, - EMPTY_STRING, - WHITESPACE, - IBuildMacroProvider.CONTEXT_FILE, - new FileContextData(resource.getLocation(), - null, null, info - .getDefaultConfiguration() - .getToolChain())); + try { + 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( + buildCmd, + "", //$NON-NLS-1$ + " ", //$NON-NLS-1$ + IBuildMacroProvider.CONTEXT_FILE, + 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) buildCmd = resolvedCommand; @@ -223,8 +294,7 @@ public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerat buildCmd + IManagedBuilderMakefileGenerator.WHITESPACE + ">>" + //$NON-NLS-1$ - IManagedBuilderMakefileGenerator.WHITESPACE + - depRule); + IManagedBuilderMakefileGenerator.WHITESPACE + depRule ); return buffer.toString(); } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuLinkOutputNameProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuLinkOutputNameProvider.java index 48ddcbd7d40..45666c9e048 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuLinkOutputNameProvider.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuLinkOutputNameProvider.java @@ -118,8 +118,32 @@ public class GnuLinkOutputNameProvider implements IManagedOutputNameProvider { } 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 { + + if(explicitRuleRequired) + { + outputPrefix = ManagedBuildManager + .getBuildMacroProvider() + .resolveValue( + outputPrefix, + "", //$NON-NLS-1$ + " ", //$NON-NLS-1$ + IBuildMacroProvider.CONTEXT_CONFIGURATION, + config); + } + + else { outputPrefix = ManagedBuildManager .getBuildMacroProvider() .resolveValueToMakefileFormat( @@ -128,6 +152,7 @@ public class GnuLinkOutputNameProvider implements IManagedOutputNameProvider { " ", //$NON-NLS-1$ IBuildMacroProvider.CONTEXT_CONFIGURATION, config); + } } catch (BuildMacroException e) { diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java index 631f1229090..8633f439642 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java @@ -554,6 +554,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { new String(), null); // Add a new status for each of the bad folders + // TODO: fix error message iter = getInvalidDirList().iterator(); while (iter.hasNext()) { status.add(new Status ( @@ -714,6 +715,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { new String(), null); // Add a new status for each of the bad folders + // TODO: fix error message iter = getInvalidDirList().iterator(); while (iter.hasNext()) { status.add(new Status ( @@ -1101,11 +1103,11 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { StringBuffer buffer = new StringBuffer(); // Add the ROOT macro - buffer.append("ROOT := .." + NEWLINE); //$NON-NLS-1$ - buffer.append(NEWLINE); + //buffer.append("ROOT := .." + NEWLINE); //$NON-NLS-1$ + //buffer.append(NEWLINE); // 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); // Get the clean command from the build model @@ -1116,14 +1118,27 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { // Now add the source providers buffer.append(COMMENT_SYMBOL + WHITESPACE + ManagedMakeMessages.getResourceString(SRC_LISTS) + NEWLINE); 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$ // Include DEPS makefiles if non-empty 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("endif" + NEWLINE + NEWLINE); //$NON-NLS-1$ // 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)); @@ -1364,7 +1379,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { buffer.append(NEWLINE); // 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; } @@ -1771,7 +1786,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { buffer.append(DOT + WHITESPACE + LINEBREAK); } else { IPath path = container.getProjectRelativePath(); - buffer.append(path.toString() + WHITESPACE + LINEBREAK); + buffer.append(escapeWhitespaces(path.toString()) + WHITESPACE + LINEBREAK); } } @@ -1804,8 +1819,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { IPath moduleRelativePath = module.getProjectRelativePath(); String relativePath = moduleRelativePath.toString(); relativePath += relativePath.length() == 0 ? "" : SEPARATOR; //$NON-NLS-1$ - relativePath = escapeWhitespaces(relativePath); - + // For build macros in the configuration, create a map which will map them // to a string which holds its list of sources. LinkedHashMap buildVarToRuleStringMap = new LinkedHashMap(); @@ -1825,8 +1839,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { String macroName = (String)entry.getKey(); addMacroAdditionPrefix(buildVarToRuleStringMap, macroName, "./" + relativePath, false); //$NON-NLS-1$ } + // 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 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 (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, @@ -2022,7 +2041,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { * * This is an example of a pattern rule: * - * /%.: $(ROOT)//%. + * /%.: ..//%. * @echo 'Building file: $<' * @echo 'Invoking tool xxx' * @echo $@ $< @@ -2035,7 +2054,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { * Note that the macros all come from the build model and are * resolved to a real command before writing to the module * makefile, so a real command might look something like: - * source1/%.o: $(ROOT)/source1/%.cpp + * source1/%.o: ../source1/%.cpp * @echo 'Building file: $<' * @echo 'Invoking tool xxx' * @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); String primaryOutputName = null; if (enumeratedPrimaryOutputs.size() > 0) { - primaryOutputName = ((IPath)enumeratedPrimaryOutputs.get(0)).toString(); + primaryOutputName = escapeWhitespaces(((IPath)enumeratedPrimaryOutputs.get(0)).toString()); } else { - primaryOutputName = relativePath + fileName + OptDotExt; + primaryOutputName = escapeWhitespaces(relativePath + fileName + OptDotExt); } String otherPrimaryOutputs = EMPTY_STRING; for (int i=1; i 0 || - MacroResolver.getReferencedExplitFileMacros(tool.getToolCommand(),IBuildMacroProvider.CONTEXT_FILE, - new FileContextData(sourceLocation, outputLocation, null, config.getToolChain())).length > 0; + // are referenced, or if the resource contains special characters in its path + boolean needExplicitRuleForFile = containsSpecialCharacters(sourceLocation.toString()) || //$NON-NLS-1$ + MacroResolver.getReferencedExplitFileMacros(tool).length > 0 + || MacroResolver.getReferencedExplitFileMacros(tool + .getToolCommand(), IBuildMacroProvider.CONTEXT_FILE, + new FileContextData(sourceLocation, outputLocation, + null, config.getToolChain())).length > 0; //get and resolve command String cmd = tool.getToolCommand(); - try{ - String resolvedCommand = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(cmd, - EMPTY_STRING, - WHITESPACE, - IBuildMacroProvider.CONTEXT_FILE, - new FileContextData(sourceLocation, outputLocation, null, info.getDefaultConfiguration().getToolChain())); - if((resolvedCommand = resolvedCommand.trim()).length() > 0) - cmd = resolvedCommand; - - } catch (BuildMacroException e){ - } + + try { + String resolvedCommand = null; + if (!needExplicitRuleForFile) { + resolvedCommand = ManagedBuildManager.getBuildMacroProvider() + .resolveValueToMakefileFormat( + cmd, + EMPTY_STRING, + WHITESPACE, + IBuildMacroProvider.CONTEXT_FILE, + new FileContextData(sourceLocation, + 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; + + } catch (BuildMacroException e) { + } + + String defaultOutputName = EMPTY_STRING; String primaryDependencyName = EMPTY_STRING; String home = (generatedSource)? DOT : ROOT; @@ -2155,17 +2202,17 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { resourcePath = sourceLocation.toString(); // Need a hardcoded rule, not a pattern rule, as a linked file // can reside in any path - defaultOutputName = relativePath + fileName + OptDotExt; - primaryDependencyName = resourcePath; + defaultOutputName = escapeWhitespaces(relativePath + fileName + OptDotExt); + primaryDependencyName = escapeWhitespaces(resourcePath); patternRule = false; } else { // use the relative path (not really needed to store per se but in the future someone may want this) resourcePath = relativePath; // 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 - defaultOutputName = resourcePath + fileName + OptDotExt; - primaryDependencyName = home + SEPARATOR + resourcePath + fileName + DOT + inputExtension; + defaultOutputName = escapeWhitespaces(resourcePath + fileName + OptDotExt); + primaryDependencyName = escapeWhitespaces(home + SEPARATOR + resourcePath + fileName + DOT + inputExtension); patternRule = false; } else { defaultOutputName = relativePath + WILDCARD + OptDotExt; @@ -2186,7 +2233,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { } if (!patternRule) { // 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 @@ -2251,7 +2298,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { String outflag = 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); outflag = tool.getOutputFlag(); outputPrefix = tool.getOutputPrefix(); @@ -2289,23 +2336,40 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { // resolve any remaining macros in the command after it has been // generated - try { - String resolvedCommand = ManagedBuildManager - .getBuildMacroProvider() - .resolveValueToMakefileFormat( - buildCmd, - EMPTY_STRING, - WHITESPACE, - IBuildMacroProvider.CONTEXT_FILE, - new FileContextData(sourceLocation, - outputLocation, null, info - .getDefaultConfiguration() - .getToolChain())); - if ((resolvedCommand = resolvedCommand.trim()).length() > 0) - buildCmd = resolvedCommand; + try { + String resolvedCommand = null; + if (!needExplicitRuleForFile) { + resolvedCommand = ManagedBuildManager.getBuildMacroProvider() + .resolveValueToMakefileFormat( + buildCmd, + EMPTY_STRING, + WHITESPACE, + IBuildMacroProvider.CONTEXT_FILE, + new FileContextData(sourceLocation, + 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( + buildCmd, + EMPTY_STRING, + WHITESPACE, + IBuildMacroProvider.CONTEXT_FILE, + new FileContextData(sourceLocation, + outputLocation, null, info + .getDefaultConfiguration() + .getToolChain())); + } - } catch (BuildMacroException e) { - } + if ((resolvedCommand = resolvedCommand.trim()).length() > 0) + buildCmd = resolvedCommand; + + } catch (BuildMacroException e) { + } buffer.append(TAB + AT + ECHO + WHITESPACE + buildCmd + NEWLINE); @@ -2349,23 +2413,40 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { // resolve any remaining macros in the command after it has been // generated - try { - String resolvedCommand = ManagedBuildManager - .getBuildMacroProvider() - .resolveValueToMakefileFormat( - buildCmd, - EMPTY_STRING, - WHITESPACE, - IBuildMacroProvider.CONTEXT_FILE, - new FileContextData(sourceLocation, - outputLocation, null, info - .getDefaultConfiguration() - .getToolChain())); - if ((resolvedCommand = resolvedCommand.trim()).length() > 0) - buildCmd = resolvedCommand; + try { + String resolvedCommand = null; + if (!needExplicitRuleForFile) { + resolvedCommand = ManagedBuildManager.getBuildMacroProvider() + .resolveValueToMakefileFormat( + buildCmd, + EMPTY_STRING, + WHITESPACE, + IBuildMacroProvider.CONTEXT_FILE, + new FileContextData(sourceLocation, + 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( + buildCmd, + EMPTY_STRING, + WHITESPACE, + IBuildMacroProvider.CONTEXT_FILE, + new FileContextData(sourceLocation, + outputLocation, null, info + .getDefaultConfiguration() + .getToolChain())); + } - } catch (BuildMacroException e) { - } + if ((resolvedCommand = resolvedCommand.trim()).length() > 0) + buildCmd = resolvedCommand; + + } catch (BuildMacroException e) { + } buffer.append(TAB + AT + ECHO + WHITESPACE + buildCmd + NEWLINE); @@ -2384,20 +2465,34 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { // 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. try { - depCmd = ManagedBuildManager - .getBuildMacroProvider() - .resolveValueToMakefileFormat( - depCmd, - EMPTY_STRING, - WHITESPACE, - IBuildMacroProvider.CONTEXT_FILE, - new FileContextData(sourceLocation, - outputLocation, null, info - .getDefaultConfiguration() - .getToolChain())); - - } catch (BuildMacroException e) { - } + if (!needExplicitRuleForFile) { + depCmd = ManagedBuildManager.getBuildMacroProvider() + .resolveValueToMakefileFormat( + depCmd, + EMPTY_STRING, + WHITESPACE, + IBuildMacroProvider.CONTEXT_FILE, + new FileContextData(sourceLocation, + outputLocation, null, + info.getDefaultConfiguration() + .getToolChain())); + } + + else { + depCmd = ManagedBuildManager.getBuildMacroProvider() + .resolveValue( + depCmd, + EMPTY_STRING, + WHITESPACE, + IBuildMacroProvider.CONTEXT_FILE, + new FileContextData(sourceLocation, + outputLocation, null, + info.getDefaultConfiguration() + .getToolChain())); + } + + } catch (BuildMacroException e) { + } buffer.append(depCmd); } @@ -2408,7 +2503,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { buffer.append(TAB + AT + ECHO + WHITESPACE + SINGLE_QUOTE + WHITESPACE + SINGLE_QUOTE + NEWLINE + NEWLINE); } - // Determine if there are calculated dependencies + // Determine if there are calculated dependencies String calculatedDependencies = null; boolean addedDepLines = false; String depLine; @@ -2659,6 +2754,19 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { if (config != null) { try { + + if(containsSpecialCharacters(sourceLocation.toString())) + { + outputPrefix = ManagedBuildManager + .getBuildMacroProvider() + .resolveValue( + outputPrefix, + "", //$NON-NLS-1$ + " ", //$NON-NLS-1$ + IBuildMacroProvider.CONTEXT_CONFIGURATION, + config); + } + else { outputPrefix = ManagedBuildManager .getBuildMacroProvider() .resolveValueToMakefileFormat( @@ -2667,6 +2775,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { " ", //$NON-NLS-1$ IBuildMacroProvider.CONTEXT_CONFIGURATION, config); + } } catch (BuildMacroException e) { @@ -2705,14 +2814,42 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { } for (int j=0; j 0) outputName = resolved; } catch (BuildMacroException e){ @@ -2740,18 +2877,44 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { IPath[] outPaths = nameProvider.getOutputNames(tool, inPaths); for (int j=0; j 0) - outPath = Path.fromOSString(resolved); - } catch (BuildMacroException e){ + String outputName = outPaths[j].toString(); + + + // try to resolve the build macros in the output names + try { + + String resolved = null; + + if (containsSpecialCharacters(sourceLocation.toString())) + { + resolved = ManagedBuildManager + .getBuildMacroProvider() + .resolveValue( + outputName, + "", //$NON-NLS-1$ + " ", //$NON-NLS-1$ + IBuildMacroProvider.CONTEXT_FILE, + 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) + outputName = resolved; + } catch (BuildMacroException e) { } // 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); } + protected boolean containsSpecialCharacters(String path) + { + return path.matches(".*(\\s|[\\{\\}\\(\\)\\$\\@%=;]).*"); + } + /* (non-Javadoc) * Answers the argument with all whitespaces replaced with an escape sequence. * @@ -3012,6 +3180,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { * C_SRCS += \ * ${addprefix $(ROOT)/, \ */ + // TODO fix comment 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 StringBuffer tempBuffer = new StringBuffer(); @@ -3032,6 +3201,10 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { protected void addMacroAdditionFile(HashMap map, String macroName, String filename) { StringBuffer buffer = new StringBuffer(); buffer.append(map.get(macroName)); + + // escape whitespace in the filename + filename = escapeWhitespaces(filename); + buffer.append(filename + WHITESPACE + LINEBREAK); // re-insert string in the map map.put(macroName, buffer.toString()); @@ -3056,7 +3229,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { if (generatedSource) { srcName = "./" + srcPath.toString(); //$NON-NLS-1$ } else { - srcName = "$(ROOT)/" + srcPath.toString(); //$NON-NLS-1$ + srcName = ROOT + "/" + srcPath.toString(); //$NON-NLS-1$ } } else { if (generatedSource && !sourceLocation.isAbsolute()) { @@ -3102,23 +3275,22 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { String macroString = collectionIterator.next().toString(); // 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 - if (!(macroString.endsWith(MACRO_ADDITION_PREFIX_SUFFIX)) && - !(macroString.endsWith(MACRO_ADDITION_ADDPREFIX_SUFFIX))) { + if (!(macroString.endsWith(MACRO_ADDITION_PREFIX_SUFFIX))) { 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 "/" - if (macroString.endsWith(LINEBREAK)) { - macroString = macroString.substring(0, (macroString.length() - 2)) + NEWLINE; - } - currentBuffer.append(macroString); + + // Remove the final "/" + if (macroString.endsWith(LINEBREAK)) { + macroString = macroString.substring(0, (macroString + .length() - 2)) + + NEWLINE; } + currentBuffer.append(macroString); + currentBuffer.append(NEWLINE); - - // append the contents of the buffer to the master buffer for the whole file - buffer.append(currentBuffer); + + // append the contents of the buffer to the master buffer for + // the whole file + buffer.append(currentBuffer); } } return buffer.append(NEWLINE); @@ -3394,18 +3566,10 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { */ protected void appendBuildSubdirectory(IResource resource) { 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 if (!getSubdirList().contains(container)) { - getSubdirList().add(container); + getSubdirList().add(container); } - } } /** @@ -3445,17 +3609,10 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { */ protected void appendModifiedSubdirectory(IResource resource) { 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)) { getModifiedList().add(container); } - } } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/ManagedBuildGnuToolInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/ManagedBuildGnuToolInfo.java index 15e77c02c42..83c097394ed 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/ManagedBuildGnuToolInfo.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/ManagedBuildGnuToolInfo.java @@ -192,18 +192,50 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo { inputs = (List)option.getValue(); } for (int j=0; j 0) + String inputName = (String)inputs.get(j); + + + 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, + "", //$NON-NLS-1$ + " ", //$NON-NLS-1$ + IBuildMacroProvider.CONTEXT_OPTION, + new OptionContextData( + 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; - } catch (BuildMacroException e){ + } catch (BuildMacroException e) { } if (primaryInput) { @@ -938,10 +970,10 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo { OptDotExt = DOT + tool.getOutputExtension(srcExtensionName); // 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(); 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 + DOT + srcExtensionName + "=" + wildcard + OptDotExt + ")" ); //$NON-NLS-1$ //$NON-NLS-2$ return objectsBuffer.toString();