diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2021-06-12 16:16:41 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2021-06-12 16:16:41 +0200 |
commit | 6bcbf18a6a67707c13d66b96770c8b210a45b9f4 (patch) | |
tree | bbbc866f84df2985db6ca8719884e4fb09fd10cf /task.cc | |
parent | 889106af4d8381ac188a6532625e2c642150220f (diff) |
Skip non-dirty tasks.
Diffstat (limited to 'task.cc')
-rw-r--r-- | task.cc | 95 |
1 files changed, 48 insertions, 47 deletions
@@ -94,84 +94,80 @@ Task::Task(const BuildConfiguration& config, const Settings& settings, depsFile += ".d"; } -int Task::run() +bool Task::dirty() { if(!std::filesystem::exists(sourceFile)) { - std::cout << "Missing source file: " << std::string(sourceFile) << "\n"; - return 1; + //std::cout << "Missing source file: " << std::string(sourceFile) << "\n"; + return true; } - bool recompile{false}; - - if(!recompile && - !std::filesystem::exists(targetFile)) + if(!std::filesystem::exists(targetFile)) { - recompile = true; //std::cout << "Missing targetFile\n"; + return true; } - if(!recompile && - !std::filesystem::exists(depsFile)) + if(!std::filesystem::exists(depsFile)) { - recompile = true; //std::cout << "Missing depsFile\n"; + return true; } - if(!recompile && - std::filesystem::last_write_time(sourceFile) > + if(std::filesystem::last_write_time(sourceFile) > std::filesystem::last_write_time(depsFile)) { - recompile = true; //std::cout << "The sourceFile newer than depsFile\n"; + return true; } - if(!recompile) + auto depList = readDeps(depsFile); + for(const auto& dep : depList) { - auto depList = readDeps(depsFile); - for(const auto& dep : depList) + if(!std::filesystem::exists(dep) || + std::filesystem::last_write_time(targetFile) < + std::filesystem::last_write_time(dep)) { - if(!std::filesystem::exists(dep) || - std::filesystem::last_write_time(targetFile) < - std::filesystem::last_write_time(dep)) - { - recompile = true; - //std::cout << "The targetFile older than dep\n"; - break; - } + //std::cout << "The targetFile older than " << std::string(dep) << "\n"; + return true; } } - if(!recompile && - std::filesystem::last_write_time(sourceFile) > + if(std::filesystem::last_write_time(sourceFile) > std::filesystem::last_write_time(targetFile)) { - recompile = true; //std::cout << "The targetFile older than sourceFile\n"; + return true; } - if(recompile) + return false; +} + +int Task::run() +{ + if(!std::filesystem::exists(sourceFile)) { - std::string comp = "g++"; - std::string flags = config.cxxflags; - if(std::string(sourceFile.extension()) == ".c") - { - comp = "gcc"; - flags = config.cflags; - } - std::string cmd = comp + - " -MMD -c " + std::string(sourceFile) + " " + - flags + " " + - "-o " + std::string(targetFile); - std::cout << cmd << "\n"; + std::cout << "Missing source file: " << std::string(sourceFile) << "\n"; + return 1; + } - if(system(cmd.data())) - { - return 1; - } - return 0; + std::string comp = "g++"; + std::string flags = config.cxxflags; + if(std::string(sourceFile.extension()) == ".c") + { + comp = "gcc"; + flags = config.cflags; } + std::string cmd = comp + + " -MMD -c " + std::string(sourceFile) + " " + + flags + " " + + "-o " + std::string(targetFile); + std::cout << cmd << "\n"; + if(system(cmd.data())) + { + return 1; + } return 0; } @@ -192,7 +188,12 @@ int Task::clean() return 0; } -std::vector<std::string> Task::depends() +std::vector<std::string> Task::depends() const { return {}; } + +std::string Task::target() const +{ + return targetFile; +} |