QHash<QString, QByteArray> QtPatch::qmakeValues(const QString &qmakePath, QByteArray *qmakeOutput) { QHash<QString, QByteArray> qmakeValueHash; // in some cases qmake is not runable, because another process is blocking it(filewatcher ...) int waitCount = 0; while (qmakeValueHash.isEmpty() && waitCount < 3) { QFileInfo qmake(qmakePath); if (!qmake.exists()) { qmakeOutput->append(QString::fromLatin1("%1 is not existing").arg(qmakePath)); return qmakeValueHash; } if (!qmake.isExecutable()) { qmakeOutput->append(QString::fromLatin1("%1 is not executable").arg(qmakePath)); return qmakeValueHash; } QStringList args; args << QLatin1String("-query"); QProcess process; process.start(qmake.absoluteFilePath(), args, QIODevice::ReadOnly); if (process.waitForFinished(10000)) { QByteArray output = process.readAllStandardOutput(); qmakeOutput->append(output); if (process.exitStatus() == QProcess::CrashExit) { qWarning() << qmake.absoluteFilePath() << args << "crashed with exit code" << process.exitCode() << "standard output: " << output << "error output: " << process.readAllStandardError(); return qmakeValueHash; } qmakeValueHash = readQmakeOutput(output); } if (qmakeValueHash.isEmpty()) { ++waitCount; static const int waitTimeInMilliSeconds = 500; QInstaller::uiDetachedWait(waitTimeInMilliSeconds); } if (process.state() > QProcess::NotRunning ) { qDebug() << "qmake process is still running, need to kill it."; process.kill(); } } if (qmakeValueHash.isEmpty()) qDebug() << "Cannot get any query output from qmake."; return qmakeValueHash; }
static void do_init(FILE *ofd, Symbol *sp) { int i; extern Queue *ltab[]; if (sp->ini && sp->type == CHAN && ((i = qmake(sp)) > 0)) { if (sp->ini->ntyp == CHAN) fprintf(ofd, "addqueue(%d, %d)", i, ltab[i-1]->nslots == 0); else fprintf(ofd, "%d", i); } else putstmnt(ofd, sp->ini, 0); }
Utils::FileName BuildableHelperLibrary::findSystemQt(const Utils::Environment &env) { QStringList paths = env.path(); foreach (const QString &path, paths) { QString prefix = path; if (!prefix.endsWith(QLatin1Char('/'))) prefix.append(QLatin1Char('/')); foreach (const QString &possibleCommand, possibleQMakeCommands()) { QFileInfo qmake(prefix + possibleCommand); if (qmake.exists()) { if (isQtChooser(qmake)) qmake.setFile(qtChooserToQmakePath(qmake.symLinkTarget())); if (!qtVersionForQMake(qmake.absoluteFilePath()).isNull()) return Utils::FileName(qmake); } }
void IncludePathLocator::Locate(wxArrayString& paths, wxArrayString &excludePaths, bool thirdPartyLibs, const wxString &tool) { // Common compiler paths - should be placed at top of the include path! wxString tmpfile1 = wxFileName::CreateTempFileName(wxT("codelite")); wxString command; wxString tmpfile = tmpfile1; tmpfile += wxT(".cpp"); wxString bin = tool; if(bin.IsEmpty()) { bin = wxT("gcc"); } wxRenameFile(tmpfile1, tmpfile); // GCC prints parts of its output to stdout and some to stderr // redirect all output to stdout #if defined(__WXMAC__) || defined(__WXGTK__) // Mac does not like the standard command command = wxString::Format(wxT("%s -v -x c++ /dev/null -fsyntax-only"), bin.c_str()); #else command = wxString::Format(wxT("%s -v -x c++ %s -fsyntax-only"), bin.c_str(), tmpfile.c_str()); #endif wxString outputStr = wxShellExec(command, wxEmptyString); wxRemoveFile( tmpfile ); wxArrayString outputArr = wxStringTokenize(outputStr, wxT("\n\r"), wxTOKEN_STRTOK); // Analyze the output bool collect(false); for(size_t i=0; i<outputArr.GetCount(); i++) { if(outputArr[i].Contains(wxT("#include <...> search starts here:"))) { collect = true; continue; } if(outputArr[i].Contains(wxT("End of search list."))) { break; } if(collect) { wxString file = outputArr.Item(i).Trim().Trim(false); // on Mac, (framework directory) appears also, // but it is harmless to use it under all OSs file.Replace(wxT("(framework directory)"), wxT("")); file.Trim().Trim(false); wxFileName includePath(file, wxT("")); includePath.Normalize(); paths.Add( includePath.GetPath() ); } } if(thirdPartyLibs) { // try to locate QMAKE wxFileConfig qmakeConf(wxEmptyString, wxEmptyString, m_mgr->GetStartupDirectory() + wxT("/config/qmake.ini")); wxString groupName; long index(0); wxArrayString out; wxString qmake(wxT("qmake")); if (qmakeConf.GetFirstGroup(groupName, index)) { // we got qmake configuration, use it instead of the default qmake command qmake = qmakeConf.Read(groupName + wxT("/qmake")); } // Run: qmake -query QT_INSTALL_PREFIX wxString cmd; cmd << qmake << wxT(" -query QT_INSTALL_PREFIX"); #ifdef __WXGTK__ cmd << wxT(" 2>/dev/null"); #endif out = ExecCommand(cmd); if (out.IsEmpty() == false ) { wxString qt_output (out.Item(0)); qt_output.Trim().Trim(false); #if defined(__WXGTK__)||defined(__WXMAC__) wxString pathQt4, pathQt3, pathQt; pathQt4 << qt_output << wxFileName::GetPathSeparator() << wxT("include") << wxFileName::GetPathSeparator() << wxT("qt4"); pathQt3 << qt_output << wxFileName::GetPathSeparator() << wxT("include") << wxFileName::GetPathSeparator() << wxT("qt3"); pathQt << qt_output << wxFileName::GetPathSeparator() << wxT("include"); if (wxDir::Exists( pathQt4 )) { wxString tmpPath; tmpPath = pathQt4 + wxT("/QtCore"); if(wxFileName::DirExists(tmpPath)) paths.Add( tmpPath ); tmpPath = pathQt4 + wxT("/QtGui"); if(wxFileName::DirExists(tmpPath)) paths.Add( tmpPath ); tmpPath = pathQt4 + wxT("/QtXml"); if(wxFileName::DirExists(tmpPath)) paths.Add( tmpPath ); } else if (wxDir::Exists( pathQt3 ) ) { wxString tmpPath; tmpPath = pathQt3 + wxT("/QtCore"); if(wxFileName::DirExists(tmpPath)) paths.Add( tmpPath ); tmpPath = pathQt3 + wxT("/QtGui"); if(wxFileName::DirExists(tmpPath)) paths.Add( tmpPath ); tmpPath = pathQt3 + wxT("/QtXml"); if(wxFileName::DirExists(tmpPath)) paths.Add( tmpPath ); } else if (wxDir::Exists( pathQt ) ) { wxString tmpPath; tmpPath = pathQt + wxT("/QtCore"); if(wxFileName::DirExists(tmpPath)) paths.Add( tmpPath ); tmpPath = pathQt + wxT("/QtGui"); if(wxFileName::DirExists(tmpPath)) paths.Add( pathQt ); tmpPath = pathQt + wxT("/QtXml"); if(wxFileName::DirExists(tmpPath)) paths.Add( tmpPath ); } #else // __WXMSW__ wxString pathWin; pathWin << qt_output << wxFileName::GetPathSeparator() << wxT("include") << wxFileName::GetPathSeparator(); if (wxDir::Exists( pathWin )) { wxString tmpPath; tmpPath = pathWin + wxT("QtCore"); if(wxFileName::DirExists(tmpPath)) { wxFileName fn(tmpPath, wxT("")); paths.Add( fn.GetPath() ); } tmpPath = pathWin + wxT("QtGui"); if(wxFileName::DirExists(tmpPath)) { wxFileName fn(tmpPath, wxT("")); paths.Add( fn.GetPath() ); } tmpPath = pathWin + wxT("QtXml"); if(wxFileName::DirExists(tmpPath)) { wxFileName fn(tmpPath, wxT("")); paths.Add( fn.GetPath() ); } } #endif } // Try wxWidgets #ifdef __WXMSW__ // On Windows, just read the content of the WXWIN environment variable wxString wxwin; if (wxGetEnv(wxT("WX_INCL_HOME"), &wxwin)) { // we got the path to the installation of wxWidgets if (wxDir::Exists(wxwin)) { paths.Add( wxwin ); excludePaths.Add( wxwin + wxT("\\univ") ); excludePaths.Add( wxwin + wxT("\\unix") ); } } #else // run wx-config and parse the output out.Clear(); out = ExecCommand(wxT("wx-config --cxxflags 2>/dev/null")); if (out.IsEmpty() == false) { wxString line ( out.Item(0) ); int where = line.Find(wxT(" -I")); while (where != wxNOT_FOUND) { line = line.Mid(where + 3); paths.Add( line.BeforeFirst(wxT(' ')) ); where = line.Find(wxT(" -I")); } } #endif } }