Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[重构]: 项目结构和构建系统全面升级
Browse files Browse the repository at this point in the history
- 项目代码重构至 `src` 目录,优化模块化管理
- CMake 构建系统更新,提高跨平台构建效率
- 引入 vcpkg 作为依赖管理工具,简化第三方库集成
- 更新 `.gitignore` 文件,合理忽略构建和临时文件
RealChuan committed May 31, 2024
1 parent bdad19d commit 206c7dc
Showing 172 changed files with 1,592 additions and 1,195 deletions.
99 changes: 99 additions & 0 deletions .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
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 giflib'
type: string
qt_modules:
description: 'qt modules'
required: false
default: 'qt5compat qtnetworkauth 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 }} --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 python-setuptools
ninja --version
cmake --version
clang --version
vcpkg install ${{ inputs.vcpkg_libs }} --triplet x64-osx || (cat /usr/local/share/vcpkg/installed/vcpkg/issue_body.md && exit 1)
vcpkg install ${{ inputs.vcpkg_libs }} --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 build-essential libgl1-mesa-dev clang
ninja --version
cmake --version
gcc --version
vcpkg install ${{ inputs.vcpkg_libs }} --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'
109 changes: 23 additions & 86 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,24 @@
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-format'
- '.gitignore'
- 'LICENSE'
- 'README*'
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-format'
- '.gitignore'
- 'LICENSE'
- 'README*'

env:
MACOSX_DEPLOYMENT_TARGET: 11.0

jobs:
build:
name: Build
@@ -38,94 +30,39 @@ jobs:
- windows-latest
- macos-latest
- ubuntu-latest
qt_ver:
- 6.6.1
build_type:
- "Release"
- "RelWithDebInfo"
generators:
- "Ninja"
libs:
- breakpad giflib

steps:
- name: Restore windows vcpkg
if: startsWith(matrix.os, 'windows')
uses: actions/cache/restore@v3
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@v3
with:
path: /usr/local/share/vcpkg/installed
key: ${{ runner.os }}-vcpkg-installed-${{ matrix.os }}

- name: Install dependencies on windows
if: startsWith(matrix.os, 'windows')
run: |
choco install ninja
ninja --version
cmake --version
vcpkg install ${{ matrix.libs }} --triplet x64-windows
- name: Install dependencies on macos
if: startsWith(matrix.os, 'macos')
run: |
brew install ninja
ninja --version
cmake --version
clang --version
vcpkg install ${{ matrix.libs }} --triplet x64-osx
- name: Install dependencies on ubuntu
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get install ninja-build
ninja --version
cmake --version
gcc --version
vcpkg install ${{ matrix.libs }} --triplet x64-linux
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
version: ${{ matrix.qt_ver }}
install-deps: 'true'
modules: 'qt5compat qtnetworkauth qtimageformats'
cache: 'true'

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

- name: Enable Developer Command Prompt
if: startsWith(matrix.os, 'windows')
uses: ilammy/[email protected]

- 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
@@ -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"
Loading

0 comments on commit 206c7dc

Please sign in to comment.