From a264b6539b816256b33ba1898ac8998fe1d3bca2 Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Sat, 22 Apr 2023 13:13:57 -0500 Subject: [PATCH] game: Remove temporary CLI arg shim in `gk` (#2532) --- .gitignore | 1 + common/CMakeLists.txt | 27 +++++++- common/goal_constants.h | 2 +- common/repl/config.cpp | 2 +- common/repl/config.h | 2 +- common/repl/nrepl/ReplClient.cpp | 2 +- common/repl/nrepl/ReplServer.cpp | 2 +- common/repl/util.cpp | 2 +- common/symbols.h | 4 +- common/util/FileUtil.h | 2 +- common/util/dgo_util.cpp | 2 +- common/util/dgo_util.h | 4 +- common/{ => versions}/versions.cpp | 22 +++++++ common/{ => versions}/versions.h | 3 + decompiler/analysis/mips2c.h | 2 +- decompiler/config.h | 2 +- decompiler/data/StrFileReader.h | 2 +- decompiler/data/tpage.cpp | 2 +- decompiler/level_extractor/BspHeader.h | 2 +- decompiler/level_extractor/MercData.h | 4 +- decompiler/main.cpp | 2 +- decompiler/util/data_decompile.h | 2 +- decompiler/util/type_utils.h | 4 +- game/CMakeLists.txt | 31 ---------- game/common/dgo_rpc_types.h | 2 +- game/common/game_common_types.h | 2 +- game/common/loader_rpc_types.h | 2 +- game/common/play_rpc_types.h | 2 +- game/common/player_rpc_types.h | 2 +- game/common/ramdisk_rpc_types.h | 2 +- game/common/str_rpc_types.h | 2 +- game/discord.h | 2 +- game/graphics/gfx.cpp | 11 ++-- game/graphics/gfx.h | 2 +- .../opengl_renderer/CollideMeshRenderer.h | 2 +- game/graphics/opengl_renderer/Shader.h | 2 +- game/graphics/opengl_renderer/debug_gui.cpp | 1 - game/graphics/texture/TexturePool.h | 4 +- game/kernel/jak1/fileio.cpp | 2 +- game/kernel/jak1/kmachine.cpp | 3 +- game/kernel/jak2/fileio.cpp | 2 +- game/kernel/jak2/kmachine.cpp | 3 +- game/main.cpp | 62 +++---------------- game/overlord/srpc.cpp | 2 +- game/runtime.cpp | 2 +- game/runtime.h | 2 +- game/system/Deci2Server.cpp | 2 +- goalc/build_level/FileInfo.cpp | 4 +- goalc/compiler/CodeGenerator.h | 2 +- goalc/debugger/Debugger.h | 2 +- goalc/emitter/ObjectGenerator.cpp | 4 +- goalc/emitter/ObjectGenerator.h | 2 +- goalc/listener/Listener.cpp | 2 +- goalc/listener/Listener.h | 2 +- goalc/main.cpp | 2 +- goalc/simple_main.cpp | 2 +- tools/dgo_packer.cpp | 2 +- tools/dgo_unpacker.cpp | 2 +- 58 files changed, 123 insertions(+), 151 deletions(-) rename common/{ => versions}/versions.cpp (64%) rename common/{ => versions}/versions.h (94%) diff --git a/.gitignore b/.gitignore index a77e0d760..39afe2599 100644 --- a/.gitignore +++ b/.gitignore @@ -57,6 +57,7 @@ texture_replacements/* # generated cmake files svnrev.h +common/versions/revision.h ci-artifacts/ out/build/ __pycache__/ diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 24b25a632..2db69a314 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -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 - versions.cpp + versions/versions.cpp audio/audio_formats.cpp cross_os_debug/xdbg.cpp cross_sockets/XSocket.cpp @@ -53,7 +76,7 @@ add_library(common util/print_float.cpp util/FrameLimiter.cpp util/unicode_util.cpp - util/term_util.cpp) + util/term_util.cpp ) target_link_libraries(common fmt lzokay replxx libzstd_static) diff --git a/common/goal_constants.h b/common/goal_constants.h index 55dc2bcfd..9c7385a2e 100644 --- a/common/goal_constants.h +++ b/common/goal_constants.h @@ -1,7 +1,7 @@ #pragma once #include "common/common_types.h" -#include "common/versions.h" +#include "common/versions/versions.h" constexpr s32 BINTEGER_OFFSET = 0; constexpr s32 PAIR_OFFSET = 2; diff --git a/common/repl/config.cpp b/common/repl/config.cpp index 32c805a2f..e2d58e1ee 100644 --- a/common/repl/config.cpp +++ b/common/repl/config.cpp @@ -1,6 +1,6 @@ #include "config.h" -#include "common/versions.h" +#include "common/versions/versions.h" #include "third-party/fmt/core.h" diff --git a/common/repl/config.h b/common/repl/config.h index 0da9563f5..814006416 100644 --- a/common/repl/config.h +++ b/common/repl/config.h @@ -5,7 +5,7 @@ #include #include -#include "common/versions.h" +#include "common/versions/versions.h" #include "third-party/json.hpp" diff --git a/common/repl/nrepl/ReplClient.cpp b/common/repl/nrepl/ReplClient.cpp index eb19cd28b..4e00afb83 100644 --- a/common/repl/nrepl/ReplClient.cpp +++ b/common/repl/nrepl/ReplClient.cpp @@ -2,7 +2,7 @@ #include "ReplClient.h" #include "common/cross_sockets/XSocket.h" -#include "common/versions.h" +#include "common/versions/versions.h" #include "third-party/fmt/core.h" diff --git a/common/repl/nrepl/ReplServer.cpp b/common/repl/nrepl/ReplServer.cpp index 2286a8b8f..aec41d79b 100644 --- a/common/repl/nrepl/ReplServer.cpp +++ b/common/repl/nrepl/ReplServer.cpp @@ -2,7 +2,7 @@ #include "ReplServer.h" #include "common/cross_sockets/XSocket.h" -#include "common/versions.h" +#include "common/versions/versions.h" #include "third-party/fmt/core.h" diff --git a/common/repl/util.cpp b/common/repl/util.cpp index bddd44aea..45eef4a2b 100644 --- a/common/repl/util.cpp +++ b/common/repl/util.cpp @@ -3,7 +3,7 @@ #include "common/util/FileUtil.h" #include "common/util/json_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/core.h" diff --git a/common/symbols.h b/common/symbols.h index 1dc291dc1..225ce128e 100644 --- a/common/symbols.h +++ b/common/symbols.h @@ -1,6 +1,6 @@ #pragma once -#include "common/versions.h" +#include "common/versions/versions.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. return jak2_symbols::S7_OFF_FIX_SYM_EMPTY_PAIR; } -} \ No newline at end of file +} diff --git a/common/util/FileUtil.h b/common/util/FileUtil.h index 9b5864de4..5c5337a5b 100644 --- a/common/util/FileUtil.h +++ b/common/util/FileUtil.h @@ -22,7 +22,7 @@ #include #include "common/common_types.h" -#include "common/versions.h" +#include "common/versions/versions.h" namespace fs = ghc::filesystem; diff --git a/common/util/dgo_util.cpp b/common/util/dgo_util.cpp index b328d2740..acffcda44 100644 --- a/common/util/dgo_util.cpp +++ b/common/util/dgo_util.cpp @@ -3,7 +3,7 @@ #include #include "common/util/Assert.h" -#include "common/versions.h" +#include "common/versions/versions.h" #include "third-party/fmt/core.h" diff --git a/common/util/dgo_util.h b/common/util/dgo_util.h index 06d22b6e0..8f1b06d73 100644 --- a/common/util/dgo_util.h +++ b/common/util/dgo_util.h @@ -3,7 +3,7 @@ #include #include "common/common_types.h" -#include "common/versions.h" +#include "common/versions/versions.h" 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); \ No newline at end of file +std::string get_object_file_name(const std::string& original_name, u8* data, int size); diff --git a/common/versions.cpp b/common/versions/versions.cpp similarity index 64% rename from common/versions.cpp rename to common/versions/versions.cpp index 72932c04d..836c454cd 100644 --- a/common/versions.cpp +++ b/common/versions/versions.cpp @@ -1,6 +1,7 @@ #include "versions.h" #include "common/util/Assert.h" +#include "common/versions/revision.h" #include "third-party/fmt/core.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 valid_game_version_names() { 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"; +} diff --git a/common/versions.h b/common/versions/versions.h similarity index 94% rename from common/versions.h rename to common/versions/versions.h index d26bc156a..40c34e402 100644 --- a/common/versions.h +++ b/common/versions/versions.h @@ -56,4 +56,7 @@ constexpr PerGameVersion game_version_names = {"jak1", "jak2"}; GameVersion game_name_to_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_external(GameVersion v); std::vector valid_game_version_names(); + +std::string build_revision(); diff --git a/decompiler/analysis/mips2c.h b/decompiler/analysis/mips2c.h index ee69b1b73..1613393e0 100644 --- a/decompiler/analysis/mips2c.h +++ b/decompiler/analysis/mips2c.h @@ -2,7 +2,7 @@ #include -#include "common/versions.h" +#include "common/versions/versions.h" namespace decompiler { class Function; diff --git a/decompiler/config.h b/decompiler/config.h index b7f302115..470aafe38 100644 --- a/decompiler/config.h +++ b/decompiler/config.h @@ -8,7 +8,7 @@ #include "common/common_types.h" #include "common/util/FileUtil.h" -#include "common/versions.h" +#include "common/versions/versions.h" #include "decompiler/Disasm/Register.h" #include "decompiler/data/game_text.h" diff --git a/decompiler/data/StrFileReader.h b/decompiler/data/StrFileReader.h index 3d16de1ff..2db7f612c 100644 --- a/decompiler/data/StrFileReader.h +++ b/decompiler/data/StrFileReader.h @@ -11,7 +11,7 @@ #include "common/common_types.h" #include "common/util/Assert.h" #include "common/util/FileUtil.h" -#include "common/versions.h" +#include "common/versions/versions.h" namespace decompiler { class StrFileReader { diff --git a/decompiler/data/tpage.cpp b/decompiler/data/tpage.cpp index 4654f64bc..1d8e25a90 100644 --- a/decompiler/data/tpage.cpp +++ b/decompiler/data/tpage.cpp @@ -18,7 +18,7 @@ #include "common/texture/texture_conversion.h" #include "common/util/FileUtil.h" -#include "common/versions.h" +#include "common/versions/versions.h" #include "decompiler/ObjectFile/ObjectFileDB.h" diff --git a/decompiler/level_extractor/BspHeader.h b/decompiler/level_extractor/BspHeader.h index 40dd0ad11..aecc6d191 100644 --- a/decompiler/level_extractor/BspHeader.h +++ b/decompiler/level_extractor/BspHeader.h @@ -7,7 +7,7 @@ #include "common/common_types.h" #include "common/math/Vector.h" -#include "common/versions.h" +#include "common/versions/versions.h" #include "decompiler/level_extractor/common_formats.h" #include "decompiler/util/goal_data_reader.h" diff --git a/decompiler/level_extractor/MercData.h b/decompiler/level_extractor/MercData.h index d004347e4..81950a244 100644 --- a/decompiler/level_extractor/MercData.h +++ b/decompiler/level_extractor/MercData.h @@ -7,7 +7,7 @@ #include "common/common_types.h" #include "common/dma/gs.h" #include "common/math/Vector.h" -#include "common/versions.h" +#include "common/versions/versions.h" #include "decompiler/util/goal_data_reader.h" @@ -219,4 +219,4 @@ struct MercCtrl { void debug_print_blerc(); std::string print(); }; -} // namespace decompiler \ No newline at end of file +} // namespace decompiler diff --git a/decompiler/main.cpp b/decompiler/main.cpp index abf940ec7..2db59e4d9 100644 --- a/decompiler/main.cpp +++ b/decompiler/main.cpp @@ -11,7 +11,7 @@ #include "common/util/os.h" #include "common/util/set_util.h" #include "common/util/unicode_util.h" -#include "common/versions.h" +#include "common/versions/versions.h" #include "ObjectFile/ObjectFileDB.h" #include "decompiler/data/TextureDB.h" diff --git a/decompiler/util/data_decompile.h b/decompiler/util/data_decompile.h index e9075f8dd..9adb5d498 100644 --- a/decompiler/util/data_decompile.h +++ b/decompiler/util/data_decompile.h @@ -5,7 +5,7 @@ #include "common/goos/Object.h" #include "common/type_system/TypeSpec.h" #include "common/type_system/TypeSystem.h" -#include "common/versions.h" +#include "common/versions/versions.h" #include "decompiler/Disasm/DecompilerLabel.h" #include "decompiler/IR2/LabelDB.h" diff --git a/decompiler/util/type_utils.h b/decompiler/util/type_utils.h index b4587eda1..250d7b3c9 100644 --- a/decompiler/util/type_utils.h +++ b/decompiler/util/type_utils.h @@ -1,7 +1,7 @@ #pragma once #include "common/goal_constants.h" #include "common/type_system/TypeSpec.h" -#include "common/versions.h" +#include "common/versions/versions.h" namespace decompiler { @@ -16,4 +16,4 @@ constexpr PerGameVersion SYMBOL_TO_STRING_MEM_OFFSET_DECOMP = {8167 * 8, jak2::SYM_TO_STRING_OFFSET}; constexpr PerGameVersion OFFSET_OF_NEXT_STATE_STORE = {72, 64}; -} // namespace decompiler \ No newline at end of file +} // namespace decompiler diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt index 4e8833498..49967d4f0 100644 --- a/game/CMakeLists.txt +++ b/game/CMakeLists.txt @@ -182,37 +182,6 @@ set(RUNTIME_SOURCE tools/subtitles/subtitle_editor.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) # we build the runtime as a static library. diff --git a/game/common/dgo_rpc_types.h b/game/common/dgo_rpc_types.h index 0890a3407..e2e770fa6 100644 --- a/game/common/dgo_rpc_types.h +++ b/game/common/dgo_rpc_types.h @@ -6,7 +6,7 @@ */ #include "common/common_types.h" -#include "common/versions.h" +#include "common/versions/versions.h" constexpr PerGameVersion DGO_RPC_ID(0xdeb4, 0xfab3); constexpr int DGO_RPC_CHANNEL = 3; diff --git a/game/common/game_common_types.h b/game/common/game_common_types.h index a082909fb..aa841d7a3 100644 --- a/game/common/game_common_types.h +++ b/game/common/game_common_types.h @@ -1,7 +1,7 @@ #pragma once #include "common/listener_common.h" -#include "common/versions.h" +#include "common/versions/versions.h" //! Supported languages. enum class Language { diff --git a/game/common/loader_rpc_types.h b/game/common/loader_rpc_types.h index c7dc7d420..1d52320e6 100644 --- a/game/common/loader_rpc_types.h +++ b/game/common/loader_rpc_types.h @@ -5,7 +5,7 @@ * 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 LOADER_RPC_ID(0xdeb2, 0xfab1); constexpr int LOADER_RPC_CHANNEL = 1; diff --git a/game/common/play_rpc_types.h b/game/common/play_rpc_types.h index b9bd6039c..e018b729f 100644 --- a/game/common/play_rpc_types.h +++ b/game/common/play_rpc_types.h @@ -5,7 +5,7 @@ * Types used for the play Remote Procedure Call between the EE and the IOP. * Note that PLAY and PLAYER are different. */ -#include "common/versions.h" +#include "common/versions/versions.h" constexpr PerGameVersion PLAY_RPC_ID(0xdeb6, 0xfab5); constexpr int PLAY_RPC_CHANNEL = 5; diff --git a/game/common/player_rpc_types.h b/game/common/player_rpc_types.h index 6e7dfa050..d26eb4046 100644 --- a/game/common/player_rpc_types.h +++ b/game/common/player_rpc_types.h @@ -5,7 +5,7 @@ * Types used for the player Remote Procedure Call between the EE and the IOP. * Note that PLAY and PLAYER are different. */ -#include "common/versions.h" +#include "common/versions/versions.h" constexpr PerGameVersion PLAYER_RPC_ID(0xdeb1, 0xfab0); constexpr int PLAYER_RPC_CHANNEL = 0; diff --git a/game/common/ramdisk_rpc_types.h b/game/common/ramdisk_rpc_types.h index 2a990b5f0..209a338dc 100644 --- a/game/common/ramdisk_rpc_types.h +++ b/game/common/ramdisk_rpc_types.h @@ -6,7 +6,7 @@ */ #include "common/common_types.h" -#include "common/versions.h" +#include "common/versions/versions.h" constexpr PerGameVersion RAMDISK_RPC_ID(0xdeb3, 0xfab2); constexpr int RAMDISK_RPC_CHANNEL = 2; diff --git a/game/common/str_rpc_types.h b/game/common/str_rpc_types.h index 5e849901a..ae357bde3 100644 --- a/game/common/str_rpc_types.h +++ b/game/common/str_rpc_types.h @@ -1,7 +1,7 @@ #pragma once #include "common/common_types.h" -#include "common/versions.h" +#include "common/versions/versions.h" #include "game/common/overlord_common.h" diff --git a/game/discord.h b/game/discord.h index f694d2826..5d9eb769d 100644 --- a/game/discord.h +++ b/game/discord.h @@ -2,7 +2,7 @@ #include -#include "common/versions.h" +#include "common/versions/versions.h" #include "third-party/discord-rpc/include/discord_rpc.h" diff --git a/game/graphics/gfx.cpp b/game/graphics/gfx.cpp index 143d85f11..462177d3a 100644 --- a/game/graphics/gfx.cpp +++ b/game/graphics/gfx.cpp @@ -18,7 +18,6 @@ #include "game/common/file_paths.h" #include "game/kernel/common/kscheme.h" -#include "game/kernel/svnrev.h" #include "game/runtime.h" #include "game/system/newpad.h" #include "pipelines/opengl.h" @@ -312,9 +311,13 @@ u32 Init(GameVersion version) { if (g_main_thread_id != std::this_thread::get_id()) { lg::error("Ran Gfx::Init outside main thread. Init display elsewhere?"); } else { - Display::InitMainDisplay(640, 480, - fmt::format("OpenGOAL - Work in Progress - {}", GIT_VERSION).c_str(), - g_settings, version); + std::string title = "OpenGOAL"; + if (g_game_version == GameVersion::Jak2) { + 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; diff --git a/game/graphics/gfx.h b/game/graphics/gfx.h index 0b31c156b..f0c97a6d0 100644 --- a/game/graphics/gfx.h +++ b/game/graphics/gfx.h @@ -11,7 +11,7 @@ #include "common/common_types.h" #include "common/util/FileUtil.h" -#include "common/versions.h" +#include "common/versions/versions.h" #include "game/kernel/common/kboot.h" #include "game/system/newpad.h" diff --git a/game/graphics/opengl_renderer/CollideMeshRenderer.h b/game/graphics/opengl_renderer/CollideMeshRenderer.h index f524dfed0..b7c18ce93 100644 --- a/game/graphics/opengl_renderer/CollideMeshRenderer.h +++ b/game/graphics/opengl_renderer/CollideMeshRenderer.h @@ -1,5 +1,5 @@ #pragma once -#include "common/versions.h" +#include "common/versions/versions.h" #include "game/graphics/opengl_renderer/BucketRenderer.h" diff --git a/game/graphics/opengl_renderer/Shader.h b/game/graphics/opengl_renderer/Shader.h index 95c047f0b..b74101738 100644 --- a/game/graphics/opengl_renderer/Shader.h +++ b/game/graphics/opengl_renderer/Shader.h @@ -3,7 +3,7 @@ #include #include "common/common_types.h" -#include "common/versions.h" +#include "common/versions/versions.h" class Shader { public: diff --git a/game/graphics/opengl_renderer/debug_gui.cpp b/game/graphics/opengl_renderer/debug_gui.cpp index 856e3d24a..b725d0990 100644 --- a/game/graphics/opengl_renderer/debug_gui.cpp +++ b/game/graphics/opengl_renderer/debug_gui.cpp @@ -4,7 +4,6 @@ #include #include "game/graphics/gfx.h" -#include "game/kernel/svnrev.h" #include "third-party/imgui/imgui.h" diff --git a/game/graphics/texture/TexturePool.h b/game/graphics/texture/TexturePool.h index bcd3cb6ab..9a03c8b97 100644 --- a/game/graphics/texture/TexturePool.h +++ b/game/graphics/texture/TexturePool.h @@ -10,7 +10,7 @@ #include "common/common_types.h" #include "common/util/Serializer.h" #include "common/util/SmallVector.h" -#include "common/versions.h" +#include "common/versions/versions.h" #include "game/graphics/texture/TextureConverter.h" @@ -383,4 +383,4 @@ class TexturePool { u32 m_tpage_dir_size = 0; std::mutex m_mutex; -}; \ No newline at end of file +}; diff --git a/game/kernel/jak1/fileio.cpp b/game/kernel/jak1/fileio.cpp index f491a5480..300ba3c78 100644 --- a/game/kernel/jak1/fileio.cpp +++ b/game/kernel/jak1/fileio.cpp @@ -3,7 +3,7 @@ #include #include -#include "common/versions.h" +#include "common/versions/versions.h" #include "game/kernel/common/fileio.h" #include "game/kernel/common/kmalloc.h" diff --git a/game/kernel/jak1/kmachine.cpp b/game/kernel/jak1/kmachine.cpp index e1b3a4745..73f3529d6 100644 --- a/game/kernel/jak1/kmachine.cpp +++ b/game/kernel/jak1/kmachine.cpp @@ -35,7 +35,6 @@ #include "game/kernel/jak1/klisten.h" #include "game/kernel/jak1/kscheme.h" #include "game/kernel/jak1/ksound.h" -#include "game/kernel/svnrev.h" #include "game/sce/deci2.h" #include "game/sce/libcdvd_ee.h" #include "game/sce/libdma.h" @@ -653,7 +652,7 @@ void InitMachine_PCPort() { make_string_from_c(user_dir_path.string().c_str()); 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-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()); } /*! diff --git a/game/kernel/jak2/fileio.cpp b/game/kernel/jak2/fileio.cpp index 13aea7328..5568ae6d2 100644 --- a/game/kernel/jak2/fileio.cpp +++ b/game/kernel/jak2/fileio.cpp @@ -3,7 +3,7 @@ #include #include -#include "common/versions.h" +#include "common/versions/versions.h" #include "game/kernel/common/fileio.h" #include "game/kernel/common/kmalloc.h" diff --git a/game/kernel/jak2/kmachine.cpp b/game/kernel/jak2/kmachine.cpp index 604748071..0e430db64 100644 --- a/game/kernel/jak2/kmachine.cpp +++ b/game/kernel/jak2/kmachine.cpp @@ -31,7 +31,6 @@ #include "game/kernel/jak2/kmalloc.h" #include "game/kernel/jak2/kscheme.h" #include "game/kernel/jak2/ksound.h" -#include "game/kernel/svnrev.h" #include "game/sce/libdma.h" #include "game/sce/libgraph.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); 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()); } /*! diff --git a/game/main.cpp b/game/main.cpp index 2103ed584..cac0a5624 100644 --- a/game/main.cpp +++ b/game/main.cpp @@ -13,7 +13,7 @@ #include "common/util/FileUtil.h" #include "common/util/os.h" #include "common/util/unicode_util.h" -#include "common/versions.h" +#include "common/versions/versions.h" #include "game/common/game_common_types.h" @@ -81,60 +81,8 @@ std::string game_arg_documentation() { int main(int argc, char** 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 adjusted_argv_vals; - std::vector 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 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 + bool show_version = false; std::string game_name = "jak1"; bool verbose_logging = false; bool disable_avx2 = false; @@ -144,6 +92,7 @@ int main(int argc, char** argv) { fs::path project_path_override; std::vector game_args; 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_flag("-v,--verbose", verbose_logging, "Enable verbose logging on stdout"); app.add_flag( @@ -160,6 +109,11 @@ int main(int argc, char** argv) { app.allow_extras(); 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 GameLaunchOptions game_options; game_options.disable_debug_vm = disable_debug_vm; diff --git a/game/overlord/srpc.cpp b/game/overlord/srpc.cpp index be76346c9..0906dad2f 100644 --- a/game/overlord/srpc.cpp +++ b/game/overlord/srpc.cpp @@ -10,7 +10,7 @@ #include "common/log/log.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/loader_rpc_types.h" diff --git a/game/runtime.cpp b/game/runtime.cpp index 240add299..c97a99485 100644 --- a/game/runtime.cpp +++ b/game/runtime.cpp @@ -27,7 +27,7 @@ #include "common/goal_constants.h" #include "common/log/log.h" #include "common/util/FileUtil.h" -#include "common/versions.h" +#include "common/versions/versions.h" #include "game/discord.h" #include "game/graphics/gfx.h" diff --git a/game/runtime.h b/game/runtime.h index 23ffa33e4..143a1ffa6 100644 --- a/game/runtime.h +++ b/game/runtime.h @@ -8,7 +8,7 @@ #include #include "common/common_types.h" -#include "common/versions.h" +#include "common/versions/versions.h" #include "game/common/game_common_types.h" #include "game/kernel/common/kboot.h" diff --git a/game/system/Deci2Server.cpp b/game/system/Deci2Server.cpp index 2fca1a588..dfed9a3bd 100644 --- a/game/system/Deci2Server.cpp +++ b/game/system/Deci2Server.cpp @@ -8,7 +8,7 @@ #include "Deci2Server.h" #include "common/cross_sockets/XSocket.h" -#include "common/versions.h" +#include "common/versions/versions.h" #include "common/listener_common.h" #include "common/util/Assert.h" diff --git a/goalc/build_level/FileInfo.cpp b/goalc/build_level/FileInfo.cpp index 229a67457..e93781dd0 100644 --- a/goalc/build_level/FileInfo.cpp +++ b/goalc/build_level/FileInfo.cpp @@ -1,6 +1,6 @@ #include "FileInfo.h" -#include "common/versions.h" +#include "common/versions/versions.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.mdb_file_name = "Unknown"; return info; -} \ No newline at end of file +} diff --git a/goalc/compiler/CodeGenerator.h b/goalc/compiler/CodeGenerator.h index c60f70a49..24f380688 100644 --- a/goalc/compiler/CodeGenerator.h +++ b/goalc/compiler/CodeGenerator.h @@ -9,7 +9,7 @@ #include "Env.h" -#include "common/versions.h" +#include "common/versions/versions.h" #include "goalc/emitter/ObjectGenerator.h" diff --git a/goalc/debugger/Debugger.h b/goalc/debugger/Debugger.h index 421a39435..49c6aa12d 100644 --- a/goalc/debugger/Debugger.h +++ b/goalc/debugger/Debugger.h @@ -17,7 +17,7 @@ #include "common/common_types.h" #include "common/cross_os_debug/xdbg.h" -#include "common/versions.h" +#include "common/versions/versions.h" #include "goalc/listener/MemoryMap.h" diff --git a/goalc/emitter/ObjectGenerator.cpp b/goalc/emitter/ObjectGenerator.cpp index e8dd8786c..64b6e764e 100644 --- a/goalc/emitter/ObjectGenerator.cpp +++ b/goalc/emitter/ObjectGenerator.cpp @@ -17,7 +17,7 @@ #include "common/goal_constants.h" #include "common/type_system/TypeSystem.h" -#include "common/versions.h" +#include "common/versions/versions.h" #include "goalc/debugger/DebugInfo.h" @@ -636,4 +636,4 @@ ObjectGeneratorStats ObjectGenerator::get_stats() const { void ObjectGenerator::count_eliminated_move() { m_stats.moves_eliminated++; } -} // namespace emitter \ No newline at end of file +} // namespace emitter diff --git a/goalc/emitter/ObjectGenerator.h b/goalc/emitter/ObjectGenerator.h index c8b5244cd..8cfaf2c60 100644 --- a/goalc/emitter/ObjectGenerator.h +++ b/goalc/emitter/ObjectGenerator.h @@ -12,7 +12,7 @@ #include "Instruction.h" #include "ObjectFileData.h" -#include "common/versions.h" +#include "common/versions/versions.h" #include "goalc/debugger/DebugInfo.h" diff --git a/goalc/listener/Listener.cpp b/goalc/listener/Listener.cpp index d3a1df913..35cd7207c 100644 --- a/goalc/listener/Listener.cpp +++ b/goalc/listener/Listener.cpp @@ -28,7 +28,7 @@ #include "common/cross_sockets/XSocket.h" #include "common/util/Assert.h" -#include "common/versions.h" +#include "common/versions/versions.h" #include "common/log/log.h" #include "Listener.h" diff --git a/goalc/listener/Listener.h b/goalc/listener/Listener.h index f49deecb1..e67858f02 100644 --- a/goalc/listener/Listener.h +++ b/goalc/listener/Listener.h @@ -17,7 +17,7 @@ #include "common/common_types.h" #include "common/cross_os_debug/xdbg.h" -#include "common/versions.h" +#include "common/versions/versions.h" #include "common/listener_common.h" #include "goalc/debugger/Debugger.h" diff --git a/goalc/main.cpp b/goalc/main.cpp index 52466ce0c..c41f1e92c 100644 --- a/goalc/main.cpp +++ b/goalc/main.cpp @@ -8,7 +8,7 @@ #include "common/util/diff.h" #include "common/util/string_util.h" #include "common/util/unicode_util.h" -#include "common/versions.h" +#include "common/versions/versions.h" #include "goalc/compiler/Compiler.h" diff --git a/goalc/simple_main.cpp b/goalc/simple_main.cpp index ee48b73bd..fe14bbb1d 100644 --- a/goalc/simple_main.cpp +++ b/goalc/simple_main.cpp @@ -1,6 +1,6 @@ #include "common/log/log.h" #include "common/util/FileUtil.h" -#include "common/versions.h" +#include "common/versions/versions.h" #include "goalc/compiler/Compiler.h" diff --git a/tools/dgo_packer.cpp b/tools/dgo_packer.cpp index 6275e959c..b99147f5d 100644 --- a/tools/dgo_packer.cpp +++ b/tools/dgo_packer.cpp @@ -3,7 +3,7 @@ #include "common/util/BinaryWriter.h" #include "common/util/FileUtil.h" #include "common/util/unicode_util.h" -#include "common/versions.h" +#include "common/versions/versions.h" #include "third-party/json.hpp" diff --git a/tools/dgo_unpacker.cpp b/tools/dgo_unpacker.cpp index ff8b45ae4..fc01c2f86 100644 --- a/tools/dgo_unpacker.cpp +++ b/tools/dgo_unpacker.cpp @@ -4,7 +4,7 @@ #include "common/util/DgoReader.h" #include "common/util/FileUtil.h" #include "common/util/unicode_util.h" -#include "common/versions.h" +#include "common/versions/versions.h" namespace { int run(int argc, char** argv) {