diff options
Diffstat (limited to 'org.rtems.cdt/src/org/rtems/cdt/build/EnvironmentSupplier.java')
-rw-r--r-- | org.rtems.cdt/src/org/rtems/cdt/build/EnvironmentSupplier.java | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/org.rtems.cdt/src/org/rtems/cdt/build/EnvironmentSupplier.java b/org.rtems.cdt/src/org/rtems/cdt/build/EnvironmentSupplier.java new file mode 100644 index 0000000..80f88b2 --- /dev/null +++ b/org.rtems.cdt/src/org/rtems/cdt/build/EnvironmentSupplier.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2008 Embedded Brains GmbH and others. + * + * Embedded Brains GmbH + * Obere Lagerstr. 30 + * D-82178 Puchheim + * Germany + * rtems@embedded-brains.de + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Eclipse Public License Version 1.0 ("EPL") + * which accompanies this distribution and is available at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * For purposes of the EPL, "Program" will mean the Content. + * + * Contributors: + * + * Sebastian Huber (Embedded Brains GmbH) - Initial API and implementation. + */ + +package org.rtems.cdt.build; + +import org.eclipse.core.resources.IProject; +import org.eclipse.cdt.managedbuilder.core.IConfiguration; +import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable; +import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier; +import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider; +import org.eclipse.cdt.managedbuilder.internal.envvar.BuildEnvVar; +import org.rtems.cdt.Constants; +import org.rtems.cdt.Storage; + +public class EnvironmentSupplier implements IConfigurationEnvironmentVariableSupplier { + private static final int PATH_INDEX = 0; + + private static final int VARIABLE_COUNT = 1; + + protected String getPlatform() { + return Constants.PLATFORM_DEFAULT; + } + + public IBuildEnvironmentVariable getVariable( String name, IConfiguration configuration, IEnvironmentVariableProvider provider) { + if (name.equals( "PATH")) { + IProject project = (IProject) configuration.getOwner(); + + // Change platform + Storage.changePlatform( project, getPlatform()); + + // Get path parts + String part = Storage.getProperty( project, Constants.PATH_PREPEND_KEY); + + return new BuildEnvVar( name, part, IBuildEnvironmentVariable.ENVVAR_PREPEND, Constants.PATH_SEPARATOR); + } + + return null; + } + + public IBuildEnvironmentVariable [] getVariables( IConfiguration configuration, IEnvironmentVariableProvider provider) { + IBuildEnvironmentVariable variables [] = new IBuildEnvironmentVariable [VARIABLE_COUNT]; + + variables [PATH_INDEX] = getVariable( "PATH", configuration, provider); + + return variables; + } +} |