mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Fix for bug#150972
This commit is contained in:
parent
d80185bcd5
commit
ce1a8b474e
2 changed files with 71 additions and 14 deletions
|
@ -34,8 +34,11 @@ import org.eclipse.cdt.managedbuilder.core.ITool;
|
|||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.Tool;
|
||||
import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroSubstitutor;
|
||||
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
|
||||
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
|
||||
import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo;
|
||||
import org.eclipse.cdt.managedbuilder.internal.macros.IMacroSubstitutor;
|
||||
import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
|
||||
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
|
||||
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
|
||||
import org.eclipse.cdt.managedbuilder.macros.IFileContextData;
|
||||
|
@ -277,16 +280,17 @@ public class BuildStep implements IBuildStep {
|
|||
|
||||
IManagedCommandLineGenerator gen = fTool.getCommandLineGenerator();
|
||||
FileContextData data = new FileContextData(inRcPath, outRcPath, null, fTool);
|
||||
|
||||
IManagedCommandLineInfo info = gen.generateCommandLineInfo(fTool,
|
||||
resolveMacros(fTool.getToolCommand(), data, true),
|
||||
fTool.getToolCommand(),
|
||||
getCommandFlags(inRcPath, outRcPath, resolveAll),
|
||||
resolveMacros(fTool.getOutputFlag(), data, true),
|
||||
resolveMacros(fTool.getOutputPrefix(), data, true),
|
||||
fTool.getOutputFlag(),
|
||||
fTool.getOutputPrefix(),
|
||||
listToString(resourcesToStrings(cwd, getPrimaryResources(false)), " "), //$NON-NLS-1$
|
||||
resourcesToStrings(cwd, getPrimaryResources(true)),
|
||||
fTool.getCommandLinePattern());
|
||||
|
||||
return createCommandsFromString(info.getCommandLine(), cwd, getEnvironment());
|
||||
|
||||
return createCommandsFromString(resolveMacros(info.getCommandLine(), data, true), cwd, getEnvironment());
|
||||
}
|
||||
|
||||
private IPath calcCWD(){
|
||||
|
@ -381,25 +385,36 @@ public class BuildStep implements IBuildStep {
|
|||
}
|
||||
return (String[])list.toArray(new String[list.size()]);
|
||||
}
|
||||
|
||||
private String resolveMacros(String str, IFileContextData fileData, boolean resolveAll){
|
||||
String result = str;
|
||||
try {
|
||||
String tmp = resolveAll ? ManagedBuildManager.getBuildMacroProvider().resolveValue(str, "", " ", IBuildMacroProvider.CONTEXT_FILE, fileData) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
:
|
||||
ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(str, "", " ", IBuildMacroProvider.CONTEXT_FILE, fileData); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if((tmp = tmp.trim()).length() != 0)
|
||||
str = tmp;
|
||||
if(resolveAll){
|
||||
IMacroSubstitutor sub = createSubstitutor(fileData);
|
||||
result = MacroResolver.resolveToString(str, sub);
|
||||
} else {
|
||||
result = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(str, "", " ", IBuildMacroProvider.CONTEXT_FILE, fileData); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
} catch (BuildMacroException e) {
|
||||
}
|
||||
|
||||
return str;
|
||||
return result;
|
||||
}
|
||||
|
||||
private IMacroSubstitutor createSubstitutor(IFileContextData fileData){
|
||||
BuildMacroProvider prov = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
|
||||
IMacroContextInfo info = prov.getMacroContextInfo(IBuildMacroProvider.CONTEXT_FILE, fileData);
|
||||
FileMacroExplicitSubstitutor sub = new FileMacroExplicitSubstitutor(
|
||||
info,
|
||||
"", " "); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
return sub;
|
||||
}
|
||||
|
||||
private String[] getCommandFlags(IPath inRcPath, IPath outRcPath, boolean resolveAll){
|
||||
try {
|
||||
return resolveAll ?
|
||||
((Tool)fTool).getToolCommandFlags(inRcPath, outRcPath,
|
||||
new DefaultMacroSubstitutor(IBuildMacroProvider.CONTEXT_FILE, new FileContextData(inRcPath, outRcPath, null, fTool), "", " ")) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
createSubstitutor(new FileContextData(inRcPath, outRcPath, null, fTool)))
|
||||
:
|
||||
fTool.getToolCommandFlags(inRcPath, outRcPath);
|
||||
} catch (BuildException e) {
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.managedbuilder.internal.buildmodel;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroSubstitutor;
|
||||
import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo;
|
||||
import org.eclipse.cdt.managedbuilder.internal.macros.MbsMacroSupplier;
|
||||
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
|
||||
import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
|
||||
|
||||
public class FileMacroExplicitSubstitutor extends DefaultMacroSubstitutor {
|
||||
|
||||
public FileMacroExplicitSubstitutor(int contextType, Object contextData, String inexistentMacroValue, String listDelimiter){
|
||||
super(contextType, contextData, inexistentMacroValue, listDelimiter);
|
||||
}
|
||||
|
||||
public FileMacroExplicitSubstitutor(IMacroContextInfo contextInfo, String inexistentMacroValue, String listDelimiter){
|
||||
super(contextInfo, inexistentMacroValue, listDelimiter);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroSubstitutor#resolveMacro(org.eclipse.cdt.managedbuilder.macros.IBuildMacro)
|
||||
*/
|
||||
protected ResolvedMacro resolveMacro(IBuildMacro macro) throws BuildMacroException{
|
||||
if(macro instanceof MbsMacroSupplier.FileContextMacro){
|
||||
MbsMacroSupplier.FileContextMacro fileMacro = (MbsMacroSupplier.FileContextMacro)macro;
|
||||
String val = fileMacro.getExplicitMacroValue();
|
||||
return new ResolvedMacro(macro.getName(), val);
|
||||
}
|
||||
return super.resolveMacro(macro);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue