mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Cosmetics - JavaDoc and code formatting
This commit is contained in:
parent
b4f9e7052e
commit
d1bb13b08c
8 changed files with 330 additions and 406 deletions
|
@ -14,7 +14,6 @@ import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* this interface represent the environment variable provider - the main entry-point
|
* this interface represent the environment variable provider - the main entry-point
|
||||||
* to be used for querying the build environment
|
* to be used for querying the build environment
|
||||||
*
|
*
|
||||||
|
@ -22,13 +21,11 @@ import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
* @noextend This class is not intended to be subclassed by clients.
|
* @noextend This class is not intended to be subclassed by clients.
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface IEnvironmentVariableProvider{
|
public interface IEnvironmentVariableProvider {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
*
|
|
||||||
* @return the reference to the IBuildEnvironmentVariable interface representing
|
* @return the reference to the IBuildEnvironmentVariable interface representing
|
||||||
* the variable of a given name
|
* the variable of a given name
|
||||||
|
*
|
||||||
* @param variableName environment variable name
|
* @param variableName environment variable name
|
||||||
* if environment variable names are case insensitive in the current OS,
|
* if environment variable names are case insensitive in the current OS,
|
||||||
* the environment variable provider will query the getVariable method of suppliers always
|
* the environment variable provider will query the getVariable method of suppliers always
|
||||||
|
@ -48,17 +45,27 @@ public interface IEnvironmentVariableProvider{
|
||||||
* 2. IManagedProject to represent the managed project
|
* 2. IManagedProject to represent the managed project
|
||||||
* 3. IWorkspace to represent the workspace
|
* 3. IWorkspace to represent the workspace
|
||||||
* 4. null to represent the system environment passed to eclipse
|
* 4. null to represent the system environment passed to eclipse
|
||||||
|
*
|
||||||
* @deprecated use {@link IEnvironmentVariableProvider#getVariable(String, IConfiguration, boolean)} instead
|
* @deprecated use {@link IEnvironmentVariableProvider#getVariable(String, IConfiguration, boolean)} instead
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public IBuildEnvironmentVariable getVariable(
|
public IBuildEnvironmentVariable getVariable(String variableName, Object level, boolean includeParentLevels, boolean resolveMacros);
|
||||||
String variableName, Object level, boolean includeParentLevels, boolean resolveMacros);
|
|
||||||
|
|
||||||
public IEnvironmentVariable getVariable(String variableName,
|
|
||||||
IConfiguration cfg, boolean resolveMacros);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Get variable for the given configuration, normally including those defined in project properties
|
||||||
|
* and workspace preferences.
|
||||||
*
|
*
|
||||||
|
* See also {@code CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(String name, ICConfigurationDescription cfg, boolean resolveMacros)}
|
||||||
|
*
|
||||||
|
* @param variableName - name of the variable (not including $ sign).
|
||||||
|
* @param cfg - configuration or {@code null} for workspace preferences only.
|
||||||
|
* @param resolveMacros - if {@code true} expand macros, {@code false} otherwise.
|
||||||
|
* @return variable defined for the configuration or the workspace.
|
||||||
|
* Returns {@code null} if variable is not defined.
|
||||||
|
*/
|
||||||
|
public IEnvironmentVariable getVariable(String variableName, IConfiguration cfg, boolean resolveMacros);
|
||||||
|
|
||||||
|
/**
|
||||||
* if environment variable names are case insensitive in the current OS,
|
* if environment variable names are case insensitive in the current OS,
|
||||||
* the environment variable provider will remove the duplicates of the variables if their names
|
* the environment variable provider will remove the duplicates of the variables if their names
|
||||||
* differ only by case
|
* differ only by case
|
||||||
|
@ -67,14 +74,22 @@ public interface IEnvironmentVariableProvider{
|
||||||
* @return the array of IBuildEnvironmentVariable that represents the environment variables
|
* @return the array of IBuildEnvironmentVariable that represents the environment variables
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public IBuildEnvironmentVariable[] getVariables(
|
public IBuildEnvironmentVariable[] getVariables(Object level, boolean includeParentLevels, boolean resolveMacros);
|
||||||
Object level, boolean includeParentLevels, boolean resolveMacros);
|
|
||||||
|
|
||||||
public IEnvironmentVariable[] getVariables(
|
|
||||||
IConfiguration cfg, boolean resolveMacros);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Get variables for the given configuration, normally including those defined in project properties
|
||||||
|
* and workspace preferences.
|
||||||
*
|
*
|
||||||
|
* See also {@code CCorePlugin.getDefault().getBuildEnvironmentManager().getVariables(ICConfigurationDescription cfg, boolean resolveMacros)}
|
||||||
|
*
|
||||||
|
* @param cfg - configuration or {@code null} for workspace preferences only.
|
||||||
|
* @param resolveMacros - if {@code true} expand macros, {@code false} otherwise.
|
||||||
|
* @return array of variables defined for the configuration or the workspace.
|
||||||
|
* Returns an empty array if no variables are defined.
|
||||||
|
*/
|
||||||
|
public IEnvironmentVariable[] getVariables(IConfiguration cfg, boolean resolveMacros);
|
||||||
|
|
||||||
|
/**
|
||||||
* @return the String representing default system delimiter. That is the ":" for Unix-like
|
* @return the String representing default system delimiter. That is the ":" for Unix-like
|
||||||
* systems and the ";" for Win32 systems. This method will be used by the
|
* systems and the ";" for Win32 systems. This method will be used by the
|
||||||
* tool-integrator provided variable supplier e.g. in order to concatenate the list of paths into the
|
* tool-integrator provided variable supplier e.g. in order to concatenate the list of paths into the
|
||||||
|
@ -97,7 +112,8 @@ public interface IEnvironmentVariableProvider{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the array of String that holds the build paths of the specified type
|
* @return the array of String that holds the build paths of the specified type
|
||||||
|
*
|
||||||
* @param configuration represent the configuration for which the paths were changed
|
* @param configuration represent the configuration for which the paths were changed
|
||||||
* @param buildPathType can be set to one of the IEnvVarBuildPath.BUILDPATH _xxx
|
* @param buildPathType can be set to one of the IEnvVarBuildPath.BUILDPATH _xxx
|
||||||
* (the IEnvVarBuildPath will represent the build environment variables, see also
|
* (the IEnvVarBuildPath will represent the build environment variables, see also
|
||||||
|
@ -107,19 +123,15 @@ public interface IEnvironmentVariableProvider{
|
||||||
String[] getBuildPaths(IConfiguration configuration, int buildPathType);
|
String[] getBuildPaths(IConfiguration configuration, int buildPathType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* adds the listener that will return notifications about the include and library paths changes.
|
* adds the listener that will return notifications about the include and library paths changes.
|
||||||
* The ManagedBuildManager will register the change listener and will notify all registered
|
* The ManagedBuildManager will register the change listener and will notify all registered
|
||||||
* Scanned Info Change Listeners about the include paths change.
|
* Scanned Info Change Listeners about the include paths change.
|
||||||
*/
|
*/
|
||||||
void subscribe(
|
void subscribe(IEnvironmentBuildPathsChangeListener listener);
|
||||||
IEnvironmentBuildPathsChangeListener listener);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* removes the include and library paths change listener
|
* removes the include and library paths change listener
|
||||||
*/
|
*/
|
||||||
void unsubscribe(
|
void unsubscribe(IEnvironmentBuildPathsChangeListener listener);
|
||||||
IEnvironmentBuildPathsChangeListener listener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,10 +35,8 @@ import org.eclipse.cdt.utils.envvar.EnvVarOperationProcessor;
|
||||||
* build environment functionality to the MBS
|
* build environment functionality to the MBS
|
||||||
*
|
*
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class EnvironmentVariableProvider implements
|
public class EnvironmentVariableProvider implements IEnvironmentVariableProvider {
|
||||||
IEnvironmentVariableProvider {
|
|
||||||
// private static final QualifiedName fBuildPathVarProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), "buildPathVar"); //$NON-NLS-1$
|
// private static final QualifiedName fBuildPathVarProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), "buildPathVar"); //$NON-NLS-1$
|
||||||
|
|
||||||
// private static final String DELIMITER_WIN32 = ";"; //$NON-NLS-1$
|
// private static final String DELIMITER_WIN32 = ";"; //$NON-NLS-1$
|
||||||
|
@ -58,20 +56,17 @@ public class EnvironmentVariableProvider implements
|
||||||
* paths from environment variable values
|
* paths from environment variable values
|
||||||
*
|
*
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
static public class DefaultBuildPathResolver implements IBuildPathResolver {
|
static public class DefaultBuildPathResolver implements IBuildPathResolver {
|
||||||
private String fDelimiter;
|
private String fDelimiter;
|
||||||
|
|
||||||
public DefaultBuildPathResolver(String delimiter){
|
public DefaultBuildPathResolver(String delimiter) {
|
||||||
fDelimiter = delimiter;
|
fDelimiter = delimiter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] resolveBuildPaths(int pathType, String variableName,
|
public String[] resolveBuildPaths(int pathType, String variableName, String variableValue, IConfiguration configuration) {
|
||||||
String variableValue, IConfiguration configuration) {
|
if (fDelimiter == null || "".equals(fDelimiter)) //$NON-NLS-1$
|
||||||
|
|
||||||
if(fDelimiter == null || "".equals(fDelimiter)) //$NON-NLS-1$
|
|
||||||
return new String[]{variableValue};
|
return new String[]{variableValue};
|
||||||
|
|
||||||
List<String> list = EnvVarOperationProcessor.convertToList(variableValue,fDelimiter);
|
List<String> list = EnvVarOperationProcessor.convertToList(variableValue,fDelimiter);
|
||||||
|
@ -80,46 +75,39 @@ public class EnvironmentVariableProvider implements
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected EnvironmentVariableProvider(IEnvironmentVariableManager mngr){
|
protected EnvironmentVariableProvider(IEnvironmentVariableManager mngr) {
|
||||||
fMngr = mngr;
|
fMngr = mngr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EnvironmentVariableProvider getDefault(){
|
public static EnvironmentVariableProvider getDefault() {
|
||||||
if(fInstance == null){
|
if (fInstance == null) {
|
||||||
fInstance = new EnvironmentVariableProvider(CCorePlugin.getDefault().getBuildEnvironmentManager());
|
fInstance = new EnvironmentVariableProvider(CCorePlugin.getDefault().getBuildEnvironmentManager());
|
||||||
fInstance.fBuildPathVarCheckAllowed = true;
|
fInstance.fBuildPathVarCheckAllowed = true;
|
||||||
}
|
}
|
||||||
return fInstance;
|
return fInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getVariable()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IBuildEnvironmentVariable getVariable(String variableName,
|
public IBuildEnvironmentVariable getVariable(String variableName, Object level, boolean includeParentLevels, boolean resolveMacros) {
|
||||||
Object level, boolean includeParentLevels, boolean resolveMacros) {
|
if (variableName == null || "".equals(variableName)) //$NON-NLS-1$
|
||||||
|
|
||||||
if(variableName == null || "".equals(variableName)) //$NON-NLS-1$
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if(level instanceof IConfiguration){
|
if (level instanceof IConfiguration) {
|
||||||
return wrap(getVariable(variableName, (IConfiguration)level, resolveMacros));
|
return wrap(getVariable(variableName, (IConfiguration)level, resolveMacros));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEnvironmentVariable getVariable(String variableName,
|
public IEnvironmentVariable getVariable(String variableName, IConfiguration cfg, boolean resolveMacros) {
|
||||||
IConfiguration cfg, boolean resolveMacros){
|
|
||||||
return getVariable(variableName, cfg, resolveMacros, true);
|
return getVariable(variableName, cfg, resolveMacros, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnvironmentVariable getVariable(String variableName,
|
public IEnvironmentVariable getVariable(String variableName, IConfiguration cfg, boolean resolveMacros, boolean checkBuildPaths) {
|
||||||
IConfiguration cfg, boolean resolveMacros, boolean checkBuildPaths){
|
|
||||||
ICConfigurationDescription des = ManagedBuildManager.getDescriptionForConfiguration(cfg);
|
ICConfigurationDescription des = ManagedBuildManager.getDescriptionForConfiguration(cfg);
|
||||||
if(des != null){
|
if (des != null) {
|
||||||
IEnvironmentVariable variable = fMngr.getVariable(variableName, des, resolveMacros);
|
IEnvironmentVariable variable = fMngr.getVariable(variableName, des, resolveMacros);
|
||||||
if(checkBuildPaths && resolveMacros && fBuildPathVarCheckAllowed)
|
if (checkBuildPaths && resolveMacros && fBuildPathVarCheckAllowed)
|
||||||
checkBuildPathVariable(cfg, variableName, variable);
|
checkBuildPathVariable(cfg, variableName, variable);
|
||||||
return variable;
|
return variable;
|
||||||
}
|
}
|
||||||
|
@ -127,130 +115,109 @@ public class EnvironmentVariableProvider implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEnvironmentVariable[] getVariables(IConfiguration cfg, boolean resolveMacros){
|
public IEnvironmentVariable[] getVariables(IConfiguration cfg, boolean resolveMacros) {
|
||||||
return getVariables(cfg, resolveMacros, true);
|
return getVariables(cfg, resolveMacros, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnvironmentVariable[] getVariables(IConfiguration cfg, boolean resolveMacros, boolean checkBuildPaths){
|
public IEnvironmentVariable[] getVariables(IConfiguration cfg, boolean resolveMacros, boolean checkBuildPaths) {
|
||||||
ICConfigurationDescription des = ManagedBuildManager.getDescriptionForConfiguration(cfg);
|
ICConfigurationDescription des = ManagedBuildManager.getDescriptionForConfiguration(cfg);
|
||||||
if(des != null){
|
if (des != null) {
|
||||||
IEnvironmentVariable vars[] = fMngr.getVariables(des, resolveMacros);
|
IEnvironmentVariable vars[] = fMngr.getVariables(des, resolveMacros);
|
||||||
if(checkBuildPaths && resolveMacros && fBuildPathVarCheckAllowed)
|
if (checkBuildPaths && resolveMacros && fBuildPathVarCheckAllowed)
|
||||||
checkBuildPathVariables(cfg,vars);
|
checkBuildPathVariables(cfg,vars);
|
||||||
return vars;
|
return vars;
|
||||||
}
|
}
|
||||||
return new IBuildEnvironmentVariable[0];
|
return new IBuildEnvironmentVariable[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IBuildEnvironmentVariable wrap(IEnvironmentVariable var){
|
public static IBuildEnvironmentVariable wrap(IEnvironmentVariable var) {
|
||||||
if(var == null)
|
if (var == null)
|
||||||
return null;
|
return null;
|
||||||
if(var instanceof IBuildEnvironmentVariable)
|
if (var instanceof IBuildEnvironmentVariable)
|
||||||
return (IBuildEnvironmentVariable)var;
|
return (IBuildEnvironmentVariable)var;
|
||||||
return new BuildEnvVar(var);
|
return new BuildEnvVar(var);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IBuildEnvironmentVariable[] wrap(IEnvironmentVariable vars[]){
|
public static IBuildEnvironmentVariable[] wrap(IEnvironmentVariable vars[]) {
|
||||||
if(vars == null)
|
if (vars == null)
|
||||||
return null;
|
return null;
|
||||||
if(vars instanceof IBuildEnvironmentVariable[])
|
if (vars instanceof IBuildEnvironmentVariable[])
|
||||||
return (IBuildEnvironmentVariable[])vars;
|
return (IBuildEnvironmentVariable[])vars;
|
||||||
|
|
||||||
IBuildEnvironmentVariable[] buildVars = new IBuildEnvironmentVariable[vars.length];
|
IBuildEnvironmentVariable[] buildVars = new IBuildEnvironmentVariable[vars.length];
|
||||||
for(int i = 0; i < vars.length; i++){
|
for(int i = 0; i < vars.length; i++) {
|
||||||
buildVars[i] = wrap(vars[i]);
|
buildVars[i] = wrap(vars[i]);
|
||||||
}
|
}
|
||||||
return buildVars;
|
return buildVars;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* protected ICConfigurationDescription getDescription(IConfiguration cfg){
|
/* protected ICConfigurationDescription getDescription(IConfiguration cfg) {
|
||||||
IProject project = cfg.getOwner().getProject();
|
IProject project = cfg.getOwner().getProject();
|
||||||
ICProjectDescription des = CoreModel.getDefault().getProjectDescription(project, false);
|
ICProjectDescription des = CoreModel.getDefault().getProjectDescription(project, false);
|
||||||
if(des != null){
|
if (des != null) {
|
||||||
return des.getConfigurationById(cfg.getId());
|
return des.getConfigurationById(cfg.getId());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getVariables()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IBuildEnvironmentVariable[] getVariables(Object level,
|
public IBuildEnvironmentVariable[] getVariables(Object level, boolean includeParentLevels, boolean resolveMacros) {
|
||||||
boolean includeParentLevels, boolean resolveMacros) {
|
if (level instanceof IConfiguration) {
|
||||||
|
|
||||||
if(level instanceof IConfiguration){
|
|
||||||
return wrap(getVariables((IConfiguration)level, resolveMacros));
|
return wrap(getVariables((IConfiguration)level, resolveMacros));
|
||||||
}
|
}
|
||||||
return new IBuildEnvironmentVariable[0];
|
return new IBuildEnvironmentVariable[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getDefaultDelimiter()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getDefaultDelimiter() {
|
public String getDefaultDelimiter() {
|
||||||
return fMngr.getDefaultDelimiter();
|
return fMngr.getDefaultDelimiter();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#isVariableCaseSensitive()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVariableCaseSensitive() {
|
public boolean isVariableCaseSensitive() {
|
||||||
return fMngr.isVariableCaseSensitive();
|
return fMngr.isVariableCaseSensitive();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getSuppliers()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IEnvironmentVariableSupplier[] getSuppliers(Object level) {
|
public IEnvironmentVariableSupplier[] getSuppliers(Object level) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getBuildPaths()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getBuildPaths(IConfiguration configuration,
|
public String[] getBuildPaths(IConfiguration configuration, int buildPathType) {
|
||||||
int buildPathType) {
|
|
||||||
ITool tools[] = configuration.getFilteredTools();
|
ITool tools[] = configuration.getFilteredTools();
|
||||||
List<String> list = new ArrayList<String>();
|
List<String> list = new ArrayList<String>();
|
||||||
|
|
||||||
for(int i = 0; i < tools.length; i++){
|
for (ITool tool : tools) {
|
||||||
IEnvVarBuildPath pathDescriptors[] = tools[i].getEnvVarBuildPaths();
|
IEnvVarBuildPath pathDescriptors[] = tool.getEnvVarBuildPaths();
|
||||||
|
|
||||||
if(pathDescriptors == null || pathDescriptors.length == 0)
|
if (pathDescriptors == null || pathDescriptors.length == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for(int j = 0; j < pathDescriptors.length; j++){
|
for (IEnvVarBuildPath curPathDes : pathDescriptors) {
|
||||||
IEnvVarBuildPath curPathDes = pathDescriptors[j];
|
if (curPathDes.getType() != buildPathType)
|
||||||
if(curPathDes.getType() != buildPathType)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
String vars[] = curPathDes.getVariableNames();
|
String vars[] = curPathDes.getVariableNames();
|
||||||
if(vars == null || vars.length == 0)
|
if (vars == null || vars.length == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
IBuildPathResolver pathResolver = curPathDes.getBuildPathResolver();
|
IBuildPathResolver pathResolver = curPathDes.getBuildPathResolver();
|
||||||
if(pathResolver == null){
|
if (pathResolver == null) {
|
||||||
String delimiter = curPathDes.getPathDelimiter();
|
String delimiter = curPathDes.getPathDelimiter();
|
||||||
if(delimiter == null)
|
if (delimiter == null)
|
||||||
delimiter = getDefaultDelimiter();
|
delimiter = getDefaultDelimiter();
|
||||||
pathResolver = new DefaultBuildPathResolver(delimiter);
|
pathResolver = new DefaultBuildPathResolver(delimiter);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int k = 0; k < vars.length; k++){
|
for (String varName : vars) {
|
||||||
String varName = vars[k];
|
|
||||||
|
|
||||||
IEnvironmentVariable var = getVariable(varName,configuration,true, false);
|
IEnvironmentVariable var = getVariable(varName,configuration,true, false);
|
||||||
if(var == null)
|
if (var == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
String varValue = var.getValue();
|
String varValue = var.getValue();
|
||||||
String paths[] = pathResolver.resolveBuildPaths(buildPathType,varName,varValue,configuration);
|
String paths[] = pathResolver.resolveBuildPaths(buildPathType,varName,varValue,configuration);
|
||||||
if(paths != null && paths.length != 0)
|
if (paths != null && paths.length != 0)
|
||||||
list.addAll(Arrays.asList(paths));
|
list.addAll(Arrays.asList(paths));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,45 +226,39 @@ public class EnvironmentVariableProvider implements
|
||||||
return list.toArray(new String[list.size()]);
|
return list.toArray(new String[list.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* returns a list of registered listeners
|
* @return a list of registered listeners
|
||||||
*/
|
*/
|
||||||
private List<IEnvironmentBuildPathsChangeListener> getListeners(){
|
private List<IEnvironmentBuildPathsChangeListener> getListeners() {
|
||||||
if(fListeners == null)
|
if (fListeners == null)
|
||||||
fListeners = new ArrayList<IEnvironmentBuildPathsChangeListener>();
|
fListeners = new ArrayList<IEnvironmentBuildPathsChangeListener>();
|
||||||
return fListeners;
|
return fListeners;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* notifies registered listeners
|
* notifies registered listeners
|
||||||
*/
|
*/
|
||||||
private void notifyListeners(IConfiguration configuration, int buildPathType){
|
private void notifyListeners(IConfiguration configuration, int buildPathType) {
|
||||||
List<IEnvironmentBuildPathsChangeListener> listeners = getListeners();
|
List<IEnvironmentBuildPathsChangeListener> listeners = getListeners();
|
||||||
for (IEnvironmentBuildPathsChangeListener listener : listeners) {
|
for (IEnvironmentBuildPathsChangeListener listener : listeners) {
|
||||||
listener.buildPathsChanged(configuration,buildPathType);
|
listener.buildPathsChanged(configuration,buildPathType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#subscribe()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void subscribe(IEnvironmentBuildPathsChangeListener listener) {
|
public synchronized void subscribe(IEnvironmentBuildPathsChangeListener listener) {
|
||||||
if(listener == null)
|
if (listener == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
List<IEnvironmentBuildPathsChangeListener> listeners = getListeners();
|
List<IEnvironmentBuildPathsChangeListener> listeners = getListeners();
|
||||||
|
|
||||||
if(!listeners.contains(listener))
|
if (!listeners.contains(listener))
|
||||||
listeners.add(listener);
|
listeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#unsubscribe()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void unsubscribe(IEnvironmentBuildPathsChangeListener listener) {
|
public synchronized void unsubscribe(IEnvironmentBuildPathsChangeListener listener) {
|
||||||
if(listener == null)
|
if (listener == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
List<IEnvironmentBuildPathsChangeListener> listeners = getListeners();
|
List<IEnvironmentBuildPathsChangeListener> listeners = getListeners();
|
||||||
|
@ -305,39 +266,39 @@ public class EnvironmentVariableProvider implements
|
||||||
listeners.remove(listener);
|
listeners.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* performs a check of the build path variables for the given configuration
|
* performs a check of the build path variables for the given configuration
|
||||||
* If the build variables are changed, the notification is sent
|
* If the build variables are changed, the notification is sent
|
||||||
*/
|
*/
|
||||||
public void checkBuildPathVariables(IConfiguration configuration){
|
public void checkBuildPathVariables(IConfiguration configuration) {
|
||||||
checkBuildPathVariables(configuration, getVariables(configuration ,true, false));
|
checkBuildPathVariables(configuration, getVariables(configuration ,true, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* performs a check of the build path variables of the specified type
|
* performs a check of the build path variables of the specified type
|
||||||
* for the given configuration
|
* for the given configuration
|
||||||
* If the build variables are changed, the notification is sent
|
* If the build variables are changed, the notification is sent
|
||||||
*/
|
*/
|
||||||
public void checkBuildPathVariables(IConfiguration configuration,int buildPathType){
|
public void checkBuildPathVariables(IConfiguration configuration,int buildPathType) {
|
||||||
EnvVarCollector cr = new EnvVarCollector();
|
EnvVarCollector cr = new EnvVarCollector();
|
||||||
cr.add(getVariables(configuration, true, false));
|
cr.add(getVariables(configuration, true, false));
|
||||||
checkBuildPathVariables(configuration,buildPathType,cr);
|
checkBuildPathVariables(configuration,buildPathType,cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* performs a check of the build path variables
|
* performs a check of the build path variables
|
||||||
* for the given configuration given the set of the variables
|
* for the given configuration given the set of the variables
|
||||||
* defined for this configuration
|
* defined for this configuration
|
||||||
* If the build variables are changed, the notification is sent
|
* If the build variables are changed, the notification is sent
|
||||||
*/
|
*/
|
||||||
protected void checkBuildPathVariables(IConfiguration configuration, IEnvironmentVariable vars[]){
|
protected void checkBuildPathVariables(IConfiguration configuration, IEnvironmentVariable vars[]) {
|
||||||
EnvVarCollector cr = new EnvVarCollector();
|
EnvVarCollector cr = new EnvVarCollector();
|
||||||
cr.add(vars);
|
cr.add(vars);
|
||||||
checkBuildPathVariables(configuration,IEnvVarBuildPath.BUILDPATH_INCLUDE,cr);
|
checkBuildPathVariables(configuration,IEnvVarBuildPath.BUILDPATH_INCLUDE,cr);
|
||||||
checkBuildPathVariables(configuration,IEnvVarBuildPath.BUILDPATH_LIBRARY,cr);
|
checkBuildPathVariables(configuration,IEnvVarBuildPath.BUILDPATH_LIBRARY,cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* performs a check of whether the given variable is the build path variable
|
* performs a check of whether the given variable is the build path variable
|
||||||
* and if true checks whether it is changed.
|
* and if true checks whether it is changed.
|
||||||
* In the case of it is changed all other build path variables are checked
|
* In the case of it is changed all other build path variables are checked
|
||||||
|
@ -345,12 +306,12 @@ public class EnvironmentVariableProvider implements
|
||||||
* If it is not changed, other build path variables are not checked
|
* 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
|
* In the case of the given variable is not the build path one, this method does nothing
|
||||||
*/
|
*/
|
||||||
protected void checkBuildPathVariable(IConfiguration configuration, String varName, IEnvironmentVariable var){
|
protected void checkBuildPathVariable(IConfiguration configuration, String varName, IEnvironmentVariable var) {
|
||||||
checkBuildPathVariable(configuration, IEnvVarBuildPath.BUILDPATH_INCLUDE, varName, var);
|
checkBuildPathVariable(configuration, IEnvVarBuildPath.BUILDPATH_INCLUDE, varName, var);
|
||||||
checkBuildPathVariable(configuration, IEnvVarBuildPath.BUILDPATH_LIBRARY, varName, var);
|
checkBuildPathVariable(configuration, IEnvVarBuildPath.BUILDPATH_LIBRARY, varName, var);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* performs a check of whether the given variable is the build path variable
|
* performs a check of whether the given variable is the build path variable
|
||||||
* of the specified type and if true checks whether it is changed.
|
* of the specified type and if true checks whether it is changed.
|
||||||
* In the case of it is changed all other build path variables of that type are checked
|
* In the case of it is changed all other build path variables of that type are checked
|
||||||
|
@ -358,11 +319,11 @@ public class EnvironmentVariableProvider implements
|
||||||
* If it is not changed, other build path variables are not checked
|
* 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
|
* 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, IEnvironmentVariable var){
|
protected void checkBuildPathVariable(IConfiguration configuration, int buildPathType, String varName, IEnvironmentVariable var) {
|
||||||
StoredBuildPathEnvironmentContainer buildPathVars = getStoredBuildPathVariables(buildPathType);
|
StoredBuildPathEnvironmentContainer buildPathVars = getStoredBuildPathVariables(buildPathType);
|
||||||
if(buildPathVars == null)
|
if (buildPathVars == null)
|
||||||
return;
|
return;
|
||||||
if(buildPathVars.isVariableChanged(varName,var,configuration)){
|
if (buildPathVars.isVariableChanged(varName,var,configuration)) {
|
||||||
EnvVarCollector cr = new EnvVarCollector();
|
EnvVarCollector cr = new EnvVarCollector();
|
||||||
cr.add(getVariables(configuration, true, false));
|
cr.add(getVariables(configuration, true, false));
|
||||||
buildPathVars.synchronize(cr,configuration);
|
buildPathVars.synchronize(cr,configuration);
|
||||||
|
@ -370,44 +331,44 @@ public class EnvironmentVariableProvider implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* performs a check of the build path variables of the specified type
|
* performs a check of the build path variables of the specified type
|
||||||
* for the given configuration given the set of the variables
|
* for the given configuration given the set of the variables
|
||||||
* defined for this configuration.
|
* defined for this configuration.
|
||||||
* If the build variables are changed, the notification is sent
|
* If the build variables are changed, the notification is sent
|
||||||
*/
|
*/
|
||||||
protected void checkBuildPathVariables(IConfiguration configuration, int buildPathType, EnvVarCollector varSet){
|
protected void checkBuildPathVariables(IConfiguration configuration, int buildPathType, EnvVarCollector varSet) {
|
||||||
StoredBuildPathEnvironmentContainer buildPathVars = getStoredBuildPathVariables(buildPathType);
|
StoredBuildPathEnvironmentContainer buildPathVars = getStoredBuildPathVariables(buildPathType);
|
||||||
if(buildPathVars == null)
|
if (buildPathVars == null)
|
||||||
return;
|
return;
|
||||||
if(buildPathVars.checkBuildPathChange(varSet,configuration)){
|
if (buildPathVars.checkBuildPathChange(varSet,configuration)) {
|
||||||
notifyListeners(configuration, buildPathType);
|
notifyListeners(configuration, buildPathType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* returns the container of the build variables of the specified type
|
* returns the container of the build variables of the specified type
|
||||||
*/
|
*/
|
||||||
protected StoredBuildPathEnvironmentContainer getStoredBuildPathVariables(int buildPathType){
|
protected StoredBuildPathEnvironmentContainer getStoredBuildPathVariables(int buildPathType) {
|
||||||
return buildPathType == IEnvVarBuildPath.BUILDPATH_LIBRARY ?
|
return buildPathType == IEnvVarBuildPath.BUILDPATH_LIBRARY ?
|
||||||
getStoredLibraryBuildPathVariables() :
|
getStoredLibraryBuildPathVariables() :
|
||||||
getStoredIncludeBuildPathVariables();
|
getStoredIncludeBuildPathVariables();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* returns the container of the Include path variables
|
* returns the container of the Include path variables
|
||||||
*/
|
*/
|
||||||
protected StoredBuildPathEnvironmentContainer getStoredIncludeBuildPathVariables(){
|
protected StoredBuildPathEnvironmentContainer getStoredIncludeBuildPathVariables() {
|
||||||
if(fIncludeStoredBuildPathVariables == null)
|
if (fIncludeStoredBuildPathVariables == null)
|
||||||
fIncludeStoredBuildPathVariables = new StoredBuildPathEnvironmentContainer(IEnvVarBuildPath.BUILDPATH_INCLUDE);
|
fIncludeStoredBuildPathVariables = new StoredBuildPathEnvironmentContainer(IEnvVarBuildPath.BUILDPATH_INCLUDE);
|
||||||
return fIncludeStoredBuildPathVariables;
|
return fIncludeStoredBuildPathVariables;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* returns the container of the Library path variables
|
* returns the container of the Library path variables
|
||||||
*/
|
*/
|
||||||
protected StoredBuildPathEnvironmentContainer getStoredLibraryBuildPathVariables(){
|
protected StoredBuildPathEnvironmentContainer getStoredLibraryBuildPathVariables() {
|
||||||
if(fLibraryStoredBuildPathVariables == null)
|
if (fLibraryStoredBuildPathVariables == null)
|
||||||
fLibraryStoredBuildPathVariables = new StoredBuildPathEnvironmentContainer(IEnvVarBuildPath.BUILDPATH_LIBRARY);
|
fLibraryStoredBuildPathVariables = new StoredBuildPathEnvironmentContainer(IEnvVarBuildPath.BUILDPATH_LIBRARY);
|
||||||
return fLibraryStoredBuildPathVariables;
|
return fLibraryStoredBuildPathVariables;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,16 +63,13 @@ public class CygwinPathResolver implements IBuildPathResolver {
|
||||||
private static String rootCygwin = null;
|
private static String rootCygwin = null;
|
||||||
private static String etcCygwin = null;
|
private static String etcCygwin = null;
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.managedbuilder.core.IBuildPathResolver#resolveBuildPaths(int, java.lang.String, java.lang.String, org.eclipse.cdt.managedbuilder.core.IConfiguration)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String[] resolveBuildPaths(int pathType, String variableName,
|
public String[] resolveBuildPaths(int pathType, String variableName,
|
||||||
String variableValue, IConfiguration configuration) {
|
String variableValue, IConfiguration configuration) {
|
||||||
|
|
||||||
if(!isWindows()){
|
if(!isWindows()) {
|
||||||
return variableValue.split(DELIMITER_UNIX);
|
return variableValue.split(DELIMITER_UNIX);
|
||||||
} else if(isMinGW(configuration)){
|
} else if(isMinGW(configuration)) {
|
||||||
return variableValue.split(DELIMITER_WIN);
|
return variableValue.split(DELIMITER_WIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +89,8 @@ public class CygwinPathResolver implements IBuildPathResolver {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
|
/**
|
||||||
* returns "/etc" path in Windows format
|
* returns "/etc" path in Windows format
|
||||||
*/
|
*/
|
||||||
public static String getEtcPath() {
|
public static String getEtcPath() {
|
||||||
|
@ -100,17 +98,17 @@ public class CygwinPathResolver implements IBuildPathResolver {
|
||||||
return etcCygwin;
|
return etcCygwin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* returns "/usr/bin" path in Windows format
|
* returns "/usr/bin" path in Windows format
|
||||||
*/
|
*/
|
||||||
public static String getBinPath() {
|
public static String getBinPath() {
|
||||||
if (!checked) findPaths();
|
if (!checked) findPaths();
|
||||||
return binCygwin;
|
return binCygwin;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
|
/**
|
||||||
* returns Cygwin root ("/") path in Windows format
|
* returns Cygwin root ("/") path in Windows format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static String getRootPath() {
|
public static String getRootPath() {
|
||||||
if (!checked) findPaths();
|
if (!checked) findPaths();
|
||||||
return rootCygwin;
|
return rootCygwin;
|
||||||
|
@ -140,6 +138,7 @@ public class CygwinPathResolver implements IBuildPathResolver {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the absolute path of the pattern by
|
* Returns the absolute path of the pattern by
|
||||||
* simply appending the pattern to the root
|
* simply appending the pattern to the root
|
||||||
|
@ -233,7 +232,7 @@ public class CygwinPathResolver implements IBuildPathResolver {
|
||||||
try {
|
try {
|
||||||
IEnvironmentVariable vars[] = ManagedBuildManager.getEnvironmentVariableProvider().getVariables(cfg,true);
|
IEnvironmentVariable vars[] = ManagedBuildManager.getEnvironmentVariableProvider().getVariables(cfg,true);
|
||||||
String env[] = new String[vars.length];
|
String env[] = new String[vars.length];
|
||||||
for(int i = 0; i < env.length; i++){
|
for(int i = 0; i < env.length; i++) {
|
||||||
env[i] = vars[i].getName() + "="; //$NON-NLS-1$
|
env[i] = vars[i].getName() + "="; //$NON-NLS-1$
|
||||||
String value = vars[i].getValue();
|
String value = vars[i].getValue();
|
||||||
if(value != null)
|
if(value != null)
|
||||||
|
@ -258,10 +257,10 @@ public class CygwinPathResolver implements IBuildPathResolver {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isMinGW(IConfiguration cfg){
|
public static boolean isMinGW(IConfiguration cfg) {
|
||||||
String versionInfo[] = exec(GCC_VERSION_CMD, cfg);
|
String versionInfo[] = exec(GCC_VERSION_CMD, cfg);
|
||||||
if(versionInfo != null) {
|
if(versionInfo != null) {
|
||||||
for(int i = 0; i < versionInfo.length; i++){
|
for(int i = 0; i < versionInfo.length; i++) {
|
||||||
if(versionInfo[i].indexOf(MINGW_SPECIAL) != -1)
|
if(versionInfo[i].indexOf(MINGW_SPECIAL) != -1)
|
||||||
return true;
|
return true;
|
||||||
else if(versionInfo[i].indexOf(CYGWIN_SPECIAL) != -1)
|
else if(versionInfo[i].indexOf(CYGWIN_SPECIAL) != -1)
|
||||||
|
|
|
@ -16,13 +16,10 @@ import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSu
|
||||||
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
|
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.envvar.BuildEnvVar;
|
import org.eclipse.cdt.managedbuilder.internal.envvar.BuildEnvVar;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @noextend This class is not intended to be subclassed by clients.
|
* @noextend This class is not intended to be subclassed by clients.
|
||||||
*/
|
*/
|
||||||
public class GnuCygwinConfigurationEnvironmentSupplier implements
|
public class GnuCygwinConfigurationEnvironmentSupplier implements IConfigurationEnvironmentVariableSupplier {
|
||||||
IConfigurationEnvironmentVariableSupplier {
|
|
||||||
|
|
||||||
private static final String PATH = "PATH"; //$NON-NLS-1$
|
private static final String PATH = "PATH"; //$NON-NLS-1$
|
||||||
private static final String DELIMITER_UNIX = ":"; //$NON-NLS-1$
|
private static final String DELIMITER_UNIX = ":"; //$NON-NLS-1$
|
||||||
private static final String PROPERTY_DELIMITER = "path.separator"; //$NON-NLS-1$
|
private static final String PROPERTY_DELIMITER = "path.separator"; //$NON-NLS-1$
|
||||||
|
@ -32,50 +29,46 @@ public class GnuCygwinConfigurationEnvironmentSupplier implements
|
||||||
private static final String LC_ALL = "LC_ALL"; //$NON-NLS-1$
|
private static final String LC_ALL = "LC_ALL"; //$NON-NLS-1$
|
||||||
private static final String LC_MESSAGES = "LC_MESSAGES"; //$NON-NLS-1$
|
private static final String LC_MESSAGES = "LC_MESSAGES"; //$NON-NLS-1$
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier#getVariable(java.lang.String, org.eclipse.cdt.managedbuilder.core.IConfiguration, org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IBuildEnvironmentVariable getVariable(String variableName,
|
public IBuildEnvironmentVariable getVariable(String variableName, IConfiguration configuration, IEnvironmentVariableProvider provider) {
|
||||||
IConfiguration configuration, IEnvironmentVariableProvider provider) {
|
if (variableName == null) {
|
||||||
|
|
||||||
if (variableName == null)
|
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (!System.getProperty(PROPERTY_OSNAME).toLowerCase().startsWith("windows ")) //$NON-NLS-1$
|
if (!System.getProperty(PROPERTY_OSNAME).toLowerCase().startsWith("windows ")) { //$NON-NLS-1$
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (variableName.equalsIgnoreCase(PATH)) {
|
if (variableName.equalsIgnoreCase(PATH)) {
|
||||||
String p = CygwinPathResolver.getBinPath();
|
String p = CygwinPathResolver.getBinPath();
|
||||||
if (p != null)
|
if (p != null) {
|
||||||
return new BuildEnvVar(PATH, p.replace('/','\\'), IBuildEnvironmentVariable.ENVVAR_PREPEND, System.getProperty(PROPERTY_DELIMITER, DELIMITER_UNIX));
|
return new BuildEnvVar(PATH, p.replace('/','\\'), IBuildEnvironmentVariable.ENVVAR_PREPEND, System.getProperty(PROPERTY_DELIMITER, DELIMITER_UNIX));
|
||||||
|
}
|
||||||
} else if (variableName.equalsIgnoreCase(LANG)) {
|
} else if (variableName.equalsIgnoreCase(LANG)) {
|
||||||
// Workaround for not being able to select encoding for CDT console -> change codeset to Latin1
|
// Workaround for not being able to select encoding for CDT console -> change codeset to Latin1
|
||||||
String langValue = System.getenv(LANG);
|
String langValue = System.getenv(LANG);
|
||||||
if (langValue == null || langValue.length() == 0)
|
if (langValue == null || langValue.length() == 0) {
|
||||||
langValue = System.getenv(LC_ALL);
|
langValue = System.getenv(LC_ALL);
|
||||||
if (langValue == null || langValue.length() == 0)
|
}
|
||||||
|
if (langValue == null || langValue.length() == 0) {
|
||||||
langValue = System.getenv(LC_MESSAGES);
|
langValue = System.getenv(LC_MESSAGES);
|
||||||
if (langValue != null && langValue.length() > 0)
|
}
|
||||||
|
if (langValue != null && langValue.length() > 0) {
|
||||||
// langValue is [language[_territory][.codeset][@modifier]], i.e. "en_US.UTF-8@dict"
|
// langValue is [language[_territory][.codeset][@modifier]], i.e. "en_US.UTF-8@dict"
|
||||||
// we replace codeset with Latin1 as CDT console garbles UTF
|
// we replace codeset with Latin1 as CDT console garbles UTF
|
||||||
// and ignore modifier which is not used by LANG
|
// and ignore modifier which is not used by LANG
|
||||||
langValue = langValue.replaceFirst("([^.@]*)(\\..*)?(@.*)?", "$1.ISO-8859-1"); //$NON-NLS-1$ //$NON-NLS-2$
|
langValue = langValue.replaceFirst("([^.@]*)(\\..*)?(@.*)?", "$1.ISO-8859-1"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
else
|
} else {
|
||||||
langValue = "C.ISO-8859-1"; //$NON-NLS-1$
|
langValue = "C.ISO-8859-1"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
return new BuildEnvVar(LANG, langValue);
|
return new BuildEnvVar(LANG, langValue);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier#getVariables(org.eclipse.cdt.managedbuilder.core.IConfiguration, org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IBuildEnvironmentVariable[] getVariables(
|
public IBuildEnvironmentVariable[] getVariables(IConfiguration configuration, IEnvironmentVariableProvider provider) {
|
||||||
IConfiguration configuration, IEnvironmentVariableProvider provider) {
|
|
||||||
|
|
||||||
IBuildEnvironmentVariable varLang = getVariable(LANG, configuration, provider);
|
IBuildEnvironmentVariable varLang = getVariable(LANG, configuration, provider);
|
||||||
IBuildEnvironmentVariable varPath = getVariable(PATH, configuration, provider);
|
IBuildEnvironmentVariable varPath = getVariable(PATH, configuration, provider);
|
||||||
|
|
||||||
|
|
|
@ -32,24 +32,17 @@ import org.osgi.framework.Version;
|
||||||
*
|
*
|
||||||
* @noextend This class is not intended to be subclassed by clients.
|
* @noextend This class is not intended to be subclassed by clients.
|
||||||
*/
|
*/
|
||||||
public class IsGnuCygwinToolChainSupported implements
|
public class IsGnuCygwinToolChainSupported implements IManagedIsToolChainSupported {
|
||||||
IManagedIsToolChainSupported {
|
|
||||||
|
|
||||||
static final String[] CHECKED_NAMES = {"gcc", "binutils", "make"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
static final String[] CHECKED_NAMES = {"gcc", "binutils", "make"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
|
|
||||||
static boolean suppChecked = false;
|
static boolean suppChecked = false;
|
||||||
static boolean toolchainIsSupported = false;
|
static boolean toolchainIsSupported = false;
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.managedbuilder.core.IManagedIsToolChainSupported#isSupported(org.eclipse.cdt.managedbuilder.core.IToolChain, org.eclipse.core.runtime.PluginVersionIdentifier, java.lang.String)
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* @since 8.0
|
* @since 8.0
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isSupported(IToolChain toolChain, Version version, String instance) {
|
public boolean isSupported(IToolChain toolChain, Version version, String instance) {
|
||||||
|
|
||||||
if (suppChecked) return toolchainIsSupported;
|
if (suppChecked) return toolchainIsSupported;
|
||||||
|
|
||||||
String etcCygwin = CygwinPathResolver.getEtcPath();
|
String etcCygwin = CygwinPathResolver.getEtcPath();
|
||||||
|
@ -80,7 +73,9 @@ public class IsGnuCygwinToolChainSupported implements
|
||||||
String s;
|
String s;
|
||||||
while ((s = data.readLine()) != null ) {
|
while ((s = data.readLine()) != null ) {
|
||||||
for (int j = 0; j < CHECKED_NAMES.length; j++) {
|
for (int j = 0; j < CHECKED_NAMES.length; j++) {
|
||||||
if (s.startsWith(CHECKED_NAMES[j])) {found[j] = true;}
|
if (s.startsWith(CHECKED_NAMES[j])) {
|
||||||
|
found[j] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
arePackagesInstalled = true;
|
arePackagesInstalled = true;
|
||||||
|
|
|
@ -25,9 +25,7 @@ import org.eclipse.core.runtime.Platform;
|
||||||
*
|
*
|
||||||
* @noextend This class is not intended to be subclassed by clients.
|
* @noextend This class is not intended to be subclassed by clients.
|
||||||
*/
|
*/
|
||||||
public class MingwEnvironmentVariableSupplier implements
|
public class MingwEnvironmentVariableSupplier implements IConfigurationEnvironmentVariableSupplier {
|
||||||
IConfigurationEnvironmentVariableSupplier {
|
|
||||||
|
|
||||||
private static boolean checked = false;
|
private static boolean checked = false;
|
||||||
private static IPath binDir = null;
|
private static IPath binDir = null;
|
||||||
|
|
||||||
|
|
|
@ -34,14 +34,11 @@ import org.eclipse.cdt.utils.envvar.EnvVarOperationProcessor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class implements the IEnvironmentVariableProvider interface and provides all
|
* This class implements the IEnvironmentVariableProvider interface and provides all
|
||||||
* build environment funvtionality to the MBS
|
* build environment functionality to the MBS
|
||||||
*
|
*
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class EnvironmentVariableManager implements
|
public class EnvironmentVariableManager implements IEnvironmentVariableManager {
|
||||||
IEnvironmentVariableManager {
|
|
||||||
|
|
||||||
private static final String DELIMITER_WIN32 = ";"; //$NON-NLS-1$
|
private static final String DELIMITER_WIN32 = ";"; //$NON-NLS-1$
|
||||||
private static final String DELIMITER_UNIX = ":"; //$NON-NLS-1$
|
private static final String DELIMITER_UNIX = ":"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
@ -57,23 +54,23 @@ public class EnvironmentVariableManager implements
|
||||||
|
|
||||||
public class EnvVarVariableSubstitutor extends SupplierBasedCdtVariableSubstitutor {
|
public class EnvVarVariableSubstitutor extends SupplierBasedCdtVariableSubstitutor {
|
||||||
private String fDefaultDelimiter;
|
private String fDefaultDelimiter;
|
||||||
/* public EnvVarMacroSubstitutor(int contextType, Object contextData, String inexistentMacroValue, String listDelimiter){
|
/* public EnvVarMacroSubstitutor(int contextType, Object contextData, String inexistentMacroValue, String listDelimiter) {
|
||||||
super(contextType,contextData,inexistentMacroValue,listDelimiter);
|
super(contextType,contextData,inexistentMacroValue,listDelimiter);
|
||||||
fDefaultDelimiter = listDelimiter;
|
fDefaultDelimiter = listDelimiter;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
public EnvVarVariableSubstitutor(IVariableContextInfo contextInfo, String inexistentMacroValue, String listDelimiter){
|
public EnvVarVariableSubstitutor(IVariableContextInfo contextInfo, String inexistentMacroValue, String listDelimiter) {
|
||||||
super(contextInfo, inexistentMacroValue, listDelimiter, null ,inexistentMacroValue);
|
super(contextInfo, inexistentMacroValue, listDelimiter, null ,inexistentMacroValue);
|
||||||
fDefaultDelimiter = listDelimiter;
|
fDefaultDelimiter = listDelimiter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnvironmentVariable resolveVariable(EnvVarDescriptor var) throws CdtVariableException {
|
public IEnvironmentVariable resolveVariable(EnvVarDescriptor var) throws CdtVariableException {
|
||||||
String value;
|
String value;
|
||||||
if(var == null || (value = var.getValue()) == null || value.length() == 0 || var.getOperation() == IEnvironmentVariable.ENVVAR_REMOVE)
|
if (var == null || (value = var.getValue()) == null || value.length() == 0 || var.getOperation() == IEnvironmentVariable.ENVVAR_REMOVE)
|
||||||
return var;
|
return var;
|
||||||
|
|
||||||
String listDelimiter = var.getDelimiter();
|
String listDelimiter = var.getDelimiter();
|
||||||
if(listDelimiter == null)
|
if (listDelimiter == null)
|
||||||
listDelimiter = fDefaultDelimiter;
|
listDelimiter = fDefaultDelimiter;
|
||||||
setListDelimiter(listDelimiter);
|
setListDelimiter(listDelimiter);
|
||||||
ICdtVariable macro = EnvironmentVariableSupplier.getInstance().createBuildMacro(var);
|
ICdtVariable macro = EnvironmentVariableSupplier.getInstance().createBuildMacro(var);
|
||||||
|
@ -84,18 +81,18 @@ public class EnvironmentVariableManager implements
|
||||||
return new EnvironmentVariable(var.getName(),value,var.getOperation(),var.getDelimiter());
|
return new EnvironmentVariable(var.getName(),value,var.getOperation(),var.getDelimiter());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IVariableContextInfo getVarMacroContextInfo(EnvVarDescriptor var){
|
protected IVariableContextInfo getVarMacroContextInfo(EnvVarDescriptor var) {
|
||||||
IEnvironmentContextInfo info = var.getContextInfo();
|
IEnvironmentContextInfo info = var.getContextInfo();
|
||||||
if(info != null)
|
if (info != null)
|
||||||
return getMacroContextInfoForContext(info.getContext());
|
return getMacroContextInfoForContext(info.getContext());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getVarMacroSupplierNum(EnvVarDescriptor var, IVariableContextInfo varMacroInfo){
|
protected int getVarMacroSupplierNum(EnvVarDescriptor var, IVariableContextInfo varMacroInfo) {
|
||||||
int varSupplierNum = -1;
|
int varSupplierNum = -1;
|
||||||
ICdtVariableSupplier macroSuppliers[] = varMacroInfo.getSuppliers();
|
ICdtVariableSupplier macroSuppliers[] = varMacroInfo.getSuppliers();
|
||||||
for(int i = 0; i < macroSuppliers.length; i++){
|
for(int i = 0; i < macroSuppliers.length; i++) {
|
||||||
if(macroSuppliers[i] instanceof EnvironmentVariableSupplier){
|
if (macroSuppliers[i] instanceof EnvironmentVariableSupplier) {
|
||||||
varSupplierNum = i;
|
varSupplierNum = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -104,42 +101,38 @@ public class EnvironmentVariableManager implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected EnvironmentVariableManager(){
|
protected EnvironmentVariableManager() {
|
||||||
fContributedEnvironment = new ContributedEnvironment(this);
|
fContributedEnvironment = new ContributedEnvironment(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EnvironmentVariableManager getDefault(){
|
public static EnvironmentVariableManager getDefault() {
|
||||||
if(fInstance == null)
|
if (fInstance == null)
|
||||||
fInstance = new EnvironmentVariableManager();
|
fInstance = new EnvironmentVariableManager();
|
||||||
return fInstance;
|
return fInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* returns a variable of a given name or null
|
* @return a variable of a given name or null
|
||||||
* the context information is taken from the contextInfo passed
|
* the context information is taken from the contextInfo passed
|
||||||
* @see org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo
|
|
||||||
*/
|
*/
|
||||||
public static EnvVarDescriptor getVariable(String variableName,
|
public static EnvVarDescriptor getVariable(String variableName, IEnvironmentContextInfo contextInfo, boolean includeParentLevels) {
|
||||||
IEnvironmentContextInfo contextInfo, boolean includeParentLevels){
|
if (contextInfo == null)
|
||||||
|
|
||||||
if(contextInfo == null)
|
|
||||||
return null;
|
return null;
|
||||||
if((variableName = EnvVarOperationProcessor.normalizeName(variableName)) == null)
|
if ((variableName = EnvVarOperationProcessor.normalizeName(variableName)) == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
|
||||||
IEnvironmentContextInfo infos[] = getAllContextInfos(contextInfo);
|
IEnvironmentContextInfo infos[] = getAllContextInfos(contextInfo);
|
||||||
|
|
||||||
if(!includeParentLevels){
|
if (!includeParentLevels) {
|
||||||
ICoreEnvironmentVariableSupplier suppliers[] = infos[0].getSuppliers();
|
ICoreEnvironmentVariableSupplier suppliers[] = infos[0].getSuppliers();
|
||||||
boolean bVarFound = false;
|
boolean bVarFound = false;
|
||||||
for (ICoreEnvironmentVariableSupplier supplier : suppliers) {
|
for (ICoreEnvironmentVariableSupplier supplier : suppliers) {
|
||||||
if(supplier.getVariable(variableName,infos[0].getContext()) != null){
|
if (supplier.getVariable(variableName,infos[0].getContext()) != null) {
|
||||||
bVarFound = true;
|
bVarFound = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!bVarFound)
|
if (!bVarFound)
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,94 +149,88 @@ public class EnvironmentVariableManager implements
|
||||||
ICoreEnvironmentVariableSupplier supplier = suppliers[j];
|
ICoreEnvironmentVariableSupplier supplier = suppliers[j];
|
||||||
IEnvironmentVariable var = supplier.getVariable(variableName,info.getContext());
|
IEnvironmentVariable var = supplier.getVariable(variableName,info.getContext());
|
||||||
|
|
||||||
if(var == null)
|
if (var == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
varContextInfo = info;
|
varContextInfo = info;
|
||||||
varSupplierNum = j;
|
varSupplierNum = j;
|
||||||
varSupplier = supplier;
|
varSupplier = supplier;
|
||||||
|
|
||||||
if(variable == null)
|
if (variable == null)
|
||||||
variable = var;
|
variable = var;
|
||||||
else
|
else
|
||||||
variable = EnvVarOperationProcessor.performOperation(variable,var);
|
variable = EnvVarOperationProcessor.performOperation(variable,var);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(variable != null){
|
if (variable != null) {
|
||||||
// if(variable.getOperation() == IEnvironmentVariable.ENVVAR_REMOVE)
|
// if (variable.getOperation() == IEnvironmentVariable.ENVVAR_REMOVE)
|
||||||
// return null;
|
// return null;
|
||||||
return new EnvVarDescriptor(variable,varContextInfo,varSupplierNum,varSupplier);
|
return new EnvVarDescriptor(variable,varContextInfo,varSupplierNum,varSupplier);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getVariable()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IEnvironmentVariable getVariable(String variableName,
|
public IEnvironmentVariable getVariable(String variableName, ICConfigurationDescription cfg, boolean resolveMacros) {
|
||||||
ICConfigurationDescription cfg, boolean resolveMacros) {
|
if (variableName == null || "".equals(variableName)) //$NON-NLS-1$
|
||||||
if(variableName == null || "".equals(variableName)) //$NON-NLS-1$
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
IEnvironmentContextInfo info = getContextInfo(cfg);
|
IEnvironmentContextInfo info = getContextInfo(cfg);
|
||||||
EnvVarDescriptor var = getVariable(variableName,info,true);
|
EnvVarDescriptor var = getVariable(variableName,info,true);
|
||||||
|
|
||||||
if(var != null && var.getOperation() != IEnvironmentVariable.ENVVAR_REMOVE){
|
if (var != null && var.getOperation() != IEnvironmentVariable.ENVVAR_REMOVE) {
|
||||||
return resolveMacros ? calculateResolvedVariable(var,info) : var;
|
return resolveMacros ? calculateResolvedVariable(var,info) : var;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnvironmentContextInfo getDefaultContextInfo(Object level){
|
IEnvironmentContextInfo getDefaultContextInfo(Object level) {
|
||||||
DefaultEnvironmentContextInfo info = new DefaultEnvironmentContextInfo(level);
|
DefaultEnvironmentContextInfo info = new DefaultEnvironmentContextInfo(level);
|
||||||
if(info.getSuppliers() == null)
|
if (info.getSuppliers() == null)
|
||||||
return null;
|
return null;
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* returns the context info that should be used for the given level
|
* @return the context info that should be used for the given level
|
||||||
* or null if the the given level is not supported
|
* or null if the the given level is not supported
|
||||||
*/
|
*/
|
||||||
public IEnvironmentContextInfo getContextInfo(Object level){
|
public IEnvironmentContextInfo getContextInfo(Object level) {
|
||||||
if(level instanceof ICConfigurationDescription)
|
if (level instanceof ICConfigurationDescription)
|
||||||
return fContributedEnvironment.appendEnvironment((ICConfigurationDescription)level) ?
|
return fContributedEnvironment.appendEnvironment((ICConfigurationDescription)level) ?
|
||||||
getDefaultContextInfo(level) : fContributedEnvironment.getContextInfo(level);
|
getDefaultContextInfo(level) : fContributedEnvironment.getContextInfo(level);
|
||||||
return getDefaultContextInfo(level);
|
return getDefaultContextInfo(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* returns a list of defined variables.
|
* @return a list of defined variables.
|
||||||
* the context information is taken from the contextInfo passed
|
* the context information is taken from the contextInfo passed
|
||||||
* @see org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo
|
|
||||||
*/
|
*/
|
||||||
public static EnvVarCollector getVariables(IEnvironmentContextInfo contextInfo,
|
public static EnvVarCollector getVariables(IEnvironmentContextInfo contextInfo, boolean includeParentLevels) {
|
||||||
boolean includeParentLevels) {
|
if (contextInfo == null)
|
||||||
if(contextInfo == null)
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
IEnvironmentContextInfo infos[] = getAllContextInfos(contextInfo);
|
IEnvironmentContextInfo infos[] = getAllContextInfos(contextInfo);
|
||||||
HashSet<String> set = null;
|
HashSet<String> set = null;
|
||||||
|
|
||||||
if(!includeParentLevels){
|
if (!includeParentLevels) {
|
||||||
ICoreEnvironmentVariableSupplier suppliers[] = infos[0].getSuppliers();
|
ICoreEnvironmentVariableSupplier suppliers[] = infos[0].getSuppliers();
|
||||||
set = new HashSet<String>();
|
set = new HashSet<String>();
|
||||||
for(int i = 0; i < suppliers.length; i++){
|
for(int i = 0; i < suppliers.length; i++) {
|
||||||
IEnvironmentVariable vars[] = suppliers[i].getVariables(infos[0].getContext());
|
IEnvironmentVariable vars[] = suppliers[i].getVariables(infos[0].getContext());
|
||||||
if(vars != null){
|
if (vars != null) {
|
||||||
for (IEnvironmentVariable var : vars) {
|
for (IEnvironmentVariable var : vars) {
|
||||||
String name = EnvVarOperationProcessor.normalizeName(var.
|
String name = EnvVarOperationProcessor.normalizeName(var.
|
||||||
getName());
|
getName());
|
||||||
if(name != null)
|
if (name != null)
|
||||||
set.add(name);
|
set.add(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!suppliers[i].appendEnvironment(infos[0].getContext()))
|
if (!suppliers[i].appendEnvironment(infos[0].getContext()))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(set.size() == 0)
|
if (set.size() == 0)
|
||||||
return new EnvVarCollector();
|
return new EnvVarCollector();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,18 +242,18 @@ public class EnvironmentVariableManager implements
|
||||||
|
|
||||||
for(int j = suppliers.length-1 ; j >= 0 ; j-- ) {
|
for(int j = suppliers.length-1 ; j >= 0 ; j-- ) {
|
||||||
ICoreEnvironmentVariableSupplier supplier = suppliers[j];
|
ICoreEnvironmentVariableSupplier supplier = suppliers[j];
|
||||||
if(!supplier.appendEnvironment(info.getContext())){
|
if (!supplier.appendEnvironment(info.getContext())) {
|
||||||
envVarSet.clear();
|
envVarSet.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnvironmentVariable vars[] = null;
|
IEnvironmentVariable vars[] = null;
|
||||||
if(set != null){
|
if (set != null) {
|
||||||
List<IEnvironmentVariable> varList = new ArrayList<IEnvironmentVariable>();
|
List<IEnvironmentVariable> varList = new ArrayList<IEnvironmentVariable>();
|
||||||
Iterator<String> iter = set.iterator();
|
Iterator<String> iter = set.iterator();
|
||||||
|
|
||||||
while(iter.hasNext()){
|
while(iter.hasNext()) {
|
||||||
IEnvironmentVariable var = supplier.getVariable(iter.next(),info.getContext());
|
IEnvironmentVariable var = supplier.getVariable(iter.next(),info.getContext());
|
||||||
if(var != null)
|
if (var != null)
|
||||||
varList.add(var);
|
varList.add(var);
|
||||||
}
|
}
|
||||||
vars = varList.toArray(new IEnvironmentVariable[varList.size()]);
|
vars = varList.toArray(new IEnvironmentVariable[varList.size()]);
|
||||||
|
@ -281,20 +268,15 @@ public class EnvironmentVariableManager implements
|
||||||
return envVarSet;
|
return envVarSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getVariables()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IEnvironmentVariable[] getVariables(ICConfigurationDescription cfg, boolean resolveMacros) {
|
public IEnvironmentVariable[] getVariables(ICConfigurationDescription cfg, boolean resolveMacros) {
|
||||||
|
|
||||||
|
|
||||||
IEnvironmentContextInfo info = getContextInfo(cfg);
|
IEnvironmentContextInfo info = getContextInfo(cfg);
|
||||||
EnvVarCollector varSet = getVariables(info,true);
|
EnvVarCollector varSet = getVariables(info,true);
|
||||||
|
|
||||||
EnvVarDescriptor vars[] = varSet != null ? varSet.toArray(false) : null;
|
EnvVarDescriptor vars[] = varSet != null ? varSet.toArray(false) : null;
|
||||||
|
|
||||||
if(vars != null){
|
if (vars != null) {
|
||||||
if(!resolveMacros)
|
if (!resolveMacros)
|
||||||
return vars;
|
return vars;
|
||||||
|
|
||||||
IEnvironmentVariable resolved[] = new IEnvironmentVariable[vars.length];
|
IEnvironmentVariable resolved[] = new IEnvironmentVariable[vars.length];
|
||||||
|
@ -305,12 +287,12 @@ public class EnvironmentVariableManager implements
|
||||||
return new EnvVarDescriptor[0];
|
return new EnvVarDescriptor[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* returns an array of the IContextInfo that holds the context informations
|
* @return an array of the IContextInfo that holds the context informations
|
||||||
* starting from the one passed to this method and including all subsequent parents
|
* starting from the one passed to this method and including all subsequent parents
|
||||||
*/
|
*/
|
||||||
public static IEnvironmentContextInfo[] getAllContextInfos(IEnvironmentContextInfo contextInfo){
|
public static IEnvironmentContextInfo[] getAllContextInfos(IEnvironmentContextInfo contextInfo) {
|
||||||
if(contextInfo == null)
|
if (contextInfo == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
List<IEnvironmentContextInfo> list = new ArrayList<IEnvironmentContextInfo>();
|
List<IEnvironmentContextInfo> list = new ArrayList<IEnvironmentContextInfo>();
|
||||||
|
@ -323,100 +305,91 @@ public class EnvironmentVariableManager implements
|
||||||
return list.toArray(new IEnvironmentContextInfo[list.size()]);
|
return list.toArray(new IEnvironmentContextInfo[list.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isWin32(){
|
private boolean isWin32() {
|
||||||
String os = System.getProperty("os.name").toLowerCase(); //$NON-NLS-1$
|
String os = System.getProperty("os.name").toLowerCase(); //$NON-NLS-1$
|
||||||
if (os.startsWith("windows ")) //$NON-NLS-1$
|
if (os.startsWith("windows ")) //$NON-NLS-1$
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getDefaultDelimiter()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getDefaultDelimiter() {
|
public String getDefaultDelimiter() {
|
||||||
return isWin32() ? DELIMITER_WIN32 : DELIMITER_UNIX;
|
return isWin32() ? DELIMITER_WIN32 : DELIMITER_UNIX;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#isVariableCaseSensitive()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVariableCaseSensitive() {
|
public boolean isVariableCaseSensitive() {
|
||||||
return !isWin32();
|
return !isWin32();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getSuppliers()
|
|
||||||
*/
|
|
||||||
public ICoreEnvironmentVariableSupplier[] getSuppliers(Object level) {
|
public ICoreEnvironmentVariableSupplier[] getSuppliers(Object level) {
|
||||||
IEnvironmentContextInfo info = getContextInfo(level);
|
IEnvironmentContextInfo info = getContextInfo(level);
|
||||||
if(info != null)
|
if (info != null)
|
||||||
return info.getSuppliers();
|
return info.getSuppliers();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* returns true if the first passed contextInfo is the child of the second one
|
* @return true if the first passed contextInfo is the child of the second one
|
||||||
*/
|
*/
|
||||||
public boolean checkParentContextRelation(IEnvironmentContextInfo child, IEnvironmentContextInfo parent){
|
public boolean checkParentContextRelation(IEnvironmentContextInfo child, IEnvironmentContextInfo parent) {
|
||||||
if(child == null || parent == null)
|
if (child == null || parent == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
IEnvironmentContextInfo enumInfo = child;
|
IEnvironmentContextInfo enumInfo = child;
|
||||||
do{
|
do{
|
||||||
if(parent.getContext() == enumInfo.getContext())
|
if (parent.getContext() == enumInfo.getContext())
|
||||||
return true;
|
return true;
|
||||||
}while((enumInfo = enumInfo.getNext()) != null);
|
}while((enumInfo = enumInfo.getNext()) != null);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnvironmentVariable calculateResolvedVariable(EnvVarDescriptor des, IEnvironmentContextInfo info){
|
public IEnvironmentVariable calculateResolvedVariable(EnvVarDescriptor des, IEnvironmentContextInfo info) {
|
||||||
if(des == null || info == null)
|
if (des == null || info == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return calculateResolvedVariable(des,getVariableSubstitutor(getMacroContextInfoForContext(info.getContext()),""," ")); //$NON-NLS-1$ //$NON-NLS-2$
|
return calculateResolvedVariable(des,getVariableSubstitutor(getMacroContextInfoForContext(info.getContext()),""," ")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnvironmentVariable calculateResolvedVariable(EnvVarDescriptor des, IVariableSubstitutor sub){
|
public IEnvironmentVariable calculateResolvedVariable(EnvVarDescriptor des, IVariableSubstitutor sub) {
|
||||||
if(des == null)
|
if (des == null)
|
||||||
return null;
|
return null;
|
||||||
IEnvironmentVariable var = des;
|
IEnvironmentVariable var = des;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
if(sub instanceof EnvVarVariableSubstitutor)
|
if (sub instanceof EnvVarVariableSubstitutor)
|
||||||
var = ((EnvVarVariableSubstitutor)sub).resolveVariable(des);
|
var = ((EnvVarVariableSubstitutor)sub).resolveVariable(des);
|
||||||
else if(des.getOperation() != IEnvironmentVariable.ENVVAR_REMOVE){
|
else if (des.getOperation() != IEnvironmentVariable.ENVVAR_REMOVE) {
|
||||||
String name = des.getName();
|
String name = des.getName();
|
||||||
var = new EnvironmentVariable(name,sub.resolveToString(name),des.getOperation(),des.getDelimiter());
|
var = new EnvironmentVariable(name,sub.resolveToString(name),des.getOperation(),des.getDelimiter());
|
||||||
}
|
}
|
||||||
} catch (CdtVariableException e){
|
} catch (CdtVariableException e) {
|
||||||
}
|
}
|
||||||
return var;
|
return var;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getMacroContextTypeFromContext(Object context){
|
protected int getMacroContextTypeFromContext(Object context) {
|
||||||
if(context instanceof ICConfigurationDescription)
|
if (context instanceof ICConfigurationDescription)
|
||||||
return ICoreVariableContextInfo.CONTEXT_CONFIGURATION;
|
return ICoreVariableContextInfo.CONTEXT_CONFIGURATION;
|
||||||
else
|
else
|
||||||
return ICoreVariableContextInfo.CONTEXT_WORKSPACE;
|
return ICoreVariableContextInfo.CONTEXT_WORKSPACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICoreVariableContextInfo getMacroContextInfoForContext(Object context){
|
public ICoreVariableContextInfo getMacroContextInfoForContext(Object context) {
|
||||||
return new DefaultVariableContextInfo(getMacroContextTypeFromContext(context),context);
|
return new DefaultVariableContextInfo(getMacroContextTypeFromContext(context),context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IVariableSubstitutor getVariableSubstitutor(IVariableContextInfo info, String inexistentMacroValue, String listDelimiter){
|
public IVariableSubstitutor getVariableSubstitutor(IVariableContextInfo info, String inexistentMacroValue, String listDelimiter) {
|
||||||
return new EnvVarVariableSubstitutor(info,inexistentMacroValue,listDelimiter);
|
return new EnvVarVariableSubstitutor(info,inexistentMacroValue,listDelimiter);
|
||||||
// if(fVariableSubstitutor == null)
|
// if (fVariableSubstitutor == null)
|
||||||
// fVariableSubstitutor = new EnvVarVariableSubstitutor(info,inexistentMacroValue,listDelimiter);
|
// fVariableSubstitutor = new EnvVarVariableSubstitutor(info,inexistentMacroValue,listDelimiter);
|
||||||
// else {
|
// else {
|
||||||
// try {
|
// try {
|
||||||
// fVariableSubstitutor.setMacroContextInfo(info);
|
// fVariableSubstitutor.setMacroContextInfo(info);
|
||||||
// fVariableSubstitutor.setInexistentMacroValue(inexistentMacroValue);
|
// fVariableSubstitutor.setInexistentMacroValue(inexistentMacroValue);
|
||||||
// fVariableSubstitutor.setListDelimiter(listDelimiter);
|
// fVariableSubstitutor.setListDelimiter(listDelimiter);
|
||||||
// } catch (CdtVariableException e){
|
// } catch (CdtVariableException e) {
|
||||||
// fVariableSubstitutor = new EnvVarVariableSubstitutor(info,inexistentMacroValue,listDelimiter);
|
// fVariableSubstitutor = new EnvVarVariableSubstitutor(info,inexistentMacroValue,listDelimiter);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
@ -428,5 +401,4 @@ public class EnvironmentVariableManager implements
|
||||||
return fContributedEnvironment;
|
return fContributedEnvironment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,43 +75,43 @@ public class UserDefinedEnvironmentSupplier extends
|
||||||
private boolean fNameOnly;
|
private boolean fNameOnly;
|
||||||
private int fCode;
|
private int fCode;
|
||||||
|
|
||||||
VarKey(IEnvironmentVariable var, boolean nameOnly){
|
VarKey(IEnvironmentVariable var, boolean nameOnly) {
|
||||||
fVar = var;
|
fVar = var;
|
||||||
fNameOnly = nameOnly;
|
fNameOnly = nameOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnvironmentVariable getVariable(){
|
public IEnvironmentVariable getVariable() {
|
||||||
return fVar;
|
return fVar;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if(obj == this)
|
if (obj == this)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(!(obj instanceof VarKey))
|
if (!(obj instanceof VarKey))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
VarKey other = (VarKey)obj;
|
VarKey other = (VarKey)obj;
|
||||||
|
|
||||||
IEnvironmentVariable otherVar = other.fVar;
|
IEnvironmentVariable otherVar = other.fVar;
|
||||||
|
|
||||||
if(fVar == otherVar)
|
if (fVar == otherVar)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(!CDataUtil.objectsEqual(fVar.getName(), otherVar.getName()))
|
if (!CDataUtil.objectsEqual(fVar.getName(), otherVar.getName()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(fNameOnly)
|
if (fNameOnly)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(fVar.getOperation() != otherVar.getOperation())
|
if (fVar.getOperation() != otherVar.getOperation())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(!CDataUtil.objectsEqual(fVar.getValue(), otherVar.getValue()))
|
if (!CDataUtil.objectsEqual(fVar.getValue(), otherVar.getValue()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(!CDataUtil.objectsEqual(fVar.getDelimiter(),otherVar.getDelimiter()))
|
if (!CDataUtil.objectsEqual(fVar.getDelimiter(),otherVar.getDelimiter()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -120,24 +120,24 @@ public class UserDefinedEnvironmentSupplier extends
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int code = fCode;
|
int code = fCode;
|
||||||
if(code == 0){
|
if (code == 0) {
|
||||||
code = 47;
|
code = 47;
|
||||||
|
|
||||||
String tmp = fVar.getName();
|
String tmp = fVar.getName();
|
||||||
if(tmp != null)
|
if (tmp != null)
|
||||||
code += tmp.hashCode();
|
code += tmp.hashCode();
|
||||||
|
|
||||||
if(fNameOnly)
|
if (fNameOnly)
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
code += fVar.getOperation();
|
code += fVar.getOperation();
|
||||||
|
|
||||||
tmp = fVar.getValue();
|
tmp = fVar.getValue();
|
||||||
if(tmp != null)
|
if (tmp != null)
|
||||||
code += tmp.hashCode();
|
code += tmp.hashCode();
|
||||||
|
|
||||||
tmp = fVar.getDelimiter();
|
tmp = fVar.getDelimiter();
|
||||||
if(tmp != null)
|
if (tmp != null)
|
||||||
code += tmp.hashCode();
|
code += tmp.hashCode();
|
||||||
|
|
||||||
fCode = code;
|
fCode = code;
|
||||||
|
@ -146,20 +146,20 @@ public class UserDefinedEnvironmentSupplier extends
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public StorableEnvironment getEnvironment(Object context){
|
public StorableEnvironment getEnvironment(Object context) {
|
||||||
return getEnvironment(context,true);
|
return getEnvironment(context,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected StorableEnvironment getEnvironment(Object context, boolean forceLoad){
|
protected StorableEnvironment getEnvironment(Object context, boolean forceLoad) {
|
||||||
// if(context == null)
|
// if (context == null)
|
||||||
// return null;
|
// return null;
|
||||||
|
|
||||||
StorableEnvironment env = null;
|
StorableEnvironment env = null;
|
||||||
if(context instanceof IInternalCCfgInfo){
|
if (context instanceof IInternalCCfgInfo) {
|
||||||
try {
|
try {
|
||||||
CConfigurationSpecSettings settings = ((IInternalCCfgInfo)context).getSpecSettings();
|
CConfigurationSpecSettings settings = ((IInternalCCfgInfo)context).getSpecSettings();
|
||||||
env = settings.getEnvironment();
|
env = settings.getEnvironment();
|
||||||
if(env == null && forceLoad){
|
if (env == null && forceLoad) {
|
||||||
env = loadEnvironment(context, settings.isReadOnly());
|
env = loadEnvironment(context, settings.isReadOnly());
|
||||||
settings.setEnvironment(env);
|
settings.setEnvironment(env);
|
||||||
}
|
}
|
||||||
|
@ -167,8 +167,8 @@ public class UserDefinedEnvironmentSupplier extends
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(context instanceof IWorkspace || context == null){
|
else if (context instanceof IWorkspace || context == null) {
|
||||||
if(fWorkspaceVariables == null && forceLoad)
|
if (fWorkspaceVariables == null && forceLoad)
|
||||||
fWorkspaceVariables = loadEnvironment(context, false);
|
fWorkspaceVariables = loadEnvironment(context, false);
|
||||||
env = fWorkspaceVariables;
|
env = fWorkspaceVariables;
|
||||||
}
|
}
|
||||||
|
@ -177,37 +177,37 @@ public class UserDefinedEnvironmentSupplier extends
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ISerializeInfo getSerializeInfo(Object context){
|
protected ISerializeInfo getSerializeInfo(Object context) {
|
||||||
ISerializeInfo serializeInfo = null;
|
ISerializeInfo serializeInfo = null;
|
||||||
|
|
||||||
if(context instanceof ICConfigurationDescription){
|
if (context instanceof ICConfigurationDescription) {
|
||||||
final ICConfigurationDescription cfg = (ICConfigurationDescription)context;
|
final ICConfigurationDescription cfg = (ICConfigurationDescription)context;
|
||||||
final String name = cfg.getId();
|
final String name = cfg.getId();
|
||||||
if(name != null)
|
if (name != null)
|
||||||
serializeInfo = new ISerializeInfo(){
|
serializeInfo = new ISerializeInfo() {
|
||||||
@Override
|
@Override
|
||||||
public Preferences getNode(){
|
public Preferences getNode() {
|
||||||
return getConfigurationNode(cfg.getProjectDescription());
|
return getConfigurationNode(cfg.getProjectDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPrefName(){
|
public String getPrefName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else if(context == null || context instanceof IWorkspace){
|
else if (context == null || context instanceof IWorkspace) {
|
||||||
final Preferences prefs = getWorkspaceNode();
|
final Preferences prefs = getWorkspaceNode();
|
||||||
final String name = PREFNAME_WORKSPACE;
|
final String name = PREFNAME_WORKSPACE;
|
||||||
if (prefs != null)
|
if (prefs != null)
|
||||||
serializeInfo = new ISerializeInfo(){
|
serializeInfo = new ISerializeInfo() {
|
||||||
@Override
|
@Override
|
||||||
public Preferences getNode(){
|
public Preferences getNode() {
|
||||||
return prefs;
|
return prefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPrefName(){
|
public String getPrefName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -215,74 +215,74 @@ public class UserDefinedEnvironmentSupplier extends
|
||||||
return serializeInfo;
|
return serializeInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Preferences getConfigurationNode(ICProjectDescription projDes){
|
private Preferences getConfigurationNode(ICProjectDescription projDes) {
|
||||||
Preferences prefNode = getProjectNode(projDes);
|
Preferences prefNode = getProjectNode(projDes);
|
||||||
if(prefNode == null)
|
if (prefNode == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return prefNode.node(NODENAME_CFG);
|
return prefNode.node(NODENAME_CFG);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Preferences getProjectNode(ICProjectDescription projDes){
|
private Preferences getProjectNode(ICProjectDescription projDes) {
|
||||||
if(projDes == null)
|
if (projDes == null)
|
||||||
return null;
|
return null;
|
||||||
IProject project = projDes.getProject();
|
IProject project = projDes.getProject();
|
||||||
if(!project.exists())
|
if (!project.exists())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
Preferences prefNode = new ProjectScope(project).getNode(CCorePlugin.PLUGIN_ID);
|
Preferences prefNode = new ProjectScope(project).getNode(CCorePlugin.PLUGIN_ID);
|
||||||
if(prefNode == null)
|
if (prefNode == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return prefNode.node(NODENAME);
|
return prefNode.node(NODENAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Preferences getWorkspaceNode(){
|
private Preferences getWorkspaceNode() {
|
||||||
Preferences prefNode = new InstanceScope().getNode(CCorePlugin.PLUGIN_ID);
|
Preferences prefNode = new InstanceScope().getNode(CCorePlugin.PLUGIN_ID);
|
||||||
if(prefNode == null)
|
if (prefNode == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return prefNode.node(NODENAME);
|
return prefNode.node(NODENAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkInexistentConfigurations(ICProjectDescription projDes){
|
public void checkInexistentConfigurations(ICProjectDescription projDes) {
|
||||||
Preferences prefNode = getConfigurationNode(projDes);
|
Preferences prefNode = getConfigurationNode(projDes);
|
||||||
if(prefNode == null)
|
if (prefNode == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
String ids[] = prefNode.keys();
|
String ids[] = prefNode.keys();
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (String id : ids) {
|
for (String id : ids) {
|
||||||
if(projDes.getConfigurationById(id) == null){
|
if (projDes.getConfigurationById(id) == null) {
|
||||||
prefNode.remove(id);
|
prefNode.remove(id);
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(found)
|
if (found)
|
||||||
prefNode.flush();
|
prefNode.flush();
|
||||||
}
|
}
|
||||||
catch(BackingStoreException e){
|
catch(BackingStoreException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void storeWorkspaceEnvironment(boolean force){
|
public void storeWorkspaceEnvironment(boolean force) {
|
||||||
if(fWorkspaceVariables != null){
|
if (fWorkspaceVariables != null) {
|
||||||
try{
|
try{
|
||||||
storeEnvironment(fWorkspaceVariables,ResourcesPlugin.getWorkspace(),force, true);
|
storeEnvironment(fWorkspaceVariables,ResourcesPlugin.getWorkspace(),force, true);
|
||||||
} catch(CoreException e){
|
} catch(CoreException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public StorableEnvironment getWorkspaceEnvironmentCopy(){
|
public StorableEnvironment getWorkspaceEnvironmentCopy() {
|
||||||
StorableEnvironment envVar = getEnvironment(null);
|
StorableEnvironment envVar = getEnvironment(null);
|
||||||
return new StorableEnvironment(envVar, false);
|
return new StorableEnvironment(envVar, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setWorkspaceEnvironment(StorableEnvironment env){
|
public boolean setWorkspaceEnvironment(StorableEnvironment env) {
|
||||||
StorableEnvironment oldEnv = getEnvironment(null);
|
StorableEnvironment oldEnv = getEnvironment(null);
|
||||||
|
|
||||||
fWorkspaceVariables = new StorableEnvironment(env, false);
|
fWorkspaceVariables = new StorableEnvironment(env, false);
|
||||||
|
@ -296,13 +296,13 @@ public class UserDefinedEnvironmentSupplier extends
|
||||||
return event != null;
|
return event != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static EnvironmentChangeEvent createEnvironmentChangeEvent(IEnvironmentVariable[] newVars, IEnvironmentVariable[] oldVars){
|
static EnvironmentChangeEvent createEnvironmentChangeEvent(IEnvironmentVariable[] newVars, IEnvironmentVariable[] oldVars) {
|
||||||
IEnvironmentVariable[] addedVars = null, removedVars = null, changedVars = null;
|
IEnvironmentVariable[] addedVars = null, removedVars = null, changedVars = null;
|
||||||
|
|
||||||
if(oldVars == null || oldVars.length == 0){
|
if (oldVars == null || oldVars.length == 0) {
|
||||||
if(newVars != null && newVars.length != 0)
|
if (newVars != null && newVars.length != 0)
|
||||||
addedVars = newVars.clone();
|
addedVars = newVars.clone();
|
||||||
} else if(newVars == null || newVars.length == 0){
|
} else if (newVars == null || newVars.length == 0) {
|
||||||
removedVars = oldVars.clone();
|
removedVars = oldVars.clone();
|
||||||
} else {
|
} else {
|
||||||
HashSet<VarKey> newSet = new HashSet<VarKey>(newVars.length);
|
HashSet<VarKey> newSet = new HashSet<VarKey>(newVars.length);
|
||||||
|
@ -322,11 +322,11 @@ public class UserDefinedEnvironmentSupplier extends
|
||||||
newSet.removeAll(oldSet);
|
newSet.removeAll(oldSet);
|
||||||
oldSet.removeAll(newSetCopy);
|
oldSet.removeAll(newSetCopy);
|
||||||
|
|
||||||
if(newSet.size() != 0){
|
if (newSet.size() != 0) {
|
||||||
addedVars = varsFromKeySet(newSet);
|
addedVars = varsFromKeySet(newSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(oldSet.size() != 0){
|
if (oldSet.size() != 0) {
|
||||||
removedVars = varsFromKeySet(oldSet);
|
removedVars = varsFromKeySet(oldSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,19 +341,19 @@ public class UserDefinedEnvironmentSupplier extends
|
||||||
modifiedSet.remove(new VarKey(oldVar, false));
|
modifiedSet.remove(new VarKey(oldVar, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(modifiedSet.size() != 0)
|
if (modifiedSet.size() != 0)
|
||||||
changedVars = varsFromKeySet(modifiedSet);
|
changedVars = varsFromKeySet(modifiedSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(addedVars != null || removedVars != null || changedVars != null)
|
if (addedVars != null || removedVars != null || changedVars != null)
|
||||||
return new EnvironmentChangeEvent(addedVars, removedVars, changedVars);
|
return new EnvironmentChangeEvent(addedVars, removedVars, changedVars);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static IEnvironmentVariable[] varsFromKeySet(Set<VarKey> set){
|
static IEnvironmentVariable[] varsFromKeySet(Set<VarKey> set) {
|
||||||
IEnvironmentVariable vars[] = new IEnvironmentVariable[set.size()];
|
IEnvironmentVariable vars[] = new IEnvironmentVariable[set.size()];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(Iterator<VarKey> iter = set.iterator(); iter.hasNext(); i++){
|
for(Iterator<VarKey> iter = set.iterator(); iter.hasNext(); i++) {
|
||||||
VarKey key = iter.next();
|
VarKey key = iter.next();
|
||||||
vars[i] = key.getVariable();
|
vars[i] = key.getVariable();
|
||||||
}
|
}
|
||||||
|
@ -362,7 +362,7 @@ public class UserDefinedEnvironmentSupplier extends
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void storeProjectEnvironment(ICProjectDescription des, boolean force){
|
public void storeProjectEnvironment(ICProjectDescription des, boolean force) {
|
||||||
ICConfigurationDescription cfgs[] = des.getConfigurations();
|
ICConfigurationDescription cfgs[] = des.getConfigurations();
|
||||||
for (ICConfigurationDescription cfg : cfgs) {
|
for (ICConfigurationDescription cfg : cfgs) {
|
||||||
storeEnvironment(cfg, force, false);
|
storeEnvironment(cfg, force, false);
|
||||||
|
@ -375,9 +375,9 @@ public class UserDefinedEnvironmentSupplier extends
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void storeEnvironment(Object context, boolean force, boolean flush){
|
private void storeEnvironment(Object context, boolean force, boolean flush) {
|
||||||
StorableEnvironment env = getEnvironment(context, false);
|
StorableEnvironment env = getEnvironment(context, false);
|
||||||
if(env != null){
|
if (env != null) {
|
||||||
try {
|
try {
|
||||||
storeEnvironment(env, context, force, flush);
|
storeEnvironment(env, context, force, flush);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
@ -385,12 +385,9 @@ public class UserDefinedEnvironmentSupplier extends
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariable()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IEnvironmentVariable getVariable(String name, Object context) {
|
public IEnvironmentVariable getVariable(String name, Object context) {
|
||||||
if(getValidName(name) == null)
|
if (getValidName(name) == null)
|
||||||
return null;
|
return null;
|
||||||
IEnvironmentVariable var = fOverrideVariables.getVariable(name);
|
IEnvironmentVariable var = fOverrideVariables.getVariable(name);
|
||||||
StorableEnvironment env = getEnvironment(context);
|
StorableEnvironment env = getEnvironment(context);
|
||||||
|
@ -399,13 +396,10 @@ public class UserDefinedEnvironmentSupplier extends
|
||||||
return EnvVarOperationProcessor.performOperation(env.getVariable(name), var);
|
return EnvVarOperationProcessor.performOperation(env.getVariable(name), var);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariables()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IEnvironmentVariable[] getVariables(Object context) {
|
public IEnvironmentVariable[] getVariables(Object context) {
|
||||||
StorableEnvironment env = getEnvironment(context);
|
StorableEnvironment env = getEnvironment(context);
|
||||||
if(env == null)
|
if (env == null)
|
||||||
return null;
|
return null;
|
||||||
IEnvironmentVariable[] override = filterVariables(fOverrideVariables.getVariables());
|
IEnvironmentVariable[] override = filterVariables(fOverrideVariables.getVariables());
|
||||||
IEnvironmentVariable[] normal = filterVariables(env.getVariables());
|
IEnvironmentVariable[] normal = filterVariables(env.getVariables());
|
||||||
|
@ -442,88 +436,88 @@ public class UserDefinedEnvironmentSupplier extends
|
||||||
return fOverrideVariables.createVariable(name,value,op,delimiter);
|
return fOverrideVariables.createVariable(name,value,op,delimiter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnvironmentVariable createVariable(String name, String value, int op, String delimiter, Object context){
|
public IEnvironmentVariable createVariable(String name, String value, int op, String delimiter, Object context) {
|
||||||
if(getValidName(name) == null)
|
if (getValidName(name) == null)
|
||||||
return null;
|
return null;
|
||||||
StorableEnvironment env = getEnvironment(context);
|
StorableEnvironment env = getEnvironment(context);
|
||||||
if(env == null)
|
if (env == null)
|
||||||
return null;
|
return null;
|
||||||
IEnvironmentVariable var = env.createVariable(name,value,op,delimiter);
|
IEnvironmentVariable var = env.createVariable(name,value,op,delimiter);
|
||||||
if(env.isChanged()){
|
if (env.isChanged()) {
|
||||||
// updateProjectInfo(context);
|
// updateProjectInfo(context);
|
||||||
env.setChanged(false);
|
env.setChanged(false);
|
||||||
}
|
}
|
||||||
return var;
|
return var;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnvironmentVariable deleteVariable(String name, Object context){
|
public IEnvironmentVariable deleteVariable(String name, Object context) {
|
||||||
StorableEnvironment env = getEnvironment(context);
|
StorableEnvironment env = getEnvironment(context);
|
||||||
if(env == null)
|
if (env == null)
|
||||||
return null;
|
return null;
|
||||||
IEnvironmentVariable var = env.deleteVariable(name);
|
IEnvironmentVariable var = env.deleteVariable(name);
|
||||||
if(var != null){
|
if (var != null) {
|
||||||
// updateProjectInfo(context);
|
// updateProjectInfo(context);
|
||||||
}
|
}
|
||||||
return var;
|
return var;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteAll(Object context){
|
public void deleteAll(Object context) {
|
||||||
StorableEnvironment env = getEnvironment(context);
|
StorableEnvironment env = getEnvironment(context);
|
||||||
if(env == null)
|
if (env == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(env.deleteAll()){
|
if (env.deleteAll()) {
|
||||||
// updateProjectInfo(context);
|
// updateProjectInfo(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVariables(IEnvironmentVariable vars[], Object context){
|
public void setVariables(IEnvironmentVariable vars[], Object context) {
|
||||||
StorableEnvironment env = getEnvironment(context);
|
StorableEnvironment env = getEnvironment(context);
|
||||||
if(env == null)
|
if (env == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
env.setVariales(vars);
|
env.setVariales(vars);
|
||||||
if(env.isChanged()){
|
if (env.isChanged()) {
|
||||||
// updateProjectInfo(context);
|
// updateProjectInfo(context);
|
||||||
env.setChanged(false);
|
env.setChanged(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// protected void updateProjectInfo(Object context){
|
// protected void updateProjectInfo(Object context) {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// protected void cfgVarsModified(ICConfigurationDescription cfg){
|
// protected void cfgVarsModified(ICConfigurationDescription cfg) {
|
||||||
// cfg.setRebuildState(true);
|
// cfg.setRebuildState(true);
|
||||||
// EnvironmentVariableProvider.getDefault().checkBuildPathVariables(cfg);
|
// EnvironmentVariableProvider.getDefault().checkBuildPathVariables(cfg);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
protected String getValidName(String name){
|
protected String getValidName(String name) {
|
||||||
if(name == null || (name = name.trim()).length() == 0)
|
if (name == null || (name = name.trim()).length() == 0)
|
||||||
return null;
|
return null;
|
||||||
// if(fNonOverloadableVariables != null){
|
// if (fNonOverloadableVariables != null) {
|
||||||
// for(int i = 0; i < fNonOverloadableVariables.length; i++){
|
// for(int i = 0; i < fNonOverloadableVariables.length; i++) {
|
||||||
// if(fNonOverloadableVariables[i].equals(EnvVarOperationProcessor.normalizeName(name)))
|
// if (fNonOverloadableVariables[i].equals(EnvVarOperationProcessor.normalizeName(name)))
|
||||||
// return null;
|
// return null;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IEnvironmentVariable[] filterVariables(IEnvironmentVariable variables[]){
|
protected IEnvironmentVariable[] filterVariables(IEnvironmentVariable variables[]) {
|
||||||
return EnvVarOperationProcessor.filterVariables(variables,null);
|
return EnvVarOperationProcessor.filterVariables(variables,null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean appendEnvironment(Object context) {
|
public boolean appendEnvironment(Object context) {
|
||||||
StorableEnvironment env = getEnvironment(context);
|
StorableEnvironment env = getEnvironment(context);
|
||||||
if(env == null)
|
if (env == null)
|
||||||
return true;
|
return true;
|
||||||
return env.appendEnvironment();
|
return env.appendEnvironment();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean appendContributedEnvironment(Object context){
|
public boolean appendContributedEnvironment(Object context) {
|
||||||
StorableEnvironment env = getEnvironment(context);
|
StorableEnvironment env = getEnvironment(context);
|
||||||
if(env == null)
|
if (env == null)
|
||||||
return true;
|
return true;
|
||||||
return env.appendContributedEnvironment();
|
return env.appendContributedEnvironment();
|
||||||
}
|
}
|
||||||
|
@ -531,21 +525,21 @@ public class UserDefinedEnvironmentSupplier extends
|
||||||
|
|
||||||
public void setAppendEnvironment(boolean append, Object context) {
|
public void setAppendEnvironment(boolean append, Object context) {
|
||||||
StorableEnvironment env = getEnvironment(context);
|
StorableEnvironment env = getEnvironment(context);
|
||||||
if(env != null){
|
if (env != null) {
|
||||||
env.setAppendEnvironment(append);
|
env.setAppendEnvironment(append);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAppendContributedEnvironment(boolean append, Object context){
|
public void setAppendContributedEnvironment(boolean append, Object context) {
|
||||||
StorableEnvironment env = getEnvironment(context);
|
StorableEnvironment env = getEnvironment(context);
|
||||||
if(env != null){
|
if (env != null) {
|
||||||
env.setAppendContributedEnvironment(append);
|
env.setAppendContributedEnvironment(append);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void restoreDefaults(Object context){
|
public void restoreDefaults(Object context) {
|
||||||
StorableEnvironment env = getEnvironment(context);
|
StorableEnvironment env = getEnvironment(context);
|
||||||
if(env != null){
|
if (env != null) {
|
||||||
env.restoreDefaults();
|
env.restoreDefaults();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue