1 | /* |
---|
2 | * Copyright (c) 2008 |
---|
3 | * Embedded Brains GmbH |
---|
4 | * Obere Lagerstr. 30 |
---|
5 | * D-82178 Puchheim |
---|
6 | * Germany |
---|
7 | * rtems@embedded-brains.de |
---|
8 | * |
---|
9 | * The license and distribution terms for this file may be found in the file |
---|
10 | * LICENSE in this distribution or at http://www.rtems.com/license/LICENSE. |
---|
11 | */ |
---|
12 | |
---|
13 | package org.rtems.cdt.build; |
---|
14 | |
---|
15 | import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator; |
---|
16 | import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo; |
---|
17 | import org.eclipse.cdt.managedbuilder.core.ITool; |
---|
18 | import org.eclipse.cdt.managedbuilder.internal.core.ManagedCommandLineGenerator; |
---|
19 | import org.eclipse.core.resources.IProject; |
---|
20 | import org.rtems.cdt.Constants; |
---|
21 | import org.rtems.cdt.Storage; |
---|
22 | |
---|
23 | public class CommandLineGenerator extends ManagedCommandLineGenerator implements IManagedCommandLineGenerator { |
---|
24 | public IManagedCommandLineInfo generateCommandLineInfo( |
---|
25 | ITool tool, |
---|
26 | String commandName, |
---|
27 | String [] userOptions, |
---|
28 | String outputFlag, |
---|
29 | String outputPrefix, |
---|
30 | String outputName, |
---|
31 | String [] inputResources, |
---|
32 | String commandLinePattern |
---|
33 | ) { |
---|
34 | // Get associated project of the tool |
---|
35 | IProject project = (IProject) tool.getParentResourceInfo().getParent().getOwner(); |
---|
36 | |
---|
37 | // Determine tool key via the tool ID |
---|
38 | String id = tool.getId(); |
---|
39 | String toolKey = "gcc"; |
---|
40 | if (id.contains( "archiver")) { |
---|
41 | toolKey = Constants.TOOL_ARCHIVER_KEY; |
---|
42 | } else if (id.contains( "assembler")) { |
---|
43 | toolKey = Constants.TOOL_ASSEMBLER_KEY; |
---|
44 | } else if (id.contains( "compiler.cpp")) { |
---|
45 | toolKey = Constants.TOOL_COMPILER_CPP_KEY; |
---|
46 | } else if (id.contains( "compiler.c")) { |
---|
47 | toolKey = Constants.TOOL_COMPILER_C_KEY; |
---|
48 | } else if (id.contains( "linker.cpp")) { |
---|
49 | toolKey = Constants.TOOL_LINKER_CPP_KEY; |
---|
50 | } else if (id.contains( "linker.c")) { |
---|
51 | toolKey = Constants.TOOL_LINKER_C_KEY; |
---|
52 | } |
---|
53 | |
---|
54 | // Set command name |
---|
55 | commandName = Storage.getProperty( project, toolKey); |
---|
56 | tool.setToolCommand( commandName); |
---|
57 | |
---|
58 | // Combine tool and user options |
---|
59 | String [] toolOptions = Storage.getToolOptions( project, toolKey); |
---|
60 | String options [] = new String [toolOptions.length + userOptions.length]; |
---|
61 | System.arraycopy( toolOptions, 0, options, 0, toolOptions.length); |
---|
62 | System.arraycopy( userOptions, 0, options, toolOptions.length, userOptions.length); |
---|
63 | |
---|
64 | return super.generateCommandLineInfo( |
---|
65 | tool, |
---|
66 | commandName, |
---|
67 | options, |
---|
68 | outputFlag, |
---|
69 | outputPrefix, |
---|
70 | outputName, |
---|
71 | inputResources, |
---|
72 | commandLinePattern |
---|
73 | ); |
---|
74 | } |
---|
75 | } |
---|