From e73ee708292aac55070701ff0157db4eab6c06f4 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Mon, 27 Sep 2021 21:32:17 +0200 Subject: Add folder hierarchy in build folder corresponding to that of the source folders and store build-files in corresponding locations. --- src/task_ld.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/task_ld.cc') diff --git a/src/task_ld.cc b/src/task_ld.cc index 7710bb0..10b8bce 100644 --- a/src/task_ld.cc +++ b/src/task_ld.cc @@ -29,7 +29,8 @@ std::string readFile(const std::string &fileName) TaskLD::TaskLD(const BuildConfiguration& config, const Settings& settings, const std::string& target, - const std::vector& objects) + const std::vector& objects, + const std::string& sourcePath) : Task(config) , config(config) , settings(settings) @@ -40,8 +41,11 @@ TaskLD::TaskLD(const BuildConfiguration& config, target_type = TargetType::Executable; } - targetFile = settings.builddir; - targetFile /= target; + std::filesystem::path base = settings.builddir; + base /= sourcePath; + std::filesystem::create_directories(base); + + targetFile = base / target; for(const auto& object : objects) { std::filesystem::path objectFile = object; @@ -56,7 +60,7 @@ TaskLD::TaskLD(const BuildConfiguration& config, depFiles.push_back(depFile); } - flagsFile = settings.builddir / targetFile.stem(); + flagsFile = base / targetFile.stem(); flagsFile += ".flags"; source_language = Language::C; -- cgit v1.2.3