Skip to content

Commit

Permalink
Handle ${SLOEBER_HOME} properly for the boards.txt file
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jan committed Jun 24, 2024
1 parent 9b525b2 commit 483f9d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions io.sloeber.core/src/io/sloeber/core/api/BoardDescription.java
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ public BoardDescription(Map<String, String> envVars) {
myBoardID = value;
break;
case KEY_SLOEBER_BOARD_TXT:
myUserSelectedBoardsTxtFile = new File(value);
myUserSelectedBoardsTxtFile = resolvePathEnvironmentString(new File(value));
mySloeberBoardTxtFile = new BoardTxtFile(myUserSelectedBoardsTxtFile);
break;
case KEY_SLOEBER_UPLOAD_PORT:
Expand Down Expand Up @@ -822,7 +822,7 @@ public Map<String, String> getEnvVars() {
}
allVars.put(ENV_KEY_SOFTWARE,VENDOR_ARDUINO);
allVars.put(ENV_KEY_ID,getBoardID());



allVars.put(ENV_KEY_SERIAL_PORT, getActualUploadPort());
Expand Down
19 changes: 12 additions & 7 deletions io.sloeber.core/src/io/sloeber/core/api/Common.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,15 @@ public static IPath getWorkspaceRoot() {
* Check whether the string starts with the SLOEBER_HOME path If it does replace
* with environment variable This keeps things more compatible over environments
*
* @param path
* @param file
* string to check
* @return modified string or the original
*/
public static String makePathEnvironmentString(IPath path) {
return path.toOSString().replace(sloeberHomePathToString, SLOEBER_HOME_VAR);
}

public static String makePathVersionString(File file) {
return file.getPath().replace(sloeberHomePathToString, SLOEBER_HOME_VAR);
if(sloeberHomePath.isPrefixOf(IPath.fromFile(file))) {
return SLOEBER_HOME_VAR+SLACH+IPath.fromFile(file) .makeRelativeTo(sloeberHomePath).toString();
}
return file.toString();
}

/**
Expand All @@ -247,7 +246,13 @@ public static String makePathVersionString(File file) {
* @return
*/
public static File resolvePathEnvironmentString(File file) {
String retString = file.getPath().replace(SLOEBER_HOME_VAR, sloeberHomePathToString);

String retString = file.getPath();
if (retString.startsWith(SLOEBER_HOME_VAR)) {
retString=retString.replace(SLOEBER_HOME_VAR, EMPTY_STRING);
return sloeberHomePath.append(retString).toFile();
//.replace(SLOEBER_HOME_VAR, sloeberHomePathToString);
}
return new File(retString);
}

Expand Down

0 comments on commit 483f9d6

Please sign in to comment.