mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 00:57:44 -04:00
8846968963
* Update assert.h * stuff for `process-drawable` to work * add windows code for debugger * debugger attaches * something works * remove bad ideas * `(:break)` works * connection fixes * fixes + update docs * crates & `defskelgroup` macro * clang * update tests and a few types * temp * temp * fix files * game builds * reverse TypeConsistency operation * add eye stuff for merc art login * add `(:sym-name)` * oops * add `--auto-dbg` option to gc args * codacy * improve robustness of dgo unpacker and objectfiledb reading * `cavegeyserrock` * hopefully fix linux * windows FormatMessage weirdness? * mutex fixes * fix merge conflicts Co-authored-by: ManDude <7569514+ManDude@users.noreply.github.com>
75 lines
2 KiB
C++
75 lines
2 KiB
C++
#include <cstdio>
|
|
#include "goalc/compiler/Compiler.h"
|
|
#include "common/versions.h"
|
|
#include "common/util/FileUtil.h"
|
|
#include "common/log/log.h"
|
|
|
|
#include "third-party/fmt/core.h"
|
|
#include "third-party/fmt/color.h"
|
|
|
|
#include "common/goos/ReplUtils.h"
|
|
|
|
void setup_logging(bool verbose) {
|
|
lg::set_file(file_util::get_file_path({"log/compiler.txt"}));
|
|
if (verbose) {
|
|
lg::set_file_level(lg::level::info);
|
|
lg::set_stdout_level(lg::level::info);
|
|
lg::set_flush_level(lg::level::info);
|
|
} else {
|
|
lg::set_file_level(lg::level::warn);
|
|
lg::set_stdout_level(lg::level::warn);
|
|
lg::set_flush_level(lg::level::warn);
|
|
}
|
|
lg::initialize();
|
|
}
|
|
|
|
int main(int argc, char** argv) {
|
|
(void)argc;
|
|
(void)argv;
|
|
|
|
std::string argument;
|
|
bool verbose = false;
|
|
bool auto_listen = false;
|
|
bool auto_debug = false;
|
|
for (int i = 1; i < argc; i++) {
|
|
if (std::string("-v") == argv[i]) {
|
|
verbose = true;
|
|
}
|
|
if (std::string("-cmd") == argv[i] && i < argc - 1) {
|
|
argument = argv[++i];
|
|
}
|
|
if (std::string("-auto-lt") == argv[i]) {
|
|
auto_listen = true;
|
|
}
|
|
if (std::string("-auto-dbg") == argv[i]) {
|
|
auto_debug = true;
|
|
}
|
|
}
|
|
setup_logging(verbose);
|
|
|
|
lg::info("OpenGOAL Compiler {}.{}", versions::GOAL_VERSION_MAJOR, versions::GOAL_VERSION_MINOR);
|
|
|
|
// Init REPL
|
|
// the compiler may throw an exception if it fails to load its standard library.
|
|
try {
|
|
std::unique_ptr<Compiler> compiler;
|
|
if (argument.empty()) {
|
|
ReplStatus status = ReplStatus::WANT_RELOAD;
|
|
while (status == ReplStatus::WANT_RELOAD) {
|
|
compiler = std::make_unique<Compiler>(std::make_unique<ReplWrapper>());
|
|
status = compiler->execute_repl(auto_listen, auto_debug);
|
|
if (status == ReplStatus::WANT_RELOAD) {
|
|
fmt::print("Reloading compiler...\n");
|
|
}
|
|
}
|
|
} else {
|
|
compiler = std::make_unique<Compiler>();
|
|
compiler->run_front_end_on_string(argument);
|
|
}
|
|
} catch (std::exception& e) {
|
|
fmt::print("Compiler Fatal Error: {}\n", e.what());
|
|
}
|
|
|
|
return 0;
|
|
}
|