Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2003-07-25 10:40:04 -0400
committerDoug Schaefer2003-07-25 10:40:04 -0400
commit2ea02e19824f84f23cea8bf44b5fb3c02cd6f969 (patch)
treebf0949ee25515c415bcaadddc0df757a1627eaf2 /core/org.eclipse.cdt.core/build
parent196aedf3450b8a58d2b994847b61a40615233ee3 (diff)
downloadorg.eclipse.cdt-2ea02e19824f84f23cea8bf44b5fb3c02cd6f969.tar.gz
org.eclipse.cdt-2ea02e19824f84f23cea8bf44b5fb3c02cd6f969.tar.xz
org.eclipse.cdt-2ea02e19824f84f23cea8bf44b5fb3c02cd6f969.zip
Patch for Sean Evoy:
- Initial makefile generator for managed build.
Diffstat (limited to 'core/org.eclipse.cdt.core/build')
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IManagedBuildInfo.java51
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java76
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ManagedBuildInfo.java113
3 files changed, 197 insertions, 43 deletions
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IManagedBuildInfo.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IManagedBuildInfo.java
index 7684d41f98..baf3146f5c 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IManagedBuildInfo.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IManagedBuildInfo.java
@@ -23,6 +23,15 @@ public interface IManagedBuildInfo {
public void addTarget(ITarget target);
/**
+ * Answers <code>true</code> if the build system knows how to
+ * build a file with the extension passed in the argument.
+ *
+ * @param srcExt
+ * @return
+ */
+ public boolean buildsFileType(String srcExt);
+
+ /**
* Returns the name of the artifact to build for the receiver.
*
* @return
@@ -30,6 +39,21 @@ public interface IManagedBuildInfo {
public String getBuildArtifactName();
/**
+ * Answers the command needed to remove files on the build machine
+ *
+ * @return
+ */
+ public String getCleanCommand();
+
+ /**
+ * Answers the name of the default configuration, for example <code>Debug</code>
+ * or <code>Release</code>.
+ *
+ * @return
+ */
+ public String getConfigurationName();
+
+ /**
* Get the default configuration associated with the receiver
*
* @return
@@ -54,6 +78,16 @@ public interface IManagedBuildInfo {
public String getOutputExtension(String resourceExtension);
/**
+ * Answers the flag to be passed to the build tool to produce a specific output
+ * or an empty <code>String</code> if there is no special flag. For example, the
+ * GCC tools use the -o flag to produce a named output, for example
+ * gcc -c foo.c -o foo.o
+ *
+ * @return
+ */
+ public String getOutputFlag();
+
+ /**
* Get the target specified in the argument.
*
* @param id
@@ -89,6 +123,21 @@ public interface IManagedBuildInfo {
public String getFlagsForTarget(String extension);
/**
+ * Answers a string array containing the arguments to be passed to
+ * make. For example, if the user has selected a build that stops
+ * at the first error, the array would contain {"k"}.
+ *
+ * @return
+ */
+ public String[] getMakeArguments();
+
+ /**
+ * Answers a <code>String</code> containing the make command invocation
+ * for the default target/configuration.
+ */
+ public String getMakeCommand();
+
+ /**
* Returns a <code>String</code> containing the command-line invocation
* for the tool associated with the source extension.
*
@@ -120,5 +169,7 @@ public interface IManagedBuildInfo {
* @param target
*/
public void setDefaultTarget(ITarget target);
+
+
}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java
index 54d2e7920e..727b30681c 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java
@@ -328,6 +328,28 @@ public class ManagedBuildManager implements IScannerInfoProvider {
getExtensionTargetMap().put(target.getId(), target);
}
+ private static ManagedBuildInfo loadBuildInfo(IProject project) {
+ ManagedBuildInfo buildInfo = null;
+ IFile file = project.getFile(FILE_NAME);
+ if (!file.exists())
+ return null;
+
+ try {
+ InputStream stream = file.getContents();
+ DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document document = parser.parse(stream);
+ Node rootElement = document.getFirstChild();
+ if (rootElement.getNodeName().equals(ROOT_ELEM_NAME)) {
+ buildInfo = new ManagedBuildInfo(project, (Element)rootElement);
+ project.setSessionProperty(buildInfoProperty, buildInfo);
+ }
+ } catch (Exception e) {
+ buildInfo = null;
+ }
+
+ return buildInfo;
+ }
+
private static void loadExtensions() {
if (extensionTargetsLoaded)
return;
@@ -347,26 +369,37 @@ public class ManagedBuildManager implements IScannerInfoProvider {
}
}
- private static ManagedBuildInfo loadBuildInfo(IProject project) {
- ManagedBuildInfo buildInfo = null;
+ /**
+ * @param project
+ * @return
+ */
+ public static boolean manages(IResource resource) {
+ // The managed build manager manages build information for the
+ // resource IFF it it is a project and has a build file with the proper
+ // root element
+ IProject project = null;
+ if (resource instanceof IProject){
+ project = (IProject)resource;
+ } else if (resource instanceof IFile) {
+ project = ((IFile)resource).getProject();
+ } else {
+ return false;
+ }
IFile file = project.getFile(FILE_NAME);
- if (!file.exists())
- return null;
-
- try {
- InputStream stream = file.getContents();
- DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document document = parser.parse(stream);
- Node rootElement = document.getFirstChild();
- if (rootElement.getNodeName().equals(ROOT_ELEM_NAME)) {
- buildInfo = new ManagedBuildInfo(project, (Element)rootElement);
- project.setSessionProperty(buildInfoProperty, buildInfo);
+ if (file.exists()) {
+ try {
+ InputStream stream = file.getContents();
+ DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document document = parser.parse(stream);
+ Node rootElement = document.getFirstChild();
+ if (rootElement.getNodeName().equals(ROOT_ELEM_NAME)) {
+ return true;
+ }
+ } catch (Exception e) {
+ return false;
}
- } catch (Exception e) {
- buildInfo = null;
}
-
- return buildInfo;
+ return false;
}
private static ManagedBuildInfo findBuildInfo(IResource resource, boolean create) {
@@ -417,6 +450,11 @@ public class ManagedBuildManager implements IScannerInfoProvider {
* Answers with an interface to the parse information that has been
* associated with the resource specified in the argument.
*
+ * NOTE: This method is not part of the registration interface. It has
+ * been made public as a short-term workaround for the clients of the
+ * scanner information until the redesign of the build information management
+ * occurs.
+ *
* @param resource
* @return
*/
@@ -450,6 +488,9 @@ public class ManagedBuildManager implements IScannerInfoProvider {
}
}
+ // TODO Remove all of the IScannerInfoProvider interface methods when
+ // the discovery mechanism is solidified
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.IScannerInfoProvider#managesResource(org.eclipse.core.resources.IResource)
*/
@@ -504,4 +545,5 @@ public class ManagedBuildManager implements IScannerInfoProvider {
}
}
+
}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ManagedBuildInfo.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ManagedBuildInfo.java
index 04502ea575..3f6f451d67 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ManagedBuildInfo.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ManagedBuildInfo.java
@@ -88,6 +88,22 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
}
/* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#buildsFileType(java.lang.String)
+ */
+ public boolean buildsFileType(String srcExt) {
+ // Check to see if there is a rule to build a file with this extension
+ IConfiguration config = getDefaultConfiguration(getDefaultTarget());
+ ITool[] tools = config.getTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ if (tool.buildsFileType(srcExt)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IResourceBuildInfo#getBuildArtifactName()
*/
public String getBuildArtifactName() {
@@ -97,6 +113,23 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
}
/* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getCleanCommand()
+ */
+ public String getCleanCommand() {
+ // TODO Get from the model
+ return new String("rm -rf");
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getConfigurationName()
+ */
+ public String getConfigurationName() {
+ // Return the human-readable name of the default configuration
+ IConfiguration config = getDefaultConfiguration(getDefaultTarget());
+ return config == null ? new String() : config.getName();
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IResourceBuildInfo#getDefaultConfiguration()
*/
public IConfiguration getDefaultConfiguration(ITarget target) {
@@ -169,6 +202,51 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
}
/* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IScannerInfo#getIncludePaths()
+ */
+ public String[] getIncludePaths() {
+ // Return the include paths for the default configuration
+ ArrayList paths = new ArrayList();
+ IConfiguration config = getDefaultConfiguration(getDefaultTarget());
+ ITool[] tools = config.getTools();
+ for (int i = 0; i < tools.length; i++) {
+ ITool tool = tools[i];
+ IOption[] opts = tool.getOptions();
+ for (int j = 0; j < opts.length; j++) {
+ IOption option = opts[j];
+ if (option.getValueType() == IOption.INCLUDE_PATH) {
+ try {
+ paths.addAll(Arrays.asList(option.getIncludePaths()));
+ } catch (BuildException e) {
+ // we should never get here
+ continue;
+ }
+ }
+ }
+ }
+ paths.trimToSize();
+ return (String[])paths.toArray(new String[paths.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getMakeArguments()
+ */
+ public String[] getMakeArguments() {
+ // TODO Stop hard-coding this
+ String[] args = {""};
+
+ return args;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getMakeCommand()
+ */
+ public String getMakeCommand() {
+ // TODO Don't hard-code this
+ return new String("make");
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IResourceBuildInfo#getOutputExtension(java.lang.String)
*/
public String getOutputExtension(String resourceExtension) {
@@ -185,6 +263,15 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
return null;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getOutputFlag()
+ */
+ public String getOutputFlag() {
+ // TODO Stop hard-coding this
+ String flag = new String("-o");
+ return flag;
+ }
+
public IResource getOwner() {
return owner;
}
@@ -319,31 +406,5 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
return symbols;
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IScannerInfo#getIncludePaths()
- */
- public String[] getIncludePaths() {
- // Return the include paths for the default configuration
- ArrayList paths = new ArrayList();
- IConfiguration config = getDefaultConfiguration(getDefaultTarget());
- ITool[] tools = config.getTools();
- for (int i = 0; i < tools.length; i++) {
- ITool tool = tools[i];
- IOption[] opts = tool.getOptions();
- for (int j = 0; j < opts.length; j++) {
- IOption option = opts[j];
- if (option.getValueType() == IOption.INCLUDE_PATH) {
- try {
- paths.addAll(Arrays.asList(option.getIncludePaths()));
- } catch (BuildException e) {
- // we should never get here
- continue;
- }
- }
- }
- }
- paths.trimToSize();
- return (String[])paths.toArray(new String[paths.size()]);
- }
}

Back to the top