1 | /* |
---|
2 | * Copyright (c) 2008 Embedded Brains GmbH and others. |
---|
3 | * |
---|
4 | * Embedded Brains GmbH |
---|
5 | * Obere Lagerstr. 30 |
---|
6 | * D-82178 Puchheim |
---|
7 | * Germany |
---|
8 | * rtems@embedded-brains.de |
---|
9 | * |
---|
10 | * All rights reserved. This program and the accompanying materials are made |
---|
11 | * available under the terms of the Eclipse Public License Version 1.0 ("EPL") |
---|
12 | * which accompanies this distribution and is available at |
---|
13 | * |
---|
14 | * http://www.eclipse.org/legal/epl-v10.html |
---|
15 | * |
---|
16 | * For purposes of the EPL, "Program" will mean the Content. |
---|
17 | * |
---|
18 | * Contributors: |
---|
19 | * |
---|
20 | * Sebastian Huber (Embedded Brains GmbH) - Initial API and implementation. |
---|
21 | */ |
---|
22 | |
---|
23 | package org.rtems.cdt.build; |
---|
24 | |
---|
25 | import org.eclipse.core.resources.IProject; |
---|
26 | import org.eclipse.cdt.managedbuilder.core.IConfiguration; |
---|
27 | import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable; |
---|
28 | import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier; |
---|
29 | import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider; |
---|
30 | import org.eclipse.cdt.managedbuilder.internal.envvar.BuildEnvVar; |
---|
31 | import org.rtems.cdt.Constants; |
---|
32 | import org.rtems.cdt.Storage; |
---|
33 | |
---|
34 | public class EnvironmentSupplier implements IConfigurationEnvironmentVariableSupplier { |
---|
35 | private static final int PATH_INDEX = 0; |
---|
36 | |
---|
37 | private static final int VARIABLE_COUNT = 1; |
---|
38 | |
---|
39 | protected String getPlatform() { |
---|
40 | return Constants.PLATFORM_DEFAULT; |
---|
41 | } |
---|
42 | |
---|
43 | public IBuildEnvironmentVariable getVariable( String name, IConfiguration configuration, IEnvironmentVariableProvider provider) { |
---|
44 | if (name.equals( "PATH")) { |
---|
45 | IProject project = (IProject) configuration.getOwner(); |
---|
46 | |
---|
47 | // Change platform |
---|
48 | Storage.changePlatform( project, getPlatform()); |
---|
49 | |
---|
50 | // Get path parts |
---|
51 | String part = Storage.getProperty( project, Constants.PATH_PREPEND_KEY); |
---|
52 | |
---|
53 | return new BuildEnvVar( name, part, IBuildEnvironmentVariable.ENVVAR_PREPEND, Constants.PATH_SEPARATOR); |
---|
54 | } |
---|
55 | |
---|
56 | return null; |
---|
57 | } |
---|
58 | |
---|
59 | public IBuildEnvironmentVariable [] getVariables( IConfiguration configuration, IEnvironmentVariableProvider provider) { |
---|
60 | IBuildEnvironmentVariable variables [] = new IBuildEnvironmentVariable [VARIABLE_COUNT]; |
---|
61 | |
---|
62 | variables [PATH_INDEX] = getVariable( "PATH", configuration, provider); |
---|
63 | |
---|
64 | return variables; |
---|
65 | } |
---|
66 | } |
---|