Skip to content

Commit 71b2669

Browse files
author
jantje
committed
#1283 convert now also work when there is no sloeber.cfg
1 parent 365a855 commit 71b2669

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

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

+11-9
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,21 @@ public void run(IProgressMonitor internalMonitor) throws CoreException {
113113
workspaceDesc.setAutoBuilding(false);
114114
workspace.setDescription(workspaceDesc);
115115

116-
String RELEASE = "Release";
117-
118116
// create a sloeber project
119117
SloeberProject sloeberProject = new SloeberProject(project);
120118
if (!sloeberProject.readConfigFromFiles()) {
119+
String RELEASE = "Release";
121120
sloeberProject.setBoardDescription(RELEASE, new BoardDescription(), false);
122121
sloeberProject.setCompileDescription(RELEASE, new CompileDescription());
123122
sloeberProject.setOtherDescription(RELEASE, new OtherDescription());
123+
// we failed to read from disk so we set opourselfves some values
124+
// faking the stuf is in memory
125+
sloeberProject.isInMemory = true;
124126
}
125-
126-
BoardDescription boardDescriptor = sloeberProject.getBoardDescription(RELEASE, true);
127-
CompileDescription compileDescriptor = sloeberProject.getCompileDescription(RELEASE, true);
128-
OtherDescription otherDesc = sloeberProject.getOtherDescription(RELEASE, true);
127+
String configName = sloeberProject.myBoardDescriptions.keySet().iterator().next();
128+
BoardDescription boardDescriptor = sloeberProject.getBoardDescription(configName, true);
129+
CompileDescription compileDescriptor = sloeberProject.getCompileDescription(configName, true);
130+
OtherDescription otherDesc = sloeberProject.getOtherDescription(configName, true);
129131

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

396-
private boolean configure(ICProjectDescription prjCDesc, boolean prjDescWritable) {
398+
public boolean configure(ICProjectDescription prjCDesc, boolean prjDescWritable) {
397399
Map<String, String> configs = getConfigs(prjCDesc);
398400
boolean saveProjDesc = false;
399401
if (isInMemory) {
@@ -432,7 +434,6 @@ private boolean configure(ICProjectDescription prjCDesc, boolean prjDescWritable
432434
}
433435
}
434436
setEnvironmentVariables(getCfgKeys(configs));
435-
isInMemory = true;
436437
return saveProjDesc;
437438
}
438439

@@ -587,6 +588,7 @@ private boolean readConfig(ICProjectDescription prjCDesc, boolean prjDescWritabl
587588

588589
}
589590
}
591+
isInMemory = true;
590592
return projDescNeedsWriting;
591593
}
592594

@@ -995,7 +997,7 @@ public void sloeberCfgChanged() {
995997
CCorePlugin cCorePlugin = CCorePlugin.getDefault();
996998
ICProjectDescription projDesc = cCorePlugin.getProjectDescription(myProject);
997999
ICConfigurationDescription activeConfig = projDesc.getActiveConfiguration();
998-
isInMemory = false;
1000+
isDirty = true;
9991001
boolean projDescNeedsSaving = configure(projDesc, true);
10001002
Helpers.deleteBuildFolder(myProject, activeConfig.getName());
10011003
projDescNeedsSaving = projDescNeedsSaving || setActiveConfig(activeConfig);

io.sloeber.core/src/io/sloeber/core/toolchain/SloeberConfigurationVariableSupplier.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,6 @@ private void initializeIfNotYetDone(IConfiguration configuration) {
7878
ICProjectDescription projDesc = confDesc.getProjectDescription();
7979
IProject project = projDesc.getProject();
8080
SloeberProject sloeberProject = SloeberProject.getSloeberProject(project, false);
81-
sloeberProject.configure();
81+
sloeberProject.configure(projDesc, false);
8282
}
8383
}

0 commit comments

Comments
 (0)