Skip to content

Support for uploadtool in menu #770

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion io.sloeber.application/introContent.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<introContent>
<!-- Root page -->
<page id="root" style="html/style.css" style-id="page" >
<html text="hhh" id="my web site" src="http://eclipse.baeyens.it/product/V4_0.php" type="inline" />
<html text="hhh" id="my web site" src="https://eclipse.baeyens.it/product/V4_0.php" type="inline" />
</page>

</introContent>
2 changes: 1 addition & 1 deletion io.sloeber.application/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
</property>
<property
name="aboutText"
value="Sloeber, the Eclipse IDE for Arduino Developers&#x0A;&#x0A;Info: http://eclipse.baeyens.it/&#x0A;Source: https://github.com/jantje/arduino-eclipse-plugin&#x0A;Binaries: http://eclipse.baeyens.it/download.php&#x0A;&#x0A;Contributors (github users): jantje, brodykenrick, wimjongman, neuweiler, &#x0A;darcade, amorellgarcia, MarceloLimori&#x0A;&#x0A;https://github.com/jantje/arduino-eclipse-plugin/graphs/contributors">
value="Sloeber, the Eclipse IDE for Arduino Developers&#x0A;&#x0A;Info: https://eclipse.baeyens.it/&#x0A;Source: https://github.com/jantje/arduino-eclipse-plugin&#x0A;Binaries: https://eclipse.baeyens.it/download.php&#x0A;&#x0A;Contributors (github users): jantje, brodykenrick, wimjongman, neuweiler, &#x0A;darcade, amorellgarcia, MarceloLimori&#x0A;&#x0A;https://github.com/jantje/arduino-eclipse-plugin/graphs/contributors">
</property>
<property
name="aboutImage"
Expand Down
6 changes: 6 additions & 0 deletions io.sloeber.core/config/pre_processing_platform_default.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,9 @@ A.SERIAL.PORT.FILE={A.SERIAL.PORT}
#to turn warnings on/off
A.COMPILER.WARNING_FLAGS=-w
A.COMPILER.WARNING_FLAGS.ALL=-Wall -Wextra

#for stm

A.UPLOAD.ALTID=no_altID
A.UPLOAD.USBID=no_altID

