Static linking on Windows (#385)

* Static linking on Windows

* build Qt static with actions

---------

Co-authored-by: Nova <mahdi.zrei@gmail.com>
This commit is contained in:
parhelia512 2025-04-24 01:39:49 -04:00 committed by GitHub
parent 5c4ef35b48
commit 4798208f40
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 31 additions and 13 deletions

View File

@ -75,7 +75,6 @@ jobs:
- platform: windows-latest
qt_version: "6.9.0"
target: amd64
qt_arch: win64_mingw
- platform: ubuntu-22.04
qt_version: "6.9.0"
target: amd64
@ -97,23 +96,34 @@ jobs:
- name: Install mingw
if: matrix.platform == 'windows-latest'
uses: bwoodsend/setup-winlibs-action@v1.15
- name: Install ninja-build tool
uses: seanmiddleditch/gha-setup-ninja@v5
- name: Download Artifacts
uses: actions/download-artifact@v4.1.8
with:
path: download-artifact
# ========================================================================================================= Qt Install
- name: Qt static Cache
id: cache-static-Qt
if: matrix.platform == 'windows-latest'
uses: actions/cache@v4.2.0
with:
path: qt6/build
key: QtStaticCache-${{ matrix.platform }}-${{ matrix.target }}-Qt${{ matrix.qt_version }}
- name: Install Qt Windows
shell: powershell
if: matrix.platform == 'windows-latest' && steps.cache-static-Qt.outputs.cache-hit != 'true'
run: ./script/build_qt_static_windows.bat ${{ matrix.qt_version }}
- name: Install Qt
uses: jurplel/install-qt-action@v4.1.1
if: matrix.platform != 'windows-latest'
with:
arch: ${{ matrix.qt_arch }}
version: ${{ matrix.qt_version }}
setup-python: true
cache: true
cache-key-prefix: QtCache-${{ matrix.platform }}-${{ matrix.target }}
# ========================================================================================================= Install Ninja and Build deps
- name: Install ninja-build tool
uses: seanmiddleditch/gha-setup-ninja@v5
# ========================================================================================================= Build deps
- name: Cache Download
id: cache-deps
uses: actions/cache@v4.2.0
@ -132,9 +142,10 @@ jobs:
CC: gcc.exe
CXX: g++.exe
run: |
export CMAKE_PREFIX_PATH=$PWD/qt6/build/lib/cmake
mkdir build
cd build
cmake -GNinja -DQT_VERSION_MAJOR=6 -DCMAKE_BUILD_TYPE=Release ..
cmake -GNinja -DQT_VERSION_MAJOR=6 -DCMAKE_CXX_FLAGS="-static -DNDEBUG -s" ..
ninja -j2
cd ..
./script/deploy_windows64.sh

View File

@ -0,0 +1,14 @@
git clone https://code.qt.io/qt/qt5.git qt6
cd qt6
git switch %1
mkdir build
CALL .\configure.bat -release -static -prefix ./build -static-runtime -submodules qtbase,qtimageformats,qtsvg,qttranslations -skip tests -skip examples -gui -widgets -init-submodules
echo on branch %1
echo config complete, building...
cmake --build . --parallel
echo build one, installing...
ninja install
echo installed Qt %1 in static mode
cd ..

View File

@ -18,10 +18,3 @@ tar xvzf artifacts.tgz -C ../../
cd ../..
mv $DEPLOYMENT/public_res/* $DEST
#### deploy qt & DLL runtime ####
pushd $DEST
windeployqt nekoray.exe --no-translations --no-system-d3d-compiler --no-opengl-sw --no-svg --verbose 2
popd
rm -rf $DEST/dxcompiler.dll $DEST/dxil.dll