Changeset 1172
- Timestamp:
- 05/21/08 07:38:44 (3 months ago)
- Files:
-
- trunk/descent.launching/plugin.xml (modified) (1 diff)
- trunk/descent.launching/src/descent/internal/launching/LaunchingPlugin.java (modified) (2 diffs)
- trunk/descent.launching/src/descent/internal/launching/debuild/BuildRequest.java (modified) (6 diffs)
- trunk/descent.launching/src/descent/internal/launching/debuild/DebuildBuilder.java (modified) (12 diffs)
- trunk/descent.launching/src/descent/internal/launching/debuild/DebuildBuilderNew.java (deleted)
- trunk/descent.launching/src/descent/internal/launching/debuild/RecursiveDependancyCollector.java (modified) (2 diffs)
- trunk/descent.launching/src/descent/launching/AbstractExecutableTarget.java (deleted)
- trunk/descent.launching/src/descent/launching/BuildCancelledException.java (deleted)
- trunk/descent.launching/src/descent/launching/BuildProcessor.java (deleted)
- trunk/descent.launching/src/descent/launching/BuilderLaunchDelegate.java (modified) (2 diffs)
- trunk/descent.launching/src/descent/launching/BuilderRegistry.java (modified) (1 diff)
- trunk/descent.launching/src/descent/launching/IDBuilder.java (modified) (1 diff)
- trunk/descent.launching/src/descent/launching/IDBuilderType.java (added)
- trunk/descent.launching/src/descent/launching/IDebuildEventListener.java (deleted)
- trunk/descent.launching/src/descent/launching/IDescentBuilderConstants.java (added)
- trunk/descent.launching/src/descent/launching/IExecutableTarget.java (deleted)
- trunk/descent.unittest/testdata/src/sample/foo/module3.d (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/descent.launching/plugin.xml
r1170 r1172 173 173 point="descent.launching.dBuilders"> 174 174 <builder 175 class="descent.internal.launching.debuild.DebuildBuilder New"175 class="descent.internal.launching.debuild.DebuildBuilder" 176 176 id="descent.launching.builders.debuildBuilder" 177 177 launchConfigurationType="descent.launching.builders.debuild"> trunk/descent.launching/src/descent/internal/launching/LaunchingPlugin.java
r1170 r1172 81 81 public static final String PLUGIN_ID = "descent.launching"; //$NON-NLS-1$ 82 82 public static final String ID_PLUGIN = PLUGIN_ID; 83 84 // The build group identifier 83 85 public static final String ID_BUILD_GROUP = "descent.launching.builders"; //$NON-NLS-1$ 84 86 … … 95 97 */ 96 98 public static final String ID_EXTENSION_POINT_RUNTIME_CLASSPATH_ENTRIES = "runtimeClasspathEntries"; //$NON-NLS-1$ 99 100 /** 101 * Identifier for 'dBuilders' extension point 102 */ 103 public static final String ID_EXTENSION_POINT_D_BUILDERS = "dBuilders"; 97 104 98 105 /** trunk/descent.launching/src/descent/internal/launching/debuild/BuildRequest.java
r1101 r1172 4 4 import java.util.HashSet; 5 5 import java.util.List; 6 import java.util.Set;7 6 8 7 import org.eclipse.core.runtime.CoreException; 8 import org.eclipse.debug.core.ILaunchConfiguration; 9 9 10 10 import descent.core.IJavaProject; 11 11 import descent.core.JavaCore; 12 import descent.launching.IExecutableTarget;13 12 import descent.launching.IVMInstall; 14 13 import descent.launching.JavaRuntime; … … 21 20 * of this type will exist per DebuildBuilder, and this object should 22 21 * generally simply serve as a wrapper for abstracting getting information 23 * that the build needs from the {@link IExecutableTarget}. 24 * 25 * Note that many of these methods are simply wrappers for 26 * <code>IExecutableTarget</code> methods. This is okay, since it helps abstract 27 * these things from the builder if that interface ever changes. 22 * that the build needs from the {@link ILaunchConfiguration}. 28 23 * 29 24 * @author Robert Fraser … … 31 26 /* package */ class BuildRequest 32 27 { 33 /** 34 * Information about the executable target to be built (is it debug? 35 * should we optimize? Add unit tests? etc., etc.) 36 */ 37 private final IExecutableTarget target; 28 private final ILaunchConfiguration config; 38 29 private final IJavaProject project; 39 30 private final IVMInstall compilerType; 40 31 41 public BuildRequest(I ExecutableTarget target)42 { 43 this. target = target;44 this.project = target.getProject();32 public BuildRequest(ILaunchConfiguration config) 33 { 34 this.config = config; 35 this.project = null; // TODO config.getProject(); 45 36 46 37 IVMInstall compilerType = null; … … 77 68 public String[] getModules() 78 69 { 79 return target.getModules(); 70 // TODO return config.getModules(); 71 return null; 80 72 } 81 73 … … 85 77 public String[] getDefaultImportPath() 86 78 { 87 return target.getDefaultImportPath(); 79 // TODO return config.getDefaultImportPath(); 80 return null; 88 81 } 89 82 … … 109 102 110 103 // Set the executable-target-specific options 111 opts.addDebugInfo = target.getAddDebugInfo();112 opts.addUnittests = target.getAddUnittests();113 opts.addAssertsAndContracts = target.getAddAssertsAndContracts();114 opts.inlineFunctions = target.getInlineFunctions();115 opts.optimizeCode = target.getOptimizeCode();116 opts.instrumentForCoverage = target.getInstrumentForCoverage();117 opts.instrumentForProfile = target.getInstrumentForProfile();118 for(String ident : target.getDefaultVersionIdents())119 opts.debugIdents.add(ident);120 for(String ident : target.getDefaultDebugIdents())121 opts.debugIdents.add(ident);104 // TODO opts.addDebugInfo = config.getAddDebugInfo(); 105 // TODO opts.addUnittests = config.getAddUnittests(); 106 // TODO opts.addAssertsAndContracts = config.getAddAssertsAndContracts(); 107 // TODO opts.inlineFunctions = config.getInlineFunctions(); 108 // TODO opts.optimizeCode = config.getOptimizeCode(); 109 // TODO opts.instrumentForCoverage = config.getInstrumentForCoverage(); 110 // TODO opts.instrumentForProfile = config.getInstrumentForProfile(); 111 // TODO for(String ident : config.getDefaultVersionIdents()) 112 // TODO opts.debugIdents.add(ident); 113 // TODO for(String ident : config.getDefaultDebugIdents()) 114 // TODO opts.debugIdents.add(ident); 122 115 123 116 // Set the project-specific options trunk/descent.launching/src/descent/internal/launching/debuild/DebuildBuilder.java
r1170 r1172 7 7 import java.util.Set; 8 8 9 import org.eclipse.core.runtime.CoreException; 9 10 import org.eclipse.core.runtime.IProgressMonitor; 10 11 import org.eclipse.core.runtime.NullProgressMonitor; … … 16 17 import descent.core.IJavaProject; 17 18 import descent.core.JavaModelException; 18 import descent.launching.BuildCancelledException;19 19 import descent.launching.IDBuilder; 20 import descent.launching.IExecutableTarget;21 20 import descent.launching.compiler.BuildError; 22 21 import descent.launching.compiler.BuildResponse; … … 26 25 import descent.launching.compiler.IResponseInterpreter; 27 26 28 /** 29 * The main engine of the descent remote builder. Given an executable target 30 * (info on what type of executable is needed) and a project, performs the 31 * build. The publuc interface of this class can be accessed via the 32 * {@link #build(IExecutableTarget, IProgressMonitor)} method, 33 * which will initiat a build. 34 * 35 * @author Robert Fraser 36 */ 37 public class DebuildBuilder 27 // TODO recomment 28 public class DebuildBuilder implements IDBuilder 38 29 { 39 /**40 * Public interface to the debuild builder, which initiates a new build41 * based on the given executable target. The target42 * should contain information on what is to be built. Returns the path to43 * the executable file if one is built (or already exists in the project)44 * or null if the project could not be built.45 *46 * @param target information about the target executable to be built47 * @param pm a monitor to track the progress of the build48 * @return the path to the executable file or null if one could not49 * be built due to an error50 */51 public static String build(IExecutableTarget target, IProgressMonitor pm)52 {53 DebuildBuilder builder = new DebuildBuilder(new BuildRequest(target));54 return builder.build(pm);55 }56 57 30 /* package */ static final boolean DEBUG = true; 58 59 31 /* package */ static final String EXECUTABLE_FILE_PREFIX = "-"; 60 32 61 //-------------------------------------------------------------------------- 62 63 private final BuildRequest req; 64 private final ErrorReporter err; 33 private BuildRequest req; 34 private ErrorReporter err; 65 35 66 36 private List<File> importPath; … … 68 38 private List<GroupedCompile> groupedCompiles; 69 39 private CompileOptions opts; 70 71 private DebuildBuilder(BuildRequest req) 40 41 public String build(ILaunchConfiguration config, IProgressMonitor pm) 42 throws CoreException 72 43 { 73 this.req = req; 74 this.err = new ErrorReporter(req.getProject()); 75 } 76 77 private String build(IProgressMonitor pm) 78 { 44 // TODO remove 45 if(true) 46 { 47 System.out.println("We here, baby!"); 48 return null; 49 } 50 79 51 if(null == pm) 80 52 pm = new NullProgressMonitor(); 81 53 82 54 if(pm.isCanceled()) 83 throw new BuildCancelledException();55 return null; 84 56 85 57 try … … 87 59 pm.beginTask("Building D application", 100); 88 60 89 // Usually, a little work has been done by now. Move the progress bar to keep the90 // user in a pleasent and productive mood61 req = new BuildRequest(config); 62 err = new ErrorReporter(req.getProject()); 91 63 pm.worked(5); // 5 92 64 … … 98 70 99 71 if(pm.isCanceled()) 100 throw new BuildCancelledException();72 return null; 101 73 102 74 // Then, recursively collect dependancies for all the object files … … 108 80 109 81 if(pm.isCanceled()) 110 throw new BuildCancelledException();82 return null; 111 83 112 84 // Then, get the compile options we should use and apply them to … … 118 90 119 91 if(pm.isCanceled()) 120 throw new BuildCancelledException();92 return null; 121 93 122 94 // Create a set of grouped compiles for each compile group we need … … 125 97 126 98 if(pm.isCanceled()) 127 throw new BuildCancelledException();99 return null; 128 100 129 101 // Perform each compile operation … … 137 109 catch(Exception e) 138 110 { 139 if(DEBUG && !(e instanceof BuildCancelledException))111 if(DEBUG) 140 112 e.printStackTrace(); 141 113 if(e instanceof RuntimeException) … … 224 196 { 225 197 if(pm.isCanceled()) 226 throw new BuildCancelledException();198 return null; 227 199 228 200 // Get & setup a new compile command … … 274 246 275 247 if(pm.isCanceled()) 276 throw new BuildCancelledException();248 return null; 277 249 278 250 // Create the linker command trunk/descent.launching/src/descent/internal/launching/debuild/RecursiveDependancyCollector.java
r1101 r1172 23 23 import descent.core.IParent; 24 24 import descent.core.JavaModelException; 25 import descent.launching.BuildCancelledException;26 27 25 /** 28 26 * Class that can recurse through dependancies to generate a list of all files … … 91 89 // is good! 92 90 if(pm.isCanceled()) 93 throw new BuildCancelledException();91 return null; 94 92 95 93 collectRecursive(moduleName); trunk/descent.launching/src/descent/launching/BuilderLaunchDelegate.java
r1170 r1172 3 3 import org.eclipse.core.runtime.CoreException; 4 4 import org.eclipse.core.runtime.IProgressMonitor; 5 import org.eclipse.core.runtime.IStatus; 6 import org.eclipse.core.runtime.Status; 5 7 import org.eclipse.debug.core.ILaunch; 6 8 import org.eclipse.debug.core.ILaunchConfiguration; 7 9 import org.eclipse.debug.core.model.ILaunchConfigurationDelegate; 10 11 import descent.internal.launching.LaunchingPlugin; 8 12 9 13 /** … … 20 24 ILaunch launch, IProgressMonitor pm) throws CoreException 21 25 { 22 // TODO get the builder type & perform the build 26 // Get the builder and call its build method... pretty simple, actually 27 String configTypeId = config.getType().getIdentifier(); 28 IDBuilderType builderType = BuilderRegistry.getInstance().getBuilderForLaunchConfigurationType(configTypeId); 29 if(null == builderType) 30 throw error("Could not find builder for launch configuration type " + configTypeId); 31 32 IDBuilder builder = builderType.getBuilder(); 33 if(null == builder) 34 throw error("Could not create builder for builder type " + builderType.getIdentifier()); 35 36 builder.build(config, pm); 37 } 38 39 private static CoreException error(String message) 40 { 41 return new CoreException(new Status(IStatus.ERROR, 42 LaunchingPlugin.PLUGIN_ID, message)); 23 43 } 24 44 } trunk/descent.launching/src/descent/launching/BuilderRegistry.java
r1170 r1172 1 1 package descent.launching; 2 2 3 import java.util.ArrayList; 4 import java.util.List; 5 6 import org.eclipse.core.runtime.CoreException; 7 import org.eclipse.core.runtime.IConfigurationElement; 8 import org.eclipse.core.runtime.IExtensionPoint; 9 import org.eclipse.core.runtime.Platform; 10 11 import descent.internal.launching.LaunchingPlugin; 12 13 /** 14 * Class used to get information about what types of D builders have been configured 15 * for use with Descent. 16 * 17 * @author Robert Fraser 18 */ 3 19 public class BuilderRegistry 4 20 { 21 private class DBuilderType implements IDBuilderType 22 { 23 // Attributes defined in the schema 24 private static final String ATTR_ID = "id"; 25 private static final String ATTR_CLASS = "class"; 26 private static final String ATTR_LAUNCH_CONFIGURATION_TYPE = "launchConfigurationType"; 27 28 private final IConfigurationElement info; 5 29 30 private DBuilderType(IConfigurationElement info) 31 { 32 this.info = info; 33 } 34 35 /* (non-Javadoc) 36 * @see descent.launching.IDBuilderType#getBuilder() 37 */ 38 public IDBuilder getBuilder() throws CoreException 39 { 40 return (IDBuilder) info.createExecutableExtension(ATTR_CLASS); 41 } 42 43 /* (non-Javadoc) 44 * @see descent.launching.IDBuilderType#getIdentifier() 45 */ 46 public String getIdentifier() 47 { 48 return info.getAttribute(ATTR_ID); 49 } 50 51 /* (non-Javadoc) 52 * @see descent.launching.IDBuilderType#getLaunchConfigurationType() 53 */ 54 public String getLaunchConfigurationType() 55 { 56 return info.getAttribute(ATTR_LAUNCH_CONFIGURATION_TYPE); 57 } 58 } 59 60 private List<DBuilderType> builders; 61 62 /** 63 * Gets info about all the builders registered with this plugin 64 * 65 * @return the list of all builders associated with this plugin 66 */ 67 public IDBuilderType[] getBuilders() 68 { 69 if(null == builders) 70 loadBuilders(); 71 72 return builders.toArray(new IDBuilderType[builders.size()]); 73 } 74 75 /** 76 * Gets the builder associated with the given id. I'm not sure if Eclipse 77 * allows multiple things to have the same "id" property, but if it does, 78 * that would be an undefined condition for this method. 79 * 80 * @param id the id to look up 81 * @return the builder associated with the id or <code>null</code> if none 82 * was found 83 */ 84 public IDBuilderType getBuilderById(String id) 85 { 86 if(null == builders) 87 loadBuilders(); 88 89 for(IDBuilderType builder : builders) 90 { 91 if(builder.getIdentifier().equals(id)) 92 return builder; 93 } 94 return null; 95 } 96 97 /** 98 * Gets the builder associated with the given launch configuration type. Note 99 * that if multiple builders are associated with the same launch configuration 100 * type, the one which is returned is undefined, so don't let this happen. 101 * 102 * @param launchConfigurationType the launch configuration type to look up 103 * @return the associated builder or <code>null</code> 104 * if none was found 105 */ 106 public IDBuilderType getBuilderForLaunchConfigurationType( 107 String launchConfigurationType) 108 { 109 if(null == builders) 110 loadBuilders(); 111 112 for(IDBuilderType builder : builders) 113 { 114 if(builder.getLaunchConfigurationType().equals(launchConfigurationType)) 115 return builder; 116 } 117 return null; 118 } 119 120 /** 121 * Gets the builder type associated with the default descent builder 122 * 123 * @return the builder type associated with the default descent builder 124 */ 125 public IDBuilderType getDescentBuilder() 126 { 127 return getBuilderById(IDescentBuilderConstants.ID_DESCENT_BUILDER); 128 } 129 130 private synchronized void loadBuilders() 131 { 132 if(null != builders) 133 return; 134 135 builders = new ArrayList<DBuilderType>(); 136 IExtensionPoint extensionPoint = Platform.getExtensionRegistry(). 137 getExtensionPoint(LaunchingPlugin.ID_PLUGIN, 138 LaunchingPlugin.ID_EXTENSION_POINT_D_BUILDERS); 139 IConfigurationElement[] infos = extensionPoint.getConfigurationElements(); 140 141 for(IConfigurationElement info : infos) 142 { 143 DBuilderType builder = new DBuilderType(info); 144 builders.add(builder); 145 } 146 } 147 148 //-------------------------------------------------------------------------- 149 // Instance management 150 151 private static BuilderRegistry instance; 152 153 /** 154 * Gets the instance of the singleton. 155 * 156 * @return the singleton instance 157 */ 158 public static synchronized BuilderRegistry getInstance() 159 { 160 if(null == instance) 161 instance = new BuilderRegistry(); 162 163 return instance; 164 } 165 166 private BuilderRegistry() 167 { 168 // Should not be called outside this class 169 } 6 170 } trunk/descent.launching/src/descent/launching/IDBuilder.java
r1170 r1172 1 1 package descent.launching; 2 2 3 import org.eclipse.core.runtime.CoreException; 3 4 import org.eclipse.core.runtime.IProgressMonitor; 4 5 import org.eclipse.debug.core.ILaunchConfiguration; 5 6 7 /** 8 * Interface which should be implemented by all builder providers. Provides a 9 * mechanism for building a D application, library, dynamic library or associated 10 * resource(s). Builders may be associated with one or more run configurations 11 * or as part of the Eclipse build cycle, as well as being invoked manually, so 12 * there is no guarantee that it is actually being invoked within a launch despite 13 * the fact that all configurations are done using a {@link ILaunchConfiguration}. 14 * 15 * Implementations must have a no-element constructor unless they follow the 16 * design pattern laid out in 17 * {@link org.eclipse.core.runtime.IConfigurationElement#createExecutableExtension(String)} 18 * A new builder instance will be constructed on each build. The constructor should 19 * run fairly quickly, as there is no progress monitor running during this phase 20 * of the build. 21 * 22 * @author Robert Fraser 23 */ 6 24 public interface IDBuilder 7 25 { 8 public String build(ILaunchConfiguration config, IProgressMonitor pm) ;26 public String build(ILaunchConfiguration config, IProgressMonitor pm) throws CoreException; 9 27 } trunk/descent.unittest/testdata/src/sample/foo/module3.d
r1113 r1172 1 1 module sample.foo.module3; 2 3 // You get nothing! Ha ha, you are so STUUUPID!
