Skip to content

Commit 46bb08c

Browse files
committed
fixed issue #95 Plugin ignores custom boards.txt
1 parent 7cc09a6 commit 46bb08c

File tree

6 files changed

+68
-6
lines changed

6 files changed

+68
-6
lines changed

it.baeyens.arduino.common/src/it/baeyens/arduino/common/ArduinoConst.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package it.baeyens.arduino.common;
22

3+
34
/**
45
* ArduinoConst only contains global strings used in the eclipse plugin.
56
*
@@ -31,6 +32,7 @@ public class ArduinoConst {
3132
public static final String KEY_RXTXDISABLED = "Arduino DisAbleRXTX";
3233
public static final String KEY_ARDUINOPATH = "Arduino Path";
3334
public static final String KEY_PRIVATE_LIBRARY_PATH = "Private Library Path";
35+
public static final String KEY_PRIVATE_HARDWARE_PATH = "Private hardware Path";
3436

3537
// properties keys
3638
public static final String KEY_LAST_USED_ARDUINOBOARD = "Arduino Board";
@@ -80,6 +82,7 @@ public class ArduinoConst {
8082
public static final String ENV_KEY_SOFTWARE = ENV_KEY_ARDUINO_START + "SOFTWARE";
8183
public static final String ENV_KEY_ARCHITECTURE = ENV_KEY_ARDUINO_START + "ARCHITECTURE";
8284
public static final String ENV_KEY_BUILD_ARCH = ENV_KEY_ARDUINO_START + "BUILD.ARCH";
85+
public static final String ENV_KEY_HARDWARE_PATH = ENV_KEY_ARDUINO_START + "RUNTIME.HARDWARE.PATH";
8386

8487
public static final String ENV_KEY_runtime_ide_version = ENV_KEY_ARDUINO_START + "RUNTIME.IDE.VERSION";
8588
public static final String ENV_KEY_build_path = ENV_KEY_ARDUINO_START + "BUILD.PATH";

it.baeyens.arduino.common/src/it/baeyens/arduino/common/ArduinoInstancePreferences.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,4 +251,20 @@ public static void setLastTemplateFolderName(String folderName) {
251251
setGlobalValue(ENV_KEY_SKETCH_TEMPLATE_FOLDER, folderName);
252252

253253
}
254+
255+
public static String getPrivateLibraryPath() {
256+
return getGlobalValue(KEY_PRIVATE_LIBRARY_PATH);
257+
}
258+
259+
public static void setPrivateLibraryPath(String folderName) {
260+
setGlobalValue(KEY_PRIVATE_LIBRARY_PATH, folderName);
261+
}
262+
263+
public static String getPrivateHardwarePath() {
264+
return getGlobalValue(KEY_PRIVATE_HARDWARE_PATH);
265+
}
266+
267+
public static void setPrivateHardwarePath(String folderName) {
268+
setGlobalValue(KEY_PRIVATE_HARDWARE_PATH, folderName);
269+
}
254270
}

it.baeyens.arduino.common/src/it/baeyens/arduino/common/Common.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
import org.eclipse.core.resources.ResourcesPlugin;
1919
import org.eclipse.core.runtime.CoreException;
2020
import org.eclipse.core.runtime.IAdaptable;
21+
import org.eclipse.core.runtime.IPath;
2122
import org.eclipse.core.runtime.IStatus;
23+
import org.eclipse.core.runtime.Path;
2224
import org.eclipse.core.runtime.Platform;
2325
import org.eclipse.core.runtime.QualifiedName;
2426
import org.eclipse.core.runtime.Status;
@@ -689,4 +691,25 @@ static public String getArduinoIdeSuffix() {
689691
return ArduinoIdeSuffix_WIN;
690692
}
691693

694+
/**
695+
* Arduino has the default libraries in the user home directory in subfolder Arduino/libraries. As the home directory is platform dependent
696+
* getting the value is resolved by this method
697+
*
698+
* @return the folder where Arduino puts the libraries by default.
699+
*/
700+
public static String getDefaultPrivateLibraryPath() {
701+
IPath homPath = new Path(System.getProperty("user.home"));
702+
return homPath.append("Arduino").append("libraries").toString();
703+
}
704+
705+
/**
706+
* same as getDefaultLibPath but for the hardware folder
707+
*
708+
* @return
709+
*/
710+
public static String getDefaultPrivateHardwarePath() {
711+
IPath homPath = new Path(System.getProperty("user.home"));
712+
return homPath.append("Arduino").append("hardware").toString();
713+
}
714+
692715
}

