summaryrefslogtreecommitdiffstats
path: root/org.rtems.cdt
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2009-02-06 14:21:18 +0000
committerSebastian Huber <sebastian.huber@embedded-brains.de>2009-02-06 14:21:18 +0000
commitebe332a175fd3af80c4ca47084bdaf80cc7adb7a (patch)
tree3b05cf42f1b3402bc04f23e79ea74bb472c9bf04 /org.rtems.cdt
parentNew version 1.0.1. (diff)
downloadrtems-eclipse-plug-in-ebe332a175fd3af80c4ca47084bdaf80cc7adb7a.tar.bz2
Added problem markers.
Initialize tools with default values on platform change.
Diffstat (limited to 'org.rtems.cdt')
-rw-r--r--org.rtems.cdt/src/org/rtems/cdt/Constants.java2
-rw-r--r--org.rtems.cdt/src/org/rtems/cdt/Storage.java73
2 files changed, 67 insertions, 8 deletions
diff --git a/org.rtems.cdt/src/org/rtems/cdt/Constants.java b/org.rtems.cdt/src/org/rtems/cdt/Constants.java
index a991a9c..3a97a6b 100644
--- a/org.rtems.cdt/src/org/rtems/cdt/Constants.java
+++ b/org.rtems.cdt/src/org/rtems/cdt/Constants.java
@@ -93,6 +93,8 @@ public class Constants {
public static final String TOOL_OPTIONS_LINKER_CPP_KEY = TOOL_LINKER_CPP_KEY + TOOL_OPTIONS_KEY_POSTFIX;
+ public static final String MARKER_ID_TOOL_DISCOVERY = "tool discovery";
+
private static String getPathVariableName() {
Map<String, String> env = System.getenv();
for (String name : env.keySet()) {
diff --git a/org.rtems.cdt/src/org/rtems/cdt/Storage.java b/org.rtems.cdt/src/org/rtems/cdt/Storage.java
index a71de94..93078c5 100644
--- a/org.rtems.cdt/src/org/rtems/cdt/Storage.java
+++ b/org.rtems.cdt/src/org/rtems/cdt/Storage.java
@@ -38,7 +38,9 @@ import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
@@ -198,7 +200,19 @@ public class Storage {
private static void updateTools( IProject project, String platform) {
String bspPath = getProperty( project, Constants.BSP_PATH_KEY);
IPath make = new Path( "make");
-
+ List<String> options = new LinkedList<String>();
+
+ // Set tools to default values
+ updateTool( project, Constants.TOOL_ARCHIVER_KEY, "ar", options);
+ updateTool( project, Constants.TOOL_ASSEMBLER_KEY, "as", options);
+ updateTool( project, Constants.TOOL_COMPILER_CPP_KEY, "g++", options);
+ updateTool( project, Constants.TOOL_COMPILER_C_KEY, "gcc", options);
+ updateTool( project, Constants.TOOL_LINKER_CPP_KEY, "g++", options);
+ updateTool( project, Constants.TOOL_LINKER_C_KEY, "gcc", options);
+
+ // Delete markers for this unit
+ deleteMarkers( project, Constants.MARKER_ID_TOOL_DISCOVERY);
+
// Translate path if necessary
if (Platform.getOS().equals( Platform.OS_WIN32)) {
if (platform.equals( Constants.PLATFORM_CYGWIN)) {
@@ -251,7 +265,6 @@ public class Storage {
String line = br.readLine();
String key = null;
String command = null;
- List<String> options = new LinkedList<String>();
int state = EXPECT_KEY;
while (line != null) {
switch (state) {
@@ -268,7 +281,7 @@ public class Storage {
command = line.substring( 1);
state = EXPECT_OPTION;
} else {
- throw new IOException( "Unexpected line format");
+ throw new IOException( "unexpected line format");
}
break;
case EXPECT_KEY:
@@ -276,16 +289,16 @@ public class Storage {
key = line;
state = EXPECT_COMMAND;
} else {
- throw new IOException( "Unexpected line format");
+ throw new IOException( "unexpected line format");
}
break;
case TOOL_COMPLETE:
- updateTool( project, key, command, options);
+ updateTool( project, key, command, options);
options.clear();
state = EXPECT_KEY;
continue;
default:
- throw new IOException( "Unexpected state");
+ throw new IOException( "unexpected state");
}
line = br.readLine();
}
@@ -293,7 +306,11 @@ public class Storage {
updateTool( project, key, command, options);
}
} catch (IOException e) {
- e.printStackTrace();
+ createMarker(
+ project,
+ Constants.MARKER_ID_TOOL_DISCOVERY,
+ "make output parse error: " + e.getMessage()
+ );
} finally {
while (true) {
try {
@@ -304,6 +321,15 @@ public class Storage {
}
}
}
+
+ // Check exit status
+ if (p.exitValue() != 0) {
+ createMarker(
+ project,
+ Constants.MARKER_ID_TOOL_DISCOVERY,
+ "make invokation `" + make.toOSString() + "' returned with error status " + p.exitValue()
+ );
+ }
}
private static void updateTool( IProject project, String toolKey, String command, List<String> options) {
@@ -312,7 +338,7 @@ public class Storage {
// Filter options
if (toolKey.startsWith( Constants.COMPILER_KEY_PREFIX) || toolKey.startsWith( Constants.LINKER_KEY_PREFIX)) {
for (String option : options) {
- if (!(option.length()==0 || option.trim().matches( "^-c|-O[0123s]|-g|-W[\\w-]*$"))) {
+ if (!(option.length() == 0 || option.trim().matches( "^-c|-O[0123s]|-g|-W[\\w-]*$"))) {
filteredOptions.add( option);
}
}
@@ -340,6 +366,37 @@ public class Storage {
return optionsValue.split( OPTION_SEPARATOR);
}
+
+ public static void createMarker( IProject project, String id, String message) {
+ createMarker( project, id, message, IMarker.SEVERITY_ERROR);
+ }
+ public static void createMarker( IProject project, String id, String message, int severity) {
+ try {
+ IMarker marker = project.createMarker( IMarker.PROBLEM);
+ marker.setAttribute( IMarker.LOCATION, id);
+ marker.setAttribute( IMarker.MESSAGE, message);
+ marker.setAttribute( IMarker.SEVERITY, severity);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ public static void deleteMarkers( IProject project, String id) {
+ try {
+ IMarker[] markers = project.findMarkers( IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
+ if (markers != null) {
+ for (IMarker m : markers) {
+ if (m.getResource().equals( project) && m.getAttribute( IMarker.LOCATION, "").equals( id)) {
+ m.delete();
+ }
+ }
+ }
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+
+ }
private Storage() {
// Do nothing