Skip to content

Commit

Permalink
ci: mingw64 build static link depency
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonflylee committed Sep 22, 2023
1 parent e486c01 commit d18391c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 28 deletions.
59 changes: 32 additions & 27 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,52 +116,57 @@ jobs:
build-win-x64:
needs: [ version ]
runs-on: windows-2022
env:
MSYSTEM: MINGW64
defaults:
run:
shell: C:\shells\msys2bash.cmd {0}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0

- name: Install dependency
run: |
pacman -S --noconfirm --noprogressbar mingw-w64-x86_64-gcc mingw-w64-x86_64-make mingw-w64-x86_64-cmake git p7zip
curl -Lo /tmp/mpv.7z https://master.dl.sourceforge.net/project/mpv-player-windows/libmpv/mpv-dev-x86_64-20230806-git-6729285.7z
7z x /tmp/mpv.7z -o/mingw64/
mv /mingw64/libmpv.dll.a /mingw64/lib/
rm /mingw64/lib/libz.dll.a /mingw64/lib/libcurl.dll.a
- name: Update gamepad db
run: |
cmake -P library/borealis/library/lib/extern/glfw//CMake/GenerateMappings.cmake library/borealis/library/lib/extern/glfw//src/mappings.h.in library/borealis/library/lib/extern/glfw//src/mappings.h
- name: Install dependency
uses: msys2/setup-msys2@v2
with:
# update: true
install: >-
mingw-w64-x86_64-gcc
mingw-w64-x86_64-cmake
mingw-w64-x86_64-make
mingw-w64-x86_64-mpv
mingw-w64-x86_64-libwebp
git
p7zip
cmake -P library/borealis/library/lib/extern/glfw/CMake/GenerateMappings.cmake library/borealis/library/lib/extern/glfw/src/mappings.h.in library/borealis/library/lib/extern/glfw/src/mappings.h
- name: Build dependency
run: |
curl -sL https://github.com/webmproject/libwebp/archive/v1.3.1.tar.gz | tar zxf - -C /tmp
cd /tmp/libwebp-1.3.1
cmake -B build -G 'MinGW Makefiles' -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/mingw64 -DBUILD_SHARED_LIBS=OFF \
-DWEBP_BUILD_ANIM_UTILS=OFF -DWEBP_BUILD_CWEBP=OFF -DWEBP_BUILD_DWEBP=OFF -DWEBP_BUILD_GIF2WEBP=OFF \
-DWEBP_BUILD_IMG2WEBP=OFF -DWEBP_BUILD_VWEBP=OFF -DWEBP_BUILD_WEBPINFO=OFF -DWEBP_BUILD_WEBPMUX=OFF \
-DWEBP_BUILD_LIBWEBPMUX=OFF -DWEBP_BUILD_EXTRAS=OFF
mingw32-make -C build -j4 install
curl -sL https://github.com/curl/curl/releases/download/curl-7_88_1/curl-7.88.1.tar.xz | tar Jxf - -C /tmp
cd /tmp/curl-7.88.1
cmake -B build -G 'MinGW Makefiles' -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/mingw64 \
-DCURL_USE_SCHANNEL=ON -DBUILD_SHARED_LIBS=OFF -DHTTP_ONLY=ON -DCURL_DISABLE_PROGRESS_METER=OFF \
-DBUILD_CURL_EXE=OFF -DBUILD_TESTING=OFF -DUSE_LIBIDN2=OFF -DCURL_USE_LIBSSH2=OFF -DCURL_USE_LIBPSL=OFF
mingw32-make -C build -j4 install
- name: Build
shell: msys2 {0}
id: compile
run: |
mkdir -p build && pushd build
cmake .. -G "MinGW Makefiles" -DPLATFORM_DESKTOP=ON -DWIN32_TERMINAL=OFF -DCMAKE_BUILD_TYPE=Release
cmake .. -G "MinGW Makefiles" -DPLATFORM_DESKTOP=ON -DWIN32_TERMINAL=OFF -DUSE_SYSTEM_CURL=ON -DCMAKE_BUILD_TYPE=Release
mingw32-make wiliwili -j4
strip wiliwili.exe
mkdir wiliwili && mv wiliwili.exe wiliwili && mv resources wiliwili
for i in {libwinpthread-1,libgcc_s_seh-1,zlib1,libssh2-1,libstdc++-6,libcrypto-3-x64,libwebp-7,libsharpyuv-0}; do
cp /mingw64/bin/${i}.dll wiliwili
done
wget https://github.com/xfangfang/wiliwili/releases/download/v0.1.0/mpv-dev-x86_64-20221204-git-4574dd5.7z -O mpv.7z
7z e mpv.7z -ompv
cp mpv/mpv-2.dll wiliwili/libmpv-2.dll
tar -czvf ../${{ needs.version.outputs.DIST_EXE }}.tar.gz wiliwili
7z a -mx=9 ../${{ needs.version.outputs.DIST_EXE }}.7z wiliwili.exe resources /mingw64/libmpv-2.dll
- name: Upload dist
uses: actions/upload-artifact@v3
with:
name: ${{ needs.version.outputs.DIST_EXE }}
path: "${{ needs.version.outputs.DIST_EXE }}.tar.gz"
path: "${{ needs.version.outputs.DIST_EXE }}.7z"

build-win-uwp:
needs: [ version ]
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ if (PLATFORM_DESKTOP)
list(APPEND APP_PLATFORM_INCLUDE ${WebP_INCLUDE_DIRS})
list(APPEND APP_PLATFORM_LIB ${WebP_LIBRARY})
endif ()

if (MINGW)
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static" CACHE STRING "" FORCE)
endif ()
elseif (APP_PLATFORM_CUSTOM_LIBS)
message(STATUS "Using custom libraries for mpv and webp")
# If you want to manually specify dependencies:
Expand Down
1 change: 0 additions & 1 deletion library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ else ()
set(CPR_ENABLE_SSL ON)
if (PLATFORM_DESKTOP)
if (WIN32)
set(CPR_USE_SYSTEM_CURL OFF)
set(CPR_FORCE_WINSSL_BACKEND ON)
endif ()
elseif (PLATFORM_IOS)
Expand Down

0 comments on commit d18391c

Please sign in to comment.