Changeset View
Changeset View
Standalone View
Standalone View
plugins/meson/mesonjob.cpp
- This file was added.
1 | /* This file is part of KDevelop | ||||
---|---|---|---|---|---|
2 | Copyright 2018 Daniel Mensinger <daniel@mensinger-ka.de> | ||||
3 | | ||||
4 | This library is free software; you can redistribute it and/or | ||||
5 | modify it under the terms of the GNU Library General Public | ||||
6 | License as published by the Free Software Foundation; either | ||||
7 | version 2 of the License, or (at your option) any later version. | ||||
8 | | ||||
9 | This library is distributed in the hope that it will be useful, | ||||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
12 | Library General Public License for more details. | ||||
13 | | ||||
14 | You should have received a copy of the GNU Library General Public License | ||||
15 | along with this library; see the file COPYING.LIB. If not, write to | ||||
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||||
17 | Boston, MA 02110-1301, USA. | ||||
18 | */ | ||||
19 | | ||||
20 | #include "mesonjob.h" | ||||
21 | #include "mesonconfig.h" | ||||
22 | #include <interfaces/iproject.h> | ||||
23 | #include <klocalizedstring.h> | ||||
24 | #include <project/projectmodel.h> | ||||
25 | | ||||
26 | using namespace KDevelop; | ||||
27 | | ||||
28 | MesonJob::MesonJob(Meson::BuildDir const& buildDir, IProject* project, MesonJob::CommandType commandType, | ||||
29 | const QStringList& arguments, QObject* parent) | ||||
30 | : OutputExecuteJob(parent) | ||||
31 | , m_project(project) | ||||
32 | , m_commandType(commandType) | ||||
33 | , m_arguments(arguments) | ||||
34 | { | ||||
35 | Q_ASSERT(m_project); | ||||
36 | | ||||
37 | setToolTitle(i18n("Meson")); | ||||
38 | setCapabilities(Killable); | ||||
39 | setStandardToolView(KDevelop::IOutputView::BuildView); | ||||
40 | setBehaviours(KDevelop::IOutputView::AllowUserClose | KDevelop::IOutputView::AutoScroll); | ||||
41 | setProperties(NeedWorkingDirectory | PortableMessages | DisplayStdout | DisplayStderr); | ||||
42 | | ||||
43 | *this << buildDir.mesonExecutable.toLocalFile(); | ||||
44 | | ||||
45 | switch (m_commandType) { | ||||
46 | case CONFIGURE: | ||||
47 | if (!buildDir.installPrefix.isEmpty()) { | ||||
48 | *this << QStringLiteral("--prefix") << buildDir.installPrefix.toLocalFile(); | ||||
49 | } | ||||
50 | | ||||
51 | *this << QStringLiteral("--backend") << buildDir.mesonBackend; | ||||
52 | *this << QStringLiteral("--buildtype") << buildDir.buildType; | ||||
53 | | ||||
54 | for (auto const& i : buildDir.mesonArgs) { | ||||
55 | *this << i; | ||||
56 | } | ||||
57 | | ||||
58 | break; | ||||
59 | case RE_CONFIGURE: | ||||
60 | *this << QStringLiteral("--reconfigure"); | ||||
61 | break; | ||||
62 | case SET_CONFIG: | ||||
63 | *this << QStringLiteral("configure"); | ||||
64 | if (!buildDir.installPrefix.isEmpty()) { | ||||
65 | *this << QStringLiteral("-Dprefix=") + buildDir.installPrefix.toLocalFile(); | ||||
66 | } | ||||
67 | *this << QStringLiteral("-Dbuildtype=") + buildDir.buildType; | ||||
68 | } | ||||
69 | | ||||
70 | *this << m_arguments; | ||||
71 | *this << buildDir.buildDir.toLocalFile(); | ||||
72 | } | ||||
73 | | ||||
74 | QUrl MesonJob::workingDirectory() const | ||||
75 | { | ||||
76 | return m_project->path().toUrl(); | ||||
77 | } |