summaryrefslogtreecommitdiffstats
path: root/org.rtems.cdt/src/org/rtems/cdt/build/RunScannerInfoProvider.java
blob: 93c67fd1e55a24c208d597799db3115043f59fdc (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
 * 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.cdt.make.internal.core.scannerconfig2.GCCSpecsRunSIProvider;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
import org.rtems.cdt.Constants;
import org.rtems.cdt.Storage;

public class RunScannerInfoProvider extends GCCSpecsRunSIProvider {
	protected String getPlatform() {
		return Constants.PLATFORM_DEFAULT;
	}

	protected boolean initialize() {
		if (!super.initialize()) {
			return false;
		}

		IProject project = resource.getProject();

		/*
		 * FIXME: This is a hack to avoid to early discovery of internal
		 * compiler include paths and symbols.  The discovery is suppressed for
		 * empty projects which contain only the '.project' and '.cproject'
		 * files.
		 */
		try {
			if (project.members().length < 3) {
				return false;
			}
		} catch (CoreException e) {
			e.printStackTrace();
			return false;
		}

		// Change platform
		Storage.changePlatform( project, getPlatform());

		// Set compile command
		fCompileCommand = new Path(
			Storage.getProperty( project, Constants.TOOL_COMPILER_C_KEY)
		);

		// Add the standard options to the command arguments
		String options [] = Storage.getToolOptions( project, Constants.TOOL_COMPILER_C_KEY);
		String newCompileArguments [] = new String [options.length + fCompileArguments.length];
		System.arraycopy( options, 0, newCompileArguments, 0, options.length);
		System.arraycopy( fCompileArguments, 0, newCompileArguments, options.length, fCompileArguments.length);
		fCompileArguments = newCompileArguments;

		return true;
	}
}