it.baeyens.arduino.core/src/it/baeyens/arduino/tools/ArduinoHelpers.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -486,11 +486,13 @@ private static void setTheEnvironmentVariablesSetTheDefaults(IContributedEnviron
486486
IEnvironmentVariable var = new EnvironmentVariable(ENV_KEY_ARDUINO_PATH, getArduinoPath().toString());
487487
contribEnv.addVariable(var, confDesc);
488488

489-
// from 1.5.3 onwards 2 more environment variables need to be added
489+
// from 1.5.3 onwards 3 more environment variables need to be added
490490
var = new EnvironmentVariable(ENV_KEY_ARCHITECTURE, platformFile.removeLastSegments(1).lastSegment());
491491
contribEnv.addVariable(var, confDesc);
492492
var = new EnvironmentVariable(ENV_KEY_BUILD_ARCH, platformFile.removeLastSegments(1).lastSegment().toUpperCase());
493493
contribEnv.addVariable(var, confDesc);
494+
var = new EnvironmentVariable(ENV_KEY_HARDWARE_PATH, platformFile.removeLastSegments(3).toString());
495+
contribEnv.addVariable(var, confDesc);
494496

495497
// I'm not sure why but till now arduino refused to put this in the platform.txt file
496498
// I won't call them idiots for this but it is getting close
@@ -972,14 +974,15 @@ public static String[] getPlatformFiles() {
972974
public static String[] getBoardsFiles() {
973975
File HardwareFolder = ArduinoInstancePreferences.getArduinoPath().append(ArduinoConst.ARDUINO_HARDWARE_FOLDER_NAME).toFile();
974976

975-
HashSet<String> Hardwarelists = new HashSet<String>();
976-
searchFiles(HardwareFolder, Hardwarelists, ArduinoConst.BOARDS_FILE_NAME, 3);
977-
if (Hardwarelists.size() == 0) {
977+
HashSet<String> boardFiles = new HashSet<String>();
978+
searchFiles(HardwareFolder, boardFiles, ArduinoConst.BOARDS_FILE_NAME, 3);
979+
if (boardFiles.size() == 0) {
978980
Common.log(new Status(IStatus.ERROR, ArduinoConst.CORE_PLUGIN_ID, "No boards.txt files found in the arduino hardware folder", null));
979981
return null;
980982
}
983+
searchFiles(new File(getPrivateHardwarePath()), boardFiles, ArduinoConst.BOARDS_FILE_NAME, 3);
981984

982-
return Hardwarelists.toArray(new String[Hardwarelists.size()]);
985+
return boardFiles.toArray(new String[boardFiles.size()]);
983986

984987
}
985988

it.baeyens.arduino.core/src/it/baeyens/arduino/ui/ArduinoPreferencePage.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public class ArduinoPreferencePage extends FieldEditorPreferencePage implements
4848
private StringFieldEditor mArduinoIdeVersion;
4949
private MyDirectoryFieldEditor mArduinoIdePath;
5050
private DirectoryFieldEditor mArduinoPrivateLibPath;
51+
private DirectoryFieldEditor mArduinoPrivateHardwarePath;
5152
private boolean mIsDirty = false;
5253
private IPath mPrefBoardFile = null;
5354

@@ -175,9 +176,25 @@ protected void createFieldEditors() {
175176
mArduinoIdePath = new MyDirectoryFieldEditor(ArduinoConst.KEY_ARDUINOPATH, "Arduino IDE path", parent, Common.getArduinoIdeSuffix());
176177

177178
addField(mArduinoIdePath.getfield());
179+
180+
String LibPath = ArduinoInstancePreferences.getPrivateLibraryPath();
181+
if (LibPath.isEmpty()) {
182+
String libraryPath = Common.getDefaultPrivateLibraryPath();
183+
new File(libraryPath).mkdirs();
184+
ArduinoInstancePreferences.setPrivateLibraryPath(libraryPath);
185+
}
178186
mArduinoPrivateLibPath = new DirectoryFieldEditor(ArduinoConst.KEY_PRIVATE_LIBRARY_PATH, "Private Library path", parent);
179187
addField(mArduinoPrivateLibPath);
180188

189+
LibPath = ArduinoInstancePreferences.getPrivateHardwarePath();
190+
if (LibPath.isEmpty()) {
191+
String hardwarePath = Common.getDefaultPrivateHardwarePath();
192+
new File(hardwarePath).mkdirs();
193+
ArduinoInstancePreferences.setPrivateHardwarePath(hardwarePath);
194+
}
195+
mArduinoPrivateHardwarePath = new DirectoryFieldEditor(ArduinoConst.KEY_PRIVATE_HARDWARE_PATH, "Private hardware path", parent);
196+
addField(mArduinoPrivateHardwarePath);
197+
181198
Dialog.applyDialogFont(parent);
182199

183200
addField(new BooleanFieldEditor(ArduinoConst.KEY_RXTXDISABLED, "Disable RXTX (disables Arduino reset during upload and the serial monitor)",

it.baeyens.arduino.core/src/it/baeyens/arduino/ui/Import_Arduino_Libraries_Page.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ protected void createSourceGroup(Composite parent) {
111111
if ((HardwareLibraryPath.toFile().exists()) && (HardwareLibraryPath.toFile().list().length > 0)) {
112112
// Create Arduino Item
113113
myArduinoHardwareLibItem = new TreeItem(myLibrarySelector, SWT.NONE);
114-
myArduinoHardwareLibItem.setText("Arduino Hardware Libraries");
114+
myArduinoHardwareLibItem.setText("Hardware provided Libraries");
115115
// Add the Arduino Libs
116116
AddLibs(myArduinoHardwareLibItem, HardwareLibraryPath);
117117
}

0 commit comments

Comments
 (0)