Changeset View
Changeset View
Standalone View
Standalone View
plugins/meson/settings/mesonnewbuilddir.cpp
Show First 20 Lines • Show All 97 Lines • ▼ Show 20 Line(s) | 78 | { | |||
---|---|---|---|---|---|
98 | 98 | | |||
99 | for (int i = 2; checkInCfg(cfg, buildDirPath); ++i) { | 99 | for (int i = 2; checkInCfg(cfg, buildDirPath); ++i) { | ||
100 | buildDirPath = projectPath; | 100 | buildDirPath = projectPath; | ||
101 | buildDirPath.addPath(QStringLiteral("build%1").arg(i)); | 101 | buildDirPath.addPath(QStringLiteral("build%1").arg(i)); | ||
102 | } | 102 | } | ||
103 | 103 | | |||
104 | m_ui->i_buildDir->setUrl(buildDirPath.toUrl()); | 104 | m_ui->i_buildDir->setUrl(buildDirPath.toUrl()); | ||
105 | 105 | | |||
106 | // Init build type | | |||
107 | // TODO use introspection once https://github.com/mesonbuild/meson/pull/4564 is merged | | |||
108 | QStringList buildTypes = { QStringLiteral("plain"), QStringLiteral("debug"), QStringLiteral("debugoptimized"), | | |||
109 | QStringLiteral("release"), QStringLiteral("minsize"), QStringLiteral("custom") }; | | |||
110 | | ||||
111 | m_ui->i_buildType->clear(); | | |||
112 | m_ui->i_buildType->addItems(buildTypes); | | |||
113 | m_ui->i_buildType->setCurrentIndex(std::max(0, buildTypes.indexOf(QStringLiteral("debug")))); | | |||
114 | | ||||
115 | // Install prefix | | |||
116 | m_ui->i_installPrefix->clear(); | | |||
117 | | ||||
118 | // Extra args | 106 | // Extra args | ||
119 | aConf.args.clear(); | 107 | aConf.args.clear(); | ||
120 | 108 | | |||
121 | // Backend | 109 | // Backend | ||
122 | aConf.backend = mgr->defaultMesonBackend(); | 110 | aConf.backend = mgr->defaultMesonBackend(); | ||
123 | 111 | | |||
124 | // Meson exe | 112 | // Meson exe | ||
125 | aConf.meson = mgr->findMeson(); | 113 | aConf.meson = mgr->findMeson(); | ||
Show All 28 Lines | |||||
154 | } | 142 | } | ||
155 | 143 | | |||
156 | void MesonNewBuildDir::updated() | 144 | void MesonNewBuildDir::updated() | ||
157 | { | 145 | { | ||
158 | auto advanced = m_ui->advanced->getConfig(); | 146 | auto advanced = m_ui->advanced->getConfig(); | ||
159 | Path buildDir = Path(m_ui->i_buildDir->url()); | 147 | Path buildDir = Path(m_ui->i_buildDir->url()); | ||
160 | QFileInfo mesonExe(advanced.meson.toLocalFile()); | 148 | QFileInfo mesonExe(advanced.meson.toLocalFile()); | ||
161 | 149 | | |||
162 | if (!mesonExe.exists() || !mesonExe.isExecutable() | 150 | if (!mesonExe.exists() || !mesonExe.isExecutable() || !mesonExe.isFile() | ||
163 | || !mesonExe.permission(QFileDevice::ReadUser | QFileDevice::ExeUser)) { | 151 | || !mesonExe.permission(QFileDevice::ReadUser | QFileDevice::ExeUser)) { | ||
164 | setStatus(i18n("Specified meson executable does not exist"), false); | 152 | setStatus(i18n("Specified meson executable does not exist"), false); | ||
165 | return; | 153 | return; | ||
166 | } | 154 | } | ||
167 | 155 | | |||
168 | MesonBuilder::DirectoryStatus status = MesonBuilder::evaluateBuildDirectory(buildDir, advanced.backend); | 156 | MesonBuilder::DirectoryStatus status = MesonBuilder::evaluateBuildDirectory(buildDir, advanced.backend); | ||
169 | switch (status) { | 157 | switch (status) { | ||
170 | case MesonBuilder::CLEAN: | 158 | case MesonBuilder::CLEAN: | ||
Show All 14 Lines | 171 | case MesonBuilder::DIR_NOT_EMPTY: | |||
185 | break; | 173 | break; | ||
186 | case MesonBuilder::EMPTY_STRING: | 174 | case MesonBuilder::EMPTY_STRING: | ||
187 | setStatus(i18n("The build directory field must not be empty"), false); | 175 | setStatus(i18n("The build directory field must not be empty"), false); | ||
188 | break; | 176 | break; | ||
189 | case MesonBuilder::___UNDEFINED___: | 177 | case MesonBuilder::___UNDEFINED___: | ||
190 | setStatus(i18n("You have reached unreachable code. This is a bug"), false); | 178 | setStatus(i18n("You have reached unreachable code. This is a bug"), false); | ||
191 | break; | 179 | break; | ||
192 | } | 180 | } | ||
181 | | ||||
182 | bool buildDirChanged = false; | ||||
183 | if(m_oldBuildDir != buildDir.toLocalFile()) { | ||||
184 | m_oldBuildDir = buildDir.toLocalFile(); | ||||
185 | buildDirChanged = true; | ||||
186 | } | ||||
187 | | ||||
188 | bool mesonHasChanged = m_ui->advanced->hasMesonChanged(); // Outside if to prevent lazy evaluation | ||||
189 | if (!m_ui->options->options() || mesonHasChanged || buildDirChanged) { | ||||
190 | if (status == MesonBuilder::MESON_CONFIGURED) { | ||||
191 | m_ui->options->repopulateFromBuildDir(m_project->path(), currentConfig())->start(); | ||||
192 | } else { | ||||
193 | m_ui->options->repopulateFromMesonFile(m_project->path(), advanced.meson)->start(); | ||||
194 | } | ||||
195 | } | ||||
193 | } | 196 | } | ||
194 | 197 | | |||
195 | Meson::BuildDir MesonNewBuildDir::currentConfig() const | 198 | Meson::BuildDir MesonNewBuildDir::currentConfig() const | ||
196 | { | 199 | { | ||
197 | Meson::BuildDir buildDir; | 200 | Meson::BuildDir buildDir; | ||
198 | if (!m_configIsValid) { | 201 | if (!m_configIsValid) { | ||
199 | qCDebug(KDEV_Meson) << "Cannot generate build dir config from invalid config"; | 202 | qCDebug(KDEV_Meson) << "Cannot generate build dir config from invalid config"; | ||
200 | return buildDir; | 203 | return buildDir; | ||
201 | } | 204 | } | ||
202 | 205 | | |||
203 | auto advanced = m_ui->advanced->getConfig(); | 206 | auto advanced = m_ui->advanced->getConfig(); | ||
204 | 207 | | |||
205 | buildDir.buildDir = Path(m_ui->i_buildDir->url()); | 208 | buildDir.buildDir = Path(m_ui->i_buildDir->url()); | ||
206 | buildDir.buildType = m_ui->i_buildType->currentText(); | | |||
207 | buildDir.installPrefix = Path(m_ui->i_installPrefix->url()); | | |||
208 | buildDir.mesonArgs = advanced.args; | 209 | buildDir.mesonArgs = advanced.args; | ||
209 | buildDir.mesonBackend = advanced.backend; | 210 | buildDir.mesonBackend = advanced.backend; | ||
210 | buildDir.mesonExecutable = advanced.meson; | 211 | buildDir.mesonExecutable = advanced.meson; | ||
211 | 212 | | |||
212 | return buildDir; | 213 | return buildDir; | ||
213 | } | 214 | } | ||
214 | 215 | | |||
216 | QStringList MesonNewBuildDir::mesonArgs() const | ||||
217 | { | ||||
218 | auto options = m_ui->options->options(); | ||||
219 | if (!options) { | ||||
220 | return {}; | ||||
221 | } | ||||
222 | | ||||
223 | return options->getMesonArgs(); | ||||
224 | } | ||||
225 | | ||||
215 | bool MesonNewBuildDir::isConfigValid() const | 226 | bool MesonNewBuildDir::isConfigValid() const | ||
216 | { | 227 | { | ||
217 | return m_configIsValid; | 228 | return m_configIsValid; | ||
218 | } | 229 | } |