2222import it .baeyens .arduino .common .Common ;
2323import it .baeyens .arduino .common .Const ;
2424
25- public class ArduinoLanguageProvider extends ToolchainBuiltinSpecsDetector implements ILanguageSettingsEditableProvider {
25+ public class ArduinoLanguageProvider extends ToolchainBuiltinSpecsDetector
26+ implements ILanguageSettingsEditableProvider {
2627 // ID must match the tool-chain definition in
2728 // org.eclipse.cdt.managedbuilder.core.buildDefinitions extension point
2829 private static final String GCC_TOOLCHAIN_ID = "cdt.managedbuild.toolchain.gnu.base" ; //$NON-NLS-1$
@@ -34,12 +35,15 @@ private enum State {
3435 private State state = State .NONE ;
3536
3637 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 ),
3840 new IncludePathOptionParser ("#include <(\\ S.*)>" , "$1" , ICSettingEntry .BUILTIN | ICSettingEntry .READONLY ), //$NON-NLS-1$ //$NON-NLS-2$
3941 new IncludePathOptionParser ("#framework <(\\ S.*)>" , "$1" , //$NON-NLS-1$ //$NON-NLS-2$
4042 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 ), };
4347
4448 @ Override
4549 public String getToolchainId () {
@@ -105,7 +109,8 @@ protected List<String> parseOptions(String lineIn) {
105109 }
106110
107111 @ Override
108- public void startup (ICConfigurationDescription cfgDescription , IWorkingDirectoryTracker cwdTracker1 ) throws CoreException {
112+ public void startup (ICConfigurationDescription cfgDescription , IWorkingDirectoryTracker cwdTracker1 )
113+ throws CoreException {
109114 super .startup (cfgDescription , cwdTracker1 );
110115
111116 this .state = State .NONE ;
@@ -148,45 +153,54 @@ protected String getCompilerCommand(String languageId) {
148153 try {
149154 buildFolder .create (true , true , null );
150155 } 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$
152158 }
153159 }
154160 // End of Bug fix for CDT 8.1 fixed in 8.2
155161 if (languageId .equals ("org.eclipse.cdt.core.gcc" )) { //$NON-NLS-1$
156162 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$
158165 } catch (Exception e ) {
159166 compilerCommand = Const .EMPTY_STRING ;
160167 }
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 );
163172 if (op1 != null ) {
164173 compilerCommand = compilerCommand + ' ' + op1 .getValue ();
165174 }
166175 if (op2 != null ) {
167176 compilerCommand = compilerCommand + ' ' + op2 .getValue ();
168177 }
169- compilerCommand = compilerCommand + " -D__IN_ECLIPSE__ =1" ; //$NON-NLS-1$
178+ compilerCommand = compilerCommand + " -D" + Const . DEFINE_IN_ECLIPSE + " =1" ; //$NON-NLS-1$
170179 } else if (languageId .equals ("org.eclipse.cdt.core.g++" )) { //$NON-NLS-1$
171180 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$
173183 } catch (Exception e ) {
174184 compilerCommand = Const .EMPTY_STRING ;
175185 }
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 );
178190 if (op1 != null ) {
179191 compilerCommand = compilerCommand + ' ' + op1 .getValue ();
180192 }
181193 if (op2 != null ) {
182194 compilerCommand = compilerCommand + ' ' + op2 .getValue ();
183195 }
184- compilerCommand = compilerCommand + " -D__IN_ECLIPSE__ =1" ; //$NON-NLS-1$
196+ compilerCommand = compilerCommand + " -D" + Const . DEFINE_IN_ECLIPSE + " =1" ; //$NON-NLS-1$
185197 } 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$
187200 }
188201
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$
190204 // "" except \""
191205 // and
192206 // double
0 commit comments