game: Remove temporary CLI arg shim in gk (#2532)

This commit is contained in:
Tyler Wilding 2023-04-22 13:13:57 -05:00 committed by GitHub
parent 47d85f896e
commit a264b6539b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
58 changed files with 123 additions and 151 deletions

1
.gitignore vendored
View file

@ -57,6 +57,7 @@ texture_replacements/*
# generated cmake files # generated cmake files
svnrev.h svnrev.h
common/versions/revision.h
ci-artifacts/ ci-artifacts/
out/build/ out/build/
__pycache__/ __pycache__/

View file

@ -1,5 +1,28 @@
function(write_revision_h)
find_package(Git)
set(GIT_SHORT_SHA "")
set(GIT_TAG "")
if(NOT GIT_FOUND)
MESSAGE(STATUS "write_revision_h(): git was not found")
endif()
MESSAGE(STATUS "write_revision_h(): ${CMAKE_SOURCE_DIR}")
if (GIT_FOUND AND EXISTS ${CMAKE_SOURCE_DIR}/.git)
MESSAGE(STATUS "Git found, using it to get revision info")
EXECUTE_PROCESS(WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
OUTPUT_VARIABLE GIT_SHORT_SHA
OUTPUT_STRIP_TRAILING_WHITESPACE)
EXECUTE_PROCESS(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} tag --points-at HEAD
OUTPUT_VARIABLE GIT_TAG
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET)
endif()
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/versions/revision.h "#define BUILT_TAG \"${GIT_TAG}\"\n#define BUILT_SHA \"${GIT_SHORT_SHA}\"\n")
endfunction()
write_revision_h()
add_library(common add_library(common
versions.cpp versions/versions.cpp
audio/audio_formats.cpp audio/audio_formats.cpp
cross_os_debug/xdbg.cpp cross_os_debug/xdbg.cpp
cross_sockets/XSocket.cpp cross_sockets/XSocket.cpp
@ -53,7 +76,7 @@ add_library(common
util/print_float.cpp util/print_float.cpp
util/FrameLimiter.cpp util/FrameLimiter.cpp
util/unicode_util.cpp util/unicode_util.cpp
util/term_util.cpp) util/term_util.cpp )
target_link_libraries(common fmt lzokay replxx libzstd_static) target_link_libraries(common fmt lzokay replxx libzstd_static)

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "common/common_types.h" #include "common/common_types.h"
#include "common/versions.h" #include "common/versions/versions.h"
constexpr s32 BINTEGER_OFFSET = 0; constexpr s32 BINTEGER_OFFSET = 0;
constexpr s32 PAIR_OFFSET = 2; constexpr s32 PAIR_OFFSET = 2;

View file

@ -1,6 +1,6 @@
#include "config.h" #include "config.h"
#include "common/versions.h" #include "common/versions/versions.h"
#include "third-party/fmt/core.h" #include "third-party/fmt/core.h"

View file

@ -5,7 +5,7 @@
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include "common/versions.h" #include "common/versions/versions.h"
#include "third-party/json.hpp" #include "third-party/json.hpp"

View file

@ -2,7 +2,7 @@
#include "ReplClient.h" #include "ReplClient.h"
#include "common/cross_sockets/XSocket.h" #include "common/cross_sockets/XSocket.h"
#include "common/versions.h" #include "common/versions/versions.h"
#include "third-party/fmt/core.h" #include "third-party/fmt/core.h"

View file

@ -2,7 +2,7 @@
#include "ReplServer.h" #include "ReplServer.h"
#include "common/cross_sockets/XSocket.h" #include "common/cross_sockets/XSocket.h"
#include "common/versions.h" #include "common/versions/versions.h"
#include "third-party/fmt/core.h" #include "third-party/fmt/core.h"

View file

@ -3,7 +3,7 @@
#include "common/util/FileUtil.h" #include "common/util/FileUtil.h"
#include "common/util/json_util.h" #include "common/util/json_util.h"
#include "common/util/string_util.h" #include "common/util/string_util.h"
#include "common/versions.h" #include "common/versions/versions.h"
#include "third-party/fmt/color.h" #include "third-party/fmt/color.h"
#include "third-party/fmt/core.h" #include "third-party/fmt/core.h"

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "common/versions.h" #include "common/versions/versions.h"
/*! /*!
* @file symbols.h * @file symbols.h
@ -171,4 +171,4 @@ constexpr int empty_pair_offset_from_s7(GameVersion version) {
// minus 1 for the symbol table pointer's offset. // minus 1 for the symbol table pointer's offset.
return jak2_symbols::S7_OFF_FIX_SYM_EMPTY_PAIR; return jak2_symbols::S7_OFF_FIX_SYM_EMPTY_PAIR;
} }
} }

View file

@ -22,7 +22,7 @@
#include <vector> #include <vector>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/versions.h" #include "common/versions/versions.h"
namespace fs = ghc::filesystem; namespace fs = ghc::filesystem;

View file

@ -3,7 +3,7 @@
#include <cstring> #include <cstring>
#include "common/util/Assert.h" #include "common/util/Assert.h"
#include "common/versions.h" #include "common/versions/versions.h"
#include "third-party/fmt/core.h" #include "third-party/fmt/core.h"

View file

@ -3,7 +3,7 @@
#include <string> #include <string>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/versions.h" #include "common/versions/versions.h"
void assert_string_empty_after(const char* str, int size); void assert_string_empty_after(const char* str, int size);
std::string get_object_file_name(const std::string& original_name, u8* data, int size); std::string get_object_file_name(const std::string& original_name, u8* data, int size);

View file

@ -1,6 +1,7 @@
#include "versions.h" #include "versions.h"
#include "common/util/Assert.h" #include "common/util/Assert.h"
#include "common/versions/revision.h"
#include "third-party/fmt/core.h" #include "third-party/fmt/core.h"
#include "third-party/fmt/format.h" #include "third-party/fmt/format.h"
@ -30,6 +31,27 @@ std::string version_to_game_name(GameVersion v) {
} }
} }
std::string version_to_game_name_external(GameVersion v) {
switch (v) {
case GameVersion::Jak1:
return "Jak 1";
case GameVersion::Jak2:
return "Jak 2";
default:
ASSERT_MSG(false, fmt::format("no game_name for version: {} found", fmt::underlying(v)));
}
}
std::vector<std::string> valid_game_version_names() { std::vector<std::string> valid_game_version_names() {
return {game_version_names[GameVersion::Jak1], game_version_names[GameVersion::Jak2]}; return {game_version_names[GameVersion::Jak1], game_version_names[GameVersion::Jak2]};
} }
std::string build_revision() {
if (BUILT_TAG != "") {
return BUILT_TAG;
}
if (BUILT_SHA != "") {
return BUILT_SHA;
}
return "Unknown Revision";
}

View file

@ -56,4 +56,7 @@ constexpr PerGameVersion<const char*> game_version_names = {"jak1", "jak2"};
GameVersion game_name_to_version(const std::string& name); GameVersion game_name_to_version(const std::string& name);
bool valid_game_version(const std::string& name); bool valid_game_version(const std::string& name);
std::string version_to_game_name(GameVersion v); std::string version_to_game_name(GameVersion v);
std::string version_to_game_name_external(GameVersion v);
std::vector<std::string> valid_game_version_names(); std::vector<std::string> valid_game_version_names();
std::string build_revision();

View file

@ -2,7 +2,7 @@
#include <vector> #include <vector>
#include "common/versions.h" #include "common/versions/versions.h"
namespace decompiler { namespace decompiler {
class Function; class Function;

View file

@ -8,7 +8,7 @@
#include "common/common_types.h" #include "common/common_types.h"
#include "common/util/FileUtil.h" #include "common/util/FileUtil.h"
#include "common/versions.h" #include "common/versions/versions.h"
#include "decompiler/Disasm/Register.h" #include "decompiler/Disasm/Register.h"
#include "decompiler/data/game_text.h" #include "decompiler/data/game_text.h"

View file

@ -11,7 +11,7 @@
#include "common/common_types.h" #include "common/common_types.h"
#include "common/util/Assert.h" #include "common/util/Assert.h"
#include "common/util/FileUtil.h" #include "common/util/FileUtil.h"
#include "common/versions.h" #include "common/versions/versions.h"
namespace decompiler { namespace decompiler {
class StrFileReader { class StrFileReader {

View file

@ -18,7 +18,7 @@
#include "common/texture/texture_conversion.h" #include "common/texture/texture_conversion.h"
#include "common/util/FileUtil.h" #include "common/util/FileUtil.h"
#include "common/versions.h" #include "common/versions/versions.h"
#include "decompiler/ObjectFile/ObjectFileDB.h" #include "decompiler/ObjectFile/ObjectFileDB.h"

View file

@ -7,7 +7,7 @@
#include "common/common_types.h" #include "common/common_types.h"
#include "common/math/Vector.h" #include "common/math/Vector.h"
#include "common/versions.h" #include "common/versions/versions.h"
#include "decompiler/level_extractor/common_formats.h" #include "decompiler/level_extractor/common_formats.h"
#include "decompiler/util/goal_data_reader.h" #include "decompiler/util/goal_data_reader.h"

View file

@ -7,7 +7,7 @@
#include "common/common_types.h" #include "common/common_types.h"
#include "common/dma/gs.h" #include "common/dma/gs.h"
#include "common/math/Vector.h" #include "common/math/Vector.h"
#include "common/versions.h" #include "common/versions/versions.h"
#include "decompiler/util/goal_data_reader.h" #include "decompiler/util/goal_data_reader.h"
@ -219,4 +219,4 @@ struct MercCtrl {
void debug_print_blerc(); void debug_print_blerc();
std::string print(); std::string print();
}; };
} // namespace decompiler } // namespace decompiler

View file

@ -11,7 +11,7 @@
#include "common/util/os.h" #include "common/util/os.h"
#include "common/util/set_util.h" #include "common/util/set_util.h"
#include "common/util/unicode_util.h" #include "common/util/unicode_util.h"
#include "common/versions.h" #include "common/versions/versions.h"
#include "ObjectFile/ObjectFileDB.h" #include "ObjectFile/ObjectFileDB.h"
#include "decompiler/data/TextureDB.h" #include "decompiler/data/TextureDB.h"

View file

@ -5,7 +5,7 @@
#include "common/goos/Object.h" #include "common/goos/Object.h"
#include "common/type_system/TypeSpec.h" #include "common/type_system/TypeSpec.h"
#include "common/type_system/TypeSystem.h" #include "common/type_system/TypeSystem.h"
#include "common/versions.h" #include "common/versions/versions.h"
#include "decompiler/Disasm/DecompilerLabel.h" #include "decompiler/Disasm/DecompilerLabel.h"
#include "decompiler/IR2/LabelDB.h" #include "decompiler/IR2/LabelDB.h"

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "common/goal_constants.h" #include "common/goal_constants.h"
#include "common/type_system/TypeSpec.h" #include "common/type_system/TypeSpec.h"
#include "common/versions.h" #include "common/versions/versions.h"
namespace decompiler { namespace decompiler {
@ -16,4 +16,4 @@ constexpr PerGameVersion<int> SYMBOL_TO_STRING_MEM_OFFSET_DECOMP = {8167 * 8,
jak2::SYM_TO_STRING_OFFSET}; jak2::SYM_TO_STRING_OFFSET};
constexpr PerGameVersion<int> OFFSET_OF_NEXT_STATE_STORE = {72, 64}; constexpr PerGameVersion<int> OFFSET_OF_NEXT_STATE_STORE = {72, 64};
} // namespace decompiler } // namespace decompiler

View file

@ -182,37 +182,6 @@ set(RUNTIME_SOURCE
tools/subtitles/subtitle_editor.cpp tools/subtitles/subtitle_editor.cpp
tools/filter_menu/filter_menu.cpp) tools/filter_menu/filter_menu.cpp)
find_package(Git)
function(write_svnrev_h)
set(GIT_VERSION "")
set(GIT_SHORT_SHA "")
set(GIT_TAG "")
if (GIT_FOUND AND EXISTS ${CMAKE_SOURCE_DIR}/.git)
EXECUTE_PROCESS(WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
OUTPUT_VARIABLE GIT_SHORT_SHA
OUTPUT_STRIP_TRAILING_WHITESPACE)
EXECUTE_PROCESS(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} tag --points-at HEAD
OUTPUT_VARIABLE GIT_TAG
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET)
else()
set(GIT_VERSION "unk. rev.")
endif()
if(GIT_TAG)
set(GIT_VERSION ${GIT_TAG})
elseif(GIT_SHORT_SHA)
string(SUBSTRING ${GIT_SHORT_SHA} 0 6 GIT_SHORT_SHA)
set(GIT_VERSION "rev. ${GIT_SHORT_SHA}")
else()
set(GIT_VERSION "unk. rev.")
endif()
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/kernel/svnrev.h "#define GIT_VERSION \"${GIT_VERSION}\"\n")
endfunction()
write_svnrev_h()
add_subdirectory(sound) add_subdirectory(sound)
# we build the runtime as a static library. # we build the runtime as a static library.

View file

@ -6,7 +6,7 @@
*/ */
#include "common/common_types.h" #include "common/common_types.h"
#include "common/versions.h" #include "common/versions/versions.h"
constexpr PerGameVersion<int> DGO_RPC_ID(0xdeb4, 0xfab3); constexpr PerGameVersion<int> DGO_RPC_ID(0xdeb4, 0xfab3);
constexpr int DGO_RPC_CHANNEL = 3; constexpr int DGO_RPC_CHANNEL = 3;

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "common/listener_common.h" #include "common/listener_common.h"
#include "common/versions.h" #include "common/versions/versions.h"
//! Supported languages. //! Supported languages.
enum class Language { enum class Language {

View file

@ -5,7 +5,7 @@
* Types used for the Loader Remote Procedure Call between the EE and the IOP * Types used for the Loader Remote Procedure Call between the EE and the IOP
*/ */
#include "common/versions.h" #include "common/versions/versions.h"
constexpr PerGameVersion<int> LOADER_RPC_ID(0xdeb2, 0xfab1); constexpr PerGameVersion<int> LOADER_RPC_ID(0xdeb2, 0xfab1);
constexpr int LOADER_RPC_CHANNEL = 1; constexpr int LOADER_RPC_CHANNEL = 1;

View file

@ -5,7 +5,7 @@
* Types used for the play Remote Procedure Call between the EE and the IOP. * Types used for the play Remote Procedure Call between the EE and the IOP.
* Note that PLAY and PLAYER are different. * Note that PLAY and PLAYER are different.
*/ */
#include "common/versions.h" #include "common/versions/versions.h"
constexpr PerGameVersion<int> PLAY_RPC_ID(0xdeb6, 0xfab5); constexpr PerGameVersion<int> PLAY_RPC_ID(0xdeb6, 0xfab5);
constexpr int PLAY_RPC_CHANNEL = 5; constexpr int PLAY_RPC_CHANNEL = 5;

View file

@ -5,7 +5,7 @@
* Types used for the player Remote Procedure Call between the EE and the IOP. * Types used for the player Remote Procedure Call between the EE and the IOP.
* Note that PLAY and PLAYER are different. * Note that PLAY and PLAYER are different.
*/ */
#include "common/versions.h" #include "common/versions/versions.h"
constexpr PerGameVersion<int> PLAYER_RPC_ID(0xdeb1, 0xfab0); constexpr PerGameVersion<int> PLAYER_RPC_ID(0xdeb1, 0xfab0);
constexpr int PLAYER_RPC_CHANNEL = 0; constexpr int PLAYER_RPC_CHANNEL = 0;

View file

@ -6,7 +6,7 @@
*/ */
#include "common/common_types.h" #include "common/common_types.h"
#include "common/versions.h" #include "common/versions/versions.h"
constexpr PerGameVersion<int> RAMDISK_RPC_ID(0xdeb3, 0xfab2); constexpr PerGameVersion<int> RAMDISK_RPC_ID(0xdeb3, 0xfab2);
constexpr int RAMDISK_RPC_CHANNEL = 2; constexpr int RAMDISK_RPC_CHANNEL = 2;

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "common/common_types.h" #include "common/common_types.h"
#include "common/versions.h" #include "common/versions/versions.h"
#include "game/common/overlord_common.h" #include "game/common/overlord_common.h"

View file

@ -2,7 +2,7 @@
#include <string> #include <string>
#include "common/versions.h" #include "common/versions/versions.h"
#include "third-party/discord-rpc/include/discord_rpc.h" #include "third-party/discord-rpc/include/discord_rpc.h"

View file

@ -18,7 +18,6 @@
#include "game/common/file_paths.h" #include "game/common/file_paths.h"
#include "game/kernel/common/kscheme.h" #include "game/kernel/common/kscheme.h"
#include "game/kernel/svnrev.h"
#include "game/runtime.h" #include "game/runtime.h"
#include "game/system/newpad.h" #include "game/system/newpad.h"
#include "pipelines/opengl.h" #include "pipelines/opengl.h"
@ -312,9 +311,13 @@ u32 Init(GameVersion version) {
if (g_main_thread_id != std::this_thread::get_id()) { if (g_main_thread_id != std::this_thread::get_id()) {
lg::error("Ran Gfx::Init outside main thread. Init display elsewhere?"); lg::error("Ran Gfx::Init outside main thread. Init display elsewhere?");
} else { } else {
Display::InitMainDisplay(640, 480, std::string title = "OpenGOAL";
fmt::format("OpenGOAL - Work in Progress - {}", GIT_VERSION).c_str(), if (g_game_version == GameVersion::Jak2) {
g_settings, version); title += " - Work in Progress";
}
title +=
fmt::format(" - {} - {}", version_to_game_name_external(g_game_version), build_revision());
Display::InitMainDisplay(640, 480, title.c_str(), g_settings, version);
} }
return 0; return 0;

View file

@ -11,7 +11,7 @@
#include "common/common_types.h" #include "common/common_types.h"
#include "common/util/FileUtil.h" #include "common/util/FileUtil.h"
#include "common/versions.h" #include "common/versions/versions.h"
#include "game/kernel/common/kboot.h" #include "game/kernel/common/kboot.h"
#include "game/system/newpad.h" #include "game/system/newpad.h"

View file

@ -1,5 +1,5 @@
#pragma once #pragma once
#include "common/versions.h" #include "common/versions/versions.h"
#include "game/graphics/opengl_renderer/BucketRenderer.h" #include "game/graphics/opengl_renderer/BucketRenderer.h"

View file

@ -3,7 +3,7 @@
#include <string> #include <string>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/versions.h" #include "common/versions/versions.h"
class Shader { class Shader {
public: public:

View file

@ -4,7 +4,6 @@
#include <algorithm> #include <algorithm>
#include "game/graphics/gfx.h" #include "game/graphics/gfx.h"
#include "game/kernel/svnrev.h"
#include "third-party/imgui/imgui.h" #include "third-party/imgui/imgui.h"

View file

@ -10,7 +10,7 @@
#include "common/common_types.h" #include "common/common_types.h"
#include "common/util/Serializer.h" #include "common/util/Serializer.h"
#include "common/util/SmallVector.h" #include "common/util/SmallVector.h"
#include "common/versions.h" #include "common/versions/versions.h"
#include "game/graphics/texture/TextureConverter.h" #include "game/graphics/texture/TextureConverter.h"
@ -383,4 +383,4 @@ class TexturePool {
u32 m_tpage_dir_size = 0; u32 m_tpage_dir_size = 0;
std::mutex m_mutex; std::mutex m_mutex;
}; };

View file

@ -3,7 +3,7 @@
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
#include "common/versions.h" #include "common/versions/versions.h"
#include "game/kernel/common/fileio.h" #include "game/kernel/common/fileio.h"
#include "game/kernel/common/kmalloc.h" #include "game/kernel/common/kmalloc.h"

View file

@ -35,7 +35,6 @@
#include "game/kernel/jak1/klisten.h" #include "game/kernel/jak1/klisten.h"
#include "game/kernel/jak1/kscheme.h" #include "game/kernel/jak1/kscheme.h"
#include "game/kernel/jak1/ksound.h" #include "game/kernel/jak1/ksound.h"
#include "game/kernel/svnrev.h"
#include "game/sce/deci2.h" #include "game/sce/deci2.h"
#include "game/sce/libcdvd_ee.h" #include "game/sce/libcdvd_ee.h"
#include "game/sce/libdma.h" #include "game/sce/libdma.h"
@ -653,7 +652,7 @@ void InitMachine_PCPort() {
make_string_from_c(user_dir_path.string().c_str()); make_string_from_c(user_dir_path.string().c_str());
auto settings_path = file_util::get_user_settings_dir(g_game_version); auto settings_path = file_util::get_user_settings_dir(g_game_version);
intern_from_c("*pc-settings-folder*")->value = make_string_from_c(settings_path.string().c_str()); intern_from_c("*pc-settings-folder*")->value = make_string_from_c(settings_path.string().c_str());
intern_from_c("*pc-settings-built-sha*")->value = make_string_from_c(GIT_VERSION); intern_from_c("*pc-settings-built-sha*")->value = make_string_from_c(build_revision().c_str());
} }
/*! /*!

View file

@ -3,7 +3,7 @@
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
#include "common/versions.h" #include "common/versions/versions.h"
#include "game/kernel/common/fileio.h" #include "game/kernel/common/fileio.h"
#include "game/kernel/common/kmalloc.h" #include "game/kernel/common/kmalloc.h"

View file

@ -31,7 +31,6 @@
#include "game/kernel/jak2/kmalloc.h" #include "game/kernel/jak2/kmalloc.h"
#include "game/kernel/jak2/kscheme.h" #include "game/kernel/jak2/kscheme.h"
#include "game/kernel/jak2/ksound.h" #include "game/kernel/jak2/ksound.h"
#include "game/kernel/svnrev.h"
#include "game/sce/libdma.h" #include "game/sce/libdma.h"
#include "game/sce/libgraph.h" #include "game/sce/libgraph.h"
#include "game/sce/sif_ee.h" #include "game/sce/sif_ee.h"
@ -691,7 +690,7 @@ void InitMachine_PCPort() {
auto settings_path = file_util::get_user_settings_dir(g_game_version); auto settings_path = file_util::get_user_settings_dir(g_game_version);
intern_from_c("*pc-settings-folder*")->value() = intern_from_c("*pc-settings-folder*")->value() =
make_string_from_c(settings_path.string().c_str()); make_string_from_c(settings_path.string().c_str());
intern_from_c("*pc-settings-built-sha*")->value() = make_string_from_c(GIT_VERSION); intern_from_c("*pc-settings-built-sha*")->value() = make_string_from_c(build_revision().c_str());
} }
/*! /*!

View file

@ -13,7 +13,7 @@
#include "common/util/FileUtil.h" #include "common/util/FileUtil.h"
#include "common/util/os.h" #include "common/util/os.h"
#include "common/util/unicode_util.h" #include "common/util/unicode_util.h"
#include "common/versions.h" #include "common/versions/versions.h"
#include "game/common/game_common_types.h" #include "game/common/game_common_types.h"
@ -81,60 +81,8 @@ std::string game_arg_documentation() {
int main(int argc, char** argv) { int main(int argc, char** argv) {
ArgumentGuard u8_guard(argc, argv); ArgumentGuard u8_guard(argc, argv);
// TODO - this is a temporary shim to convert the old arg format
// into the new
//
// This is needed to avoid a coupled release with the launcher and
// can be removed after one release cycle
//
// Normal users launch gk with _no_ args
//
// Only handling args the launcher provides, all others can be changed
// in this repo at the time of merge.
std::vector<const char*> adjusted_argv_vals;
std::vector<const char*> adjusted_argv_vals_passthru;
for (int i = 0; i < argc; i++) {
const auto& val = std::string(argv[i]);
// Handle all args that aren't passed through
if (val == "-proj-path") {
adjusted_argv_vals.push_back("--proj-path");
i++;
if (i > argc) {
return 1;
}
adjusted_argv_vals.push_back(argv[i]);
} else if (val == "--") {
// if we hit a '--' then break out, args will be matched but they are already in the new
// format
break;
} else if (val == "-boot") {
// now handle all the ones that get passed to the game
adjusted_argv_vals_passthru.push_back("-boot");
} else if (val == "-fakeiso") {
adjusted_argv_vals_passthru.push_back("-fakeiso");
} else if (val == "-debug") {
adjusted_argv_vals_passthru.push_back("-debug");
}
}
std::vector<const char*> new_argv;
if (!adjusted_argv_vals.empty() || !adjusted_argv_vals_passthru.empty()) {
new_argv.push_back(argv[0]);
for (const auto& arg : adjusted_argv_vals) {
new_argv.push_back(arg);
}
if (!adjusted_argv_vals_passthru.empty()) {
new_argv.push_back("--");
for (const auto& arg : adjusted_argv_vals_passthru) {
new_argv.push_back(arg);
}
}
argv = (char**)new_argv.data();
argc = new_argv.size();
}
// --- END temporary shim
// CLI flags // CLI flags
bool show_version = false;
std::string game_name = "jak1"; std::string game_name = "jak1";
bool verbose_logging = false; bool verbose_logging = false;
bool disable_avx2 = false; bool disable_avx2 = false;
@ -144,6 +92,7 @@ int main(int argc, char** argv) {
fs::path project_path_override; fs::path project_path_override;
std::vector<std::string> game_args; std::vector<std::string> game_args;
CLI::App app{"OpenGOAL Game Runtime"}; CLI::App app{"OpenGOAL Game Runtime"};
app.add_flag("--version", show_version, "Display the built revision");
app.add_option("-g,--game", game_name, "The game name: 'jak1' or 'jak2'"); app.add_option("-g,--game", game_name, "The game name: 'jak1' or 'jak2'");
app.add_flag("-v,--verbose", verbose_logging, "Enable verbose logging on stdout"); app.add_flag("-v,--verbose", verbose_logging, "Enable verbose logging on stdout");
app.add_flag( app.add_flag(
@ -160,6 +109,11 @@ int main(int argc, char** argv) {
app.allow_extras(); app.allow_extras();
CLI11_PARSE(app, argc, argv); CLI11_PARSE(app, argc, argv);
if (show_version) {
lg::print(build_revision());
return 0;
}
// Create struct with all non-kmachine handled args to pass to the runtime // Create struct with all non-kmachine handled args to pass to the runtime
GameLaunchOptions game_options; GameLaunchOptions game_options;
game_options.disable_debug_vm = disable_debug_vm; game_options.disable_debug_vm = disable_debug_vm;

View file

@ -10,7 +10,7 @@
#include "common/log/log.h" #include "common/log/log.h"
#include "common/util/Assert.h" #include "common/util/Assert.h"
#include "common/versions.h" #include "common/versions/versions.h"
#include "game/common/game_common_types.h" #include "game/common/game_common_types.h"
#include "game/common/loader_rpc_types.h" #include "game/common/loader_rpc_types.h"

View file

@ -27,7 +27,7 @@
#include "common/goal_constants.h" #include "common/goal_constants.h"
#include "common/log/log.h" #include "common/log/log.h"
#include "common/util/FileUtil.h" #include "common/util/FileUtil.h"
#include "common/versions.h" #include "common/versions/versions.h"
#include "game/discord.h" #include "game/discord.h"
#include "game/graphics/gfx.h" #include "game/graphics/gfx.h"

View file

@ -8,7 +8,7 @@
#include <thread> #include <thread>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/versions.h" #include "common/versions/versions.h"
#include "game/common/game_common_types.h" #include "game/common/game_common_types.h"
#include "game/kernel/common/kboot.h" #include "game/kernel/common/kboot.h"

View file

@ -8,7 +8,7 @@
#include "Deci2Server.h" #include "Deci2Server.h"
#include "common/cross_sockets/XSocket.h" #include "common/cross_sockets/XSocket.h"
#include "common/versions.h" #include "common/versions/versions.h"
#include "common/listener_common.h" #include "common/listener_common.h"
#include "common/util/Assert.h" #include "common/util/Assert.h"

View file

@ -1,6 +1,6 @@
#include "FileInfo.h" #include "FileInfo.h"
#include "common/versions.h" #include "common/versions/versions.h"
#include "goalc/data_compiler/DataObjectGenerator.h" #include "goalc/data_compiler/DataObjectGenerator.h"
@ -29,4 +29,4 @@ FileInfo make_file_info_for_level(const std::string& file_name) {
info.tool_debug = "Created by OpenGOAL buildlevel"; info.tool_debug = "Created by OpenGOAL buildlevel";
info.mdb_file_name = "Unknown"; info.mdb_file_name = "Unknown";
return info; return info;
} }

View file

@ -9,7 +9,7 @@
#include "Env.h" #include "Env.h"
#include "common/versions.h" #include "common/versions/versions.h"
#include "goalc/emitter/ObjectGenerator.h" #include "goalc/emitter/ObjectGenerator.h"

View file

@ -17,7 +17,7 @@
#include "common/common_types.h" #include "common/common_types.h"
#include "common/cross_os_debug/xdbg.h" #include "common/cross_os_debug/xdbg.h"
#include "common/versions.h" #include "common/versions/versions.h"
#include "goalc/listener/MemoryMap.h" #include "goalc/listener/MemoryMap.h"

View file

@ -17,7 +17,7 @@
#include "common/goal_constants.h" #include "common/goal_constants.h"
#include "common/type_system/TypeSystem.h" #include "common/type_system/TypeSystem.h"
#include "common/versions.h" #include "common/versions/versions.h"
#include "goalc/debugger/DebugInfo.h" #include "goalc/debugger/DebugInfo.h"
@ -636,4 +636,4 @@ ObjectGeneratorStats ObjectGenerator::get_stats() const {
void ObjectGenerator::count_eliminated_move() { void ObjectGenerator::count_eliminated_move() {
m_stats.moves_eliminated++; m_stats.moves_eliminated++;
} }
} // namespace emitter } // namespace emitter

View file

@ -12,7 +12,7 @@
#include "Instruction.h" #include "Instruction.h"
#include "ObjectFileData.h" #include "ObjectFileData.h"
#include "common/versions.h" #include "common/versions/versions.h"
#include "goalc/debugger/DebugInfo.h" #include "goalc/debugger/DebugInfo.h"

View file

@ -28,7 +28,7 @@
#include "common/cross_sockets/XSocket.h" #include "common/cross_sockets/XSocket.h"
#include "common/util/Assert.h" #include "common/util/Assert.h"
#include "common/versions.h" #include "common/versions/versions.h"
#include "common/log/log.h" #include "common/log/log.h"
#include "Listener.h" #include "Listener.h"

View file

@ -17,7 +17,7 @@
#include "common/common_types.h" #include "common/common_types.h"
#include "common/cross_os_debug/xdbg.h" #include "common/cross_os_debug/xdbg.h"
#include "common/versions.h" #include "common/versions/versions.h"
#include "common/listener_common.h" #include "common/listener_common.h"
#include "goalc/debugger/Debugger.h" #include "goalc/debugger/Debugger.h"

View file

@ -8,7 +8,7 @@
#include "common/util/diff.h" #include "common/util/diff.h"
#include "common/util/string_util.h" #include "common/util/string_util.h"
#include "common/util/unicode_util.h" #include "common/util/unicode_util.h"
#include "common/versions.h" #include "common/versions/versions.h"
#include "goalc/compiler/Compiler.h" #include "goalc/compiler/Compiler.h"

View file

@ -1,6 +1,6 @@
#include "common/log/log.h" #include "common/log/log.h"
#include "common/util/FileUtil.h" #include "common/util/FileUtil.h"
#include "common/versions.h" #include "common/versions/versions.h"
#include "goalc/compiler/Compiler.h" #include "goalc/compiler/Compiler.h"

View file

@ -3,7 +3,7 @@
#include "common/util/BinaryWriter.h" #include "common/util/BinaryWriter.h"
#include "common/util/FileUtil.h" #include "common/util/FileUtil.h"
#include "common/util/unicode_util.h" #include "common/util/unicode_util.h"
#include "common/versions.h" #include "common/versions/versions.h"
#include "third-party/json.hpp" #include "third-party/json.hpp"

View file

@ -4,7 +4,7 @@
#include "common/util/DgoReader.h" #include "common/util/DgoReader.h"
#include "common/util/FileUtil.h" #include "common/util/FileUtil.h"
#include "common/util/unicode_util.h" #include "common/util/unicode_util.h"
#include "common/versions.h" #include "common/versions/versions.h"
namespace { namespace {
int run(int argc, char** argv) { int run(int argc, char** argv) {