summaryrefslogtreecommitdiff
path: root/src/task_so.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_so.cc
parent80db51ae3f7d5fbfb52eee4505f615ea4edba62d (diff)
Refactor the way task names are looked up.
Diffstat (limited to 'src/task_so.cc')
-rw-r--r--src/task_so.cc33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/task_so.cc b/src/task_so.cc
index 44340dd..34de2bb 100644
--- a/src/task_so.cc
+++ b/src/task_so.cc
@@ -15,16 +15,16 @@ TaskSO::TaskSO(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::path base = sourceDir;
+ std::filesystem::create_directories(std::filesystem::path(settings.builddir) / base);
- targetFile = base / target;
+ _targetFile = base / target;
for(const auto& object : objects)
{
std::filesystem::path objectFile = object;
@@ -39,7 +39,7 @@ TaskSO::TaskSO(const BuildConfiguration& config,
depFiles.push_back(depFile);
}
- flagsFile = base / targetFile.stem();
+ flagsFile = std::filesystem::path(settings.builddir) / cleanUp(sourceDir) / targetFile().stem();
flagsFile += ".flags";
target_type = TargetType::DynamicLibrary;
@@ -57,7 +57,7 @@ TaskSO::TaskSO(const BuildConfiguration& config,
bool TaskSO::dirtyInner()
{
- if(!std::filesystem::exists(targetFile))
+ if(!std::filesystem::exists(targetFile()))
{
return true;
}
@@ -87,7 +87,7 @@ int TaskSO::runInner()
args.push_back("-shared");
args.push_back("-o");
- args.push_back(targetFile.string());
+ args.push_back(targetFile().string());
for(const auto& task : getDependsTasks())
{
@@ -111,7 +111,7 @@ int TaskSO::runInner()
if(settings.verbose == 0)
{
- std::cout << "LD => " << targetFile.string() << "\n";
+ std::cout << "LD => " << targetFile().string() << "\n";
}
auto tool = compiler();
@@ -120,10 +120,10 @@ int TaskSO::runInner()
int TaskSO::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))
@@ -153,7 +153,12 @@ std::vector<std::string> TaskSO::depends() const
std::string TaskSO::target() const
{
- return targetFile.string();
+ return _targetFile.string();
+}
+
+std::filesystem::path TaskSO::targetFile() const
+{
+ return std::filesystem::path(settings.builddir) / sourceDir / _targetFile;
}
bool TaskSO::derived() const