diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2021-06-18 07:27:57 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2021-06-18 08:07:20 +0200 |
commit | 80290e7d65dc498e9ea5e64aa6cbc65282072deb (patch) | |
tree | 796f723f449d58615c6d81f5eecd212a1e4d0399 /task_ld.cc | |
parent | 33addfbf9cc21cd69b3d6476eb0c062bb2c6fcfb (diff) |
New dependency system.
Diffstat (limited to 'task_ld.cc')
-rw-r--r-- | task_ld.cc | 54 |
1 files changed, 49 insertions, 5 deletions
@@ -21,13 +21,27 @@ std::string readFile(const std::string &fileName) return std::string(bytes.data(), fileSize); } + +std::vector<std::string> addPrefix(const std::vector<std::string>& lst, + const Settings& settings) +{ + std::vector<std::string> out; + for(const auto& item : lst) + { + std::filesystem::path file = settings.builddir; + file /= item; + out.push_back(file.string()); + } + return out; +} } // namespace :: TaskLD::TaskLD(const BuildConfiguration& config, const Settings& settings, const std::string& target, const std::vector<std::string>& objects) - : config(config) + : Task(addPrefix(config.depends, settings)) + , config(config) , settings(settings) { targetFile = settings.builddir; @@ -36,13 +50,21 @@ TaskLD::TaskLD(const BuildConfiguration& config, { std::filesystem::path objectFile = object; objectFiles.push_back(objectFile); + dependsStr.push_back(objectFile); + } + + for(const auto& dep : config.depends) + { + std::filesystem::path depFile = settings.builddir; + depFile /= dep; + depFiles.push_back(depFile); } flagsFile = settings.builddir / targetFile.stem(); flagsFile += ".flags"; } -bool TaskLD::dirty() +bool TaskLD::dirtyInner() { if(!std::filesystem::exists(targetFile)) { @@ -75,7 +97,7 @@ bool TaskLD::dirty() return false; } -int TaskLD::run() +int TaskLD::runInner() { std::string objectlist; for(const auto& objectFile : objectFiles) @@ -92,6 +114,12 @@ int TaskLD::run() { args.push_back(std::string(objectFile)); } + + for(const auto& depFile : depFiles) + { + args.push_back(depFile.string()); + } + for(const auto& flag : config.ldflags) { args.push_back(flag); @@ -104,7 +132,12 @@ int TaskLD::run() flagsStream << flagsString(); } - return execute("/usr/bin/g++", args); + if(settings.verbose == 0) + { + std::cout << "LD => " << targetFile.string() << "\n"; + } + + return execute("/usr/bin/g++", args, settings.verbose > 0); } int TaskLD::clean() @@ -126,7 +159,18 @@ int TaskLD::clean() std::vector<std::string> TaskLD::depends() const { - return {}; + std::vector<std::string> deps; + for(const auto& objectFile : objectFiles) + { + deps.push_back(objectFile.string()); + } + + for(const auto& depFile : depFiles) + { + deps.push_back(depFile.string()); + } + + return deps; } std::string TaskLD::target() const |