22
22
import it .baeyens .arduino .common .Common ;
23
23
import it .baeyens .arduino .common .Const ;
24
24
25
- public class ArduinoLanguageProvider extends ToolchainBuiltinSpecsDetector implements ILanguageSettingsEditableProvider {
25
+ public class ArduinoLanguageProvider extends ToolchainBuiltinSpecsDetector
26
+ implements ILanguageSettingsEditableProvider {
26
27
// ID must match the tool-chain definition in
27
28
// org.eclipse.cdt.managedbuilder.core.buildDefinitions extension point
28
29
private static final String GCC_TOOLCHAIN_ID = "cdt.managedbuild.toolchain.gnu.base" ; //$NON-NLS-1$
@@ -34,12 +35,15 @@ private enum State {
34
35
private State state = State .NONE ;
35
36
36
37
private static final AbstractOptionParser [] optionParsers = {
37
- new IncludePathOptionParser ("#include \" (\\ S.*)\" " , "$1" , ICSettingEntry .BUILTIN | ICSettingEntry .READONLY | ICSettingEntry .LOCAL ), //$NON-NLS-1$ //$NON-NLS-2$
38
+ new IncludePathOptionParser ("#include \" (\\ S.*)\" " , "$1" , //$NON-NLS-1$ //$NON-NLS-2$
39
+ ICSettingEntry .BUILTIN | ICSettingEntry .READONLY | ICSettingEntry .LOCAL ),
38
40
new IncludePathOptionParser ("#include <(\\ S.*)>" , "$1" , ICSettingEntry .BUILTIN | ICSettingEntry .READONLY ), //$NON-NLS-1$ //$NON-NLS-2$
39
41
new IncludePathOptionParser ("#framework <(\\ S.*)>" , "$1" , //$NON-NLS-1$ //$NON-NLS-2$
40
42
ICSettingEntry .BUILTIN | ICSettingEntry .READONLY | ICSettingEntry .FRAMEWORKS_MAC ),
41
- new MacroOptionParser ("#define\\ s+(\\ S*\\ (.*?\\ ))\\ s*(.*)" , "$1" , "$2" , ICSettingEntry .BUILTIN | ICSettingEntry .READONLY ), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
42
- new MacroOptionParser ("#define\\ s+(\\ S*)\\ s*(\\ S*)" , "$1" , "$2" , ICSettingEntry .BUILTIN | ICSettingEntry .READONLY ), }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
43
+ new MacroOptionParser ("#define\\ s+(\\ S*\\ (.*?\\ ))\\ s*(.*)" , "$1" , "$2" , //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
44
+ ICSettingEntry .BUILTIN | ICSettingEntry .READONLY ),
45
+ new MacroOptionParser ("#define\\ s+(\\ S*)\\ s*(\\ S*)" , "$1" , "$2" , //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
46
+ ICSettingEntry .BUILTIN | ICSettingEntry .READONLY ), };
43
47
44
48
@ Override
45
49
public String getToolchainId () {
@@ -105,7 +109,8 @@ protected List<String> parseOptions(String lineIn) {
105
109
}
106
110
107
111
@ Override
108
- public void startup (ICConfigurationDescription cfgDescription , IWorkingDirectoryTracker cwdTracker1 ) throws CoreException {
112
+ public void startup (ICConfigurationDescription cfgDescription , IWorkingDirectoryTracker cwdTracker1 )
113
+ throws CoreException {
109
114
super .startup (cfgDescription , cwdTracker1 );
110
115
111
116
this .state = State .NONE ;
@@ -148,45 +153,54 @@ protected String getCompilerCommand(String languageId) {
148
153
try {
149
154
buildFolder .create (true , true , null );
150
155
} catch (CoreException e ) {
151
- Common .log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID , "failed to create folder " + confDesc .getName (), e )); //$NON-NLS-1$
156
+ Common .log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID ,
157
+ "failed to create folder " + confDesc .getName (), e )); //$NON-NLS-1$
152
158
}
153
159
}
154
160
// End of Bug fix for CDT 8.1 fixed in 8.2
155
161
if (languageId .equals ("org.eclipse.cdt.core.gcc" )) { //$NON-NLS-1$
156
162
try {
157
- compilerCommand = envManager .getVariable (Const .ENV_KEY_recipe_c_o_pattern , confDesc , true ).getValue ().replace (" -o " , " " ); //$NON-NLS-1$ //$NON-NLS-2$
163
+ compilerCommand = envManager .getVariable (Const .ENV_KEY_recipe_c_o_pattern , confDesc , true ).getValue ()
164
+ .replace (" -o " , " " ); //$NON-NLS-1$ //$NON-NLS-2$
158
165
} catch (Exception e ) {
159
166
compilerCommand = Const .EMPTY_STRING ;
160
167
}
161
- IEnvironmentVariable op1 = envManager .getVariable (Const .ENV_KEY_JANTJE_ADDITIONAL_COMPILE_OPTIONS , confDesc , true );
162
- IEnvironmentVariable op2 = envManager .getVariable (Const .ENV_KEY_JANTJE_ADDITIONAL_C_COMPILE_OPTIONS , confDesc , true );
168
+ IEnvironmentVariable op1 = envManager .getVariable (Const .ENV_KEY_JANTJE_ADDITIONAL_COMPILE_OPTIONS , confDesc ,
169
+ true );
170
+ IEnvironmentVariable op2 = envManager .getVariable (Const .ENV_KEY_JANTJE_ADDITIONAL_C_COMPILE_OPTIONS ,
171
+ confDesc , true );
163
172
if (op1 != null ) {
164
173
compilerCommand = compilerCommand + ' ' + op1 .getValue ();
165
174
}
166
175
if (op2 != null ) {
167
176
compilerCommand = compilerCommand + ' ' + op2 .getValue ();
168
177
}
169
- compilerCommand = compilerCommand + " -D__IN_ECLIPSE__ =1" ; //$NON-NLS-1$
178
+ compilerCommand = compilerCommand + " -D" + Const . DEFINE_IN_ECLIPSE + " =1" ; //$NON-NLS-1$
170
179
} else if (languageId .equals ("org.eclipse.cdt.core.g++" )) { //$NON-NLS-1$
171
180
try {
172
- compilerCommand = envManager .getVariable (Const .ENV_KEY_recipe_cpp_o_pattern , confDesc , true ).getValue ().replace (" -o " , " " ); //$NON-NLS-1$//$NON-NLS-2$
181
+ compilerCommand = envManager .getVariable (Const .ENV_KEY_recipe_cpp_o_pattern , confDesc , true ).getValue ()
182
+ .replace (" -o " , " " ); //$NON-NLS-1$//$NON-NLS-2$
173
183
} catch (Exception e ) {
174
184
compilerCommand = Const .EMPTY_STRING ;
175
185
}
176
- IEnvironmentVariable op1 = envManager .getVariable (Const .ENV_KEY_JANTJE_ADDITIONAL_COMPILE_OPTIONS , confDesc , true );
177
- IEnvironmentVariable op2 = envManager .getVariable (Const .ENV_KEY_JANTJE_ADDITIONAL_CPP_COMPILE_OPTIONS , confDesc , true );
186
+ IEnvironmentVariable op1 = envManager .getVariable (Const .ENV_KEY_JANTJE_ADDITIONAL_COMPILE_OPTIONS , confDesc ,
187
+ true );
188
+ IEnvironmentVariable op2 = envManager .getVariable (Const .ENV_KEY_JANTJE_ADDITIONAL_CPP_COMPILE_OPTIONS ,
189
+ confDesc , true );
178
190
if (op1 != null ) {
179
191
compilerCommand = compilerCommand + ' ' + op1 .getValue ();
180
192
}
181
193
if (op2 != null ) {
182
194
compilerCommand = compilerCommand + ' ' + op2 .getValue ();
183
195
}
184
- compilerCommand = compilerCommand + " -D__IN_ECLIPSE__ =1" ; //$NON-NLS-1$
196
+ compilerCommand = compilerCommand + " -D" + Const . DEFINE_IN_ECLIPSE + " =1" ; //$NON-NLS-1$
185
197
} else {
186
- ManagedBuilderCorePlugin .error ("Unable to find compiler command for language " + languageId + " in toolchain=" + getToolchainId ()); //$NON-NLS-1$ //$NON-NLS-2$
198
+ ManagedBuilderCorePlugin .error (
199
+ "Unable to find compiler command for language " + languageId + " in toolchain=" + getToolchainId ()); //$NON-NLS-1$ //$NON-NLS-2$
187
200
}
188
201
189
- String ret = compilerCommand .replaceAll (" -MMD " , " " ).replaceAll ("[^\\ \\ ]\" \" " , Const .EMPTY_STRING ).replaceAll (" " , " " ); // remove //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
202
+ String ret = compilerCommand .replaceAll (" -MMD " , " " ).replaceAll ("[^\\ \\ ]\" \" " , Const .EMPTY_STRING ) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
203
+ .replaceAll (" " , " " ); // remove //$NON-NLS-1$ //$NON-NLS-2$
190
204
// "" except \""
191
205
// and
192
206
// double
0 commit comments