diff --git a/server/src/printers/RelativeMakefilePrinter.cpp b/server/src/printers/RelativeMakefilePrinter.cpp index 40e3c00a..041e7231 100644 --- a/server/src/printers/RelativeMakefilePrinter.cpp +++ b/server/src/printers/RelativeMakefilePrinter.cpp @@ -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 { @@ -23,6 +25,7 @@ RelativeMakefilePrinter::RelativeMakefilePrinter( return std::greater<>()(lhs, rhs); }}, buildDirectoryRelative{buildDirectoryRelative}, + testsPath{testsPath}, projectPath{projectPath} { initializePathsToShellVariables(); } @@ -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(); } diff --git a/server/src/printers/RelativeMakefilePrinter.h b/server/src/printers/RelativeMakefilePrinter.h index b8f963a3..d9fd71a9 100644 --- a/server/src/printers/RelativeMakefilePrinter.h +++ b/server/src/printers/RelativeMakefilePrinter.h @@ -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; @@ -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> pathToShellVariable; diff --git a/server/src/printers/TestMakefilesPrinter.cpp b/server/src/printers/TestMakefilesPrinter.cpp index d07b087d..28f5adfb 100644 --- a/server/src/printers/TestMakefilesPrinter.cpp +++ b/server/src/printers/TestMakefilesPrinter.cpp @@ -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) {