Skip to content

Commit 100dd21

Browse files
cmaglieFederico Fissore
authored and
Federico Fissore
committed
Added Contributed Platforms.
- TargetPackage / TargetPlatform / TargetBoard are now interfaces - Contributions installed are detected during init time - Tools must be referenced through "path" property (automatically set by the IDE to the contributed tool path)
1 parent 183c386 commit 100dd21

21 files changed

+1480
-290
lines changed

app/src/processing/app/Base.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ static public void main(String args[]) throws Exception {
9191

9292
splashScreenHelper.splashText(_("Loading configuration..."));
9393

94+
try {
95+
guardedMain(args);
96+
} catch (Throwable e) {
97+
e.printStackTrace(System.err);
98+
System.exit(255);
99+
}
100+
}
101+
102+
static public void guardedMain(String args[]) throws Exception {
94103
BaseNoGui.initLogger();
95104

96105
BaseNoGui.notifier = new GUIUserNotifier();

app/test/processing/app/debug/UploaderFactoryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class UploaderFactoryTest extends AbstractWithPreferencesTest {
1919

2020
@Before
2121
public void setUp() throws Exception {
22-
targetPackage = new TargetPackage("arduino", new File(".", "hardware/arduino/"));
22+
targetPackage = new LegacyTargetPackage("arduino", new File(".", "hardware/arduino/"));
2323
}
2424

2525
@Test
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* This file is part of Arduino.
3+
*
4+
* Copyright 2014 Arduino LLC (http://www.arduino.cc/)
5+
*
6+
* Arduino is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 2 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program; if not, write to the Free Software
18+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19+
*
20+
* As a special exception, you may use this file as part of a free software
21+
* library without restriction. Specifically, if other files instantiate
22+
* templates or use macros or inline functions from this file, or you compile
23+
* this file and link it with other files to produce an executable, this
24+
* file does not by itself cause the resulting executable to be covered by
25+
* the GNU General Public License. This exception does not however
26+
* invalidate any other reasons why the executable file might be covered by
27+
* the GNU General Public License.
28+
*/
29+
package cc.arduino.packages.contributions;
30+
31+
public interface ContributedBoard {
32+
33+
public String getName();
34+
35+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
* This file is part of Arduino.
3+
*
4+
* Copyright 2014 Arduino LLC (http://www.arduino.cc/)
5+
*
6+
* Arduino is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 2 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program; if not, write to the Free Software
18+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19+
*
20+
* As a special exception, you may use this file as part of a free software
21+
* library without restriction. Specifically, if other files instantiate
22+
* templates or use macros or inline functions from this file, or you compile
23+
* this file and link it with other files to produce an executable, this
24+
* file does not by itself cause the resulting executable to be covered by
25+
* the GNU General Public License. This exception does not however
26+
* invalidate any other reasons why the executable file might be covered by
27+
* the GNU General Public License.
28+
*/
29+
package cc.arduino.packages.contributions;
30+
31+
import java.util.List;
32+
33+
public abstract class ContributedPackage {
34+
35+
public abstract String getName();
36+
37+
public abstract String getMaintainer();
38+
39+
public abstract String getWebsiteURL();
40+
41+
public abstract String getEmail();
42+
43+
public abstract List<ContributedPlatform> getPlatforms();
44+
45+
public abstract List<ContributedTool> getTools();
46+
47+
public ContributedPlatform findPlatform(String architecture, String version) {
48+
for (ContributedPlatform platform : getPlatforms()) {
49+
if (platform.getArchitecture().equals(architecture) &&
50+
platform.getVersion().equals(version))
51+
return platform;
52+
}
53+
return null;
54+
}
55+
56+
public ContributedTool findTool(String name, String version) {
57+
for (ContributedTool tool : getTools()) {
58+
if (tool.getName().equals(name) && tool.getVersion().equals(version))
59+
return tool;
60+
}
61+
return null;
62+
}
63+
64+
@Override
65+
public String toString() {
66+
String res;
67+
res = "Package name : " + getName() + "\n";
68+
res += " maintaner : " + getMaintainer() + " (" + getEmail() + ")\n";
69+
if (getPlatforms() != null) {
70+
for (ContributedPlatform plat : getPlatforms()) {
71+
res += "\n Plaform : name : " + plat.getName();
72+
if (plat.isInstalled()) {
73+
res += "\n " + ((DownloadableContribution) plat);
74+
}
75+
res += "\n category : " + plat.getCategory();
76+
res += "\n architecture : " +
77+
plat.getArchitecture() + " " + plat.getVersion() + "\n";
78+
if (plat.getToolsDependencies() != null)
79+
for (ContributedToolReference t : plat.getToolsDependencies()) {
80+
res += " tool dep : " + t.getName() + " " +
81+
t.getVersion() + "\n";
82+
}
83+
if (plat.getBoards() != null)
84+
for (ContributedBoard board : plat.getBoards())
85+
res += " board : " + board.getName() +
86+
"\n";
87+
}
88+
}
89+
if (getTools() != null) {
90+
for (ContributedTool tool : getTools())
91+
res += tool + "\n";
92+
}
93+
return res;
94+
}
95+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* This file is part of Arduino.
3+
*
4+
* Copyright 2014 Arduino LLC (http://www.arduino.cc/)
5+
*
6+
* Arduino is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 2 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program; if not, write to the Free Software
18+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19+
*
20+
* As a special exception, you may use this file as part of a free software
21+
* library without restriction. Specifically, if other files instantiate
22+
* templates or use macros or inline functions from this file, or you compile
23+
* this file and link it with other files to produce an executable, this
24+
* file does not by itself cause the resulting executable to be covered by
25+
* the GNU General Public License. This exception does not however
26+
* invalidate any other reasons why the executable file might be covered by
27+
* the GNU General Public License.
28+
*/
29+
package cc.arduino.packages.contributions;
30+
31+
import java.util.ArrayList;
32+
import java.util.Collection;
33+
import java.util.List;
34+
35+
public abstract class ContributedPlatform extends DownloadableContribution {
36+
37+
public abstract String getName();
38+
39+
public abstract String getVersion();
40+
41+
public abstract String getCategory();
42+
43+
public abstract String getArchitecture();
44+
45+
public abstract String getChecksum();
46+
47+
public abstract List<ContributedToolReference> getToolsDependencies();
48+
49+
public abstract List<ContributedBoard> getBoards();
50+
51+
private List<ContributedTool> resolvedTools = null;
52+
53+
private ContributedPackage parentPackage;
54+
55+
public List<ContributedTool> getResolvedTools() {
56+
return resolvedTools;
57+
}
58+
59+
public List<ContributedTool> resolveToolsDependencies(Collection<ContributedPackage> packages) {
60+
resolvedTools = new ArrayList<ContributedTool>();
61+
62+
// If there are no dependencies return empty list
63+
if (getToolsDependencies() == null)
64+
return resolvedTools;
65+
66+
// For each tool dependency
67+
for (ContributedToolReference dep : getToolsDependencies()) {
68+
// Search the referenced tool
69+
ContributedTool tool = dep.resolve(packages);
70+
if (tool == null) {
71+
System.err
72+
.println("Index error: could not find referenced tool " + dep);
73+
}
74+
resolvedTools.add(tool);
75+
}
76+
return resolvedTools;
77+
}
78+
79+
public ContributedPackage getParentPackage() {
80+
return parentPackage;
81+
}
82+
83+
public void setParentPackage(ContributedPackage parentPackage) {
84+
this.parentPackage = parentPackage;
85+
}
86+
87+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* This file is part of Arduino.
3+
*
4+
* Copyright 2014 Arduino LLC (http://www.arduino.cc/)
5+
*
6+
* Arduino is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 2 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program; if not, write to the Free Software
18+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19+
*
20+
* As a special exception, you may use this file as part of a free software
21+
* library without restriction. Specifically, if other files instantiate
22+
* templates or use macros or inline functions from this file, or you compile
23+
* this file and link it with other files to produce an executable, this
24+
* file does not by itself cause the resulting executable to be covered by
25+
* the GNU General Public License. This exception does not however
26+
* invalidate any other reasons why the executable file might be covered by
27+
* the GNU General Public License.
28+
*/
29+
package cc.arduino.packages.contributions;
30+
31+
import java.util.Collection;
32+
import java.util.HashMap;
33+
import java.util.Map;
34+
35+
import processing.app.debug.TargetPackage;
36+
import processing.app.debug.TargetPlatform;
37+
38+
public class ContributedTargetPackage implements TargetPackage {
39+
40+
private String id;
41+
private Map<String, TargetPlatform> platforms;
42+
43+
public ContributedTargetPackage(String _id) {
44+
id = _id;
45+
platforms = new HashMap<String, TargetPlatform>();
46+
}
47+
48+
void addPlatform(TargetPlatform p) {
49+
platforms.put(p.getId(), p);
50+
}
51+
52+
boolean hasPlatforms() {
53+
return platforms.size() > 0;
54+
}
55+
56+
@Override
57+
public String getId() {
58+
return id;
59+
}
60+
61+
@Override
62+
public Map<String, TargetPlatform> getPlatforms() {
63+
return platforms;
64+
}
65+
66+
@Override
67+
public Collection<TargetPlatform> platforms() {
68+
return platforms.values();
69+
}
70+
71+
@Override
72+
public TargetPlatform get(String platform) {
73+
return platforms.get(platform);
74+
}
75+
76+
@Override
77+
public String toString() {
78+
return "TargetPackage: " + getId();
79+
}
80+
}

0 commit comments

Comments
 (0)