tools/qdoc3/command.cpp
branchGCC_SURGE
changeset 31 5daf16870df6
parent 30 5dc02b23752f
equal deleted inserted replaced
27:93b982ccede2 31:5daf16870df6
    45 
    45 
    46 #include <QProcess>
    46 #include <QProcess>
    47 
    47 
    48 #include "command.h"
    48 #include "command.h"
    49 
    49 
       
    50 #include <stdlib.h>
       
    51 
    50 QT_BEGIN_NAMESPACE
    52 QT_BEGIN_NAMESPACE
    51 
    53 
    52 void executeCommand(const Location& location,
    54 void executeCommand(const Location& location,
    53                     const QString& format,
    55                     const QString& format,
    54                     const QStringList& args)
    56                     const QStringList& args)
    67     QString toolName = actualCommand;
    69     QString toolName = actualCommand;
    68     int space = toolName.indexOf(QLatin1Char(' '));
    70     int space = toolName.indexOf(QLatin1Char(' '));
    69     if (space != -1)
    71     if (space != -1)
    70 	toolName.truncate(space);
    72 	toolName.truncate(space);
    71 
    73 
       
    74 #ifdef QT_BOOTSTRAPPED
       
    75     int status = system(qPrintable(actualCommand));
       
    76     int exitCode = WEXITSTATUS(status);
       
    77     if (status == -1 || exitCode != EXIT_SUCCESS)
       
    78         location.fatal(QString("Error executing '$1': $2").arg(toolName).arg(exitCode));
       
    79 #else
    72     QProcess process;
    80     QProcess process;
    73     process.start(QLatin1String("sh"),
    81     process.start(QLatin1String("sh"),
    74         QStringList() << QLatin1String("-c") << actualCommand);
    82         QStringList() << QLatin1String("-c") << actualCommand);
    75     process.waitForFinished();
    83     process.waitForFinished();
    76 
    84 
    87 	location.fatal(tr("The '%1' tool encountered some problems")
    95 	location.fatal(tr("The '%1' tool encountered some problems")
    88                        .arg(toolName),
    96                        .arg(toolName),
    89                        tr("The tool was invoked like this:\n%1\n"
    97                        tr("The tool was invoked like this:\n%1\n"
    90                           "It emitted these errors:\n%2")
    98                           "It emitted these errors:\n%2")
    91                        .arg(actualCommand).arg(errors));
    99                        .arg(actualCommand).arg(errors));
       
   100 #endif
    92 }
   101 }
    93 
   102 
    94 QT_END_NAMESPACE
   103 QT_END_NAMESPACE