From 2d81f900bee0ce2cf94b41b5131e724cdb419a88 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Wed, 16 Apr 2025 23:44:22 -0400 Subject: [PATCH] Updated to use the latest libgit2 1.9.0 and GCC14. --- Makefile | 4 ++-- builder.cpp | 9 ++++----- game_engine.cpp | 7 +++---- gui.cpp | 3 +-- meson.build | 4 ++-- patches/process.h | 8 ++------ scratchpad/meson.build | 10 +++++----- sfmlbackend.cpp | 7 +++---- watcher.cpp | 4 +++- wraps/libgit2.wrap | 8 ++++---- 10 files changed, 29 insertions(+), 35 deletions(-) diff --git a/Makefile b/Makefile index 23d1527..0c6ab86 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ reset: powershell -executionpolicy bypass .\scripts\reset_build.ps1 patch: - powershell "cp ./patches/process.h ./subprojects/libgit2-1.8.1/src/util/process.h" + powershell "cp ./patches/process.h ./subprojects/libgit2-1.9.0/src/util/process.h" build: patch meson compile -j 4 -C builddir @@ -17,7 +17,7 @@ test: build # make an install for real maybe copy dll and .exe to dir and zip? install: build test - powershell "cp ./builddir/subprojects/libgit2-1.8.1/liblibgit2package.dll ." + powershell "cp ./builddir/subprojects/libgit2-1.9.0/liblibgit2package.dll ." powershell "cp ./builddir/subprojects/efsw/libefsw.dll ." powershell "cp builddir/escape_turings_tarpit.exe ." diff --git a/builder.cpp b/builder.cpp index f670945..c7324c0 100644 --- a/builder.cpp +++ b/builder.cpp @@ -17,7 +17,6 @@ #include "dbc.hpp" using std::string; -using namespace fmt; using namespace nlohmann; using namespace std::chrono_literals; @@ -92,7 +91,7 @@ void Builder::BUILDING(BuildEvent ev) { auto m = parse_line(line); if(m.match) { - gui.output(format("HIT WITH {} @ {}:{}:{} {}", m.type, m.file_name, m.lnumber, m.col, m.message)); + gui.output(fmt::format("HIT WITH {} @ {}:{}:{} {}", m.type, m.file_name, m.lnumber, m.col, m.message)); game.event(GameEvent::HIT, m.type); } state(BuildState::READING); @@ -100,7 +99,7 @@ void Builder::BUILDING(BuildEvent ev) { } void Builder::START(BuildEvent ev) { - gui.output(format("Using build command: {}", build_cmd)); + gui.output(fmt::format("Using build command: {}", build_cmd)); fileWatcher = new efsw::FileWatcher(); dbc::check(fileWatcher != nullptr, "Failed to create filewatcher."); @@ -112,7 +111,7 @@ void Builder::START(BuildEvent ev) { listener = new UpdateListener(repo); dbc::check(listener != nullptr, "Failed to create listener."); - gui.output(format("Watching directory {} for changes...", git_path)); + gui.output(fmt::format("Watching directory {} for changes...", git_path)); wid = fileWatcher->addWatch(git_path, listener, true); fileWatcher->watch(); @@ -123,7 +122,7 @@ void Builder::WAITING(BuildEvent ev) { if(listener->changes) { game.event(GameEvent::BUILD_START); gui.building(); - gui.output(format("CHANGES! Running build {}", build_cmd)); + gui.output(fmt::format("CHANGES! Running build {}", build_cmd)); state(BuildState::FORKING); } } diff --git a/game_engine.cpp b/game_engine.cpp index e3b57ad..be6b885 100644 --- a/game_engine.cpp +++ b/game_engine.cpp @@ -10,7 +10,6 @@ const auto ERROR = fmt::emphasis::bold | fg(fmt::color::red); -using namespace fmt; using namespace std; GameEngine::GameEngine(int hp) : starting_hp(hp) { @@ -21,13 +20,13 @@ int GameEngine::determine_damage(string &type) { try { return damage_types.at(type); } catch(std::out_of_range &err) { - print(ERROR, "BAD DAMAGE TYPE {}\n", type); + fmt::print(ERROR, "BAD DAMAGE TYPE {}\n", type); return 0; } } void GameEngine::reset() { - println("!!!!!!! RESET hit_points={}, max={}", hit_points, max_hp()); + fmt::println("!!!!!!! RESET hit_points={}, max={}", hit_points, max_hp()); if(free_death) { hit_points = max_hp() * 0.5f; } else { @@ -35,7 +34,7 @@ void GameEngine::reset() { hit_points = max_hp(); } - println("!!!!!!!! AFTER RESET hit_points={}, max={}", hit_points, max_hp()); + fmt::println("!!!!!!!! AFTER RESET hit_points={}, max={}", hit_points, max_hp()); free_death = false; } diff --git a/gui.cpp b/gui.cpp index 8f938bb..f235048 100644 --- a/gui.cpp +++ b/gui.cpp @@ -13,7 +13,6 @@ using std::string, std::vector; -using namespace fmt; using namespace nlohmann; namespace fs = std::filesystem; @@ -54,7 +53,7 @@ void GUI::build_failed(bool play_sound, const string &command) { build_failed_sound.play(); } - output(format("!!! BUILD FAILED. Your command correct? '{}'", command)); + output(fmt::format("!!! BUILD FAILED. Your command correct? '{}'", command)); } void GUI::you_died() { diff --git a/meson.build b/meson.build index 01ecd57..962f996 100644 --- a/meson.build +++ b/meson.build @@ -5,7 +5,7 @@ cmake = import('cmake') opts = cmake.subproject_options() opts.add_cmake_defines({ 'USE_ICONV': false, - 'USE_SSH': false, + #'USE_SSH': false, 'USE_NTLMCLIENT': false, 'BUILD_SHARED_LIBS': true, 'BUILD_TESTS': false, @@ -14,7 +14,7 @@ libgit2_proj = cmake.subproject('libgit2', options: opts) libgit2package = libgit2_proj.dependency('libgit2package') efsw = dependency('efsw') -fmt = dependency('fmt') +fmt = subproject('fmt').get_variable('fmt_dep') catch2 = dependency('catch2-with-main') sfml = dependency('sfml') json = dependency('nlohmann_json') diff --git a/patches/process.h b/patches/process.h index 44e009b..0ca2fd3 100644 --- a/patches/process.h +++ b/patches/process.h @@ -8,7 +8,6 @@ #ifndef INCLUDE_process_h__ #define INCLUDE_process_h__ -typedef struct git_str git_str; typedef struct git_process git_process; typedef struct { @@ -113,10 +112,7 @@ extern int git_process__cmdline( * cmdline arguments to ensure that they are not erroneously treated * as an option. For example, arguments to `ssh`. */ -static __inline__ bool git_process__is_cmdline_option(const char *str) -{ - return (str && str[0] == '-'); -} +#define git_process__is_cmdline_option(S) ((S) && (S)[0] == '-') /** * Start the process. @@ -211,7 +207,7 @@ extern int git_process_close(git_process *process); * @param msg the buffer to store the message * @param result the process result that produced an error */ -extern int git_process_result_msg(git_str *msg, git_process_result *result); +extern int git_process_result_msg(struct git_str *msg, git_process_result *result); /** * Free a process structure diff --git a/scratchpad/meson.build b/scratchpad/meson.build index cef6686..fd73b8f 100644 --- a/scratchpad/meson.build +++ b/scratchpad/meson.build @@ -13,8 +13,8 @@ executable('threadtest', 'threadtest.cpp', executable('badref', 'badref.cpp', dependencies: dependencies) -executable('corotest', [ - 'corotest.cpp' - ], - dependencies: dependencies, - cpp_args: '-fcoroutines') +#executable('corotest', [ +# 'corotest.cpp' +# ], +# dependencies: dependencies, +# cpp_args: '-fcoroutines') diff --git a/sfmlbackend.cpp b/sfmlbackend.cpp index 7eff721..3f68e8f 100644 --- a/sfmlbackend.cpp +++ b/sfmlbackend.cpp @@ -14,7 +14,6 @@ #include #include -using namespace fmt; using namespace nlohmann; using std::string; @@ -36,7 +35,7 @@ void SoundQuip::load(json &data, const char *file_key, bool loop) { json::string_t file_name = audio[file_key].template get(); if(!buffer.loadFromFile(file_name)) { - println("Failed to load sound: {} with file {}", file_key, file_name); + fmt::println("Failed to load sound: {} with file {}", file_key, file_name); } sound.setBuffer(buffer); @@ -157,7 +156,7 @@ void SFMLBackend::update_entities() { auto elapsed_time = std::chrono::system_clock::now() - clock_start; - string time = format("{:%H:%M:%OS}", elapsed_time); + string time = fmt::format("{:%H:%M:%OS}", elapsed_time); write_text(7, 14, time, 2.0f); @@ -215,7 +214,7 @@ void SFMLBackend::startup() { fmt::println("Cannot load font."); } - window.setPosition({.x=0,.y=0}); + window.setPosition({0,0}); window.setFramerateLimit(FPS); window.setVerticalSyncEnabled(true); diff --git a/watcher.cpp b/watcher.cpp index 0b9203c..654ba6c 100644 --- a/watcher.cpp +++ b/watcher.cpp @@ -1,5 +1,7 @@ #include "watcher.hpp" #include +#include +#include using std::string; namespace fs = std::filesystem; @@ -10,7 +12,6 @@ void UpdateListener::handleFileAction(efsw::WatchID watchid, efsw::Action action, string oldFilename) { - // this is some gnarly BS here, probably tons // of memory leaks for now but it's working int ignored = 1; @@ -21,6 +22,7 @@ void UpdateListener::handleFileAction(efsw::WatchID watchid, full_path.end(), '\\', '/'); int rc = git_ignore_path_is_ignored(&ignored, repo, full_path.c_str()); + assert(rc == 0 && "libgit2 says it can't check the ignored file"); if(!ignored) { changes = changes || !ignored; diff --git a/wraps/libgit2.wrap b/wraps/libgit2.wrap index 9291d77..ffd5bd1 100644 --- a/wraps/libgit2.wrap +++ b/wraps/libgit2.wrap @@ -1,8 +1,8 @@ [wrap-file] -directory = libgit2-1.8.1 -source_url = https://github.com/libgit2/libgit2/archive/refs/tags/v1.8.1.tar.gz -source_filename = v1.8.1.tar.gz -source_hash = 8c1eaf0cf07cba0e9021920bfba9502140220786ed5d8a8ec6c7ad9174522f8e +directory = libgit2-1.9.0 +source_url = https://github.com/libgit2/libgit2/archive/refs/tags/v1.9.0.tar.gz +source_filename = v1.9.0.tar.gz +source_hash = 75b27d4d6df44bd34e2f70663cfd998f5ec41e680e1e593238bbe517a84c7ed2 wrapdb_version = 2.4.1-3 # patch_filename = # patch_hash =