Skip to content

Commit 5abbd0a

Browse files
author
jantje
committed
#80 upload Port and upload protocol changes no longer trigger clean
I do log a info message in the error log that a clean may be required.
1 parent 44dbdc3 commit 5abbd0a

File tree

1 file changed

+45
-22
lines changed

1 file changed

+45
-22
lines changed

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

+45-22
Original file line numberDiff line numberDiff line change
@@ -142,36 +142,49 @@ public String toString() {
142142
* @param obj
143143
* @return true if equal otherwise false
144144
*/
145-
public boolean equals(BoardDescriptor obj) {
146-
if (!this.getUploadPort().equals(obj.getUploadPort())) {
145+
public boolean equals(BoardDescriptor otherBoardDescriptor) {
146+
if (!this.getUploadPort().equals(otherBoardDescriptor.getUploadPort())) {
147147
return false;
148148
}
149-
if (!this.getProgrammer().equals(obj.getProgrammer())) {
149+
if (!this.getProgrammer().equals(otherBoardDescriptor.getProgrammer())) {
150150
return false;
151151
}
152-
if (!this.getBoardID().equals(obj.getBoardID())) {
153-
return false;
154-
}
155-
if (!this.getReferencingBoardsFile().equals(obj.getReferencingBoardsFile())) {
156-
return false;
152+
return !needsSettingDirty(otherBoardDescriptor);
153+
}
154+
155+
/**
156+
* compare 2 board descriptors and return true if replacing one board descriptor
157+
* with the other implies that a rebuild is needed
158+
*
159+
* @param otherBoardDescriptor
160+
* @return
161+
*/
162+
public boolean needsSettingDirty(BoardDescriptor otherBoardDescriptor) {
163+
164+
165+
if (!this.getBoardID().equals(otherBoardDescriptor.getBoardID())) {
166+
return true;
157167
}
158-
if (!this.getOptions().equals(obj.getOptions())) {
159-
return false;
168+
if (!this.getReferencingBoardsFile().equals(otherBoardDescriptor.getReferencingBoardsFile())) {
169+
return true;
160170
}
161-
if (!this.getProjectName().equals(obj.getProjectName())) {
162-
return false;
171+
if (!this.getOptions().equals(otherBoardDescriptor.getOptions())) {
172+
return true;
163173
}
164-
if (!this.getMyOSName().equals(obj.getMyOSName())) {
165-
return false;
174+
if (!this.getProjectName().equals(otherBoardDescriptor.getProjectName())) {
175+
return true;
166176
}
167-
if (!this.getMyWorkEclipseLocation().equals(obj.getMyWorkEclipseLocation())) {
168-
return false;
177+
if (!this.getMyOSName().equals(otherBoardDescriptor.getMyOSName())) {
178+
return true;
169179
}
170-
if (!this.getMyWorkSpaceLocation().equals(obj.getMyWorkSpaceLocation())) {
171-
return false;
180+
if (!this.getMyWorkEclipseLocation().equals(otherBoardDescriptor.getMyWorkEclipseLocation())) {
181+
return true;
172182
}
183+
if (!this.getMyWorkSpaceLocation().equals(otherBoardDescriptor.getMyWorkSpaceLocation())) {
173184
return true;
174185
}
186+
return false;
187+
}
175188

176189
/*
177190
* Create a sketchProject. This class does not really create a sketch object.
@@ -537,25 +550,34 @@ public IProject createProject(String projectName, URI projectURI,
537550
}
538551

539552
public void save(ICConfigurationDescription confdesc) throws Exception {
540-
saveConfiguration(confdesc, null);
553+
boolean needsSettingDirty = saveConfiguration(confdesc, null);
554+
541555
if (confdesc != null) {
542556
IProject project = confdesc.getProjectDescription().getProject();
543557

544558
Helpers.setTheEnvironmentVariables(project, confdesc, (InternalBoardDescriptor) this);
545559

546560
Helpers.addArduinoCodeToProject(this, project, confdesc);
547561

548-
Helpers.removeInvalidIncludeFolders(confdesc);
549-
Helpers.setDirtyFlag(project, confdesc);
562+
needsSettingDirty = needsSettingDirty || Helpers.removeInvalidIncludeFolders(confdesc);
563+
if (needsSettingDirty) {
564+
Helpers.setDirtyFlag(project, confdesc);
565+
} else {
566+
Common.log(new Status(IStatus.INFO, io.sloeber.core.Activator.getId(),
567+
"Ignoring update; clean may be required: " + project.getName()));
568+
}
550569
}
551570
}
552571

553572
public void saveConfiguration() {
554573
saveConfiguration(null, null);
555574
}
556575

557-
public void saveConfiguration(ICConfigurationDescription confDesc, IContributedEnvironment contribEnvIn) {
576+
public boolean saveConfiguration(ICConfigurationDescription confDesc, IContributedEnvironment contribEnvIn) {
577+
boolean needsSettingDirty = false;
558578
if (confDesc != null) {
579+
BoardDescriptor curBoardDesCriptor = makeBoardDescriptor(confDesc);
580+
needsSettingDirty = curBoardDesCriptor.needsSettingDirty(this);
559581
IContributedEnvironment contribEnv = contribEnvIn;
560582
if (contribEnv == null) {
561583
IEnvironmentVariableManager envManager = CCorePlugin.getDefault().getBuildEnvironmentManager();
@@ -595,6 +617,7 @@ public void saveConfiguration(ICConfigurationDescription confDesc, IContributedE
595617
myStorageNode.put(KEY_LAST_USED_UPLOAD_PORT, this.myUploadPort);
596618
myStorageNode.put(KEY_LAST_USED_UPLOAD_PROTOCOL, this.myProgrammer);
597619
myStorageNode.put(KEY_LAST_USED_BOARD_MENU_OPTIONS, KeyValue.makeString(this.myOptions));
620+
return needsSettingDirty;
598621
}
599622

600623
public String getPackage() {

0 commit comments

Comments
 (0)