Skip to content

Commit de6c46d

Browse files
author
Samat Gaynutdinov
committed
refactor: move comparator to definition
1 parent 5c2ad06 commit de6c46d

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

server/src/printers/NativeMakefilePrinter.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,12 @@ namespace printer {
111111
pathToShellVariable({{buildDirectory, "$(BUILD_DIR)"},
112112
{projectContext.projectPath, "$(PROJECT_DIR)"},
113113
{buildDirectoryRelative, "$(BUILD_RELATIVE)"}},
114-
comparator
114+
[](const std::string& lhs, const std::string& rhs) -> bool {
115+
if (rhs == Paths::getUTBotRootDir().string()) {
116+
return true;
117+
}
118+
return std::greater<>()(lhs, rhs);
119+
}
115120
),
116121
stubSources(stubSources) {
117122

@@ -703,8 +708,8 @@ namespace printer {
703708

704709
fs::path NativeMakefilePrinter::getRelativePathForLinker(fs::path path) const {
705710
const auto compiler = CompilationUtils::getCompilerName(path);
706-
if (compiler == CompilationUtils::CompilerName::UNKNOWN) {
707-
// not compiler
711+
if (compiler == CompilationUtils::CompilerName::CLANGXX) {
712+
// don't transform to canonical if CLANGXX
708713
return getRelativePath(path);
709714
}
710715
return getRelativePath(path, false);

server/src/printers/NativeMakefilePrinter.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ namespace printer {
1515
class NativeMakefilePrinter : public DefaultMakefilePrinter {
1616
friend class TestMakefilesPrinter;
1717
private:
18-
std::function<bool(const std::string&, const std::string&)> comparator = [](const std::string& lhs, const std::string& rhs) -> bool {
19-
if (rhs == Paths::getUTBotRootDir().string()) {
20-
return true;
21-
}
22-
return std::greater<>()(lhs, rhs);
23-
};
2418
const utbot::ProjectContext projectContext;
2519
std::shared_ptr<BuildDatabase> buildDatabase;
2620
fs::path rootPath;
@@ -38,7 +32,7 @@ namespace printer {
3832
fs::path buildDirectory, dependencyDirectory, buildDirectoryRelative;
3933

4034
// map variable with absolute path to $(someVar)
41-
std::map<std::string, fs::path, decltype(comparator)> pathToShellVariable;
35+
std::map<std::string, fs::path, std::function<bool(const std::string&, const std::string&)>> pathToShellVariable;
4236

4337
std::vector<fs::path> artifacts{};
4438

0 commit comments

Comments
 (0)