summaryrefslogtreecommitdiffstats
path: root/org.rtems.cdt.toolchain2/org/rtems/cdt/build/EnvironmentSupplier.java
blob: d8decf5b0f24322825db56669a14892d2b4082ee (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
 * Copyright (c) 2008
 * Embedded Brains GmbH
 * Obere Lagerstr. 30
 * D-82178 Puchheim
 * Germany
 * rtems@embedded-brains.de
 *
 * The license and distribution terms for this file may be found in the file
 * LICENSE in this distribution or at http://www.rtems.com/license/LICENSE.
 */

package org.rtems.cdt.build;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
import org.eclipse.cdt.managedbuilder.envvar.IProjectEnvironmentVariableSupplier;
import org.eclipse.cdt.managedbuilder.internal.envvar.BuildEnvVar;
import org.rtems.cdt.Constants;
import org.rtems.cdt.Storage;

public class EnvironmentSupplier implements IProjectEnvironmentVariableSupplier {
	private static final int PATH_INDEX = 0;
	
	private static final int VARIABLE_COUNT = 1;
	
	public EnvironmentSupplier() {
		// Do nothing
	}

	public IBuildEnvironmentVariable getVariable( String name, IManagedProject project, IEnvironmentVariableProvider provider) {
		if (name.equals( "PATH")) {
			IPath path = new Path(
				Storage.getProperty( (IProject) project.getOwner(), Constants.BASE_PATH_KEY)
			);
			path = path.append( "bin");
			
			return new BuildEnvVar( name, path.toOSString(), IBuildEnvironmentVariable.ENVVAR_PREPEND, Constants.PATH_SEPERATOR);
		}

		return null;
	}

	public IBuildEnvironmentVariable [] getVariables( IManagedProject project, IEnvironmentVariableProvider provider) {
		IBuildEnvironmentVariable variables [] = new IBuildEnvironmentVariable [VARIABLE_COUNT];
		
		// System.out.println( Constants.getCounter() + ": getVariables");
		
		variables [PATH_INDEX] = getVariable( "PATH", project, provider);
		
		return variables;
	}
}