Skip to content

Commit b11301d

Browse files
committed
Removed the debug flag when creating a sketch.
The debug configuration is identified by a name starting with "Debug"
1 parent 769bdb4 commit b11301d

File tree

3 files changed

+38
-46
lines changed

3 files changed

+38
-46
lines changed

it.baeyens.arduino.core/src/it/baeyens/arduino/tools/ArduinoHelpers.java

Lines changed: 36 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,9 @@ public static void addCodeFolder(IProject project, String PathVarName, String Su
246246
}
247247

248248
/**
249-
* This method creates a link folder in the project and adds the folder as a source path to the project it also adds the path to the include folder
250-
* if the includepath parameter points to a path that contains a subfolder named "utility" this subfolder will be added to the include path as
251-
* well <br/>
249+
* This method creates a link folder in the project and adds the folder as a source path to the project it also adds the path to the include
250+
* folder if the includepath parameter points to a path that contains a subfolder named "utility" this subfolder will be added to the include path
251+
* as well <br/>
252252
* <br/>
253253
*
254254
* note Arduino has these subfolders in the libraries that need to be include.<br/>
@@ -711,8 +711,7 @@ private static boolean isThisMenuItemSelected(ArduinoBoards boardsFile, ICConfig
711711
* the info of the selected board to set the variables for
712712
*/
713713

