summaryrefslogtreecommitdiffstats
path: root/org.rtems.cdt.toolchain2/org/rtems/cdt/build/CommandLineGenerator.java
blob: 4147e61dfe93024d65717e22677fdb59306c124b (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
 * 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.cdt.managedbuilder.core.IManagedCommandLineGenerator;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedCommandLineGenerator;
import org.eclipse.core.resources.IProject;
import org.rtems.cdt.Constants;
import org.rtems.cdt.Storage;

public class CommandLineGenerator extends ManagedCommandLineGenerator implements IManagedCommandLineGenerator {
	public IManagedCommandLineInfo generateCommandLineInfo(
		ITool tool,
		String commandName,
		String [] flags,
		String outputFlag,
		String outputPrefix,
		String outputName,
		String [] inputResources,
		String commandLinePattern
	) {
		// Get associated project of the tool
		IProject project = (IProject) tool.getParentResourceInfo().getParent().getOwner();
		
		// Determine main command name via the tool ID
	    String id = tool.getId();
	    String name = "-gcc";    
	    if (id.contains( "archiver")) {
	    	name = "-ar";
	    } else if (id.contains( "assembler")) {
	    	name = "-as";
	    } else if (id.contains( "cpp.compiler")) {
	    	name = "-g++";
	    } else if (id.contains( "cpp.linker")) {
	    	name = "-g++";
	    }
		
	    // Create and set command name
		commandName = new String(
			Storage.getProperty( project, Constants.TARGET_KEY)
				+ "-rtems"
				+ Storage.getProperty( project, Constants.VERSION_KEY)
				+ name
		);
		tool.setToolCommand( commandName);

		return super.generateCommandLineInfo(
			tool,
			commandName,
			flags,
			outputFlag,
			outputPrefix,
			outputName,
			inputResources,
			commandLinePattern
		);
	}
}