Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameterize the iso_data folder for goalc #3692

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
4 changes: 4 additions & 0 deletions common/repl/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace REPL {
void to_json(json& j, const Config& obj) {
j = json{
{"nreplPort", obj.nrepl_port},
{"isoPath", obj.iso_path},
{"gameVersionFolder", obj.game_version_folder},
{"numConnectToTargetAttempts", obj.target_connect_attempts},
{"asmFileSearchDirs", obj.asm_file_search_dirs},
Expand All @@ -22,6 +23,9 @@ void from_json(const json& j, Config& obj) {
if (j.contains("nreplPort")) {
j.at("nreplPort").get_to(obj.nrepl_port);
}
if (j.contains("isoPath")) {
j.at("isoPath").get_to(obj.iso_path);
}
if (j.contains("gameVersionFolder")) {
j.at("gameVersionFolder").get_to(obj.game_version_folder);
}
Expand Down
1 change: 1 addition & 0 deletions common/repl/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ struct Config {
{KeyBind::Modifier::CTRL, "N", "Full build of the game", "(mi)"}};
bool per_game_history = true;
bool permissive_redefinitions = false;
std::string iso_path;

int get_nrepl_port() {
if (temp_nrepl_port != -1) {
Expand Down
19 changes: 11 additions & 8 deletions common/repl/repl_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,31 @@ void Wrapper::print_welcome_message(const std::vector<std::string>& loaded_proje
fmt::format(" Project Path: {}\n",
fmt::format(fg(fmt::color::gray), file_util::get_jak_project_dir().string()));
message += fmt::format(fmt::emphasis::bold | fg(fmt::color::orange), " - :===: -");
message +=
fmt::format(" ISO Data Path: {}\n", fmt::format(fg(fmt::color::gray), repl_config.iso_path));
message += fmt::format(fmt::emphasis::bold | fg(fmt::color::orange), " --. .--: :--. .--");
message += " nREPL:";
if (!nrepl_alive) {
message += fmt::format(fg(fmt::color::red), "DISABLED\n");
} else {
message += fmt::format(fg(fmt::color::light_green), " Listening on {}\n",
repl_config.get_nrepl_port());
}
message += fmt::format(fmt::emphasis::bold | fg(fmt::color::orange), " --. .--: :--. .--");
message += fmt::format(fmt::emphasis::bold | fg(fmt::color::orange), " .=======. =======.");
message += " Source File Search Dirs: ";
const auto search_dir_string =
fmt::format("{}", fmt::join(repl_config.asm_file_search_dirs, ","));
message += fmt::format("[{}]\n", fmt::format(fg(fmt::color::gray), search_dir_string));
message += fmt::format(fmt::emphasis::bold | fg(fmt::color::orange), " .=======. =======.");
message += fmt::format(" {} or {} for basic help and usage\n",
message += fmt::format(fmt::emphasis::bold | fg(fmt::color::orange), " .-=====-. .-=====-");
message += fmt::format(" {} or {} for basic help and usage\n",
fmt::format(fg(fmt::color::cyan), "(repl-help)"),
fmt::format(fg(fmt::color::cyan), "(repl-keybinds)"));
message += fmt::format(fmt::emphasis::bold | fg(fmt::color::orange), " .-=====-. .-=====-");
message +=
fmt::format(" {} to connect to the game\n", fmt::format(fg(fmt::color::cyan), "(lt)"));
message += fmt::format(fmt::emphasis::bold | fg(fmt::color::orange), " .-===========-.");
message += fmt::format(" {} to recompile the active project.\n",
message +=
fmt::format(" {} to connect to the game\n", fmt::format(fg(fmt::color::cyan), "(lt)"));
message += fmt::format(fmt::emphasis::bold | fg(fmt::color::orange), " .-===-.");
message += fmt::format(" {} to recompile the active project.\n",
fmt::format(fg(fmt::color::cyan), "(mi)"));
message += fmt::format(fmt::emphasis::bold | fg(fmt::color::orange), " .-===-.\n");
message += fmt::format(fmt::emphasis::bold | fg(fmt::color::orange), " .\n");
fmt::print("{}", message);
}
Expand Down Expand Up @@ -289,6 +291,7 @@ REPL::Config load_repl_config(const std::string& username,
// do nothing
}
}
loaded_config.iso_path = file_util::get_iso_dir_for_game(game_version).string();
loaded_config.temp_nrepl_port = nrepl_port;
return loaded_config;
massimilianodelliubaldini marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down
11 changes: 11 additions & 0 deletions goalc/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ int main(int argc, char** argv) {
std::string game = "jak1";
int nrepl_port = -1;
fs::path project_path_override;
fs::path iso_path_override;

// TODO - a lot of these flags could be deprecated and moved into `repl-config.json`
CLI::App app{"OpenGOAL Compiler / REPL"};
Expand All @@ -49,6 +50,7 @@ int main(int argc, char** argv) {
app.add_option("-g,--game", game, "The game name: 'jak1' or 'jak2'");
app.add_option("--proj-path", project_path_override,
"Specify the location of the 'data/' folder");
app.add_option("--iso-path", iso_path_override, "Specify the location of the 'iso_data/' folder");
define_common_cli_arguments(app);
app.validate_positionals();
CLI11_PARSE(app, argc, argv);
Expand All @@ -68,6 +70,15 @@ int main(int argc, char** argv) {
return 1;
}

// Check for a custom ISO path before the REPL window renders.
if (!iso_path_override.empty()) {
if (!fs::exists(iso_path_override)) {
lg::error("Error: iso path override '{}' does not exist", iso_path_override.string());
return 1;
}
file_util::set_iso_data_dir(iso_path_override);
}

try {
setup_logging(_cli_flag_disable_ansi);
} catch (const std::exception& e) {
Expand Down
9 changes: 7 additions & 2 deletions goalc/make/MakeSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,13 @@ MakeSystem::MakeSystem(const std::optional<REPL::Config> repl_config, const std:

m_goos.set_global_variable_to_symbol("ASSETS", "#t");

set_constant("*iso-data*", file_util::get_file_path({"iso_data"}));
set_constant("*use-iso-data-path*", false);
if (m_repl_config && !m_repl_config.value().iso_path.empty()) {
set_constant("*iso-data*", m_repl_config.value().iso_path);
set_constant("*use-iso-data-path*", true);
} else {
set_constant("*iso-data*", file_util::get_file_path({"iso_data"}));
set_constant("*use-iso-data-path*", false);
}

add_tool<DgoTool>();
add_tool<TpageDirTool>();
Expand Down
1 change: 1 addition & 0 deletions goalc/make/MakeSystem.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "common/goos/Interpreter.h"
#include "common/util/FileUtil.h"

#include "goalc/make/Tool.h"

Expand Down
Loading