Merge "Fixed C++ deploy in Eclipse"

This commit is contained in:
Brad Miller (WPI)
2014-07-02 10:41:36 -07:00
committed by Gerrit Code Review
4 changed files with 59 additions and 119 deletions

View File

@@ -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
sim.lib=${wpilib.sim}/lib

View File

@@ -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<Executable> 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");

View File

@@ -2,10 +2,6 @@
<project name="athena-project-build" default="deploy">
<property file="${wpilib.ant.dir}/../so.properties"/>
<property name="opkg.name" value="wpilib" />
<property name="opkg.arch" value="armv7a-vfp" />
<!-- Load Tasks -->
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
@@ -31,99 +27,28 @@
<target name="deploy" depends="get-target-ip" description="Deploy the progam and start it running.">
<sshexec host="${target}"
username="${username}"
password="${password}"
trust="true"
command="rm ${deploy.dir}/FRCUserProgram" />
username="${username}"
password="${password}"
trust="true"
failonerror="no"
command="rm ${deploy.dir}/FRCUserProgram" />
<echo>[athena-deploy] Copying code over.</echo>
<scp file="${out.exe}" sftp="true" todir="${username}@${target}:${deploy.dir}"
password="${password}" trust="true"/>
<sshexec host="${target}"
username="${username}"
password="${password}"
trust="true"
command="opkg info wpilib |grep Version | awk '{printf $2}'"
outputproperty="installedWpilibSo"/>
<if>
<equals arg1="${installedWpilibSo}" arg2="${cpp-sos}" />
<then>
<echo>Found version of WPILib: ${installedWpilibSo} (latest)</echo>
</then>
<else>
<echo>Found version of WPILib: ${installedWpilibSo}</echo>
<echo>Upgrading WPILib to ${cpp-sos}...</echo>
<delete>
<fileset dir="${wpilib.ant.dir}">
<include name="data.tar*" />
<include name="control*" />
<include name="post*" />
<include name="md5sums" />
<include name="*.deb" />
</fileset>
</delete>
<tar destfile="${wpilib.ant.dir}/data.tar">
<tarfileset dir="${wpilib.ant.dir}/../lib" username="root" group="admin" uid="0" gid="0"
prefix="usr/local/frc/lib">
<include name="libWPILibAthena.so" />
<include name="libNetworkTables.so" />
<include name="libHALAthena.so" />
</tarfileset>
</tar>
<gzip destfile="${wpilib.ant.dir}/data.tar.gz" src="${wpilib.ant.dir}/data.tar"/>
<echo file="${wpilib.ant.dir}/debian-binary">2.0</echo>
<echo file="${wpilib.ant.dir}/control">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 &gt;bamiller@wpi.edu&lt;
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
</echo>
<echo file="${wpilib.ant.dir}/postinst">#!/bin/sh
ldconfig
</echo>
<echo file="${wpilib.ant.dir}/postrm">#!/bin/sh
ldconfig
</echo>
<checksum property="md5.wpilib" format="MD5SUM" file="${wpilib.ant.dir}/../lib/libWPILibAthena.so" />
<checksum property="md5.nwt" format="MD5SUM" file="${wpilib.ant.dir}/../lib/libNetworkTables.so" />
<checksum property="md5.hal" format="MD5SUM" file="${wpilib.ant.dir}/../lib/libHALAthena.so" />
<echo file="${wpilib.ant.dir}/md5sums">${md5.wpilib} usr/local/frc/lib/libWPILibAthena.so
${md5.nwt} usr/local/frc/lib/libNetworkTables.so
${md5.hal} usr/local/frc/lib/libHALAthena.so</echo>
<tar destfile="${wpilib.ant.dir}/control.tar">
<tarfileset dir="${wpilib.ant.dir}" username="root" group="admin" uid="0" gid="0"
prefix="">
<include name="control" />
<include name="md5sums" />
</tarfileset>
<tarfileset dir="${wpilib.ant.dir}" filemode="755" username="root" group="admin" uid="0" gid="0"
prefix="">
<include name="postinst" />
<include name="postrm" />
</tarfileset>
</tar>
<gzip destfile="${wpilib.ant.dir}/control.tar.gz" src="${wpilib.ant.dir}/control.tar"/>
<exec command="${wpilib.ant.dir}\..\..\..\toolchains\arm-none-linux-gnueabi-4.4.1\bin\arm-none-linux-gnueabi-ar -r ${opkg.name}_${cpp-sos}_${opkg.arch}.deb debian-binary control.tar.gz data.tar.gz" dir="${wpilib.ant.dir}"/>
<scp file="${wpilib.ant.dir}/${opkg.name}_${cpp-sos}_${opkg.arch}.deb" todir="${username}@${target}:/tmp"
password="${password}" trust="true"/>
<sshexec host="${target}"
username="${username}"
password="${password}"
trust="true"
command="opkg install /tmp/${opkg.name}_${cpp-sos}_${opkg.arch}.deb; sh -c 'rm -rf /tmp/wpilib*.deb'"/>
</else>
</if>
<scp file="${out.exe}" sftp="true" todir="${username}@${target}:${deploy.dir}" password="${password}" trust="true"/>
<scp file="${wpilib.ant.dir}/robotCommand" todir="${username}@${target}:/home/lvuser/" password="${password}" trust="true"/>
<echo>[athena-deploy] Starting program.</echo>
<sshexec host="${target}"
username="${username}"
password="${password}"
trust="true"
command="chmod +x ${deploy.dir}/FRCUserProgram; ${deploy.dir}/FRCUserProgram"/>
username="${username}"
password="${password}"
trust="true"
command=". /etc/profile.d/natinst-path.sh; chmod a+x ${deploy.dir}/${out}; ${deploy.kill.command};"/>
<sshexec host="${target}"
username="${username}"
password="${password}"
trust="true"
command="tail -f -s 0 -n 1 ${deploy.log.file}"/>
</target>
<target name="debug-deploy" depends="get-target-ip" description="Deploy the jar and start the program running in debug mode.">
@@ -171,4 +96,4 @@ ${md5.hal} usr/local/frc/lib/libHALAthena.so</echo>
</sequential>
</parallel>
</target>
</project>
</project>

View File

@@ -0,0 +1 @@
/home/admin/FRCUserProgram