1 | /* |
---|
2 | * Copyright (c) 2008 |
---|
3 | * Embedded Brains GmbH |
---|
4 | * Obere Lagerstr. 30 |
---|
5 | * D-82178 Puchheim |
---|
6 | * Germany |
---|
7 | * rtems@embedded-brains.de |
---|
8 | * |
---|
9 | * The license and distribution terms for this file may be found in the file |
---|
10 | * LICENSE in this distribution or at http://www.rtems.com/license/LICENSE. |
---|
11 | */ |
---|
12 | |
---|
13 | package org.rtems.cdt.build; |
---|
14 | |
---|
15 | import org.eclipse.core.resources.IProject; |
---|
16 | import org.eclipse.core.runtime.IPath; |
---|
17 | import org.eclipse.core.runtime.Path; |
---|
18 | import org.eclipse.cdt.managedbuilder.core.IManagedProject; |
---|
19 | import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable; |
---|
20 | import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider; |
---|
21 | import org.eclipse.cdt.managedbuilder.envvar.IProjectEnvironmentVariableSupplier; |
---|
22 | import org.eclipse.cdt.managedbuilder.internal.envvar.BuildEnvVar; |
---|
23 | import org.rtems.cdt.Constants; |
---|
24 | import org.rtems.cdt.Storage; |
---|
25 | |
---|
26 | public class EnvironmentSupplier implements IProjectEnvironmentVariableSupplier { |
---|
27 | private static final int PATH_INDEX = 0; |
---|
28 | |
---|
29 | private static final int VARIABLE_COUNT = 1; |
---|
30 | |
---|
31 | public IBuildEnvironmentVariable getVariable( String name, IManagedProject project, IEnvironmentVariableProvider provider) { |
---|
32 | if (name.equals( "PATH")) { |
---|
33 | IPath path = new Path( |
---|
34 | Storage.getProperty( (IProject) project.getOwner(), Constants.BASE_PATH_KEY) |
---|
35 | ); |
---|
36 | path = path.append( "bin"); |
---|
37 | |
---|
38 | return new BuildEnvVar( name, path.toOSString(), IBuildEnvironmentVariable.ENVVAR_PREPEND, Constants.PATH_SEPERATOR); |
---|
39 | } |
---|
40 | |
---|
41 | return null; |
---|
42 | } |
---|
43 | |
---|
44 | public IBuildEnvironmentVariable [] getVariables( IManagedProject project, IEnvironmentVariableProvider provider) { |
---|
45 | IBuildEnvironmentVariable variables [] = new IBuildEnvironmentVariable [VARIABLE_COUNT]; |
---|
46 | |
---|
47 | variables [PATH_INDEX] = getVariable( "PATH", project, provider); |
---|
48 | |
---|
49 | return variables; |
---|
50 | } |
---|
51 | } |
---|