Skip to content

Commit 483f9d6

Browse files
author
jan
committed
Handle ${SLOEBER_HOME} properly for the boards.txt file
When reading the cfg file the ${SLOEBER_HOME) (if present) was not properly processed. This change also makes sure the SLOBER_HOME variable is there if it needs to be (It went from string replacement to pat.isPrefix) Hopefully this fixes the github build
1 parent 9b525b2 commit 483f9d6

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ public BoardDescription(Map<String, String> envVars) {
697697
myBoardID = value;
698698
break;
699699
case KEY_SLOEBER_BOARD_TXT:
700-
myUserSelectedBoardsTxtFile = new File(value);
700+
myUserSelectedBoardsTxtFile = resolvePathEnvironmentString(new File(value));
701701
mySloeberBoardTxtFile = new BoardTxtFile(myUserSelectedBoardsTxtFile);
702702
break;
703703
case KEY_SLOEBER_UPLOAD_PORT:
@@ -822,7 +822,7 @@ public Map<String, String> getEnvVars() {
822822
}
823823
allVars.put(ENV_KEY_SOFTWARE,VENDOR_ARDUINO);
824824
allVars.put(ENV_KEY_ID,getBoardID());
825-
825+
826826

827827

828828
allVars.put(ENV_KEY_SERIAL_PORT, getActualUploadPort());

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,16 +228,15 @@ public static IPath getWorkspaceRoot() {
228228
* Check whether the string starts with the SLOEBER_HOME path If it does replace
229229
* with environment variable This keeps things more compatible over environments
230230
*
231-
* @param path
231+
* @param file
232232
* string to check
233233
* @return modified string or the original
234234
*/
235-
public static String makePathEnvironmentString(IPath path) {
236-
return path.toOSString().replace(sloeberHomePathToString, SLOEBER_HOME_VAR);
237-
}
238-
239235
public static String makePathVersionString(File file) {
240-
return file.getPath().replace(sloeberHomePathToString, SLOEBER_HOME_VAR);
236+
if(sloeberHomePath.isPrefixOf(IPath.fromFile(file))) {
237+
return SLOEBER_HOME_VAR+SLACH+IPath.fromFile(file) .makeRelativeTo(sloeberHomePath).toString();
238+
}
239+
return file.toString();
241240
}
242241

243242
/**
@@ -247,7 +246,13 @@ public static String makePathVersionString(File file) {
247246
* @return
248247
*/
249248
public static File resolvePathEnvironmentString(File file) {
250-
String retString = file.getPath().replace(SLOEBER_HOME_VAR, sloeberHomePathToString);
249+
250+
String retString = file.getPath();
251+
if (retString.startsWith(SLOEBER_HOME_VAR)) {
252+
retString=retString.replace(SLOEBER_HOME_VAR, EMPTY_STRING);
253+
return sloeberHomePath.append(retString).toFile();
254+
//.replace(SLOEBER_HOME_VAR, sloeberHomePathToString);
255+
}
251256
return new File(retString);
252257
}
253258

0 commit comments

Comments
 (0)