From 244923903ca9f3e10d9c7caca98cc6488acfd1e9 Mon Sep 17 00:00:00 2001 From: rzlamrr Date: Fri, 6 Mar 2026 20:40:06 +0700 Subject: [PATCH] fix libgit2 --- .github/workflows/windows.yml | 14 +++++- patches/libgit2detect-vcpkg.patch | 81 +++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 patches/libgit2detect-vcpkg.patch diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 00d1456..bd6d316 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -14,6 +14,12 @@ jobs: VCPKG_ROOT: C:\vcpkg steps: + # ── 0. Checkout this build repo (for patches) ──────────────────────── + - name: Checkout fritzing-build + uses: actions/checkout@v4 + with: + path: fritzing-build + # ── 1. Checkout Fritzing source ────────────────────────────────────── - name: Checkout fritzing-app uses: actions/checkout@v4 @@ -27,6 +33,12 @@ jobs: repository: fritzing/fritzing-parts path: fritzing-parts + # ── 1b. Apply build patches ────────────────────────────────────────── + - name: Patch libgit2detect.pri for vcpkg + working-directory: fritzing-app + run: git apply ../fritzing-build/patches/libgit2detect-vcpkg.patch + shell: bash + # ── 2. Setup MSVC 2022 64-bit environment ──────────────────────────── - name: Setup MSVC environment uses: ilammy/msvc-dev-cmd@v1 @@ -52,7 +64,7 @@ jobs: uses: actions/cache@v4 with: path: C:\vcpkg\installed - key: vcpkg-x64-windows-${{ hashFiles('**/build-windows.yml') }} + key: vcpkg-x64-windows-${{ hashFiles('**/windows.yml') }} restore-keys: | vcpkg-x64-windows- diff --git a/patches/libgit2detect-vcpkg.patch b/patches/libgit2detect-vcpkg.patch new file mode 100644 index 0000000..89b0f47 --- /dev/null +++ b/patches/libgit2detect-vcpkg.patch @@ -0,0 +1,81 @@ +--- a/pri/libgit2detect.pri ++++ b/pri/libgit2detect.pri +@@ -28,30 +28,51 @@ + } + + + win32 { +- if ($$LIBGIT_STATIC) { +- LIBGIT2INCLUDE = "$$_PRO_FILE_PWD_/../libgit2/include" ++ # If LIBGIT2_PATH is passed on the qmake command line (e.g. from vcpkg), ++ # use its standard include/ and lib/ layout. Otherwise fall back to the ++ # legacy ../libgit2 sibling-directory layout. ++ !isEmpty(LIBGIT2_PATH) { ++ LIBGIT2INCLUDE = "$$LIBGIT2_PATH/include" ++ LIBGIT2LIB = "$$LIBGIT2_PATH/lib" + + exists($$LIBGIT2INCLUDE/git2.h) { +- message("found libgit2 include path at $$LIBGIT2INCLUDE") +- } else { +- message("Fritzing requires libgit2") +- message("Build it from the repo at https://github.com/libgit2") +- message("See https://github.com/fritzing/fritzing-app/wiki for details.") +- +- error("libgit2 include path not found in $$LIBGIT2INCLUDE") +- } +- } +- +- contains(QMAKE_TARGET.arch, x86_64) { +- LIBGIT2LIB = "$$_PRO_FILE_PWD_/../libgit2/build64/Release" +- } else { +- LIBGIT2LIB = "$$_PRO_FILE_PWD_/../libgit2/build32/Release" +- } +- +- exists($$LIBGIT2LIB/git2.lib) { +- message("found libgit2 library in $$LIBGIT2LIB") +- } else { +- error("libgit2 library not found in $$LIBGIT2LIB") +- } ++ message("found libgit2 include path at $$LIBGIT2INCLUDE (from LIBGIT2_PATH)") ++ } else { ++ error("libgit2 include path not found in $$LIBGIT2INCLUDE (LIBGIT2_PATH was set)") ++ } ++ ++ exists($$LIBGIT2LIB/git2.lib) { ++ message("found libgit2 library in $$LIBGIT2LIB (from LIBGIT2_PATH)") ++ } else { ++ error("libgit2 library not found in $$LIBGIT2LIB (LIBGIT2_PATH was set)") ++ } ++ } else { ++ # Legacy layout: ../libgit2/include + ../libgit2/build{32,64}/Release ++ if ($$LIBGIT_STATIC) { ++ LIBGIT2INCLUDE = "$$_PRO_FILE_PWD_/../libgit2/include" ++ ++ exists($$LIBGIT2INCLUDE/git2.h) { ++ message("found libgit2 include path at $$LIBGIT2INCLUDE") ++ } else { ++ message("Fritzing requires libgit2") ++ message("Build it from the repo at https://github.com/libgit2") ++ message("See https://github.com/fritzing/fritzing-app/wiki for details.") ++ ++ error("libgit2 include path not found in $$LIBGIT2INCLUDE") ++ } ++ } ++ ++ contains(QMAKE_TARGET.arch, x86_64) { ++ LIBGIT2LIB = "$$_PRO_FILE_PWD_/../libgit2/build64/Release" ++ } else { ++ LIBGIT2LIB = "$$_PRO_FILE_PWD_/../libgit2/build32/Release" ++ } ++ ++ exists($$LIBGIT2LIB/git2.lib) { ++ message("found libgit2 library in $$LIBGIT2LIB") ++ } else { ++ error("libgit2 library not found in $$LIBGIT2LIB") ++ } ++ } + + INCLUDEPATH += $$LIBGIT2INCLUDE +- LIBS += -L$$LIBGIT2LIB -lgit2 ++ LIBS += -L$$LIBGIT2LIB -lgit2 + }