Skip to content

Commit fd07fd3

Browse files
author
Samat Gaynutdinov
committed
refactor
1 parent 5a52bcd commit fd07fd3

File tree

9 files changed

+11
-41
lines changed

9 files changed

+11
-41
lines changed

server/src/Paths.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ namespace Paths {
393393
return fs::relative(source.parent_path(), projectContext.projectPath);
394394
}
395395

396-
std::optional<std::string> getRelativePathWithShellVariable(const string &shellVariableForBase,
396+
std::optional<std::string> getRelativePathWithShellVariable(const std::string &shellVariableForBase,
397397
const fs::path &base,
398398
const fs::path &source) {
399399

server/src/Paths.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ namespace Paths {
164164
if (projectName.empty()) {
165165
return tmpPath / "tmp" / RequestEnvironment::getClientId();
166166
}
167-
// return tmpPath / "tmp" / RequestEnvironment::getClientId() / projectName;
168167
// here projectName is actually buildPath
169168
return fs::path(projectName) / CompilationUtils::MOUNTED_CC_JSON_DIR_NAME / "tmp" /
170169
RequestEnvironment::getClientId();
@@ -187,7 +186,7 @@ namespace Paths {
187186
return tmpPath / "tmp" / "clients.json";
188187
}
189188

190-
fs::path getCCJsonFileFullPath(const string &filename, const fs::path &directory);
189+
fs::path getCCJsonFileFullPath(const std::string &filename, const fs::path &directory);
191190

192191
bool isPath(const std::string &possibleFilePath) noexcept;
193192
//endregion

server/src/Server.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,6 @@ Status Server::TestsGenServiceImpl::PrintModulesContent(ServerContext *context,
574574

575575
MEASURE_FUNCTION_EXECUTION_TIME
576576

577-
// fs::path serverBuildDir = Paths::getTmpDir(request->projectname());
578577
utbot::ProjectContext projectContext{ *request };
579578
fs::path serverBuildDir = Paths::getTmpDir(projectContext);
580579
std::shared_ptr<BuildDatabase> buildDatabase = BuildDatabase::create(projectContext);

server/src/building/BaseCommand.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,4 @@ namespace utbot {
128128
void BaseCommand::setDirectory(const fs::path& directory) {
129129
this->directory = directory;
130130
}
131-
}
131+
}

server/src/building/UserProjectConfiguration.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Status UserProjectConfiguration::RunBuildDirectoryCreation(const fs::path &build
4040
Status
4141
UserProjectConfiguration::RunProjectConfigurationCommands(const fs::path &buildDirPath,
4242
const utbot::ProjectContext& projectContext,
43-
vector<std::string> cmakeOptions,
43+
std::vector<std::string> cmakeOptions,
4444
ProjectConfigWriter const &writer) {
4545
try {
4646
fs::path bearShPath = createBearShScript(buildDirPath);
@@ -125,8 +125,6 @@ Status UserProjectConfiguration::RunProjectReConfigurationCommands(const fs::pat
125125
const fs::path &projectDirPath,
126126
const utbot::ProjectContext &projectContext,
127127
std::vector<std::string> cmakeOptions,
128-
const std::string &projectName,
129-
std::vector<std::string> cmakeOptions,
130128
ProjectConfigWriter const &writer) {
131129
try {
132130
fs::remove_all(Paths::getTmpDir(""));

server/src/printers/NativeMakefilePrinter.cpp

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -151,26 +151,13 @@ namespace printer {
151151
declareVariableIfNotDefined("clang", getRelativePathWithShellVariable(
152152
Paths::getUTBotInstallDir(), Paths::getUTBotClang()));
153153
declareVariableIfNotDefined("clangpp", stringFormat("%s/bin/clang++", pathToShellVariable.at(Paths::getUTBotInstallDir())));
154-
// declareAction(stringFormat("clangpp = %s", getRelativePathWithShellVariable(
155-
// Paths::getUTBotInstallDir(), Paths::getUTBotClangPP())));
156154
declareVariableIfNotDefined("gcc", Paths::getGcc());
157155
declareVariableIfNotDefined("gpp", Paths::getGpp());
158-
//
159-
// declareVariableIfNotDefined("CC", getShellByCompiler(primaryCompiler));
160-
// declareVariableIfNotDefined("CXX", getShellByCompiler(primaryCxxCompiler));
161156

162157
declareVariableIfNotDefined("ar", Paths::getAr());
163158
declareVariableIfNotDefined("ld", Paths::getLd());
164159
declareVariableIfNotDefined("ldGold", Paths::getLdGold());
165160

166-
// declareVariableIfNotDefined("CxxLinker", getShellByLinker(cxxLinker));
167-
168-
// here we possibly erase mapping of someLinker -> shellVar but we don't care since we only use
169-
// cxxLinker, primaryCompiler and primaryCxxCompiler later on for reference
170-
// pathToShellVariable[cxxLinker] = "$(CxxLinker)";
171-
// pathToShellVariable[primaryCompiler] = "$(CC)";
172-
// pathToShellVariable[{primaryCxxCompiler}] = "$(CXX)";
173-
174161

175162

176163
declareVariable("asanLib", Paths::getAsanLibraryPath());
@@ -189,11 +176,11 @@ namespace printer {
189176
declareTarget(FORCE, {}, {});
190177

191178
comment("gtest");
192-
// fs::path gtestBuildDirectory = buildDirectory / "googletest";
179+
193180
fs::path gtestBuildDirectory = getRelativePathWithShellVariable(buildDirectory,
194181
buildDirectory / "googletest");
195182
fs::path defaultPath = "default.c";
196-
std::vector<std::string> defaultGtestCompileCommandLine{getShellByCompiler(primaryCxxCompiler), "-c", "-std=c++11",
183+
std::vector<std::string> defaultGtestCompileCommandLine{ getShellByCompiler(primaryCxxCompiler), "-c", "-std=c++11",
197184
FPIC_FLAG, defaultPath };
198185
utbot::CompileCommand defaultGtestCompileCommand{ defaultGtestCompileCommandLine,
199186
pathToShellVariable.at(buildDirectory), defaultPath };
@@ -217,14 +204,12 @@ namespace printer {
217204
fs::path relativePath = fs::relative(file, projectContext.projectPath);
218205
return getRelativePathWithShellVariable(buildDirectory, dependencyDirectory) /
219206
Paths::addExtension(relativePath, ".Td");
220-
// return dependencyDirectory / Paths::addExtension(relativePath, ".Td");
221207
}
222208

223209
fs::path NativeMakefilePrinter::getDependencyFile(fs::path const &file) {
224210
fs::path relativePath = fs::relative(file, projectContext.projectPath);
225211
return getRelativePathWithShellVariable(buildDirectory, dependencyDirectory) /
226212
Paths::addExtension(relativePath, ".d");
227-
// return dependencyDirectory / Paths::addExtension(relativePath, ".d");
228213
}
229214

230215
void NativeMakefilePrinter::gtestAllTargets(const utbot::CompileCommand &defaultCompileCommand,
@@ -240,7 +225,7 @@ namespace printer {
240225
{ stringFormat("-I%s", getRelativePathWithShellVariable(gtestLib, gtestLib / "googletest/include")),
241226
stringFormat("-I%s", getRelativePathWithShellVariable(gtestLib, gtestLib / "googletest")) });
242227

243-
declareTarget(gtestAllObjectFile, {gtestCompilationArguments.getSourcePath() },
228+
declareTarget(gtestAllObjectFile, { gtestCompilationArguments.getSourcePath() },
244229
{ gtestCompilationArguments.toStringWithChangingDirectory() });
245230
declareVariable("GTEST_ALL", gtestAllObjectFile);
246231

@@ -328,7 +313,6 @@ namespace printer {
328313
recompiledFile = Paths::getRecompiledFile(projectContext, pathToCompile);
329314
buildResultType = BuildResult::Type::ALL_STUBS;
330315

331-
// pathToCompile = getRelativePathWithShellVariable(projectContext.projectPath, pathToCompile);
332316
} else {
333317
if (Paths::isCXXFile(sourcePath)) {
334318
pathToCompile = sourcePath;
@@ -338,11 +322,8 @@ namespace printer {
338322
recompiledFile =
339323
Paths::getRecompiledFile(projectContext, compilationUnitInfo->getOutputFile());
340324
buildResultType = BuildResult::Type::NO_STUBS;
341-
342-
// pathToCompile = getRelativePathWithShellVariable(buildDirectory, pathToCompile);
343325
}
344326

345-
// recompiledFile = getRelativePathWithShellVariable(buildDirectory, recompiledFile);
346327
buildResult = { recompiledFile, buildResultType};
347328

348329
addCompileTarget(pathToCompile, buildResult.output, *compilationUnitInfo);
@@ -436,7 +417,6 @@ namespace printer {
436417
sharedOutput.value().parent_path())));
437418
dynamicLinkCommand.addFlagToBegin("$(LDFLAGS)");
438419

439-
// auto linker = pathToShellVariable.at(getLinker(cxxLinker));
440420
auto linker = getShellByLinker(cxxLinker);
441421
dynamicLinkCommand.setLinker(linker);
442422
dynamicLinkCommand.setOutput(
@@ -507,7 +487,7 @@ namespace printer {
507487
testRunCommand.addEnvironmentVariable(SanitizerUtils::ASAN_OPTIONS_NAME,
508488
SanitizerUtils::ASAN_OPTIONS_VALUE);
509489

510-
declareTarget("build", {getRelativePathWithShellVariableForProjectDirOrBuildDirOrRootDir(testExecutablePath) }, {});
490+
declareTarget("build", { getRelativePathWithShellVariableForProjectDirOrBuildDirOrRootDir(testExecutablePath) }, {});
511491
declareTarget("run", { "build" },
512492
{ testRunCommand.toStringWithChangingDirectory() });
513493

@@ -612,7 +592,6 @@ namespace printer {
612592
}
613593

614594
fs::path linker = linkCommand.getLinker();
615-
// linkCommand.setLinker(pathToShellVariable.at(getLinker(linkCommand.getLinker())));
616595
linkCommand.setLinker(getShellByLinker(linker));
617596

618597

@@ -633,7 +612,7 @@ namespace printer {
633612
});
634613

635614

636-
string recompiledFileRelative = getRelativePathWithShellVariableForProjectDirOrBuildDirOrRootDir(recompiledFile);
615+
std::string recompiledFileRelative = getRelativePathWithShellVariableForProjectDirOrBuildDirOrRootDir(recompiledFile);
637616
std::string removeAction = stringFormat("rm -f %s", recompiledFileRelative);
638617
std::vector<std::string> actions{ removeAction };
639618
CollectionUtils::extend(actions, std::move(commandActions));
@@ -647,7 +626,7 @@ namespace printer {
647626
auto sharedOutputRelative = getRelativePathWithShellVariableForProjectDirOrBuildDirOrRootDir(
648627
sharedOutput.value());
649628
std::vector<std::string> sharedLinkCommandLine{
650-
getShellByCompiler(primaryCompiler), "$(LDFLAGS)",
629+
getShellByCompiler(primaryCompiler), "$(LDFLAGS)",
651630
SHARED_FLAG, coverageLinkFlags,
652631
sanitizerLinkFlags, "-o",
653632
sharedOutputRelative, "-Wl,--whole-archive",

server/src/printers/NativeMakefilePrinter.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ namespace printer {
3636

3737
CollectionUtils::MapFileTo<std::string> pathToShellVariable;
3838

39-
const std::string shellPrimaryCompiler = "$(CC)";
40-
const std::string shellPrimaryCxxCompiler = "$(CXX)";
41-
const std::string shellCxxLinker = "$(CxxLinker)";
42-
4339
std::vector<fs::path> artifacts{};
4440

4541
CollectionUtils::FileSet const *const stubSources = nullptr;

server/src/printers/SourceWrapperPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace printer {
2525
auto sourcePathRelativeToProjectDir = fs::relative(sourceFilePath, projectContext.projectPath);
2626
auto projectDirRelativeToWrapperFile =
2727
fs::relative(projectContext.projectPath, wrapperFilePath.parent_path());
28-
// strInclude(Include(false, sourceFilePath));
28+
2929
strInclude(Include(false, projectDirRelativeToWrapperFile / sourcePathRelativeToProjectDir));
3030

3131
ss << wrapperDefinitions;

server/test/framework/Server_Tests.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,6 @@ namespace {
881881
};
882882

883883
const std::vector<CompilerName> compilerNames = { CompilerName::CLANG, CompilerName::GCC };
884-
// const std::vector<CompilerName> compilerNames = { CompilerName::CLANG};
885884

886885
#define INSTANTIATE_TEST_SUITE_P_DifferentCompilers(test_suite_name) \
887886
INSTANTIATE_TEST_SUITE_P( \

0 commit comments

Comments
 (0)