From accbee3c6e76bd7dd5b88d6a6b342a94d6b4e659 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Fri, 12 Sep 2025 07:17:42 -0700 Subject: [PATCH] Move git stuff to kicommon to fix build And do other cool stuff --- common/CMakeLists.txt | 45 ++++++++++++---------- common/git/git_add_to_index_handler.h | 3 +- common/git/git_backend.h | 7 ++-- common/git/git_branch_handler.h | 3 +- common/git/git_clone_handler.h | 3 +- common/git/git_commit_handler.h | 3 +- common/git/git_config_handler.h | 3 +- common/git/git_init_handler.h | 3 +- common/git/git_progress.h | 3 +- common/git/git_pull_handler.h | 3 +- common/git/git_push_handler.h | 3 +- common/git/git_remove_from_index_handler.h | 3 +- common/git/git_repo_mixin.h | 3 +- common/git/git_resolve_conflict_handler.h | 3 +- common/git/git_revert_handler.h | 3 +- common/git/git_status_handler.h | 3 +- common/git/git_sync_handler.h | 3 +- common/git/kicad_git_blob_reader.h | 5 ++- common/git/kicad_git_common.h | 29 +++++++------- common/git/kicad_git_errors.h | 2 +- common/git/libgit_backend.h | 3 +- common/git/project_git_utils.h | 3 +- 22 files changed, 81 insertions(+), 58 deletions(-) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 1c7a1ea444..7faab9f847 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -67,6 +67,30 @@ set( KICOMMON_SRCS # Gal gal/color4d.cpp gal/opengl/gl_context_mgr.cpp + + # Git + git/git_add_to_index_handler.cpp + git/git_branch_handler.cpp + git/git_clone_handler.cpp + git/git_commit_handler.cpp + git/git_config_handler.cpp + git/git_compare_handler.cpp + git/git_init_handler.cpp + git/project_git_utils.cpp + git/git_pull_handler.cpp + git/git_push_handler.cpp + git/git_remove_from_index_handler.cpp + git/git_remove_vcs_handler.cpp + git/git_resolve_conflict_handler.cpp + git/git_revert_handler.cpp + git/git_status_handler.cpp + git/git_switch_branch_handler.cpp + git/git_sync_handler.cpp + git/kicad_git_common.cpp + git/kicad_git_errors.cpp + git/git_backend.cpp + git/libgit_backend.cpp + # Jobs jobs/job.cpp jobs/job_dispatcher.cpp @@ -616,26 +640,6 @@ set( COMMON_IMPORT_GFX_SRCS import_gfx/svg_import_plugin.cpp ) -set( COMMON_GIT_SRCS - git/git_add_to_index_handler.cpp - git/git_branch_handler.cpp - git/git_clone_handler.cpp - git/git_commit_handler.cpp - git/git_config_handler.cpp - git/git_init_handler.cpp - git/git_pull_handler.cpp - git/git_push_handler.cpp - git/git_remove_from_index_handler.cpp - git/git_resolve_conflict_handler.cpp - git/git_revert_handler.cpp - git/git_status_handler.cpp - git/git_sync_handler.cpp - git/project_git_utils.cpp - git/kicad_git_common.cpp - git/kicad_git_errors.cpp - git/git_backend.cpp - git/libgit_backend.cpp - ) set( COMMON_SRCS ${LIB_KICAD_SRCS} @@ -648,7 +652,6 @@ set( COMMON_SRCS ${COMMON_IO_SRCS} ${FONT_SRCS} ${COMMON_IMPORT_GFX_SRCS} - ${COMMON_GIT_SRCS} ${COMMON_TRANSLINE_CALCULATION_SRCS} base_screen.cpp bin_mod.cpp diff --git a/common/git/git_add_to_index_handler.h b/common/git/git_add_to_index_handler.h index 09fe901f21..4a010fad05 100644 --- a/common/git/git_add_to_index_handler.h +++ b/common/git/git_add_to_index_handler.h @@ -25,12 +25,13 @@ #define GIT_ADD_TO_INDEX_HANDLER_H_ #include +#include #include #include class LIBGIT_BACKEND; -class GIT_ADD_TO_INDEX_HANDLER : public KIGIT_COMMON +class APIEXPORT GIT_ADD_TO_INDEX_HANDLER : public KIGIT_COMMON { public: GIT_ADD_TO_INDEX_HANDLER( git_repository* aRepository ); diff --git a/common/git/git_backend.h b/common/git/git_backend.h index 3df3101330..6651cb924e 100644 --- a/common/git/git_backend.h +++ b/common/git/git_backend.h @@ -25,6 +25,7 @@ #define GIT_BACKEND_H_ #include +#include #include #include #include @@ -56,7 +57,7 @@ enum class CommitResult Cancelled }; -class GIT_BACKEND +class APIEXPORT GIT_BACKEND { public: virtual ~GIT_BACKEND() = default; @@ -121,7 +122,7 @@ public: virtual void PerformRemoveFromIndex( GIT_REMOVE_FROM_INDEX_HANDLER* aHandler ) = 0; }; -GIT_BACKEND* GetGitBackend(); -void SetGitBackend( GIT_BACKEND* aBackend ); +APIEXPORT GIT_BACKEND* GetGitBackend(); +APIEXPORT void SetGitBackend( GIT_BACKEND* aBackend ); #endif diff --git a/common/git/git_branch_handler.h b/common/git/git_branch_handler.h index d12e752c57..8156995bcb 100644 --- a/common/git/git_branch_handler.h +++ b/common/git/git_branch_handler.h @@ -25,6 +25,7 @@ #define GIT_BRANCH_HANDLER_H #include +#include #include #include @@ -36,7 +37,7 @@ enum class BranchResult Error }; -class GIT_BRANCH_HANDLER : public KIGIT_REPO_MIXIN +class APIEXPORT GIT_BRANCH_HANDLER : public KIGIT_REPO_MIXIN { public: GIT_BRANCH_HANDLER( KIGIT_COMMON* aCommon ); diff --git a/common/git/git_clone_handler.h b/common/git/git_clone_handler.h index 61bb18e232..1e3d258ca0 100644 --- a/common/git/git_clone_handler.h +++ b/common/git/git_clone_handler.h @@ -25,10 +25,11 @@ #define GIT_CLONE_HANDLER_H_ #include "kicad_git_common.h" +#include #include "git_repo_mixin.h" #include "git_progress.h" -class GIT_CLONE_HANDLER : public KIGIT_REPO_MIXIN +class APIEXPORT GIT_CLONE_HANDLER : public KIGIT_REPO_MIXIN { public: GIT_CLONE_HANDLER( KIGIT_COMMON* aCommon ); diff --git a/common/git/git_commit_handler.h b/common/git/git_commit_handler.h index fd8f87eb41..ca5f39a2bf 100644 --- a/common/git/git_commit_handler.h +++ b/common/git/git_commit_handler.h @@ -27,6 +27,7 @@ // Define a class to handle git commit operations #include +#include #include "git_backend.h" #include @@ -35,7 +36,7 @@ class LIBGIT_BACKEND; -class GIT_COMMIT_HANDLER : public KIGIT_COMMON +class APIEXPORT GIT_COMMIT_HANDLER : public KIGIT_COMMON { public: GIT_COMMIT_HANDLER( git_repository* aRepo ); diff --git a/common/git/git_config_handler.h b/common/git/git_config_handler.h index d23857c7bf..e5ef1bc3c0 100644 --- a/common/git/git_config_handler.h +++ b/common/git/git_config_handler.h @@ -25,6 +25,7 @@ #define GIT_CONFIG_HANDLER_H #include +#include #include struct GitUserConfig @@ -35,7 +36,7 @@ struct GitUserConfig bool hasEmail = false; }; -class GIT_CONFIG_HANDLER : public KIGIT_REPO_MIXIN +class APIEXPORT GIT_CONFIG_HANDLER : public KIGIT_REPO_MIXIN { public: GIT_CONFIG_HANDLER( KIGIT_COMMON* aCommon ); diff --git a/common/git/git_init_handler.h b/common/git/git_init_handler.h index 14fb0e6909..94baf83d3d 100644 --- a/common/git/git_init_handler.h +++ b/common/git/git_init_handler.h @@ -25,6 +25,7 @@ #define GIT_INIT_HANDLER_H #include +#include #include enum class InitResult @@ -43,7 +44,7 @@ struct RemoteConfig KIGIT_COMMON::GIT_CONN_TYPE connType; }; -class GIT_INIT_HANDLER : public KIGIT_REPO_MIXIN +class APIEXPORT GIT_INIT_HANDLER : public KIGIT_REPO_MIXIN { public: GIT_INIT_HANDLER( KIGIT_COMMON* aCommon ); diff --git a/common/git/git_progress.h b/common/git/git_progress.h index 27239a2f24..cd84b639b6 100644 --- a/common/git/git_progress.h +++ b/common/git/git_progress.h @@ -25,10 +25,11 @@ #define GIT_PROGRESS_H_ #include +#include #include -class GIT_PROGRESS +class APIEXPORT GIT_PROGRESS { public: GIT_PROGRESS() : diff --git a/common/git/git_pull_handler.h b/common/git/git_pull_handler.h index 7f95155f00..144c5bdcd5 100644 --- a/common/git/git_pull_handler.h +++ b/common/git/git_pull_handler.h @@ -25,6 +25,7 @@ #define _GIT_PULL_HANDLER_H_ #include +#include #include #include @@ -51,7 +52,7 @@ enum class PullResult : int class LIBGIT_BACKEND; -class GIT_PULL_HANDLER : public KIGIT_REPO_MIXIN +class APIEXPORT GIT_PULL_HANDLER : public KIGIT_REPO_MIXIN { public: friend class LIBGIT_BACKEND; diff --git a/common/git/git_push_handler.h b/common/git/git_push_handler.h index d540ba2845..0c8bf1f486 100644 --- a/common/git/git_push_handler.h +++ b/common/git/git_push_handler.h @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -37,7 +38,7 @@ enum class PushResult Error }; -class GIT_PUSH_HANDLER : public KIGIT_REPO_MIXIN +class APIEXPORT GIT_PUSH_HANDLER : public KIGIT_REPO_MIXIN { public: GIT_PUSH_HANDLER( KIGIT_COMMON* aCommon ); diff --git a/common/git/git_remove_from_index_handler.h b/common/git/git_remove_from_index_handler.h index 53a60108ef..1ce7046745 100644 --- a/common/git/git_remove_from_index_handler.h +++ b/common/git/git_remove_from_index_handler.h @@ -25,12 +25,13 @@ #define GIT_REMOVE_FROM_INDEX_HANDLER_H_ #include +#include #include #include class LIBGIT_BACKEND; -class GIT_REMOVE_FROM_INDEX_HANDLER : public KIGIT_COMMON +class APIEXPORT GIT_REMOVE_FROM_INDEX_HANDLER : public KIGIT_COMMON { public: GIT_REMOVE_FROM_INDEX_HANDLER( git_repository* aRepository ); diff --git a/common/git/git_repo_mixin.h b/common/git/git_repo_mixin.h index f86d841ac6..583b627eb1 100644 --- a/common/git/git_repo_mixin.h +++ b/common/git/git_repo_mixin.h @@ -17,8 +17,9 @@ #include "kicad_git_common.h" #include "kicad_git_errors.h" #include "git_progress.h" +#include -class KIGIT_REPO_MIXIN: public KIGIT_ERRORS, public GIT_PROGRESS +class APIEXPORT KIGIT_REPO_MIXIN: public KIGIT_ERRORS, public GIT_PROGRESS { public: KIGIT_REPO_MIXIN( KIGIT_COMMON* aCommon ) : m_common( aCommon ) diff --git a/common/git/git_resolve_conflict_handler.h b/common/git/git_resolve_conflict_handler.h index 37680849de..9269f39172 100644 --- a/common/git/git_resolve_conflict_handler.h +++ b/common/git/git_resolve_conflict_handler.h @@ -25,10 +25,11 @@ #define GIT_RESOLVE_CONFLICT_HANDLER_H #include +#include class wxString; -class GIT_RESOLVE_CONFLICT_HANDLER +class APIEXPORT GIT_RESOLVE_CONFLICT_HANDLER { public: GIT_RESOLVE_CONFLICT_HANDLER( git_repository* aRepository ); diff --git a/common/git/git_revert_handler.h b/common/git/git_revert_handler.h index a697647a09..78b414895c 100644 --- a/common/git/git_revert_handler.h +++ b/common/git/git_revert_handler.h @@ -25,6 +25,7 @@ #define GIT_REVERT_HANDLER_H_ #include +#include #include #include // TEMPORARY HACKFIX INCLUDE FOR STD::VECTOR EXPORT OUT OF KICOMMON ON WINDOWS @@ -32,7 +33,7 @@ class LIBGIT_BACKEND; -class GIT_REVERT_HANDLER +class APIEXPORT GIT_REVERT_HANDLER { public: GIT_REVERT_HANDLER( git_repository* aRepository ); diff --git a/common/git/git_status_handler.h b/common/git/git_status_handler.h index 8aac4cbbf7..807da8ec61 100644 --- a/common/git/git_status_handler.h +++ b/common/git/git_status_handler.h @@ -25,6 +25,7 @@ #define GIT_STATUS_HANDLER_H #include +#include #include #include #include @@ -38,7 +39,7 @@ struct FileStatus unsigned int gitStatus; // Raw git status flags }; -class GIT_STATUS_HANDLER : public KIGIT_REPO_MIXIN +class APIEXPORT GIT_STATUS_HANDLER : public KIGIT_REPO_MIXIN { public: GIT_STATUS_HANDLER( KIGIT_COMMON* aCommon ); diff --git a/common/git/git_sync_handler.h b/common/git/git_sync_handler.h index 45aa891679..4a95a12b62 100644 --- a/common/git/git_sync_handler.h +++ b/common/git/git_sync_handler.h @@ -25,10 +25,11 @@ #define GIT_SYNC_HANDLER_H_ #include +#include class wxString; -class GIT_SYNC_HANDLER +class APIEXPORT GIT_SYNC_HANDLER { public: GIT_SYNC_HANDLER( git_repository* aRepository ); diff --git a/common/git/kicad_git_blob_reader.h b/common/git/kicad_git_blob_reader.h index 599cb0a7b0..a4c9a93ba7 100644 --- a/common/git/kicad_git_blob_reader.h +++ b/common/git/kicad_git_blob_reader.h @@ -25,11 +25,12 @@ #include #include #include +#include #include -class BLOB_BUFFER_STREAM : public std::streambuf +class APIEXPORT BLOB_BUFFER_STREAM : public std::streambuf { public: BLOB_BUFFER_STREAM( git_blob* aBlob ) @@ -57,7 +58,7 @@ public: }; // Build a class that implements LINE_READER for git_blobs -class BLOB_READER : public LINE_READER +class APIEXPORT BLOB_READER : public LINE_READER { public: BLOB_READER( git_blob* aBlob ) : m_blob( aBlob ) diff --git a/common/git/kicad_git_common.h b/common/git/kicad_git_common.h index d6d5bf4c7d..48a058ecb1 100644 --- a/common/git/kicad_git_common.h +++ b/common/git/kicad_git_common.h @@ -25,6 +25,7 @@ #define _GIT_COMMON_H_ #include +#include #include #include @@ -35,7 +36,7 @@ class LIBGIT_BACKEND; -class KIGIT_COMMON +class APIEXPORT KIGIT_COMMON { public: @@ -193,19 +194,19 @@ private: static const unsigned KIGIT_CREDENTIAL_SSH_AGENT = 1 << sizeof( m_testedTypes - 1 ); }; -extern "C" int progress_cb( const char* str, int len, void* data ); -extern "C" void clone_progress_cb( const char* str, size_t len, size_t total, void* data ); -extern "C" int transfer_progress_cb( const git_transfer_progress* aStats, void* aPayload ); -extern "C" int update_cb( const char* aRefname, const git_oid* aFirst, const git_oid* aSecond, - void* aPayload ); -extern "C" int push_transfer_progress_cb( unsigned int aCurrent, unsigned int aTotal, - size_t aBytes, void* aPayload ); -extern "C" int push_update_reference_cb( const char* aRefname, const char* aStatus, - void* aPayload ); +extern "C" APIEXPORT int progress_cb( const char* str, int len, void* data ); +extern "C" APIEXPORT void clone_progress_cb( const char* str, size_t len, size_t total, void* data ); +extern "C" APIEXPORT int transfer_progress_cb( const git_transfer_progress* aStats, void* aPayload ); +extern "C" APIEXPORT int update_cb( const char* aRefname, const git_oid* aFirst, const git_oid* aSecond, + void* aPayload ); +extern "C" APIEXPORT int push_transfer_progress_cb( unsigned int aCurrent, unsigned int aTotal, + size_t aBytes, void* aPayload ); +extern "C" APIEXPORT int push_update_reference_cb( const char* aRefname, const char* aStatus, + void* aPayload ); -extern "C" int fetchhead_foreach_cb( const char*, const char*, - const git_oid* aOID, unsigned int aIsMerge, void* aPayload ); -extern "C" int credentials_cb( git_cred** aOut, const char* aUrl, const char* aUsername, - unsigned int aAllowedTypes, void* aPayload ); +extern "C" APIEXPORT int fetchhead_foreach_cb( const char*, const char*, + const git_oid* aOID, unsigned int aIsMerge, void* aPayload ); +extern "C" APIEXPORT int credentials_cb( git_cred** aOut, const char* aUrl, const char* aUsername, + unsigned int aAllowedTypes, void* aPayload ); #endif // _GIT_COMMON_H_ diff --git a/common/git/kicad_git_errors.h b/common/git/kicad_git_errors.h index f6e5e61d44..cecc6200cf 100644 --- a/common/git/kicad_git_errors.h +++ b/common/git/kicad_git_errors.h @@ -28,7 +28,7 @@ #include -class KIGIT_ERRORS +class APIEXPORT KIGIT_ERRORS { public: diff --git a/common/git/libgit_backend.h b/common/git/libgit_backend.h index 350e0e1b56..5300e17fa3 100644 --- a/common/git/libgit_backend.h +++ b/common/git/libgit_backend.h @@ -25,11 +25,12 @@ #define LIBGIT_BACKEND_H_ #include "git_backend.h" +#include // Forward declarations to avoid exposing libgit2 headers struct git_annotated_commit; -class LIBGIT_BACKEND : public GIT_BACKEND +class APIEXPORT LIBGIT_BACKEND : public GIT_BACKEND { public: void Init() override; diff --git a/common/git/project_git_utils.h b/common/git/project_git_utils.h index 2905477d75..88844455e0 100644 --- a/common/git/project_git_utils.h +++ b/common/git/project_git_utils.h @@ -26,12 +26,13 @@ #include #include +#include namespace KIGIT { /** Utility class with helper functions for project level git operations. */ -class PROJECT_GIT_UTILS +class APIEXPORT PROJECT_GIT_UTILS { public: /**