diff --git a/.github/actions/initialize-vcpkg/action.yml b/.github/actions/initialize-vcpkg/action.yml deleted file mode 100644 index 5f6f6dd4..00000000 --- a/.github/actions/initialize-vcpkg/action.yml +++ /dev/null @@ -1,75 +0,0 @@ -# SPDX-FileCopyrightText: Team OpenVPI -# SPDX-License-Identifier: Apache-2.0 - -name: Initialize Vcpkg -description: Initialize vcpkg - -inputs: - ref: - description: "The ref to checkout" - required: false - default: "master" - use_cache: - description: Restore and save vcpkg binary caches - required: false - default: 'true' - - -runs: - using: "composite" - steps: - - name: Prepare vcpkg - if: inputs.use_cache == 'true' - shell: pwsh - run: | - 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 - - - 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 }} - restore-keys: | - ${{ runner.os }}-vcpkg-${{ inputs.ref }}- - - - 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" - 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' - ) - if ($env:USE_CACHE -ne 'true') { - $env:VCPKG_BINARY_SOURCES = 'clear' - 'VCPKG_BINARY_SOURCES=clear' >> $env:GITHUB_ENV - $arguments += '--binarysource=clear' - } - ./vcpkg @arguments - if ($LASTEXITCODE -ne 0) { - throw 'vcpkg installation failed' - } - - - 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 }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d396da5b..a3bb31a0 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 @@ -168,10 +167,13 @@ jobs: "DSSP_DIRECTORY=$dsspDirectory" >> $env:GITHUB_ENV - name: Initialize Vcpkg - uses: ./.github/actions/initialize-vcpkg + id: vcpkg + uses: stdware/dev-scripts/actions/vcpkg-workspace@main + env: + VCPKG_KEEP_ENV_VARS: VCPKG_BUILD_TYPE;MACOSX_DEPLOYMENT_TARGET with: - ref: ${{ env.VCPKG_REF }} - use_cache: ${{ inputs.build_type != 'nightly' && inputs.use_cache }} + qt-dir: ${{ env.QT_ROOT_DIR }} + cache: ${{ inputs.build_type != 'nightly' && inputs.use_cache }} - name: Restore CCache cache if: inputs.build_type != 'nightly' && inputs.use_cache && inputs.use_ccache @@ -185,6 +187,7 @@ jobs: - name: Build env: DSPM_EXECUTABLE: ${{ steps.download_dspm.outputs.path }} + VCPKG_ROOT_DIR: ${{ steps.vcpkg.outputs.vcpkg-root }} run: | $expectedRunnerArch = $env:ARTIFACT_ARCH -eq 'amd64' ? 'X64' : 'ARM64' if ($env:RUNNER_ARCH -ne $expectedRunnerArch) { @@ -218,6 +221,8 @@ jobs: key: ${{ runner.os }}-ccache-${{ inputs.source_sha }} - name: Collect symbol files + env: + VCPKG_ROOT_DIR: ${{ steps.vcpkg.outputs.vcpkg-root }} run: | $output = & ./scripts/ci/Collect-Symbol-Files.ps1 ` -VcpkgRootDir $env:VCPKG_ROOT_DIR ` diff --git a/.gitignore b/.gitignore index d41a831d..e135dc16 100644 --- a/.gitignore +++ b/.gitignore @@ -89,7 +89,7 @@ cache .vs 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..c35e37cf 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 repositories and refs of vcpkg and of the overlays, which `scripts/vcpkg-workspace.cmake` checks out into the ignored directory `deps/`. The ignored file `scripts/vcpkg-sources.local.json` takes precedence over it, for example to use a local overlay through `"path"`. `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,16 @@ 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`, which is downloaded from https://github.com/stdware/dev-scripts and ignored by git, 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= +curl -fsSL -o scripts/vcpkg-workspace.cmake https://raw.githubusercontent.com/stdware/dev-scripts/main/scripts/vcpkg-workspace.cmake +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/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/README.md b/README.md index 2f5b2201..79aaae82 100644 --- a/README.md +++ b/README.md @@ -41,13 +41,26 @@ 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 with [vcpkg-workspace.cmake](https://github.com/stdware/dev-scripts/blob/main/docs/about-scripts/vcpkg-workspace.md), downloaded into `scripts/`. The script checks out vcpkg and the overlays 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 + curl -fsSL -o scripts/vcpkg-workspace.cmake https://raw.githubusercontent.com/stdware/dev-scripts/main/scripts/vcpkg-workspace.cmake + cmake -P scripts/vcpkg-workspace.cmake install --qt-dir /path/to/Qt/lib/cmake/Qt6 ``` + + On Windows, the script is downloaded in PowerShell or in cmd with + + ```bat + powershell -Command "Invoke-WebRequest -OutFile scripts/vcpkg-workspace.cmake https://raw.githubusercontent.com/stdware/dev-scripts/main/scripts/vcpkg-workspace.cmake" + ``` + + `cmake -P scripts/vcpkg-workspace.cmake help` lists the other commands. `--dry-run` prints the commands without running them. `scripts/vcpkg-sources.local.json` takes precedence over `scripts/vcpkg-sources.json`, for example to use a local overlay. -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/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/scripts/.gitignore b/scripts/.gitignore new file mode 100644 index 00000000..9f556eb6 --- /dev/null +++ b/scripts/.gitignore @@ -0,0 +1,7 @@ +# SPDX-FileCopyrightText: Team OpenVPI +# SPDX-License-Identifier: Apache-2.0 + +# vcpkg-workspace.cmake from https://github.com/stdware/dev-scripts, downloaded before use, and its +# local sources, which take precedence over vcpkg-sources.json +/vcpkg-workspace.cmake +/vcpkg-sources.local.json 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..59c42162 --- /dev/null +++ b/scripts/vcpkg-sources.json @@ -0,0 +1,20 @@ +{ + "manifest-dir": "vcpkg-manifest", + "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}" + ] + } +} \ No newline at end of file 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()) {