| 72 | } |
| 73 | |
| 74 | MesonConfig Meson::getMesonConfig(IProject* project) |
| 75 | { |
| 76 | KConfigGroup root = rootGroup(project); |
| 77 | MesonConfig result; |
| 78 | |
| 79 | int numDirs = root.readEntry(NUM_BUILD_DIRS, 0); |
| 80 | result.currentIndex = root.readEntry(CURRENT_INDEX, -1); |
| 81 | |
| 82 | for (int i = 0; i < numDirs; ++i) { |
| 83 | QString section = BUILD_DIR_SEC.arg(i); |
| 84 | if (!root.hasGroup(section)) { |
| 85 | continue; |
| 86 | } |
| 87 | |
| 88 | KConfigGroup current = root.group(section); |
| 89 | BuildDir currBD; |
| 90 | currBD.buildDir = Path(current.readEntry(BUILD_DIR_PATH, QString())); |
| 91 | currBD.mesonExecutable = Path(current.readEntry(MESON_EXE, QString())); |
| 92 | currBD.mesonBackend = current.readEntry(BACKEND, QString()); |
| 93 | currBD.mesonArgs = current.readEntry(EXTRA_ARGS, QString()); |
| 94 | |
| 95 | currBD.canonicalizePaths(); |
| 96 | |
| 97 | // Try to find meson if the config is bad |
| 98 | if (currBD.mesonExecutable.isEmpty()) { |
| 99 | Q_ASSERT(project); |
| 100 | IBuildSystemManager* ibsm = project->buildSystemManager(); |
| 101 | auto* bsm = dynamic_cast<MesonManager*>(ibsm); |
| 102 | if (bsm) { |
| 103 | currBD.mesonExecutable = bsm->findMeson(); |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | result.buildDirs.push_back(currBD); |
| 108 | } |
| 109 | |
| 110 | if (result.buildDirs.isEmpty()) { |
| 111 | result.currentIndex = -1; |
| 112 | } else if (result.currentIndex < 0 || result.currentIndex >= result.buildDirs.size()) { |
| 113 | result.currentIndex = 0; |
| 114 | } |
| 115 | |
| 116 | return result; |
| 117 | } |
| 118 | |
| 119 | void Meson::writeMesonConfig(IProject* project, const MesonConfig& cfg) |
| 120 | { |
nothing calls this directly
no test coverage detected