fix windows build error

This commit is contained in:
asdlokj1qpi23
2025-03-25 17:27:28 +08:00
parent f69597efb7
commit 2b0011a127
2 changed files with 114 additions and 87 deletions

View File

@@ -1,5 +1,5 @@
name: GitHub CI name: GitHub CI
on: on:
push: push:
branches: [ master ] branches: [ master ]
tags: tags:
@@ -7,7 +7,7 @@ on:
workflow_dispatch: workflow_dispatch:
pull_request: pull_request:
concurrency: concurrency:
group: ${{ github.ref }}-${{ github.workflow }} group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true cancel-in-progress: true
@@ -31,29 +31,29 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
name: Linux ${{ matrix.arch }} Build name: Linux ${{ matrix.arch }} Build
steps: steps:
- name: Checkout base - name: Checkout base
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
- name: Add commit id into version - name: Add commit id into version
if: ${{ !startsWith(github.ref, 'refs/tags/') }} 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 run: SHA=$(git rev-parse --short HEAD) && sed -i 's/\(v[0-9]\.[0-9]\.[0-9]\)/\1-'"$SHA"'/' src/version.h
- name: Build - 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" 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 - name: Upload
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: ${{ matrix.artifact }} name: ${{ matrix.artifact }}
path: subconverter/ path: subconverter/
- name: Package Release - name: Package Release
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }} if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
run: tar czf ${{ matrix.artifact }}.tar.gz subconverter run: tar czf ${{ matrix.artifact }}.tar.gz subconverter
- name: Draft Release - name: Draft Release
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }} if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
uses: softprops/action-gh-release@v2 uses: softprops/action-gh-release@v2
with: with:
files: ${{ matrix.artifact }}.tar.gz files: ${{ matrix.artifact }}.tar.gz
draft: true draft: true
macos_build: macos_build:
strategy: strategy:
@@ -68,31 +68,31 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
name: macOS ${{ matrix.arch }} Build name: macOS ${{ matrix.arch }} Build
steps: steps:
- name: Checkout base - name: Checkout base
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup Python - name: Setup Python
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: '3.11' python-version: '3.11'
- name: Add commit id into version - name: Add commit id into version
if: ${{ !startsWith(github.ref, 'refs/tags/') }} 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 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 - name: Build
run: bash scripts/build.macos.release.sh run: bash scripts/build.macos.release.sh
- name: Upload - name: Upload
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: ${{ matrix.artifact }} name: ${{ matrix.artifact }}
path: subconverter/ path: subconverter/
- name: Package Release - name: Package Release
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }} if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
run: tar czf ${{ matrix.artifact }}.tar.gz subconverter run: tar czf ${{ matrix.artifact }}.tar.gz subconverter
- name: Draft Release - name: Draft Release
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }} if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
uses: softprops/action-gh-release@v2 uses: softprops/action-gh-release@v2
with: with:
files: ${{ matrix.artifact }}.tar.gz files: ${{ matrix.artifact }}.tar.gz
draft: true draft: true
windows_build: windows_build:
strategy: strategy:
@@ -112,39 +112,66 @@ jobs:
run: run:
shell: msys2 {0} shell: msys2 {0}
steps: steps:
- name: Checkout base - name: Checkout base
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5 - name: Setup Python
with: uses: actions/setup-python@v5
python-version: '3.11' with:
- name: Setup Node.js python-version: '3.11'
uses: actions/setup-node@v4
with: - name: Setup Node.js
node-version: '16' uses: actions/setup-node@v4
- name: Setup MSYS2 with:
uses: msys2/setup-msys2@v2 node-version: '16'
with:
update: true - name: Setup MSYS2
install: base-devel git mingw-w64-${{ matrix.env }}-gcc mingw-w64-${{ matrix.env }}-cmake mingw-w64-${{ matrix.env }}-pcre2 patch uses: msys2/setup-msys2@v2
msystem: ${{ matrix.msystem }} with:
path-type: inherit update: true
- name: Add commit id into version install: base-devel git mingw-w64-${{ matrix.env }}-gcc mingw-w64-${{ matrix.env }}-cmake mingw-w64-${{ matrix.env }}-pcre2 patch
if: ${{ !startsWith(github.ref, 'refs/tags/') }} msystem: ${{ matrix.msystem }}
run: SHA=$(git rev-parse --short HEAD) && sed -i 's/\(v[0-9]\.[0-9]\.[0-9]\)/\1-'"$SHA"'/' src/version.h path-type: inherit
- name: Build
run: bash scripts/build.windows.release.sh - name: Downgrade MinGW-w64 (i686)
- name: Upload if: matrix.env == 'i686'
uses: actions/upload-artifact@v4 run: |
with: pacman -Sy --noconfirm
name: ${{ matrix.artifact }} pacman -U --noconfirm https://repo.msys2.org/mingw/i686/mingw-w64-i686-gcc-13.2.0-1-any.pkg.tar.zst
path: subconverter/ pacman -U --noconfirm https://repo.msys2.org/mingw/i686/mingw-w64-i686-crt-11.0.0-1-any.pkg.tar.zst
- name: Package Release
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }} - name: Check GCC Version
run: 7z a ${{ matrix.artifact }}.7z subconverter/ run: gcc --version
- name: Draft Release
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }} - name: Set Compiler Flags
uses: softprops/action-gh-release@v2 run: |
with: echo "CFLAGS=-fcommon -static" >> $GITHUB_ENV
files: ${{ matrix.artifact }}.7z echo "CXXFLAGS=-fcommon -static" >> $GITHUB_ENV
draft: true 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

View File

@@ -54,4 +54,4 @@ make -j4
rm subconverter.exe rm subconverter.exe
# shellcheck disable=SC2046 # 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 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