Skip to content

Commit 70d43df

Browse files
committed
add build option for parallel build
1 parent 8a7fea5 commit 70d43df

File tree

8 files changed

+42
-4
lines changed

8 files changed

+42
-4
lines changed

io.sloeber.core/src/io/sloeber/core/api/BoardDescriptor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ public IProject createProject(String projectName, URI projectURI,
542542

543543
// Creates the .cproject file with the configurations
544544
ICProjectDescription prjCDesc = ShouldHaveBeenInCDT.setCProjectDescription(projectHandle, cfgNamesAndTCIds,
545-
true, monitor);
545+
true, compileOptions.isParallelBuildEnabledForNewProject(), monitor);
546546

547547
// Add the C C++ AVR and other needed Natures to the project
548548
Helpers.addTheNatures(desc);

io.sloeber.core/src/io/sloeber/core/api/CompileOptions.java

+9
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class CompileOptions {
2525
private String my_Link_CompileOptions = new String();
2626
private String my_All_CompileOptions = new String();
2727

28+
private boolean myEnableParallelBuildForNewProject;
2829

2930

3031
private static final String ENV_KEY_WARNING_LEVEL_OFF = "A.COMPILER.WARNING_FLAGS"; //$NON-NLS-1$
@@ -94,6 +95,14 @@ public boolean isWarningLevel() {
9495
public void setWarningLevel(boolean myWarningLevel) {
9596
this.myWarningLevel = new Boolean(myWarningLevel);
9697
}
98+
99+
public boolean isParallelBuildEnabledForNewProject() {
100+
return myEnableParallelBuildForNewProject;
101+
}
102+
103+
public void setEnableParallelBuildForNewProject(boolean myEnableParallelBuildForNewProject) {
104+
this.myEnableParallelBuildForNewProject = myEnableParallelBuildForNewProject;
105+
}
97106

98107
public boolean isAlternativeSizeCommand() {
99108
return this.myAlternativeSizeCommand;

io.sloeber.core/src/io/sloeber/core/tools/ShouldHaveBeenInCDT.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public class ShouldHaveBeenInCDT {
5555
* @throws CoreException
5656
*/
5757
public static ICProjectDescription setCProjectDescription(IProject project,
58-
ArrayList<ConfigurationDescriptor> alCfgs, boolean isManagedBuild, IProgressMonitor monitor)
58+
ArrayList<ConfigurationDescriptor> alCfgs, boolean isManagedBuild, boolean enableParallelBuild, IProgressMonitor monitor)
5959
throws CoreException {
6060

6161
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
@@ -71,7 +71,9 @@ public static ICProjectDescription setCProjectDescription(IProject project,
7171

7272
Configuration cfg = new Configuration(mProj, (ToolChain) tcs,
7373
ManagedBuildManager.calculateChildId(curConfDesc.ToolchainID, null), curConfDesc.configName);
74-
cfg.setParallelDef(true);
74+
if (enableParallelBuild) {
75+
cfg.setParallelDef(true);
76+
}
7577
IBuilder bld = cfg.getEditableBuilder();
7678
if (bld != null) {
7779
bld.setManagedBuildOn(isManagedBuild);

io.sloeber.ui/src/io/sloeber/ui/Messages.java

+1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public class Messages extends NLS {
100100
public static String SampleSelector_num_selected;
101101

102102
public static String ui_Clean_Serial_Monitor_After_Upload;
103+
public static String ui_Enable_Parallel_Build_For_New_Projects;
103104
public static String ArduinoUploadProjectHandler_Build_failed;
104105
public static String ArduinoUploadProjectHandler_Build_failed_so_no_upload;
105106
public static String ArduinoUploadProjectHandler_Multiple_projects_found;

io.sloeber.ui/src/io/sloeber/ui/helpers/MyPreferences.java

+17
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public class MyPreferences {
2626
public static final String NODE_ARDUINO = "io.sloeber.core.ui"; //$NON-NLS-1$
2727
public static final String KEY_OPEN_SERIAL_WITH_MONITOR = "Open serial connections with the monitor"; //$NON-NLS-1$
2828
private static final String KEY_CLEAN_MONITOR_AFTER_UPLOAD = "Clean Serial Monitor after upload"; //$NON-NLS-1$
29+
private static final String KEY_ENABLE_PARALLEL_BUILD_FOR_NEW_PROJECTS = "Enable parallel build for new projects"; //$NON-NLS-1$
30+
2931
public static final boolean DEFAULT_OPEN_SERIAL_WITH_MONITOR = true;
3032
// Serial monitor keys
3133
private static final String KEY_SERIAL_RATE = "Serial monitor last selected rate"; //$NON-NLS-1$
@@ -177,6 +179,11 @@ public static boolean getCleanSerialMonitorAfterUpload() {
177179

178180
}
179181

182+
public static boolean getEnableParallelBuildForNewProjects() {
183+
return getGlobalBoolean(KEY_ENABLE_PARALLEL_BUILD_FOR_NEW_PROJECTS, false);
184+
185+
}
186+
180187
/**
181188
* This method returns the index of the last used line ending options are CR
182189
* LF CR+LF none
@@ -214,6 +221,16 @@ public static String getCleanSerialMonitorAfterUploadKey() {
214221
return KEY_CLEAN_MONITOR_AFTER_UPLOAD;
215222
}
216223

224+
public static String getEnableParallelBuildForNewProjectsKey() {
225+
return KEY_ENABLE_PARALLEL_BUILD_FOR_NEW_PROJECTS;
226+
227+
}
228+
229+
public static void setEnableParallelBuildForNewProjects(boolean newSetting) {
230+
setGlobalValue(KEY_ENABLE_PARALLEL_BUILD_FOR_NEW_PROJECTS, newSetting);
231+
232+
}
233+
217234
public static boolean getLastUsedPlotterFilter() {
218235
return getGlobalBoolean(KEY_LAST_USED_PLOTTER_FILTER_MENU_OPTION, false);
219236

io.sloeber.ui/src/io/sloeber/ui/messages.properties

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ ui_url_for_index_file=Enter URLs for package_index.json or library_index.json fi
6464
ui_workspace_settings=Arduino Settings for this workspace:
6565
ui_error_select_arduino_project=As no project is selected it is not possible to import libraries
6666
ui_Clean_Serial_Monitor_After_Upload=Clean Serial monitor after upload
67+
ui_Enable_Parallel_Build_For_New_Projects=Enable parallel build for new projects
6768
ArduinoUploadProjectHandler_Build_failed=The build failed\!
6869
ArduinoUploadProjectHandler_Build_failed_so_no_upload=As the build failed the upload is not executed.
6970
ArduinoUploadProjectHandler_Multiple_projects_found=Only 1 project should be selected: found

io.sloeber.ui/src/io/sloeber/ui/preferences/PreferencePage.java

+5
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public class PreferencePage extends FieldEditorPreferencePage implements IWorkbe
5555
private BooleanFieldEditor useArduinoToolchainSelectionEditor;
5656
private BooleanFieldEditor pragmaOnceHeaderOptionEditor;
5757
private BooleanFieldEditor cleanSerialMonitorAfterUploadEditor;
58+
private BooleanFieldEditor enableParallelBuildForNewProjects;
5859

5960
public PreferencePage() {
6061
super(org.eclipse.jface.preference.FieldEditorPreferencePage.GRID);
@@ -182,6 +183,10 @@ protected void createFieldEditors() {
182183
Messages.ui_Clean_Serial_Monitor_After_Upload, BooleanFieldEditor.DEFAULT, parent);
183184
addField(this.cleanSerialMonitorAfterUploadEditor);
184185

186+
this.enableParallelBuildForNewProjects = new BooleanFieldEditor(MyPreferences.getEnableParallelBuildForNewProjectsKey(),
187+
Messages.ui_Enable_Parallel_Build_For_New_Projects, BooleanFieldEditor.DEFAULT, parent);
188+
addField(this.enableParallelBuildForNewProjects);
189+
185190
createLine(parent, 4);
186191
Label label = new Label(parent, SWT.LEFT);
187192
label.setText("Your HashKey: " + Other.getSystemHash()); //$NON-NLS-1$

io.sloeber.ui/src/io/sloeber/ui/wizard/newsketch/NewSketchWizard.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import io.sloeber.core.api.ConfigurationDescriptor;
2727
import io.sloeber.ui.Activator;
2828
import io.sloeber.ui.Messages;
29+
import io.sloeber.ui.helpers.MyPreferences;
2930

3031
/**
3132
* This class is the class related to the new arduino sketch
@@ -121,9 +122,11 @@ protected void createProjectWrapper(IProgressMonitor monitor) {
121122
BoardDescriptor boardID = this.mArduinoPage.getBoardID();
122123
CodeDescriptor codeDescription = this.mNewArduinoSketchWizardCodeSelectionPage.getCodeDescription();
123124
try {
125+
CompileOptions compileOptions = new CompileOptions(null);
126+
compileOptions.setEnableParallelBuildForNewProject(MyPreferences.getEnableParallelBuildForNewProjects());
124127
this.mProject = boardID.createProject(this.mWizardPage.getProjectName(),
125128
(!this.mWizardPage.useDefaults()) ? this.mWizardPage.getLocationURI() : null,
126-
ConfigurationDescriptor.getDefaultDescriptors(), codeDescription, new CompileOptions(null),
129+
ConfigurationDescriptor.getDefaultDescriptors(), codeDescription, compileOptions,
127130
monitor);
128131

129132
} catch (Exception e) {

0 commit comments

Comments
 (0)