From 2b0011a1273d1f16a51efb53b2539ddc489c63d8 Mon Sep 17 00:00:00 2001 From: asdlokj1qpi23 Date: Tue, 25 Mar 2025 17:27:28 +0800 Subject: [PATCH] fix windows build error --- .github/workflows/build.yml | 199 ++++++++++++++++++------------- scripts/build.windows.release.sh | 2 +- 2 files changed, 114 insertions(+), 87 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d07c5a6..27de523 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,5 @@ name: GitHub CI -on: +on: push: branches: [ master ] tags: @@ -7,7 +7,7 @@ on: workflow_dispatch: pull_request: -concurrency: +concurrency: group: ${{ github.ref }}-${{ github.workflow }} cancel-in-progress: true @@ -31,29 +31,29 @@ jobs: runs-on: ${{ matrix.os }} name: Linux ${{ matrix.arch }} Build steps: - - name: Checkout base - uses: actions/checkout@v4 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Add commit id into version - if: ${{ !startsWith(github.ref, 'refs/tags/') }} - run: SHA=$(git rev-parse --short HEAD) && sed -i 's/\(v[0-9]\.[0-9]\.[0-9]\)/\1-'"$SHA"'/' src/version.h - - name: Build - run: docker run --rm -v $GITHUB_WORKSPACE:/root/workdir multiarch/alpine:${{ matrix.arch }}-latest-stable /bin/sh -c "apk add bash git nodejs npm && cd /root/workdir && chmod +x scripts/build.alpine.release.sh && bash scripts/build.alpine.release.sh" - - name: Upload - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.artifact }} - path: subconverter/ - - name: Package Release - if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }} - run: tar czf ${{ matrix.artifact }}.tar.gz subconverter - - name: Draft Release - if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }} - uses: softprops/action-gh-release@v2 - with: - files: ${{ matrix.artifact }}.tar.gz - draft: true + - name: Checkout base + uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Add commit id into version + if: ${{ !startsWith(github.ref, 'refs/tags/') }} + run: SHA=$(git rev-parse --short HEAD) && sed -i 's/\(v[0-9]\.[0-9]\.[0-9]\)/\1-'"$SHA"'/' src/version.h + - name: Build + run: docker run --rm -v $GITHUB_WORKSPACE:/root/workdir multiarch/alpine:${{ matrix.arch }}-latest-stable /bin/sh -c "apk add bash git nodejs npm && cd /root/workdir && chmod +x scripts/build.alpine.release.sh && bash scripts/build.alpine.release.sh" + - name: Upload + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.artifact }} + path: subconverter/ + - name: Package Release + if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }} + run: tar czf ${{ matrix.artifact }}.tar.gz subconverter + - name: Draft Release + if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }} + uses: softprops/action-gh-release@v2 + with: + files: ${{ matrix.artifact }}.tar.gz + draft: true macos_build: strategy: @@ -68,31 +68,31 @@ jobs: runs-on: ${{ matrix.os }} name: macOS ${{ matrix.arch }} Build steps: - - name: Checkout base - uses: actions/checkout@v4 - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - name: Add commit id into version - if: ${{ !startsWith(github.ref, 'refs/tags/') }} - run: SHA=$(git rev-parse --short HEAD) && sed -i -e 's/\(v[0-9]\.[0-9]\.[0-9]\)/\1-'"$SHA"'/' src/version.h - - name: Build - run: bash scripts/build.macos.release.sh - - name: Upload - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.artifact }} - path: subconverter/ - - name: Package Release - if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }} - run: tar czf ${{ matrix.artifact }}.tar.gz subconverter - - name: Draft Release - if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }} - uses: softprops/action-gh-release@v2 - with: - files: ${{ matrix.artifact }}.tar.gz - draft: true + - name: Checkout base + uses: actions/checkout@v4 + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Add commit id into version + if: ${{ !startsWith(github.ref, 'refs/tags/') }} + run: SHA=$(git rev-parse --short HEAD) && sed -i -e 's/\(v[0-9]\.[0-9]\.[0-9]\)/\1-'"$SHA"'/' src/version.h + - name: Build + run: bash scripts/build.macos.release.sh + - name: Upload + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.artifact }} + path: subconverter/ + - name: Package Release + if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }} + run: tar czf ${{ matrix.artifact }}.tar.gz subconverter + - name: Draft Release + if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }} + uses: softprops/action-gh-release@v2 + with: + files: ${{ matrix.artifact }}.tar.gz + draft: true windows_build: strategy: @@ -112,39 +112,66 @@ jobs: run: shell: msys2 {0} steps: - - name: Checkout base - uses: actions/checkout@v4 - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: '16' - - name: Setup MSYS2 - uses: msys2/setup-msys2@v2 - with: - update: true - install: base-devel git mingw-w64-${{ matrix.env }}-gcc mingw-w64-${{ matrix.env }}-cmake mingw-w64-${{ matrix.env }}-pcre2 patch - msystem: ${{ matrix.msystem }} - path-type: inherit - - name: Add commit id into version - if: ${{ !startsWith(github.ref, 'refs/tags/') }} - run: SHA=$(git rev-parse --short HEAD) && sed -i 's/\(v[0-9]\.[0-9]\.[0-9]\)/\1-'"$SHA"'/' src/version.h - - name: Build - run: bash scripts/build.windows.release.sh - - name: Upload - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.artifact }} - path: subconverter/ - - name: Package Release - if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }} - run: 7z a ${{ matrix.artifact }}.7z subconverter/ - - name: Draft Release - if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }} - uses: softprops/action-gh-release@v2 - with: - files: ${{ matrix.artifact }}.7z - draft: true + - name: Checkout base + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '16' + + - name: Setup MSYS2 + uses: msys2/setup-msys2@v2 + with: + update: true + install: base-devel git mingw-w64-${{ matrix.env }}-gcc mingw-w64-${{ matrix.env }}-cmake mingw-w64-${{ matrix.env }}-pcre2 patch + msystem: ${{ matrix.msystem }} + path-type: inherit + + - name: Downgrade MinGW-w64 (i686) + if: matrix.env == 'i686' + run: | + pacman -Sy --noconfirm + pacman -U --noconfirm https://repo.msys2.org/mingw/i686/mingw-w64-i686-gcc-13.2.0-1-any.pkg.tar.zst + pacman -U --noconfirm https://repo.msys2.org/mingw/i686/mingw-w64-i686-crt-11.0.0-1-any.pkg.tar.zst + + - name: Check GCC Version + run: gcc --version + + - name: Set Compiler Flags + run: | + echo "CFLAGS=-fcommon -static" >> $GITHUB_ENV + echo "CXXFLAGS=-fcommon -static" >> $GITHUB_ENV + echo "LDFLAGS=-static -static-libgcc -static-libstdc++" >> $GITHUB_ENV + + - name: Remove pkg-config + run: rm -f C:/Strawberry/perl/bin/pkg-config C:/Strawberry/perl/bin/pkg-config.bat /mingw32/bin/pkg-config* + + - name: Add commit id into version + if: ${{ !startsWith(github.ref, 'refs/tags/') }} + run: SHA=$(git rev-parse --short HEAD) && sed -i 's/\(v[0-9]\.[0-9]\.[0-9]\)/\1-'"$SHA"'/' src/version.h + + - name: Build + run: bash scripts/build.windows.release.sh + + - name: Upload + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.artifact }} + path: subconverter/ + + - name: Package Release + if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }} + run: 7z a ${{ matrix.artifact }}.7z subconverter/ + + - name: Draft Release + if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }} + uses: softprops/action-gh-release@v2 + with: + files: ${{ matrix.artifact }}.7z + draft: true diff --git a/scripts/build.windows.release.sh b/scripts/build.windows.release.sh index c085989..423fc43 100644 --- a/scripts/build.windows.release.sh +++ b/scripts/build.windows.release.sh @@ -54,4 +54,4 @@ make -j4 rm subconverter.exe # shellcheck disable=SC2046 g++ $(find CMakeFiles/subconverter.dir/src -name "*.obj") curl/lib/libcurl.a -o base/subconverter.exe -static -lbcrypt -lpcre2-8 -l:quickjs/libquickjs.a -llibcron -lyaml-cpp -liphlpapi -lcrypt32 -lws2_32 -lwsock32 -lz -s -mv base subconverter +mv base subconverter \ No newline at end of file