/* * V1.0 Edited by Jing * * - Fixed the installation of eclipse using different names [without spaces] * Bug: Plugin will only work if Eclipse is installed in C:/eclipse/ * Fix: run() modified so that the internal path is dynamic with respect to the * root folder [folder in which eclipse is installed] instead of being static to c:/eclipse/ * Now: User can install eclipse into a folder named "blah" instead of "eclipse" and the plugin will still run correctly * * - Fixed the bug for installation of eclipse into a folder with spaces * Bug: Build will not generate makefile, run make file or create the simu.exe or complete any build functions correctly * if there is a space in the path to eclipse. * Fix: All instances of "cmd" [dos/unix command] are fixed to a format that supports spaces * A new function is created called toUnixPath that will convert a path to unix [used by cygwin] * Quotes are added to path names so that it will support spaces in file names. * */ package CDBuilder.buttons; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.dialogs.ProgressMonitorDialog; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.viewers.ISelection; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IPageLayout; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PlatformUI; import CDBuilder.CDBuilderPlugin; import CDBuilder.console.ConsoleDocument; import CDBuilder.console.StreamHandler; /** * @author sddsim * * To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */ public class RunMakeFileAction extends Action implements IWorkbenchWindowActionDelegate { public class conWrite implements Runnable { String line; public conWrite(String line) { this.line = line; } public void run() { ConsoleDocument.getCDOS().set(line); } } class makefileTasks implements IRunnableWithProgress{ boolean vMode; boolean simuexists = false; boolean makeexists = false; //main object files String[] mainOFiles = {"queue.o", "main.o", "generat.o","cpu.o","transduc.o","distri.o","com.o","linpack.o","debug.o", "trafico.o"}; String originalMakefile; IContainer container; IPath projectPath; IPath internalPath; IWorkspaceRoot root; public makefileTasks(boolean vMode, IContainer container, IPath projectPath, IPath internalPath, IWorkspaceRoot root) { this.vMode = vMode; this.container = container; this.projectPath = projectPath; this.internalPath = internalPath; this.root = root; } public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { //Updates console Display.getDefault().syncExec(new conWrite("Starting Compilation of Project..." + "\n")); Display.getDefault().syncExec(new conWrite("Searching for .cpp files..." + "\n")); monitor.setTaskName("Building Project"); monitor.beginTask("Building Project", 9); monitor.subTask("Searching For CPP Files"); monitor.worked(1); if (monitor.isCanceled()) throw new InterruptedException("User has cancelled the compilation"); String[] cppFiles = null; cppFiles = findMembers(container,cppFiles); String[] oFiles = new String [cppFiles.length]; for (int a = 0; a < oFiles.length-1; a++ ){ if (cppFiles[a]!=null){ //changing files.cpp to objectFiles.cpp oFiles[a] = new String(cppFiles[a].substring(0,cppFiles[a].length()-4)+".o"); for (int b = 0; b