mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 11:26:18 -04:00
af447aeab7
* add subtitles support (tools + goal + text file). * add to build system proper * better handling of line speakers * billy test subtitles * adjust timings * better handling of subtitle timing + citadel subs * press square to toggle cutscene subtitles * improve DirectRenderer performance * clang * dont error out if there's no user files * make system supports multiple inputs for subtitles * clang * oh no typo!! * avoid future issues * fix warp gate crash * remove no longer necessary code in DirectRenderer * remove temp prints * delete triplicate code * i found a better way * fix make issues with subtitles * force avx compilation
62 lines
1.8 KiB
C++
62 lines
1.8 KiB
C++
|
|
#include <chrono>
|
|
#include <filesystem>
|
|
|
|
#include "third-party/fmt/core.h"
|
|
|
|
#include "Tool.h"
|
|
#include "common/util/FileUtil.h"
|
|
|
|
Tool::Tool(const std::string& name) : m_name(name) {}
|
|
|
|
bool Tool::needs_run(const ToolInput& task) {
|
|
// for this to return false, all outputs need to be newer than all inputs.
|
|
|
|
for (auto& in : task.input) {
|
|
auto in_file = std::filesystem::path(file_util::get_file_path({in}));
|
|
|
|
if (!std::filesystem::exists(in_file)) {
|
|
throw std::runtime_error(fmt::format("Input file {} does not exist.", in));
|
|
}
|
|
|
|
auto newest_input = std::filesystem::last_write_time(in_file);
|
|
for (auto& dep : task.deps) {
|
|
auto dep_path = std::filesystem::path(file_util::get_file_path({dep}));
|
|
if (std::filesystem::exists(dep_path)) {
|
|
auto dep_time = std::filesystem::last_write_time(dep_path);
|
|
if (dep_time > newest_input) {
|
|
newest_input = dep_time;
|
|
}
|
|
} else {
|
|
return true; // don't have a dep.
|
|
}
|
|
}
|
|
|
|
for (auto& dep : get_additional_dependencies(task)) {
|
|
auto dep_path = std::filesystem::path(file_util::get_file_path({dep}));
|
|
if (std::filesystem::exists(dep_path)) {
|
|
auto dep_time = std::filesystem::last_write_time(dep_path);
|
|
if (dep_time > newest_input) {
|
|
newest_input = dep_time;
|
|
}
|
|
} else {
|
|
return true; // don't have a dep.
|
|
}
|
|
}
|
|
|
|
for (auto& out : task.output) {
|
|
auto out_path = std::filesystem::path(file_util::get_file_path({out}));
|
|
if (std::filesystem::exists(out_path)) {
|
|
auto out_time = std::filesystem::last_write_time(out_path);
|
|
if (out_time < newest_input) {
|
|
return true;
|
|
}
|
|
} else {
|
|
return true; // don't have a dep.
|
|
}
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|