Skip to content

Commit

Permalink
Test paths in makefiles have been replaced with relative ones (#681)
Browse files Browse the repository at this point in the history
  • Loading branch information
ladisgin committed Jun 6, 2024
1 parent e2e08a0 commit e768496
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
7 changes: 6 additions & 1 deletion server/src/printers/RelativeMakefilePrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ RelativeMakefilePrinter::RelativeMakefilePrinter(PathToShellVariable pathToShell
RelativeMakefilePrinter::RelativeMakefilePrinter(
const fs::path &buildDirectory,
const fs::path &buildDirectoryRelative,
const fs::path &projectPath)
const fs::path &projectPath,
const fs::path &testsPath)
: DefaultMakefilePrinter(),
pathToShellVariable{{{buildDirectory, "$(BUILD_DIR)"},
{testsPath, "$(TESTS_DIR)"},
{projectPath, "$(PROJECT_DIR)"},
{buildDirectoryRelative, "$(BUILD_RELATIVE)"}},
[](const std::string& lhs, const std::string& rhs) -> bool {
Expand All @@ -23,6 +25,7 @@ RelativeMakefilePrinter::RelativeMakefilePrinter(
return std::greater<>()(lhs, rhs);
}},
buildDirectoryRelative{buildDirectoryRelative},
testsPath{testsPath},
projectPath{projectPath} {
initializePathsToShellVariables();
}
Expand Down Expand Up @@ -71,6 +74,8 @@ std::string RelativeMakefilePrinter::getProjectStructureRelativeTo(const fs::pat
printer.declareVariable("export PROJECT_DIR", "$(MAKEFILE_DIR)/$(PROJECT_DIR_RELATIVE_TO_MAKEFILE)");
printer.declareVariable("export BUILD_RELATIVE", buildDirectoryRelative);
printer.declareVariable("export BUILD_DIR", "$(PROJECT_DIR)/$(BUILD_RELATIVE)");
printer.declareVariable("export TESTS_DIR_RELATIVE", fs::relative(testsPath, makefilePath.parent_path()));
printer.declareVariable("export TESTS_DIR", "$(MAKEFILE_DIR)/$(TESTS_DIR_RELATIVE)");
return printer.ss.str();
}

Expand Down
5 changes: 3 additions & 2 deletions server/src/printers/RelativeMakefilePrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class RelativeMakefilePrinter : public DefaultMakefilePrinter {
RelativeMakefilePrinter(PathToShellVariable pathToShellVariable);
RelativeMakefilePrinter(const fs::path &buildDirectory,
const fs::path &buildDirectoryRelative,
const fs::path &projectPath);
const fs::path &projectPath,
const fs::path &testsPath);

~RelativeMakefilePrinter() override = default;

Expand All @@ -23,7 +24,7 @@ class RelativeMakefilePrinter : public DefaultMakefilePrinter {
void initializePathsToShellVariables();

protected:
fs::path buildDirectoryRelative, projectPath;
fs::path buildDirectoryRelative, testsPath, projectPath;

// map variable with absolute path to $(someVar)
std::map<std::string, fs::path, std::function<bool(const std::string&, const std::string&)>> pathToShellVariable;
Expand Down
3 changes: 2 additions & 1 deletion server/src/printers/TestMakefilesPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ namespace printer {
CollectionUtils::FileSet const *stubSources) :
RelativeMakefilePrinter(Paths::getUTBotBuildDir(testGen->projectContext),
Paths::getRelativeUtbotBuildDir(testGen->projectContext),
testGen->projectContext.projectPath),
testGen->projectContext.projectPath,
testGen->projectContext.getTestDirAbsPath()),
projectContext(testGen->projectContext),
sharedMakefilePrinter(testGen, rootPath, primaryCompiler, stubSources, pathToShellVariable),
objMakefilePrinter(testGen, rootPath, primaryCompiler, stubSources, pathToShellVariable) {
Expand Down

0 comments on commit e768496

Please sign in to comment.