Reverting back to static .a files for C++ and fixing lots of other assorted items

This commit is contained in:
Patrick Plenefisch
2014-05-02 17:54:01 -04:00
parent c1482cb267
commit 9b831ed34c
178 changed files with 1901 additions and 1846 deletions

View File

@@ -2,25 +2,42 @@ package edu.wpi.first.wpilib.plugins.cpp.launching;
import java.io.File;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.executables.Executable;
import org.eclipse.cdt.debug.core.executables.ExecutablesManager;
import org.eclipse.cdt.debug.mi.core.IGDBServerMILaunchConfigurationConstants;
import org.eclipse.cdt.debug.mi.core.IMIConstants;
import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants;
import org.eclipse.cdt.launch.remote.IRemoteConnectionConfigurationConstants;
import org.eclipse.cdt.launch.remote.IRemoteConnectionHostConstants;
import org.eclipse.cdt.ui.ICDTConstants;
import org.eclipse.core.internal.resources.Resource;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.ILaunchGroup;
import org.eclipse.debug.ui.ILaunchShortcut;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.PlatformUI;
@@ -38,147 +55,118 @@ import edu.wpi.first.wpilib.plugins.cpp.WPILibCPPPlugin;
* @author Alex Henning
*/
@SuppressWarnings("restriction")
public class DeployLaunchShortcut implements ILaunchShortcut {
//Class constants - used to delineate types for launch shortcuts
public class DeployLaunchShortcut implements ILaunchShortcut
{
// Class constants - used to delineate types for launch shortcuts
public static final String DEPLOY_TYPE = "edu.wpi.first.wpilib.plugins.core.deploy";
private static final String ANT_SERVER_THREAD_NAME = "Ant Build Server Connection";
private static ILaunch lastDeploy = null;
/**
* Returns the launch type of the shortcut that was used, one of the constants
* defined in BaseLaunchShortcut
* Returns the launch type of the shortcut that was used, one of the
* constants defined in BaseLaunchShortcut
*
* @return Launch shortcut type
*/
public String getLaunchType() {return DEPLOY_TYPE;}
public String getLaunchType()
{
return DEPLOY_TYPE;
}
@Override
public void launch(ISelection selection, String mode) {
//Extract resource from selection
StructuredSelection sel = (StructuredSelection)selection;
public void launch(ISelection selection, String mode)
{
// Extract resource from selection
StructuredSelection sel = (StructuredSelection) selection;
IProject activeProject = null;
if (sel.getFirstElement() instanceof IProject) {
if (sel.getFirstElement() instanceof IProject)
{
activeProject = (IProject) sel.getFirstElement();
} else {
} else
{
return;
}
//Run config using project found in extracted resource, with indicated mode
runConfig(activeProject, mode);
// Run config using project found in extracted resource, with indicated
// mode
runConfig(activeProject, mode, PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
}
@Override
public void launch(IEditorPart editor, String mode) {
//Extract resource from editor
if(editor != null){
IFileEditorInput input = (IFileEditorInput)editor.getEditorInput();
IFile file = input.getFile();
IProject activeProject = file.getProject();
//If editor existed, run config using extracted resource in indicated mode
runConfig(activeProject, mode);
}else{
public void launch(IEditorPart editor, String mode)
{
// Extract resource from editor
if (editor != null)
{
IFileEditorInput input = (IFileEditorInput) editor.getEditorInput();
IFile file = input.getFile();
IProject activeProject = file.getProject();
// If editor existed, run config using extracted resource in
// indicated mode
runConfig(activeProject, mode, editor.getSite().getWorkbenchWindow().getShell());
} else
{
System.err.println("editor was null");
}
}
/**
* Runs the ant script using the correct target for the indicated mode (deploy to cRIO or just compile)
* @param activeProj The project that the script will be run on/from
* @param mode The mode it will be run in (ILaunchManager.RUN_MODE or ILaunchManager.DEBUG_MODE)
*
* @param activeProj
* The project that the script will be run on/from
* @param mode
* The mode it will be run in (ILaunchManager.RUN_MODE or
* ILaunchManager.DEBUG_MODE)
*/
public void runConfig(IProject activeProj, String mode){
String targets = "deploy";
if(mode.equals(ILaunchManager.RUN_MODE)){
if(getLaunchType().equals(DEPLOY_TYPE)){
targets = "deploy";
}
} else if ((mode.equals(ILaunchManager.DEBUG_MODE))&&(getLaunchType().equals(DEPLOY_TYPE))) {
targets = "debug-deploy";
try{
PlatformUI.getWorkbench().showPerspective(IDebugUIConstants.ID_DEBUG_PERSPECTIVE,
PlatformUI.getWorkbench().getActiveWorkbenchWindow());
}catch(Exception e){}
public void runConfig(IProject activeProj, String mode, Shell shell) //TODO: figure out UI issues. tjats 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)
{
System.err.println("Debug attach failed.");
e.printStackTrace();
}
if((lastDeploy != null)&&(!lastDeploy.isTerminated())){
System.out.println("Last deploy running");
//Find the server connection thread and kill it
Vector<ThreadGroup> threadGroups = new Vector<ThreadGroup>();
ThreadGroup root = Thread.currentThread().getThreadGroup().getParent();
while (root.getParent() != null) {root = root.getParent();}
threadGroups.add(root);
ThreadGroup threadGroup = threadGroups.remove(0);
int numThreads = threadGroup.activeCount();
Thread[] threads = new Thread[numThreads*100];
numThreads = threadGroup.enumerate(threads, true);
for(Thread current: threads){
if(current != null){
if(current.getName().equals(ANT_SERVER_THREAD_NAME)){
try{
//Manually end thread and then try terminating launch
Method stopMethod = current.getClass().getMethod("stop");
stopMethod.invoke(current);
lastDeploy.terminate();
break;
}catch(Exception e){e.printStackTrace();}
}
}
}
System.out.println("Waiting");
try{wait(1000);}catch(Exception e){}
}
if (mode.equals(ILaunchManager.RUN_MODE)) {
System.out.println("Running ant file: " + activeProj.getLocation().toOSString() + File.separator + "build.xml");
System.out.println("Targets: " + targets + ", Mode: " + mode);
lastDeploy = AntLauncher.runAntFile(new File (activeProj.getLocation().toOSString() + File.separator + "build.xml"), targets, null, mode);
} else if((mode.equals(ILaunchManager.DEBUG_MODE))&&(getLaunchType().equals(DEPLOY_TYPE))) {
ILaunchConfigurationWorkingCopy config;
try {
config = getRemoteDebugConfig(activeProj);
//config.doSave(); // NOTE: For debugging
startDebugConfig(config, lastDeploy);
} catch (CoreException e) {
System.err.println("Debug attach failed.");
e.printStackTrace();
}
}
try {
try
{
activeProj.refreshLocal(Resource.DEPTH_INFINITE, null);
} catch (Exception e) {}
} catch (Exception e)
{
}
}
private ILaunchConfigurationWorkingCopy getRemoteDebugConfig(IProject activeProj) throws CoreException {
private ILaunchConfigurationWorkingCopy getRemoteDebugConfig(IProject activeProj) throws CoreException
{
ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType type = manager.getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_REMOTE_APP);
int teamNumber = WPILibCore.getDefault().getTeamNumber(activeProj);
String remote_connection = RSEUtils.getTarget(teamNumber).getName();
ILaunchConfigurationWorkingCopy config = type.newInstance(null, "Debug "+activeProj.getName());
ILaunchConfigurationWorkingCopy config = type.newInstance(null, activeProj.getName());
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, activeProj.getName());
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "Debug/FRCUserProgram");
config.setAttribute(DebugPlugin.getUniqueIdentifier() + ".ATTR_TARGET_PATH", "/home/admin/FRCUserProgram");
config.setAttribute("org.eclipse.cdt.debug.mi.core.DEBUG_NAME", WPILibCPPPlugin.getDefault().getToolchain()+"/bin/arm-none-linux-gnueabi-gdb");
config.setAttribute("org.eclipse.cdt.dsf.gdb.DEBUG_NAME", WPILibCPPPlugin.getDefault().getToolchain()+"/bin/arm-none-linux-gnueabi-gdb");
Collection<Executable> exes = ExecutablesManager.getExecutablesManager().getExecutablesForProject(activeProj);
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");
config.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, WPILibCPPPlugin.getDefault().getToolchain() + "/bin/arm-none-linux-gnueabi-gdb");
config.setAttribute(IRemoteConnectionConfigurationConstants.ATTR_REMOTE_CONNECTION, remote_connection);
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, "org.eclipse.rse.remotecdt.RemoteGDBDebugger");
Map<String, String> launchers = new HashMap<String, String>();
launchers.put("[debug]", "org.eclipse.rse.remotecdt.launch");
config.setAttribute(DebugPlugin.getUniqueIdentifier() + ".preferred_launchers", launchers);
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, "gdbserver");
List<String> solibs = new ArrayList<>();
solibs.add(WPILibCPPPlugin.getDefault().getToolchain() + "/arm-non-linux-gnueabi/libc/lib");
solibs.add(WPILibCPPPlugin.getDefault().getToolchain() + "/arm-non-linux-gnueabi/libc/usr/lib");
solibs.add(WPILibCPPPlugin.getDefault().getCPPDir() + "/lib");
config.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_SOLIB_PATH, solibs);
return config;
}
private void startDebugConfig(final ILaunchConfigurationWorkingCopy config, ILaunch deploy) throws CoreException {
config.launch(ILaunchManager.DEBUG_MODE, null);
}
}

View File

@@ -2,6 +2,9 @@ package edu.wpi.first.wpilib.plugins.cpp.launching;
import java.util.Arrays;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.PasswordPersistenceManager;
import org.eclipse.rse.core.RSECorePlugin;
@@ -15,7 +18,7 @@ public class RSEUtils {
public static IHost getTarget(int teamNumber) {
// The ip address based on the team number
String hostName = "10."+(teamNumber/100)+"."+(teamNumber%100)+".2";
String connectionName = "Team "+teamNumber;
String connectionName = hostName; //"Team "+teamNumber;
// get the singleton RSE registry
try {
@@ -42,7 +45,7 @@ public class RSEUtils {
"The remote target for debugging the robot for team "+teamNumber+".");
host.setDefaultUserId("admin");
SystemSignonInformation info = new SystemSignonInformation(hostName, "admin",
"XX", systemType);
"", systemType);
PasswordPersistenceManager.getInstance().add(info, true, false);
} catch (Exception e) {
e.printStackTrace();

View File

@@ -30,14 +30,13 @@
</target>
<target name="deploy" depends="get-target-ip" description="Deploy the progam and start it running.">
<echo>[athena-deploy] Killing running program</echo>
<sshexec host="${target}"
username="${username}"
password="${password}"
trust="true"
command="killall FRCUserProgram; sleep 1"/>
username="${username}"
password="${password}"
trust="true"
command="rm ${deploy.dir}/FRCUserProgram" />
<echo>[athena-deploy] Copying code over.</echo>
<scp file="${out.exe}" todir="${username}@${target}:${deploy.dir}"
<scp file="${out.exe}" sftp="true" todir="${username}@${target}:${deploy.dir}"
password="${password}" trust="true"/>
<sshexec host="${target}"
username="${username}"
@@ -119,14 +118,12 @@ ${md5.hal} usr/local/frc/lib/libHALAthena.so</echo>
command="opkg install /tmp/${opkg.name}_${cpp-sos}_${opkg.arch}.deb; sh -c 'rm -rf /tmp/wpilib*.deb'"/>
</else>
</if>
<scp file="${wpilib.ant.dir}/runcppprogram" todir="${username}@${target}:${deploy.dir}"
password="${password}" trust="true"/>
<echo>[athena-deploy] Starting program.</echo>
<sshexec host="${target}"
username="${username}"
password="${password}"
trust="true"
command="chmod a+x run*program; ${deploy.run.command}"/>
command="chmod +x ${deploy.dir}/FRCUserProgram; ${deploy.dir}/FRCUserProgram"/>
</target>
<target name="debug-deploy" depends="get-target-ip" description="Deploy the jar and start the program running in debug mode.">

View File

@@ -1,6 +0,0 @@
#. ./.profile
killall java
sleep 1
nohup java -Djna.library.path=$LD_LIBRARY_PATH -Xmx32M -agentlib:jdwp=transport=dt_socket,address=8348,server=y,suspend=y -jar FRCUserProgram.jar edu.wpi.first.wpilibj.unittests.RunTests

View File

@@ -1,6 +0,0 @@
#. ./.profile
killall java
killall FRCUserProgram
sleep 1
chmod +x ./FRCUserProgram
./FRCUserProgram

View File

@@ -1,6 +0,0 @@
#. ./.profile
killall java
killall FRCUserProgram
sleep 1
nohup /usr/local/frc/JRE/bin/java -jar FRCUserProgram.jar
#nohup /usr/local/frc/JRE/bin/java -Djna.library.path=$LD_LIBRARY_PATH -Xmx32M -jar FRCUserProgram.jar