| 82 | } |
| 83 | |
| 84 | bool QMakeFile::read() |
| 85 | { |
| 86 | Q_ASSERT(!m_projectFile.isEmpty()); |
| 87 | QFileInfo fi(m_projectFile); |
| 88 | ifDebug(qCDebug(KDEV_QMAKE) << "Is" << m_projectFile << "a dir?" << fi.isDir();) if (fi.isDir()) |
| 89 | { |
| 90 | QDir dir(m_projectFile); |
| 91 | QStringList l = dir.entryList(QStringList() << QStringLiteral("*.pro")); |
| 92 | |
| 93 | QString projectfile; |
| 94 | |
| 95 | if (!l.count() || (l.count() && l.indexOf(fi.baseName() + QLatin1String(".pro")) != -1)) { |
| 96 | projectfile = fi.baseName() + QLatin1String(".pro"); |
| 97 | } else { |
| 98 | projectfile = l.first(); |
| 99 | } |
| 100 | m_projectFile += QLatin1Char('/') + projectfile; |
| 101 | } |
| 102 | QMake::Driver d; |
| 103 | d.readFile(m_projectFile); |
| 104 | |
| 105 | if (!d.parse(&m_ast)) { |
| 106 | qCWarning(KDEV_QMAKE) << "Couldn't parse project:" << m_projectFile; |
| 107 | delete m_ast; |
| 108 | m_ast = nullptr; |
| 109 | m_projectFile = QString(); |
| 110 | return false; |
| 111 | } else { |
| 112 | ifDebug(qCDebug(KDEV_QMAKE) << "found ast:" << m_ast->statements.count();) QMakeFileVisitor visitor(this, this); |
| 113 | /// TODO: cleanup, re-use m_variableValues directly in the visitor |
| 114 | visitor.setVariables(m_variableValues); |
| 115 | m_variableValues = visitor.visitFile(m_ast); |
| 116 | ifDebug(qCDebug(KDEV_QMAKE) << "Variables found:" << m_variableValues;) |
| 117 | } |
| 118 | return true; |
| 119 | } |
| 120 | |
| 121 | QMakeFile::~QMakeFile() |
| 122 | { |