Skip to content

Commit

Permalink
[优化Qt项目构建和依赖管理]: 对Qt项目的构建系统和依赖管理进行了重要优化
Browse files Browse the repository at this point in the history
- 引入基于vcpkg的依赖管理,简化了第三方库的集成和管理过程
- 重构了项目结构,将关键组件移动到`src`目录下,提高了项目的组织性
- 更新了CMakeLists和相关项目文件,确保它们与新的依赖管理方式兼容
- 新增了自动化安装项目依赖的`install-dependencies`动作
- 调整了GitHub Actions工作流,以适应新的项目结构和构建系统
- 新增了Crashpad支持,用于更有效地处理和报告应用崩溃信息
- 更新了`utils`目录下的文件,增加了实用的系统信息和日志功能
- 移除了不再需要的代码和配置,简化了项目的复杂度
  • Loading branch information
RealChuan committed May 29, 2024
1 parent 0d9eeb3 commit 0dabe9d
Show file tree
Hide file tree
Showing 209 changed files with 1,710 additions and 1,240 deletions.
113 changes: 113 additions & 0 deletions .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: 'Install Dependencies'
description: 'Install vcpkg libraries and qt environment'
inputs:
os_name:
description: 'os name'
required: true
type: string
vcpkg_libs:
description: 'vcpkg libraries'
required: false
default: 'breakpad crashpad'
type: string
vcpkg_ffmpeg_features:
description: 'vcpkg ffmpeg features'
required: false
default: 'opengl,ass,bzip2,freetype,fribidi,zlib,gpl,ffmpeg,ffplay,ffprobe'
type: string
qt_modules:
description: 'qt modules'
required: false
default: 'qt5compat qtnetworkauth qtmultimedia qtimageformats'
type: string
qt_ver:
description: 'qt version'
required: false
default: '6.7.0'
type: string

runs:
using: 'composite'

steps:
- name: Install Custom VCPKG
uses: RealChuan/install-vcpkg@main
with:
repo: 'https://github.com/RealChuan/vcpkg.git'
branch: 'dev'

- name: Delete vcpkg.json
shell: bash
run: |
rm vcpkg.json
- name: Cache windows vcpkg
if: startsWith(runner.os, 'Windows')
uses: actions/cache@v4
with:
path: C:\vcpkg\installed
key: ${{ inputs.os_name }}-vcpkg-installed-${{ runner.os }}-${{ github.sha }}
restore-keys: |
${{ inputs.os_name }}-vcpkg-installed-${{ runner.os_name }}-
${{ inputs.os_name }}-vcpkg-installed-
${{ inputs.os_name }}-
save-always: true

- name: Cache macos or linux vcpkg
if: startsWith(runner.os, 'macOS') || startsWith(runner.os, 'Linux')
uses: actions/cache@v4
with:
path: /usr/local/share/vcpkg/installed
key: ${{ inputs.os_name }}-vcpkg-installed-${{ runner.os }}-${{ github.sha }}
restore-keys: |
${{ inputs.os_name }}-vcpkg-installed-${{ runner.os_name }}-
${{ inputs.os_name }}-vcpkg-installed-
${{ inputs.os_name }}-
save-always: true

- name: Install dependencies on windows
if: startsWith(runner.os, 'Windows')
shell: bash
run: |
choco install ninja
ninja --version
cmake --version
vcpkg install ${{ inputs.vcpkg_libs }} \
ffmpeg[${{ inputs.vcpkg_ffmpeg_features }},amf,nvcodec,qsv] --triplet x64-windows \
|| (cat C:/vcpkg/installed/vcpkg/issue_body.md && exit 1)
- name: Install dependencies on macos
if: startsWith(runner.os, 'macOS')
shell: bash
run: |
brew install ninja nasm pkg-config python-setuptools
ninja --version
cmake --version
clang --version
vcpkg install ${{ inputs.vcpkg_libs }} \
ffmpeg[${{ inputs.vcpkg_ffmpeg_features }}] --triplet x64-osx \
|| (cat /usr/local/share/vcpkg/installed/vcpkg/issue_body.md && exit 1)
vcpkg install ${{ inputs.vcpkg_libs }} \
ffmpeg[${{ inputs.vcpkg_ffmpeg_features }}] --triplet arm64-osx \
|| (cat /usr/local/share/vcpkg/installed/vcpkg/issue_body.md && exit 1)
- name: Install dependencies on linux
if: startsWith(runner.os, 'Linux')
shell: bash
run: |
sudo apt-get update
sudo apt-get install ninja-build nasm autopoint gperf libgl1-mesa-dev \
libxinerama-dev libxcursor-dev xorg-dev libglu1-mesa-dev
ninja --version
cmake --version
gcc --version
vcpkg install ${{ inputs.vcpkg_libs }} \
ffmpeg[${{ inputs.vcpkg_ffmpeg_features }},amf,nvcodec] --triplet x64-linux \
|| (cat /usr/local/share/vcpkg/installed/vcpkg/issue_body.md && exit 1)
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: ${{ inputs.qt_ver }}
modules: ${{ inputs.qt_modules }}
cache: 'true'
123 changes: 22 additions & 101 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,23 @@
name: CMake build

