blob: 15f97d44ebdabcd476799e673c68824ef69afa2f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "cmakemodificationfile.h"
#include "cocopluginconstants.h"
#include <projectexplorer/project.h>
#include <projectexplorer/target.h>
#include <projectexplorer/buildconfiguration.h>
namespace Coco::Internal {
using namespace ProjectExplorer;
static const char flagsSetting[] = "set(coverage_flags_list\n";
static const char tweaksLine[] = "# User-supplied settings follow here:\n";
CMakeModificationFile::CMakeModificationFile()
: ModificationFile{QString(Constants::PROFILE_NAME) + ".cmake", ":/cocoplugin/files/cocoplugin.cmake"}
{}
void CMakeModificationFile::read()
{
clear();
QStringList file = currentModificationFile();
{
QStringList options;
int i = file.indexOf(flagsSetting);
if (i != -1) {
i++;
while (i < file.size() && !file[i].startsWith(')')) {
options += file[i].trimmed();
i++;
}
}
setOptions(options);
}
{
QStringList tweaks;
int i = file.indexOf(tweaksLine);
if (i != -1) {
i++;
while (i < file.size()) {
tweaks += file[i].chopped(1);
i++;
}
}
setTweaks(tweaks);
}
}
void CMakeModificationFile::write() const
{
QFile out(nativePath());
QTC_CHECK(out.open(QIODevice::WriteOnly | QIODevice::Text));
QTextStream outStream(&out);
for (QString &line : defaultModificationFile()) {
outStream << line;
if (line.startsWith(flagsSetting)) {
for (const QString &option : options()) {
QString line = " " + option + '\n';
outStream << line;
}
}
}
for (const QString &line : tweaks())
outStream << line << "\n";
out.close();
}
} // namespace Coco::Internal
|