Skip to content

Commit

Permalink
#1283 convert now also work when there is no sloeber.cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
jantje committed Jan 22, 2021
1 parent 365a855 commit 71b2669
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 11 additions & 9 deletions io.sloeber.core/src/io/sloeber/core/api/SloeberProject.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,21 @@ public void run(IProgressMonitor internalMonitor) throws CoreException {
workspaceDesc.setAutoBuilding(false);
workspace.setDescription(workspaceDesc);

String RELEASE = "Release";

// create a sloeber project
SloeberProject sloeberProject = new SloeberProject(project);
if (!sloeberProject.readConfigFromFiles()) {
String RELEASE = "Release";
sloeberProject.setBoardDescription(RELEASE, new BoardDescription(), false);
sloeberProject.setCompileDescription(RELEASE, new CompileDescription());
sloeberProject.setOtherDescription(RELEASE, new OtherDescription());
// we failed to read from disk so we set opourselfves some values
// faking the stuf is in memory
sloeberProject.isInMemory = true;
}

BoardDescription boardDescriptor = sloeberProject.getBoardDescription(RELEASE, true);
CompileDescription compileDescriptor = sloeberProject.getCompileDescription(RELEASE, true);
OtherDescription otherDesc = sloeberProject.getOtherDescription(RELEASE, true);
String configName = sloeberProject.myBoardDescriptions.keySet().iterator().next();
BoardDescription boardDescriptor = sloeberProject.getBoardDescription(configName, true);
CompileDescription compileDescriptor = sloeberProject.getCompileDescription(configName, true);
OtherDescription otherDesc = sloeberProject.getOtherDescription(configName, true);

// Add the arduino code folders
List<IPath> addToIncludePath = Helpers.addArduinoCodeToProject(project, boardDescriptor);
Expand Down Expand Up @@ -393,7 +395,7 @@ public void configure() {
* @return true if the projectDesc needs to be saved
*/

private boolean configure(ICProjectDescription prjCDesc, boolean prjDescWritable) {
public boolean configure(ICProjectDescription prjCDesc, boolean prjDescWritable) {
Map<String, String> configs = getConfigs(prjCDesc);
boolean saveProjDesc = false;
if (isInMemory) {
Expand Down Expand Up @@ -432,7 +434,6 @@ private boolean configure(ICProjectDescription prjCDesc, boolean prjDescWritable
}
}
setEnvironmentVariables(getCfgKeys(configs));
isInMemory = true;
return saveProjDesc;
}

Expand Down Expand Up @@ -587,6 +588,7 @@ private boolean readConfig(ICProjectDescription prjCDesc, boolean prjDescWritabl

}
}
isInMemory = true;
return projDescNeedsWriting;
}

Expand Down Expand Up @@ -995,7 +997,7 @@ public void sloeberCfgChanged() {
CCorePlugin cCorePlugin = CCorePlugin.getDefault();
ICProjectDescription projDesc = cCorePlugin.getProjectDescription(myProject);
ICConfigurationDescription activeConfig = projDesc.getActiveConfiguration();
isInMemory = false;
isDirty = true;
boolean projDescNeedsSaving = configure(projDesc, true);
Helpers.deleteBuildFolder(myProject, activeConfig.getName());
projDescNeedsSaving = projDescNeedsSaving || setActiveConfig(activeConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ private void initializeIfNotYetDone(IConfiguration configuration) {
ICProjectDescription projDesc = confDesc.getProjectDescription();
IProject project = projDesc.getProject();
SloeberProject sloeberProject = SloeberProject.getSloeberProject(project, false);
sloeberProject.configure();
sloeberProject.configure(projDesc, false);
}
}

0 comments on commit 71b2669

Please sign in to comment.