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
8 changes: 4 additions & 4 deletions .github/workflows/compiler-output-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ jobs:
uses: hendrikmuhs/[email protected]
with:
variant: sccache
key: linux-ubuntu-20.04--Release-linux-clang-asan-${{ github.sha }}
restore-keys: linux-ubuntu-20.04--Release-linux-clang-asan
key: linux-ubuntu-20.04--Release-linux-clang-static-${{ github.sha }}
restore-keys: linux-ubuntu-20.04--Release-linux-clang-static
max-size: 1000M

- name: CMake Generation (master)
env:
CC: clang
CXX: clang++
run: |
cmake -B build --preset=Release-linux-clang-asan \
cmake -B build --preset=Release-linux-clang-static \
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache

Expand All @@ -57,7 +57,7 @@ jobs:
CC: clang
CXX: clang++
run: |
cmake -B build --preset=Release-linux-clang-asan \
cmake -B build --preset=Release-linux-clang-static \
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache

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
24 changes: 16 additions & 8 deletions common/repl/repl_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,37 @@ 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), " - :===: -");
std::string effective_iso_path;
if (repl_config.iso_path.empty()) {
effective_iso_path = file_util::get_file_path({"iso_data"});
} else {
effective_iso_path = repl_config.iso_path;
}
message +=
fmt::format(" ISO Data Path: {}\n", fmt::format(fg(fmt::color::gray), effective_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
12 changes: 12 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 Down Expand Up @@ -84,6 +86,16 @@ int main(int argc, char** argv) {
// Load the user's REPL config
auto repl_config = REPL::load_repl_config(username, game_version, nrepl_port);

// Check for a custom ISO path before we instantiate the compiler.
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);
repl_config.iso_path = iso_path_override.string();
}

// Init Compiler
std::unique_ptr<Compiler> compiler;
std::mutex compiler_mutex;
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->iso_path.empty()) {
set_constant("*iso-data*", file_util::get_iso_dir_for_game(m_repl_config->game_version).string());
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