From 3cd7d7ae9c8da53d05d9cc827566abe3d94255b5 Mon Sep 17 00:00:00 2001 From: SineStriker Date: Sat, 24 Oct 2026 17:37:56 +0800 Subject: [PATCH 1/8] Show the target platform of the build in the about dialog --- CMakeLists.txt | 5 ++ cmake/DetectTriplet.cmake | 46 +++++++++++++++++++ src/CMakeLists.txt | 1 + src/plugins/coreplugin/core/CoreInterface.cpp | 6 ++- 4 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 cmake/DetectTriplet.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index b94172ea..b470bdab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,11 @@ else() set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON) endif() +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) + +# Sets the cache entry APPLICATION_TRIPLET, the triplet of the build such as x86_64-windows-msvc +include(DetectTriplet) + if(APPLICATION_INSTALL) include(GNUInstallDirs) include(CMakePackageConfigHelpers) diff --git a/cmake/DetectTriplet.cmake b/cmake/DetectTriplet.cmake new file mode 100644 index 00000000..83dfe2fe --- /dev/null +++ b/cmake/DetectTriplet.cmake @@ -0,0 +1,46 @@ +# SPDX-FileCopyrightText: Team OpenVPI +# SPDX-License-Identifier: Apache-2.0 + +# The triplet of the build, --, such as x86_64-windows-msvc, which the +# about dialog shows as the target platform. The naming follows HelloUtau. +# +# The names are those that users know rather than those of vcpkg: x86_64 for the architecture +# rather than x64, a name of Microsoft, arm64 as Apple names the architecture, and mac for the +# system rather than osx. +# The ABI rather than the compiler is named, because a build of clang for the MSVC ABI loads the +# plugins of a build of MSVC. +# +# Sets the cache entry APPLICATION_TRIPLET, which -DAPPLICATION_TRIPLET= overrides. + +if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(AMD64|x86_64|x64)$") + set(_application_arch x86_64) +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(ARM64|aarch64|arm64)$") + set(_application_arch arm64) +else() + string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" _application_arch) +endif() + +if(WIN32) + set(_application_system windows) +elseif(APPLE) + set(_application_system mac) +else() + set(_application_system linux) +endif() + +if(MSVC OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") + set(_application_abi msvc) +elseif(MINGW) + set(_application_abi mingw) +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set(_application_abi gcc) +else() + string(TOLOWER "${CMAKE_CXX_COMPILER_ID}" _application_abi) +endif() + +set(APPLICATION_TRIPLET "${_application_arch}-${_application_system}-${_application_abi}" CACHE STRING + "The triplet of the build, which the about dialog shows") + +unset(_application_arch) +unset(_application_system) +unset(_application_abi) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 64d6e8e2..779dbd4c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -46,6 +46,7 @@ qm_add_definition(APPLICATION_DISPLAY_NAME ${APPLICATION_DISPLAY_NAME} STRING_LI qm_add_definition(APPLICATION_VERSION ${APPLICATION_VERSION} STRING_LITERAL) qm_add_definition(APPLICATION_ORG_NAME "OpenVPI" STRING_LITERAL) qm_add_definition(APPLICATION_SEMVER ${APPLICATION_SEMVER} STRING_LITERAL) +qm_add_definition(APPLICATION_TRIPLET ${APPLICATION_TRIPLET} STRING_LITERAL) qm_add_definition(APPLICATION_VENDOR_NAME ${APPLICATION_VENDOR_NAME} STRING_LITERAL) qm_add_definition(APPLICATION_DEV_START_YEAR ${APPLICATION_DEV_START_YEAR} STRING_LITERAL) qm_add_definition(APPLICATION_URL ${APPLICATION_URL} STRING_LITERAL) diff --git a/src/plugins/coreplugin/core/CoreInterface.cpp b/src/plugins/coreplugin/core/CoreInterface.cpp index 1bc393ae..964f307e 100644 --- a/src/plugins/coreplugin/core/CoreInterface.cpp +++ b/src/plugins/coreplugin/core/CoreInterface.cpp @@ -295,14 +295,16 @@ namespace Core { "Branch: %1
" "Commit: %2
" "Build date: %3
" - "Toolchain: %4 %5 %6" + "Toolchain: %4 %5 %6
" + "Target platform: %7" "