714-
715-
public static void setTheEnvironmentVariables(IProject project, ICConfigurationDescription confDesc, boolean debugConfig) {
714+
public static void setTheEnvironmentVariables(IProject project, ICConfigurationDescription confDesc) {
716715

717716
IEnvironmentVariableManager envManager = CCorePlugin.getDefault().getBuildEnvironmentManager();
718717
IContributedEnvironment contribEnv = envManager.getContributedEnvironment();
@@ -738,10 +737,10 @@ public static void setTheEnvironmentVariables(IProject project, ICConfigurationD
738737
setTheEnvironmentVariablesAddtheBoardsTxt(contribEnv, confDesc, boardFileName, boardName);
739738
// Do some post processing
740739
setTheEnvironmentVariablesPostProcessing(contribEnv, confDesc);
741-
742-
//If this is a debug config we modify the environment variables for compilation
743-
if(debugConfig) {
744-
setTheEnvironmentVariablesModifyDebugCompilerSettings(confDesc, envManager, contribEnv);
740+
741+
// If this is a debug config we modify the environment variables for compilation
742+
if (confDesc.getName().startsWith("Debug")) {
743+
setTheEnvironmentVariablesModifyDebugCompilerSettings(confDesc, envManager, contribEnv);
745744
}
746745

747746
} catch (Exception e) {// Catch exception if any
@@ -806,47 +805,41 @@ private static void setTheEnvironmentVariablesPostProcessing(IContributedEnviron
806805
}
807806

808807
/**
809-
* Converts the CPP and C compiler flags to not optimise for space/size and to leave symbols in.
810-
* These changes allow step through debugging with JTAG and Dragon AVR
808+
* Converts the CPP and C compiler flags to not optimise for space/size and to leave symbols in. These changes allow step through debugging with
809+
* JTAG and Dragon AVR
810+
*
811811
* @param confDesc
812812
* @param envManager
813813
* @param contribEnv
814814
*/
815815

816-
private static void setTheEnvironmentVariablesModifyDebugCompilerSettings(
817-
ICConfigurationDescription confDesc,
818-
IEnvironmentVariableManager envManager,
819-
IContributedEnvironment contribEnv) {
820-
821-
//Modify the compiler flags for the debug configuration
822-
//Replace "-g" with "-g2"
823-
//Replace "-Os" with ""
824-
//TODO: This should move to another location eventually -- a bit hacky here (considering other env vars come from other -- a little bit magical -- places).
825-
//I couldn't easily determine where that magic happened :(
826-
IEnvironmentVariable original = null;
827-
IEnvironmentVariable replacement = null;
828-
829-
original = envManager.getVariable( ENV_KEY_ARDUINO_START + "COMPILER.C.FLAGS" , confDesc, true);
830-
if(original != null)
831-
{
832-
replacement = new EnvironmentVariable(original.getName(),
833-
original.getValue().replace("-g", "-g2").replace("-Os", ""),
834-
original.getOperation(), original.getDelimiter() );
835-
contribEnv.addVariable(replacement, confDesc);
836-
}
837-
838-
original = envManager.getVariable( ENV_KEY_ARDUINO_START + "COMPILER.CPP.FLAGS" , confDesc, true);
839-
if(original != null)
840-
{
841-
replacement = new EnvironmentVariable(original.getName(),
842-
original.getValue().replace("-g", "-g2").replace("-Os", ""),
843-
original.getOperation(), original.getDelimiter() );
844-
contribEnv.addVariable(replacement, confDesc);
845-
}
816+
private static void setTheEnvironmentVariablesModifyDebugCompilerSettings(ICConfigurationDescription confDesc,
817+
IEnvironmentVariableManager envManager, IContributedEnvironment contribEnv) {
818+
819+
// Modify the compiler flags for the debug configuration
820+
// Replace "-g" with "-g2"
821+
// Replace "-Os" with ""
822+
// TODO: This should move to another location eventually -- a bit hacky here (considering other env vars come from other -- a little bit
823+
// magical -- places).
824+
// I couldn't easily determine where that magic happened :(
825+
IEnvironmentVariable original = null;
826+
IEnvironmentVariable replacement = null;
827+
828+
original = envManager.getVariable(ENV_KEY_ARDUINO_START + "COMPILER.C.FLAGS", confDesc, true);
829+
if (original != null) {
830+
replacement = new EnvironmentVariable(original.getName(), original.getValue().replace("-g", "-g2").replace("-Os", ""),
831+
original.getOperation(), original.getDelimiter());
832+
contribEnv.addVariable(replacement, confDesc);
846833
}
847834

848-
849-
835+
original = envManager.getVariable(ENV_KEY_ARDUINO_START + "COMPILER.CPP.FLAGS", confDesc, true);
836+
if (original != null) {
837+
replacement = new EnvironmentVariable(original.getName(), original.getValue().replace("-g", "-g2").replace("-Os", ""),
838+
original.getOperation(), original.getDelimiter());
839+
contribEnv.addVariable(replacement, confDesc);
840+
}
841+
}
842+
850843
/**
851844
* When parsing boards.txt and platform.txt some processing needs to be done to get "acceptable environment variable values" This method does the
852845
* parsing

it.baeyens.arduino.core/src/it/baeyens/arduino/ui/ArduinoSelectionPage.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,7 @@ public void saveAllSelections(ICConfigurationDescription confdesc) {
370370
contribEnv.addVariable(var, confdesc);
371371

372372
ArduinoHelpers.setProjectPathVariables(project, platformPath.removeLastSegments(1));
373-
ArduinoHelpers.setTheEnvironmentVariables(project, confdesc, false);
374-
373+
ArduinoHelpers.setTheEnvironmentVariables(project, confdesc);
375374

376375
try {
377376
ArduinoHelpers.addArduinoCodeToProject(project, confdesc);

it.baeyens.arduino.core/src/it/baeyens/arduino/ui/NewArduinoSketchWizard.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ void createProject(IProjectDescription description, IProject project, IProgressM
179179
for (int i = 0; i < Math.min(sTCIds.length, sCfgs.length); i++) {
180180
ICConfigurationDescription configurationDescriptionRel = prjDesc.getConfigurationByName(sCfgs[i]);
181181
mArduinoPage.saveAllSelections(configurationDescriptionRel);
182-
ArduinoHelpers.setTheEnvironmentVariables(project, configurationDescriptionRel, sCfgs.equals("Debug"));
182+
ArduinoHelpers.setTheEnvironmentVariables(project, configurationDescriptionRel);
183183
}
184184

185185
// Set the path variables

0 commit comments

Comments
 (0)