Skip to content

Commit b8060e7

Browse files
committed
When environment variables were undefined an error was thrown.
1 parent 0cde76f commit b8060e7

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

it.baeyens.arduino.core/src/it/baeyens/arduino/toolchain/ArduinoLanguageProvider.java

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.util.List;
88

99
import org.eclipse.cdt.core.CCorePlugin;
10+
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
1011
import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
1112
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsEditableProvider;
1213
import org.eclipse.cdt.core.language.settings.providers.IWorkingDirectoryTracker;
@@ -153,17 +154,25 @@ protected String getCompilerCommand(String languageId) {
153154
// End of Bug fix for CDT 8.1 fixed in 8.2
154155
if (languageId.equals("org.eclipse.cdt.core.gcc")) {
155156
compilerCommand = envManager.getVariable(ArduinoConst.ENV_KEY_recipe_c_o_pattern, confDesc, true).getValue().replace(" -o ", "");
156-
compilerCommand = compilerCommand + " "
157-
+ envManager.getVariable(ArduinoConst.ENV_KEY_JANTJE_ADDITIONAL_COMPILE_OPTIONS, confDesc, true).getValue();
158-
compilerCommand = compilerCommand + " "
159-
+ envManager.getVariable(ArduinoConst.ENV_KEY_JANTJE_ADDITIONAL_C_COMPILE_OPTIONS, confDesc, true).getValue();
157+
IEnvironmentVariable op1 = envManager.getVariable(ArduinoConst.ENV_KEY_JANTJE_ADDITIONAL_COMPILE_OPTIONS, confDesc, true);
158+
IEnvironmentVariable op2 = envManager.getVariable(ArduinoConst.ENV_KEY_JANTJE_ADDITIONAL_C_COMPILE_OPTIONS, confDesc, true);
159+
if (op1 != null) {
160+
compilerCommand = compilerCommand + " " + op1.getValue();
161+
}
162+
if (op2 != null) {
163+
compilerCommand = compilerCommand + " " + op2.getValue();
164+
}
160165
compilerCommand = compilerCommand + " -D__IN_ECLIPSE__=1";
161166
} else if (languageId.equals("org.eclipse.cdt.core.g++")) {
162167
compilerCommand = envManager.getVariable(ArduinoConst.ENV_KEY_recipe_cpp_o_pattern, confDesc, true).getValue().replace(" -o ", "");
163-
compilerCommand = compilerCommand + " "
164-
+ envManager.getVariable(ArduinoConst.ENV_KEY_JANTJE_ADDITIONAL_COMPILE_OPTIONS, confDesc, true).getValue();
165-
compilerCommand = compilerCommand + " "
166-
+ envManager.getVariable(ArduinoConst.ENV_KEY_JANTJE_ADDITIONAL_CPP_COMPILE_OPTIONS, confDesc, true).getValue();
168+
IEnvironmentVariable op1 = envManager.getVariable(ArduinoConst.ENV_KEY_JANTJE_ADDITIONAL_COMPILE_OPTIONS, confDesc, true);
169+
IEnvironmentVariable op2 = envManager.getVariable(ArduinoConst.ENV_KEY_JANTJE_ADDITIONAL_CPP_COMPILE_OPTIONS, confDesc, true);
170+
if (op1 != null) {
171+
compilerCommand = compilerCommand + " " + op1.getValue();
172+
}
173+
if (op2 != null) {
174+
compilerCommand = compilerCommand + " " + op2.getValue();
175+
}
167176
compilerCommand = compilerCommand + " -D__IN_ECLIPSE__=1";
168177
} else {
169178
ManagedBuilderCorePlugin.error("Unable to find compiler command for language " + languageId + " in toolchain=" + getToolchainId()); //$NON-NLS-1$

0 commit comments

Comments
 (0)