summaryrefslogtreecommitdiff
path: root/task_ld.cc
diff options
context:
space:
mode:
Diffstat (limited to 'task_ld.cc')
-rw-r--r--task_ld.cc54
1 files changed, 49 insertions, 5 deletions
diff --git a/task_ld.cc b/task_ld.cc
index de74af2..fcde6d4 100644
--- a/task_ld.cc
+++ b/task_ld.cc
@@ -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