From f8c294442d75ada7dfc47f88d90c7063a5e409fc Mon Sep 17 00:00:00 2001 From: Hat Kid <6624576+Hat-Kid@users.noreply.github.com> Date: Mon, 16 Oct 2023 17:30:04 +0200 Subject: [PATCH] `build-level2` tool --- goalc/make/MakeSystem.cpp | 1 + goalc/make/Tools.cpp | 22 ++++++++++++++++++++-- goalc/make/Tools.h | 7 +++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/goalc/make/MakeSystem.cpp b/goalc/make/MakeSystem.cpp index 4f8429a039..463adc6a3d 100644 --- a/goalc/make/MakeSystem.cpp +++ b/goalc/make/MakeSystem.cpp @@ -102,6 +102,7 @@ MakeSystem::MakeSystem(const std::optional repl_config, const std: add_tool(); add_tool(); add_tool(); + add_tool(); } /*! diff --git a/goalc/make/Tools.cpp b/goalc/make/Tools.cpp index e929a21aff..12a0a3c786 100644 --- a/goalc/make/Tools.cpp +++ b/goalc/make/Tools.cpp @@ -4,7 +4,8 @@ #include "common/util/DgoWriter.h" #include "common/util/FileUtil.h" -#include "goalc/build_level/build_level.h" +#include "goalc/build_level/jak1/build_level.h" +#include "goalc/build_level/jak2/build_level.h" #include "goalc/compiler/Compiler.h" #include "goalc/data_compiler/dir_tpages.h" #include "goalc/data_compiler/game_count.h" @@ -258,5 +259,22 @@ bool BuildLevelTool::run(const ToolInput& task, const PathMap& path_map) { if (task.input.size() != 1) { throw std::runtime_error(fmt::format("Invalid amount of inputs to {} tool", name())); } - return run_build_level(task.input.at(0), task.output.at(0), path_map.output_prefix); + return jak1::run_build_level(task.input.at(0), task.output.at(0), path_map.output_prefix); +} + +BuildLevel2Tool::BuildLevel2Tool() : Tool("build-level2") {} + +bool BuildLevel2Tool::needs_run(const ToolInput& task, const PathMap& path_map) { + if (task.input.size() != 1) { + throw std::runtime_error(fmt::format("Invalid amount of inputs to {} tool", name())); + } + auto deps = get_build_level_deps(task.input.at(0)); + return Tool::needs_run({task.input, deps, task.output, task.arg}, path_map); +} + +bool BuildLevel2Tool::run(const ToolInput& task, const PathMap& path_map) { + if (task.input.size() != 1) { + throw std::runtime_error(fmt::format("Invalid amount of inputs to {} tool", name())); + } + return jak2::run_build_level(task.input.at(0), task.output.at(0), path_map.output_prefix); } diff --git a/goalc/make/Tools.h b/goalc/make/Tools.h index a3c6d5e3f7..45b24035a1 100644 --- a/goalc/make/Tools.h +++ b/goalc/make/Tools.h @@ -78,3 +78,10 @@ class BuildLevelTool : public Tool { bool run(const ToolInput& task, const PathMap& path_map) override; bool needs_run(const ToolInput& task, const PathMap& path_map) override; }; + +class BuildLevel2Tool : public Tool { + public: + BuildLevel2Tool(); + bool run(const ToolInput& task, const PathMap& path_map) override; + bool needs_run(const ToolInput& task, const PathMap& path_map) override; +};