[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Discrete Custom Build Step core support patch
|
Title: Discrete Custom Build Step core support patch
This is a patch which implements the "core" of the Discrete Custom Build Support, i.e.
"pre-build" and "post-build" functionality, in the Managed Build System as described in the
Custom Build Step documentation:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=88922.
The user interface support for this functionality is forthcoming.
Bob Monteleone
Intel Corporation
Nashua Software Lab
603-886-7665
Index: schema/buildDefinitions.exsd
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.core/schema/buildDefinitions.exsd,v
retrieving revision 1.4
diff -u -r1.4 buildDefinitions.exsd
--- schema/buildDefinitions.exsd 18 Feb 2005 19:35:32 -0000 1.4
+++ schema/buildDefinitions.exsd 11 Apr 2005 19:47:49 -0000
@@ -188,6 +188,34 @@
</documentation>
</annotation>
</attribute>
+ <attribute name="prebuildStep" type="string">
+ <annotation>
+ <documentation>
+ Specifies the pre-build command, which runs prior to the standard MBS build.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="postbuildStep" type="string">
+ <annotation>
+ <documentation>
+ Specifies the post-build command, which runs after the standard MBS build.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="preannouncebuildStep" type="string">
+ <annotation>
+ <documentation>
+ Specifies the string to be displayed when the pre-build command step is run.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="postannouncebuildStep" type="string">
+ <annotation>
+ <documentation>
+ Specifies the string to be displayed when the post-build command step is run.
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
Index: src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java,v
retrieving revision 1.10
diff -u -r1.10 IConfiguration.java
--- src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java 28 Oct 2004 17:16:53 -0000 1.10
+++ src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java 11 Apr 2005 19:47:49 -0000
@@ -28,6 +28,10 @@
public interface IConfiguration extends IBuildObject {
public static final String ARTIFACT_NAME = "artifactName"; //$NON-NLS-1$
public static final String CLEAN_COMMAND = "cleanCommand"; //$NON-NLS-1$
+ public static final String PREBUILD_STEP = "prebuildStep"; //$NON-NLS-1$
+ public static final String POSTBUILD_STEP = "postbuildStep"; //$NON-NLS-1$
+ public static final String PREANNOUNCEBUILD_STEP = "preannouncebuildStep"; //$NON-NLS-1$
+ public static final String POSTANNOUNCEBUILD_STEP = "postannouncebuildStep"; //$NON-NLS-1$
// Schema element names
public static final String CONFIGURATION_ELEMENT_NAME = "configuration"; //$NON-NLS-1$
public static final String ERROR_PARSERS = "errorParsers"; //$NON-NLS-1$
@@ -83,6 +87,34 @@
public String getBuildCommand();
/**
+ * Returns the prebuild step from this configuration's builder
+ *
+ * @return String
+ */
+ public String getPrebuildStep();
+
+ /**
+ * Returns the postbuild step from this configuration's builder
+ *
+ * @return String
+ */
+ public String getPostbuildStep();
+
+ /**
+ * Returns the display string associated with the prebuild step from this configuration's builder
+ *
+ * @return String
+ */
+ public String getPreannouncebuildStep();
+
+ /**
+ * Returns the display string associated with the postbuild step from this configuration's builder
+ *
+ * @return String
+ */
+ public String getPostannouncebuildStep();
+
+ /**
* Answers the OS-specific command to remove files created by the build
* of this configuration.
*
@@ -266,6 +298,34 @@
public void setBuildCommand(String command);
/**
+ * Sets the prebuild step for the receiver to the value in the argument.
+ *
+ * @param step
+ */
+ public void setPrebuildStep(String step);
+
+ /**
+ * Sets the postbuild step for the receiver to the value in the argument.
+ *
+ * @param step
+ */
+ public void setPostbuildStep(String step);
+
+ /**
+ * Sets the prebuild step display string for the receiver to the value in the argument.
+ *
+ * @param announceStep
+ */
+ public void setPreannouncebuildStep(String announceStep);
+
+ /**
+ * Sets the postbuild step display string for the receiver to the value in the argument.
+ *
+ * @param announceStep
+ */
+ public void setPostannouncebuildStep(String announceStep);
+
+ /**
* Sets the command used to clean the outputs of this configuration.
*
* @param name
Index: src/org/eclipse/cdt/managedbuilder/core/IManagedBuildInfo.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedBuildInfo.java,v
retrieving revision 1.15
diff -u -r1.15 IManagedBuildInfo.java
--- src/org/eclipse/cdt/managedbuilder/core/IManagedBuildInfo.java 8 Nov 2004 20:12:37 -0000 1.15
+++ src/org/eclipse/cdt/managedbuilder/core/IManagedBuildInfo.java 11 Apr 2005 19:47:50 -0000
@@ -97,6 +97,33 @@
public String getBuildCommand();
/**
+ * Answers the prebuild step for the default configuration
+ *
+ * @return String
+ */
+ public String getPrebuildStep();
+
+ /**
+ * Answers the postbuild step for the default configuration
+ *
+ * @return String
+ */
+ public String getPostbuildStep();
+
+ /**
+ * Answers the display string associated with the prebuild step for the default configuration
+ *
+ * @return String
+ */
+ public String getPreannouncebuildStep();
+
+ /**
+ * Answers the display string associated with the postbuild step for the default configuration
+ *
+ * @return String
+ */
+ public String getPostannouncebuildStep();
+ /**
* Answers the command needed to remove files on the build machine
*
* @return
Index: src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java,v
retrieving revision 1.21
diff -u -r1.21 Configuration.java
--- src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java 15 Nov 2004 19:33:07 -0000 1.21
+++ src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java 11 Apr 2005 19:47:52 -0000
@@ -60,6 +60,10 @@
private String cleanCommand;
private String artifactExtension;
private String errorParserIds;
+ private String prebuildStep;
+ private String postbuildStep;
+ private String preannouncebuildStep;
+ private String postannouncebuildStep;
// Miscellaneous
private boolean isExtensionConfig = false;
private boolean isDirty = false;
@@ -225,6 +229,18 @@
if (cloneConfig.errorParserIds != null) {
errorParserIds = new String(cloneConfig.errorParserIds);
}
+ if (cloneConfig.prebuildStep != null) {
+ prebuildStep = new String(cloneConfig.prebuildStep);
+ }
+ if (cloneConfig.postbuildStep != null) {
+ postbuildStep = new String(cloneConfig.postbuildStep);
+ }
+ if (cloneConfig.preannouncebuildStep != null) {
+ preannouncebuildStep = new String(cloneConfig.preannouncebuildStep);
+ }
+ if (cloneConfig.postannouncebuildStep != null) {
+ postannouncebuildStep = new String(cloneConfig.postannouncebuildStep);
+ }
// Clone the configuration's children
// Tool Chain
@@ -316,6 +332,14 @@
// Get the clean command
cleanCommand = element.getAttribute(CLEAN_COMMAND);
+
+ // Get the pre-build and post-build commands
+ prebuildStep = element.getAttribute(PREBUILD_STEP);
+ postbuildStep = element.getAttribute(POSTBUILD_STEP);
+
+ // Get the pre-build and post-build announcements
+ preannouncebuildStep = element.getAttribute(PREANNOUNCEBUILD_STEP);
+ postannouncebuildStep = element.getAttribute(POSTANNOUNCEBUILD_STEP);
}
/* (non-Javadoc)
@@ -362,6 +386,24 @@
if (element.hasAttribute(CLEAN_COMMAND)) {
cleanCommand = element.getAttribute(CLEAN_COMMAND);
}
+
+ // Get the pre-build and post-build commands
+ if (element.hasAttribute(PREBUILD_STEP)) {
+ prebuildStep = element.getAttribute(PREBUILD_STEP);
+ }
+
+ if (element.hasAttribute(POSTBUILD_STEP)) {
+ postbuildStep = element.getAttribute(POSTBUILD_STEP);
+ }
+
+ // Get the pre-build and post-build announcements
+ if (element.hasAttribute(PREANNOUNCEBUILD_STEP)) {
+ preannouncebuildStep = element.getAttribute(PREANNOUNCEBUILD_STEP);
+ }
+
+ if (element.hasAttribute(POSTANNOUNCEBUILD_STEP)) {
+ postannouncebuildStep = element.getAttribute(POSTANNOUNCEBUILD_STEP);
+ }
}
/**
@@ -390,6 +432,18 @@
if (cleanCommand != null)
element.setAttribute(CLEAN_COMMAND, cleanCommand);
+
+ if (prebuildStep != null)
+ element.setAttribute(PREBUILD_STEP, prebuildStep);
+
+ if (postbuildStep != null)
+ element.setAttribute(POSTBUILD_STEP, postbuildStep);
+
+ if (preannouncebuildStep != null)
+ element.setAttribute(PREANNOUNCEBUILD_STEP, preannouncebuildStep);
+
+ if (postannouncebuildStep != null)
+ element.setAttribute(POSTANNOUNCEBUILD_STEP, postannouncebuildStep);
// Serialize my children
Element toolChainElement = doc.createElement(IToolChain.TOOL_CHAIN_ELEMENT_NAME);
@@ -784,6 +838,74 @@
}
/* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getPrebuildStep()
+ */
+ public String getPrebuildStep() {
+ if (prebuildStep == null) {
+ // If I have a parent, ask it
+ if (parent != null) {
+ return parent.getPrebuildStep();
+ } else {
+ // I'm it
+ return EMPTY_STRING;
+ }
+ } else {
+ return prebuildStep;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getPostbuildStep()
+ */
+ public String getPostbuildStep() {
+ if (postbuildStep == null) {
+ // If I have a parent, ask it
+ if (parent != null) {
+ return parent.getPostbuildStep();
+ } else {
+ // I'm it
+ return EMPTY_STRING;
+ }
+ } else {
+ return postbuildStep;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getPreannouncebuildStep()
+ */
+ public String getPreannouncebuildStep() {
+ if (preannouncebuildStep == null) {
+ // If I have a parent, ask it
+ if (parent != null) {
+ return parent.getPreannouncebuildStep();
+ } else {
+ // I'm it
+ return EMPTY_STRING;
+ }
+ } else {
+ return preannouncebuildStep;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getPostannouncebuildStep()
+ */
+ public String getPostannouncebuildStep() {
+ if (postannouncebuildStep == null) {
+ // If I have a parent, ask it
+ if (parent != null) {
+ return parent.getPostannouncebuildStep();
+ } else {
+ // I'm it
+ return EMPTY_STRING;
+ }
+ } else {
+ return postannouncebuildStep;
+ }
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getCleanCommand()
*/
public String getCleanCommand() {
@@ -928,8 +1050,56 @@
}
builder.setCommand(command);
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#setPrebuildStep(java.lang.String)
+ */
+ public void setPrebuildStep(String step) {
+ if (step == null && prebuildStep == null) return;
+ if (prebuildStep == null || step == null || !prebuildStep.equals(step)) {
+ prebuildStep = step;
+ setRebuildState(true);
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#setPostbuildStep(java.lang.String)
+ */
+ public void setPostbuildStep(String step) {
+ if (step == null && postbuildStep == null) return;
+ if (postbuildStep == null || step == null || !postbuildStep.equals(step)) {
+ postbuildStep = step;
+ setRebuildState(true);
+ isDirty = true;
+ }
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#setPreannouncebuildStep(java.lang.String)
+ */
+ public void setPreannouncebuildStep(String announceStep) {
+ if (announceStep == null && preannouncebuildStep == null) return;
+ if (preannouncebuildStep == null || announceStep == null || !preannouncebuildStep.equals(announceStep)) {
+ preannouncebuildStep = announceStep;
+ setRebuildState(true);
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#setPostannouncebuildStep(java.lang.String)
+ */
+ public void setPostannouncebuildStep(String announceStep) {
+ if (announceStep == null && postannouncebuildStep == null) return;
+ if (postannouncebuildStep == null || announceStep == null || !postannouncebuildStep.equals(announceStep)) {
+ postannouncebuildStep = announceStep;
+ setRebuildState(true);
+ isDirty = true;
+ }
+ }
+
/*
* O B J E C T S T A T E M A I N T E N A N C E
*/
Index: src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java,v
retrieving revision 1.34
diff -u -r1.34 GeneratedMakefileBuilder.java
--- src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java 28 Jan 2005 03:35:20 -0000 1.34
+++ src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java 11 Apr 2005 19:47:53 -0000
@@ -29,6 +29,7 @@
import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.core.resources.ACBuilder;
import org.eclipse.cdt.core.resources.IConsole;
+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.makegen.IManagedBuilderMakefileGenerator;
@@ -431,6 +432,7 @@
/* (non-javadoc)
* Answers an array of strings with the proper make targets
+ * for a build with no custom prebuild/postbuild steps
*
* @param fullBuild
* @return
@@ -541,9 +543,10 @@
}
/* (non-Javadoc)
- * @param fullBuild
+ * @param buildType
* @param buildDir
* @param info
+ * @param generator
* @param monitor
*/
protected void invokeMake(int buildType, IPath buildDir, IManagedBuildInfo info, IManagedBuilderMakefileGenerator generator, IProgressMonitor monitor) {
@@ -606,18 +609,6 @@
// Remove all markers for this project
removeAllMarkers(currentProject);
-
- // Get the arguments to be passed to make from build model
- ArrayList makeArgs = new ArrayList();
- String arg = info.getBuildArguments();
- if (arg.length() > 0) {
- String[] args = arg.split("\\s"); //$NON-NLS-1$
- for (int i = 0; i < args.length; ++i) {
- makeArgs.add(args[i]);
- }
- }
- makeArgs.addAll(Arrays.asList(getMakeTargets(buildType)));
- String[] makeTargets = (String[]) makeArgs.toArray(new String[makeArgs.size()]);
// Get a launcher for the make command
String errMsg = null;
@@ -646,58 +637,153 @@
OutputStream stdout = epm.getOutputStream();
OutputStream stderr = epm.getOutputStream();
- // Launch make
- Process proc = launcher.execute(makeCommand, makeTargets, env, workingDirectory);
- if (proc != null) {
- try {
- // Close the input of the process since we will never write to it
- proc.getOutputStream().close();
- } catch (IOException e) {
+ // Get the arguments to be passed to make from build model
+ ArrayList makeArgs = new ArrayList();
+ String arg = info.getBuildArguments();
+ if (arg.length() > 0) {
+ String[] args = arg.split("\\s"); //$NON-NLS-1$
+ for (int i = 0; i < args.length; ++i) {
+ makeArgs.add(args[i]);
}
+ }
- if (launcher.waitAndRead(stdout, stderr, new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN)) != CommandLauncher.OK) {
- errMsg = launcher.getErrorMessage();
- }
+ String[] makeTargets;
+ String prebuildStep = info.getPrebuildStep();
+ boolean prebuildStepPresent = (prebuildStep.length() > 0);
+ Process proc = null;
+ boolean isuptodate = false;
- // 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));
+ if (prebuildStepPresent) {
+ ArrayList premakeArgs = (ArrayList)makeArgs.clone();
+ String[] premakeTargets;
+ switch (buildType) {
+ case INCREMENTAL_BUILD: {
+ // For an incremental build with a prebuild step:
+ // Check the status of the main build with "make -q main-build"
+ // If up to date:
+ // then: don't invoke the prebuild step, which should be run only if
+ // something needs to be built in the main build
+ // else: invoke the prebuild step and the main build step
+ boolean quit = false;
+ premakeArgs.add("-q"); //$NON-NLS-1$
+ premakeArgs.add("main-build"); //$NON-NLS-1$
+ premakeTargets = (String[]) premakeArgs.toArray(new String[premakeArgs.size()]);
+ proc = launcher.execute(makeCommand, premakeTargets, env, workingDirectory);
+ if (proc != null) {
+ try {
+ // Close the input of the process since we will never write to it
+ proc.getOutputStream().close();
+ } catch (IOException e) {
+ }
+ if (launcher.waitAndRead(stdout, stderr, new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN)) != CommandLauncher.OK) {
+ errMsg = launcher.getErrorMessage();
+ }
+ } else {
+ errMsg = launcher.getErrorMessage();
+ }
+
+ if ((errMsg != null && errMsg.length() > 0) || proc == null) {
+ // Can't tell if the build is needed, so assume it is, and let any errors be triggered
+ // when the "real" build is invoked below
+ makeArgs.add("pre-build"); //$NON-NLS-1$
+ makeArgs.add("main-build"); //$NON-NLS-1$
+ } else {
+ // The "make -q" command launch was successful
+ if (proc.exitValue() == 0) {
+ // If the status value returned from "make -q" is 0, then the build state is up-to-date
+ isuptodate = true;
+ // Report that the build was up to date, and thus nothing needs to be built
+ String uptodateMsg = ManagedMakeMessages.getFormattedString(NOTHING_BUILT, currentProject.getName());
+ buf.append(uptodateMsg);
+ 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();
+ consoleOutStream.close();
+ stdout.close();
+ stderr.close();
+ } else {
+ // The status value was other than 0, so press on with the build process
+ makeArgs.add("pre-build"); //$NON-NLS-1$
+ makeArgs.add("main-build"); //$NON-NLS-1$
+ }
+ }
+ break;
+ }
+ case FULL_BUILD: {
+ makeArgs.add("clean"); //$NON-NLS-1$
+ makeArgs.add("pre-build"); //$NON-NLS-1$
+ makeArgs.add("main-build"); //$NON-NLS-1$
+ break;
+ }
+ case CLEAN_BUILD: {
+ makeArgs.add("clean"); //$NON-NLS-1$
+ break;
+ }
}
+
} else {
- errMsg = launcher.getErrorMessage();
+ // No prebuild step
+ //
+ makeArgs.addAll(Arrays.asList(getMakeTargets(buildType)));
}
+
+ makeTargets = (String[]) makeArgs.toArray(new String[makeArgs.size()]);
- // Report either the success or failure of our mission
- buf = new StringBuffer();
- if (errMsg != null && errMsg.length() > 0) {
- 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(errMsg).append(")"); //$NON-NLS-1$ //$NON-NLS-2$
- } else {
- // Report a successful build
- String successMsg = ManagedMakeMessages.getFormattedString(BUILD_FINISHED, currentProject.getName());
- buf.append(successMsg);
- 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();
- stdout.close();
- stderr.close();
-
- // Generate any error markers that the build has discovered
- monitor.subTask(ManagedMakeMessages.getResourceString(MARKERS));
- addBuilderMarkers(epm);
- epm.reportProblems();
- consoleOutStream.close();
- }
+ // Launch make - main invocation
+ if (!isuptodate) {
+ proc = launcher.execute(makeCommand, makeTargets, env, workingDirectory);
+ if (proc != null) {
+ try {
+ // Close the input of the process since we will never write to it
+ proc.getOutputStream().close();
+ } catch (IOException e) {
+ }
+
+ if (launcher.waitAndRead(stdout, stderr, new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN)) != CommandLauncher.OK) {
+ errMsg = launcher.getErrorMessage();
+ }
+
+ // 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));
+ }
+ } else {
+ errMsg = launcher.getErrorMessage();
+ }
+
+ // Report either the success or failure of our mission
+ buf = new StringBuffer();
+ if (errMsg != null && errMsg.length() > 0) {
+ 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(errMsg).append(")"); //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ // Report a successful build
+ String successMsg = ManagedMakeMessages.getFormattedString(BUILD_FINISHED, currentProject.getName());
+ buf.append(successMsg);
+ 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();
+ stdout.close();
+ stderr.close();
+
+ // Generate any error markers that the build has discovered
+ monitor.subTask(ManagedMakeMessages.getResourceString(MARKERS));
+ addBuilderMarkers(epm);
+ epm.reportProblems();
+ consoleOutStream.close();
+ }
+ }
} catch (Exception e) {
forgetLastBuiltState();
} finally {
Index: src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java,v
retrieving revision 1.32
diff -u -r1.32 ManagedBuildInfo.java
--- src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java 28 Jan 2005 03:36:33 -0000 1.32
+++ src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java 11 Apr 2005 19:47:56 -0000
@@ -515,6 +515,58 @@
}
/* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getPrebuildStep()
+ */
+ public String getPrebuildStep() {
+ // Get the default configuration and use its value
+ String name = new String();
+ IConfiguration config = getDefaultConfiguration();
+ if (config != null) {
+ name = config.getPrebuildStep();
+ }
+ return name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getPostbuildStep()
+ */
+ public String getPostbuildStep() {
+ // Get the default configuration and use its value
+ String name = new String();
+ IConfiguration config = getDefaultConfiguration();
+ if (config != null) {
+ name = config.getPostbuildStep();
+ }
+ return name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getPreannouncebuildStep()
+ */
+ public String getPreannouncebuildStep() {
+ // Get the default configuration and use its value
+ String name = new String();
+ IConfiguration config = getDefaultConfiguration();
+ if (config != null) {
+ name = config.getPreannouncebuildStep();
+ }
+ return name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getPostannouncebuildStep()
+ */
+ public String getPostannouncebuildStep() {
+ // Get the default configuration and use its value
+ String name = new String();
+ IConfiguration config = getDefaultConfiguration();
+ if (config != null) {
+ name = config.getPostannouncebuildStep();
+ }
+ return name;
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getOutputExtension(java.lang.String)
*/
public String getOutputExtension(String resourceExtension) {
Index: src/org/eclipse/cdt/managedbuilder/makegen/IManagedBuilderMakefileGenerator.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedBuilderMakefileGenerator.java,v
retrieving revision 1.5
diff -u -r1.5 IManagedBuilderMakefileGenerator.java
--- src/org/eclipse/cdt/managedbuilder/makegen/IManagedBuilderMakefileGenerator.java 26 Jun 2004 21:13:07 -0000 1.5
+++ src/org/eclipse/cdt/managedbuilder/makegen/IManagedBuilderMakefileGenerator.java 11 Apr 2005 19:47:57 -0000
@@ -28,9 +28,11 @@
public final String COLON = ":"; //$NON-NLS-1$
public final int COLS_PER_LINE = 80;
public final String COMMENT_SYMBOL = "#"; //$NON-NLS-1$
+ public final String DOLLAR_SYMBOL = "$"; //$NON-NLS-1$
public final String DEP_EXT = "d"; //$NON-NLS-1$
public final String DEPFILE_NAME = "subdir.dep"; //$NON-NLS-1$
public final String DOT = "."; //$NON-NLS-1$
+ public final String DASH = "-"; //$NON-NLS-1$
public final String ECHO = "echo"; //$NON-NLS-1$
public final String IN_MACRO = "$<"; //$NON-NLS-1$
public final String LINEBREAK = "\\\n"; //$NON-NLS-1$
@@ -39,6 +41,8 @@
public final String MAKEFILE_INIT = "makefile.init"; //$NON-NLS-1$
public final String MAKEFILE_NAME = "makefile"; //$NON-NLS-1$
public final String MAKEFILE_TARGETS = "makefile.targets"; //$NON-NLS-1$
+ public final String MAKE = "$(MAKE)"; //$NON-NLS-1$
+ public final String NO_PRINT_DIR = "--no-print-directory"; //$NON-NLS-1$
public final String MODFILE_NAME = "subdir.mk"; //$NON-NLS-1$
public final String NEWLINE = System.getProperty("line.separator"); //$NON-NLS-1$
Index: src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java,v
retrieving revision 1.30
diff -u -r1.30 GnuMakefileGenerator.java
--- src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java 28 Jan 2005 20:44:37 -0000 1.30
+++ src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java 11 Apr 2005 19:47:59 -0000
@@ -601,6 +601,15 @@
String flags = info.getFlagsForConfiguration(extension);
String outflag = info.getOutputFlag(extension);
String outputPrefix = info.getOutputPrefix(extension);
+ String prebuildStep = info.getPrebuildStep();
+ prebuildStep.trim(); // Remove leading and trailing whitespace (and control characters)
+ String postbuildStep = info.getPostbuildStep();
+ postbuildStep.trim(); // Remove leading and trailing whitespace (and control characters)
+ String preannouncebuildStep = info.getPreannouncebuildStep();
+ String postannouncebuildStep = info.getPostannouncebuildStep();
+ String prebuild = "pre-build"; //$NON-NLS-1$
+ String mainbuild = "main-build"; //$NON-NLS-1$
+ String postbuild = "post-build"; //$NON-NLS-1$
String targets = rebuild ? "clean all" : "all"; //$NON-NLS-1$ //$NON-NLS-2$
// Get all the projects the build target depends on
@@ -612,9 +621,30 @@
// and neither conditions apply if we are building for it ....
}
- // Write out the all target first in case someone just runs make
- // all: targ_<target_name>
+ // If a prebuild step exists, redefine the all target to be
+ // all: {pre-build} main-build
+ // and then reset the "traditional" all target to main-build
+ // This will allow something meaningful to happen if the generated makefile is
+ // extracted and run standalone via "make all"
+ //
String defaultTarget = "all:"; //$NON-NLS-1$
+ if (prebuildStep.length() > 0) {
+
+ buffer.append(defaultTarget + WHITESPACE);
+ buffer.append(prebuild + WHITESPACE);
+
+ // Reset defaultTarget for now and for subsequent use, below
+ defaultTarget = mainbuild;
+ buffer.append(defaultTarget);
+
+ // Update the defaultTarget, main-build, by adding a colon, which is needed below
+ defaultTarget = defaultTarget.concat(COLON);
+ buffer.append(NEWLINE + NEWLINE);
+ }
+
+ // Write out the all target first in case someone just runs make
+ // all: <target_name> or mainbuild: <target_name>
+
buffer.append(defaultTarget + WHITESPACE + outputPrefix + buildTargetName);
if (extension.length() > 0) {
buffer.append(DOT + extension);
@@ -671,7 +701,7 @@
* @echo 'Building target: $@'
* $(BUILD_TOOL) $(FLAGS) $(OUTPUT_FLAG)$@ $(OBJS) $(USER_OBJS) $(LIB_DEPS)
* @echo 'Finished building: $@'
- * @echo
+ * $(MAKE) --no-print-directory post-build //if postbuild step present
*/
buffer.append(outputPrefix + buildTargetName);
if (extension.length() > 0) {
@@ -685,7 +715,17 @@
buffer.append(NEWLINE);
buffer.append(TAB + AT + ECHO + WHITESPACE + SINGLE_QUOTE + MESSAGE_START_BUILD + WHITESPACE + OUT_MACRO + SINGLE_QUOTE + NEWLINE);
buffer.append(TAB + cmd + WHITESPACE + flags + WHITESPACE + outflag + WHITESPACE + OUT_MACRO + WHITESPACE + "$(OBJS) $(USER_OBJS) $(LIBS)" + NEWLINE); //$NON-NLS-1$
- buffer.append(TAB + AT + ECHO + WHITESPACE + SINGLE_QUOTE + MESSAGE_FINISH_FILE + WHITESPACE + OUT_MACRO + SINGLE_QUOTE + NEWLINE + NEWLINE);
+ buffer.append(TAB + AT + ECHO + WHITESPACE + SINGLE_QUOTE + MESSAGE_FINISH_FILE + WHITESPACE + OUT_MACRO + SINGLE_QUOTE + NEWLINE);
+
+ // If there is a post build step, then add a recursive invocation of MAKE to invoke it after the main build
+ // Note that $(MAKE) will instantiate in the recusive invocation to the make command that was used to invoke
+ // the makefile originally
+ if (postbuildStep.length() > 0) {
+ buffer.append(TAB + AT + ECHO + WHITESPACE + SINGLE_QUOTE + WHITESPACE + SINGLE_QUOTE + NEWLINE);
+ buffer.append(TAB + MAKE + WHITESPACE + NO_PRINT_DIR + WHITESPACE + postbuild + NEWLINE);
+ }
+
+ buffer.append(NEWLINE);
// Always add a clean target
buffer.append("clean:" + NEWLINE); //$NON-NLS-1$
@@ -693,10 +733,38 @@
if (extension.length() > 0) {
buffer.append(DOT + extension);
}
- buffer.append(NEWLINE + NEWLINE);
+ buffer.append(NEWLINE);
+ buffer.append(TAB + DASH + AT + ECHO + WHITESPACE + SINGLE_QUOTE + WHITESPACE + SINGLE_QUOTE + NEWLINE + NEWLINE);
+ // Add the prebuild step target, if specified
+ if (prebuildStep.length() > 0) {
+ buffer.append(prebuild + COLON + NEWLINE);
+ if (preannouncebuildStep.length() > 0) {
+ buffer.append(TAB + DASH + AT + ECHO + WHITESPACE + SINGLE_QUOTE + preannouncebuildStep + SINGLE_QUOTE + NEWLINE);
+ }
+ buffer.append(TAB + DASH + prebuildStep + NEWLINE);
+ buffer.append(TAB + DASH + AT + ECHO + WHITESPACE + SINGLE_QUOTE + WHITESPACE + SINGLE_QUOTE + NEWLINE + NEWLINE);
+ }
+
+ // Add the postbuild step, if specified
+ if (postbuildStep.length() > 0) {
+ buffer.append(postbuild + COLON + NEWLINE);
+ if (postannouncebuildStep.length() > 0) {
+ buffer.append(TAB + DASH + AT + ECHO + WHITESPACE + SINGLE_QUOTE + postannouncebuildStep + SINGLE_QUOTE + NEWLINE);
+ }
+ buffer.append(TAB + DASH + postbuildStep + NEWLINE);
+ buffer.append(TAB + DASH + AT + ECHO + WHITESPACE + SINGLE_QUOTE + WHITESPACE + SINGLE_QUOTE + NEWLINE + NEWLINE);
+ }
+
// Add all the eneded dummy and phony targets
- buffer.append(".PHONY: all clean dependents" + NEWLINE); //$NON-NLS-1$
+ buffer.append(".PHONY: all clean dependents"); //$NON-NLS-1$
+ if (prebuildStep.length() > 0) {
+ buffer.append(WHITESPACE + mainbuild + WHITESPACE + prebuild);
+ }
+ if (postbuildStep.length() > 0) {
+ buffer.append(WHITESPACE + postbuild);
+ }
+ buffer.append (NEWLINE);
refIter = managedProjectOutputs.listIterator();
while(refIter.hasNext()) {
buffer.append((String)refIter.next() + COLON + NEWLINE);