Changeset ebe332a in rtems-eclipse-plug-in


Ignore:
Timestamp:
02/06/09 14:21:18 (15 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
b9a8b46
Parents:
c9fa789
Message:

Added problem markers.
Initialize tools with default values on platform change.

Location:
org.rtems.cdt/src/org/rtems/cdt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • org.rtems.cdt/src/org/rtems/cdt/Constants.java

    rc9fa789 rebe332a  
    9494        public static final String TOOL_OPTIONS_LINKER_CPP_KEY = TOOL_LINKER_CPP_KEY + TOOL_OPTIONS_KEY_POSTFIX;
    9595
     96        public static final String MARKER_ID_TOOL_DISCOVERY = "tool discovery";
     97       
    9698        private static String getPathVariableName() {
    9799                Map<String, String> env = System.getenv();
  • org.rtems.cdt/src/org/rtems/cdt/Storage.java

    rc9fa789 rebe332a  
    3939import org.eclipse.cdt.managedbuilder.core.IConfiguration;
    4040import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
     41import org.eclipse.core.resources.IMarker;
    4142import org.eclipse.core.resources.IProject;
     43import org.eclipse.core.resources.IResource;
    4244import org.eclipse.core.runtime.CoreException;
    4345import org.eclipse.core.runtime.IPath;
     
    199201                String bspPath = getProperty( project, Constants.BSP_PATH_KEY);
    200202                IPath make = new Path( "make");
    201 
     203                List<String> options = new LinkedList<String>();
     204               
     205                // Set tools to default values
     206                updateTool( project, Constants.TOOL_ARCHIVER_KEY, "ar", options);
     207                updateTool( project, Constants.TOOL_ASSEMBLER_KEY, "as", options);
     208                updateTool( project, Constants.TOOL_COMPILER_CPP_KEY, "g++", options);
     209                updateTool( project, Constants.TOOL_COMPILER_C_KEY, "gcc", options);
     210                updateTool( project, Constants.TOOL_LINKER_CPP_KEY, "g++", options);
     211                updateTool( project, Constants.TOOL_LINKER_C_KEY, "gcc", options);
     212               
     213                // Delete markers for this unit
     214                deleteMarkers( project, Constants.MARKER_ID_TOOL_DISCOVERY);
     215               
    202216                // Translate path if necessary
    203217                if (Platform.getOS().equals( Platform.OS_WIN32)) {
     
    252266                        String key = null;
    253267                        String command = null;
    254                         List<String> options = new LinkedList<String>();
    255268                        int state = EXPECT_KEY;
    256269                        while (line != null) {
     
    269282                                                        state = EXPECT_OPTION;
    270283                                                } else {
    271                                                         throw new IOException( "Unexpected line format");
     284                                                        throw new IOException( "unexpected line format");
    272285                                                }
    273286                                                break;
     
    277290                                                        state = EXPECT_COMMAND;
    278291                                                } else {
    279                                                         throw new IOException( "Unexpected line format");
     292                                                        throw new IOException( "unexpected line format");
    280293                                                }
    281294                                                break;
    282295                                        case TOOL_COMPLETE:
    283                                         updateTool( project, key, command, options);
     296                                                updateTool( project, key, command, options);
    284297                                                options.clear();
    285298                                                state = EXPECT_KEY;
    286299                                                continue;
    287300                                        default:
    288                                                 throw new IOException( "Unexpected state");
     301                                                throw new IOException( "unexpected state");
    289302                                }
    290303                                line = br.readLine();
     
    294307                        }
    295308                } catch (IOException e) {
    296                         e.printStackTrace();
     309                        createMarker(
     310                                project,
     311                                Constants.MARKER_ID_TOOL_DISCOVERY,
     312                                "make output parse error: " + e.getMessage()
     313                        );
    297314                } finally {
    298315                        while (true) {
     
    305322                        }
    306323                }
     324               
     325                // Check exit status
     326                if (p.exitValue() != 0) {
     327                        createMarker(
     328                                project,
     329                                Constants.MARKER_ID_TOOL_DISCOVERY,
     330                                "make invokation `" + make.toOSString() + "' returned with error status " + p.exitValue()
     331                        );
     332                }
    307333        }
    308334
     
    313339                if (toolKey.startsWith( Constants.COMPILER_KEY_PREFIX) || toolKey.startsWith( Constants.LINKER_KEY_PREFIX)) {
    314340                        for (String option : options) {
    315                                 if (!(option.length()==0 || option.trim().matches( "^-c|-O[0123s]|-g|-W[\\w-]*$"))) {
     341                                if (!(option.length() == 0 || option.trim().matches( "^-c|-O[0123s]|-g|-W[\\w-]*$"))) {
    316342                                        filteredOptions.add( option);
    317343                                }
     
    341367                return optionsValue.split( OPTION_SEPARATOR);
    342368        }
     369       
     370        public static void createMarker( IProject project, String id, String message) {
     371                createMarker( project, id, message, IMarker.SEVERITY_ERROR);
     372        }
     373        public static void createMarker( IProject project, String id, String message, int severity)     {       
     374                try {
     375                        IMarker marker = project.createMarker( IMarker.PROBLEM);
     376                        marker.setAttribute( IMarker.LOCATION, id);
     377                        marker.setAttribute( IMarker.MESSAGE, message);
     378                        marker.setAttribute( IMarker.SEVERITY, severity);
     379                } catch (CoreException e) {
     380                        e.printStackTrace();
     381                }
     382
     383        }
     384       
     385        public static void deleteMarkers( IProject project, String id) {
     386                try {
     387                        IMarker[] markers = project.findMarkers( IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
     388                        if (markers != null) {
     389                                for (IMarker m : markers) {
     390                                        if (m.getResource().equals( project) && m.getAttribute( IMarker.LOCATION, "").equals( id)) {
     391                                                m.delete();
     392                                        }
     393                                }
     394                        }
     395                } catch (CoreException e) {
     396                        e.printStackTrace();
     397                }
     398
     399        }
    343400
    344401        private Storage() {
Note: See TracChangeset for help on using the changeset viewer.