on:
# push代码时触发workflow
push:
paths-ignore: # 下列文件的变更不触发部署,可以自行添加
- '.github/workflows/clean_cache.yml'
- '.github/workflows/delete_workflow.yml'
- '.github/workflows/qmake.yml'
- '.github/workflows/readme.yml'
- '.github/workflows/toolchain.yml'
paths-ignore:
- 'doc/**'
- '.clang*'
- '.gitignore'
- 'LICENSE'
- 'README*'
- 'vcpkg.json'
pull_request:
paths-ignore: # 下列文件的变更不触发部署,可以自行添加
- '.github/workflows/clean_cache.yml'
- '.github/workflows/delete_workflow.yml'
- '.github/workflows/qmake.yml'
- '.github/workflows/readme.yml'
- '.github/workflows/toolchain.yml'
paths-ignore:
- 'doc/**'
- '.clang*'
- '.gitignore'
- 'LICENSE'
- 'README*'
- 'vcpkg.json'

env:
MACOSX_DEPLOYMENT_TARGET: 11.0

jobs:
build:
Expand All @@ -40,108 +30,39 @@ jobs:
- windows-latest
- macos-latest
- ubuntu-latest
qt_ver:
- 6.6.2
build_type:
- "RelWithDebInfo"
generators:
- "Ninja"
vcpkg_libs:
- breakpad
vcpkg_ffmpeg_features:
- opengl,ass,bzip2,freetype,fribidi,zlib,gpl,ffmpeg,ffplay,ffprobe

steps:
- name: Restore windows vcpkg
if: startsWith(matrix.os, 'windows')
uses: actions/cache/restore@v4
with:
path: C:\vcpkg\installed
key: ${{ runner.os }}-vcpkg-installed-${{ matrix.os }}
- name: Restore macos or ubuntu vcpkg
if: startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu')
uses: actions/cache/restore@v4
with:
path: /usr/local/share/vcpkg/installed
key: ${{ runner.os }}-vcpkg-installed-${{ matrix.os }}

- name: Install dependencies on windows
if: startsWith(matrix.os, 'windows')
shell: bash
run: |
choco install ninja
ninja --version
cmake --version
vcpkg install ${{ matrix.vcpkg_libs }} ffmpeg[${{ matrix.vcpkg_ffmpeg_features }},amf,nvcodec,qsv] --triplet x64-windows
- name: Install dependencies on macos
if: startsWith(matrix.os, 'macos')
shell: bash
run: |
brew install ninja nasm pkg-config
ninja --version
cmake --version
clang --version
vcpkg install ${{ matrix.vcpkg_libs }} ffmpeg[${{ matrix.vcpkg_ffmpeg_features }}] --triplet x64-osx
- name: Install dependencies on ubuntu
if: startsWith(matrix.os, 'ubuntu')
shell: bash
run: |
sudo apt-get update
sudo apt-get install ninja-build nasm autopoint gperf libgl1-mesa-dev \
libxinerama-dev libxcursor-dev xorg-dev libglu1-mesa-dev
ninja --version
cmake --version
gcc --version
vcpkg install ${{ matrix.vcpkg_libs }} ffmpeg[${{ matrix.vcpkg_ffmpeg_features }},amf,nvcodec] --triplet x64-linux
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
version: ${{ matrix.qt_ver }}
install-deps: 'true'
modules: 'qt5compat qtnetworkauth qtmultimedia qtimageformats'
cache: 'true'

- uses: actions/checkout@v4
with:
with:
fetch-depth: 1

# jurplel/install-qt-action@v3, 这个action会修改默认的python版本,
# 会导致部分使用vcpkg的库编译失败,比如libsystemd,所以需要删除vcpkg.json
- name: Delete vcpkg.json
shell: bash
run: |
rm vcpkg.json
- name: Enable Developer Command Prompt
if: startsWith(matrix.os, 'windows')
uses: ilammy/msvc-dev-cmd@v1.12.1

- uses: ./.github/actions/install-dependencies
with:
arch: amd64
- name: Configure windows
os_name: ${{ matrix.os }}

- name: Configure and build windows
if: startsWith(matrix.os, 'windows')
shell: bash
shell: pwsh
run: |
cmake \
-S . \
-B ./build \
-DCMAKE_C_COMPILER=cl \
-DCMAKE_CXX_COMPILER=cl \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-G "${{ matrix.generators }}" \
-DCMAKE_INSTALL_PREFIX:PATH=instdir
- name: Configure macos or ubuntu
if: startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu')
.\scripts\windows\setVsDev.ps1
cmake `
-S . `
-B ./build `
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} `
-G "${{ matrix.generators }}"
cmake --build ./build --config ${{ matrix.build_type }}
- name: Configure and build on ubuntu or macos
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos')
shell: bash
run: |
cmake \
-S . \
-B ./build \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-G "${{ matrix.generators }}" \
-DCMAKE_INSTALL_PREFIX:PATH=instdir
- name: Build
shell: bash
run: |
-G "${{ matrix.generators }}"
cmake --build ./build --config ${{ matrix.build_type }}
2 changes: 1 addition & 1 deletion .github/workflows/delete_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ on:
delete_run_by_conclusion_pattern:
description: 'Remove runs based on conclusion: action_required, cancelled, failure, skipped, success'
required: true
default: "failure"
default: "Unsuccessful: action_required,cancelled,failure,skipped"
type: choice
options:
- "ALL"
Expand Down
Loading

0 comments on commit 0dabe9d

Please sign in to comment.