Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] return code handling in org.eclipse.cdt.core.CommandLauncher

Hi all,

I'm working on a CMake plugin for CDT an have a question about the 
intended usage of org.eclipse.cdt.core.CommandLauncher (I want to use it 
to call cmake). CommandLauncher seems to ignore the return code of the 
launched command. The returned status is always ok, except the command was 
cancelled. There seems to be no way to find out if the command finished 
successfully or not. As long as it terminates by itself, OK is returned. 
See CommandLauncher::waitAndRead(...):


int state = OK;

// Operation canceled by the user, terminate abnormally.
if (monitor.isCanceled()) {
    closure.terminate();
    state = COMMAND_CANCELED;
    setErrorMessage(Messages.CommandLauncher_CommandCancelled);
}

try {
    fProcess.waitFor();
} catch (InterruptedException e) {
 // ignore
}
return state;


the call to   fProcess.waitFor();  would return the command's return code, 
but it is ignored.

I see two ways to avoid this problem:
- providing an specialized Errorparser for CMake and decide about success 
or failure from the parsed console output
- write my own class to replace CommandLauncher and evaluate cmake's 
return code there

I really would like to understand the recommended way to use 
CommandLauncher. It is also used to call make for example and make returns 
an error code != 0 if e.g. no Makefile was found.  In case of a Makefile 
generator like CMake, I would like to stop the build if CMake failed, 
instead of having the next builder run afterwards hiding the cmake error 
message with its output.

Thanks in advance and best regards
Martin


Back to the top