Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Environment variables and prepend operations

Hello,

Our MBS toolchain contributes IBuildVariable implementations in order to
change the PATH environment variable used while building. The
implementation specifies an ENVVAR_PREPEND operation so that the
contributed path is added at the beginning of the existing system path.

I have noticed that in some circumstances the path provided by our
variable erroneously replaces the system path. This seems to be
connected with the plugins loading order.

The org.eclipse.cdt.utils.envvar.EnvVarOperationProcessor class actually
performs the prepend operation and calculates the new variable. The
result of a prepend operation is an environment variable which is by
default associated to IEnvironmentVariable.ENVVAR_REPLACE, since no
operation is explicitly specified.

>From EnvVarOperationProcessor: line 58 

case IEnvironmentVariable.ENVVAR_PREPEND:{ 
String delimiter = added.getDelimiter(); 
return new EnvironmentVariable(name, 
performPrepend(initial.getValue(),added.getValue(),delimiter), 
//	 IEnvironmentVariable.ENVVAR_PREPEND, 
delimiter); 
}

(The comment on the PREPEND operation is originally there)

What happens is that our PATH build variable can get prepended with
itself, thereby generating a new PATH variable with the same value but
having a REPLACE operation instead of PREPEND. When the prepend result
gets merged with the system path, it erases existing entries.

Is that intended behavior or a bug? Should the prepend operation never
be called on the same variable? I have noticed that the line with the
PREPEND operation in EnvVarOperationProcessor had been commented out as
a bugfix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=175581.

Thank you for your help!

-Mario





Back to the top