Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikhail Sennikovsky2006-04-06 05:20:00 -0400
committerMikhail Sennikovsky2006-04-06 05:20:00 -0400
commit8f100afd6ce737232888384980887c4369742169 (patch)
tree40624a3c1c86f3d9e746047678f6dce717ce9be3 /build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core
parentd431889736c03b1e5793435a40251306ed1f11c0 (diff)
downloadorg.eclipse.cdt-8f100afd6ce737232888384980887c4369742169.tar.gz
org.eclipse.cdt-8f100afd6ce737232888384980887c4369742169.tar.xz
org.eclipse.cdt-8f100afd6ce737232888384980887c4369742169.zip
MBS Internal Builder implementation. This functionality is experimental and is disabled for now.
Fixes for the Build Model implementation.
Diffstat (limited to 'build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java2
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java171
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties6
3 files changed, 176 insertions, 3 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
index 26da8b8ce1..f8f1011e9e 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
@@ -816,7 +816,7 @@ public class Configuration extends BuildObject implements IConfiguration {
getResourceConfigurationList().remove(resConfig);
getResourceConfigurationMap().remove(resConfig.getResourcePath());
isDirty = true;
-// rebuildNeeded = true;
+ rebuildNeeded = true;
}
/*
* M O D E L A T T R I B U T E A C C E S S O R S
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java
index e9dbd2467b..283bf75941 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java
@@ -33,6 +33,8 @@ import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
+import org.eclipse.cdt.managedbuilder.internal.buildmodel.DescriptionBuilder;
+import org.eclipse.cdt.managedbuilder.internal.buildmodel.IBuildModelBuilder;
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
@@ -222,6 +224,13 @@ public class GeneratedMakefileBuilder extends ACBuilder {
private static final String TYPE_CLEAN = "ManagedMakeBuilder.type.clean"; //$NON-NLS-1$
private static final String TYPE_INC = "ManagedMakeBuider.type.incremental"; //$NON-NLS-1$
private static final String WARNING_UNSUPPORTED_CONFIGURATION = "ManagedMakeBuilder.warning.unsupported.configuration"; //$NON-NLS-1$
+ private static final String BUILD_CANCELLED = "ManagedMakeBuilder.message.cancelled"; //$NON-NLS-1$
+ private static final String BUILD_FINISHED_WITH_ERRS = "ManagedMakeBuilder.message.finished.with.errs"; //$NON-NLS-1$
+ private static final String BUILD_FAILED_ERR = "ManagedMakeBuilder.message.internal.builder.error"; //$NON-NLS-1$
+ private static final String BUILD_STOPPED_ERR = "ManagedMakeBuilder.message.stopped.error"; //$NON-NLS-1$
+ private static final String INTERNAL_BUILDER_HEADER_NOTE = "ManagedMakeBuilder.message.internal.builder.header.note"; //$NON-NLS-1$
+ private static final String TYPE_REBUILD = "ManagedMakeBuider.type.rebuild"; //$NON-NLS-1$
+ private static final String INTERNAL_BUILDER = "ManagedMakeBuilder.message.internal.builder"; //$NON-NLS-1$
public static boolean VERBOSE = false;
// Local variables
@@ -329,12 +338,24 @@ public class GeneratedMakefileBuilder extends ACBuilder {
return referencedProjects;
}
+ IConfiguration cfg = info.getDefaultConfiguration();
+
+// Uncomment the below code for using the Internal Builder
+// TODO: the info of what builder is to be used
+// should be held in and obtained from the Configuration
+/*
+ if(true){
+ invokeInternalBuilder(cfg, kind != FULL_BUILD, true, monitor);
+
+ // Scrub the build info the project
+ info.setRebuildState(false);
+ return referencedProjects;
+ }
+*/
// Create a makefile generator for the build
IManagedBuilderMakefileGenerator generator = ManagedBuildManager.getBuildfileGenerator(info.getDefaultConfiguration());
generator.initialize(getProject(), info, monitor);
- IConfiguration cfg = info.getDefaultConfiguration();
-
//perform necessary cleaning and build type calculation
if(cfg.needsFullRebuild()){
//configuration rebuild state is set to true,
@@ -1069,4 +1090,150 @@ public class GeneratedMakefileBuilder extends ACBuilder {
}
}
}
+
+ /**
+ * called to invoke the MBS Internal Builder for building the given configuration
+ *
+ * @param cfg configuration to be built
+ * @param buildIncrementaly if true, incremental build will be performed,
+ * only files that need rebuild will be built.
+ * If false, full rebuild will be performed
+ * @param resumeOnErr if true, build will continue in case of error while building.
+ * If false the build will stop on the first error
+ * @param monitor monitor
+ */
+ protected void invokeInternalBuilder(IConfiguration cfg,
+ boolean buildIncrementaly,
+ boolean resumeOnErr,
+ IProgressMonitor monitor) {
+ // Get the project and make sure there's a monitor to cancel the build
+ IProject currentProject = cfg.getOwner().getProject();
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+
+ try {
+ int flags = 0;
+ IResourceDelta delta = null;
+
+ if(buildIncrementaly){
+ flags = BuildDescriptionManager.REBUILD | BuildDescriptionManager.REMOVED;
+ delta = getDelta(currentProject);
+ }
+
+ IBuildDescription des = BuildDescriptionManager.createBuildDescription(cfg, delta, flags);
+
+ IBuildModelBuilder builder = new DescriptionBuilder(des, buildIncrementaly, resumeOnErr);
+
+ String[] msgs = new String[2];
+ msgs[0] = ManagedMakeMessages.getResourceString(INTERNAL_BUILDER);
+ msgs[1] = currentProject.getName();
+ monitor.subTask(ManagedMakeMessages.getFormattedString(MAKE, msgs));
+
+ // Get a build console for the project
+ StringBuffer buf = new StringBuffer();
+ IConsole console = CCorePlugin.getDefault().getConsole();
+ console.start(currentProject);
+ ConsoleOutputStream consoleOutStream = console.getOutputStream();
+ String[] consoleHeader = new String[3];
+ if(buildIncrementaly)
+ consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_INC);
+ else
+ consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_REBUILD);
+
+ consoleHeader[1] = cfg.getName();
+ consoleHeader[2] = currentProject.getName();
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append(ManagedMakeMessages.getFormattedString(CONSOLE_HEADER, consoleHeader));
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ buf.append(ManagedMakeMessages.getResourceString(INTERNAL_BUILDER_HEADER_NOTE));
+ buf.append("\n"); //$NON-NLS-1$
+
+ if(!cfg.isSupported()){
+ buf.append(ManagedMakeMessages.getFormattedString(WARNING_UNSUPPORTED_CONFIGURATION,new String[] {cfg.getName(),cfg.getToolChain().getName()}));
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ consoleOutStream.write(buf.toString().getBytes());
+ consoleOutStream.flush();
+
+ // Remove all markers for this project
+ removeAllMarkers(currentProject);
+
+ // Hook up an error parser manager
+ String[] errorParsers = cfg.getErrorParserList();
+ ErrorParserManager epm = new ErrorParserManager(getProject(), des.getDefaultBuildDirLocation(), this, errorParsers);
+ epm.setOutputStream(consoleOutStream);
+ // This variable is necessary to ensure that the EPM stream stay open
+ // until we explicitly close it. See bug#123302.
+ OutputStream epmOutputStream = epm.getOutputStream();
+
+ int status = builder.build(epmOutputStream, epmOutputStream, monitor);
+
+ // Force a resync of the projects without allowing the user to cancel.
+ // This is probably unkind, but short of this there is no way to insure
+ // the UI is up-to-date with the build results
+ monitor.subTask(ManagedMakeMessages
+ .getResourceString(REFRESH));
+ try {
+ currentProject.refreshLocal(
+ IResource.DEPTH_INFINITE, null);
+ } catch (CoreException e) {
+ monitor.subTask(ManagedMakeMessages
+ .getResourceString(REFRESH_ERROR));
+ }
+
+ // Report either the success or failure of our mission
+ buf = new StringBuffer();
+
+ switch(status){
+ case IBuildModelBuilder.STATUS_OK:
+ buf.append(ManagedMakeMessages
+ .getFormattedString(BUILD_FINISHED,
+ currentProject.getName()));
+ break;
+ case IBuildModelBuilder.STATUS_CANCELLED:
+ buf.append(ManagedMakeMessages
+ .getResourceString(BUILD_CANCELLED));
+ break;
+ case IBuildModelBuilder.STATUS_ERROR_BUILD:
+ String msg = resumeOnErr ?
+ ManagedMakeMessages.getResourceString(BUILD_FINISHED_WITH_ERRS) :
+ ManagedMakeMessages.getResourceString(BUILD_STOPPED_ERR);
+ buf.append(msg);
+ break;
+ case IBuildModelBuilder.STATUS_ERROR_LAUNCH:
+ default:
+ buf.append(ManagedMakeMessages
+ .getResourceString(BUILD_FAILED_ERR));
+ break;
+ }
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
+
+ // Write message on the console
+ consoleOutStream.write(buf.toString().getBytes());
+ consoleOutStream.flush();
+ epmOutputStream.close();
+
+ // Generate any error markers that the build has discovered
+ monitor.subTask(ManagedMakeMessages
+ .getResourceString(MARKERS));
+ addBuilderMarkers(epm);
+ epm.reportProblems();
+ consoleOutStream.close();
+ } catch (Exception e) {
+ StringBuffer buf = new StringBuffer();
+ String errorDesc = ManagedMakeMessages
+ .getResourceString(BUILD_ERROR);
+ buf.append(errorDesc);
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
+ buf.append("(").append(e.getLocalizedMessage()).append(")"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ forgetLastBuiltState();
+ } finally {
+ getGenerationProblems().clear();
+ }
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties
index 03173c51c7..62249c1c28 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties
@@ -16,18 +16,24 @@ ManagedMakeBuilder.message.update.makefiles = Updating makefiles for project {0}
ManagedMakeBuilder.message.incremental = Updating makefiles for project {0}
ManagedMakeBuilder.message.updating = Updating project files...
ManagedMakeBuilder.message.make = Calling {0} for project {1}
+ManagedMakeBuilder.message.internal.builder = Internal Builder
ManagedMakeBuilder.message.regen.deps = Regenerating dependency files for {0}
ManagedMakeBuilder.message.updating.deps = Updating dependency files for {0}
ManagedMakeBuilder.message.creating.markers = Generating markers...
ManagedMakeBuilder.message.console.header = **** {0} of configuration {1} for project {2} ****
+ManagedMakeBuilder.message.internal.builder.header.note = **** Internal Builder is used for build ****\n**** NOTE: Internal Builder is experimental currently ****
ManagedMakeBuilder.message.no.build = Nothing to build for {0}
ManagedMakeBuilder.message.error = Build error
ManagedMakeBuilder.message.error.refresh = Error refreshing project
ManagedMakeBuilder.message.finished = Build complete for project {0}
+ManagedMakeBuilder.message.cancelled = Build cancelled
+ManagedMakeBuilder.message.finished.with.errs = Build completed with errors
+ManagedMakeBuilder.message.internal.builder.error = Build failed: Internal builder error occured
ManagedMakeBuilder.message.clean.deleting.output=Removing build artifacts from {0}
ManagedMakeBuilder.message.clean.build.clean=Trying a make clean in {0}
ManagedMakeBuilder.type.clean = Clean-only build
ManagedMakeBuider.type.incremental = Build
+ManagedMakeBuider.type.rebuild = Rebuild
ManagedMakeBuilder.warning.unsupported.configuration=**** WARNING: The "{0}" Configuration may not build ****\n**** because it uses the "{1}" ****\n**** tool-chain that is unsupported on this system. ****\n\n**** Attempting to build... ****
# Option exception messages

Back to the top