From de026bcfe64589ab4e52e789d75d1837c83472aa Mon Sep 17 00:00:00 2001 From: Chris Recoskie Date: Fri, 14 Oct 2005 13:29:04 +0000 Subject: [PATCH] crecoskie Oct 14, 2005 - Adding macro support to buildDefinitions markup. See Bugzilla 111203 --- .../plugin.xml | 71 +++++++++++++ .../testMacroSupportInBuildDefinitions.zip | Bin 0 -> 2944 bytes .../tests/ManagedProject30MakefileTests.java | 13 +++ .../schema/buildDefinitions.exsd | 10 +- .../internal/macros/MbsMacroSupplier.java | 100 ++++++++++++++++++ .../gnu/DefaultGCCDependencyCalculator.java | 19 ++++ .../gnu/GnuLinkOutputNameProvider.java | 56 ++++++++++ .../makegen/gnu/GnuMakefileGenerator.java | 93 ++++++++++++++++ .../makegen/gnu/ManagedBuildGnuToolInfo.java | 27 +++++ 9 files changed, 384 insertions(+), 5 deletions(-) create mode 100644 build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/testMacroSupportInBuildDefinitions/testMacroSupportInBuildDefinitions.zip diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml index 11ab12f194f..5ad0e38c3dd 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml @@ -4143,6 +4143,77 @@ + + + + + + + + + + + + + + + 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 new file mode 100644 index 0000000000000000000000000000000000000000..3a633e2f50ab0f10ac3161f327ac2480db628825 GIT binary patch literal 2944 zcmaJ@2{csw8=kRb$rfYplPJqzX8OpMe5CBd7)y%?(^$qDQKC|lU46EMkjlO*WSMD_ z!u(B%GWIdH>_$Y1%zvg+pXHo-@44sPbMAeg`}@7`^SsXwVaCb^0&p^}C1bcMU`uc@ zo*}677hM89yv~;Q-H6nFYhin@nFQ>S$_IW8-FXonk3rS~ci_Kc=sChRqGPe3* zcX6G1r(9dh4ifr9vN@Buqh7oJeQw1n^Ycmri{Ry?7qP5Ros%nE(kA}!ee5&hW;=u@qRbl+)Jo4RQ+#kSWR<1AD4EY%8y104m#BUHV2+9Asdlx@F@Ex{3)P98iRDWl^o{q*C24Z6k5LP?{GvxYvQ63x>vgC2 zT>AZJk1a-?k!Jh8u~2H5bHAM(G9dEddWV783$+Gz+|T8k@u{ zXzk0yQ1nydZ}o!qRI*_6qKSMMygXg@^VX|3xzS6IHnvex2n*9RUc}1k#n2EMq_W1THc^$?E^_SHW&A@YhEd{cH{VI==& zOg#O#v3;DLTu#Z`+1q}dE)QUNqFiJAD9)_Tx88=T1uECX++x(Y9mCNqxavtH^s9|< zO>YbLS021*xq+TSL1VrSIJ3xn_ppiTt;SnXJT@+M(8EPwBNr-HnxWgcsQSFT%}RVu zOQM`QY2p@@@I~E~JH;R;p`s8<1zYn1@45Cmo}lxtFGn?Z3DL?+^6J@Eb;s7b-!jXS z8Bnq^#n}93Mu~pUD;~xd0lwa7R}U{V#MRe#H?dXO4)ExBc-4Ancoiwb#u38E=HM(3 zowNZlzGdFOM-yVabwT@}+`XOsJp-WL&YnMjOObHj5tzVH(P%nMsX)3jks@mg_9_tZ z@DSjN%mT}2g^9Mj?c?j*So=#7oUQawDm`g5Se1s-5euE`rtv!UX$`{U!E)n6L=j<$ zkMRa72b$wCh(4hI@bf+2+E&-_fhofAI>+{|5uy=yXEk5?&F=0nXj&1=;XHWu1@vg2 z+J^abE}H|kfB&h$G;WnDQoLkGqI@;`!()}Rx5i%Zu;gEeS)Y4HWgjX$;%h~d$eWGOj}G8>%=@aIw{+PCPc=>eyc$z zVl36Q&-=-<4gwunMO>s*u7L@e!+L=Qg~Nmn4bzso_5*L`C-*07OgUdv%d|@Um@KYU zcHr;30$#`L?G0(3_#BBlvF}$^`a#9;1fvIcR(?^YI#3X;Fdu%1dpEgYgGFfm=7(jf@;FB@ipI9Kgodv!w%!w5M@%FT~%Y#tIk#>H{ zD#UiUGSS?EL@fLOw|rx!VybKcw=!-cnRHqE5l^Uqqriazlh#dpJrr*BH>KN2=vrUdC>Gi>1?xA7};M94L*wI79#z;@c_ zF*X_SM=>+SxkY{ffiCAg{2BYiBO6Uw4+$J?cz0dQ!%Vo65__|>9)S?)lM0W2V=*}C z<7y&@p;L(DqRS!%e8X?dKH@dR`RGBsPxg~!t&4jl2Gtst@1!Yn2u>2&&Pc3Id|1~AaGWD5qB~6z=9pczecp|l~en7qzz_B z$y9&9!`dJUjmE1<6R_&LL~>@*|N5G$920~0p2?C%d^Xf;b84-8h6eFsX9xK zj!5NaaP)Q@PEU7wqS*?M2oKa+EmJ`kK#}+LA&+}oGYGMHLXfyJp@k(JAuTor(Pnfs z=hF;2br$vg2OISV*WRNT4N_xessqRZVob|lN3g9f&pd){kN*y2JJYs$9Ph{N)Kd z0k%q+DcH?G?b-&gIZk#$Y!%6Nh^6fin-gFs#MTxv)wCG{9NSj$pSBQY>+6c literal 0 HcmV?d00001 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 cd845adfd62..4ebf96f7439 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 @@ -79,6 +79,7 @@ public class ManagedProject30MakefileTests extends TestCase { suite.addTest(new ManagedProject30MakefileTests("CDTFortranTest1")); suite.addTest(new ManagedProject30MakefileTests("CDTFortranTest2")); suite.addTest(new ManagedProject30MakefileTests("TestATO")); + suite.addTest(new ManagedProject30MakefileTests("testMacroSupportInBuildDefinitions")); return suite; } @@ -584,4 +585,16 @@ public class ManagedProject30MakefileTests extends TestCase { IProject[] projects = createProjects("TestATO", null, null, true); buildProjects(projects, makefiles); } + + public void testMacroSupportInBuildDefinitions() { + IPath[] makefiles = { + Path.fromOSString("makefile"), + Path.fromOSString("objects.mk"), + Path.fromOSString("sources.mk"), + Path.fromOSString("subdir.mk")}; + IProject[] projects = createProjects("testMacroSupportInBuildDefinitions", null, null, true); + buildProjects(projects, makefiles); + } + + } diff --git a/build/org.eclipse.cdt.managedbuilder.core/schema/buildDefinitions.exsd b/build/org.eclipse.cdt.managedbuilder.core/schema/buildDefinitions.exsd index a7f927c22e6..49d31200a71 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/schema/buildDefinitions.exsd +++ b/build/org.eclipse.cdt.managedbuilder.core/schema/buildDefinitions.exsd @@ -121,7 +121,7 @@ - Contains the name of a class that implements an interface with a method for returning a default name for a configuration. The configuration names in a user's project must be unique. A projectType can contain configuration children with the same name. In this case, a configurationNameProvider must be specified to make the names unique before they are displayed to the user in the New Project and New Configuration dialog boxes. + Contains the name of a class that implements an interface with a method for returning a default name for a configuration. The configuration names in a user's project must be unique. A projectType can contain configuration children with the same name. In this case, a configurationNameProvider must be specified to make the names unique before they are displayed to the user in the New Project and New Configuration dialog boxes. @@ -570,14 +570,14 @@ - The command that invokes the tool. For example, gcc for the Gnu C compiler, or g++ for the Gnu C++ compiler. + The command that invokes the tool. For example, gcc for the Gnu C compiler, or g++ for the Gnu C++ compiler. This attribute supports MBS file context macros. - Specifies the command "pattern" that indicates how the parts of the command line are used to create the entire command line. The pattern consists of the replaceable variables COMMAND, FLAGS, OUTPUT_FLAG, OUTPUT_PREFIX, OUTPUT and INPUTS. The default command line pattern is ${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}, except when customBuildStep is true, where the default is $(COMMAND). White space and other characters are significant and are copied to the generated command. + Specifies the command "pattern" that indicates how the parts of the command line are used to create the entire command line. The pattern consists of the replaceable variables COMMAND, FLAGS, OUTPUT_FLAG, OUTPUT_PREFIX, OUTPUT and INPUTS. The default command line pattern is ${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}, except when customBuildStep is true, where the default is $(COMMAND). White space and other characters are significant and are copied to the generated command. This attribute supports MBS file context macros. @@ -899,7 +899,7 @@ - Some tools produce files with a special prefix that must be specified. For example, a librarian on POSIX systems expects the output to be libtarget.a, so 'lib' would be the prefix. The default is to use the Tool “outputPrefix” attribute if primaryOutput is True, otherwise the default is an empty string. + Some tools produce files with a special prefix that must be specified. For example, a librarian on POSIX systems expects the output to be libtarget.a, so 'lib' would be the prefix. The default is to use the Tool “outputPrefix” attribute if primaryOutput is True, otherwise the default is an empty string. This attribute supports the use of MBS configuration macros. @@ -1141,7 +1141,7 @@ Additional special types exist to flag options of special relevance to the build - The id of a class that implements the IManagedOptionValueHandler interface. This interface is used to dynamically manage the value of an option. + The id of a class that implements the IManagedOptionValueHandler interface. This interface is used to dynamically manage the value of an option. diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/MbsMacroSupplier.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/MbsMacroSupplier.java index 7cacb703395..545d13d813a 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/MbsMacroSupplier.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/MbsMacroSupplier.java @@ -383,6 +383,57 @@ public class MbsMacroSupplier implements IBuildMacroSupplier { if(targetTool != null){ IOutputType pot = targetTool.getPrimaryOutputType(); String prefix = pot.getOutputPrefix(); + + + // Resolve any macros in the outputPrefix + // Note that we cannot use file macros because if we do a clean + // we need to know the actual + // name of the file to clean, and cannot use any builder + // variables such as $@. Hence + // we use the next best thing, i.e. configuration context. + + // figure out the configuration we're using + IBuildObject toolParent = targetTool.getParent(); + IConfiguration config = null; + // if the parent is a config then we're done + if (toolParent instanceof IConfiguration) + config = (IConfiguration) toolParent; + else if (toolParent instanceof IToolChain) { + // must be a toolchain + config = (IConfiguration) ((IToolChain) toolParent) + .getParent(); + } + + else if (toolParent instanceof IResourceConfiguration) { + config = (IConfiguration) ((IResourceConfiguration) toolParent) + .getParent(); + } + + else { + // bad + throw new AssertionError( + "tool parent must be one of configuration, toolchain, or resource configuration"); + } + + if (config != null) { + + try { + prefix = ManagedBuildManager + .getBuildMacroProvider() + .resolveValueToMakefileFormat( + prefix, + "", //$NON-NLS-1$ + " ", //$NON-NLS-1$ + IBuildMacroProvider.CONTEXT_CONFIGURATION, + config); + } + + catch (BuildMacroException e) { + } + + } + + if(prefix != null && !EMPTY_STRING.equals(prefix)) name = prefix + name; } @@ -393,6 +444,55 @@ public class MbsMacroSupplier implements IBuildMacroSupplier { if(targetTool != null){ IOutputType pot = targetTool.getPrimaryOutputType(); String prefix = pot.getOutputPrefix(); + + // Resolve any macros in the outputPrefix + // Note that we cannot use file macros because if we do a clean + // we need to know the actual + // name of the file to clean, and cannot use any builder + // variables such as $@. Hence + // we use the next best thing, i.e. configuration context. + + // figure out the configuration we're using + IBuildObject toolParent = targetTool.getParent(); + IConfiguration config = null; + // if the parent is a config then we're done + if (toolParent instanceof IConfiguration) + config = (IConfiguration) toolParent; + else if (toolParent instanceof IToolChain) { + // must be a toolchain + config = (IConfiguration) ((IToolChain) toolParent) + .getParent(); + } + + else if (toolParent instanceof IResourceConfiguration) { + config = (IConfiguration) ((IResourceConfiguration) toolParent) + .getParent(); + } + + else { + // bad + throw new AssertionError( + "tool parent must be one of configuration, toolchain, or resource configuration"); + } + + if (config != null) { + + try { + prefix = ManagedBuildManager + .getBuildMacroProvider() + .resolveValueToMakefileFormat( + prefix, + "", //$NON-NLS-1$ + " ", //$NON-NLS-1$ + IBuildMacroProvider.CONTEXT_CONFIGURATION, + config); + } + + catch (BuildMacroException e) { + } + + } + if(prefix == null) prefix = EMPTY_STRING; macro = new BuildMacro(macroName,IBuildMacro.VALUE_TEXT,prefix); 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 a8fc14304b3..eab56f847ce 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 @@ -26,13 +26,17 @@ import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; /** * @since 2.0 */ public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerator { + private static final String EMPTY_STRING = new String(); private static final String[] EMPTY_STRING_ARRAY = new String[0]; + public final String WHITESPACE = " "; //$NON-NLS-1$ /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#findDependencies(org.eclipse.core.resources.IResource) @@ -149,6 +153,21 @@ public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerat cmdLInfo = cmdLGen.generateCommandLineInfo( tool, cmd, flags, outflag, outputPrefix, outputFile, inputs, tool.getCommandLinePattern() ); 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())); + if((resolvedCommand = resolvedCommand.trim()).length() > 0) + buildCmd = resolvedCommand; + + } catch (BuildMacroException e){ + } + + } else { String cmd = info.getToolForSource(inputExtension); //try to resolve the build macros in the tool command 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 ce88550698e..48ddcbd7d40 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 @@ -11,9 +11,16 @@ package org.eclipse.cdt.managedbuilder.makegen.gnu; +import org.eclipse.cdt.managedbuilder.core.IBuildObject; +import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IManagedOutputNameProvider; import org.eclipse.cdt.managedbuilder.core.IOption; +import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration; import org.eclipse.cdt.managedbuilder.core.ITool; +import org.eclipse.cdt.managedbuilder.core.IToolChain; +import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.cdt.managedbuilder.macros.BuildMacroException; +import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider; import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; @@ -79,6 +86,55 @@ public class GnuLinkOutputNameProvider implements IManagedOutputNameProvider { } else { // Add the outputPrefix String outputPrefix = tool.getPrimaryOutputType().getOutputPrefix(); + + // Resolve any macros in the outputPrefix + // Note that we cannot use file macros because if we do a clean + // we need to know the actual + // name of the file to clean, and cannot use any builder + // variables such as $@. Hence + // we use the next best thing, i.e. configuration context. + + // figure out the configuration we're using + IBuildObject toolParent = tool.getParent(); + IConfiguration config = null; + // if the parent is a config then we're done + if (toolParent instanceof IConfiguration) + config = (IConfiguration) toolParent; + else if (toolParent instanceof IToolChain) { + // must be a toolchain + config = (IConfiguration) ((IToolChain) toolParent) + .getParent(); + } + + else if (toolParent instanceof IResourceConfiguration) { + config = (IConfiguration) ((IResourceConfiguration) toolParent) + .getParent(); + } + + else { + // bad + throw new AssertionError( + "tool parent must be one of configuration, toolchain, or resource configuration"); + } + + if (config != null) { + + try { + outputPrefix = ManagedBuildManager + .getBuildMacroProvider() + .resolveValueToMakefileFormat( + outputPrefix, + "", //$NON-NLS-1$ + " ", //$NON-NLS-1$ + IBuildMacroProvider.CONTEXT_CONFIGURATION, + config); + } + + catch (BuildMacroException e) { + } + + } + if (outputPrefix != null && outputPrefix.length() > 0) { fileName = outputPrefix + fileName; } 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 b91989bbdfd..580c84ee916 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 @@ -1542,6 +1542,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { IManagedCommandLineGenerator gen = tool.getCommandLineGenerator(); IManagedCommandLineInfo cmdLInfo = gen.generateCommandLineInfo( tool, command, flags, outflag, outputPrefix, primaryOutputs, cmdInputs, tool.getCommandLinePattern() ); + // The command to build String buildCmd = null; if( cmdLInfo == null ) { @@ -1555,6 +1556,26 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { buildCmd = command + WHITESPACE + toolFlags + WHITESPACE + outflag + WHITESPACE + outputPrefix + primaryOutputs + WHITESPACE + IN_MACRO; } else 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(null, null, null, info + .getDefaultConfiguration() + .getToolChain())); + if ((resolvedCommand = resolvedCommand.trim()).length() > 0) + buildCmd = resolvedCommand; + + } catch (BuildMacroException e) { + } + + buffer.append(TAB + AT + ECHO + WHITESPACE + buildCmd + NEWLINE); buffer.append(TAB + AT + buildCmd); @@ -2265,6 +2286,28 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { OUT_MACRO + otherPrimaryOutputs, (String[])inputs.toArray(new String[inputs.size()]), tool.getCommandLinePattern() ); String 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(sourceLocation, + outputLocation, null, info + .getDefaultConfiguration() + .getToolChain())); + if ((resolvedCommand = resolvedCommand.trim()).length() > 0) + buildCmd = resolvedCommand; + + } catch (BuildMacroException e) { + } + + buffer.append(TAB + AT + ECHO + WHITESPACE + buildCmd + NEWLINE); buffer.append(TAB + AT + buildCmd); } else { @@ -2542,6 +2585,56 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { boolean primaryOutput = (type == tool.getPrimaryOutputType()); //if (primaryOutput && ignorePrimary) continue; String outputPrefix = type.getOutputPrefix(); + + // Resolve any macros in the outputPrefix + // Note that we cannot use file macros because if we do a clean + // we need to know the actual name of the file to clean, and + // cannot use any builder variables such as $@. Hence we use the + // next best thing, i.e. configuration context. + + // figure out the configuration we're using + IBuildObject toolParent = tool.getParent(); + IConfiguration config = null; + // if the parent is a config then we're done + if (toolParent instanceof IConfiguration) + config = (IConfiguration) toolParent; + else if (toolParent instanceof IToolChain) { + // must be a toolchain + config = (IConfiguration) ((IToolChain) toolParent) + .getParent(); + } + + else if (toolParent instanceof IResourceConfiguration) { + config = (IConfiguration) ((IResourceConfiguration) toolParent) + .getParent(); + } + + else { + // bad + throw new AssertionError( + "tool parent must be one of configuration, toolchain, or resource configuration"); + } + + if (config != null) { + + try { + outputPrefix = ManagedBuildManager + .getBuildMacroProvider() + .resolveValueToMakefileFormat( + outputPrefix, + "", //$NON-NLS-1$ + " ", //$NON-NLS-1$ + IBuildMacroProvider.CONTEXT_CONFIGURATION, + config); + } + + catch (BuildMacroException e) { + } + + } + + + boolean multOfType = type.getMultipleOfType(); IOption option = tool.getOptionBySuperClassId(type.getOptionId()); IManagedOutputNameProvider nameProvider = type.getNameProvider(); 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 0101f49c651..15e77c02c42 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 @@ -20,6 +20,7 @@ import java.util.HashMap; import java.util.HashSet; import org.eclipse.cdt.managedbuilder.core.IAdditionalInput; +import org.eclipse.cdt.managedbuilder.core.IBuildObject; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IInputType; import org.eclipse.cdt.managedbuilder.core.IOutputType; @@ -27,6 +28,7 @@ import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.IOption; import org.eclipse.cdt.managedbuilder.core.IManagedOutputNameProvider; import org.eclipse.cdt.managedbuilder.core.BuildException; +import org.eclipse.cdt.managedbuilder.core.IToolChain; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.macros.BuildMacroException; import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider; @@ -434,6 +436,31 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo { Vector typeEnumeratedOutputs = new Vector(); IOutputType type = outTypes[i]; String outputPrefix = type.getOutputPrefix(); + + // Resolve any macros in the outputPrefix + // Note that we cannot use file macros because if we do a clean + // we need to know the actual name of the file to clean, and + // cannot use any builder variables such as $@. Hence we use the + // next best thing, i.e. configuration context. + + if (config != null) { + + try { + outputPrefix = ManagedBuildManager + .getBuildMacroProvider() + .resolveValueToMakefileFormat( + outputPrefix, + "", //$NON-NLS-1$ + " ", //$NON-NLS-1$ + IBuildMacroProvider.CONTEXT_CONFIGURATION, + config); + } + + catch (BuildMacroException e) { + } + } + + String variable = type.getBuildVariable(); boolean multOfType = type.getMultipleOfType(); boolean primaryOutput = (type == tool.getPrimaryOutputType());