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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
/*******************************************************************************
* Copyright (c) 2015 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package org.eclipse.cdt.core.build;
import java.util.List;
import java.util.Map;
import org.eclipse.cdt.core.parser.ExtendedScannerInfo;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.PlatformObject;
import org.osgi.service.prefs.Preferences;
/**
* Root class for CDT toolchains.
*
* @since 5.12
*/
public abstract class CToolChain extends PlatformObject {
public static final String FAMILY = "family"; //$NON-NLS-1$
private static final String NAME = "name"; //$NON-NLS-1$
private String id;
private String name;
protected CToolChain(String id, Preferences settings) {
this.id = id;
this.name = settings.get(NAME, "<Unknown>"); //$NON-NLS-1$
}
protected CToolChain(String name) {
this.name = name;
}
public abstract String getFamily();
public String getId() {
return id;
}
void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void save(Preferences settings) {
settings.put(FAMILY, getFamily());
settings.put(NAME, name);
}
public static String[] splitCommand(String command) {
// TODO deal with quotes properly, for now just strip
return command.replace("\"", "").split("\\s+"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
public static String[] fixPaths(String[] command) {
for (int i = 0; i < command.length; ++i) {
if (command[i].indexOf('\\') >= 0) {
command[i] = command[i].replace('\\', '/');
}
}
return command;
}
/**
* Update the given environment to run the toolchain.
*
* @param env
*/
public void setEnvironment(Map<String, String> env) {
// default, nothing
}
/**
* Find the file mentioned in the command line.
*
* @param buildFolder
* @param commandLine
* @return the file in the command line or null if can't be found.
*/
public IFile getResource(IFolder buildFolder, String[] commandLine) {
// default, not found
return null;
}
public IFile getResource(IFolder buildFolder, String commandLine) {
return getResource(buildFolder, splitCommand(commandLine));
}
/**
* Calculate the scanner info from the given command line
*
* @param buildFolder
* @param commandLine
* @return scanner info, or null if can't be calculated
* @throws CoreException
*/
public ExtendedScannerInfo getScannerInfo(IFolder buildFolder, List<String> commandLine)
throws CoreException {
// default, null
return null;
}
/**
* Return the console parsers to be used when this toolchain is being used
* for a build.
*
* @return console parsers, or null if there aren't any
*/
public CConsoleParser[] getConsoleParsers() {
return null;
}
}
|