Files
jak-project/goalc/make/MakeSystem.h
T
Tyler Wilding eb703ee96e REPL related improvements and fixes (#3545)
Motivated by - https://github.com/open-goal/opengoal-vscode/pull/358

This addresses the following:
- Fixes #2939 spam edge-case
- Stop picking a different nREPL port based on the game mode by default,
this causes friction for tools in the average usecase (having a REPL
open for a single game, and wanting to connect to it). `goalc` spins up
fine even if the port is already bound to.
- For people that need/want this behaviour, adding per-game
configuration to the `repl-config.json` is on my todo list.
- Allows `goalc` to permit redefining symbols, including functions. This
is defaulted to off via the `repl-config.json` but it allows you to for
example, change the definition of a function without having to restart
and rebuild the entire game.
![Screenshot 2024-06-02
124558](https://github.com/open-goal/jak-project/assets/13153231/28f81f6e-b7b8-4172-9787-f96e4ab1305b)
- Updates the welcome message to include a bunch of useful metadata
up-front. Cleaned up all the startup logs that appear when starting
goalc, many of whom's information is now included in the welcome
message.
  - Before:

![image](https://github.com/open-goal/jak-project/assets/13153231/814c2374-4808-408e-9ed6-67114902a1d9)

  - After:
![Screenshot 2024-06-01
235954](https://github.com/open-goal/jak-project/assets/13153231/f3f459fb-2cbb-46ba-a90f-318243d4b3b3)
2024-06-03 00:14:52 -04:00

103 lines
4.0 KiB
C++

#pragma once
#include "common/goos/Interpreter.h"
#include "goalc/make/Tool.h"
struct MakeStep {
std::vector<std::string> input;
std::vector<std::string> deps, outputs;
goos::Object arg;
std::string tool;
std::string print() const;
};
class MakeSystem {
public:
MakeSystem(const std::optional<REPL::Config> repl_config, const std::string& username = "#f");
void load_project_file(const std::string& file_path);
goos::Object handle_defstep(const goos::Object& obj,
goos::Arguments& args,
const std::shared_ptr<goos::EnvironmentObject>& env);
goos::Object handle_basename(const goos::Object& obj,
goos::Arguments& args,
const std::shared_ptr<goos::EnvironmentObject>& env);
goos::Object handle_stem(const goos::Object& obj,
goos::Arguments&,
const std::shared_ptr<goos::EnvironmentObject>& env);
goos::Object handle_get_gsrc_path(const goos::Object& obj,
goos::Arguments&,
const std::shared_ptr<goos::EnvironmentObject>& env);
goos::Object handle_map_path(const goos::Object& obj,
goos::Arguments& args,
const std::shared_ptr<goos::EnvironmentObject>& env);
goos::Object handle_set_output_prefix(const goos::Object& obj,
goos::Arguments& args,
const std::shared_ptr<goos::EnvironmentObject>& env);
goos::Object handle_set_gsrc_folder(const goos::Object& obj,
goos::Arguments& args,
const std::shared_ptr<goos::EnvironmentObject>& env);
goos::Object handle_get_gsrc_folder(const goos::Object& obj,
goos::Arguments& args,
const std::shared_ptr<goos::EnvironmentObject>& env);
goos::Object handle_get_game_version_folder(const goos::Object& obj,
goos::Arguments&,
const std::shared_ptr<goos::EnvironmentObject>& env);
std::vector<std::string> get_dependencies(const std::string& target) const;
std::vector<std::string> filter_dependencies(const std::vector<std::string>& all_deps);
bool make(const std::string& target, bool force, bool verbose, bool gen_report);
void add_tool(std::shared_ptr<Tool> tool);
void set_constant(const std::string& name, const std::string& value);
void set_constant(const std::string& name, bool value);
void set_constant(const std::string& name, int value);
template <typename T>
void add_tool() {
add_tool(std::make_shared<T>());
}
void clear_project();
std::vector<std::string> get_loaded_projects() const { return m_loaded_projects; }
/*!
* Get the prefix that the project has requested for all compiler outputs
*/
const std::string& compiler_output_prefix() const { return m_path_map.output_prefix; }
private:
void va_check(const goos::Object& form,
const goos::Arguments& args,
const std::vector<std::optional<goos::ObjectType>>& unnamed,
const std::unordered_map<std::string,
std::pair<bool, std::optional<goos::ObjectType>>>& named);
void get_dependencies(const std::string& master_target,
const std::string& output,
std::vector<std::string>* result_order,
std::unordered_set<std::string>* result_set) const;
goos::Interpreter m_goos;
std::optional<REPL::Config> m_repl_config;
std::vector<std::string> m_loaded_projects;
std::unordered_map<std::string, std::shared_ptr<MakeStep>> m_output_to_step;
std::unordered_map<std::string, std::shared_ptr<Tool>> m_tools;
PathMap m_path_map;
std::vector<std::string> m_gsrc_folder;
std::map<std::string, std::string> m_gsrc_files = {};
};