Skip to content

Commit a7a8b93

Browse files
author
jantje
committed
#521 and fixing boards that didn't compile
Like the assembly of chipKIT
1 parent a15c94d commit a7a8b93

File tree

7 files changed

+379
-156
lines changed

7 files changed

+379
-156
lines changed

it.baeyens.arduino.core/plugin.xml

+13
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,19 @@
699699
id="it.baeyens.arduino.tool.sketch.compiler.s"
700700
name="%tool.Arduino.S20.name"
701701
natureFilter="both">
702+
<optionCategory
703+
id="it.baeyens.arduino.core.asm.optionCategory.includePaths"
704+
name="%optionCategory.include.name">
705+
</optionCategory>
706+
<option
707+
browseType="directory"
708+
category="it.baeyens.arduino.core.asm.optionCategory.includePaths"
709+
command="-I"
710+
id="it.baeyens.arduino.compiler.asm.sketch.option.incpath"
711+
name="%option.include.path.name"
712+
resourceFilter="project"
713+
valueType="includePath">
714+
</option>
702715
<inputType
703716
buildVariable="S_SKETCH_FILES"
704717
dependencyCalculator="it.baeyens.arduino.toolchain.ArduinoDependencyCalculator"

it.baeyens.arduino.core/src/io/sloeber/core/api/BoardID.java renamed to it.baeyens.arduino.core/src/io/sloeber/core/api/BoardDescriptor.java

+29-12
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import it.baeyens.arduino.tools.ShouldHaveBeenInCDT;
4141
import it.baeyens.arduino.tools.TxtFile;
4242

