1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix for [Bug 202805] custom IManagedBuilderMakefileGenerator.getBuildWorkingDir() is nor called

This commit is contained in:
Mikhail Sennikovsky 2007-09-10 16:25:08 +00:00
parent 8d1c3416a8
commit e67e534b88
3 changed files with 66 additions and 32 deletions

View file

@ -357,7 +357,7 @@ public class ProjectModelTests extends TestCase implements IElementChangedListen
cfgDes = cfgDess[0];
rf = cfgDes.getRootFolderDescription();
settings = rf.getLanguageSettings();
ICLanguageSettingEntry updatedEntries[] = null;
ICLanguageSettingEntry updatedEntries[] = new ICLanguageSettingEntry[0];
for(int i = 0; i < settings.length; i++){
ICLanguageSetting setting = settings[i];
ICLanguageSettingEntry[] entries = setting.getSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH);

View file

@ -55,11 +55,13 @@ import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator2;
import org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.PluginVersionIdentifier;
@ -377,8 +379,10 @@ public class Builder extends BuildObject implements IBuilder, IMatchKeyProvider
if(builder.customizedEnvironment != null)
customizedEnvironment = (HashMap)builder.customizedEnvironment.clone();
appendEnvironment = builder.appendEnvironment;
if(!getBuildPath().equals(builder.getBuildPath()))
setBuildPath(builder.getBuildPath());
if(isBuildPathEditable()){
if(!getBuildPath().equals(builder.getBuildPath()))
setBuildPath(builder.getBuildPath());
}
if(builder.customBuildProperties != null)
customBuildProperties = (HashMap)builder.customBuildProperties.clone();
@ -1728,31 +1732,62 @@ public class Builder extends BuildObject implements IBuilder, IMatchKeyProvider
return path;
}
private boolean isBuildPathEditable(){
return !isManagedBuildOn();
}
public String getDefaultBuildPath(){
Configuration cfg = (Configuration)getConfguration();
String path = null;
IPath buildPath;
String result;
// Builder extBuilder = (Builder)ManagedBuildManager.getExtensionBuilder(this);
// String attr = extBuilder.getBuildPathAttribute();
if(cfg != null){
if(isManagedBuildOn()){
path = cfg.getName();
}
if(!isExtensionElement() && !cfg.isPreference()){
IProject project = cfg.getOwner().getProject();
IPath buildPath = project.getFullPath();
IStringVariableManager mngr = VariablesPlugin.getDefault().getStringVariableManager();
if(path != null)
buildPath = buildPath.append(path);
path = buildPath.toString();
path = mngr.generateVariableExpression("workspace_loc", path); //$NON-NLS-1$
// if(attr == null){
if(isManagedBuildOn()){
IManagedBuilderMakefileGenerator gen = getBuildFileGenerator();
if(gen instanceof IManagedBuilderMakefileGenerator2){
((IManagedBuilderMakefileGenerator2)gen).initialize(IncrementalProjectBuilder.FULL_BUILD, cfg, this, new NullProgressMonitor());
} else {
gen.initialize(project, ManagedBuildManager.getBuildInfo(project), new NullProgressMonitor());
}
buildPath = gen.getBuildWorkingDir();
if(buildPath == null)
buildPath = new Path(cfg.getName());
} else {
buildPath = Path.EMPTY;
}
// } else {
// buildPath = new Path(attr);
// }
if(!buildPath.isAbsolute()){
buildPath = project.getFullPath().append(buildPath);
IStringVariableManager mngr = VariablesPlugin.getDefault().getStringVariableManager();
result = buildPath.toString();
result = mngr.generateVariableExpression("workspace_loc", result); //$NON-NLS-1$
} else {
result = buildPath.toString();
}
} else {
if(isManagedBuildOn()){
result = cfg.getName();
if(result == null)
result = ""; //$NON-NLS-1$
} else {
result = ""; //$NON-NLS-1$
}
}
} else {
result = ""; //$NON-NLS-1$
}
if(path == null){
path = ""; //$NON-NLS-1$
}
return path;
return result;
}
/* public boolean isWorkspaceBuildPath(){

View file

@ -21,7 +21,6 @@ import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
/**
* This is the Environment Variable Supplier used to supply variables
@ -30,10 +29,10 @@ import org.eclipse.core.runtime.Path;
* @since 3.0
*/
public class MbsEnvironmentSupplier implements IEnvironmentVariableSupplier {
private static final String fVariableNames[] = new String[]{
"CWD", //$NON-NLS-1$
"PWD" //$NON-NLS-1$
};
// private static final String fVariableNames[] = new String[]{
// "CWD", //$NON-NLS-1$
// "PWD" //$NON-NLS-1$
// };
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariable()
@ -76,14 +75,14 @@ public class MbsEnvironmentSupplier implements IEnvironmentVariableSupplier {
*/
public IEnvironmentVariable[] getVariables(Object context) {
if(context instanceof IConfiguration){
List variables = new ArrayList(fVariableNames.length);
for(int i = 0; i < fVariableNames.length; i++){
IBuildEnvironmentVariable var = getConfigurationVariable(fVariableNames[i],(IConfiguration)context);
if(var != null)
variables.add(var);
}
if(variables.size() == 0)
List variables = new ArrayList(2);
IBuildEnvironmentVariable var = getConfigurationVariable("CWD",(IConfiguration)context);
if(var != null){
variables.add(var);
variables.add(new BuildEnvVar("PWD", var.getValue(), IBuildEnvironmentVariable.ENVVAR_REPLACE, null));
} else {
return null;
}
return (IEnvironmentVariable[])variables.toArray(new IBuildEnvironmentVariable[variables.size()]);
}
return null;