summaryrefslogtreecommitdiffstats
path: root/org.rtems.cdt/src/org/rtems/cdt/build/CygwinScannerInfoCollector.java
blob: 99f0da9ccb46a6c76fbf4bfc0e2befe54326a272 (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
/*
 * 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 java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector3;
import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
import org.eclipse.cdt.make.internal.core.scannerconfig2.PerProjectSICollector;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.CygpathTranslator;
import org.eclipse.cdt.managedbuilder.scannerconfig.IManagedScannerInfoCollector;
import org.eclipse.core.resources.IProject;

/**
 * This class exists only to disable the specialized UI elements of the scanner configuration.
 *
 * See also 'org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGnuWinScannerInfoCollector'.
 */
public class CygwinScannerInfoCollector extends PerProjectSICollector implements IScannerInfoCollector3, IManagedScannerInfoCollector {
	private IProject mProject;

	public void contributeToScannerConfig(Object resource, Map scannerInfo) {
		List<String> includes = (List<String>) scannerInfo.get(ScannerInfoTypes.INCLUDE_PATHS);
		List<String> translatedIncludes = CygpathTranslator.translateIncludePaths(mProject, includes);

		Iterator<String> iter = translatedIncludes.listIterator();
		while (iter.hasNext()) {
			String convertedPath = iter.next();
			if (convertedPath.startsWith("/")) {
				iter.remove();
			}
		}
		scannerInfo.put(ScannerInfoTypes.INCLUDE_PATHS, translatedIncludes);

		super.contributeToScannerConfig(resource, scannerInfo);
}

	public void setProject(IProject project) {
		mProject = project;
		super.setProject(project);
	}

	public void setInfoContext(InfoContext context) {
		mProject = context.getProject();
		super.setInfoContext(context);
	}
}