43-
public class BoardID {
43+
public class BoardDescriptor {
4444

4545
private String myUploadPort;
4646
private String myUploadProtocol;
@@ -60,7 +60,7 @@ public class BoardID {
6060
*
6161
*/
6262
@SuppressWarnings("nls")
63-
public BoardID(ICConfigurationDescription confdesc) {
63+
public BoardDescriptor(ICConfigurationDescription confdesc) {
6464
if (confdesc == null) {
6565
String boardsFile = InstancePreferences.getGlobalString(Const.KEY_LAST_USED_BOARDS_FILE, "");
6666
this.myBoardsFile = new TxtFile(new File(boardsFile));
@@ -80,6 +80,14 @@ public BoardID(ICConfigurationDescription confdesc) {
8080
}
8181
}
8282

83+
public BoardDescriptor(TxtFile boardsTxtFile, String boardID, Map<String, String> options) {
84+
this.myUploadPort = Const.EMPTY_STRING;
85+
this.myUploadProtocol = Const.DEFAULT;
86+
this.myBoardID = boardID;
87+
this.myOptions = options;
88+
this.myBoardsFile = boardsTxtFile;
89+
}
90+
8391
/*
8492
* Method to create a project based on the board
8593
*/
@@ -195,10 +203,11 @@ public void save(ICConfigurationDescription confdesc) {
195203
Common.setBuildEnvironmentVariable(confdesc, Const.get_Jantje_KEY_PROTOCOL(Const.ACTION_UPLOAD),
196204
this.myUploadProtocol);
197205
setMenuOptions(confdesc);
198-
199-
for (Map.Entry<String, String> curoption : this.myOptions.entrySet()) {
200-
Common.setBuildEnvironmentVariable(confdesc, Const.ENV_KEY_JANTJE_START + curoption.getKey(),
201-
curoption.getValue());
206+
if (this.myOptions != null) {
207+
for (Map.Entry<String, String> curoption : this.myOptions.entrySet()) {
208+
Common.setBuildEnvironmentVariable(confdesc, Const.ENV_KEY_JANTJE_START + curoption.getKey(),
209+
curoption.getValue());
210+
}
202211
}
203212
}
204213

@@ -278,9 +287,11 @@ public Map<String, String> getOptions() {
278287
private void setLastUsedMenuOption() {
279288
String store = ""; //$NON-NLS-1$
280289
String concat = ""; //$NON-NLS-1$
281-
for (Entry<String, String> curOption : this.myOptions.entrySet()) {
282-
store = store + concat + curOption.getKey() + '=' + curOption.getValue();
283-
concat = "\n"; //$NON-NLS-1$
290+
if (this.myOptions != null) {
291+
for (Entry<String, String> curOption : this.myOptions.entrySet()) {
292+
store = store + concat + curOption.getKey() + '=' + curOption.getValue();
293+
concat = "\n"; //$NON-NLS-1$
294+
}
284295
}
285296
InstancePreferences.setGlobalValue(Const.KEY_LAST_USED_BOARD_MENU_OPTIONS, store);
286297

@@ -301,9 +312,11 @@ private void getLastUsedMenuOption() {
301312
private void setMenuOptions(ICConfigurationDescription confdesc) {
302313
String store = ""; //$NON-NLS-1$
303314
String concat = ""; //$NON-NLS-1$
304-
for (Entry<String, String> curOption : this.myOptions.entrySet()) {
305-
store = store + concat + curOption.getKey() + '=' + curOption.getValue();
306-
concat = "\n"; //$NON-NLS-1$
315+
if (this.myOptions != null) {
316+
for (Entry<String, String> curOption : this.myOptions.entrySet()) {
317+
store = store + concat + curOption.getKey() + '=' + curOption.getValue();
318+
concat = "\n"; //$NON-NLS-1$
319+
}
307320
}
308321
try {
309322
confdesc.getProjectDescription().getProject().setPersistentProperty(this.optionsStorageQualifiedName,
@@ -335,4 +348,8 @@ private void getMenuOptions(ICConfigurationDescription confdesc) {
335348
}
336349

337350
}
351+
352+
public String getBoardID() {
353+
return this.myBoardID;
354+
}
338355
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
package io.sloeber.core.api;
2+
3+
import java.io.File;
4+
import java.util.Collection;
5+
import java.util.List;
6+
import java.util.Map;
7+
8+
import org.eclipse.core.runtime.CoreException;
9+
import org.eclipse.core.runtime.NullProgressMonitor;
10+
11+
import it.baeyens.arduino.common.InstancePreferences;
12+
import it.baeyens.arduino.managers.ArduinoPlatform;
13+
import it.baeyens.arduino.managers.Board;
14+
import it.baeyens.arduino.managers.Manager;
15+
import it.baeyens.arduino.managers.Package;
16+
import it.baeyens.arduino.tools.TxtFile;
17+
18+
/**
19+
* This class groups both boards installed by the hardware manager and boards
20+
* installed locally.
21+
*
22+
* @author jan
23+
*
24+
*/
25+
public class BoardsManager {
26+
/**
27+
* Gets the board id based on the information provided. If
28+
* jsonFileName="local" the board is assumend not to be installed by the
29+
* boards manager. Otherwise the boardsmanager is queried to find the board
30+
* ID. In this case the latest installed board will be returned
31+
*
32+
* @param jsonFileName
33+
* equals to "local" or the name of the json file used by the
34+
* boards manager to install the boards
35+
* @param packageName
36+
* if jsonFileName equals "local" the filename of the boards.txt
37+
* containing the boards. otherwise the name of the package
38+
* containing the board
39+
* @param platformName
40+
* ignored if jsonFileName equals "local" otherwise the name of
41+
* the platform containing the board
42+
* @param boardID
43+
* the id of the board in the boards.txt file
44+
* @param options
45+
* the options to specify the board (the menu named on the
46+
* boards.txt file)
47+
* @return The class BoardDescriptor or null
48+
*/
49+
static public BoardDescriptor getBoardID(String jsonFileName, String packageName, String platformName,
50+
String boardID, Map<String, String> options) {
51+
if (jsonFileName.equals("local")) { //$NON-NLS-1$
52+
return new BoardDescriptor(new TxtFile(new File(packageName)), boardID, options);
53+
}
54+
return getNewestBoardIDFromBoardsManager(jsonFileName, packageName, platformName, boardID, options);
55+
}
56+
57+
static private BoardDescriptor getNewestBoardIDFromBoardsManager(String jsonFileName, String packageName,
58+
String platformName, String boardID, Map<String, String> options) {
59+
60+
List<Board> boards = null;
61+
try {
62+
Package thePackage = Manager.getPackage(jsonFileName, packageName);
63+
if (thePackage == null) {
64+
// fail("failed to find package:" + this.mPackageName);
65+
return null;
66+
}
67+
ArduinoPlatform platform = thePackage.getLatestPlatform(platformName);
68+
if (platform == null) {
69+
// fail("failed to find platform " + this.mPlatform + " in
70+
// package:" + this.mPackageName);
71+
return null;
72+
}
73+
boards = platform.getBoards();
74+
} catch (CoreException e1) {
75+
e1.printStackTrace();
76+
}
77+
if (boards == null) {
78+
// fail("No boards found");
79+
return null;
80+
}
81+
for (Board curBoard : boards) {
82+
if (curBoard.getId().equals(boardID)) {
83+
java.io.File boardsFile = curBoard.getPlatform().getBoardsFile();
84+
TxtFile boardsTxtFile = new TxtFile(boardsFile);
85+
System.out.println("Testing board: " + curBoard.getName()); //$NON-NLS-1$
86+
BoardDescriptor boardid = new BoardDescriptor(boardsTxtFile, curBoard.getId(), options);
87+
88+
return boardid;
89+
}
90+
91+
}
92+
return null;
93+
}
94+
95+
public static void addPackageURLs(String[] packageUrlsToAdd) {
96+
Manager.addPackageURLs(packageUrlsToAdd);
97+
98+
}
99+
100+
public static void installAllLatestPlatforms() {
101+
NullProgressMonitor monitor = new NullProgressMonitor();
102+
List<Package> allPackages = Manager.getPackages();
103+
for (Package curPackage : allPackages) {
104+
Collection<ArduinoPlatform> latestPlatforms = curPackage.getLatestPlatforms();
105+
for (ArduinoPlatform curPlatform : latestPlatforms) {
106+
curPlatform.install(monitor);
107+
}
108+
}
109+
}
110+
111+
public static void referenceLocallInstallation(String newHardwarePath) {
112+
// TODO Auto-generated method stub
113+
114+
String currentPaths[] = InstancePreferences.getPrivateHardwarePaths();
115+
String newPaths[] = new String[currentPaths.length + 1];
116+
for (int i = 0; i < currentPaths.length; i++) {
117+
if (currentPaths[i].equals(newHardwarePath)) {
118+
return;
119+
}
120+
newPaths[i] = currentPaths[i];
121+
}
122+
newPaths[currentPaths.length] = newHardwarePath;
123+
InstancePreferences.setPrivateHardwarePaths(newPaths);
124+
}
125+
126+
}

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import org.eclipse.swt.widgets.Text;
3535

3636
import cc.arduino.packages.discoverers.NetworkDiscovery;
37-
import io.sloeber.core.api.BoardID;
37+
import io.sloeber.core.api.BoardDescriptor;
3838
import it.baeyens.arduino.common.Common;
3939
import it.baeyens.arduino.common.Const;
4040
import it.baeyens.arduino.tools.Helpers;
@@ -62,7 +62,7 @@ public class BoardSelectionPage extends AbstractCPropertyTab {
6262
protected LabelCombo[] mBoardOptionCombos = null;
6363
private final int ncol = 2;
6464
protected Listener mBoardSelectionChangedListener = null;
65-
private BoardID myBoardID = null;
65+
private BoardDescriptor myBoardID = null;
6666

6767
// the properties to modify
6868
private String[] mAllBoardsFileNames; // contains the boards.txt file names
@@ -340,7 +340,7 @@ protected void updateButtons() {
340340
private void setValues(ICConfigurationDescription confdesc) {
341341

342342
if (this.myBoardID == null) {
343-
this.myBoardID = new BoardID(confdesc);
343+
this.myBoardID = new BoardDescriptor(confdesc);
344344
}
345345

346346
String boardIdBoardFile = this.myBoardID.getBoardsFile();
@@ -497,7 +497,7 @@ private Map<String, String> getOptions() {
497497
return options;
498498
}
499499

500-
public BoardID getBoardID() {
500+
public BoardDescriptor getBoardID() {
501501
this.myBoardID.setBoardsFile(getSelectedBoardsFile());
502502
this.myBoardID.setBoardName(getBoardName());
503503
this.myBoardID.setOptions(getOptions());

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
2222
import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
2323

24-
import io.sloeber.core.api.BoardID;
24+
import io.sloeber.core.api.BoardDescriptor;
2525
import io.sloeber.core.api.CodeDescriptor;
2626
import it.baeyens.arduino.common.Common;
2727
import it.baeyens.arduino.common.Const;
@@ -132,7 +132,7 @@ protected void execute(IProgressMonitor monitor) throws CoreException {
132132

133133
protected void createProjectWrapper(IProgressMonitor monitor) {
134134

135-
BoardID boardID = this.mArduinoPage.getBoardID();
135+
BoardDescriptor boardID = this.mArduinoPage.getBoardID();
136136
CodeDescriptor codeDescription = this.mNewArduinoSketchWizardCodeSelectionPage.getCodeDescription();
137137
try {
138138
this.mProject = boardID.createProject(this.mWizardPage.getProjectName(),

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import org.eclipse.swt.widgets.Listener;
99
import org.eclipse.swt.widgets.Shell;
1010

11-
import io.sloeber.core.api.BoardID;
11+
import io.sloeber.core.api.BoardDescriptor;
1212

1313
/**
1414
* The ArduinoSettingsPage class is linked to page in the import wizard. It
@@ -53,7 +53,7 @@ public void createControl(Composite parent) {
5353
setPageComplete(this.mPageLayout.isPageComplete());
5454
}
5555

56-
public BoardID getBoardID() {
56+
public BoardDescriptor getBoardID() {
5757
return this.mPageLayout.getBoardID();
5858
}
5959

0 commit comments

Comments
 (0)