From ae8d22b0f24613d283f4ddc7163a48b3852429cc Mon Sep 17 00:00:00 2001 From: thomasclark Date: Tue, 1 Jul 2014 17:04:28 -0400 Subject: [PATCH] Fixed C++ deploy in Eclipse Eclipse now runs an ant script to deploy C++ programs, which runs the robot program with the run-at-startup system Change-Id: I3e63967ebc40ad3c38aa561fd303ca3c577fd2a2 --- .../resources/templates/build.properties | 9 +- .../cpp/launching/DeployLaunchShortcut.java | 53 +++++--- .../src/main/resources/cpp-zip/ant/build.xml | 115 +++--------------- .../main/resources/cpp-zip/ant/robotCommand | 1 + 4 files changed, 59 insertions(+), 119 deletions(-) create mode 100644 eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/robotCommand diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/build.properties b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/build.properties index ae7c0ab297..4e945fde05 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/build.properties +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/build.properties @@ -2,8 +2,9 @@ username=admin password= deploy.dir=/home/admin -deploy.run.command=./runcppprogram -deploy.debug.command=./debugcppprogram +deploy.kill.command=/usr/local/frc/bin/frcKillRobot.sh -t -r +deploy.log.file=/var/local/natinst/log/FRC_UserProgram.log +command.dir=/home/lvuser/ # Libraries to use wpilib=${user.home}/wpilib/cpp/${cpp-version} @@ -21,8 +22,8 @@ build.dir=build out.exe=Debug/${out} # Simulation -simulation.world.file=$world +simulation.world.file=/usr/share/frcsim/worlds/GearsBotDemo.world sim.exe=Simulate/${out} wpilib.sim=${wpilib}/sim sim.tools=${wpilib.sim}/tools -sim.lib=${wpilib.sim}/lib \ No newline at end of file +sim.lib=${wpilib.sim}/lib diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/launching/DeployLaunchShortcut.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/launching/DeployLaunchShortcut.java index c8eb74ba28..26236404df 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/launching/DeployLaunchShortcut.java +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/launching/DeployLaunchShortcut.java @@ -3,6 +3,7 @@ package edu.wpi.first.wpilib.plugins.cpp.launching; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.io.File; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.executables.Executable; @@ -28,12 +29,13 @@ import org.eclipse.ui.PlatformUI; import edu.wpi.first.wpilib.plugins.core.WPILibCore; import edu.wpi.first.wpilib.plugins.cpp.WPILibCPPPlugin; +import edu.wpi.first.wpilib.plugins.core.launching.AntLauncher; /** * Launch shortcut base functionality, common for deploying to the robot. * Retrieves the project the operation is being called on, and runs the correct * ant targets based on polymorphically determined data values - * + * * @author Ryan O'Meara * @author Alex Henning */ @@ -46,7 +48,7 @@ public class DeployLaunchShortcut implements ILaunchShortcut /** * Returns the launch type of the shortcut that was used, one of the * constants defined in BaseLaunchShortcut - * + * * @return Launch shortcut type */ public String getLaunchType() @@ -91,7 +93,7 @@ public class DeployLaunchShortcut implements ILaunchShortcut } /** - * + * * @param activeProj * The project that the script will be run on/from * @param mode @@ -99,23 +101,34 @@ public class DeployLaunchShortcut implements ILaunchShortcut * ILaunchManager.DEBUG_MODE) */ public void runConfig(IProject activeProj, String mode, Shell shell) { - // TODO: figure out UI issues. that's why this is undocumented - ILaunchConfigurationWorkingCopy config; - try { - config = getRemoteDebugConfig(activeProj); - //config.doSave(); // NOTE: For debugging - //org.eclipse.debug.core.DebugPlugin.getDefault().getLaunchManager().addLaunch(config.launch(mode, null)); - //THIS IS MADDENING! we want to add to the recent history, but I can't seem to find a public api to do so, so lets just launch the config dialog - //DebugUITools.openLaunchConfigurationPropertiesDialog(shell, config, "org.eclipse.cdt.launch.launchGroup"); - //config.launch(mode, new NullProgressMonitor(), false, true); - DebugUITools.launch(config, mode); - } catch (CoreException e) { - WPILibCPPPlugin.logError("Debug attach failed.", e); + if(mode.equals(ILaunchManager.RUN_MODE)) { + // Regular deploys are done with an ant script for now, for both + // C++ and Java. + WPILibCPPPlugin.logInfo("Running ant file: " + activeProj.getLocation().toOSString() + File.separator + "build.xml"); + WPILibCPPPlugin.logInfo("Targets: deploy, Mode: " + mode); + AntLauncher.runAntFile(new File (activeProj.getLocation().toOSString() + File.separator + "build.xml"), "deploy", null, mode); + } else { + // Debug deploys are done with the Eclipse Remote System Explorer, + // which lets it work with Eclipse's C++ debugger. + + // TODO: figure out UI issues. that's why this is undocumented + ILaunchConfigurationWorkingCopy config; + try { + config = getRemoteDebugConfig(activeProj); + //config.doSave(); // NOTE: For debugging + //org.eclipse.debug.core.DebugPlugin.getDefault().getLaunchManager().addLaunch(config.launch(mode, null)); + //THIS IS MADDENING! we want to add to the recent history, but I can't seem to find a public api to do so, so lets just launch the config dialog + //DebugUITools.openLaunchConfigurationPropertiesDialog(shell, config, "org.eclipse.cdt.launch.launchGroup"); + //config.launch(mode, new NullProgressMonitor(), false, true); + DebugUITools.launch(config, mode); + } catch (CoreException e) { + WPILibCPPPlugin.logError("Debug attach failed.", e); + } + + try { + activeProj.refreshLocal(Resource.DEPTH_INFINITE, null); + } catch (Exception e) {} } - - try { - activeProj.refreshLocal(Resource.DEPTH_INFINITE, null); - } catch (Exception e) {} } private ILaunchConfigurationWorkingCopy getRemoteDebugConfig(IProject activeProj) throws CoreException @@ -128,7 +141,7 @@ public class DeployLaunchShortcut implements ILaunchShortcut ILaunchConfigurationWorkingCopy config = type.newInstance(null, activeProj.getName()); config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, activeProj.getName()); Collection exes = ExecutablesManager.getExecutablesManager().getExecutablesForProject(activeProj); - config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, + config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, exes.size() > 0 ? exes.toArray(new Executable[0])[0].getPath().makeRelativeTo(activeProj.getLocation()).toString(): "Debug/FRCUserProgram"); config.setAttribute(IRemoteConnectionConfigurationConstants.ATTR_REMOTE_PATH, "/home/admin/FRCUserProgram"); diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/build.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/build.xml index ce352e51b8..270dea8fea 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/build.xml +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/build.xml @@ -2,10 +2,6 @@ - - - - @@ -31,99 +27,28 @@ + username="${username}" + password="${password}" + trust="true" + failonerror="no" + command="rm ${deploy.dir}/FRCUserProgram" /> + [athena-deploy] Copying code over. - - - - - - - Found version of WPILib: ${installedWpilibSo} (latest) - - - Found version of WPILib: ${installedWpilibSo} - Upgrading WPILib to ${cpp-sos}... - - - - - - - - - - - - - - - - - - 2.0 - Package: ${opkg.name} -Version: ${cpp-sos} -Section: devel -Priority: optional -Architecture: ${opkg.arch} -Depends: libc6 (>= 2.11.1-r7), libgcc1 (>= 4.4.1) -Maintainer: Brad Miller >bamiller@wpi.edu< -Description: WPILib, NetworkTables and HAL for RoboRIO target - . - This package contains the shared objects for WPILib, NetworkTables, and HAL for the 2015 target on the RoboRIO - - #!/bin/sh -ldconfig - - #!/bin/sh -ldconfig - - - - - ${md5.wpilib} usr/local/frc/lib/libWPILibAthena.so -${md5.nwt} usr/local/frc/lib/libNetworkTables.so -${md5.hal} usr/local/frc/lib/libHALAthena.so - - - - - - - - - - - - - - - - + + + [athena-deploy] Starting program. + username="${username}" + password="${password}" + trust="true" + command=". /etc/profile.d/natinst-path.sh; chmod a+x ${deploy.dir}/${out}; ${deploy.kill.command};"/> + + @@ -171,4 +96,4 @@ ${md5.hal} usr/local/frc/lib/libHALAthena.so - + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/robotCommand b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/robotCommand new file mode 100644 index 0000000000..d7713d7fe9 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/robotCommand @@ -0,0 +1 @@ +/home/admin/FRCUserProgram