| 80 | } |
| 81 | |
| 82 | MesonBuilder::DirectoryStatus MesonBuilder::evaluateBuildDirectory(const Path& path, const QString& backend) |
| 83 | { |
| 84 | QString pathSTR = path.toLocalFile(); |
| 85 | if (pathSTR.isEmpty()) { |
| 86 | return EMPTY_STRING; |
| 87 | } |
| 88 | |
| 89 | QFileInfo info(pathSTR); |
| 90 | if (!info.exists()) { |
| 91 | return DOES_NOT_EXIST; |
| 92 | } |
| 93 | |
| 94 | if (!info.isDir() || !info.isReadable() || !info.isWritable()) { |
| 95 | return INVALID_BUILD_DIR; |
| 96 | } |
| 97 | |
| 98 | QDir dir(path.toLocalFile()); |
| 99 | if (dir.isEmpty(QDir::NoDotAndDotDot | QDir::Hidden | QDir::AllEntries)) { |
| 100 | return CLEAN; |
| 101 | } |
| 102 | |
| 103 | // Check if the directory is a meson directory |
| 104 | const static QStringList mesonPaths = { QStringLiteral("meson-logs"), QStringLiteral("meson-private") }; |
| 105 | for (const auto& i : mesonPaths) { |
| 106 | Path curr = path; |
| 107 | curr.addPath(i); |
| 108 | QFileInfo currFI(curr.toLocalFile()); |
| 109 | if (!currFI.exists()) { |
| 110 | return DIR_NOT_EMPTY; |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | // Also check if the meson configuration succeeded. This should be the case if the backend file exists. |
| 115 | // Meson actually checks for meson-private/coredata.dat, this might change in the future. |
| 116 | // see: https://github.com/mesonbuild/meson/blob/master/mesonbuild/msetup.py#L117 |
| 117 | QStringList configured = {}; |
| 118 | if (backend == QStringLiteral("ninja")) { |
| 119 | configured << QStringLiteral("build.ninja"); |
| 120 | } |
| 121 | |
| 122 | // Check if this is a CONFIGURED meson directory |
| 123 | for (const auto& i : configured) { |
| 124 | Path curr = path; |
| 125 | curr.addPath(i); |
| 126 | QFileInfo currFI(curr.toLocalFile()); |
| 127 | if (!currFI.exists()) { |
| 128 | return MESON_FAILED_CONFIGURATION; |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | return MESON_CONFIGURED; |
| 133 | } |
| 134 | |
| 135 | KJob* MesonBuilder::configure(IProject* project, const Meson::BuildDir& buildDir, QStringList args, |
| 136 | DirectoryStatus status) |
no test coverage detected