summaryrefslogtreecommitdiff
path: root/src/task_ar.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2022-06-07 18:06:57 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2022-06-09 22:20:31 +0200
commitdafd592cf44c184f9d24e2216bbed5c23e4b23c2 (patch)
treee94ab4c49ec4486e3a8e91c04cbba73a221d54c7 /src/task_ar.cc
parent80db51ae3f7d5fbfb52eee4505f615ea4edba62d (diff)
Refactor the way task names are looked up.
Diffstat (limited to 'src/task_ar.cc')
-rw-r--r--src/task_ar.cc42
1 files changed, 22 insertions, 20 deletions
diff --git a/src/task_ar.cc b/src/task_ar.cc
index 086ffa1..5a86ead 100644
--- a/src/task_ar.cc
+++ b/src/task_ar.cc
@@ -15,16 +15,15 @@ TaskAR::TaskAR(const BuildConfiguration& config,
const Settings& settings,
const std::string& target,
const std::vector<std::string>& objects,
- const std::string& sourcePath)
- : Task(config)
+ const std::string& sourceDir)
+ : Task(config, settings, sourceDir)
, config(config)
, settings(settings)
+ , sourceDir(sourceDir)
{
- std::filesystem::path base = settings.builddir;
- base /= sourcePath;
- std::filesystem::create_directories(base);
+ std::filesystem::create_directories(std::filesystem::path(settings.builddir) / sourceDir);
- targetFile = base / target;
+ _targetFile = target;
for(const auto& object : objects)
{
std::filesystem::path objectFile = object;
@@ -34,12 +33,10 @@ TaskAR::TaskAR(const BuildConfiguration& config,
for(const auto& dep : config.depends)
{
- std::filesystem::path depFile = settings.builddir;
- depFile /= dep;
- depFiles.push_back(depFile);
+ depFiles.push_back(dep);
}
- flagsFile = base / targetFile.stem();
+ flagsFile = std::filesystem::path(settings.builddir) / cleanUp(sourceDir) / targetFile().stem();
flagsFile += ".flags";
target_type = TargetType::StaticLibrary;
@@ -57,7 +54,7 @@ TaskAR::TaskAR(const BuildConfiguration& config,
bool TaskAR::dirtyInner()
{
- if(!std::filesystem::exists(targetFile))
+ if(!std::filesystem::exists(targetFile()))
{
return true;
}
@@ -83,10 +80,10 @@ int TaskAR::runInner()
{
std::vector<std::string> args;
args.push_back("rcs");
- args.push_back(targetFile.string());
+ args.push_back(targetFile().string());
for(const auto& task : getDependsTasks())
{
- args.push_back(task->target());
+ args.push_back(task->targetFile().string());
}
{ // Write flags to file.
@@ -96,7 +93,7 @@ int TaskAR::runInner()
if(settings.verbose == 0)
{
- std::cout << "AR => " << targetFile.string() << "\n";
+ std::cout << "AR => " << targetFile().string() << "\n";
}
std::string tool;
@@ -115,10 +112,10 @@ int TaskAR::runInner()
int TaskAR::clean()
{
- if(std::filesystem::exists(targetFile))
+ if(std::filesystem::exists(targetFile()))
{
- std::cout << "Removing " << targetFile.string() << "\n";
- std::filesystem::remove(targetFile);
+ std::cout << "Removing " << targetFile().string() << "\n";
+ std::filesystem::remove(targetFile());
}
if(std::filesystem::exists(flagsFile))
@@ -138,9 +135,9 @@ std::vector<std::string> TaskAR::depends() const
deps.push_back(objectFile.string());
}
- for(const auto& depFile : depFiles)
+ for(const auto& dep : config.depends)
{
- deps.push_back(depFile.string());
+ deps.push_back(dep);
}
return deps;
@@ -148,7 +145,12 @@ std::vector<std::string> TaskAR::depends() const
std::string TaskAR::target() const
{
- return targetFile.string();
+ return _targetFile.string();
+}
+
+std::filesystem::path TaskAR::targetFile() const
+{
+ return std::filesystem::path(settings.builddir) / sourceDir / _targetFile;
}
bool TaskAR::derived() const