") .arg(QStringLiteral(APPLICATION_GIT_BRANCH), // QStringLiteral(APPLICATION_GIT_LAST_COMMIT_HASH), // QLocale().toString(QDateTime::fromString(QStringLiteral(APPLICATION_BUILD_TIME), Qt::ISODate).toLocalTime()), // QStringLiteral(APPLICATION_COMPILER_ARCH), // QStringLiteral(APPLICATION_COMPILER_ID), // - QStringLiteral(APPLICATION_COMPILER_VERSION)); + QStringLiteral(APPLICATION_COMPILER_VERSION), // + QStringLiteral(APPLICATION_TRIPLET)); QQmlComponent component(RuntimeInterface::qmlEngine(), "SVSCraft.UIComponents", "MessageBoxDialog"); if (component.isError()) { From c0bfe38c0bea42838ff66a5ab7054d68bc334e97 Mon Sep 17 00:00:00 2001 From: SineStriker Date: Sat, 24 Oct 2026 18:38:22 +0800 Subject: [PATCH 2/8] Check out vcpkg and the overlays into deps with a script in place of the overlay submodule --- .github/actions/initialize-vcpkg/action.yml | 36 +- .github/workflows/build.yml | 2 - .gitignore | 1 + .gitmodules | 4 - AGENTS.md | 8 +- README.md | 12 +- scripts/vcpkg | 1 - scripts/vcpkg-manifest/vcpkg.json | 10 +- scripts/vcpkg-sources.json | 15 + scripts/vcpkg-workspace.cmake | 659 ++++++++++++++++++++ 10 files changed, 702 insertions(+), 46 deletions(-) delete mode 160000 scripts/vcpkg create mode 100644 scripts/vcpkg-sources.json create mode 100644 scripts/vcpkg-workspace.cmake diff --git a/.github/actions/initialize-vcpkg/action.yml b/.github/actions/initialize-vcpkg/action.yml index 5f6f6dd4..8e3b34a5 100644 --- a/.github/actions/initialize-vcpkg/action.yml +++ b/.github/actions/initialize-vcpkg/action.yml @@ -2,13 +2,9 @@ # SPDX-License-Identifier: Apache-2.0 name: Initialize Vcpkg -description: Initialize vcpkg +description: Prepare the vcpkg workspace in deps/ with scripts/vcpkg-workspace.cmake inputs: - ref: - description: "The ref to checkout" - required: false - default: "master" use_cache: description: Restore and save vcpkg binary caches required: false @@ -25,51 +21,45 @@ runs: New-Item -ItemType Directory -Path ${{ github.workspace }}/../vcpkg_archives -Force Write-Output VCPKG_DEFAULT_BINARY_CACHE=$(Resolve-Path ${{ github.workspace }}/../vcpkg_archives) >> $env:GITHUB_ENV + # The binary cache of vcpkg is keyed by the ABI of each package, so a cache of other sources + # is also of use. - name: Restore vcpkg binary cache id: cache_vcpkg if: inputs.use_cache == 'true' uses: actions/cache/restore@v4 with: path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} - key: ${{ runner.os }}-vcpkg-${{ inputs.ref }}-${{ github.sha }} + key: ${{ runner.os }}-vcpkg-${{ hashFiles('scripts/vcpkg-sources.json') }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-vcpkg-${{ inputs.ref }}- + ${{ runner.os }}-vcpkg-${{ hashFiles('scripts/vcpkg-sources.json') }}- + ${{ runner.os }}-vcpkg- - name: Install vcpkg dependencies env: USE_CACHE: ${{ inputs.use_cache }} QT_DIR: ${{ env.Qt_ROOT_DIR }}/lib/cmake/Qt6 - Qt6_DIR: ${{ env.Qt_ROOT_DIR }}/lib/cmake/Qt6 - VCPKG_KEEP_ENV_VARS: "QT_DIR;Qt6_DIR;VCPKG_BUILD_TYPE;MACOSX_DEPLOYMENT_TARGET" + VCPKG_KEEP_ENV_VARS: "VCPKG_BUILD_TYPE;MACOSX_DEPLOYMENT_TARGET" shell: pwsh run: | if ($env:USE_CACHE -eq 'true' -and !(Test-Path $env:VCPKG_DEFAULT_BINARY_CACHE)) { New-Item $env:VCPKG_DEFAULT_BINARY_CACHE -ItemType directory } - Set-Location ${{ github.workspace }}/.. - git clone https://github.com/microsoft/vcpkg.git - Set-Location vcpkg - Write-Output VCPKG_ROOT_DIR=$(Resolve-Path .) >> $env:GITHUB_ENV - git checkout ${{ inputs.ref }} - ${{ runner.os == 'Windows' && './bootstrap-vcpkg.bat' || 'sh ./bootstrap-vcpkg.sh' }} - $arguments = @( - 'install' - '--x-manifest-root=${{ github.workspace }}/scripts/vcpkg-manifest' - '--x-install-root=./installed' - ) + Set-Location ${{ github.workspace }} + $arguments = @('-P', 'scripts/vcpkg-workspace.cmake', 'install') if ($env:USE_CACHE -ne 'true') { $env:VCPKG_BINARY_SOURCES = 'clear' 'VCPKG_BINARY_SOURCES=clear' >> $env:GITHUB_ENV - $arguments += '--binarysource=clear' + $arguments += @('--', '--binarysource=clear') } - ./vcpkg @arguments + cmake @arguments if ($LASTEXITCODE -ne 0) { throw 'vcpkg installation failed' } + Write-Output VCPKG_ROOT_DIR=$(Resolve-Path deps/vcpkg) >> $env:GITHUB_ENV - name: Save vcpkg binary cache if: inputs.use_cache == 'true' uses: actions/cache/save@v4 with: path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} - key: ${{ runner.os }}-vcpkg-${{ inputs.ref }}-${{ github.sha }} + key: ${{ runner.os }}-vcpkg-${{ hashFiles('scripts/vcpkg-sources.json') }}-${{ github.sha }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d396da5b..bfac6280 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -78,7 +78,6 @@ jobs: runs-on: ${{ matrix.os }} env: QT_VERSION: 6.11.2 - VCPKG_REF: 39344dff01c5a5a0134caf2624cdd492f05d30ea VCPKG_DISABLE_METRICS: '1' INNOSETUP_REF: is-6_5_4 DSSP_CHANNEL: nightly @@ -170,7 +169,6 @@ jobs: - name: Initialize Vcpkg uses: ./.github/actions/initialize-vcpkg with: - ref: ${{ env.VCPKG_REF }} use_cache: ${{ inputs.build_type != 'nightly' && inputs.use_cache }} - name: Restore CCache cache diff --git a/.gitignore b/.gitignore index d41a831d..8abbd663 100644 --- a/.gitignore +++ b/.gitignore @@ -90,6 +90,7 @@ cache out/ CMakeSettings.json /vcpkg +/deps /data /*.natvis diff --git a/.gitmodules b/.gitmodules index fb15e35e..1f88717f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -22,10 +22,6 @@ path = src/libs/3rdparty/talcs url = ../../CrSjimo/talcs.git -[submodule "vcpkg"] - path = scripts/vcpkg - url = ../../stdware/vcpkg-overlay.git - [submodule "opendspx"] path = src/libs/3rdparty/opendspx url = ../../diffscope/opendspx.git diff --git a/AGENTS.md b/AGENTS.md index 862d079d..0a607c91 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -16,7 +16,7 @@ DiffScope is a C++20/Qt 6 singing-voice editor. Keep `src/app` a thin launcher; - `src/share/`: shared install/deployment rules used after ChorusKit finishes configuring the application. - `src/libs/3rdparty/`: Git submodules. Treat these as upstream projects; do not mix ordinary feature changes with submodule edits. - `src/libs/application/uishell/tests/`: standalone visual/smoke applications. `src/tests/` is reserved for application-wide tests. -- `scripts/vcpkg-manifest/` and `scripts/vcpkg/`: dependency manifest and overlay ports/triplets. `scripts/ci/` is the packaging reference. `dist/` contains installers. +- `scripts/vcpkg-manifest/`: dependency manifest. `scripts/vcpkg-sources.json` specifies the commits of vcpkg and of the overlays, which `scripts/vcpkg-workspace.cmake` checks out into the ignored directory `deps/`. `scripts/ci/` is the packaging reference. `dist/` contains installers. Never commit generated files from `build/`, `cmake-build-*`, `out/`, `.qm`, MOC, QML cache, or synchronized include directories. @@ -215,15 +215,15 @@ View-model bindings maintain explicit document-to-view and view-to-document maps ## Configure, Build, and Run -Use a recursive checkout, CMake 3.19+, Qt 6.10-compatible development packages, Ninja, and a C++20 compiler. During vcpkg installation, expose the Qt CMake directory through `QT_DIR`/`Qt6_DIR` and retain those variables for overlay ports. +Use a recursive checkout, CMake 3.19+, Qt 6.10-compatible development packages, Ninja, and a C++20 compiler. `scripts/vcpkg-workspace.cmake` prepares vcpkg, the overlays, and the dependencies in `deps/`, and passes the Qt CMake directory to the ports that build against Qt. `cmake -P scripts/vcpkg-workspace.cmake help` lists its commands, and `--dry-run` prints the commands without running them. The configuration requires `CMAKE_TOOLCHAIN_FILE`, the toolchain of `deps/vcpkg`. Do not perform any test, build, run, or automatic formatting operations unless explicitly requested by the user. Also do not include any of these operations in the plan unless explicitly requested by the user. ```sh git submodule update --init --recursive -/vcpkg install --x-manifest-root=scripts/vcpkg-manifest --x-install-root=/installed --triplet= +cmake -P scripts/vcpkg-workspace.cmake install --qt-dir /lib/cmake/Qt6 --triplet cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug \ - -DCMAKE_TOOLCHAIN_FILE=/scripts/buildsystems/vcpkg.cmake \ + -DCMAKE_TOOLCHAIN_FILE=deps/vcpkg/scripts/buildsystems/vcpkg.cmake \ -DQt6_DIR=/lib/cmake/Qt6 -DAPPLICATION_BUILD_TESTS=ON \ -DTALCS_DSPX=ON -DTALCS_WIDGETS=ON cmake --build build --parallel diff --git a/README.md b/README.md index 2f5b2201..17047b7f 100644 --- a/README.md +++ b/README.md @@ -41,13 +41,19 @@ If you are interested in contributing or collaborating, please feel free to reac git clone --recursive https://github.com/diffscope/diffscope-project.git ``` -3. Install dependencies via Vcpkg. +3. Install dependencies via Vcpkg. The script checks out vcpkg and the overlays at the commits that `scripts/vcpkg-sources.json` specifies into `deps/`, and installs the dependencies there. It runs on Windows, macOS and Linux. ```bash - vcpkg install --x-manifest-root=/path/to/diffscope-project/scripts/vcpkg-manifest --x-install-root=/path/to/vcpkg/installed + cmake -P scripts/vcpkg-workspace.cmake install --qt-dir /path/to/Qt/lib/cmake/Qt6 ``` + + `cmake -P scripts/vcpkg-workspace.cmake help` lists the other commands. `--dry-run` prints the commands without running them. -4. Build using CMake. +4. Build using CMake with the vcpkg toolchain in `deps/`. + + ```bash + cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=deps/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_PREFIX_PATH=/path/to/Qt + ``` You may refer to CI scripts for more details. diff --git a/scripts/vcpkg b/scripts/vcpkg deleted file mode 160000 index 7acffe30..00000000 --- a/scripts/vcpkg +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7acffe30cb3fc5de2196603de20c9d68c5018415 diff --git a/scripts/vcpkg-manifest/vcpkg.json b/scripts/vcpkg-manifest/vcpkg.json index c2e4d151..5a544caa 100644 --- a/scripts/vcpkg-manifest/vcpkg.json +++ b/scripts/vcpkg-manifest/vcpkg.json @@ -44,13 +44,5 @@ "xxhash", "signalsmith-dsp", "rubberband" - ], - "vcpkg-configuration": { - "overlay-ports": [ - "../vcpkg/ports" - ], - "overlay-triplets": [ - "../vcpkg/triplets" - ] - } + ] } diff --git a/scripts/vcpkg-sources.json b/scripts/vcpkg-sources.json new file mode 100644 index 00000000..3fcca2fa --- /dev/null +++ b/scripts/vcpkg-sources.json @@ -0,0 +1,15 @@ +{ + "vcpkg": { + "repository": "https://github.com/microsoft/vcpkg.git", + "ref": "master" + }, + "overlays": [ + { + "repository": "../../stdware/vcpkg-overlay.git", + "ref": "main" + } + ], + "tasks": { + "list": ["${VCPKG_EXECUTABLE}", "list", "--x-install-root=${VCPKG_INSTALLED_DIR}"] + } +} diff --git a/scripts/vcpkg-workspace.cmake b/scripts/vcpkg-workspace.cmake new file mode 100644 index 00000000..b990d42c --- /dev/null +++ b/scripts/vcpkg-workspace.cmake @@ -0,0 +1,659 @@ +# SPDX-FileCopyrightText: Team OpenVPI +# SPDX-License-Identifier: Apache-2.0 + +#[[ +Prepares the vcpkg workspace of DiffScope in deps/: vcpkg and the overlays at the commits that +scripts/vcpkg-sources.json specifies, and the dependencies of scripts/vcpkg-manifest installed into +deps/vcpkg/installed. + +Usage: + cmake -P scripts/vcpkg-workspace.cmake [