Skip to content

Commit 9ec97f5

Browse files
author
Vladislav Kalugin
committed
rebase
1 parent 6048615 commit 9ec97f5

34 files changed

+652
-287
lines changed

server/src/KleeGenerator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ std::vector<fs::path> KleeGenerator::buildKleeFiles(const tests::TestsMap &tests
253253
return;
254254
}
255255
kleePrinter.srcLanguage = Paths::getSourceLanguage(filename);
256-
auto includeFlags = { StringUtils::stringFormat("-I%s",
257-
Paths::getFlagsDir(projectContext)) };
256+
std::vector<std::string> includeFlags = {
257+
StringUtils::stringFormat("-I%s", Paths::getFlagsDir(projectContext))};
258258
auto buildDirPath =
259259
buildDatabase->getClientCompilationUnitInfo(filename)->getDirectory();
260260

server/src/Paths.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace Paths {
2727
CollectionUtils::FileSet filtered =
2828
CollectionUtils::filterOut(paths, [&dirPaths, &filter](const fs::path &path) {
2929
return !std::any_of(dirPaths.begin(), dirPaths.end(), [&](const fs::path &dirPath) {
30-
return path.parent_path() == dirPath && fs::exists(path) && filter(path);
30+
return isSubPathOf(dirPath, path) && fs::exists(path) && filter(path);
3131
});
3232
});
3333
return filtered;

server/src/Server.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,8 @@ Status Server::TestsGenServiceImpl::PrintModulesContent(ServerContext *context,
568568

569569
utbot::ProjectContext projectContext{ *request };
570570
fs::path serverBuildDir = Paths::getUtbotBuildDir(projectContext);
571-
std::shared_ptr<BuildDatabase> buildDatabase = BuildDatabase::create(projectContext);
571+
std::shared_ptr<BuildDatabase> buildDatabase = BuildDatabase::create(projectContext,
572+
GrpcUtils::UTBOT_AUTO_TARGET_PATH);
572573
StubSourcesFinder(buildDatabase).printAllModules();
573574
return Status::OK;
574575
}
@@ -643,7 +644,7 @@ Status Server::TestsGenServiceImpl::GetProjectTargets(ServerContext *context,
643644

644645
try {
645646
utbot::ProjectContext projectContext{ request->projectcontext() };
646-
auto buildDatabase = BuildDatabase::create(projectContext);
647+
auto buildDatabase = BuildDatabase::create(projectContext, GrpcUtils::UTBOT_AUTO_TARGET_PATH);
647648
auto targets = buildDatabase->getAllTargets();
648649
ProjectTargetsWriter targetsWriter{ response };
649650
targetsWriter.writeResponse(projectContext, targets);
@@ -665,7 +666,7 @@ Status Server::TestsGenServiceImpl::GetFileTargets(ServerContext *context,
665666

666667
try {
667668
utbot::ProjectContext projectContext{ request->projectcontext() };
668-
auto buildDatabase = BuildDatabase::create(projectContext);
669+
auto buildDatabase = BuildDatabase::create(projectContext, GrpcUtils::UTBOT_AUTO_TARGET_PATH);
669670
fs::path path = request->path();
670671
auto targets = buildDatabase->getTargetsForSourceFile(path);
671672
FileTargetsWriter targetsWriter{ response };

server/src/building/BaseCommand.cpp

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
#include "tasks/ShellExecTask.h"
88
#include "utils/CollectionUtils.h"
99
#include "utils/StringUtils.h"
10+
#include "utils/path/FileSystemPath.h"
1011

1112
#include "loguru.h"
1213

1314
#include <algorithm>
14-
#include "utils/path/FileSystemPath.h"
1515
#include <iterator>
1616
#include <set>
1717
#include <utility>
@@ -20,26 +20,36 @@ namespace utbot {
2020
BaseCommand::BaseCommand(std::list<std::string> commandLine, fs::path directory, bool shouldChangeDirectory)
2121
: commandLine(std::move(commandLine)), directory(std::move(directory)), shouldChangeDirectory{shouldChangeDirectory} {
2222
initOptimizationLevel();
23+
initCompiler();
24+
initOutput();
2325
}
2426
BaseCommand::BaseCommand(std::vector<std::string> commandLine, fs::path directory, bool shouldChangeDirectory)
2527
: commandLine(commandLine.begin(), commandLine.end()), directory(std::move(directory)), shouldChangeDirectory{shouldChangeDirectory} {
2628
initOptimizationLevel();
29+
initCompiler();
30+
initOutput();
2731
}
2832

2933
BaseCommand::BaseCommand(BaseCommand const &other)
30-
: directory(other.directory), commandLine(other.commandLine),
31-
environmentVariables(other.environmentVariables), shouldChangeDirectory(other.shouldChangeDirectory) {
34+
: directory(other.directory), commandLine(other.commandLine),
35+
environmentVariables(other.environmentVariables), shouldChangeDirectory(other.shouldChangeDirectory),
36+
compiler(other.compiler),
37+
output(other.output) {
3238
if (other.optimizationLevel.has_value()) {
3339
optimizationLevel =
34-
std::next(commandLine.begin(),
35-
std::distance<const_iterator>(other.commandLine.begin(),
36-
other.optimizationLevel.value()));
40+
std::next(commandLine.begin(),
41+
std::distance<const_iterator>(other.commandLine.begin(),
42+
other.optimizationLevel.value()));
3743
}
3844
}
45+
3946
BaseCommand::BaseCommand(BaseCommand &&other) noexcept
4047
: directory(std::move(other.directory)), commandLine(std::move(other.commandLine)),
4148
environmentVariables(std::move(other.environmentVariables)),
42-
optimizationLevel(other.optimizationLevel), shouldChangeDirectory(other.shouldChangeDirectory) {
49+
optimizationLevel(other.optimizationLevel),
50+
compiler(other.compiler),
51+
output(other.output),
52+
shouldChangeDirectory(other.shouldChangeDirectory) {
4353
}
4454

4555
void BaseCommand::initOptimizationLevel() {
@@ -48,6 +58,19 @@ namespace utbot {
4858
optimizationLevel = it;
4959
}
5060
}
61+
62+
void BaseCommand::initCompiler() {
63+
auto it = commandLine.begin();
64+
compiler = it;
65+
}
66+
67+
void BaseCommand::initOutput() {
68+
auto it = findOutput();
69+
if (it != commandLine.end()) {
70+
output = it;
71+
}
72+
}
73+
5174
BaseCommand::iterator BaseCommand::findOutput() {
5275
auto it = std::find(commandLine.begin(), commandLine.end(), "-o");
5376
if (it != commandLine.end()) {
@@ -127,4 +150,20 @@ namespace utbot {
127150
optimizationLevel = addFlagToBegin(flag);
128151
}
129152
}
153+
154+
fs::path BaseCommand::getCompiler() const {
155+
return *compiler;
156+
}
157+
158+
void BaseCommand::setCompiler(fs::path compiler) {
159+
*(this->compiler) = std::move(compiler);
160+
}
161+
162+
fs::path BaseCommand::getOutput() const {
163+
return *output;
164+
}
165+
166+
void BaseCommand::setOutput(fs::path output) {
167+
*(this->output) = std::move(output);
168+
}
130169
}

server/src/building/BaseCommand.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,22 @@ namespace utbot {
2323
using iterator = decltype(commandLine)::iterator;
2424
using const_iterator = decltype(commandLine)::const_iterator;
2525

26+
iterator compiler;
27+
iterator output;
28+
2629
std::optional<iterator> optimizationLevel;
2730

2831
void initOptimizationLevel();
2932

33+
void initCompiler();
34+
35+
void initOutput();
36+
3037
[[nodiscard]] iterator findOutput();
3138

3239
iterator findOptimizationLevelFlag();
3340

34-
public:
41+
3542
BaseCommand() = default;
3643

3744
BaseCommand(std::list<std::string> commandLine, fs::path directory, bool shouldChangeDirectory = false);
@@ -42,13 +49,17 @@ namespace utbot {
4249

4350
BaseCommand(BaseCommand &&other) noexcept;
4451

52+
public:
53+
4554
[[nodiscard]] std::list<std::string> &getCommandLine();
4655

4756
[[nodiscard]] const std::list<std::string> &getCommandLine() const;
4857

4958
[[nodiscard]] const fs::path &getDirectory() const;
5059

51-
[[nodiscard]] virtual fs::path getOutput() const = 0;
60+
[[nodiscard]] fs::path getOutput() const;
61+
62+
void setOutput(fs::path output);
5263

5364
[[nodiscard]] virtual bool isArchiveCommand() const = 0;
5465

@@ -89,6 +100,10 @@ namespace utbot {
89100
size_t erase_if(std::function<bool(std::string)> f);
90101

91102
void setOptimizationLevel(const std::string &flag);
103+
104+
[[nodiscard]] fs::path getCompiler() const;
105+
106+
void setCompiler(fs::path compiler);
92107
};
93108
}
94109

0 commit comments

Comments
 (0)