mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +02:00
Some modifications and fixes for the build Environment and Macros were added
This commit is contained in:
parent
4fd7b386b2
commit
fa2c1a50ab
18 changed files with 604 additions and 159 deletions
|
@ -47,7 +47,7 @@ public interface IEnvironmentVariableProvider{
|
||||||
* 4. null to represent the system environment passed to eclipse
|
* 4. null to represent the system environment passed to eclipse
|
||||||
*/
|
*/
|
||||||
public IBuildEnvironmentVariable getVariable(
|
public IBuildEnvironmentVariable getVariable(
|
||||||
String variableName, Object level, boolean includeParentLevels);
|
String variableName, Object level, boolean includeParentLevels, boolean resolveMacros);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -58,7 +58,7 @@ public interface IEnvironmentVariableProvider{
|
||||||
* @return the array of IBuildEnvironmentVariable that represents the environment variables
|
* @return the array of IBuildEnvironmentVariable that represents the environment variables
|
||||||
*/
|
*/
|
||||||
public IBuildEnvironmentVariable[] getVariables(
|
public IBuildEnvironmentVariable[] getVariables(
|
||||||
Object level, boolean includeParentLevels);
|
Object level, boolean includeParentLevels, boolean resolveMacros);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -743,19 +743,13 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
||||||
launcher.showCommand(true);
|
launcher.showCommand(true);
|
||||||
|
|
||||||
// Set the environmennt
|
// Set the environmennt
|
||||||
IBuildEnvironmentVariable variables[] = ManagedBuildManager.getEnvironmentVariableProvider().getVariables(cfg,true);
|
IBuildEnvironmentVariable variables[] = ManagedBuildManager.getEnvironmentVariableProvider().getVariables(cfg,true,true);
|
||||||
IBuildMacroProvider macroProvier = ManagedBuildManager.getBuildMacroProvider();
|
|
||||||
String[] env = null;
|
String[] env = null;
|
||||||
ArrayList envList = new ArrayList();
|
ArrayList envList = new ArrayList();
|
||||||
if (variables != null) {
|
if (variables != null) {
|
||||||
for(int i = 0; i < variables.length; i++){
|
for(int i = 0; i < variables.length; i++){
|
||||||
//resolve the build macros in environment variables
|
|
||||||
try{
|
|
||||||
envList.add(variables[i].getName() + "=" + macroProvier.resolveValue(variables[i].getValue(),""," ",IBuildMacroProvider.CONTEXT_CONFIGURATION,cfg)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
||||||
} catch(BuildMacroException e) {
|
|
||||||
envList.add(variables[i].getName() + "=" + variables[i].getValue()); //$NON-NLS-1$
|
envList.add(variables[i].getName() + "=" + variables[i].getValue()); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
|
||||||
env = (String[]) envList.toArray(new String[envList.size()]);
|
env = (String[]) envList.toArray(new String[envList.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1098,7 +1098,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
||||||
*/
|
*/
|
||||||
private String getCWD() {
|
private String getCWD() {
|
||||||
String cwd = ""; //$NON-NLS-1$
|
String cwd = ""; //$NON-NLS-1$
|
||||||
IBuildEnvironmentVariable cwdvar = ManagedBuildManager.getEnvironmentVariableProvider().getVariable("CWD", getDefaultConfiguration(), false); //$NON-NLS-1$
|
IBuildEnvironmentVariable cwdvar = ManagedBuildManager.getEnvironmentVariableProvider().getVariable("CWD", getDefaultConfiguration(), false, true); //$NON-NLS-1$
|
||||||
if (cwdvar != null) { cwd = cwdvar.getValue().replace('\\','/'); } //$NON-NLS-1$ //$NON-NLS-2$
|
if (cwdvar != null) { cwd = cwdvar.getValue().replace('\\','/'); } //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
return cwd;
|
return cwd;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,10 @@ public class EnvVarCollector {
|
||||||
* @param vars
|
* @param vars
|
||||||
*/
|
*/
|
||||||
public void add(IBuildEnvironmentVariable vars[]){
|
public void add(IBuildEnvironmentVariable vars[]){
|
||||||
|
add(vars,null,-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(IBuildEnvironmentVariable vars[], IContextInfo info, int num){
|
||||||
if(vars == null)
|
if(vars == null)
|
||||||
return;
|
return;
|
||||||
boolean isCaseInsensitive = !EnvironmentVariableProvider.getDefault().isVariableCaseSensitive();
|
boolean isCaseInsensitive = !EnvironmentVariableProvider.getDefault().isVariableCaseSensitive();
|
||||||
|
@ -55,11 +59,15 @@ public class EnvVarCollector {
|
||||||
fMap = new HashMap();
|
fMap = new HashMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(noCheck)
|
EnvVarDescriptor des = null;
|
||||||
fMap.put(name,var);
|
if(noCheck || (des = (EnvVarDescriptor)fMap.get(name)) == null){
|
||||||
|
des = new EnvVarDescriptor(var,info,num);
|
||||||
|
fMap.put(name,des);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
IBuildEnvironmentVariable prevVar = (IBuildEnvironmentVariable)fMap.remove(name);
|
des.setContextInfo(info);
|
||||||
fMap.put(name,EnvVarOperationProcessor.performOperation(prevVar,var));
|
des.setSupplierNum(num);
|
||||||
|
des.setVariable(EnvVarOperationProcessor.performOperation(des.getOriginalVariable(),var));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,19 +78,19 @@ public class EnvVarCollector {
|
||||||
* @param includeRemoved true if removed variables should be included in the resulting array
|
* @param includeRemoved true if removed variables should be included in the resulting array
|
||||||
* @return IBuildEnvironmentVariable[]
|
* @return IBuildEnvironmentVariable[]
|
||||||
*/
|
*/
|
||||||
public IBuildEnvironmentVariable[] toArray(boolean includeRemoved){
|
public EnvVarDescriptor[] toArray(boolean includeRemoved){
|
||||||
if(fMap == null)
|
if(fMap == null)
|
||||||
return new IBuildEnvironmentVariable[0];
|
return new EnvVarDescriptor[0];
|
||||||
Collection values = fMap.values();
|
Collection values = fMap.values();
|
||||||
List list = new ArrayList();
|
List list = new ArrayList();
|
||||||
Iterator iter = values.iterator();
|
Iterator iter = values.iterator();
|
||||||
while(iter.hasNext()){
|
while(iter.hasNext()){
|
||||||
IBuildEnvironmentVariable var = (IBuildEnvironmentVariable)iter.next();
|
EnvVarDescriptor des = (EnvVarDescriptor)iter.next();
|
||||||
if(var != null &&
|
if(des != null &&
|
||||||
(includeRemoved || var.getOperation() != IBuildEnvironmentVariable.ENVVAR_REMOVE))
|
(includeRemoved || des.getOperation() != IBuildEnvironmentVariable.ENVVAR_REMOVE))
|
||||||
list.add(var);
|
list.add(des);
|
||||||
}
|
}
|
||||||
return (IBuildEnvironmentVariable[])list.toArray(new IBuildEnvironmentVariable[list.size()]);
|
return (EnvVarDescriptor[])list.toArray(new EnvVarDescriptor[list.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -91,14 +99,14 @@ public class EnvVarCollector {
|
||||||
* @param name a variable name
|
* @param name a variable name
|
||||||
* @return IBuildEnvironmentVariable
|
* @return IBuildEnvironmentVariable
|
||||||
*/
|
*/
|
||||||
public IBuildEnvironmentVariable getVariable(String name){
|
public EnvVarDescriptor getVariable(String name){
|
||||||
if(fMap == null)
|
if(fMap == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if(!EnvironmentVariableProvider.getDefault().isVariableCaseSensitive())
|
if(!EnvironmentVariableProvider.getDefault().isVariableCaseSensitive())
|
||||||
name = name.toUpperCase();
|
name = name.toUpperCase();
|
||||||
|
|
||||||
return (IBuildEnvironmentVariable)fMap.get(name);
|
return (EnvVarDescriptor)fMap.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,7 +115,7 @@ public class EnvVarCollector {
|
||||||
*
|
*
|
||||||
* @return IBuildEnvironmentVariable[]
|
* @return IBuildEnvironmentVariable[]
|
||||||
*/
|
*/
|
||||||
public IBuildEnvironmentVariable[] getVariables(){
|
public EnvVarDescriptor[] getVariables(){
|
||||||
return toArray(true);
|
return toArray(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,111 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.internal.envvar;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* this class represents the environment variable-relaed information.
|
||||||
|
* That is the context for which the variable is defined and the supplier
|
||||||
|
* that supplies the variable
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class EnvVarDescriptor implements IBuildEnvironmentVariable{
|
||||||
|
private IBuildEnvironmentVariable fVariable;
|
||||||
|
private IContextInfo fContextInfo;
|
||||||
|
private int fSupplierNum;
|
||||||
|
|
||||||
|
public EnvVarDescriptor(IBuildEnvironmentVariable variable, IContextInfo contextInfo, int supplierNum){
|
||||||
|
fVariable = variable;
|
||||||
|
fContextInfo = contextInfo;
|
||||||
|
fSupplierNum = supplierNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IContextInfo getContextInfo() {
|
||||||
|
return fContextInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSupplierNum() {
|
||||||
|
return fSupplierNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBuildEnvironmentVariable getOriginalVariable() {
|
||||||
|
return fVariable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return fVariable.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return fVariable.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOperation() {
|
||||||
|
return fVariable.getOperation();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDelimiter() {
|
||||||
|
return fVariable.getDelimiter();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContextInfo(IContextInfo contextInfo) {
|
||||||
|
fContextInfo = contextInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSupplierNum(int supplierNum) {
|
||||||
|
fSupplierNum = supplierNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVariable(IBuildEnvironmentVariable variable) {
|
||||||
|
fVariable = variable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* public String getResolvedValue(int contextType, Object contextData){
|
||||||
|
String value = null;
|
||||||
|
if(getOperation() != IBuildEnvironmentVariable.ENVVAR_REMOVE){
|
||||||
|
String name = getName();
|
||||||
|
value = getValue();
|
||||||
|
if(value != null && value.length() > 0){
|
||||||
|
int supplierNum = -1;
|
||||||
|
IMacroContextInfo macroInfo = getMacroContextInfo(fContextInfo);
|
||||||
|
IBuildMacroSupplier macroSuppliers[] = macroInfo.getSuppliers();
|
||||||
|
for(int i = 0; i < macroSuppliers.length; i++){
|
||||||
|
if(macroSuppliers[i] instanceof EnvironmentMacroSupplier){
|
||||||
|
supplierNum = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DefaultMacroSubstitutor sub = new DefaultMacroSubstitutor(new DefaultMacroContextInfo(contextType,contextData),""," ");//,delimiters,""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
|
try{
|
||||||
|
value = sub.resolveToString(new BuildMacro(name,IBuildMacro.VALUE_TEXT,value),macroInfo,supplierNum);
|
||||||
|
} catch (BuildMacroException e){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IMacroContextInfo getMacroContextInfo(IContextInfo info){
|
||||||
|
Object context = info.getContext();
|
||||||
|
if(context instanceof IConfiguration)
|
||||||
|
return new DefaultMacroContextInfo(IBuildMacroProvider.CONTEXT_CONFIGURATION,context);
|
||||||
|
else if(context instanceof IManagedProject)
|
||||||
|
return new DefaultMacroContextInfo(IBuildMacroProvider.CONTEXT_PROJECT,context);
|
||||||
|
else if(context instanceof IWorkspace)
|
||||||
|
return new DefaultMacroContextInfo(IBuildMacroProvider.CONTEXT_WORKSPACE,context);
|
||||||
|
else if(context == null)
|
||||||
|
return new DefaultMacroContextInfo(IBuildMacroProvider.CONTEXT_ECLIPSEENV,context);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
|
@ -19,12 +19,23 @@ import java.util.List;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IBuildPathResolver;
|
import org.eclipse.cdt.managedbuilder.core.IBuildPathResolver;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
|
import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||||
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
|
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
|
||||||
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentBuildPathsChangeListener;
|
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentBuildPathsChangeListener;
|
||||||
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
|
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
|
||||||
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier;
|
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroContextInfo;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroSubstitutor;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.macros.EnvironmentMacroSupplier;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.macros.IMacroSubstitutor;
|
||||||
|
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
|
||||||
|
import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
|
||||||
|
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
|
||||||
|
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier;
|
||||||
|
import org.eclipse.core.resources.IWorkspace;
|
||||||
import org.eclipse.core.runtime.QualifiedName;
|
import org.eclipse.core.runtime.QualifiedName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,6 +55,8 @@ public class EnvironmentVariableProvider implements
|
||||||
private static EnvironmentVariableProvider fInstance = null;
|
private static EnvironmentVariableProvider fInstance = null;
|
||||||
private List fListeners = null;
|
private List fListeners = null;
|
||||||
|
|
||||||
|
private EnvVarMacroSubstitutor fMacroSubstitutor;
|
||||||
|
|
||||||
private StoredBuildPathEnvironmentContainer fIncludeStoredBuildPathVariables;
|
private StoredBuildPathEnvironmentContainer fIncludeStoredBuildPathVariables;
|
||||||
private StoredBuildPathEnvironmentContainer fLibraryStoredBuildPathVariables;
|
private StoredBuildPathEnvironmentContainer fLibraryStoredBuildPathVariables;
|
||||||
|
|
||||||
|
@ -79,6 +92,55 @@ public class EnvironmentVariableProvider implements
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class EnvVarMacroSubstitutor extends DefaultMacroSubstitutor {
|
||||||
|
private String fDefaultDelimiter;
|
||||||
|
public EnvVarMacroSubstitutor(int contextType, Object contextData, String inexistentMacroValue, String listDelimiter){
|
||||||
|
super(contextType,contextData,inexistentMacroValue,listDelimiter);
|
||||||
|
fDefaultDelimiter = listDelimiter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnvVarMacroSubstitutor(IMacroContextInfo contextInfo, String inexistentMacroValue, String listDelimiter){
|
||||||
|
super(contextInfo, inexistentMacroValue, listDelimiter, null ,inexistentMacroValue);
|
||||||
|
fDefaultDelimiter = listDelimiter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBuildEnvironmentVariable resolveVariable(EnvVarDescriptor var) throws BuildMacroException {
|
||||||
|
String value;
|
||||||
|
if(var == null || (value = var.getValue()) == null || value.length() == 0 || var.getOperation() == IBuildEnvironmentVariable.ENVVAR_REMOVE)
|
||||||
|
return var;
|
||||||
|
|
||||||
|
String listDelimiter = var.getDelimiter();
|
||||||
|
if(listDelimiter == null)
|
||||||
|
listDelimiter = fDefaultDelimiter;
|
||||||
|
setListDelimiter(listDelimiter);
|
||||||
|
IBuildMacro macro = EnvironmentMacroSupplier.getInstance().createBuildMacro(var);
|
||||||
|
IMacroContextInfo varMacroInfo = getVarMacroContextInfo(var);
|
||||||
|
int varSupplierNum = getVarMacroSupplierNum(var,varMacroInfo);
|
||||||
|
value = resolveToString(new MacroDescriptor(macro,varMacroInfo,varSupplierNum));
|
||||||
|
removeResolvedMacro(var.getName());
|
||||||
|
return new BuildEnvVar(var.getName(),value,var.getOperation(),var.getDelimiter());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IMacroContextInfo getVarMacroContextInfo(EnvVarDescriptor var){
|
||||||
|
IContextInfo info = var.getContextInfo();
|
||||||
|
if(info != null)
|
||||||
|
return getMacroContextInfoForContext(info.getContext());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int getVarMacroSupplierNum(EnvVarDescriptor var, IMacroContextInfo varMacroInfo){
|
||||||
|
int varSupplierNum = -1;
|
||||||
|
IBuildMacroSupplier macroSuppliers[] = varMacroInfo.getSuppliers();
|
||||||
|
for(int i = 0; i < macroSuppliers.length; i++){
|
||||||
|
if(macroSuppliers[i] instanceof EnvironmentMacroSupplier){
|
||||||
|
varSupplierNum = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return varSupplierNum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected EnvironmentVariableProvider(){
|
protected EnvironmentVariableProvider(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -94,17 +156,16 @@ public class EnvironmentVariableProvider implements
|
||||||
* 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
|
* @see org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo
|
||||||
*/
|
*/
|
||||||
public IBuildEnvironmentVariable getVariable(String variableName,
|
public EnvVarDescriptor getVariable(String variableName,
|
||||||
IContextInfo contextInfo, boolean includeParentLevels){
|
IContextInfo contextInfo, boolean includeParentLevels){
|
||||||
|
|
||||||
if(contextInfo == null)
|
if(contextInfo == null)
|
||||||
return null;
|
return null;
|
||||||
if(variableName == null || "".equals(variableName = variableName.trim())) //$NON-NLS-1$
|
if((variableName = EnvVarOperationProcessor.normalizeName(variableName)) == null) //$NON-NLS-1$
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
|
||||||
IContextInfo infos[] = getAllContextInfos(contextInfo);
|
IContextInfo infos[] = getAllContextInfos(contextInfo);
|
||||||
variableName = adjustName(variableName);
|
|
||||||
|
|
||||||
if(!includeParentLevels){
|
if(!includeParentLevels){
|
||||||
IEnvironmentVariableSupplier suppliers[] = infos[0].getSuppliers();
|
IEnvironmentVariableSupplier suppliers[] = infos[0].getSuppliers();
|
||||||
|
@ -120,6 +181,8 @@ public class EnvironmentVariableProvider implements
|
||||||
}
|
}
|
||||||
|
|
||||||
IBuildEnvironmentVariable variable = null;
|
IBuildEnvironmentVariable variable = null;
|
||||||
|
IContextInfo varContextInfo = null;
|
||||||
|
int varSupplierNum = -1;
|
||||||
|
|
||||||
for(int i = infos.length-1 ; i >=0 ; i-- ) {
|
for(int i = infos.length-1 ; i >=0 ; i-- ) {
|
||||||
IContextInfo info = infos[i];
|
IContextInfo info = infos[i];
|
||||||
|
@ -132,6 +195,9 @@ public class EnvironmentVariableProvider implements
|
||||||
if(var == null)
|
if(var == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
varContextInfo = info;
|
||||||
|
varSupplierNum = j;
|
||||||
|
|
||||||
if(variable == null)
|
if(variable == null)
|
||||||
variable = var;
|
variable = var;
|
||||||
else
|
else
|
||||||
|
@ -139,37 +205,36 @@ public class EnvironmentVariableProvider implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(variable != null && variable.getOperation() == IBuildEnvironmentVariable.ENVVAR_REMOVE)
|
if(variable != null){
|
||||||
variable = null;
|
if(variable.getOperation() == IBuildEnvironmentVariable.ENVVAR_REMOVE)
|
||||||
return variable;
|
return null;
|
||||||
|
return new EnvVarDescriptor(variable,varContextInfo,varSupplierNum);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getVariable()
|
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getVariable()
|
||||||
*/
|
*/
|
||||||
public IBuildEnvironmentVariable getVariable(String variableName,
|
public IBuildEnvironmentVariable getVariable(String variableName,
|
||||||
Object level, boolean includeParentLevels) {
|
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;
|
||||||
|
|
||||||
IBuildEnvironmentVariable var = getVariable(variableName,getContextInfo(level),includeParentLevels);
|
IContextInfo info = getContextInfo(level);
|
||||||
if(level instanceof IConfiguration)
|
EnvVarDescriptor var = getVariable(variableName,info,includeParentLevels);
|
||||||
|
if(level instanceof IConfiguration && includeParentLevels)
|
||||||
checkBuildPathVariable((IConfiguration)level,variableName,var);
|
checkBuildPathVariable((IConfiguration)level,variableName,var);
|
||||||
return var;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String adjustName(String name){
|
return resolveMacros ? calculateResolvedVariable(var,info) : var;
|
||||||
if(!isVariableCaseSensitive())
|
|
||||||
name = name.toUpperCase();
|
|
||||||
return name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* returns the context info that should be used for the given level
|
* returns 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
|
||||||
*/
|
*/
|
||||||
protected IContextInfo getContextInfo(Object level){
|
public IContextInfo getContextInfo(Object level){
|
||||||
DefaultContextInfo info = new DefaultContextInfo(level);
|
DefaultContextInfo info = new DefaultContextInfo(level);
|
||||||
if(info.getSuppliers() == null)
|
if(info.getSuppliers() == null)
|
||||||
return null;
|
return null;
|
||||||
|
@ -196,10 +261,10 @@ public class EnvironmentVariableProvider implements
|
||||||
IBuildEnvironmentVariable vars[] = suppliers[i].getVariables(infos[0].getContext());
|
IBuildEnvironmentVariable vars[] = suppliers[i].getVariables(infos[0].getContext());
|
||||||
if(vars != null){
|
if(vars != null){
|
||||||
for(int j = 0; j < vars.length; j++){
|
for(int j = 0; j < vars.length; j++){
|
||||||
set.add(
|
String name = EnvVarOperationProcessor.normalizeName(vars[j].
|
||||||
adjustName(vars[j].
|
getName());
|
||||||
getName())
|
if(name != null)
|
||||||
);
|
set.add(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,7 +295,7 @@ public class EnvironmentVariableProvider implements
|
||||||
else{
|
else{
|
||||||
vars = supplier.getVariables(info.getContext());
|
vars = supplier.getVariables(info.getContext());
|
||||||
}
|
}
|
||||||
envVarSet.add(vars);
|
envVarSet.add(vars,info,j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,15 +306,30 @@ public class EnvironmentVariableProvider implements
|
||||||
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getVariables()
|
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getVariables()
|
||||||
*/
|
*/
|
||||||
public IBuildEnvironmentVariable[] getVariables(Object level,
|
public IBuildEnvironmentVariable[] getVariables(Object level,
|
||||||
boolean includeParentLevels) {
|
boolean includeParentLevels, boolean resolveMacros) {
|
||||||
|
|
||||||
EnvVarCollector varSet = getVariables(getContextInfo(level),includeParentLevels);
|
IContextInfo info = getContextInfo(level);
|
||||||
|
EnvVarCollector varSet = getVariables(info,includeParentLevels);
|
||||||
|
|
||||||
|
EnvVarDescriptor vars[] = varSet != null ? varSet.toArray(false) : null;
|
||||||
|
|
||||||
if(level instanceof IConfiguration)
|
if(level instanceof IConfiguration)
|
||||||
checkBuildPathVariables((IConfiguration)level,varSet);
|
if(includeParentLevels)
|
||||||
|
checkBuildPathVariables((IConfiguration)level,varSet);
|
||||||
|
else if (vars != null){
|
||||||
|
for(int i = 0; i < vars.length; i++)
|
||||||
|
checkBuildPathVariable((IConfiguration)level,vars[i].getName(),vars[i]);
|
||||||
|
}
|
||||||
|
|
||||||
if(varSet != null)
|
if(vars != null){
|
||||||
return varSet.toArray(false);
|
if(!resolveMacros)
|
||||||
|
return vars;
|
||||||
|
|
||||||
|
IBuildEnvironmentVariable resolved[] = new IBuildEnvironmentVariable[vars.length];
|
||||||
|
for(int i = 0; i < vars.length; i++)
|
||||||
|
resolved[i] = calculateResolvedVariable(vars[i], info);
|
||||||
|
return resolved;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,11 +416,11 @@ public class EnvironmentVariableProvider implements
|
||||||
for(int k = 0; k < vars.length; k++){
|
for(int k = 0; k < vars.length; k++){
|
||||||
String varName = vars[k];
|
String varName = vars[k];
|
||||||
|
|
||||||
IBuildEnvironmentVariable var = getVariable(varName,configuration,true);
|
EnvVarDescriptor var = getVariable(varName,getContextInfo(configuration),true);
|
||||||
if(var == null)
|
if(var == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
String varValue = var.getValue();
|
String varValue = calculateResolvedVariable(var, getContextInfo(configuration)).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));
|
||||||
|
@ -446,7 +526,7 @@ 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, IBuildEnvironmentVariable var){
|
protected void checkBuildPathVariable(IConfiguration configuration, String varName, EnvVarDescriptor 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);
|
||||||
}
|
}
|
||||||
|
@ -459,7 +539,7 @@ 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, IBuildEnvironmentVariable var){
|
protected void checkBuildPathVariable(IConfiguration configuration, int buildPathType, String varName, EnvVarDescriptor var){
|
||||||
StoredBuildPathEnvironmentContainer buildPathVars = getStoredBuildPathVariables(buildPathType);
|
StoredBuildPathEnvironmentContainer buildPathVars = getStoredBuildPathVariables(buildPathType);
|
||||||
if(buildPathVars == null)
|
if(buildPathVars == null)
|
||||||
return;
|
return;
|
||||||
|
@ -510,4 +590,61 @@ public class EnvironmentVariableProvider implements
|
||||||
fLibraryStoredBuildPathVariables = new StoredBuildPathEnvironmentContainer(IEnvVarBuildPath.BUILDPATH_LIBRARY);
|
fLibraryStoredBuildPathVariables = new StoredBuildPathEnvironmentContainer(IEnvVarBuildPath.BUILDPATH_LIBRARY);
|
||||||
return fLibraryStoredBuildPathVariables;
|
return fLibraryStoredBuildPathVariables;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IBuildEnvironmentVariable calculateResolvedVariable(EnvVarDescriptor des, IContextInfo info){
|
||||||
|
if(des == null || info == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return calculateResolvedVariable(des,getMacroSubstitutor(getMacroContextInfoForContext(info.getContext()),""," ")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBuildEnvironmentVariable calculateResolvedVariable(EnvVarDescriptor des, IMacroSubstitutor sub){
|
||||||
|
if(des == null)
|
||||||
|
return null;
|
||||||
|
IBuildEnvironmentVariable var = des;
|
||||||
|
|
||||||
|
try{
|
||||||
|
if(sub instanceof EnvVarMacroSubstitutor)
|
||||||
|
var = ((EnvVarMacroSubstitutor)sub).resolveVariable(des);
|
||||||
|
else if(des.getOperation() != IBuildEnvironmentVariable.ENVVAR_REMOVE){
|
||||||
|
String name = des.getName();
|
||||||
|
var = new BuildEnvVar(name,sub.resolveToString(name),des.getOperation(),des.getDelimiter());
|
||||||
|
}
|
||||||
|
} catch (BuildMacroException e){
|
||||||
|
}
|
||||||
|
return var;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int getMacroContextTypeFromContext(Object context){
|
||||||
|
if(context instanceof IConfiguration)
|
||||||
|
return IBuildMacroProvider.CONTEXT_CONFIGURATION;
|
||||||
|
else if(context instanceof IManagedProject)
|
||||||
|
return IBuildMacroProvider.CONTEXT_PROJECT;
|
||||||
|
else if(context instanceof IWorkspace)
|
||||||
|
return IBuildMacroProvider.CONTEXT_WORKSPACE;
|
||||||
|
else if(context == null)
|
||||||
|
return IBuildMacroProvider.CONTEXT_ECLIPSEENV;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IMacroContextInfo getMacroContextInfoForContext(Object context){
|
||||||
|
return new DefaultMacroContextInfo(getMacroContextTypeFromContext(context),context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IMacroSubstitutor getMacroSubstitutor(IMacroContextInfo info, String inexistentMacroValue, String listDelimiter){
|
||||||
|
if(fMacroSubstitutor == null)
|
||||||
|
fMacroSubstitutor = new EnvVarMacroSubstitutor(info,inexistentMacroValue,listDelimiter);
|
||||||
|
else {
|
||||||
|
try {
|
||||||
|
fMacroSubstitutor.setMacroContextInfo(info);
|
||||||
|
fMacroSubstitutor.setInexistentMacroValue(inexistentMacroValue);
|
||||||
|
fMacroSubstitutor.setListDelimiter(listDelimiter);
|
||||||
|
} catch (BuildMacroException e){
|
||||||
|
fMacroSubstitutor = new EnvVarMacroSubstitutor(info,inexistentMacroValue,listDelimiter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fMacroSubstitutor;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,12 @@ import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
|
||||||
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
|
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
|
||||||
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier;
|
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier;
|
||||||
import org.eclipse.cdt.managedbuilder.envvar.IProjectEnvironmentVariableSupplier;
|
import org.eclipse.cdt.managedbuilder.envvar.IProjectEnvironmentVariableSupplier;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroContextInfo;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.macros.EnvironmentMacroSupplier;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.macros.IMacroSubstitutor;
|
||||||
|
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the Environment Variable Supplier used to supply variables
|
* This is the Environment Variable Supplier used to supply variables
|
||||||
|
@ -42,29 +48,35 @@ public class ExternalExtensionEnvironmentSupplier implements
|
||||||
private IContextInfo fStartInfo;
|
private IContextInfo fStartInfo;
|
||||||
private Object fStartLevel;
|
private Object fStartLevel;
|
||||||
private boolean fStartInitialized;
|
private boolean fStartInitialized;
|
||||||
|
private int fStartType;
|
||||||
|
private Object fStartData;
|
||||||
|
private IMacroContextInfo fStartMacroContextInfo;
|
||||||
|
private boolean fStartMacroInfoInitialized;
|
||||||
|
|
||||||
public ExtensionEnvVarProvider(Object level){
|
public ExtensionEnvVarProvider(Object level){
|
||||||
fStartLevel = level;
|
fStartLevel = level;
|
||||||
|
fStartType = getMacroContextTypeFromContext(level);
|
||||||
|
fStartData = level;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getVariable(java.lang.String, java.lang.Object, boolean)
|
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getVariable(java.lang.String, java.lang.Object, boolean)
|
||||||
*/
|
*/
|
||||||
public IBuildEnvironmentVariable getVariable(String variableName,
|
public IBuildEnvironmentVariable getVariable(String variableName,
|
||||||
Object level, boolean includeParentLevels) {
|
Object level, boolean includeParentLevels, boolean resolveMacros) {
|
||||||
if(getValidName(variableName) == null)
|
if(getValidName(variableName) == null)
|
||||||
return null;
|
return null;
|
||||||
return super.getVariable(variableName,level,includeParentLevels);
|
return super.getVariable(variableName,level,includeParentLevels,resolveMacros);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBuildEnvironmentVariable[] getVariables(Object level, boolean includeParentLevels) {
|
public IBuildEnvironmentVariable[] getVariables(Object level, boolean includeParentLevels, boolean resolveMacros) {
|
||||||
return filterVariables(super.getVariables(level,includeParentLevels));
|
return filterVariables(super.getVariables(level,includeParentLevels,resolveMacros));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider#getContextInfo(java.lang.Object)
|
* @see org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider#getContextInfo(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
protected IContextInfo getContextInfo(Object level){
|
public IContextInfo getContextInfo(Object level){
|
||||||
IContextInfo startInfo = getStartInfo();
|
IContextInfo startInfo = getStartInfo();
|
||||||
if(level == fStartLevel)
|
if(level == fStartLevel)
|
||||||
return startInfo;
|
return startInfo;
|
||||||
|
@ -95,6 +107,45 @@ public class ExternalExtensionEnvironmentSupplier implements
|
||||||
return fStartInfo;
|
return fStartInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IMacroSubstitutor getMacroSubstitutor(IMacroContextInfo info, String inexistentMacroValue, String listDelimiter){
|
||||||
|
return super.getMacroSubstitutor(getSubstitutorMacroContextInfo(info),inexistentMacroValue,listDelimiter);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IMacroContextInfo getSubstitutorMacroContextInfo(IMacroContextInfo info){
|
||||||
|
IMacroContextInfo startInfo = getStartMacroContextInfo();
|
||||||
|
if(info == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if(info.getContextType() == fStartType &&
|
||||||
|
info.getContextData() == fStartData)
|
||||||
|
return startInfo;
|
||||||
|
|
||||||
|
|
||||||
|
if(BuildMacroProvider.getDefault().checkParentContextRelation(startInfo,info))
|
||||||
|
return info;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IMacroContextInfo getStartMacroContextInfo(){
|
||||||
|
if(fStartMacroContextInfo == null && !fStartMacroInfoInitialized){
|
||||||
|
final IMacroContextInfo info = getMacroContextInfoForContext(fStartLevel);
|
||||||
|
if(info != null){
|
||||||
|
fStartMacroContextInfo = new DefaultMacroContextInfo(fStartType,fStartData){
|
||||||
|
protected IBuildMacroSupplier[] getSuppliers(int type, Object data){
|
||||||
|
IBuildMacroSupplier suppliers[] = info.getSuppliers();
|
||||||
|
return filterValidMacroSuppliers(suppliers);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IMacroContextInfo getNext() {
|
||||||
|
return info.getNext();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fStartInitialized = true;
|
||||||
|
}
|
||||||
|
fStartInitialized = true;
|
||||||
|
}
|
||||||
|
return fStartMacroContextInfo;
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider#getStoredBuildPathVariables(int)
|
* @see org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider#getStoredBuildPathVariables(int)
|
||||||
|
@ -211,4 +262,30 @@ public class ExternalExtensionEnvironmentSupplier implements
|
||||||
protected IBuildEnvironmentVariable[] filterVariables(IBuildEnvironmentVariable variables[]){
|
protected IBuildEnvironmentVariable[] filterVariables(IBuildEnvironmentVariable variables[]){
|
||||||
return EnvVarOperationProcessor.filterVariables(variables,fNonOverloadableVariables);
|
return EnvVarOperationProcessor.filterVariables(variables,fNonOverloadableVariables);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected IBuildMacroSupplier[] filterValidMacroSuppliers(IBuildMacroSupplier suppliers[]){
|
||||||
|
if(suppliers == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
int i = 0, j = 0;
|
||||||
|
for(i = 0; i < suppliers.length; i++){
|
||||||
|
if(suppliers[i] instanceof EnvironmentMacroSupplier)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(i >= suppliers.length)
|
||||||
|
return suppliers;
|
||||||
|
|
||||||
|
int startNum = i + 1;
|
||||||
|
|
||||||
|
IBuildMacroSupplier validSuppliers[] =
|
||||||
|
new IBuildMacroSupplier[suppliers.length - startNum];
|
||||||
|
|
||||||
|
for(i = startNum, j = 0; i < suppliers.length; i++, j++)
|
||||||
|
validSuppliers[j] = suppliers[i];
|
||||||
|
|
||||||
|
return validSuppliers;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,8 +102,11 @@ public class StoredBuildPathEnvironmentContainer extends
|
||||||
for(int i = 0; i < vars.length; i++){
|
for(int i = 0; i < vars.length; i++){
|
||||||
IBuildEnvironmentVariable var = vars[i];
|
IBuildEnvironmentVariable var = vars[i];
|
||||||
String name = var.getName();
|
String name = var.getName();
|
||||||
IBuildEnvironmentVariable curVar = existingVariables != null ?
|
EnvVarDescriptor des = existingVariables != null ?
|
||||||
existingVariables.getVariable(name) : null;
|
existingVariables.getVariable(name) : null;
|
||||||
|
EnvironmentVariableProvider provider = ((EnvironmentVariableProvider)ManagedBuildManager.getEnvironmentVariableProvider());
|
||||||
|
IBuildEnvironmentVariable curVar = des != null ?
|
||||||
|
provider.calculateResolvedVariable(des,provider.getContextInfo(configuration)) : null;
|
||||||
if(!haveIdenticalValues(var,curVar)){
|
if(!haveIdenticalValues(var,curVar)){
|
||||||
if(curVar == null){
|
if(curVar == null){
|
||||||
env.createVariable(name,null,IBuildEnvironmentVariable.ENVVAR_REMOVE,null);
|
env.createVariable(name,null,IBuildEnvironmentVariable.ENVVAR_REMOVE,null);
|
||||||
|
@ -131,7 +134,7 @@ public class StoredBuildPathEnvironmentContainer extends
|
||||||
* returns false in this case
|
* returns false in this case
|
||||||
*/
|
*/
|
||||||
public boolean isVariableChanged(String name,
|
public boolean isVariableChanged(String name,
|
||||||
IBuildEnvironmentVariable variable,
|
EnvVarDescriptor variable,
|
||||||
IConfiguration configuration){
|
IConfiguration configuration){
|
||||||
StorableEnvironment env = getEnvironment(configuration);
|
StorableEnvironment env = getEnvironment(configuration);
|
||||||
if(env == null)
|
if(env == null)
|
||||||
|
@ -140,7 +143,11 @@ public class StoredBuildPathEnvironmentContainer extends
|
||||||
if(var == null)
|
if(var == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(haveIdenticalValues(var,variable))
|
EnvironmentVariableProvider provider = ((EnvironmentVariableProvider)ManagedBuildManager.getEnvironmentVariableProvider());
|
||||||
|
IBuildEnvironmentVariable curVar = variable != null ?
|
||||||
|
provider.calculateResolvedVariable(variable,provider.getContextInfo(configuration)) : null;
|
||||||
|
|
||||||
|
if(haveIdenticalValues(var,curVar))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -191,12 +191,12 @@ public class BuildMacroProvider implements IBuildMacroProvider {
|
||||||
* @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider#resolveStringListValue(java.lang.String, java.lang.String, int, java.lang.Object)
|
* @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider#resolveStringListValue(java.lang.String, java.lang.String, int, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public String[] resolveStringListValue(String value,
|
public String[] resolveStringListValue(String value,
|
||||||
String nonexistentMacrosValue, int contextType, Object contextData)
|
String nonexistentMacrosValue, String listDelimiter,
|
||||||
throws BuildMacroException {
|
int contextType, Object contextData) throws BuildMacroException {
|
||||||
|
|
||||||
IMacroContextInfo info = getMacroContextInfo(contextType,contextData);
|
IMacroContextInfo info = getMacroContextInfo(contextType,contextData);
|
||||||
if(info != null)
|
if(info != null)
|
||||||
return MacroResolver.resolveToStringList(value,getMacroSubstitutor(info,nonexistentMacrosValue, " ")); //$NON-NLS-1$
|
return MacroResolver.resolveToStringList(value,getMacroSubstitutor(info,nonexistentMacrosValue, listDelimiter));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,12 +218,12 @@ public class BuildMacroProvider implements IBuildMacroProvider {
|
||||||
* @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider#resolveStringListValueToMakefileFormat(java.lang.String, java.lang.String, int, java.lang.Object)
|
* @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider#resolveStringListValueToMakefileFormat(java.lang.String, java.lang.String, int, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public String[] resolveStringListValueToMakefileFormat(String value,
|
public String[] resolveStringListValueToMakefileFormat(String value,
|
||||||
String nonexistentMacrosValue, int contextType, Object contextData)
|
String nonexistentMacrosValue, String listDelimiter, int contextType, Object contextData)
|
||||||
throws BuildMacroException {
|
throws BuildMacroException {
|
||||||
|
|
||||||
IMacroContextInfo info = getMacroContextInfo(contextType,contextData);
|
IMacroContextInfo info = getMacroContextInfo(contextType,contextData);
|
||||||
if(info != null)
|
if(info != null)
|
||||||
MacroResolver.resolveToStringList(value,getBuildfileMacroSubstitutor(info,nonexistentMacrosValue, " ")); //$NON-NLS-1$
|
MacroResolver.resolveToStringList(value,getBuildfileMacroSubstitutor(info,nonexistentMacrosValue, listDelimiter));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,8 +247,15 @@ public class BuildMacroProvider implements IBuildMacroProvider {
|
||||||
throws BuildMacroException {
|
throws BuildMacroException {
|
||||||
|
|
||||||
IMacroContextInfo info = getMacroContextInfo(contextType,contextData);
|
IMacroContextInfo info = getMacroContextInfo(contextType,contextData);
|
||||||
|
IMacroSubstitutor subst = new DefaultMacroSubstitutor(info,null,""){ //$NON-NLS-1$
|
||||||
|
protected ResolvedMacro resolveMacro(IBuildMacro macro) throws BuildMacroException {
|
||||||
|
if(macro instanceof EclipseVariablesMacroSupplier.EclipseVarMacro)
|
||||||
|
return new ResolvedMacro(macro.getName(),""); //$NON-NLS-1$
|
||||||
|
return super.resolveMacro(macro);
|
||||||
|
}
|
||||||
|
};
|
||||||
if(info != null)
|
if(info != null)
|
||||||
MacroResolver.checkIntegrity(info,getMacroSubstitutor(info,null,"")); //$NON-NLS-1$
|
MacroResolver.checkIntegrity(info,subst);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IMacroSubstitutor getMacroSubstitutor(IMacroContextInfo info, String inexistentMacroValue, String listDelimiter){
|
public IMacroSubstitutor getMacroSubstitutor(IMacroContextInfo info, String inexistentMacroValue, String listDelimiter){
|
||||||
|
|
|
@ -170,7 +170,8 @@ public class BuildfileMacroSubstitutor extends DefaultMacroSubstitutor {
|
||||||
|
|
||||||
if(fConfiguration != null && fBuilder != null &&
|
if(fConfiguration != null && fBuilder != null &&
|
||||||
!UserDefinedMacroSupplier.getInstance().areMacrosExpanded(fConfiguration) &&
|
!UserDefinedMacroSupplier.getInstance().areMacrosExpanded(fConfiguration) &&
|
||||||
macro instanceof EnvironmentMacroSupplier.EnvVarMacro){
|
macro instanceof EnvironmentMacroSupplier.EnvVarMacro &&
|
||||||
|
!MacroResolver.isStringListMacro(macro.getMacroValueType())){
|
||||||
String ref = getMacroReference(macro);
|
String ref = getMacroReference(macro);
|
||||||
if(ref != null)
|
if(ref != null)
|
||||||
resolved = new ResolvedMacro(macro.getName(),ref);
|
resolved = new ResolvedMacro(macro.getName(),ref);
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
|
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
|
||||||
import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
|
import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
|
||||||
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroStatus;
|
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroStatus;
|
||||||
|
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This substitutor resolves all macro references
|
* This substitutor resolves all macro references
|
||||||
|
@ -36,6 +37,7 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
|
||||||
private String fInexistentMacroValue;
|
private String fInexistentMacroValue;
|
||||||
private String fListDelimiter;
|
private String fListDelimiter;
|
||||||
private String fIncorrectlyReferencedMacroValue;
|
private String fIncorrectlyReferencedMacroValue;
|
||||||
|
private Map fDelimiterMap;
|
||||||
|
|
||||||
protected class ResolvedMacro extends BuildMacro{
|
protected class ResolvedMacro extends BuildMacro{
|
||||||
private boolean fIsDefined;
|
private boolean fIsDefined;
|
||||||
|
@ -86,20 +88,30 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
|
||||||
return fStringListValue;
|
return fStringListValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String getDelimiter(){
|
||||||
|
if(fDelimiterMap != null){
|
||||||
|
Object delimiter = fDelimiterMap.get(fName);
|
||||||
|
if(delimiter instanceof String)
|
||||||
|
return (String)delimiter;
|
||||||
|
}
|
||||||
|
return fListDelimiter;
|
||||||
|
}
|
||||||
|
|
||||||
protected String stringListToString(String values[]) throws BuildMacroException {
|
protected String stringListToString(String values[]) throws BuildMacroException {
|
||||||
String result = null;
|
String result = null;
|
||||||
|
String delimiter;
|
||||||
if(values == null)
|
if(values == null)
|
||||||
result = null;
|
result = null;
|
||||||
else if(values.length == 0)
|
else if(values.length == 0)
|
||||||
result = EMPTY_STRING;
|
result = EMPTY_STRING;
|
||||||
else if(values.length == 1)
|
else if(values.length == 1)
|
||||||
result = values[0];
|
result = values[0];
|
||||||
else if(fListDelimiter != null){
|
else if((delimiter = getDelimiter()) != null){
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
for(int i = 0; i < values.length; i++){
|
for(int i = 0; i < values.length; i++){
|
||||||
buffer.append(values[i]);
|
buffer.append(values[i]);
|
||||||
if(i < values.length-1)
|
if(i < values.length-1)
|
||||||
buffer.append(fListDelimiter);
|
buffer.append(delimiter);
|
||||||
}
|
}
|
||||||
result = buffer.toString();
|
result = buffer.toString();
|
||||||
} else {
|
} else {
|
||||||
|
@ -132,65 +144,61 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
|
||||||
private IMacroContextInfo fInfo;
|
private IMacroContextInfo fInfo;
|
||||||
private IBuildMacro fMacro;
|
private IBuildMacro fMacro;
|
||||||
private boolean fInitialized;
|
private boolean fInitialized;
|
||||||
|
private int fSupplierNum;
|
||||||
public MacroDescriptor(String name){
|
private int fEnvSupplierNum;
|
||||||
this(name, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MacroDescriptor(String name, IMacroContextInfo info){
|
public MacroDescriptor(String name, IMacroContextInfo info){
|
||||||
fName = name;
|
fName = name;
|
||||||
fInfo = info;
|
fInfo = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MacroDescriptor(IBuildMacro macro, IMacroContextInfo info){
|
public MacroDescriptor(String name, IMacroContextInfo info, int supplierNum){
|
||||||
|
fName = name;
|
||||||
|
fInfo = info;
|
||||||
|
fSupplierNum = supplierNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MacroDescriptor(IBuildMacro macro, IMacroContextInfo info, int supplierNum){
|
||||||
fName = macro.getName();
|
fName = macro.getName();
|
||||||
fInfo = info;
|
fInfo = info;
|
||||||
fMacro = macro;
|
fMacro = macro;
|
||||||
|
fSupplierNum = supplierNum;
|
||||||
|
fInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MacroDescriptor getNext(){
|
public MacroDescriptor getNext(){
|
||||||
IMacroContextInfo info = getInfo();
|
return new MacroDescriptor(fName,getInfo(),getSupplierNum()+1);
|
||||||
if(info != null)
|
|
||||||
info = info.getNext();
|
|
||||||
|
|
||||||
return get(fName,info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected MacroDescriptor get(String name, IMacroContextInfo info){
|
public int getSupplierNum(){
|
||||||
MacroDescriptor next = null;
|
init();
|
||||||
IBuildMacro macro = null;
|
return fSupplierNum;
|
||||||
for(; info != null; info = info.getNext()){
|
|
||||||
if((macro = BuildMacroProvider.getMacro(fName,info,false)) != null){
|
|
||||||
next = new MacroDescriptor(macro,info);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init(){
|
private void init(){
|
||||||
if(fInitialized)
|
if(fInitialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MacroDescriptor des = get(fName,fContextInfo);
|
|
||||||
if(des != null){
|
|
||||||
fInfo = des.fInfo;
|
|
||||||
fMacro = des.fMacro;
|
|
||||||
}
|
|
||||||
|
|
||||||
fInitialized = true;
|
fInitialized = true;
|
||||||
|
for(; fInfo != null; fInfo = fInfo.getNext()){
|
||||||
|
IBuildMacroSupplier suppliers[] = fInfo.getSuppliers();
|
||||||
|
if(suppliers != null){
|
||||||
|
for(; fSupplierNum < suppliers.length; fSupplierNum++){
|
||||||
|
if((fMacro = suppliers[fSupplierNum].getMacro(fName,fInfo.getContextType(),fInfo.getContextData())) != null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fSupplierNum = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IMacroContextInfo getInfo(){
|
protected IMacroContextInfo getInfo(){
|
||||||
if(fInfo == null)
|
init();
|
||||||
init();
|
|
||||||
return fInfo;
|
return fInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBuildMacro getMacro(){
|
public IBuildMacro getMacro(){
|
||||||
if(fMacro == null)
|
init();
|
||||||
init();
|
|
||||||
return fMacro;
|
return fMacro;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,38 +208,55 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
|
||||||
private HashSet fMacrosUnderResolution = new HashSet();
|
private HashSet fMacrosUnderResolution = new HashSet();
|
||||||
private Stack fMacroDescriptors = new Stack();
|
private Stack fMacroDescriptors = new Stack();
|
||||||
|
|
||||||
|
public DefaultMacroSubstitutor(int contextType, Object contextData, String inexistentMacroValue, String listDelimiter, Map delimiterMap, String incorrectlyReferencedMacroValue){
|
||||||
|
this(new DefaultMacroContextInfo(contextType,contextData),inexistentMacroValue,listDelimiter, delimiterMap, incorrectlyReferencedMacroValue);
|
||||||
|
}
|
||||||
|
|
||||||
public DefaultMacroSubstitutor(int contextType, Object contextData, String inexistentMacroValue, String listDelimiter){
|
public DefaultMacroSubstitutor(int contextType, Object contextData, String inexistentMacroValue, String listDelimiter){
|
||||||
this(new DefaultMacroContextInfo(contextType,contextData),inexistentMacroValue,listDelimiter);
|
this(new DefaultMacroContextInfo(contextType,contextData),inexistentMacroValue,listDelimiter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DefaultMacroSubstitutor(IMacroContextInfo contextInfo, String inexistentMacroValue, String listDelimiter){
|
public DefaultMacroSubstitutor(IMacroContextInfo contextInfo, String inexistentMacroValue, String listDelimiter){
|
||||||
this(contextInfo, inexistentMacroValue, listDelimiter, inexistentMacroValue);
|
this(contextInfo, inexistentMacroValue, listDelimiter, null ,inexistentMacroValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DefaultMacroSubstitutor(IMacroContextInfo contextInfo, String inexistentMacroValue, String listDelimiter, String incorrectlyReferencedMacroValue){
|
public DefaultMacroSubstitutor(IMacroContextInfo contextInfo, String inexistentMacroValue, String listDelimiter, Map delimiterMap, String incorrectlyReferencedMacroValue){
|
||||||
fContextInfo = contextInfo;
|
fContextInfo = contextInfo;
|
||||||
fInexistentMacroValue = inexistentMacroValue;
|
fInexistentMacroValue = inexistentMacroValue;
|
||||||
fListDelimiter = listDelimiter;
|
fListDelimiter = listDelimiter;
|
||||||
|
fDelimiterMap = delimiterMap;
|
||||||
fIncorrectlyReferencedMacroValue = incorrectlyReferencedMacroValue;
|
fIncorrectlyReferencedMacroValue = incorrectlyReferencedMacroValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String resolveToString(MacroDescriptor des) throws BuildMacroException {
|
||||||
|
String result = null;
|
||||||
|
ResolvedMacro value = getResolvedMacro(des);
|
||||||
|
result = value.getStringValue();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String[] resolveToStringList(MacroDescriptor des) throws BuildMacroException {
|
||||||
|
String result[] = null;
|
||||||
|
ResolvedMacro value = getResolvedMacro(des);
|
||||||
|
result = value.getStringListValue();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroSubstitutor#resolveToString(java.lang.String)
|
* @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroSubstitutor#resolveToString(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public String resolveToString(String macroName) throws BuildMacroException {
|
public String resolveToString(String macroName) throws BuildMacroException {
|
||||||
String result = null;
|
return resolveToString(new MacroDescriptor(macroName,fContextInfo));
|
||||||
ResolvedMacro value = getResolvedMacro(macroName);
|
|
||||||
result = value.getStringValue();
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMacroContextInfo(IMacroContextInfo info)
|
public void setMacroContextInfo(IMacroContextInfo info)
|
||||||
throws BuildMacroException{
|
throws BuildMacroException{
|
||||||
if(fMacrosUnderResolution.size() != 0)
|
if(checkEqual(fContextInfo,info))
|
||||||
throw new BuildMacroException(IBuildMacroStatus.TYPE_ERROR,(String)null,null,null,0,null);
|
return;
|
||||||
|
|
||||||
fResolvedMacros.clear();
|
reset();
|
||||||
fContextInfo = info;
|
fContextInfo = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,20 +271,20 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
|
||||||
return ((BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider()).getMacroContextInfo(contextType,contextData);
|
return ((BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider()).getMacroContextInfo(contextType,contextData);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ResolvedMacro getResolvedMacro(String macroName)
|
protected ResolvedMacro getResolvedMacro(MacroDescriptor des)
|
||||||
throws BuildMacroException {
|
throws BuildMacroException {
|
||||||
ResolvedMacro value = checkResolvingMacro(macroName);
|
ResolvedMacro value = checkResolvingMacro(des);
|
||||||
|
|
||||||
if(value == null)
|
if(value == null)
|
||||||
{
|
{
|
||||||
try{
|
try{
|
||||||
value = resolveMacro(macroName);
|
value = resolveMacro(des);
|
||||||
}finally{
|
}finally{
|
||||||
if(value != null)
|
if(value != null)
|
||||||
addResolvedMacro(macroName,value);
|
addResolvedMacro(des,value);
|
||||||
else {
|
else {
|
||||||
value = new ResolvedMacro(macroName,fInexistentMacroValue,false);
|
value = new ResolvedMacro(des.fName,fInexistentMacroValue,false);
|
||||||
addResolvedMacro(macroName,value);
|
addResolvedMacro(des,value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -267,16 +292,16 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ResolvedMacro resolveMacro(MacroDescriptor des) throws BuildMacroException{
|
||||||
|
return des.fMacro != null ? resolveMacro(des.fMacro) : resolveMacro(des.fName);
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroSubstitutor#resolveToStringList(java.lang.String)
|
* @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroSubstitutor#resolveToStringList(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public String[] resolveToStringList(String macroName)
|
public String[] resolveToStringList(String macroName)
|
||||||
throws BuildMacroException {
|
throws BuildMacroException {
|
||||||
String result[] = null;
|
return resolveToStringList(new MacroDescriptor(macroName,fContextInfo));
|
||||||
ResolvedMacro value = getResolvedMacro(macroName);
|
|
||||||
result = value.getStringListValue();
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ResolvedMacro resolveMacro(String macroName) throws BuildMacroException{
|
protected ResolvedMacro resolveMacro(String macroName) throws BuildMacroException{
|
||||||
|
@ -369,12 +394,13 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
|
||||||
return resolvedMacro;
|
return resolvedMacro;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResolvedMacro checkResolvingMacro(String name)
|
private ResolvedMacro checkResolvingMacro(MacroDescriptor des)
|
||||||
throws BuildMacroException{
|
throws BuildMacroException{
|
||||||
|
String name = des.fName;
|
||||||
ResolvedMacro value = (ResolvedMacro)fResolvedMacros.get(name);
|
ResolvedMacro value = (ResolvedMacro)fResolvedMacros.get(name);
|
||||||
if(value == null){
|
if(value == null){
|
||||||
if(fMacrosUnderResolution.add(name))
|
if(fMacrosUnderResolution.add(name))
|
||||||
fMacroDescriptors.push(new MacroDescriptor(name,null));
|
fMacroDescriptors.push(des);
|
||||||
else {
|
else {
|
||||||
// the macro of the specified name is referenced from the other macros that
|
// the macro of the specified name is referenced from the other macros that
|
||||||
// are referenced by the given macro
|
// are referenced by the given macro
|
||||||
|
@ -408,12 +434,17 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addResolvedMacro(String name, ResolvedMacro value){
|
protected void addResolvedMacro(MacroDescriptor des, ResolvedMacro value){
|
||||||
|
String name = des.fName;
|
||||||
fMacrosUnderResolution.remove(name);
|
fMacrosUnderResolution.remove(name);
|
||||||
fResolvedMacros.put(name,value);
|
fResolvedMacros.put(name,value);
|
||||||
fMacroDescriptors.pop();
|
fMacroDescriptors.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ResolvedMacro removeResolvedMacro(String name){
|
||||||
|
return (ResolvedMacro)fResolvedMacros.remove(name);
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroSubstitutor#getMacroContextInfo()
|
* @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroSubstitutor#getMacroContextInfo()
|
||||||
*/
|
*/
|
||||||
|
@ -421,4 +452,65 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
|
||||||
return fContextInfo;
|
return fContextInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void reset() throws BuildMacroException{
|
||||||
|
if(fMacrosUnderResolution.size() != 0)
|
||||||
|
throw new BuildMacroException(IBuildMacroStatus.TYPE_ERROR,(String)null,null,null,0,null);
|
||||||
|
|
||||||
|
fResolvedMacros.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map getDelimiterMap() {
|
||||||
|
return fDelimiterMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDelimiterMap(Map delimiterMap) throws BuildMacroException {
|
||||||
|
if(checkEqual(fDelimiterMap,delimiterMap))
|
||||||
|
return;
|
||||||
|
reset();
|
||||||
|
fDelimiterMap = delimiterMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIncorrectlyReferencedMacroValue() {
|
||||||
|
return fIncorrectlyReferencedMacroValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean checkEqual(Object o1, Object o2){
|
||||||
|
if(o1 != null){
|
||||||
|
if(o1.equals(o2))
|
||||||
|
return true;
|
||||||
|
} else if (o2 == null)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIncorrectlyReferencedMacroValue(
|
||||||
|
String incorrectlyReferencedMacroValue) throws BuildMacroException {
|
||||||
|
if(checkEqual(fIncorrectlyReferencedMacroValue,incorrectlyReferencedMacroValue))
|
||||||
|
return;
|
||||||
|
reset();
|
||||||
|
fIncorrectlyReferencedMacroValue = incorrectlyReferencedMacroValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInexistentMacroValue() {
|
||||||
|
return fInexistentMacroValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInexistentMacroValue(String inexistentMacroValue) throws BuildMacroException {
|
||||||
|
if(checkEqual(fInexistentMacroValue,inexistentMacroValue))
|
||||||
|
return;
|
||||||
|
reset();
|
||||||
|
fInexistentMacroValue = inexistentMacroValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getListDelimiter() {
|
||||||
|
return fListDelimiter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setListDelimiter(String listDelimiter) throws BuildMacroException {
|
||||||
|
if(checkEqual(fListDelimiter,listDelimiter))
|
||||||
|
return;
|
||||||
|
reset();
|
||||||
|
fListDelimiter = listDelimiter;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,8 @@ import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
|
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
|
||||||
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
|
|
||||||
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvVarOperationProcessor;
|
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvVarOperationProcessor;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
|
||||||
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
|
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
|
||||||
import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
|
import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
|
||||||
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
|
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
|
||||||
|
@ -31,10 +31,10 @@ import org.eclipse.core.resources.IWorkspace;
|
||||||
*/
|
*/
|
||||||
public class EnvironmentMacroSupplier implements IBuildMacroSupplier {
|
public class EnvironmentMacroSupplier implements IBuildMacroSupplier {
|
||||||
private static EnvironmentMacroSupplier fInstance;
|
private static EnvironmentMacroSupplier fInstance;
|
||||||
private IEnvironmentVariableProvider fEnvironmentProvider;
|
private EnvironmentVariableProvider fEnvironmentProvider;
|
||||||
|
|
||||||
public class EnvVarMacro extends BuildMacro{
|
public class EnvVarMacro extends BuildMacro{
|
||||||
IBuildEnvironmentVariable fVariable;
|
private IBuildEnvironmentVariable fVariable;
|
||||||
private EnvVarMacro(IBuildEnvironmentVariable var){
|
private EnvVarMacro(IBuildEnvironmentVariable var){
|
||||||
fName = var.getName();
|
fName = var.getName();
|
||||||
fVariable = var;
|
fVariable = var;
|
||||||
|
@ -92,13 +92,19 @@ public class EnvironmentMacroSupplier implements IBuildMacroSupplier {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected EnvironmentMacroSupplier(){
|
protected EnvironmentMacroSupplier(){
|
||||||
this(ManagedBuildManager.getEnvironmentVariableProvider());
|
this((EnvironmentVariableProvider)ManagedBuildManager.getEnvironmentVariableProvider());
|
||||||
}
|
}
|
||||||
|
|
||||||
public EnvironmentMacroSupplier(IEnvironmentVariableProvider varProvider){
|
public EnvironmentMacroSupplier(EnvironmentVariableProvider varProvider){
|
||||||
fEnvironmentProvider = varProvider;
|
fEnvironmentProvider = varProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IBuildMacro createBuildMacro(IBuildEnvironmentVariable var){
|
||||||
|
if(var != null)
|
||||||
|
return new EnvVarMacro(var);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static EnvironmentMacroSupplier getInstance(){
|
public static EnvironmentMacroSupplier getInstance(){
|
||||||
if(fInstance == null)
|
if(fInstance == null)
|
||||||
fInstance = new EnvironmentMacroSupplier();
|
fInstance = new EnvironmentMacroSupplier();
|
||||||
|
@ -116,22 +122,22 @@ public class EnvironmentMacroSupplier implements IBuildMacroSupplier {
|
||||||
switch(contextType){
|
switch(contextType){
|
||||||
case IBuildMacroProvider.CONTEXT_CONFIGURATION:
|
case IBuildMacroProvider.CONTEXT_CONFIGURATION:
|
||||||
if(contextData instanceof IConfiguration){
|
if(contextData instanceof IConfiguration){
|
||||||
var = fEnvironmentProvider.getVariable(macroName,contextData,false);
|
var = fEnvironmentProvider.getVariable(macroName,fEnvironmentProvider.getContextInfo(contextData),false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IBuildMacroProvider.CONTEXT_PROJECT:
|
case IBuildMacroProvider.CONTEXT_PROJECT:
|
||||||
if(contextData instanceof IManagedProject){
|
if(contextData instanceof IManagedProject){
|
||||||
var = fEnvironmentProvider.getVariable(macroName,contextData,false);
|
var = fEnvironmentProvider.getVariable(macroName,fEnvironmentProvider.getContextInfo(contextData),false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IBuildMacroProvider.CONTEXT_WORKSPACE:
|
case IBuildMacroProvider.CONTEXT_WORKSPACE:
|
||||||
if(contextData instanceof IWorkspace){
|
if(contextData instanceof IWorkspace){
|
||||||
var = fEnvironmentProvider.getVariable(macroName,contextData,false);
|
var = fEnvironmentProvider.getVariable(macroName,fEnvironmentProvider.getContextInfo(contextData),false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IBuildMacroProvider.CONTEXT_ECLIPSEENV:
|
case IBuildMacroProvider.CONTEXT_ECLIPSEENV:
|
||||||
if(contextData == null){
|
if(contextData == null){
|
||||||
var = fEnvironmentProvider.getVariable(macroName,contextData,false);
|
var = fEnvironmentProvider.getVariable(macroName,fEnvironmentProvider.getContextInfo(contextData),false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -149,22 +155,22 @@ public class EnvironmentMacroSupplier implements IBuildMacroSupplier {
|
||||||
switch(contextType){
|
switch(contextType){
|
||||||
case IBuildMacroProvider.CONTEXT_CONFIGURATION:
|
case IBuildMacroProvider.CONTEXT_CONFIGURATION:
|
||||||
if(contextData instanceof IConfiguration){
|
if(contextData instanceof IConfiguration){
|
||||||
vars = fEnvironmentProvider.getVariables(contextData,false);
|
vars = fEnvironmentProvider.getVariables(fEnvironmentProvider.getContextInfo(contextData),false).toArray(false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IBuildMacroProvider.CONTEXT_PROJECT:
|
case IBuildMacroProvider.CONTEXT_PROJECT:
|
||||||
if(contextData instanceof IManagedProject){
|
if(contextData instanceof IManagedProject){
|
||||||
vars = fEnvironmentProvider.getVariables(contextData,false);
|
vars = fEnvironmentProvider.getVariables(fEnvironmentProvider.getContextInfo(contextData),false).toArray(false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IBuildMacroProvider.CONTEXT_WORKSPACE:
|
case IBuildMacroProvider.CONTEXT_WORKSPACE:
|
||||||
if(contextData instanceof IWorkspace){
|
if(contextData instanceof IWorkspace){
|
||||||
vars = fEnvironmentProvider.getVariables(contextData,false);
|
vars = fEnvironmentProvider.getVariables(fEnvironmentProvider.getContextInfo(contextData),false).toArray(false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IBuildMacroProvider.CONTEXT_ECLIPSEENV:
|
case IBuildMacroProvider.CONTEXT_ECLIPSEENV:
|
||||||
if(contextData == null){
|
if(contextData == null){
|
||||||
vars = fEnvironmentProvider.getVariables(contextData,false);
|
vars = fEnvironmentProvider.getVariables(fEnvironmentProvider.getContextInfo(contextData),false).toArray(false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -179,4 +185,7 @@ public class EnvironmentMacroSupplier implements IBuildMacroSupplier {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EnvironmentVariableProvider getEnvironmentVariableProvider(){
|
||||||
|
return fEnvironmentProvider;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ public interface IBuildMacroProvider{
|
||||||
* NOTE: the IFileContextData is passed that represents the current file and the option
|
* NOTE: the IFileContextData is passed that represents the current file and the option
|
||||||
* for that file because Macro Value Provider needs to know what option should be used
|
* for that file because Macro Value Provider needs to know what option should be used
|
||||||
* as a context in case macro is not found for �current file� context
|
* as a context in case macro is not found for �current file� context
|
||||||
* 2. IOption � used to represent the currently selected option context
|
* 2. IOptionContextData interface used to represent the currently selected option context
|
||||||
* 3. IConfiguration � used to represent the currently selected configuration context
|
* 3. IConfiguration � used to represent the currently selected configuration context
|
||||||
* 4. IProject � used to represent current project context
|
* 4. IProject � used to represent current project context
|
||||||
* 5. IWorkspace � used to represent current workspace context
|
* 5. IWorkspace � used to represent current workspace context
|
||||||
|
@ -109,6 +109,7 @@ public interface IBuildMacroProvider{
|
||||||
*/
|
*/
|
||||||
public String[] resolveStringListValue(String value,
|
public String[] resolveStringListValue(String value,
|
||||||
String nonexistentMacrosValue,
|
String nonexistentMacrosValue,
|
||||||
|
String listDelimiter,
|
||||||
int contextType,
|
int contextType,
|
||||||
Object contextData) throws BuildMacroException;
|
Object contextData) throws BuildMacroException;
|
||||||
|
|
||||||
|
@ -149,6 +150,7 @@ public interface IBuildMacroProvider{
|
||||||
*/
|
*/
|
||||||
public String[] resolveStringListValueToMakefileFormat(String value,
|
public String[] resolveStringListValueToMakefileFormat(String value,
|
||||||
String nonexistentMacrosValue,
|
String nonexistentMacrosValue,
|
||||||
|
String listDelimiter,
|
||||||
int contextType,
|
int contextType,
|
||||||
Object contextData) throws BuildMacroException;
|
Object contextData) throws BuildMacroException;
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class CygwinPathResolver implements IBuildPathResolver {
|
||||||
ArrayList ls = new ArrayList();
|
ArrayList ls = new ArrayList();
|
||||||
String s = exePath + TOOL + variableValue;
|
String s = exePath + TOOL + variableValue;
|
||||||
String[] lines = exec(s);
|
String[] lines = exec(s);
|
||||||
if (s != null && s.length() > 0) {
|
if (lines != null && lines.length > 0) {
|
||||||
result = lines[0].replace(BS,SLASH).split(DELIMITER_WIN);
|
result = lines[0].replace(BS,SLASH).split(DELIMITER_WIN);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -882,8 +882,7 @@ public class EnvironmentBlock extends AbstractCOptionPage {
|
||||||
if(!canDisplay(name))
|
if(!canDisplay(name))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
EnvironmentVariableProvider provider = (EnvironmentVariableProvider)ManagedBuildManager.getEnvironmentVariableProvider();
|
return EnvironmentVariableProvider.getDefault().getVariable(name,fSystemContextInfo,includeParentLevels);
|
||||||
return provider.getVariable(name,fSystemContextInfo,includeParentLevels);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
package org.eclipse.cdt.managedbuilder.internal.ui;
|
package org.eclipse.cdt.managedbuilder.internal.ui;
|
||||||
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
|
|
||||||
import org.eclipse.cdt.managedbuilder.internal.envvar.DefaultContextInfo;
|
import org.eclipse.cdt.managedbuilder.internal.envvar.DefaultContextInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
|
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo;
|
import org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo;
|
||||||
|
@ -90,7 +89,7 @@ public class EnvironmentSetBlock extends AbstractCOptionPage {
|
||||||
* the user-modified variables that are not applied yet
|
* the user-modified variables that are not applied yet
|
||||||
*/
|
*/
|
||||||
private class UIEnvVarProvider extends EnvironmentVariableProvider{
|
private class UIEnvVarProvider extends EnvironmentVariableProvider{
|
||||||
protected IContextInfo getContextInfo(Object context){
|
public IContextInfo getContextInfo(Object context){
|
||||||
EnvironmentBlock blocks[] = getAllBlocks();
|
EnvironmentBlock blocks[] = getAllBlocks();
|
||||||
for(int i = 0; i < blocks.length; i++){
|
for(int i = 0; i < blocks.length; i++){
|
||||||
if(blocks[i].getContext() == context)
|
if(blocks[i].getContext() == context)
|
||||||
|
@ -314,7 +313,7 @@ public class EnvironmentSetBlock extends AbstractCOptionPage {
|
||||||
* Unlike the default provider, the returned provider also contains
|
* Unlike the default provider, the returned provider also contains
|
||||||
* the user-modified variables that are not applied yet
|
* the user-modified variables that are not applied yet
|
||||||
*/
|
*/
|
||||||
public IEnvironmentVariableProvider getEnvironmentVariableProvider(){
|
public EnvironmentVariableProvider getEnvironmentVariableProvider(){
|
||||||
if(fEnvProvider == null)
|
if(fEnvProvider == null)
|
||||||
fEnvProvider = new UIEnvVarProvider();
|
fEnvProvider = new UIEnvVarProvider();
|
||||||
return fEnvProvider;
|
return fEnvProvider;
|
||||||
|
|
|
@ -23,8 +23,8 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
|
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter;
|
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter;
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
|
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
|
||||||
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
|
|
||||||
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvVarOperationProcessor;
|
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvVarOperationProcessor;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacro;
|
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacro;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
|
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroContextInfo;
|
import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroContextInfo;
|
||||||
|
@ -231,7 +231,7 @@ public class MacrosBlock extends AbstractCOptionPage {
|
||||||
IBuildMacroSupplier suppliers[] = super.getSuppliers(contextType,contextData);
|
IBuildMacroSupplier suppliers[] = super.getSuppliers(contextType,contextData);
|
||||||
if(suppliers == null || suppliers.length == 0)
|
if(suppliers == null || suppliers.length == 0)
|
||||||
return null;
|
return null;
|
||||||
IEnvironmentVariableProvider envProvider = obtainEnvironmentVariableProvider();
|
EnvironmentVariableProvider envProvider = obtainEnvironmentVariableProvider();
|
||||||
if(envProvider != null){
|
if(envProvider != null){
|
||||||
for(int i = 0; i < suppliers.length; i++){
|
for(int i = 0; i < suppliers.length; i++){
|
||||||
if((suppliers[i] instanceof EnvironmentMacroSupplier)){
|
if((suppliers[i] instanceof EnvironmentMacroSupplier)){
|
||||||
|
@ -1150,7 +1150,7 @@ public class MacrosBlock extends AbstractCOptionPage {
|
||||||
return MacroResolver.filterMacros(macros,fHiddenMacros);
|
return MacroResolver.filterMacros(macros,fHiddenMacros);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IEnvironmentVariableProvider obtainEnvironmentVariableProvider(){
|
protected EnvironmentVariableProvider obtainEnvironmentVariableProvider(){
|
||||||
ICOptionContainer container = getContainer();
|
ICOptionContainer container = getContainer();
|
||||||
ManagedBuildOptionBlock optionBlock = null;
|
ManagedBuildOptionBlock optionBlock = null;
|
||||||
if(container instanceof BuildPropertyPage){
|
if(container instanceof BuildPropertyPage){
|
||||||
|
|
|
@ -319,8 +319,10 @@ import org.eclipse.swt.widgets.Group;
|
||||||
* the user-modified macros that are not applied yet
|
* the user-modified macros that are not applied yet
|
||||||
*/
|
*/
|
||||||
public BuildMacroProvider getBuildMacroProvider(){
|
public BuildMacroProvider getBuildMacroProvider(){
|
||||||
if(fMacroProvider == null)
|
if(fMacroProvider == null){
|
||||||
|
updateContexts();
|
||||||
fMacroProvider = new UIMacroProvider();
|
fMacroProvider = new UIMacroProvider();
|
||||||
|
}
|
||||||
return fMacroProvider;
|
return fMacroProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue