Skip to main content

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

I don't know if anything has changed - certainly nothing in the last 6 months. I know some changes were made in environment handling over the years.

What this sounds like a much more likely case of a race condition on the project descriptions. I believe there are some known race conditions in this area, so perhaps it is that, or some code is holding a reference to the old project description for longer than it should be.

Sorry I can't be more helpful.

~~~
Jonah Graham
Kichwa Coders
www.kichwacoders.com


On Wed, 11 Mar 2020 at 20:50, Jan Baeyens <jan@xxxxxxxxxx> wrote:
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);



_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/cdt-dev

Back to the top