Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Has something changed to the environment variable management lately?

Hello

I'm getting some strange behaviour with environment variables that used to work just fine. I know it sounds crazy but .... It seems like the environment variables have become "sticky" (in like the old value is still available for some time after Sloeber updated it and then bang the new value is there) and sometimes they do not get replaced at all.

In Sloeber nothing really has changed in this area for years so it looks to me as if something happened in CDT in this area.

I realize that what I'm doing may be wrong/unsupported so here some  highlights of the code I'm using

Help is appreciated

Jantje


getting the project configuration description

       ICProjectDescription prjCDesc = CoreModel.getDefault().getProjectDescription(project);         ICConfigurationDescription confDesc= prjCDesc.getActiveConfiguration();

getting the environment manager

        IEnvironmentVariableManager envManager = CCorePlugin.getDefault().getBuildEnvironmentManager();         IContributedEnvironment contribEnv = envManager.getContributedEnvironment();

removing all old values based on the beginning of the names

        IEnvironmentVariable[] CurVariables = contribEnv.getVariables(confDesc);
        for (int i = (CurVariables.length - 1); i > 0; i--) {
            if (CurVariables[i].getName().startsWith(Const.ERASE_START)) {
contribEnv.removeVariable(CurVariables[i].getName(), confDesc);
            }
        }

Doing lots of these (the same key can be written on several times)

        IEnvironmentVariable var = new EnvironmentVariable(key, makePathEnvironmentString(value));
        contribEnv.addVariable(var, confdesc);


Saving the data

CoreModel.getDefault().getProjectDescriptionManager().setProjectDescription(project, prjCDesc, true, null);





Back to the top