diff options
-rw-r--r-- | src/task_ar.cc | 8 | ||||
-rw-r--r-- | src/task_cc.cc | 8 | ||||
-rw-r--r-- | src/task_fn.cc | 14 | ||||
-rw-r--r-- | src/task_ld.cc | 8 | ||||
-rw-r--r-- | src/task_so.cc | 8 |
5 files changed, 38 insertions, 8 deletions
diff --git a/src/task_ar.cc b/src/task_ar.cc index 512815f..3b45cc2 100644 --- a/src/task_ar.cc +++ b/src/task_ar.cc @@ -121,7 +121,13 @@ int TaskAR::runInner() break; } - return execute(settings, tool, args, c.env); + auto res = execute(settings, tool, args, c.env); + if(res != 0) + { + std::filesystem::remove(targetFile()); + } + + return res; } int TaskAR::clean() diff --git a/src/task_cc.cc b/src/task_cc.cc index cd2b51c..b9edcf7 100644 --- a/src/task_cc.cc +++ b/src/task_cc.cc @@ -192,7 +192,13 @@ int TaskCC::runInner() } const auto& cfg = ctor::get_configuration(); - return execute(settings, compiler(), args, cfg.env); + auto res = execute(settings, compiler(), args, cfg.env); + if(res != 0) + { + std::filesystem::remove(targetFile()); + } + + return res; } int TaskCC::clean() diff --git a/src/task_fn.cc b/src/task_fn.cc index 1ff72f9..b6b50ea 100644 --- a/src/task_fn.cc +++ b/src/task_fn.cc @@ -74,10 +74,16 @@ int TaskFn::runInner() std::cout << output << std::flush; } - return config.function(sourceFile.string(), - targetFile().string(), - config, - settings); + auto res = config.function(sourceFile.string(), + targetFile().string(), + config, + settings); + if(res != 0) + { + std::filesystem::remove(targetFile()); + } + + return res; } int TaskFn::clean() diff --git a/src/task_ld.cc b/src/task_ld.cc index d719ce7..69c3a8a 100644 --- a/src/task_ld.cc +++ b/src/task_ld.cc @@ -129,7 +129,13 @@ int TaskLD::runInner() auto tool = compiler(); const auto& c = ctor::get_configuration(); - return execute(settings, tool, args, c.env, is_self); + auto res = execute(settings, tool, args, c.env, is_self); + if(res != 0) + { + std::filesystem::remove(targetFile()); + } + + return res; } int TaskLD::clean() diff --git a/src/task_so.cc b/src/task_so.cc index 85e80e4..c98e4a7 100644 --- a/src/task_so.cc +++ b/src/task_so.cc @@ -116,7 +116,13 @@ int TaskSO::runInner() auto tool = compiler(); const auto& cfg = ctor::get_configuration(); - return execute(settings, tool, args, cfg.env); + auto res = execute(settings, tool, args, cfg.env); + if(res != 0) + { + std::filesystem::remove(targetFile()); + } + + return res; } int TaskSO::clean() |