Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] modify build variables

Take a look at IEnvironmentVariableManagerTests in
org.eclipse.cdt.core.tests plugin.

The environment is per configuration. So you could do something like this:

		prjDesc = CoreModel.getDefault().getProjectDescription(project);
		ICConfigurationDescription[] descs = prjDesc.getConfigurations();

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

		// Try setting an environment variable
		final IEnvironmentVariable var = new EnvironmentVariable("FOO", "BAR");
		contribEnv.addVariable(var, prjDesc.getConfigurationById(id1));

		// Get an environment variable:
		IEnvironmentVariable var2 = envManager.getVariable(var.getName(),
prjDesc.getConfigurationById(id1), true);

                // Save the changes to the environment
		CoreModel.getDefault().setProjectDescription(project, prjDesc);


Cheers,
James

On 21 May 2010 13:42, Flo Menier <josieenfrance@xxxxxxxxxxx> wrote:
>
>                 I added a build variable (with variable name "Path",
> variable value "C:\IFX_Tools") for one c project, how can I modify it in
> Java code
>                 IWorkspace workspace = ResourcesPlugin.getWorkspace();
>     pathVariableManager =
> workspace.getRoot().getWorkspace().getPathVariableManager();
>     ICdtVariable path =
> CdtVariableManager.fBuildSystemVariableSupplier.getVariable("Path", null);
>
>     System.out.println("Is
> fBuildSystemVariableSupplier?"+path.getStringValue());
> I've tried all types: fBuildSystemVariableSupplier
> ,fEnvironmentMacroSupplier,fCdtMacroSupplier, fEclipseVariablesMacroSupplier
> but I always got "null".
> Is the problem of null parameter in
> "CdtVariableManager.fBuildSystemVariableSupplier.getVariable("Path", null);
> "?
>
> thanks in advance
>
>
>
> ________________________________
> Votre messagerie et bien plus où que vous soyez. Passez à Windows Live
> Hotmail, c'est gratuit ! Inscrivez-vous
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/cdt-dev
>
>


Back to the top