mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-27 02:45:32 +02:00
1.Additional fix for the [Bug 175581] Includes path entry not filled out with envVarBuildPath
2. Small UI fix to correctly get the builder command
This commit is contained in:
parent
527a0fb83e
commit
de47620e83
5 changed files with 421 additions and 73 deletions
|
@ -10,10 +10,15 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.internal.dataprovider;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.core.envvar.IEnvironmentContributor;
|
||||
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
|
||||
import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.internal.envvar.ExternalExtensionEnvironmentSupplier;
|
||||
import org.eclipse.cdt.managedbuilder.internal.envvar.MbsEnvironmentSupplier;
|
||||
import org.eclipse.cdt.utils.envvar.EnvironmentCollector;
|
||||
|
@ -21,33 +26,34 @@ import org.eclipse.cdt.utils.envvar.EnvironmentCollector;
|
|||
public class BuildEnvironmentContributor implements IEnvironmentContributor {
|
||||
private BuildBuildData fBuildData;
|
||||
private IConfiguration fCfg;
|
||||
private ICConfigurationDescription fCfgDes;
|
||||
|
||||
private MbsEnvironmentSupplier fMbsSupplier = new MbsEnvironmentSupplier();
|
||||
|
||||
public BuildEnvironmentContributor(BuildBuildData buildData){
|
||||
fBuildData = buildData;
|
||||
fCfg = fBuildData.getBuilder().getParent().getParent();
|
||||
fCfgDes = ManagedBuildManager.getDescriptionForConfiguration(fCfg);
|
||||
}
|
||||
|
||||
public IEnvironmentVariable getVariable(String name,
|
||||
IEnvironmentVariableManager provider) {
|
||||
|
||||
EnvironmentCollector collector = new EnvironmentCollector();
|
||||
IEnvironmentVariable result = null;
|
||||
ExternalExtensionEnvironmentSupplier extSupplier = new ExternalExtensionEnvironmentSupplier(provider);
|
||||
|
||||
boolean varFound = false;
|
||||
|
||||
IEnvironmentVariable var = extSupplier.getVariable(name, fCfg.getManagedProject());
|
||||
if(var != null)
|
||||
result = collector.addVariable(var);
|
||||
varFound = processVariable(name, var, collector, provider, varFound);
|
||||
|
||||
var = fMbsSupplier.getVariable(name, fCfg);
|
||||
if(var != null)
|
||||
result = collector.addVariable(var);
|
||||
varFound = processVariable(name, var, collector, provider, varFound);
|
||||
|
||||
var = extSupplier.getVariable(name, fCfg);
|
||||
if(var != null)
|
||||
result = collector.addVariable(var);
|
||||
return result;
|
||||
varFound = processVariable(name, var, collector, provider, varFound);
|
||||
|
||||
return collector.getVariable(name);
|
||||
}
|
||||
|
||||
public IEnvironmentVariable[] getVariables(
|
||||
|
@ -55,18 +61,59 @@ public class BuildEnvironmentContributor implements IEnvironmentContributor {
|
|||
EnvironmentCollector collector = new EnvironmentCollector();
|
||||
ExternalExtensionEnvironmentSupplier extSupplier = new ExternalExtensionEnvironmentSupplier(provider);
|
||||
|
||||
Set set = null;
|
||||
|
||||
IEnvironmentVariable vars[] = extSupplier.getVariables(fCfg.getManagedProject());
|
||||
if(vars != null && vars.length != 0)
|
||||
collector.addVariables(vars);
|
||||
set = processVariables(vars, collector, provider, set);
|
||||
|
||||
vars = fMbsSupplier.getVariables(fCfg);
|
||||
if(vars != null && vars.length != 0)
|
||||
collector.addVariables(vars);
|
||||
set = processVariables(vars, collector, provider, set);
|
||||
|
||||
vars = extSupplier.getVariables(fCfg);
|
||||
if(vars != null && vars.length != 0)
|
||||
collector.addVariables(vars);
|
||||
set = processVariables(vars, collector, provider, set);
|
||||
|
||||
return collector.getVariables();
|
||||
}
|
||||
|
||||
private boolean processVariable(String name, IEnvironmentVariable var, EnvironmentCollector collector, IEnvironmentVariableManager provider, boolean varFound){
|
||||
if(var != null){
|
||||
if(!varFound){
|
||||
varFound = true;
|
||||
IEnvironmentVariable base = provider.getVariable(name, fCfgDes, false);
|
||||
if(base != null)
|
||||
collector.addVariable(base);
|
||||
}
|
||||
collector.addVariable(var);
|
||||
}
|
||||
|
||||
return varFound;
|
||||
}
|
||||
|
||||
private Set processVariables(IEnvironmentVariable vars[], EnvironmentCollector collector, IEnvironmentVariableManager provider, Set set){
|
||||
boolean checkSet = true;
|
||||
if(vars != null && vars.length != 0){
|
||||
if(set == null){
|
||||
set = new HashSet();
|
||||
checkSet = false;
|
||||
}
|
||||
|
||||
for(int i = 0; i < vars.length; i++){
|
||||
if(vars[i] == null)
|
||||
continue;
|
||||
|
||||
if(set.add(vars[i].getName()) || !checkSet){
|
||||
IEnvironmentVariable base = provider.getVariable(vars[i].getName(), fCfgDes, false);
|
||||
if(base != null){
|
||||
collector.addVariable(base);
|
||||
}
|
||||
}
|
||||
|
||||
collector.addVariable(vars[i]);
|
||||
}
|
||||
//collector.addVariables(vars);
|
||||
}
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.eclipse.cdt.core.CCorePlugin;
|
|||
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
|
||||
import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.internal.core.envvar.EnvVarCollector;
|
||||
import org.eclipse.cdt.managedbuilder.core.IBuildPathResolver;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
|
||||
|
@ -47,9 +48,10 @@ public class EnvironmentVariableProvider implements
|
|||
private static EnvironmentVariableProvider fInstance = null;
|
||||
private List fListeners = null;
|
||||
private IEnvironmentVariableManager fMngr;
|
||||
private boolean fBuildPathVarCheckAllowed;
|
||||
|
||||
// private StoredBuildPathEnvironmentContainer fIncludeStoredBuildPathVariables;
|
||||
// private StoredBuildPathEnvironmentContainer fLibraryStoredBuildPathVariables;
|
||||
private StoredBuildPathEnvironmentContainer fIncludeStoredBuildPathVariables;
|
||||
private StoredBuildPathEnvironmentContainer fLibraryStoredBuildPathVariables;
|
||||
|
||||
/**
|
||||
* This class is used by the EnvironmentVariableProvider to calculate the build paths
|
||||
|
@ -77,14 +79,16 @@ public class EnvironmentVariableProvider implements
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected EnvironmentVariableProvider(IEnvironmentVariableManager mngr){
|
||||
fMngr = mngr;
|
||||
}
|
||||
|
||||
public static EnvironmentVariableProvider getDefault(){
|
||||
if(fInstance == null)
|
||||
if(fInstance == null){
|
||||
fInstance = new EnvironmentVariableProvider(CCorePlugin.getDefault().getBuildEnvironmentManager());
|
||||
fInstance.fBuildPathVarCheckAllowed = true;
|
||||
}
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
|
@ -102,20 +106,35 @@ public class EnvironmentVariableProvider implements
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public IEnvironmentVariable getVariable(String variableName,
|
||||
IConfiguration cfg, boolean resolveMacros){
|
||||
return getVariable(variableName, cfg, resolveMacros, true);
|
||||
}
|
||||
|
||||
public IEnvironmentVariable getVariable(String variableName,
|
||||
IConfiguration cfg, boolean resolveMacros, boolean checkBuildPaths){
|
||||
ICConfigurationDescription des = ManagedBuildManager.getDescriptionForConfiguration(cfg);
|
||||
if(des != null){
|
||||
return fMngr.getVariable(variableName, des, resolveMacros);
|
||||
IEnvironmentVariable variable = fMngr.getVariable(variableName, des, resolveMacros);
|
||||
if(checkBuildPaths && resolveMacros && fBuildPathVarCheckAllowed)
|
||||
checkBuildPathVariable(cfg, variableName, variable);
|
||||
return variable;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public IEnvironmentVariable[] getVariables(IConfiguration cfg, boolean resolveMacros){
|
||||
return getVariables(cfg, resolveMacros, true);
|
||||
}
|
||||
|
||||
public IEnvironmentVariable[] getVariables(IConfiguration cfg, boolean resolveMacros, boolean checkBuildPaths){
|
||||
ICConfigurationDescription des = ManagedBuildManager.getDescriptionForConfiguration(cfg);
|
||||
if(des != null){
|
||||
return fMngr.getVariables(des, resolveMacros);
|
||||
IEnvironmentVariable vars[] = fMngr.getVariables(des, resolveMacros);
|
||||
if(checkBuildPaths && resolveMacros && fBuildPathVarCheckAllowed)
|
||||
checkBuildPathVariables(cfg,vars);
|
||||
return vars;
|
||||
}
|
||||
return new IBuildEnvironmentVariable[0];
|
||||
}
|
||||
|
@ -217,7 +236,7 @@ public class EnvironmentVariableProvider implements
|
|||
for(int k = 0; k < vars.length; k++){
|
||||
String varName = vars[k];
|
||||
|
||||
IEnvironmentVariable var = getVariable(varName,configuration,true);
|
||||
IEnvironmentVariable var = getVariable(varName,configuration,true, false);
|
||||
if(var == null)
|
||||
continue;
|
||||
|
||||
|
@ -280,18 +299,20 @@ public class EnvironmentVariableProvider implements
|
|||
* performs a check of the build path variables for the given configuration
|
||||
* If the build variables are changed, the notification is sent
|
||||
*/
|
||||
// public void checkBuildPathVariables(IConfiguration configuration){
|
||||
// checkBuildPathVariables(configuration,getVariables(getContextInfo(configuration),true));
|
||||
// }
|
||||
public void checkBuildPathVariables(IConfiguration configuration){
|
||||
checkBuildPathVariables(configuration, getVariables(configuration ,true, false));
|
||||
}
|
||||
|
||||
/*
|
||||
* performs a check of the build path variables of the specified type
|
||||
* for the given configuration
|
||||
* If the build variables are changed, the notification is sent
|
||||
*/
|
||||
// public void checkBuildPathVariables(IConfiguration configuration,int buildPathType){
|
||||
// checkBuildPathVariables(configuration,buildPathType,getVariables(getContextInfo(configuration),true));
|
||||
// }
|
||||
public void checkBuildPathVariables(IConfiguration configuration,int buildPathType){
|
||||
EnvVarCollector cr = new EnvVarCollector();
|
||||
cr.add(getVariables(configuration, true, false));
|
||||
checkBuildPathVariables(configuration,buildPathType,cr);
|
||||
}
|
||||
|
||||
/*
|
||||
* performs a check of the build path variables
|
||||
|
@ -299,10 +320,12 @@ public class EnvironmentVariableProvider implements
|
|||
* defined for this configuration
|
||||
* If the build variables are changed, the notification is sent
|
||||
*/
|
||||
// protected void checkBuildPathVariables(IConfiguration configuration, EnvVarCollector varSet){
|
||||
// checkBuildPathVariables(configuration,IEnvVarBuildPath.BUILDPATH_INCLUDE,varSet);
|
||||
// checkBuildPathVariables(configuration,IEnvVarBuildPath.BUILDPATH_LIBRARY,varSet);
|
||||
// }
|
||||
protected void checkBuildPathVariables(IConfiguration configuration, IEnvironmentVariable vars[]){
|
||||
EnvVarCollector cr = new EnvVarCollector();
|
||||
cr.add(vars);
|
||||
checkBuildPathVariables(configuration,IEnvVarBuildPath.BUILDPATH_INCLUDE,cr);
|
||||
checkBuildPathVariables(configuration,IEnvVarBuildPath.BUILDPATH_LIBRARY,cr);
|
||||
}
|
||||
|
||||
/*
|
||||
* performs a check of whether the given variable is the build path variable
|
||||
|
@ -312,10 +335,10 @@ public class EnvironmentVariableProvider implements
|
|||
* If it is not changed, other build path variables are not checked
|
||||
* In the case of the given variable is not the build path one, this method does nothing
|
||||
*/
|
||||
// protected void checkBuildPathVariable(IConfiguration configuration, String varName, EnvVarDescriptor var){
|
||||
// checkBuildPathVariable(configuration, IEnvVarBuildPath.BUILDPATH_INCLUDE, varName, var);
|
||||
// checkBuildPathVariable(configuration, IEnvVarBuildPath.BUILDPATH_LIBRARY, varName, var);
|
||||
// }
|
||||
protected void checkBuildPathVariable(IConfiguration configuration, String varName, IEnvironmentVariable var){
|
||||
checkBuildPathVariable(configuration, IEnvVarBuildPath.BUILDPATH_INCLUDE, varName, var);
|
||||
checkBuildPathVariable(configuration, IEnvVarBuildPath.BUILDPATH_LIBRARY, varName, var);
|
||||
}
|
||||
|
||||
/*
|
||||
* performs a check of whether the given variable is the build path variable
|
||||
|
@ -325,15 +348,17 @@ public class EnvironmentVariableProvider implements
|
|||
* If it is not changed, other build path variables are not checked
|
||||
* In the case of the given variable is not the build path one, this method does nothing
|
||||
*/
|
||||
// protected void checkBuildPathVariable(IConfiguration configuration, int buildPathType, String varName, EnvVarDescriptor var){
|
||||
// StoredBuildPathEnvironmentContainer buildPathVars = getStoredBuildPathVariables(buildPathType);
|
||||
// if(buildPathVars == null)
|
||||
// return;
|
||||
// if(buildPathVars.isVariableChanged(varName,var,configuration)){
|
||||
// buildPathVars.synchronize(getVariables(getContextInfo(configuration),true),configuration);
|
||||
// notifyListeners(configuration, buildPathType);
|
||||
// }
|
||||
// }
|
||||
protected void checkBuildPathVariable(IConfiguration configuration, int buildPathType, String varName, IEnvironmentVariable var){
|
||||
StoredBuildPathEnvironmentContainer buildPathVars = getStoredBuildPathVariables(buildPathType);
|
||||
if(buildPathVars == null)
|
||||
return;
|
||||
if(buildPathVars.isVariableChanged(varName,var,configuration)){
|
||||
EnvVarCollector cr = new EnvVarCollector();
|
||||
cr.add(getVariables(configuration, true, false));
|
||||
buildPathVars.synchronize(cr,configuration);
|
||||
notifyListeners(configuration, buildPathType);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* performs a check of the build path variables of the specified type
|
||||
|
@ -341,39 +366,39 @@ public class EnvironmentVariableProvider implements
|
|||
* defined for this configuration.
|
||||
* If the build variables are changed, the notification is sent
|
||||
*/
|
||||
// protected void checkBuildPathVariables(IConfiguration configuration, int buildPathType, EnvVarCollector varSet){
|
||||
// StoredBuildPathEnvironmentContainer buildPathVars = getStoredBuildPathVariables(buildPathType);
|
||||
// if(buildPathVars == null)
|
||||
// return;
|
||||
// if(buildPathVars.checkBuildPathChange(varSet,configuration)){
|
||||
// notifyListeners(configuration, buildPathType);
|
||||
// }
|
||||
// }
|
||||
protected void checkBuildPathVariables(IConfiguration configuration, int buildPathType, EnvVarCollector varSet){
|
||||
StoredBuildPathEnvironmentContainer buildPathVars = getStoredBuildPathVariables(buildPathType);
|
||||
if(buildPathVars == null)
|
||||
return;
|
||||
if(buildPathVars.checkBuildPathChange(varSet,configuration)){
|
||||
notifyListeners(configuration, buildPathType);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* returns the container of the build variables of the specified type
|
||||
*/
|
||||
// protected StoredBuildPathEnvironmentContainer getStoredBuildPathVariables(int buildPathType){
|
||||
// return buildPathType == IEnvVarBuildPath.BUILDPATH_LIBRARY ?
|
||||
// getStoredLibraryBuildPathVariables() :
|
||||
// getStoredIncludeBuildPathVariables();
|
||||
// }
|
||||
protected StoredBuildPathEnvironmentContainer getStoredBuildPathVariables(int buildPathType){
|
||||
return buildPathType == IEnvVarBuildPath.BUILDPATH_LIBRARY ?
|
||||
getStoredLibraryBuildPathVariables() :
|
||||
getStoredIncludeBuildPathVariables();
|
||||
}
|
||||
|
||||
/*
|
||||
* returns the container of the Include path variables
|
||||
*/
|
||||
// protected StoredBuildPathEnvironmentContainer getStoredIncludeBuildPathVariables(){
|
||||
// if(fIncludeStoredBuildPathVariables == null)
|
||||
// fIncludeStoredBuildPathVariables = new StoredBuildPathEnvironmentContainer(IEnvVarBuildPath.BUILDPATH_INCLUDE);
|
||||
// return fIncludeStoredBuildPathVariables;
|
||||
// }
|
||||
protected StoredBuildPathEnvironmentContainer getStoredIncludeBuildPathVariables(){
|
||||
if(fIncludeStoredBuildPathVariables == null)
|
||||
fIncludeStoredBuildPathVariables = new StoredBuildPathEnvironmentContainer(IEnvVarBuildPath.BUILDPATH_INCLUDE);
|
||||
return fIncludeStoredBuildPathVariables;
|
||||
}
|
||||
|
||||
/*
|
||||
* returns the container of the Library path variables
|
||||
*/
|
||||
// protected StoredBuildPathEnvironmentContainer getStoredLibraryBuildPathVariables(){
|
||||
// if(fLibraryStoredBuildPathVariables == null)
|
||||
// fLibraryStoredBuildPathVariables = new StoredBuildPathEnvironmentContainer(IEnvVarBuildPath.BUILDPATH_LIBRARY);
|
||||
// return fLibraryStoredBuildPathVariables;
|
||||
// }
|
||||
protected StoredBuildPathEnvironmentContainer getStoredLibraryBuildPathVariables(){
|
||||
if(fLibraryStoredBuildPathVariables == null)
|
||||
fLibraryStoredBuildPathVariables = new StoredBuildPathEnvironmentContainer(IEnvVarBuildPath.BUILDPATH_LIBRARY);
|
||||
return fLibraryStoredBuildPathVariables;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,276 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 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.envvar;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
|
||||
import org.eclipse.cdt.internal.core.envvar.EnvVarCollector;
|
||||
import org.eclipse.cdt.internal.core.envvar.EnvVarDescriptor;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
|
||||
import org.eclipse.cdt.utils.envvar.StorableEnvironment;
|
||||
import org.eclipse.cdt.utils.envvar.StorableEnvironmentLoader;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.ProjectScope;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.osgi.service.prefs.Preferences;
|
||||
|
||||
/**
|
||||
* This class holds the build path variable values and allows
|
||||
* checking the stored variable values with the values of the current environment environment
|
||||
*
|
||||
* @since 3.0
|
||||
*
|
||||
*/
|
||||
public class StoredBuildPathEnvironmentContainer extends
|
||||
StorableEnvironmentLoader {
|
||||
public static final String NODENAME = "environment"; //$NON-NLS-1$
|
||||
public static final String NODENAME_PREFIX_CFG = "buildEnvironment"; //$NON-NLS-1$
|
||||
public static final String NODENAME_CFG_INCLUDE = NODENAME_PREFIX_CFG + "Include"; //$NON-NLS-1$
|
||||
public static final String NODENAME_CFG_LIBRARY = NODENAME_PREFIX_CFG + "Library"; //$NON-NLS-1$
|
||||
|
||||
private IConfiguration fConfiguration;
|
||||
private StorableEnvironment fEnvironment;
|
||||
private int fPathType;
|
||||
private boolean fIsVariableCaseSensitive = ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive();
|
||||
|
||||
public StoredBuildPathEnvironmentContainer(int pathType){
|
||||
fPathType = pathType == IEnvVarBuildPath.BUILDPATH_LIBRARY ?
|
||||
IEnvVarBuildPath.BUILDPATH_LIBRARY : IEnvVarBuildPath.BUILDPATH_INCLUDE;
|
||||
}
|
||||
|
||||
protected StorableEnvironment getEnvironment(Object context) {
|
||||
StorableEnvironment env = null;
|
||||
if(context instanceof IConfiguration){
|
||||
if(fConfiguration != null && context == fConfiguration && fEnvironment != null)
|
||||
env = fEnvironment;
|
||||
else {
|
||||
env = loadEnvironment(context, false);
|
||||
if(env != null){
|
||||
if(fConfiguration != null && fEnvironment != null){
|
||||
try{
|
||||
storeEnvironment(fEnvironment,fConfiguration,false, false);
|
||||
}catch(CoreException e){
|
||||
}
|
||||
}
|
||||
|
||||
checkLoadedVarNames(env,context);
|
||||
|
||||
fConfiguration = (IConfiguration)context;
|
||||
fEnvironment = env;
|
||||
}
|
||||
}
|
||||
}
|
||||
return env;
|
||||
}
|
||||
|
||||
private boolean haveIdenticalValues(IEnvironmentVariable var1,
|
||||
IEnvironmentVariable var2){
|
||||
if(var1 == null)
|
||||
return var2 == null || var2.getOperation() == IBuildEnvironmentVariable.ENVVAR_REMOVE;
|
||||
if(var2 == null)
|
||||
return var1 == null || var1.getOperation() == IBuildEnvironmentVariable.ENVVAR_REMOVE;
|
||||
int op1 = var1.getOperation();
|
||||
int op2 = var2.getOperation();
|
||||
if(op1 == IBuildEnvironmentVariable.ENVVAR_REMOVE ||
|
||||
op2 == IBuildEnvironmentVariable.ENVVAR_REMOVE)
|
||||
return op1 == op2;
|
||||
|
||||
return maskNull(var1.getValue()).equals(maskNull(var2.getValue()));
|
||||
}
|
||||
|
||||
private String maskNull(String val){
|
||||
return val == null ? "" : val; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public boolean checkBuildPathChange(EnvVarCollector existingVariables,
|
||||
IConfiguration configuration){
|
||||
StorableEnvironment env = getEnvironment(configuration);
|
||||
if(env == null)
|
||||
return false;
|
||||
IEnvironmentVariable vars[] = env.getVariables();
|
||||
for(int i = 0; i < vars.length; i++){
|
||||
IEnvironmentVariable var = vars[i];
|
||||
String name = var.getName();
|
||||
EnvVarDescriptor des = existingVariables != null ?
|
||||
existingVariables.getVariable(name) : null;
|
||||
// EnvironmentVariableProvider provider = ((EnvironmentVariableProvider)ManagedBuildManager.getEnvironmentVariableProvider());
|
||||
IEnvironmentVariable curVar = des/* != null ?
|
||||
provider.getVariable(des.getName(), configuration, true, false) : null*/;
|
||||
if(!haveIdenticalValues(var,curVar)){
|
||||
if(curVar == null){
|
||||
env.createVariable(name,null,IBuildEnvironmentVariable.ENVVAR_REMOVE,null);
|
||||
}
|
||||
else{
|
||||
env.createVariable(curVar.getName(),curVar.getValue(),curVar.getOperation(),curVar.getDelimiter());
|
||||
}
|
||||
}
|
||||
}
|
||||
boolean changed = env.isChanged();
|
||||
env.setChanged(false);
|
||||
if(changed && !configuration.isTemporary())
|
||||
try{
|
||||
storeEnvironment(env,configuration, false, false);
|
||||
}catch(CoreException e){
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
/*
|
||||
* checks whether the variable of a given name is the build path variable
|
||||
* for the given configuration
|
||||
* If it is, than performs a check and returns true if the variable was changed
|
||||
* If it is not the build path variable, no check is performed and this method always
|
||||
* returns false in this case
|
||||
*/
|
||||
public boolean isVariableChanged(String name,
|
||||
IEnvironmentVariable variable,
|
||||
IConfiguration configuration){
|
||||
StorableEnvironment env = getEnvironment(configuration);
|
||||
if(env == null)
|
||||
return false;
|
||||
IEnvironmentVariable var = env.getVariable(name);
|
||||
if(var == null)
|
||||
return false;
|
||||
|
||||
// EnvironmentVariableProvider provider = (EnvironmentVariableProvider)ManagedBuildManager.getEnvironmentVariableProvider();
|
||||
// variable = provider.getVariable(name, configuration, true, false);
|
||||
|
||||
if(haveIdenticalValues(var,variable))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* synchronizes the stored variables with the ones passed to this method
|
||||
*/
|
||||
public void synchronize(EnvVarCollector existingVariables,
|
||||
IConfiguration configuration){
|
||||
checkBuildPathChange(existingVariables,configuration);
|
||||
}
|
||||
|
||||
private void checkLoadedVarNames(StorableEnvironment env, Object context){
|
||||
String varNames[] = getBuildPathVarNames((IConfiguration)context, fPathType);
|
||||
for(int i = 0; i < varNames.length; i++){
|
||||
String name = varNames[i];
|
||||
if(env.getVariable(name) == null)
|
||||
env.createVariable(name,null,IBuildEnvironmentVariable.ENVVAR_REMOVE,null);
|
||||
}
|
||||
|
||||
IEnvironmentVariable vars[] = env.getVariables();
|
||||
for(int i = 0; i < vars.length; i++){
|
||||
IEnvironmentVariable var = vars[i];
|
||||
boolean validVar = false;
|
||||
for(int j = 0; j < varNames.length; j++){
|
||||
String varName = varNames[j];
|
||||
if(varNamesEqual(var.getName(),varName)){
|
||||
validVar = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!validVar){
|
||||
env.deleteVariable(var.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* returns true if the variable names are equal and false otherwise
|
||||
*/
|
||||
private boolean varNamesEqual(String name1, String name2){
|
||||
return fIsVariableCaseSensitive ?
|
||||
name1.equals(name2) : name1.equalsIgnoreCase(name2);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.internal.envvar.StorableEnvironmentLoader#getSerializeInfo(java.lang.Object)
|
||||
*/
|
||||
protected ISerializeInfo getSerializeInfo(Object context) {
|
||||
ISerializeInfo serializeInfo = null;
|
||||
if(context instanceof IConfiguration){
|
||||
IConfiguration cfg = (IConfiguration)context;
|
||||
final Preferences prefs = getConfigurationNode(cfg);
|
||||
final String name = cfg.getId();
|
||||
if(prefs != null && name != null)
|
||||
serializeInfo = new ISerializeInfo(){
|
||||
public Preferences getNode(){
|
||||
return prefs;
|
||||
}
|
||||
|
||||
public String getPrefName(){
|
||||
return name;
|
||||
}
|
||||
};
|
||||
}
|
||||
return serializeInfo;
|
||||
}
|
||||
|
||||
public void serialize(boolean force) {
|
||||
if(fEnvironment != null){
|
||||
try{
|
||||
storeEnvironment(fEnvironment,fConfiguration,force, true);
|
||||
}catch(CoreException e){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Preferences getConfigurationNode(IConfiguration cfg){
|
||||
IProject project = (IProject)cfg.getOwner();
|
||||
if(project == null || !project.exists())
|
||||
return null;
|
||||
|
||||
Preferences prefNode = new ProjectScope(project).getNode(ManagedBuilderCorePlugin.getUniqueIdentifier());
|
||||
if(prefNode == null)
|
||||
return null;
|
||||
|
||||
prefNode = prefNode.node(NODENAME);
|
||||
if(prefNode == null)
|
||||
return null;
|
||||
|
||||
if(fPathType == IEnvVarBuildPath.BUILDPATH_LIBRARY)
|
||||
return prefNode.node(NODENAME_CFG_LIBRARY);
|
||||
return prefNode.node(NODENAME_CFG_INCLUDE);
|
||||
}
|
||||
|
||||
private String[] getBuildPathVarNames(IConfiguration configuration,int buildPathType){
|
||||
ITool tools[] = configuration.getFilteredTools();
|
||||
List list = new ArrayList();
|
||||
|
||||
for(int i = 0; i < tools.length; i++){
|
||||
IEnvVarBuildPath pathDescriptors[] = tools[i].getEnvVarBuildPaths();
|
||||
|
||||
if(pathDescriptors == null || pathDescriptors.length == 0)
|
||||
continue;
|
||||
|
||||
for(int j = 0; j < pathDescriptors.length; j++){
|
||||
IEnvVarBuildPath curPathDes = pathDescriptors[j];
|
||||
if(curPathDes.getType() != buildPathType)
|
||||
continue;
|
||||
|
||||
String vars[] = curPathDes.getVariableNames();
|
||||
if(vars == null || vars.length == 0)
|
||||
continue;
|
||||
|
||||
list.addAll(Arrays.asList(vars));
|
||||
}
|
||||
}
|
||||
|
||||
return (String[])list.toArray(new String[list.size()]);
|
||||
}
|
||||
}
|
|
@ -402,8 +402,8 @@ public class BuilderSettingsTab extends AbstractCBuildPropertyTab {
|
|||
* @return
|
||||
*/
|
||||
private String getMC() {
|
||||
String makeCommand = bld.getBuildCommand().toOSString();
|
||||
String makeArgs = bld.getBuildArguments();
|
||||
String makeCommand = bld.getCommand();
|
||||
String makeArgs = bld.getArguments();
|
||||
if (makeArgs != null) { makeCommand += " " + makeArgs; } //$NON-NLS-1$
|
||||
return makeCommand;
|
||||
}
|
||||
|
|
|
@ -52,14 +52,14 @@ public class EnvVarOperationProcessor {
|
|||
String delimiter = added.getDelimiter();
|
||||
return new EnvirinmentVariable(name,
|
||||
performAppend(initial.getValue(),added.getValue(),delimiter),
|
||||
IEnvironmentVariable.ENVVAR_APPEND,
|
||||
// IEnvironmentVariable.ENVVAR_APPEND,
|
||||
delimiter);
|
||||
}
|
||||
case IEnvironmentVariable.ENVVAR_PREPEND:{
|
||||
String delimiter = added.getDelimiter();
|
||||
return new EnvirinmentVariable(name,
|
||||
performPrepend(initial.getValue(),added.getValue(),delimiter),
|
||||
IEnvironmentVariable.ENVVAR_PREPEND,
|
||||
// IEnvironmentVariable.ENVVAR_PREPEND,
|
||||
delimiter);
|
||||
}
|
||||
case IEnvironmentVariable.ENVVAR_REPLACE:
|
||||
|
|
Loading…
Add table
Reference in a new issue