mirror of
https://github.com/open-goal/jak-project
synced 2026-07-11 15:28:58 -04:00
[jak2] goalc supports multiple projects (#1619)
* [jak2] goalc supports multiple projects * disable deci2 server if not debugging
This commit is contained in:
@@ -120,7 +120,7 @@ class ArithmeticTests : public testing::TestWithParam<IntegerParam> {
|
||||
// Called before the first test in this test suite.
|
||||
static void SetUpTestSuite() {
|
||||
runtime_thread = std::make_unique<std::thread>(std::thread((GoalTest::runtime_no_kernel)));
|
||||
compiler = std::make_unique<Compiler>();
|
||||
compiler = std::make_unique<Compiler>(GameVersion::Jak1);
|
||||
runner = std::make_unique<GoalTest::CompilerTestRunner>();
|
||||
runner->c = compiler.get();
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class CollectionTests : public testing::TestWithParam<CollectionParam> {
|
||||
public:
|
||||
static void SetUpTestSuite() {
|
||||
runtime_thread = std::make_unique<std::thread>(std::thread((GoalTest::runtime_no_kernel)));
|
||||
compiler = std::make_unique<Compiler>();
|
||||
compiler = std::make_unique<Compiler>(GameVersion::Jak1);
|
||||
runner = std::make_unique<GoalTest::CompilerTestRunner>();
|
||||
runner->c = compiler.get();
|
||||
}
|
||||
|
||||
@@ -7,5 +7,6 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
TEST(CompilerAndRuntime, ConstructCompiler) {
|
||||
Compiler compiler;
|
||||
Compiler compiler1(GameVersion::Jak1);
|
||||
Compiler compiler2(GameVersion::Jak2);
|
||||
}
|
||||
@@ -24,7 +24,7 @@ class ControlStatementTests : public testing::TestWithParam<ControlStatementPara
|
||||
public:
|
||||
static void SetUpTestSuite() {
|
||||
runtime_thread = std::make_unique<std::thread>(std::thread((GoalTest::runtime_no_kernel)));
|
||||
compiler = std::make_unique<Compiler>();
|
||||
compiler = std::make_unique<Compiler>(GameVersion::Jak1);
|
||||
runner = std::make_unique<GoalTest::CompilerTestRunner>();
|
||||
runner->c = compiler.get();
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ void connect_compiler_and_debugger(Compiler& compiler, bool do_break) {
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
TEST(Debugger, DebuggerBasicConnect) {
|
||||
Compiler compiler;
|
||||
TEST(Jak1Debugger, DebuggerBasicConnect) {
|
||||
Compiler compiler(GameVersion::Jak1);
|
||||
// evidently you can't ptrace threads in your own process, so we need to run the runtime in a
|
||||
// separate process.
|
||||
if (!fork()) {
|
||||
@@ -50,8 +50,8 @@ TEST(Debugger, DebuggerBasicConnect) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Debugger, DebuggerBreakAndContinue) {
|
||||
Compiler compiler;
|
||||
TEST(Jak1Debugger, DebuggerBreakAndContinue) {
|
||||
Compiler compiler(GameVersion::Jak1);
|
||||
// evidently you can't ptrace threads in your own process, so we need to run the runtime in a
|
||||
// separate process.
|
||||
if (!fork()) {
|
||||
@@ -72,8 +72,8 @@ TEST(Debugger, DebuggerBreakAndContinue) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Debugger, DebuggerReadMemory) {
|
||||
Compiler compiler;
|
||||
TEST(Jak1Debugger, DebuggerReadMemory) {
|
||||
Compiler compiler(GameVersion::Jak1);
|
||||
// evidently you can't ptrace threads in your own process, so we need to run the runtime in a
|
||||
// separate process.
|
||||
if (!fork()) {
|
||||
@@ -96,8 +96,8 @@ TEST(Debugger, DebuggerReadMemory) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Debugger, DebuggerWriteMemory) {
|
||||
Compiler compiler;
|
||||
TEST(Jak1Debugger, DebuggerWriteMemory) {
|
||||
Compiler compiler(GameVersion::Jak1);
|
||||
// evidently you can't ptrace threads in your own process, so we need to run the runtime in a
|
||||
// separate process.
|
||||
if (!fork()) {
|
||||
@@ -127,8 +127,8 @@ TEST(Debugger, DebuggerWriteMemory) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Debugger, Symbol) {
|
||||
Compiler compiler;
|
||||
TEST(Jak1Debugger, Symbol) {
|
||||
Compiler compiler(GameVersion::Jak1);
|
||||
// evidently you can't ptrace threads in your own process, so we need to run the runtime in a
|
||||
// separate process.
|
||||
if (!fork()) {
|
||||
@@ -158,8 +158,8 @@ TEST(Debugger, Symbol) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Debugger, SimpleBreakpoint) {
|
||||
Compiler compiler;
|
||||
TEST(Jak1Debugger, SimpleBreakpoint) {
|
||||
Compiler compiler(GameVersion::Jak1);
|
||||
|
||||
if (!fork()) {
|
||||
GoalTest::runtime_no_kernel();
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// Test the game running without loading debug segments.
|
||||
// Test jak1 running without loading debug segments.
|
||||
|
||||
#include "goalc/compiler/Compiler.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "test/goalc/framework/test_runner.h"
|
||||
|
||||
TEST(GameNoDebugSegment, Init) {
|
||||
Compiler compiler;
|
||||
TEST(Jak1NoDebugSegment, Init) {
|
||||
Compiler compiler(GameVersion::Jak1);
|
||||
compiler.run_front_end_on_string("(build-kernel)");
|
||||
std::thread runtime_thread = std::thread(GoalTest::runtime_with_kernel_no_debug_segment);
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "test/goalc/framework/test_runner.h"
|
||||
|
||||
class KernelTest : public testing::Test {
|
||||
class Jak1KernelTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestSuite() {
|
||||
shared_compiler = std::make_unique<SharedCompiler>();
|
||||
shared_compiler = std::make_unique<SharedCompiler>(GameVersion::Jak1);
|
||||
printf("Building kernel...\n");
|
||||
try {
|
||||
// a macro in goal-lib.gc
|
||||
@@ -37,6 +37,7 @@ class KernelTest : public testing::Test {
|
||||
void TearDown() {}
|
||||
|
||||
struct SharedCompiler {
|
||||
SharedCompiler(GameVersion v) : compiler(v) {}
|
||||
std::thread runtime_thread;
|
||||
Compiler compiler;
|
||||
GoalTest::CompilerTestRunner runner;
|
||||
@@ -45,7 +46,7 @@ class KernelTest : public testing::Test {
|
||||
static std::unique_ptr<SharedCompiler> shared_compiler;
|
||||
};
|
||||
|
||||
std::unique_ptr<KernelTest::SharedCompiler> KernelTest::shared_compiler;
|
||||
std::unique_ptr<Jak1KernelTest::SharedCompiler> Jak1KernelTest::shared_compiler;
|
||||
|
||||
namespace {
|
||||
std::string send_code_and_get_multiple_responses(const std::string& code,
|
||||
@@ -70,7 +71,7 @@ std::string send_code_and_get_multiple_responses(const std::string& code,
|
||||
}
|
||||
} // namespace
|
||||
|
||||
TEST_F(KernelTest, Basic) {
|
||||
TEST_F(Jak1KernelTest, Basic) {
|
||||
shared_compiler->runner.c->run_test_from_string(
|
||||
"(ml \"test/goalc/source_templates/kernel/kernel-test.gc\")");
|
||||
std::string result =
|
||||
@@ -102,7 +103,7 @@ TEST_F(KernelTest, Basic) {
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
|
||||
TEST_F(KernelTest, RunFunctionInProcess) {
|
||||
TEST_F(Jak1KernelTest, RunFunctionInProcess) {
|
||||
shared_compiler->runner.c->run_test_from_string(
|
||||
"(ml \"test/goalc/source_templates/kernel/kernel-test.gc\")");
|
||||
std::string result =
|
||||
@@ -121,7 +122,7 @@ TEST_F(KernelTest, RunFunctionInProcess) {
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
|
||||
TEST_F(KernelTest, StateAndXmm) {
|
||||
TEST_F(Jak1KernelTest, StateAndXmm) {
|
||||
shared_compiler->runner.c->run_test_from_string(
|
||||
"(ml \"test/goalc/source_templates/kernel/kernel-test.gc\")");
|
||||
std::string result =
|
||||
@@ -135,7 +136,7 @@ TEST_F(KernelTest, StateAndXmm) {
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
|
||||
TEST_F(KernelTest, ThrowXmm) {
|
||||
TEST_F(Jak1KernelTest, ThrowXmm) {
|
||||
shared_compiler->runner.c->run_test_from_string(
|
||||
"(ml \"test/goalc/source_templates/kernel/kernel-test.gc\")");
|
||||
std::string result =
|
||||
|
||||
@@ -23,7 +23,7 @@ struct VariableParam {
|
||||
class VariableTests : public testing::TestWithParam<VariableParam> {
|
||||
public:
|
||||
static void SetUpTestSuite() {
|
||||
shared_compiler = std::make_unique<SharedCompiler>();
|
||||
shared_compiler = std::make_unique<SharedCompiler>(GameVersion::Jak1);
|
||||
shared_compiler->runtime_thread = std::thread((GoalTest::runtime_no_kernel));
|
||||
shared_compiler->runner.c = &shared_compiler->compiler;
|
||||
}
|
||||
@@ -42,6 +42,7 @@ class VariableTests : public testing::TestWithParam<VariableParam> {
|
||||
void TearDown() {}
|
||||
|
||||
struct SharedCompiler {
|
||||
SharedCompiler(GameVersion version) : compiler(version) {}
|
||||
std::thread runtime_thread;
|
||||
Compiler compiler;
|
||||
GoalTest::CompilerTestRunner runner;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
class WithGameTests : public ::testing::Test {
|
||||
public:
|
||||
static void SetUpTestSuite() {
|
||||
shared_compiler = std::make_unique<SharedCompiler>();
|
||||
shared_compiler = std::make_unique<SharedCompiler>(GameVersion::Jak1);
|
||||
try {
|
||||
shared_compiler->compiler.run_test_no_load(
|
||||
"test/goalc/source_templates/with_game/test-build-game.gc");
|
||||
@@ -56,6 +56,7 @@ class WithGameTests : public ::testing::Test {
|
||||
void TearDown() {}
|
||||
|
||||
struct SharedCompiler {
|
||||
SharedCompiler(GameVersion v) : compiler(v) {}
|
||||
std::thread runtime_thread;
|
||||
Compiler compiler;
|
||||
GoalTest::CompilerTestRunner runner;
|
||||
@@ -73,7 +74,7 @@ std::unique_ptr<WithGameTests::SharedCompiler> WithGameTests::shared_compiler;
|
||||
class WithMinimalGameTests : public ::testing::Test {
|
||||
public:
|
||||
static void SetUpTestSuite() {
|
||||
shared_compiler = std::make_unique<SharedCompiler>();
|
||||
shared_compiler = std::make_unique<SharedCompiler>(GameVersion::Jak1);
|
||||
try {
|
||||
shared_compiler->compiler.run_front_end_on_string("(build-kernel)");
|
||||
} catch (std::exception& e) {
|
||||
@@ -109,6 +110,7 @@ class WithMinimalGameTests : public ::testing::Test {
|
||||
void TearDown() {}
|
||||
|
||||
struct SharedCompiler {
|
||||
SharedCompiler(GameVersion v) : compiler(v) {}
|
||||
std::thread runtime_thread;
|
||||
Compiler compiler;
|
||||
GoalTest::CompilerTestRunner runner;
|
||||
@@ -943,16 +945,16 @@ void add_expected_type_mismatches(Compiler& c) {
|
||||
c.add_ignored_define_extern_symbol("tfrag-init-buffer");
|
||||
}
|
||||
|
||||
TEST(TypeConsistency, MANUAL_TEST_TypeConsistencyWithBuildFirst) {
|
||||
Compiler compiler;
|
||||
TEST(Jak1TypeConsistency, MANUAL_TEST_TypeConsistencyWithBuildFirst) {
|
||||
Compiler compiler(GameVersion::Jak1);
|
||||
compiler.enable_throw_on_redefines();
|
||||
add_expected_type_mismatches(compiler);
|
||||
compiler.run_test_no_load("test/goalc/source_templates/with_game/test-build-all-code.gc");
|
||||
compiler.run_test_no_load("decompiler/config/all-types.gc");
|
||||
}
|
||||
|
||||
TEST(TypeConsistency, TypeConsistency) {
|
||||
Compiler compiler;
|
||||
TEST(Jak1TypeConsistency, TypeConsistency) {
|
||||
Compiler compiler(GameVersion::Jak1);
|
||||
compiler.enable_throw_on_redefines();
|
||||
add_expected_type_mismatches(compiler);
|
||||
compiler.run_test_no_load("decompiler/config/all-types.gc");
|
||||
|
||||
@@ -49,8 +49,9 @@ std::unordered_map<std::string, std::string> game_name_to_config = {
|
||||
|
||||
// TODO - i think these should be partitioned by game name instead of it being in the filename
|
||||
// (and the names not being consistent)
|
||||
std::unordered_map<std::string, std::string> game_name_to_all_types = {{"jak1", "all-types.gc"},
|
||||
{"jak2", "all-types2.gc"}};
|
||||
std::unordered_map<std::string, std::string> game_name_to_all_types = {
|
||||
{"jak1", "all-types.gc"},
|
||||
{"jak2", "jak2/all-types.gc"}};
|
||||
|
||||
Decompiler setup_decompiler(const std::vector<DecompilerFile>& files,
|
||||
const std::vector<DecompilerArtFile>& art_files,
|
||||
@@ -197,7 +198,7 @@ bool compile(Decompiler& dc,
|
||||
const OfflineTestConfig& config,
|
||||
const std::string& game_name) {
|
||||
fmt::print("Setting up compiler...\n");
|
||||
Compiler compiler;
|
||||
Compiler compiler(game_name_to_version(game_name));
|
||||
|
||||
compiler.run_front_end_on_file({"decompiler", "config", game_name_to_all_types[game_name]});
|
||||
compiler.run_front_end_on_file(
|
||||
|
||||
Reference in New Issue
Block a user