Files
massimilianodelliubaldini 7dbacc72d3 Parameterize the iso_data folder for goalc (#3692)
I hope this is everything I needed, and nothing I didn't.

## What's Changed

This update adds a command-line parameter to goalc, `--iso-path`.
Providing a path to a directory like
`D:\Files\Repositories\ArchipelaGOAL\iso_data\jak1` will inform the
compiler to use that directory instead.

## Why is this useful?

When combined with `--proj-path`, the compiler can be pointed to a
completely different project folder, given the `(mi)` command, and
immediately begin building from that directory, with everything it
needs. This eliminates the need to copy `iso_data` to multiple `data`
directories.

If a subsequent change to the Launcher is made, each mod could be passed
an --iso-path pointing to a single shared folder, allowing mods to each
run their own REPL _without_ requiring a copy of `iso_data` in a
subfolder.

## Independent testing required!

My local repositories are a little suspect, with a mod, a fork of
mod-base, and a fork of jak-project, all on the same drive. My
decompiler_out and iso_data folders are in the mod repo, not mod-base
nor jak-project. So what I did was make the change in the mod-base fork,
point `--proj-path and --iso-path` to the mod folders, and then ran
`(mi)`. The output showed a build starting with no errors.

Then I had to create this PR, which my fork of mod-base is unable to do,
so I created a patch file, forked jak-project, then applied the patch
there.

All this is to say that it would be preferable if someone could apply
this code to their own installation and see if it works. Even I wouldn't
take my own word for this.

---------

Co-authored-by: Tyler Wilding <xtvaser@gmail.com>
2024-10-18 00:03:14 -04:00

104 lines
4.1 KiB
C++

#pragma once
#include "common/goos/Interpreter.h"
#include "common/util/FileUtil.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 = {};
};