8 changes: 4 additions & 4 deletions io.sloeber.core/src/io/sloeber/core/Activator.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ public class Activator extends AbstractUIPlugin {
private static final String UPLOAD_FLAG = "F" + "u" + "S" + "t" + "a" + "t" + "u" + "s";
private static final String BUILD_FLAG = "F" + "b" + "S" + "t" + "a" + "t" + "u" + "s";
private static final String LOCAL_FLAG = "l" + FLAG_START;
private static final String HELP_LOC = "http://www.baeyens.it/eclipse/remind.php";
private static final String HELP_LOC = "https://www.baeyens.it/eclipse/remind.php";

private static Activator instance;
protected char[] uri = { 'h', 't', 't', 'p', ':', '/', '/', 'b', 'a', 'e', 'y', 'e', 'n', 's', '.', 'i', 't', '/',
'e', 'c', 'l', 'i', 'p', 's', 'e', '/', 'd', 'o', 'w', 'n', 'l', 'o', 'a', 'd', '/', 'p', 'l', 'u', 'g',
'i', 'n', 'S', 't', 'a', 'r', 't', '.', 'h', 't', 'm', 'l', '?', 's', '=' };
protected char[] uri = { 'h', 't', 't', 'p', 's', ':', '/', '/', 'b', 'a', 'e', 'y', 'e', 'n', 's', '.', 'i', 't',
'/', 'e', 'c', 'l', 'i', 'p', 's', 'e', '/', 'd', 'o', 'w', 'n', 'l', 'o', 'a', 'd', '/', 'p', 'l', 'u',
'g', 'i', 'n', 'S', 't', 'a', 'r', 't', '.', 'h', 't', 'm', 'l', '?', 's', '=' };
private static final String PLUGIN_ID = "io.sloeber.core";
private static Boolean isPatron = null;

Expand Down
41 changes: 26 additions & 15 deletions io.sloeber.core/src/io/sloeber/core/api/BoardDescriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public String toString() {
* This is the basic info contained in the descriptor
*/
private String myUploadPort;
private String myUploadProtocol;
private String myProgrammer;
private String myBoardID;
private Map<String, String> myOptions;

Expand Down Expand Up @@ -144,7 +144,7 @@ public boolean equals(BoardDescriptor obj) {
if (!this.getUploadPort().equals(obj.getUploadPort())) {
return false;
}
if (!this.getUploadProtocol().equals(obj.getUploadProtocol())) {
if (!this.getProgrammer().equals(obj.getProgrammer())) {
return false;
}
if (!this.getBoardID().equals(obj.getBoardID())) {
Expand Down Expand Up @@ -291,13 +291,12 @@ protected BoardDescriptor(ICConfigurationDescription confdesc) {
this.myTxtFile = new TxtFile(this.myreferencingBoardsFile);
this.myBoardID = myStorageNode.get(KEY_LAST_USED_BOARD, "");
this.myUploadPort = myStorageNode.get(KEY_LAST_USED_UPLOAD_PORT, "");
this.myUploadProtocol = myStorageNode.get(KEY_LAST_USED_UPLOAD_PROTOCOL,
Defaults.getDefaultUploadProtocol());
this.myProgrammer = myStorageNode.get(KEY_LAST_USED_UPLOAD_PROTOCOL, Defaults.getDefaultUploadProtocol());
this.myOptions = KeyValue.makeMap(myStorageNode.get(KEY_LAST_USED_BOARD_MENU_OPTIONS, new String()));

} else {
this.myUploadPort = Common.getBuildEnvironmentVariable(confdesc, ENV_KEY_JANTJE_UPLOAD_PORT, "");
this.myUploadProtocol = Common.getBuildEnvironmentVariable(confdesc, JANTJE_ACTION_UPLOAD, "");
this.myProgrammer = Common.getBuildEnvironmentVariable(confdesc, JANTJE_ACTION_UPLOAD, "");
this.myreferencingBoardsFile = new File(
Common.getBuildEnvironmentVariable(confdesc, ENV_KEY_JANTJE_BOARDS_FILE, ""));
this.myBoardID = Common.getBuildEnvironmentVariable(confdesc, ENV_KEY_JANTJE_BOARD_ID, "");
Expand Down Expand Up @@ -357,7 +356,7 @@ public static List<BoardDescriptor> makeBoardDescriptors(File boardFile) {
*/
protected BoardDescriptor(File boardsFile, String boardID, Map<String, String> options) {
this.myUploadPort = new String();
this.myUploadProtocol = Defaults.getDefaultUploadProtocol();
this.myProgrammer = Defaults.getDefaultUploadProtocol();
this.myBoardID = boardID;
this.myOptions = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
this.myreferencingBoardsFile = boardsFile;
Expand All @@ -373,7 +372,7 @@ protected BoardDescriptor(File boardsFile, String boardID, Map<String, String> o

protected BoardDescriptor(TxtFile txtFile, String boardID) {
this.myUploadPort = new String();
this.myUploadProtocol = Defaults.getDefaultUploadProtocol();
this.myProgrammer = Defaults.getDefaultUploadProtocol();
this.myBoardID = boardID;
this.myOptions = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
this.myreferencingBoardsFile = txtFile.getTxtFile();
Expand Down Expand Up @@ -545,7 +544,7 @@ public void saveConfiguration(ICConfigurationDescription confDesc, IContributedE
this.myWorkSpaceLocation);
Common.setBuildEnvironmentVariable(contribEnv, confDesc, ENV_KEY_JANTJE_ECLIPSE_LOCATION,
this.myWorkEclipseLocation);
Common.setBuildEnvironmentVariable(confDesc, JANTJE_ACTION_UPLOAD, this.myUploadProtocol);
Common.setBuildEnvironmentVariable(confDesc, JANTJE_ACTION_UPLOAD, this.myProgrammer);
if (this.myOptions != null) {
for (Map.Entry<String, String> curoption : this.myOptions.entrySet()) {
Common.setBuildEnvironmentVariable(contribEnv, confDesc, MENUSELECTION + curoption.getKey(),
Expand All @@ -558,7 +557,7 @@ public void saveConfiguration(ICConfigurationDescription confDesc, IContributedE
myStorageNode.put(KEY_LAST_USED_BOARDS_FILE, getReferencingBoardsFile().toString());
myStorageNode.put(KEY_LAST_USED_BOARD, this.myBoardID);
myStorageNode.put(KEY_LAST_USED_UPLOAD_PORT, this.myUploadPort);
myStorageNode.put(KEY_LAST_USED_UPLOAD_PROTOCOL, this.myUploadProtocol);
myStorageNode.put(KEY_LAST_USED_UPLOAD_PROTOCOL, this.myProgrammer);
myStorageNode.put(KEY_LAST_USED_BOARD_MENU_OPTIONS, KeyValue.makeString(this.myOptions));
}

Expand All @@ -582,16 +581,16 @@ public String getUploadPort() {
return this.myUploadPort;
}

public String getUploadProtocol() {
return this.myUploadProtocol;
public String getProgrammer() {
return this.myProgrammer;
}

public void setUploadPort(String newUploadPort) {
this.myUploadPort = newUploadPort;
}

public void setUploadProtocol(String newUploadProtocol) {
this.myUploadProtocol = newUploadProtocol;
this.myProgrammer = newUploadProtocol;

}

Expand Down Expand Up @@ -825,17 +824,29 @@ public IPath getReferencingLibraryPath() {
}

public String getUploadCommand(ICConfigurationDescription confdesc) {
String upLoadProtocol = getActualUploadProtocol();
String upLoadProtocol = getActualUploadTool(confdesc);
return Common.getBuildEnvironmentVariable(confdesc, "A.TOOLS." + upLoadProtocol + ".UPLOAD.PATTERN",
upLoadProtocol);
}

public String getActualUploadProtocol() {
public String getActualUploadTool(ICConfigurationDescription confdesc) {
if (this.myUploadTool == null && confdesc != null) {
return Common.getBuildEnvironmentVariable(confdesc, "A.UPLOAD.TOOL", this.myUploadTool);
}
return this.myUploadTool;
}

public String getActualUploadTool() {
return getActualUploadTool(null);
}

public boolean usesProgrammer() {
return !this.myUploadProtocol.equals(Defaults.getDefaultUploadProtocol());
return !this.myProgrammer.equals(Defaults.getDefaultUploadProtocol());
}

// public String getActualUploadProtocol() {
// // TODO Auto-generated method stub
// return null;
// }

}
2 changes: 1 addition & 1 deletion io.sloeber.core/src/io/sloeber/core/api/Defaults.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@SuppressWarnings("nls")
public class Defaults {
public static final String EXAMPLE_PACKAGE = "examples_Arduino_1_6_7.zip";
public static final String EXAMPLES_URL = "http://eclipse.baeyens.it/download/" + EXAMPLE_PACKAGE;
public static final String EXAMPLES_URL = "https://eclipse.baeyens.it/download/" + EXAMPLE_PACKAGE;
public static final String PLATFORM_NAME = "Arduino AVR Boards";
public static final String[] INSTALLED_LIBRARIES = new String[] { "Ethernet", "Firmata", "GSM", "Keyboard",
"LiquidCrystal", "Mouse", "SD", "Servo", "Stepper", "TFT", "WiFi", "CapacitiveSensor" };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ public static String makeArduinoUploadready(MessageConsoleStream console, IProje
.equalsIgnoreCase(Const.TRUE);
String comPort = boardDescriptor.getUploadPort();
String boardName = boardDescriptor.getBoardName();
String uploadProtocol = boardDescriptor.getActualUploadProtocol();

boolean bResetPortForUpload = Common
.getBuildEnvironmentVariable(project, configName, Const.ENV_KEY_RESET_BEFORE_UPLOAD, Const.TRUE)
Expand All @@ -184,7 +183,7 @@ public static String makeArduinoUploadready(MessageConsoleStream console, IProje
* boards.txt use Const.ENV_KEY_RESET_BEFORE_UPLOAD=FALSE to disable a
* reset
*/
if (!bResetPortForUpload || uploadProtocol.equalsIgnoreCase("halfkay")) { //$NON-NLS-1$
if (!bResetPortForUpload || "teensyloader".equalsIgnoreCase(boardDescriptor.getActualUploadTool())) { //$NON-NLS-1$
return comPort;
}
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void run() {
0);

if (dialog.open() == 0) {
org.eclipse.swt.program.Program.launch("http://baeyens.it/eclipse/toolchainFix.php"); //$NON-NLS-1$
org.eclipse.swt.program.Program.launch("https://baeyens.it/eclipse/toolchainFix.php"); //$NON-NLS-1$
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions io.sloeber.core/src/io/sloeber/core/managers/Manager.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ static public IStatus downloadAndInstall(ArduinoPlatform platform, boolean force
Path localMakePath = Paths.get(ConfigurationPreferences.getMakePath().toString());
if (!ConfigurationPreferences.getMakePath().append("make.exe").toFile().exists()) { //$NON-NLS-1$
mstatus.addErrors(
downloadAndInstall("http://eclipse.baeyens.it/download/make.zip", "make.zip", localMakePath, //$NON-NLS-1$ //$NON-NLS-2$
downloadAndInstall("https://eclipse.baeyens.it/download/make.zip", "make.zip", localMakePath, //$NON-NLS-1$ //$NON-NLS-2$
forceDownload, monitor));
}
}
Expand Down Expand Up @@ -205,7 +205,7 @@ public static File getLocalFileName(String url) {
* @return the file that represents the file on Baeyens.it
*/
private static String getBaeyensItAlternativeDownload(String localFileName) {
return "http://eclipse.baeyens.it/download/" + localFileName; //$NON-NLS-1$
return "https://eclipse.baeyens.it/download/" + localFileName; //$NON-NLS-1$
}

/**
Expand Down
4 changes: 2 additions & 2 deletions io.sloeber.core/src/io/sloeber/core/tools/Helpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ public static void setTheEnvironmentVariables(IProject project, ICConfigurationD
// add the boards file
setTheEnvironmentVariablesAddtheBoardsTxt(contribEnv, confDesc, boardsDescriptor, true);

String programmer = boardsDescriptor.getUploadProtocol();
String programmer = boardsDescriptor.getProgrammer();
for (Programmers curProgrammer : localProgrammers) {
String programmerID = curProgrammer.getBoardIDFromBoardName(programmer);
if (programmerID != null) {
Expand Down Expand Up @@ -853,7 +853,7 @@ private static void setTheEnvironmentVariablesPostProcessing(IContributedEnviron
}
}

String programmer = boardsDescriptor.getUploadProtocol();
String programmer = boardsDescriptor.getProgrammer();
if (programmer.equalsIgnoreCase(Defaults.getDefaultUploadProtocol())) {
String MComPort = boardsDescriptor.getUploadPort();
if (MComPort.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void internalUpload(IProject project, String configName) {
ICConfigurationDescription confDesc = prjDesc.getConfigurationByName(configName);

BoardDescriptor boardDescriptor = BoardDescriptor.makeBoardDescriptor(confDesc);
String UpLoadTool = boardDescriptor.getActualUploadProtocol();
String UpLoadTool = boardDescriptor.getActualUploadTool(confDesc);
String MComPort = boardDescriptor.getUploadPort();
String uploadClass = Common.getBuildEnvironmentVariable(confDesc, Common.get_ENV_KEY_TOOL(Const.UPLOAD_CLASS),
new String());
Expand Down
138 changes: 138 additions & 0 deletions io.sloeber.core/src/jUnit/CompileAndUpload.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
package jUnit;

import static org.junit.Assert.fail;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

import io.sloeber.core.api.BoardsManager;
import io.sloeber.core.api.CodeDescriptor;
import io.sloeber.core.api.CompileOptions;
import io.sloeber.core.api.ConfigurationDescriptor;
import io.sloeber.core.api.Sketch;
import jUnit.boards.Due;
import jUnit.boards.IBoard;
import jUnit.boards.NodeMCUBoard;
import jUnit.boards.UnoBoard;
import jUnit.boards.Zero;
import jUnit.boards.megaBoard;

@SuppressWarnings("nls")
@RunWith(Parameterized.class)
public class CompileAndUpload {
private static final boolean reinstall_boards_and_libraries = false;
private static int mCounter = 0;
private IBoard myBoard;
private String myName;

public CompileAndUpload(String name, IBoard board) {
this.myBoard = board;
this.myName = name;

}

@SuppressWarnings("rawtypes")
@Parameters(name = "{index}: {0}")
public static Collection examples() {
WaitForInstallerToFinish();

IBoard unoBoard = new UnoBoard();
IBoard nodeMCUBoard = new NodeMCUBoard();
IBoard megaBoard = new megaBoard();
IBoard zeroBoard = new Zero();
IBoard dueBoard = new Due();
LinkedList<Object[]> examples = new LinkedList<>();

examples.add(new Object[] { "uno", unoBoard });
examples.add(new Object[] { "mega", megaBoard });
examples.add(new Object[] { "zero", zeroBoard });
examples.add(new Object[] { "due", dueBoard });

return examples;
// new leonardoBoard(), new EsploraBoard(), new AdafruitnRF52idBoard(),
// new AdafruitnCirquitPlaygroundBoard(), new Primo(),
}

/*
* In new new installations (of the Sloeber development environment) the
* installer job will trigger downloads These mmust have finished before we
* can start testing
*/

public static void WaitForInstallerToFinish() {

installAdditionalBoards();

Shared.waitForAllJobsToFinish();
}

public static void installAdditionalBoards() {
String[] packageUrlsToAdd = { "http://arduino.esp8266.com/stable/package_esp8266com_index.json",
"https://raw.githubusercontent.com/stm32duino/BoardManagerFiles/master/STM32/package_stm_index.json" };
BoardsManager.addPackageURLs(new HashSet<>(Arrays.asList(packageUrlsToAdd)), true);
if (reinstall_boards_and_libraries) {
BoardsManager.installAllLatestPlatforms();
}

}

@Test
public void testExamples() {
IPath templateFolder = Shared.getTemplateFolder("fastBlink");
Build_Verify_upload(CodeDescriptor.createCustomTemplate(templateFolder));

}

public void Build_Verify_upload(CodeDescriptor codeDescriptor) {

IProject theTestProject = null;

NullProgressMonitor monitor = new NullProgressMonitor();
String projectName = String.format("%05d_%s", new Integer(mCounter++), this.myName);
try {

theTestProject = this.myBoard.getBoardDescriptor().createProject(projectName, null,
ConfigurationDescriptor.getDefaultDescriptors(), codeDescriptor, new CompileOptions(null), monitor);
Shared.waitForAllJobsToFinish(); // for the indexer
} catch (Exception e) {
e.printStackTrace();
fail("Failed to create the project:" + projectName);
return;
}
try {
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
if (Shared.hasBuildErrors(theTestProject)) {
// try again because the libraries may not yet been added
Shared.waitForAllJobsToFinish(); // for the indexer
try {
Thread.sleep(3000);// seen sometimes the libs were still not
// added
} catch (InterruptedException e) {
// ignore
}
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
if (Shared.hasBuildErrors(theTestProject)) {
// give up
fail("Failed to compile the project:" + projectName + " build errors");
}
}

} catch (CoreException e) {
e.printStackTrace();
fail("Failed to compile the project:" + projectName + " exception");
}
Sketch.upload(theTestProject);
}
}
Loading