Move the install locking file to "installed" rather than VCPKG_ROOT. (#1938)

Feedback from the Windows build lab is that they run several concurrent vcpkg manifest installs in ways that don't actually conflict. However, our file locking for manifest mode put the file lock in VCPKG_ROOT, a false conflict for manifest mode builds.

This change moves that lock into the installed tree itself so that only actually conflicting installs will lock or block.

Drive by changes:

* "tools" is removed from z-print-config as that forced extra API surface onto vcpkg paths for a meaningless test.
* re-sorted contractual-constants.h
* try_take_exclusive_file_lock double-nested optional removed
* shorten_text moved from "vcpkglib.h" to "strings.h"
* vcpkglib.* renamed to installeddatabase.*
* database_load_collapse renamed database_sync
* write_update renamed database_write_update
* The on-disk layout of the installed tree is now documented in installedpaths.h
* VcpkgCmdArguments::do_not_take_lock is now unnecessary as the lock is targeted at operations that actually affect the installed tree rather than everything.
* blocks concurrent modification of an installed tree in 'classic' mode, not only manifest mode
* Improve shorten_text to not visit more of the input than necessary.
This commit is contained in:
Billy O'Neal authored and GitHub committed 2026-03-12 17:06:28 -07:00
1 parent 4b3e4c276b
commit 73afc2038f
45 files changed
+390 -207

No files matched your search

+11 -12
View File
@@ -1,18 +1,17 @@
/.vscode
/build*
**/dist/
*.swp
.DS_Store
.cache
CMakeLists.txt.user
/.idea
/cmake-build-*
/.vs
/CMakeSettings.json
/out
/OneLocBuild
.DS_Store
CMakeLists.txt.user
.cache
/vcpkg-artifacts/node_modules/
**/dist/
/vcpkg-root
/.vscode
/CMakeUserPresets.json
/OneLocBuild
/build*
/cmake-build-*
/out
/vcpkg-artifacts/node_modules/
/vcpkg-root
/work
@@ -43,7 +43,6 @@ $b = @{
packages = Join-Path $VcpkgRoot "packages"
installed = Join-Path $VcpkgRoot "installed"
'versions-output' = Join-Path $VcpkgRoot "buildtrees" "versioning_" "versions"
tools = Join-Path $VcpkgRoot "downloads" "tools"
'vcpkg-root' = $VcpkgRoot
}
foreach ($k in $b.keys) {
@@ -68,7 +67,6 @@ $b = @{
packages = $null
installed = $null
'versions-output' = $null
tools = Join-Path $cache_home "vcpkg" "downloads" "tools"
'vcpkg-root' = $VcpkgRoot
}
foreach ($k in $b.keys) {
@@ -98,7 +96,6 @@ $b = @{
packages = Join-Path $manifestdir "vcpkg_installed" "vcpkg" "pkgs"
installed = Join-Path $manifestdir "vcpkg_installed"
'versions-output' = Join-Path $manifestdir "vcpkg_installed" "vcpkg" "blds" "versioning_" "versions"
tools = Join-Path $cache_home "vcpkg" "downloads" "tools"
'vcpkg-root' = $VcpkgRoot
'manifest-mode-enabled' = $True
}
@@ -138,7 +135,6 @@ $b = @{
packages = $packagesRoot
installed = $installRoot
'versions-output' = Join-Path $buildtreesRoot "versioning_" "versions"
tools = Join-Path $cache_home "vcpkg" "downloads" "tools"
'vcpkg-root' = $VcpkgRoot
'manifest-mode-enabled' = $True
}
+29 -28
View File
@@ -12,11 +12,11 @@ namespace vcpkg
inline constexpr StringLiteral JsonIdAcquiredArtifacts = "acquired-artifacts";
inline constexpr StringLiteral JsonIdActivatedArtifacts = "activated-artifacts";
inline constexpr StringLiteral JsonIdAlgorithm = "algorithm";
inline constexpr StringLiteral JsonIdArchive = "archive";
inline constexpr StringLiteral JsonIdAllCapsSHA256 = "SHA256";
inline constexpr StringLiteral JsonIdAllCapsSHA512 = "SHA512";
inline constexpr StringLiteral JsonIdApply = "apply";
inline constexpr StringLiteral JsonIdArch = "arch";
inline constexpr StringLiteral JsonIdArchive = "archive";
inline constexpr StringLiteral JsonIdArchiveCapitalLocation = "archiveLocation";
inline constexpr StringLiteral JsonIdArtifact = "artifact";
inline constexpr StringLiteral JsonIdBaseline = "baseline";
@@ -76,9 +76,9 @@ namespace vcpkg
inline constexpr StringLiteral JsonIdOverlayPorts = "overlay-ports";
inline constexpr StringLiteral JsonIdOverlayTriplets = "overlay-triplets";
inline constexpr StringLiteral JsonIdOverrides = "overrides";
inline constexpr StringLiteral JsonIdPackages = "packages";
inline constexpr StringLiteral JsonIdPackageUnderscoreName = "package_name";
inline constexpr StringLiteral JsonIdPackageUnderscoreUrl = "package_url";
inline constexpr StringLiteral JsonIdPackages = "packages";
inline constexpr StringLiteral JsonIdPath = "path";
inline constexpr StringLiteral JsonIdPlatform = "platform";
inline constexpr StringLiteral JsonIdPortUnderscoreVersion = "port_version";
@@ -112,10 +112,10 @@ namespace vcpkg
inline constexpr StringLiteral JsonIdVersion = "version";
inline constexpr StringLiteral JsonIdVersionDate = "version-date";
inline constexpr StringLiteral JsonIdVersionGreaterEqual = "version>=";
inline constexpr StringLiteral JsonIdVersions = "versions";
inline constexpr StringLiteral JsonIdVersionSemver = "version-semver";
inline constexpr StringLiteral JsonIdVersionsOutput = "versions-output";
inline constexpr StringLiteral JsonIdVersionString = "version-string";
inline constexpr StringLiteral JsonIdVersions = "versions";
inline constexpr StringLiteral JsonIdVersionsOutput = "versions-output";
inline constexpr StringLiteral JsonIdWarning = "warning";
// SPDX constants are JsonIds which follow capitalization and separation in the SPDX specification,
@@ -167,10 +167,10 @@ namespace vcpkg
inline constexpr StringLiteral ParagraphIdPackage = "Package";
inline constexpr StringLiteral ParagraphIdPortVersion = "Port-Version";
inline constexpr StringLiteral ParagraphIdSource = "Source";
inline constexpr StringLiteral ParagraphIdStatus = "Status";
inline constexpr StringLiteral ParagraphIdSupports = "Supports";
inline constexpr StringLiteral ParagraphIdType = "Type";
inline constexpr StringLiteral ParagraphIdVersion = "Version";
inline constexpr StringLiteral ParagraphIdStatus = "Status";
// Switches are lowercase separated by dashes
inline constexpr StringLiteral SwitchAbiToolsUseExactVersions = "abi-tools-use-exact-versions";
@@ -193,19 +193,20 @@ namespace vcpkg
inline constexpr StringLiteral SwitchBuiltinRegistryVersionsDir = "builtin-registry-versions-dir";
inline constexpr StringLiteral SwitchCIBaseline = "ci-baseline";
inline constexpr StringLiteral SwitchCIFeatureBaseline = "ci-feature-baseline";
inline constexpr StringLiteral SwitchCMakeArgs = "cmake-args";
inline constexpr StringLiteral SwitchCMakeConfigureDebug = "cmake-configure-debug";
inline constexpr StringLiteral SwitchCMakeDebug = "cmake-debug";
inline constexpr StringLiteral SwitchClassic = "classic";
inline constexpr StringLiteral SwitchCleanAfterBuild = "clean-after-build";
inline constexpr StringLiteral SwitchCleanBuildtreesAfterBuild = "clean-buildtrees-after-build";
inline constexpr StringLiteral SwitchCleanDownloadsAfterBuild = "clean-downloads-after-build";
inline constexpr StringLiteral SwitchCleanPackagesAfterBuild = "clean-packages-after-build";
inline constexpr StringLiteral SwitchCMakeArgs = "cmake-args";
inline constexpr StringLiteral SwitchCMakeConfigureDebug = "cmake-configure-debug";
inline constexpr StringLiteral SwitchCMakeDebug = "cmake-debug";
inline constexpr StringLiteral SwitchConvertControl = "convert-control";
inline constexpr StringLiteral SwitchCopiedFilesLog = "copied-files-log";
inline constexpr StringLiteral SwitchDebug = "debug";
inline constexpr StringLiteral SwitchDebugBin = "debug-bin";
inline constexpr StringLiteral SwitchDebugEnv = "debug-env";
inline constexpr StringLiteral SwitchDereferenceSymlinks = "dereference-symlinks";
inline constexpr StringLiteral SwitchDgml = "dgml";
inline constexpr StringLiteral SwitchDisableMetrics = "disable-metrics";
inline constexpr StringLiteral SwitchDot = "dot";
@@ -218,26 +219,25 @@ namespace vcpkg
inline constexpr StringLiteral SwitchFailureLogs = "failure-logs";
inline constexpr StringLiteral SwitchFeatureFlags = "feature-flags";
inline constexpr StringLiteral SwitchFix = "fix";
inline constexpr StringLiteral SwitchForMergeWith = "for-merge-with";
inline constexpr StringLiteral SwitchForce = "force";
inline constexpr StringLiteral SwitchFormat = "format";
inline constexpr StringLiteral SwitchForMergeWith = "for-merge-with";
inline constexpr StringLiteral SwitchFreeBsd = "freebsd";
inline constexpr StringLiteral SwitchHead = "head";
inline constexpr StringLiteral SwitchHeader = "header";
inline constexpr StringLiteral SwitchHostExclude = "host-exclude";
inline constexpr StringLiteral SwitchHostTriplet = "host-triplet";
inline constexpr StringLiteral SwitchDereferenceSymlinks = "dereference-symlinks";
inline constexpr StringLiteral SwitchIgnoreLockFailures = "ignore-lock-failures";
inline constexpr StringLiteral SwitchInclude = "include";
inline constexpr StringLiteral SwitchInstalledBinDir = "installed-bin-dir";
inline constexpr StringLiteral SwitchInstallRoot = "install-root";
inline constexpr StringLiteral SwitchInstalledBinDir = "installed-bin-dir";
inline constexpr StringLiteral SwitchJson = "json";
inline constexpr StringLiteral SwitchKeepGoing = "keep-going";
inline constexpr StringLiteral SwitchKnownFailuresFrom = "known-failures-from";
inline constexpr StringLiteral SwitchLinux = "linux";
inline constexpr StringLiteral SwitchMSBuildProps = "msbuild-props";
inline constexpr StringLiteral SwitchManifestRoot = "manifest-root";
inline constexpr StringLiteral SwitchMaxRecurse = "max-recurse";
inline constexpr StringLiteral SwitchMSBuildProps = "msbuild-props";
inline constexpr StringLiteral SwitchName = "name";
inline constexpr StringLiteral SwitchNoCombined = "no-combined";
inline constexpr StringLiteral SwitchNoCore = "no-core";
@@ -284,14 +284,14 @@ namespace vcpkg
inline constexpr StringLiteral SwitchSort = "sort";
inline constexpr StringLiteral SwitchStore = "store";
inline constexpr StringLiteral SwitchStrip = "strip";
inline constexpr StringLiteral SwitchTLogFile = "tlog-file";
inline constexpr StringLiteral SwitchTargetArm = "target:arm";
inline constexpr StringLiteral SwitchTargetArm64 = "target:arm64";
inline constexpr StringLiteral SwitchTargetBinary = "target-binary";
inline constexpr StringLiteral SwitchTargetX64 = "target:x64";
inline constexpr StringLiteral SwitchTargetX86 = "target:x86";
inline constexpr StringLiteral SwitchTLogFile = "tlog-file";
inline constexpr StringLiteral SwitchTools = "tools";
inline constexpr StringLiteral SwitchToolDataFile = "tool-data-file";
inline constexpr StringLiteral SwitchTools = "tools";
inline constexpr StringLiteral SwitchTriplet = "triplet";
inline constexpr StringLiteral SwitchUrl = "url";
inline constexpr StringLiteral SwitchVcpkgRoot = "vcpkg-root";
@@ -317,8 +317,8 @@ namespace vcpkg
inline constexpr StringLiteral SwitchXWriteNuGetPackagesConfig = "x-write-nuget-packages-config";
inline constexpr StringLiteral SwitchXXUnit = "x-xunit";
inline constexpr StringLiteral SwitchXXUnitAll = "x-xunit-all";
inline constexpr StringLiteral SwitchZip = "zip";
inline constexpr StringLiteral SwitchZMachineReadableProgress = "z-machine-readable-progress";
inline constexpr StringLiteral SwitchZip = "zip";
// Sorts
inline constexpr StringLiteral SortLexicographical = "lexicographical";
@@ -330,8 +330,8 @@ namespace vcpkg
inline constexpr StringLiteral FileBaselineDotJson = "baseline.json";
inline constexpr StringLiteral FileBin = "bin";
inline constexpr StringLiteral FileBuildInfo = "BUILD_INFO";
inline constexpr StringLiteral FileControl = "CONTROL";
inline constexpr StringLiteral FileCompilerFileHashCacheDotJson = "compiler-file-hash-cache.json";
inline constexpr StringLiteral FileControl = "CONTROL";
inline constexpr StringLiteral FileCopying = "COPYING";
inline constexpr StringLiteral FileCopyright = "copyright";
inline constexpr StringLiteral FileDebug = "debug";
@@ -343,6 +343,7 @@ namespace vcpkg
inline constexpr StringLiteral FileIssueBodyMD = "issue_body.md";
inline constexpr StringLiteral FileLicense = "LICENSE";
inline constexpr StringLiteral FileLicenseDotTxt = "LICENSE.txt";
inline constexpr StringLiteral FileManifestInfo = "manifest-info.json";
inline constexpr StringLiteral FilePortfileDotCMake = "portfile.cmake";
inline constexpr StringLiteral FileReadmeDotLog = "readme.log";
inline constexpr StringLiteral FileShare = "share";
@@ -358,9 +359,9 @@ namespace vcpkg
inline constexpr StringLiteral FileVcpkgConfigurationDotJson = "vcpkg-configuration.json";
inline constexpr StringLiteral FileVcpkgDotJson = "vcpkg.json";
inline constexpr StringLiteral FileVcpkgLock = "vcpkg-lock.json";
inline constexpr StringLiteral FileManifestInfo = "manifest-info.json";
inline constexpr StringLiteral FileVcpkgPathTxt = "vcpkg.path.txt";
inline constexpr StringLiteral FileVcpkgPortConfig = "vcpkg-port-config.cmake";
inline constexpr StringLiteral FileVcpkgRunningLock = "vcpkg-running.lock";
inline constexpr StringLiteral FileVcpkgSpdxJson = "vcpkg.spdx.json";
inline constexpr StringLiteral FileVcpkgUserProps = "vcpkg.user.props";
inline constexpr StringLiteral FileVcpkgUserTargets = "vcpkg.user.targets";
@@ -370,9 +371,9 @@ namespace vcpkg
inline constexpr StringLiteral CMakeVariableAllFeatures = "ALL_FEATURES";
inline constexpr StringLiteral CMakeVariableBaseVersion = "VCPKG_BASE_VERSION";
inline constexpr StringLiteral CMakeVariableBuildType = "VCPKG_BUILD_TYPE";
inline constexpr StringLiteral CMakeVariableChainloadToolchainFile = "VCPKG_CHAINLOAD_TOOLCHAIN_FILE";
inline constexpr StringLiteral CMakeVariableCMakeSystemName = "VCPKG_CMAKE_SYSTEM_NAME";
inline constexpr StringLiteral CMakeVariableCMakeSystemVersion = "VCPKG_CMAKE_SYSTEM_VERSION";
inline constexpr StringLiteral CMakeVariableChainloadToolchainFile = "VCPKG_CHAINLOAD_TOOLCHAIN_FILE";
inline constexpr StringLiteral CMakeVariableCmd = "CMD";
inline constexpr StringLiteral CMakeVariableCompilerCacheFile = "VCPKG_COMPILER_CACHE_FILE";
inline constexpr StringLiteral CMakeVariableConcurrency = "VCPKG_CONCURRENCY";
@@ -445,9 +446,9 @@ namespace vcpkg
inline constexpr StringLiteral CMakeVariableVisualStudioPath = "VCPKG_VISUAL_STUDIO_PATH";
inline constexpr StringLiteral CMakeVariableXBoxConsoleTarget = "VCPKG_XBOX_CONSOLE_TARGET";
inline constexpr StringLiteral CMakeVariableZChainloadToolchainFile = "Z_VCPKG_CHAINLOAD_TOOLCHAIN_FILE";
inline constexpr StringLiteral CMakeVariableZPostPortfileIncludes = "Z_VCPKG_POST_PORTFILE_INCLUDES";
inline constexpr StringLiteral CMakeVariableZVcpkgGameDKLatest = "Z_VCPKG_GameDKLatest";
inline constexpr StringLiteral CMakeVariableZVcpkgGameDKXboxLatest = "Z_VCPKG_GameDKXboxLatest";
inline constexpr StringLiteral CMakeVariableZPostPortfileIncludes = "Z_VCPKG_POST_PORTFILE_INCLUDES";
// Policies are PascalCase
inline constexpr StringLiteral PolicyAllowDebugInclude = "PolicyAllowDebugInclude";
@@ -508,11 +509,11 @@ namespace vcpkg
inline constexpr StringLiteral EnvironmentVariableHome = "HOME";
inline constexpr StringLiteral EnvironmentVariableHttpProxy = "HTTP_PROXY";
inline constexpr StringLiteral EnvironmentVariableHttpsProxy = "HTTPS_PROXY";
inline constexpr StringLiteral EnvironmentVariableNoProxy = "NO_PROXY";
inline constexpr StringLiteral EnvironmentVariableInclude = "INCLUDE";
inline constexpr StringLiteral EnvironmentVariableJenkinsHome = "JENKINS_HOME";
inline constexpr StringLiteral EnvironmentVariableJenkinsUrl = "JENKINS_URL";
inline constexpr StringLiteral EnvironmentVariableLocalAppData = "LOCALAPPDATA";
inline constexpr StringLiteral EnvironmentVariableNoProxy = "NO_PROXY";
inline constexpr StringLiteral EnvironmentVariableOverlayTriplets = "VCPKG_OVERLAY_TRIPLETS";
inline constexpr StringLiteral EnvironmentVariablePath = "PATH";
inline constexpr StringLiteral EnvironmentVariablePlatform = "Platform";
@@ -527,6 +528,7 @@ namespace vcpkg
inline constexpr StringLiteral EnvironmentVariableTravis = "TRAVIS";
inline constexpr StringLiteral EnvironmentVariableUserprofile = "USERPROFILE";
inline constexpr StringLiteral EnvironmentVariableVCInstallDir = "VCINSTALLDIR";
inline constexpr StringLiteral EnvironmentVariableVSCmdSkipSendTelemetry = "VSCMD_SKIP_SENDTELEMETRY";
inline constexpr StringLiteral EnvironmentVariableVcpkgBinarySources = "VCPKG_BINARY_SOURCES";
inline constexpr StringLiteral EnvironmentVariableVcpkgCommand = "VCPKG_COMMAND";
inline constexpr StringLiteral EnvironmentVariableVcpkgDefaultBinaryCache = "VCPKG_DEFAULT_BINARY_CACHE";
@@ -545,9 +547,8 @@ namespace vcpkg
inline constexpr StringLiteral EnvironmentVariableVcpkgRoot = "VCPKG_ROOT";
inline constexpr StringLiteral EnvironmentVariableVcpkgUseNuGetCache = "VCPKG_USE_NUGET_CACHE";
inline constexpr StringLiteral EnvironmentVariableVcpkgVisualStudioPath = "VCPKG_VISUAL_STUDIO_PATH";
inline constexpr StringLiteral EnvironmentVariableVscmdArgTgtArch = "VSCMD_ARG_TGT_ARCH";
inline constexpr StringLiteral EnvironmentVariableVSCmdSkipSendTelemetry = "VSCMD_SKIP_SENDTELEMETRY";
inline constexpr StringLiteral EnvironmentVariableVsLang = "VSLANG";
inline constexpr StringLiteral EnvironmentVariableVscmdArgTgtArch = "VSCMD_ARG_TGT_ARCH";
inline constexpr StringLiteral EnvironmentVariableXVcpkgAssetSources = "X_VCPKG_ASSET_SOURCES";
inline constexpr StringLiteral EnvironmentVariableXVcpkgIgnoreLockFailures = "X_VCPKG_IGNORE_LOCK_FAILURES";
inline constexpr StringLiteral EnvironmentVariableXVcpkgNuGetIDPrefix = "X_VCPKG_NUGET_ID_PREFIX";
@@ -566,19 +567,19 @@ namespace vcpkg
inline constexpr StringLiteral FeatureFlagRegistries = "registries";
inline constexpr StringLiteral FeatureFlagVersions = "versions";
inline constexpr StringLiteral MarkerCompilerHash = "#COMPILER_HASH#";
inline constexpr StringLiteral MarkerCompilerCxxVersion = "#COMPILER_CXX_VERSION#";
inline constexpr StringLiteral MarkerCompilerCxxId = "#COMPILER_CXX_ID#";
inline constexpr StringLiteral MarkerCompilerCxxVersion = "#COMPILER_CXX_VERSION#";
inline constexpr StringLiteral MarkerCompilerHash = "#COMPILER_HASH#";
inline constexpr StringLiteral AbiTagCMake = "cmake";
inline constexpr StringLiteral AbiTagFeatures = "features";
inline constexpr StringLiteral AbiTagGrdkH = "grdk.h";
inline constexpr StringLiteral AbiTagTriplet = "triplet";
inline constexpr StringLiteral AbiTagTripletAbi = "triplet_abi";
inline constexpr StringLiteral AbiTagPortsDotCMake = "ports.cmake";
inline constexpr StringLiteral AbiTagPostBuildChecks = "post_build_checks";
inline constexpr StringLiteral AbiTagPowershell = "powershell";
inline constexpr StringLiteral AbiTagSbomInfo = "sbom_info";
inline constexpr StringLiteral AbiTagTriplet = "triplet";
inline constexpr StringLiteral AbiTagTripletAbi = "triplet_abi";
inline constexpr StringLiteral StatusDeinstall = "deinstall";
inline constexpr StringLiteral StatusError = "error";
@@ -590,7 +591,7 @@ namespace vcpkg
inline constexpr StringLiteral StatusPurge = "purge";
// App Insights JSON response fields
inline constexpr StringLiteral AppInsightsResponseItemsReceived = "itemsReceived";
inline constexpr StringLiteral AppInsightsResponseItemsAccepted = "itemsAccepted";
inline constexpr StringLiteral AppInsightsResponseErrors = "errors";
inline constexpr StringLiteral AppInsightsResponseItemsAccepted = "itemsAccepted";
inline constexpr StringLiteral AppInsightsResponseItemsReceived = "itemsReceived";
}
+2 -2
View File
@@ -364,8 +364,8 @@ namespace vcpkg
const Path& lockfile) const = 0;
// waits, at most, 1.5 seconds, for the file lock
virtual Optional<std::unique_ptr<IExclusiveFileLock>> try_take_exclusive_file_lock(
DiagnosticContext& context, const Path& lockfile) const = 0;
virtual std::unique_ptr<IExclusiveFileLock> try_take_exclusive_file_lock(DiagnosticContext& context,
const Path& lockfile) const = 0;
virtual WriteFilePointer open_for_write(const Path& file_path, Append append, std::error_code& ec) const = 0;
WriteFilePointer open_for_write(const Path& file_path, Append append, LineInfo li) const;
+4 -1
View File
@@ -1357,7 +1357,10 @@ DECLARE_MESSAGE(FailedToParseSerializedBinParagraph,
"with the following output:\n{error_msg}\nSerialized Binary Paragraph:")
DECLARE_MESSAGE(FailedToStoreBackToMirror, (msg::path, msg::url), "", "Failed to store {path} to {url}.")
DECLARE_MESSAGE(FailedToStoreBinaryCache, (msg::path), "", "Failed to store binary cache {path}")
DECLARE_MESSAGE(FailedToTakeFileSystemLock, (), "", "Failed to take the filesystem lock")
DECLARE_MESSAGE(FailedToTakeInstalledLock,
(),
"",
"failed to take lock, another vcpkg may be running against the same installed tree")
DECLARE_MESSAGE(FailedVendorAuthentication,
(msg::vendor, msg::url),
"",
+2
View File
@@ -344,4 +344,6 @@ namespace vcpkg::Strings
LinesStream stream;
std::vector<std::string> lines;
};
std::string shorten_text(StringView desc, const size_t length);
}
+5 -1
View File
@@ -5,6 +5,7 @@
#include <vcpkg/base/fwd/span.h>
#include <vcpkg/fwd/dependencies.h>
#include <vcpkg/fwd/installeddatabase.h>
#include <vcpkg/fwd/packagespec.h>
#include <vcpkg/fwd/portfileprovider.h>
#include <vcpkg/fwd/triplet.h>
@@ -39,5 +40,8 @@ namespace vcpkg::CMakeVars
void load_tag_vars(const std::vector<InstallPlanAction>& install_actions, Triplet host_triplet) const;
};
std::unique_ptr<CMakeVarProvider> make_triplet_cmake_var_provider(const VcpkgPaths& paths);
// Ideally, buildtrees would have its own locks rather than reusing the installed database lock; this behavior
// attempts to match previous versions of vcpkg which used one lock on VCPKG_ROOT.
std::unique_ptr<CMakeVarProvider> make_triplet_cmake_var_provider(const VcpkgPaths& paths,
const InstalledDatabaseLock& /* witness */);
}
+3
View File
@@ -7,6 +7,7 @@
#include <vcpkg/fwd/cmakevars.h>
#include <vcpkg/fwd/commands.install.h>
#include <vcpkg/fwd/dependencies.h>
#include <vcpkg/fwd/installeddatabase.h>
#include <vcpkg/fwd/portfileprovider.h>
#include <vcpkg/fwd/vcpkgcmdarguments.h>
@@ -80,6 +81,7 @@ namespace vcpkg
const VcpkgPaths& paths,
Triplet host_triplet,
const BuildPackageOptions& build_options,
const InstalledDatabaseLock& installed_lock,
const FullPackageSpec& full_spec,
const PathsPortFileProvider& provider,
const IBuildLogsRecorder& build_logs_recorder);
@@ -87,6 +89,7 @@ namespace vcpkg
const VcpkgPaths& paths,
Triplet host_triplet,
const BuildPackageOptions& build_options,
const InstalledDatabaseLock& installed_lock,
const FullPackageSpec& full_spec,
const PathsPortFileProvider& provider,
const IBuildLogsRecorder& build_logs_recorder);
+2
View File
@@ -2,6 +2,7 @@
#include <vcpkg/fwd/binaryparagraph.h>
#include <vcpkg/fwd/commands.install.h>
#include <vcpkg/fwd/installeddatabase.h>
#include <vcpkg/fwd/installedpaths.h>
#include <vcpkg/fwd/vcpkgcmdarguments.h>
#include <vcpkg/fwd/vcpkgpaths.h>
@@ -129,6 +130,7 @@ namespace vcpkg
const VcpkgPaths& paths,
Triplet host_triplet,
const BuildPackageOptions& build_options,
const InstalledDatabaseLock& installed_lock,
const ActionPlan& action_plan,
StatusParagraphs& status_db,
BinaryCache& binary_cache,
+2
View File
@@ -7,6 +7,7 @@
#include <vcpkg/fwd/cmakevars.h>
#include <vcpkg/fwd/commands.install.h>
#include <vcpkg/fwd/dependencies.h>
#include <vcpkg/fwd/installeddatabase.h>
#include <vcpkg/fwd/statusparagraphs.h>
#include <vcpkg/fwd/triplet.h>
#include <vcpkg/fwd/vcpkgcmdarguments.h>
@@ -38,6 +39,7 @@ namespace vcpkg
Triplet host_triplet,
const BuildPackageOptions& build_options,
const CMakeVars::CMakeVarProvider& cmake_vars,
const InstalledDatabaseLock& installed_lock,
ActionPlan action_plan,
DryRun dry_run,
PrintUsage print_usage,
+6
View File
@@ -0,0 +1,6 @@
#pragma once
namespace vcpkg
{
struct InstalledDatabaseLock;
}
@@ -2,22 +2,48 @@
#include <vcpkg/base/fwd/files.h>
#include <vcpkg/fwd/installeddatabase.h>
#include <vcpkg/fwd/installedpaths.h>
#include <vcpkg/fwd/statusparagraphs.h>
#include <vcpkg/statusparagraph.h>
#include <memory>
#include <string>
namespace vcpkg
{
// When vcpkg does anything that needs to look at an installed database, it must take this
// filesystem lock to protect itself from concurrent modification of the same installed tree
// by competing vcpkg instances.
struct InstalledDatabaseLock
{
InstalledDatabaseLock(const Filesystem& fs,
const InstalledPaths& installed,
const Optional<bool>& wait_for_lock,
const Optional<bool>& ignore_lock_failures);
~InstalledDatabaseLock();
InstalledDatabaseLock(const InstalledDatabaseLock&) = delete;
InstalledDatabaseLock& operator=(const InstalledDatabaseLock&) = delete;
private:
std::unique_ptr<IExclusiveFileLock> m_lock;
};
// Read the status database
StatusParagraphs database_load(const ReadOnlyFilesystem& fs, const InstalledPaths& installed);
StatusParagraphs database_load(const ReadOnlyFilesystem& fs,
const InstalledPaths& installed,
const InstalledDatabaseLock& /*witness*/);
// Read the status database, and collapse update records into the current status file
StatusParagraphs database_load_collapse(const Filesystem& fs, const InstalledPaths& installed);
StatusParagraphs database_sync(const Filesystem& fs,
const InstalledPaths& installed,
const InstalledDatabaseLock& /*witness*/);
// Adds an update record
void write_update(const Filesystem& fs, const InstalledPaths& installed, const StatusParagraph& p);
void database_write_update(const Filesystem& fs, const InstalledPaths& installed, const StatusParagraph& p);
std::vector<InstalledPackageView> get_installed_ports(const StatusParagraphs& status_db);
struct StatusParagraphAndAssociatedFiles
{
@@ -25,8 +51,6 @@ namespace vcpkg
std::vector<std::string> files;
};
std::vector<InstalledPackageView> get_installed_ports(const StatusParagraphs& status_db);
// Reads the installed files from the status database.
std::vector<StatusParagraphAndAssociatedFiles> get_installed_files(const ReadOnlyFilesystem& fs,
const InstalledPaths& installed,
@@ -36,6 +60,4 @@ namespace vcpkg
std::vector<StatusParagraphAndAssociatedFiles> get_installed_files_and_upgrade(const Filesystem& fs,
const InstalledPaths& installed,
const StatusParagraphs& status_db);
std::string shorten_text(StringView desc, const size_t length);
} // namespace vcpkg
+51 -4
View File
@@ -1,5 +1,7 @@
#pragma once
#include <vcpkg/base/fwd/files.h>
#include <vcpkg/fwd/binaryparagraph.h>
#include <vcpkg/base/contractual-constants.h>
@@ -14,16 +16,61 @@ namespace vcpkg
{
explicit InstalledPaths(Path&& root) : m_root(std::move(root)) { }
// A vcpkg "installed" tree consists of installed contents and a database that describes what is installed.
//
// The paths below assume root() is / (that is, typically vcpkg_dir/installed or vcpkg.json_dir/vcpkg_installed)
const Path& root() const { return m_root; }
Path listfile_path(const BinaryParagraph& pgh) const;
// Creates the minimum directory structure for an installed tree.
void create_directories(const Filesystem& fs) const;
Path vcpkg_dir() const { return m_root / FileVcpkg; }
Path vcpkg_dir_status_file() const { return vcpkg_dir() / FileStatus; }
Path vcpkg_dir_info() const { return vcpkg_dir() / FileInfo; }
Path vcpkg_dir_updates() const { return vcpkg_dir() / FileUpdates; }
// /vcpkg/compiler-file-hash-cache.json, caches the SHA of detected compilers as that is expensive on platforms
// where the compiler binary is often ~60MB or more
Path compiler_hash_cache_file() const { return vcpkg_dir() / FileCompilerFileHashCacheDotJson; }
// /vcpkg/issue_body.md, where the body of a GitHub issue is written on install failure to make it convenient
// for users to pass to `gh`
Path issue_body_path() const { return vcpkg_dir() / FileIssueBodyMD; }
// vcpkg/vcpkg-lock.json stores information about data fetched in resolving registry references
// (this is the 'npm lockfile' meaning of lockfile, not a file system lock)
Path lockfile_path() const { return vcpkg_dir() / FileVcpkgLock; }
// vcpkg/manifest-info.json, stores the path to the manifest file from which an installed tree was generated;
// this helps tools like component governance that want to report errors about dependencies detected in this
// installed tree be reported in the file that led to them being installed.
Path manifest_info_path() const { return vcpkg_dir() / FileManifestInfo; }
// /vcpkg/info/<name>_<version_<triplet>.list, contains a list of every file installed by a given package
// These list files are created by install_files_and_write_listfile
Path vcpkg_dir_info() const { return vcpkg_dir() / FileInfo; }
Path listfile_path(const BinaryParagraph& pgh) const;
// /vcpkg/status contains information about which packages are installed in this tree
Path vcpkg_dir_status_file() const { return vcpkg_dir() / FileStatus; }
// /vcpkg/updates/*
// rolling updates to the status file, written by database_write_update.
Path vcpkg_dir_updates() const { return vcpkg_dir() / FileUpdates; }
// database_load will read status and the updates to have information about what this installed tree currently
// contains database_sync will also collapse all the update files into the status file, and delete the
// update files. This avoids the status database being corrupted if vcpkg is terminated while it is running
// (each update is written immediately after each port install and the results merged only at the end)
// /vcpkg/vcpkg-running.lock is a file system lock used to synchronize access to the installed tree
Path vcpkg_running_lock() const { return vcpkg_dir() / FileVcpkgRunningLock; }
// /<triplet> is the root for user facing contents associated with <triplet>
// for example, /x64-windows/include/zlib.h would be the path to zlib's public header when installed for
// x64-windows
Path triplet_dir(Triplet t) const { return m_root / t.canonical_name(); }
// /<triplet>/<share>/<name> typically stores build system bindings for <name> and some communication to
// vcpkg, for example:
// /<triplet>/share/<name>/copyright stores the license information for <name>
// /<triplet>/share/<name>/usage provides for customized usage
// /<triplet>/share/<name>/vcpkg_abi_info.txt is the file hashed to form a package ABI
// /<triplet>/share/<name>/vcpkg.spdx.json stores information about what should be included in an SBOM for
// that package
// /<triplet>/share/<name>/vcpkg-port-config.cmake is included automatically in ports that directly depend on
// <name>
Path share_dir(const PackageSpec& p) const { return triplet_dir(p.triplet()) / FileShare / p.name(); }
Path usage_file(const PackageSpec& p) const { return share_dir(p) / FileUsage; }
Path spdx_file(const PackageSpec& p) const { return share_dir(p) / FileVcpkgSpdxJson; }
-2
View File
@@ -264,8 +264,6 @@ namespace vcpkg
Optional<bool> ignore_lock_failures = nullopt;
bool do_not_take_lock = false;
Optional<std::string> github_run_id;
Optional<std::string> github_token;
Optional<std::string> github_job;
-2
View File
@@ -85,10 +85,8 @@ namespace vcpkg
public:
const Path& scripts;
const Path& downloads;
const Path& tools;
const Path builtin_registry_versions;
ExpectedL<Path> versions_dot_git_dir() const;
const Path prefab;
const Path buildsystems;
const Path buildsystems_msbuild_targets;
const Path buildsystems_msbuild_props;
+1 -1
View File
@@ -811,7 +811,7 @@
"_FailedToStoreBackToMirror.comment": "An example of {path} is /foo/bar. An example of {url} is https://github.com/microsoft/vcpkg.",
"FailedToStoreBinaryCache": "Failed to store binary cache {path}",
"_FailedToStoreBinaryCache.comment": "An example of {path} is /foo/bar.",
"FailedToTakeFileSystemLock": "Failed to take the filesystem lock",
"FailedToTakeInstalledLock": "failed to take lock, another vcpkg may be running against the same installed tree",
"FailedVendorAuthentication": "One or more {vendor} credential providers failed to authenticate. See '{url}' for more details on how to provide credentials.",
"_FailedVendorAuthentication.comment": "An example of {vendor} is Azure. An example of {url} is https://github.com/microsoft/vcpkg.",
"FeatureBaselineEntryAlreadySpecified": "'{feature}' was already declared as '{value}'",
+20
View File
@@ -306,3 +306,23 @@ TEST_CASE ("ascii to utf16", "[utf16]")
}
}
#endif
TEST_CASE ("shorten_text", "[strings]")
{
using Strings::shorten_text;
REQUIRE(shorten_text("", 3) == "");
REQUIRE(shorten_text(" hello\t\tworld \n", 20) == "hello world");
REQUIRE(shorten_text("hello world", 11) == "hello world");
REQUIRE(shorten_text(" hello world", 11) == "hello world");
REQUIRE(shorten_text(" hello world", 11) == "hello world");
REQUIRE(shorten_text("hello world ", 11) == "hello world");
REQUIRE(shorten_text("hello world ", 11) == "hello world");
REQUIRE(shorten_text("hello world", 10) == "hello w...");
REQUIRE(shorten_text("abc", 3) == "abc");
REQUIRE(shorten_text("abcd", 3) == "...");
REQUIRE(shorten_text("hello there world ", 16) == "hello there w...");
REQUIRE(shorten_text("hello there world", 17) == "hello there world");
REQUIRE(shorten_text("hello there world ", 17) == "hello there world");
REQUIRE(shorten_text("hello there world ", 18) == "hello there world");
}
+7 -7
View File
@@ -4296,15 +4296,15 @@ namespace vcpkg
}
}
virtual Optional<std::unique_ptr<IExclusiveFileLock>> try_take_exclusive_file_lock(
DiagnosticContext& context, const Path& lockfile) const override
virtual std::unique_ptr<IExclusiveFileLock> try_take_exclusive_file_lock(DiagnosticContext& context,
const Path& lockfile) const override
{
std::error_code ec;
auto result = std::make_unique<ExclusiveFileLock>(lockfile, ec);
if (ec)
{
context.report_error(format_filesystem_call_error(ec, "try_take_exclusive_file_lock", {lockfile}));
return nullopt;
return nullptr;
}
// waits, at most, a second and a half.
@@ -4315,7 +4315,7 @@ namespace vcpkg
auto attempt = maybe_attempt.get();
if (!attempt)
{
return nullopt;
return nullptr;
}
if (*attempt)
@@ -4605,8 +4605,8 @@ namespace vcpkg
return nullptr;
}
Optional<std::unique_ptr<IExclusiveFileLock>> try_take_exclusive_file_lock(DiagnosticContext& context,
const Path&) const override
std::unique_ptr<IExclusiveFileLock> try_take_exclusive_file_lock(DiagnosticContext& context,
const Path&) const override
{
context.report_system_error("try_take_exclusive_file_lock",
#if defined(_WIN32)
@@ -4616,7 +4616,7 @@ namespace vcpkg
#endif
);
return nullopt;
return nullptr;
}
WriteFilePointer open_for_write(const Path&, Append, std::error_code& ec) const override
+44
View File
@@ -812,4 +812,48 @@ namespace vcpkg::Strings
stream.on_end(CB{this});
return std::move(this->lines);
}
std::string shorten_text(StringView desc, const size_t length)
{
// replace all sequences of whitespace with a single space, and trim leading/trailing whitespace
static constexpr size_t dot_length = 3;
Checks::check_exit(VCPKG_LINE_INFO, length >= dot_length);
std::string simple_desc;
simple_desc.reserve(length);
bool previous_whitespace = false;
auto last = desc.end();
auto first = std::find_if_not(desc.begin(), last, ParserBase::is_whitespace);
for (; first != last; ++first)
{
const auto ch = *first;
if (ParserBase::is_whitespace(ch))
{
previous_whitespace = true;
continue;
}
if (previous_whitespace)
{
previous_whitespace = false;
if (simple_desc.size() == length)
{
std::fill_n(simple_desc.end() - dot_length, dot_length, '.');
return simple_desc;
}
simple_desc.push_back(' ');
}
if (simple_desc.size() == length)
{
std::fill_n(simple_desc.end() - dot_length, dot_length, '.');
return simple_desc;
}
simple_desc.push_back(ch);
}
return simple_desc;
}
}
+2 -1
View File
@@ -79,7 +79,8 @@ namespace vcpkg::CMakeVars
};
}
std::unique_ptr<CMakeVarProvider> make_triplet_cmake_var_provider(const vcpkg::VcpkgPaths& paths)
std::unique_ptr<CMakeVarProvider> make_triplet_cmake_var_provider(const vcpkg::VcpkgPaths& paths,
const InstalledDatabaseLock& /* witness */)
{
return std::make_unique<TripletCMakeVarProvider>(paths);
}
-1
View File
@@ -10,7 +10,6 @@
#include <vcpkg/metrics.h>
#include <vcpkg/paragraphs.h>
#include <vcpkg/vcpkgcmdarguments.h>
#include <vcpkg/vcpkglib.h>
#include <vcpkg/vcpkgpaths.h>
#include <string>
+4 -1
View File
@@ -1,6 +1,7 @@
#include <vcpkg/commands.build-external.h>
#include <vcpkg/commands.build.h>
#include <vcpkg/input.h>
#include <vcpkg/installeddatabase.h>
#include <vcpkg/portfileprovider.h>
#include <vcpkg/registries.h>
#include <vcpkg/vcpkgcmdarguments.h>
@@ -47,6 +48,8 @@ namespace vcpkg
auto& fs = paths.get_filesystem();
auto registry_set = paths.make_registry_set();
PathsPortFileProvider provider(*registry_set, make_overlay_provider(fs, overlays));
command_build_and_exit_ex(args, paths, host_triplet, build_options, spec, provider, null_build_logs_recorder);
InstalledDatabaseLock installed_lock{fs, paths.installed(), args.wait_for_lock, args.ignore_lock_failures};
command_build_and_exit_ex(
args, paths, host_triplet, build_options, installed_lock, spec, provider, null_build_logs_recorder);
}
}
+9 -4
View File
@@ -24,6 +24,7 @@
#include <vcpkg/dependencies.h>
#include <vcpkg/documentation.h>
#include <vcpkg/input.h>
#include <vcpkg/installeddatabase.h>
#include <vcpkg/installedpaths.h>
#include <vcpkg/metrics.h>
#include <vcpkg/paragraphs.h>
@@ -34,7 +35,6 @@
#include <vcpkg/statusparagraphs.h>
#include <vcpkg/tools.h>
#include <vcpkg/vcpkgcmdarguments.h>
#include <vcpkg/vcpkglib.h>
#include <vcpkg/vcpkgpaths.h>
#include <iterator>
@@ -176,13 +176,15 @@ namespace vcpkg
const VcpkgPaths& paths,
Triplet host_triplet,
const BuildPackageOptions& build_options,
const InstalledDatabaseLock& installed_lock,
const FullPackageSpec& full_spec,
const PathsPortFileProvider& provider,
const IBuildLogsRecorder& build_logs_recorder)
{
Checks::exit_with_code(
VCPKG_LINE_INFO,
command_build_ex(args, paths, host_triplet, build_options, full_spec, provider, build_logs_recorder));
command_build_ex(
args, paths, host_triplet, build_options, installed_lock, full_spec, provider, build_logs_recorder));
}
constexpr CommandMetadata CommandBuildMetadata{
@@ -221,11 +223,13 @@ namespace vcpkg
auto& fs = paths.get_filesystem();
auto registry_set = paths.make_registry_set();
PathsPortFileProvider provider(*registry_set, make_overlay_provider(fs, paths.overlay_ports));
InstalledDatabaseLock installed_lock{fs, paths.installed(), args.wait_for_lock, args.ignore_lock_failures};
Checks::exit_with_code(VCPKG_LINE_INFO,
command_build_ex(args,
paths,
host_triplet,
build_command_build_package_options,
installed_lock,
spec,
provider,
null_build_logs_recorder));
@@ -235,17 +239,18 @@ namespace vcpkg
const VcpkgPaths& paths,
Triplet host_triplet,
const BuildPackageOptions& build_options,
const InstalledDatabaseLock& installed_lock,
const FullPackageSpec& full_spec,
const PathsPortFileProvider& provider,
const IBuildLogsRecorder& build_logs_recorder)
{
const PackageSpec& spec = full_spec.package_spec;
auto var_provider_storage = CMakeVars::make_triplet_cmake_var_provider(paths);
auto var_provider_storage = CMakeVars::make_triplet_cmake_var_provider(paths, installed_lock);
auto& var_provider = *var_provider_storage;
var_provider.load_dep_info_vars({{spec}}, host_triplet);
auto& fs = paths.get_filesystem();
StatusParagraphs status_db = database_load_collapse(fs, paths.installed());
StatusParagraphs status_db = database_sync(fs, paths.installed(), installed_lock);
PackagesDirAssigner packages_dir_assigner{paths.packages()};
auto action_plan = create_feature_install_plan(
provider,
+3 -1
View File
@@ -7,6 +7,7 @@
#include <vcpkg/commands.check-support.h>
#include <vcpkg/dependencies.h>
#include <vcpkg/input.h>
#include <vcpkg/installeddatabase.h>
#include <vcpkg/packagespec.h>
#include <vcpkg/platform-expression.h>
#include <vcpkg/portfileprovider.h>
@@ -129,7 +130,8 @@ namespace vcpkg
auto& fs = paths.get_filesystem();
auto registry_set = paths.make_registry_set();
PathsPortFileProvider provider(*registry_set, make_overlay_provider(fs, paths.overlay_ports));
auto cmake_vars = CMakeVars::make_triplet_cmake_var_provider(paths);
InstalledDatabaseLock installed_lock{fs, paths.installed(), args.wait_for_lock, args.ignore_lock_failures};
auto cmake_vars = CMakeVars::make_triplet_cmake_var_provider(paths, installed_lock);
// for each spec in the user-requested specs, check all dependencies
CreateInstallPlanOptions create_options{
+14 -5
View File
@@ -15,13 +15,13 @@
#include <vcpkg/commands.install.h>
#include <vcpkg/commands.set-installed.h>
#include <vcpkg/dependencies.h>
#include <vcpkg/installeddatabase.h>
#include <vcpkg/packagespec.h>
#include <vcpkg/paragraphs.h>
#include <vcpkg/platform-expression.h>
#include <vcpkg/portfileprovider.h>
#include <vcpkg/registries.h>
#include <vcpkg/vcpkgcmdarguments.h>
#include <vcpkg/vcpkglib.h>
#include <vcpkg/vcpkgpaths.h>
#include <vcpkg/xunitwriter.h>
@@ -504,9 +504,11 @@ namespace vcpkg
}
}
InstalledDatabaseLock installed_lock{
paths.get_filesystem(), paths.installed(), args.wait_for_lock, args.ignore_lock_failures};
auto registry_set = paths.make_registry_set();
PathsPortFileProvider provider(*registry_set, make_overlay_provider(fs, paths.overlay_ports));
auto var_provider_storage = CMakeVars::make_triplet_cmake_var_provider(paths);
auto var_provider_storage = CMakeVars::make_triplet_cmake_var_provider(paths, installed_lock);
auto& var_provider = *var_provider_storage;
const ElapsedTimer timer;
@@ -566,7 +568,7 @@ namespace vcpkg
}
else
{
StatusParagraphs status_db = database_load_collapse(fs, paths.installed());
StatusParagraphs status_db = database_sync(fs, paths.installed(), installed_lock);
auto already_installed = adjust_action_plan_to_status_db(action_plan, status_db);
Util::erase_if(already_installed,
[&](const PackageSpec& spec) { return Util::Sets::contains(pre_build_status.known, spec); });
@@ -583,8 +585,15 @@ namespace vcpkg
install_preclear_plan_packages(paths, action_plan);
binary_cache.fetch(console_diagnostic_context, fs, action_plan.install_actions);
auto summary = install_execute_plan(
args, paths, host_triplet, build_options, action_plan, status_db, binary_cache, *build_logs_recorder);
auto summary = install_execute_plan(args,
paths,
host_triplet,
build_options,
installed_lock,
action_plan,
status_db,
binary_cache,
*build_logs_recorder);
msg::println(msgTotalInstallTime, msg::elapsed = summary.elapsed);
for (auto&& result : summary.install_results)
+3 -1
View File
@@ -8,6 +8,7 @@
#include <vcpkg/commands.depend-info.h>
#include <vcpkg/dependencies.h>
#include <vcpkg/input.h>
#include <vcpkg/installeddatabase.h>
#include <vcpkg/packagespec.h>
#include <vcpkg/portfileprovider.h>
#include <vcpkg/registries.h>
@@ -408,7 +409,8 @@ namespace vcpkg
auto& fs = paths.get_filesystem();
auto registry_set = paths.make_registry_set();
PathsPortFileProvider provider(*registry_set, make_overlay_provider(fs, paths.overlay_ports));
auto var_provider_storage = CMakeVars::make_triplet_cmake_var_provider(paths);
InstalledDatabaseLock installed_lock{fs, paths.installed(), args.wait_for_lock, args.ignore_lock_failures};
auto var_provider_storage = CMakeVars::make_triplet_cmake_var_provider(paths, installed_lock);
auto& var_provider = *var_provider_storage;
// By passing an empty status_db, we should get a plan containing all dependencies.
+6 -1
View File
@@ -6,6 +6,7 @@
#include <vcpkg/cmakevars.h>
#include <vcpkg/commands.build.h>
#include <vcpkg/commands.env.h>
#include <vcpkg/installeddatabase.h>
#include <vcpkg/installedpaths.h>
#include <vcpkg/portfileprovider.h>
#include <vcpkg/registries.h>
@@ -95,7 +96,10 @@ namespace vcpkg
auto registry_set = paths.make_registry_set();
PathsPortFileProvider provider(*registry_set, make_overlay_provider(fs, paths.overlay_ports));
auto var_provider_storage = CMakeVars::make_triplet_cmake_var_provider(paths);
Optional<InstalledDatabaseLock> installed_lock_storage;
auto& installed_lock =
installed_lock_storage.emplace(fs, paths.installed(), args.wait_for_lock, args.ignore_lock_failures);
auto var_provider_storage = CMakeVars::make_triplet_cmake_var_provider(paths, installed_lock);
auto& var_provider = *var_provider_storage;
var_provider.load_generic_triplet_vars(triplet);
@@ -151,6 +155,7 @@ namespace vcpkg
cmd.string_arg("/c").raw_arg(options.command_arguments[0]);
}
installed_lock_storage.clear(); // release the lock before launching the subprocess
enter_interactive_subprocess();
auto rc = cmd_execute(cmd, settings);
exit_interactive_subprocess();
+4 -2
View File
@@ -10,12 +10,12 @@
#include <vcpkg/commands.install.h>
#include <vcpkg/dependencies.h>
#include <vcpkg/input.h>
#include <vcpkg/installeddatabase.h>
#include <vcpkg/installedpaths.h>
#include <vcpkg/portfileprovider.h>
#include <vcpkg/registries.h>
#include <vcpkg/tools.h>
#include <vcpkg/vcpkgcmdarguments.h>
#include <vcpkg/vcpkglib.h>
#include <vcpkg/vcpkgpaths.h>
using namespace vcpkg;
@@ -539,7 +539,9 @@ namespace vcpkg
Triplet host_triplet)
{
(void)host_triplet;
const StatusParagraphs status_db = database_load(paths.get_filesystem(), paths.installed());
InstalledDatabaseLock installed_lock{
paths.get_filesystem(), paths.installed(), args.wait_for_lock, args.ignore_lock_failures};
const StatusParagraphs status_db = database_load(paths.get_filesystem(), paths.installed(), installed_lock);
const auto opts = handle_export_command_arguments(paths, args, default_triplet, status_db);
// Load ports from ports dirs
+2 -3
View File
@@ -13,7 +13,6 @@
#include <vcpkg/registries.h>
#include <vcpkg/sourceparagraph.h>
#include <vcpkg/vcpkgcmdarguments.h>
#include <vcpkg/vcpkglib.h>
#include <vcpkg/vcpkgpaths.h>
using namespace vcpkg;
@@ -71,7 +70,7 @@ namespace
source_paragraph.name,
ver_size,
full_version,
vcpkg::shorten_text(description, description_size)));
Strings::shorten_text(description, description_size)));
}
}
@@ -97,7 +96,7 @@ namespace
fmt::format("{1:{0}} {2}\n",
s_name_and_ver_columns,
full_feature_name,
vcpkg::shorten_text(description, desc_length)));
Strings::shorten_text(description, desc_length)));
}
}
+13 -10
View File
@@ -21,13 +21,13 @@
#include <vcpkg/dependencies.h>
#include <vcpkg/documentation.h>
#include <vcpkg/input.h>
#include <vcpkg/installeddatabase.h>
#include <vcpkg/installedpaths.h>
#include <vcpkg/metrics.h>
#include <vcpkg/paragraphs.h>
#include <vcpkg/portfileprovider.h>
#include <vcpkg/tools.h>
#include <vcpkg/vcpkgcmdarguments.h>
#include <vcpkg/vcpkglib.h>
#include <vcpkg/vcpkgpaths.h>
#include <vcpkg/xunitwriter.h>
@@ -356,7 +356,7 @@ namespace vcpkg
source_paragraph.package = bcf_core_paragraph;
source_paragraph.status = StatusLine{Want::INSTALL, InstallState::HALF_INSTALLED};
write_update(fs, installed, source_paragraph);
database_write_update(fs, installed, source_paragraph);
status_db.insert(std::make_unique<StatusParagraph>(source_paragraph));
std::vector<StatusParagraph> features_spghs;
@@ -366,7 +366,7 @@ namespace vcpkg
feature_paragraph.package = feature;
feature_paragraph.status = StatusLine{Want::INSTALL, InstallState::HALF_INSTALLED};
write_update(fs, installed, feature_paragraph);
database_write_update(fs, installed, feature_paragraph);
status_db.insert(std::make_unique<StatusParagraph>(feature_paragraph));
}
@@ -379,13 +379,13 @@ namespace vcpkg
SymlinkHydrate::CopySymlinks);
source_paragraph.status.state = InstallState::INSTALLED;
write_update(fs, installed, source_paragraph);
database_write_update(fs, installed, source_paragraph);
status_db.insert(std::make_unique<StatusParagraph>(source_paragraph));
for (auto&& feature_paragraph : features_spghs)
{
feature_paragraph.status.state = InstallState::INSTALLED;
write_update(fs, installed, feature_paragraph);
database_write_update(fs, installed, feature_paragraph);
status_db.insert(std::make_unique<StatusParagraph>(feature_paragraph));
}
@@ -610,6 +610,7 @@ namespace vcpkg
const VcpkgPaths& paths,
Triplet host_triplet,
const BuildPackageOptions& build_options,
const InstalledDatabaseLock& installed_lock,
const ActionPlan& action_plan,
StatusParagraphs& status_db,
BinaryCache& binary_cache,
@@ -706,7 +707,7 @@ namespace vcpkg
paths,
result.build_result.error_logs,
result.build_result.stdoutlog.then([&](auto&) -> Optional<Path> {
auto issue_body_path = paths.installed().root() / FileVcpkg / FileIssueBodyMD;
auto issue_body_path = paths.installed().issue_body_path();
paths.get_filesystem().write_contents(
issue_body_path,
create_github_issue(args, paths, result, include_manifest_in_github_issue),
@@ -738,7 +739,7 @@ namespace vcpkg
msg::println(msgElapsedForPackage, msg::spec = action.spec, msg::elapsed = result.timing);
}
database_load_collapse(fs, paths.installed());
database_sync(fs, paths.installed(), installed_lock);
summary.elapsed = timer.elapsed();
return summary;
}
@@ -1284,9 +1285,9 @@ namespace vcpkg
Util::Enum::to_enum<UseHeadVersion>(use_head_version),
Util::Enum::to_enum<Editable>(is_editable)};
auto var_provider_storage = CMakeVars::make_triplet_cmake_var_provider(paths);
InstalledDatabaseLock installed_lock{fs, paths.installed(), args.wait_for_lock, args.ignore_lock_failures};
auto var_provider_storage = CMakeVars::make_triplet_cmake_var_provider(paths, installed_lock);
auto& var_provider = *var_provider_storage;
if (manifest)
{
Optional<Path> pkgsconfig;
@@ -1418,6 +1419,7 @@ namespace vcpkg
host_triplet,
build_package_options,
var_provider,
installed_lock,
std::move(install_plan),
dry_run ? DryRun::Yes : DryRun::No,
print_cmake_usage ? PrintUsage::Yes : PrintUsage::No,
@@ -1435,7 +1437,7 @@ namespace vcpkg
// create the plan
msg::println(msgComputingInstallPlan);
StatusParagraphs status_db = database_load_collapse(fs, paths.installed());
StatusParagraphs status_db = database_sync(fs, paths.installed(), installed_lock);
// Note: action_plan will hold raw pointers to SourceControlFileLocations from this map
auto action_plan = create_feature_install_plan(
@@ -1502,6 +1504,7 @@ namespace vcpkg
paths,
host_triplet,
build_package_options,
installed_lock,
action_plan,
status_db,
binary_cache,
+3 -2
View File
@@ -2,11 +2,11 @@
#include <vcpkg/commands.install.h>
#include <vcpkg/commands.license-report.h>
#include <vcpkg/installeddatabase.h>
#include <vcpkg/installedpaths.h>
#include <vcpkg/spdx.h>
#include <vcpkg/statusparagraphs.h>
#include <vcpkg/vcpkgcmdarguments.h>
#include <vcpkg/vcpkglib.h>
#include <vcpkg/vcpkgpaths.h>
using namespace vcpkg;
@@ -32,8 +32,9 @@ namespace vcpkg
auto&& fs = paths.get_filesystem();
auto&& installed_paths = paths.installed();
InstalledDatabaseLock installed_lock{fs, installed_paths, args.wait_for_lock, args.ignore_lock_failures};
LicenseReport report;
auto status_paragraphs = database_load(fs, installed_paths);
auto status_paragraphs = database_load(fs, installed_paths, installed_lock);
auto installed_ipvs = get_installed_ports(status_paragraphs);
if (installed_ipvs.empty())
{
+8 -5
View File
@@ -4,9 +4,9 @@
#include <vcpkg/base/util.h>
#include <vcpkg/commands.list.h>
#include <vcpkg/installeddatabase.h>
#include <vcpkg/statusparagraphs.h>
#include <vcpkg/vcpkgcmdarguments.h>
#include <vcpkg/vcpkglib.h>
#include <vcpkg/vcpkgpaths.h>
using namespace vcpkg;
@@ -73,9 +73,9 @@ namespace
}
msg::write_unlocalized_text_to_stdout(Color::none,
fmt::format("{:<50}{:<20}{:<}\n",
vcpkg::shorten_text(pgh.package.display_name(), 50),
vcpkg::shorten_text(full_version, 16),
vcpkg::shorten_text(description, 51)));
Strings::shorten_text(pgh.package.display_name(), 50),
Strings::shorten_text(full_version, 16),
Strings::shorten_text(description, 51)));
}
}
@@ -104,7 +104,10 @@ namespace vcpkg
msg::default_output_stream = OutputStream::StdErr;
const ParsedArguments options = args.parse_arguments(CommandListMetadata);
const StatusParagraphs status_paragraphs = database_load(paths.get_filesystem(), paths.installed());
InstalledDatabaseLock installed_lock{
paths.get_filesystem(), paths.installed(), args.wait_for_lock, args.ignore_lock_failures};
const StatusParagraphs status_paragraphs =
database_load(paths.get_filesystem(), paths.installed(), installed_lock);
auto installed_ipv = get_installed_ports(status_paragraphs);
const auto output_json = Util::Sets::contains(options.switches, SwitchXJson);
+4 -2
View File
@@ -1,9 +1,9 @@
#include <vcpkg/base/files.h>
#include <vcpkg/commands.owns.h>
#include <vcpkg/installeddatabase.h>
#include <vcpkg/statusparagraphs.h>
#include <vcpkg/vcpkgcmdarguments.h>
#include <vcpkg/vcpkglib.h>
#include <vcpkg/vcpkgpaths.h>
using namespace vcpkg;
@@ -48,7 +48,9 @@ namespace vcpkg
void command_owns_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths)
{
const auto parsed = args.parse_arguments(CommandOwnsMetadata);
const StatusParagraphs status_db = database_load(paths.get_filesystem(), paths.installed());
InstalledDatabaseLock installed_lock{
paths.get_filesystem(), paths.installed(), args.wait_for_lock, args.ignore_lock_failures};
const StatusParagraphs status_db = database_load(paths.get_filesystem(), paths.installed(), installed_lock);
search_file(paths.get_filesystem(), paths.installed(), parsed.command_arguments[0], status_db);
Checks::exit_success(VCPKG_LINE_INFO);
}
+4 -2
View File
@@ -6,11 +6,11 @@
#include <vcpkg/base/util.h>
#include <vcpkg/commands.package-info.h>
#include <vcpkg/installeddatabase.h>
#include <vcpkg/portfileprovider.h>
#include <vcpkg/registries.h>
#include <vcpkg/statusparagraphs.h>
#include <vcpkg/vcpkgcmdarguments.h>
#include <vcpkg/vcpkglib.h>
#include <vcpkg/vcpkgpaths.h>
using namespace vcpkg;
@@ -61,7 +61,9 @@ namespace vcpkg
auto& fs = paths.get_filesystem();
if (installed)
{
const StatusParagraphs status_paragraphs = database_load(fs, paths.installed());
InstalledDatabaseLock installed_lock{
paths.get_filesystem(), paths.installed(), args.wait_for_lock, args.ignore_lock_failures};
const StatusParagraphs status_paragraphs = database_load(fs, paths.installed(), installed_lock);
std::set<PackageSpec> specs_written;
std::vector<PackageSpec> specs_to_write;
for (auto&& arg : options.command_arguments)
+9 -6
View File
@@ -7,11 +7,11 @@
#include <vcpkg/dependencies.h>
#include <vcpkg/documentation.h>
#include <vcpkg/input.h>
#include <vcpkg/installeddatabase.h>
#include <vcpkg/installedpaths.h>
#include <vcpkg/portfileprovider.h>
#include <vcpkg/registries.h>
#include <vcpkg/vcpkgcmdarguments.h>
#include <vcpkg/vcpkglib.h>
#include <vcpkg/vcpkgpaths.h>
namespace vcpkg
@@ -35,7 +35,7 @@ namespace vcpkg
for (auto&& spgh : spghs)
{
spgh.status = {Want::PURGE, InstallState::HALF_INSTALLED};
write_update(fs, installed, spgh);
database_write_update(fs, installed, spgh);
}
auto maybe_lines = fs.read_lines(installed.listfile_path(ipv.core->package));
@@ -101,7 +101,7 @@ namespace vcpkg
for (auto&& spgh : spghs)
{
spgh.status.state = InstallState::NOT_INSTALLED;
write_update(fs, installed, spgh);
database_write_update(fs, installed, spgh);
status_db.insert(std::make_unique<StatusParagraph>(std::move(spgh)));
}
@@ -158,7 +158,8 @@ namespace
std::vector<std::string> valid_arguments(const VcpkgPaths& paths)
{
const StatusParagraphs status_db = database_load(paths.get_filesystem(), paths.installed());
InstalledDatabaseLock installed_lock{paths.get_filesystem(), paths.installed(), false, true};
const StatusParagraphs status_db = database_load(paths.get_filesystem(), paths.installed(), installed_lock);
auto installed_packages = get_installed_ports(status_db);
return Util::fmap(installed_packages, [](auto&& pgh) -> std::string { return pgh.spec().to_string(); });
@@ -191,7 +192,9 @@ namespace vcpkg
}
const ParsedArguments options = args.parse_arguments(CommandRemoveMetadata);
StatusParagraphs status_db = database_load_collapse(paths.get_filesystem(), paths.installed());
InstalledDatabaseLock installed_lock{
paths.get_filesystem(), paths.installed(), args.wait_for_lock, args.ignore_lock_failures};
StatusParagraphs status_db = database_sync(paths.get_filesystem(), paths.installed(), installed_lock);
std::vector<PackageSpec> specs;
if (Util::Sets::contains(options.switches, SwitchOutdated))
{
@@ -310,7 +313,7 @@ namespace vcpkg
}
purge_packages_dirs(paths, all_spec_dirs);
database_load_collapse(fs, paths.installed());
database_sync(fs, paths.installed(), installed_lock);
Checks::exit_success(VCPKG_LINE_INFO);
}
}
+10 -7
View File
@@ -8,12 +8,12 @@
#include <vcpkg/commands.install.h>
#include <vcpkg/commands.set-installed.h>
#include <vcpkg/input.h>
#include <vcpkg/installeddatabase.h>
#include <vcpkg/installedpaths.h>
#include <vcpkg/metrics.h>
#include <vcpkg/portfileprovider.h>
#include <vcpkg/registries.h>
#include <vcpkg/vcpkgcmdarguments.h>
#include <vcpkg/vcpkglib.h>
#include <vcpkg/vcpkgpaths.h>
using namespace vcpkg;
@@ -185,6 +185,7 @@ namespace vcpkg
Triplet host_triplet,
const BuildPackageOptions& build_options,
const CMakeVars::CMakeVarProvider& cmake_vars,
const InstalledDatabaseLock& installed_lock,
ActionPlan action_plan,
DryRun dry_run,
PrintUsage print_usage,
@@ -232,7 +233,7 @@ namespace vcpkg
}
// currently (or once) installed specifications
auto status_db = database_load_collapse(fs, paths.installed());
auto status_db = database_sync(fs, paths.installed(), installed_lock);
adjust_action_plan_to_status_db(action_plan, status_db);
print_plan(action_plan);
@@ -269,6 +270,7 @@ namespace vcpkg
paths,
host_triplet,
build_options,
installed_lock,
action_plan,
status_db,
binary_cache,
@@ -309,9 +311,7 @@ namespace vcpkg
// See docs/manifest-info.schema.json
Json::Object manifest_info;
manifest_info.insert("manifest-path", Json::Value::string(manifest->path));
const auto json_file_path = installed_paths->vcpkg_dir() / FileManifestInfo;
const auto json_contents = Json::stringify(manifest_info);
fs.write_contents(json_file_path, json_contents, VCPKG_LINE_INFO);
fs.write_contents(installed_paths->manifest_info_path(), Json::stringify(manifest_info), VCPKG_LINE_INFO);
}
binary_cache.wait_for_async_complete_and_join();
@@ -358,7 +358,10 @@ namespace vcpkg
auto& fs = paths.get_filesystem();
auto registry_set = paths.make_registry_set();
PathsPortFileProvider provider(*registry_set, make_overlay_provider(fs, paths.overlay_ports));
auto cmake_vars = CMakeVars::make_triplet_cmake_var_provider(paths);
InstalledDatabaseLock installed_lock{
paths.get_filesystem(), paths.installed(), args.wait_for_lock, args.ignore_lock_failures};
auto cmake_vars = CMakeVars::make_triplet_cmake_var_provider(paths, installed_lock);
Optional<Path> pkgsconfig;
auto it_pkgsconfig = options.settings.find(SwitchXWriteNuGetPackagesConfig);
@@ -380,13 +383,13 @@ namespace vcpkg
{},
packages_dir_assigner,
{nullptr, host_triplet, unsupported_port_action, UseHeadVersion::No, Editable::No});
command_set_installed_and_exit_ex(
args,
paths,
host_triplet,
build_options,
*cmake_vars,
installed_lock,
std::move(action_plan),
Util::Sets::contains(options.switches, SwitchDryRun) ? DryRun::Yes : DryRun::No,
Util::Sets::contains(options.switches, SwitchNoPrintUsage) ? PrintUsage::No : PrintUsage::Yes,
+6 -3
View File
@@ -20,6 +20,7 @@
#include <vcpkg/commands.test-features.h>
#include <vcpkg/dependencies.h>
#include <vcpkg/input.h>
#include <vcpkg/installeddatabase.h>
#include <vcpkg/packagespec.h>
#include <vcpkg/paragraphs.h>
#include <vcpkg/platform-expression.h>
@@ -27,7 +28,6 @@
#include <vcpkg/registries.h>
#include <vcpkg/tools.h>
#include <vcpkg/vcpkgcmdarguments.h>
#include <vcpkg/vcpkglib.h>
#include <vcpkg/vcpkgpaths.h>
using namespace vcpkg;
@@ -517,9 +517,11 @@ namespace vcpkg
}
}
InstalledDatabaseLock installed_lock{
paths.get_filesystem(), paths.installed(), args.wait_for_lock, args.ignore_lock_failures};
auto registry_set = paths.make_registry_set();
PathsPortFileProvider provider(*registry_set, make_overlay_provider(fs, paths.overlay_ports));
auto var_provider_storage = CMakeVars::make_triplet_cmake_var_provider(paths);
auto var_provider_storage = CMakeVars::make_triplet_cmake_var_provider(paths, installed_lock);
auto& var_provider = *var_provider_storage;
std::vector<SourceControlFile*> feature_test_ports;
@@ -601,7 +603,7 @@ namespace vcpkg
BackcompatFeatures::Prohibit,
KeepGoing::Yes,
};
StatusParagraphs status_db = database_load_collapse(fs, paths.installed());
StatusParagraphs status_db = database_sync(fs, paths.installed(), installed_lock);
SpecAbiInfoCache spec_abi_info_cache;
// check what should be tested
@@ -870,6 +872,7 @@ namespace vcpkg
paths,
host_triplet,
build_options,
installed_lock,
install_plan,
status_db,
binary_cache,
+3 -2
View File
@@ -2,11 +2,11 @@
#include <vcpkg/base/util.h>
#include <vcpkg/commands.update.h>
#include <vcpkg/installeddatabase.h>
#include <vcpkg/portfileprovider.h>
#include <vcpkg/registries.h>
#include <vcpkg/statusparagraphs.h>
#include <vcpkg/vcpkgcmdarguments.h>
#include <vcpkg/vcpkglib.h>
#include <vcpkg/vcpkgpaths.h>
namespace vcpkg
@@ -66,7 +66,8 @@ namespace vcpkg
msg::println(msgLocalPortfileVersion);
auto& fs = paths.get_filesystem();
const StatusParagraphs status_db = database_load(fs, paths.installed());
InstalledDatabaseLock installed_lock{fs, paths.installed(), args.wait_for_lock, args.ignore_lock_failures};
const StatusParagraphs status_db = database_load(fs, paths.installed(), installed_lock);
auto registry_set = paths.make_registry_set();
PathsPortFileProvider provider(*registry_set, make_overlay_provider(fs, paths.overlay_ports));
+14 -5
View File
@@ -9,11 +9,11 @@
#include <vcpkg/commands.upgrade.h>
#include <vcpkg/dependencies.h>
#include <vcpkg/input.h>
#include <vcpkg/installeddatabase.h>
#include <vcpkg/portfileprovider.h>
#include <vcpkg/registries.h>
#include <vcpkg/statusparagraphs.h>
#include <vcpkg/vcpkgcmdarguments.h>
#include <vcpkg/vcpkglib.h>
#include <vcpkg/vcpkgpaths.h>
using namespace vcpkg;
@@ -73,13 +73,15 @@ namespace vcpkg
const CreateUpgradePlanOptions create_upgrade_plan_options{nullptr, host_triplet, unsupported_port_action};
StatusParagraphs status_db = database_load_collapse(paths.get_filesystem(), paths.installed());
InstalledDatabaseLock installed_lock{
paths.get_filesystem(), paths.installed(), args.wait_for_lock, args.ignore_lock_failures};
StatusParagraphs status_db = database_sync(paths.get_filesystem(), paths.installed(), installed_lock);
// Load ports from ports dirs
auto& fs = paths.get_filesystem();
auto registry_set = paths.make_registry_set();
PathsPortFileProvider provider(*registry_set, make_overlay_provider(fs, paths.overlay_ports));
auto var_provider_storage = CMakeVars::make_triplet_cmake_var_provider(paths);
auto var_provider_storage = CMakeVars::make_triplet_cmake_var_provider(paths, installed_lock);
auto& var_provider = *var_provider_storage;
PackagesDirAssigner packages_dir_assigner{paths.packages()};
@@ -211,8 +213,15 @@ namespace vcpkg
compute_all_abis(paths, action_plan, var_provider, status_db);
binary_cache.fetch(console_diagnostic_context, fs, action_plan.install_actions);
const InstallSummary summary = install_execute_plan(
args, paths, host_triplet, build_options, action_plan, status_db, binary_cache, null_build_logs_recorder);
const InstallSummary summary = install_execute_plan(args,
paths,
host_triplet,
build_options,
installed_lock,
action_plan,
status_db,
binary_cache,
null_build_logs_recorder);
msg::println(msgTotalInstallTime, msg::elapsed = summary.elapsed);
if (keep_going == KeepGoing::Yes)
{
-1
View File
@@ -47,7 +47,6 @@ namespace vcpkg
obj.insert(JsonIdDefaultTriplet, default_triplet.canonical_name());
obj.insert(JsonIdHostTriplet, host_triplet.canonical_name());
obj.insert(JsonIdVcpkgRoot, paths.root.native());
obj.insert(JsonIdTools, paths.tools.native());
if (auto ci_env = args.detected_ci_environment_name().get())
{
obj.insert(JsonIdDetectedCIEnvironment, *ci_env);
+1 -1
View File
@@ -7,10 +7,10 @@
#include <vcpkg/cmakevars.h>
#include <vcpkg/dependencies.h>
#include <vcpkg/documentation.h>
#include <vcpkg/installeddatabase.h>
#include <vcpkg/packagespec.h>
#include <vcpkg/portfileprovider.h>
#include <vcpkg/statusparagraphs.h>
#include <vcpkg/vcpkglib.h>
#include <unordered_map>
#include <unordered_set>
@@ -2,11 +2,11 @@
#include <vcpkg/base/strings.h>
#include <vcpkg/base/util.h>
#include <vcpkg/installeddatabase.h>
#include <vcpkg/installedpaths.h>
#include <vcpkg/metrics.h>
#include <vcpkg/paragraphs.h>
#include <vcpkg/statusparagraphs.h>
#include <vcpkg/vcpkglib.h>
namespace vcpkg
{
@@ -65,7 +65,43 @@ namespace vcpkg
}
}
StatusParagraphs database_load(const ReadOnlyFilesystem& fs, const InstalledPaths& installed)
InstalledDatabaseLock::InstalledDatabaseLock(const Filesystem& fs,
const InstalledPaths& installed,
const Optional<bool>& wait_for_lock,
const Optional<bool>& ignore_lock_failures)
{
installed.create_directories(fs);
const bool allow_errors = ignore_lock_failures.value_or(false);
DiagnosticContext* lock_taking_context = &stderr_diagnostic_context;
WarningDiagnosticContext wdc{stderr_diagnostic_context};
if (allow_errors)
{
lock_taking_context = &wdc;
}
const auto lock_file = installed.vcpkg_running_lock();
if (wait_for_lock.value_or(false))
{
m_lock = fs.take_exclusive_file_lock(*lock_taking_context, lock_file);
}
else
{
m_lock = fs.try_take_exclusive_file_lock(*lock_taking_context, lock_file);
}
if (!m_lock && !allow_errors)
{
stderr_diagnostic_context.report(
DiagnosticLine{DiagKind::Error, lock_file, msg::format(msgFailedToTakeInstalledLock)});
Checks::exit_fail(VCPKG_LINE_INFO);
}
}
InstalledDatabaseLock::~InstalledDatabaseLock() = default;
StatusParagraphs database_load(const ReadOnlyFilesystem& fs,
const InstalledPaths& installed,
const InstalledDatabaseLock& /* witness */)
{
const auto maybe_status_file = installed.vcpkg_dir_status_file();
if (!fs.exists(maybe_status_file, IgnoreErrors{}))
@@ -81,15 +117,10 @@ namespace vcpkg
return current_status_db;
}
StatusParagraphs database_load_collapse(const Filesystem& fs, const InstalledPaths& installed)
StatusParagraphs database_sync(const Filesystem& fs,
const InstalledPaths& installed,
const InstalledDatabaseLock& /* witness */)
{
const auto updates_dir = installed.vcpkg_dir_updates();
fs.create_directories(installed.root(), VCPKG_LINE_INFO);
fs.create_directory(installed.vcpkg_dir(), VCPKG_LINE_INFO);
fs.create_directory(installed.vcpkg_dir_info(), VCPKG_LINE_INFO);
fs.create_directory(updates_dir, VCPKG_LINE_INFO);
const auto status_file = installed.vcpkg_dir_status_file();
if (!fs.exists(status_file, IgnoreErrors{}))
{
@@ -104,7 +135,7 @@ namespace vcpkg
return current_status_db;
}
void write_update(const Filesystem& fs, const InstalledPaths& installed, const StatusParagraph& p)
void database_write_update(const Filesystem& fs, const InstalledPaths& installed, const StatusParagraph& p)
{
static std::atomic<int> update_id = 0;
@@ -257,24 +288,4 @@ namespace vcpkg
{
return get_installed_files_impl<true>(fs, installed, status_db);
}
std::string shorten_text(StringView desc, const size_t length)
{
Checks::check_exit(VCPKG_LINE_INFO, length >= 3);
std::string simple_desc;
auto first = desc.begin();
auto last = desc.end();
for (;;)
{
auto next_ws = std::find_if(first, last, ParserBase::is_whitespace);
simple_desc.append(first, next_ws);
if (next_ws == last) break;
simple_desc.push_back(' ');
first = std::find_if_not(next_ws + 1, last, ParserBase::is_whitespace);
}
return simple_desc.size() <= length ? simple_desc : simple_desc.substr(0, length - 3) + "...";
}
}
-3
View File
@@ -686,9 +686,6 @@ namespace vcpkg
// z-upload-metrics causing z-upload-metrics to crash.
args.disable_metrics = true;
// In vcpkg-in-vcpkg cases the lock is held by the outer vcpkg already.
args.do_not_take_lock = true;
// Setting the recursive data to 'poison' prevents more than one level of recursion because
// Json::parse() will fail.
set_environment_variable(EnvironmentVariableXVcpkgRecursiveData, "poison");
+8 -36
View File
@@ -538,6 +538,14 @@ namespace
namespace vcpkg
{
void InstalledPaths::create_directories(const Filesystem& fs) const
{
fs.create_directories(root(), VCPKG_LINE_INFO);
fs.create_directory(vcpkg_dir(), VCPKG_LINE_INFO);
fs.create_directory(vcpkg_dir_info(), VCPKG_LINE_INFO);
fs.create_directory(vcpkg_dir_updates(), VCPKG_LINE_INFO);
}
Path InstalledPaths::listfile_path(const BinaryParagraph& pgh) const
{
return this->vcpkg_dir_info() / (pgh.fullstem() + ".list");
@@ -597,38 +605,6 @@ namespace vcpkg
if (!m_manifest_dir.empty())
{
Debug::print("Using manifest-root: ", m_manifest_dir, '\n');
if (!args.do_not_take_lock)
{
const bool allow_errors = args.ignore_lock_failures.value_or(false);
DiagnosticContext* lock_taking_context = &stderr_diagnostic_context;
WarningDiagnosticContext wdc{stderr_diagnostic_context};
if (allow_errors)
{
lock_taking_context = &wdc;
}
const auto vcpkg_root_file = root / ".vcpkg-root";
if (args.wait_for_lock.value_or(false))
{
file_lock_handle = fs.take_exclusive_file_lock(*lock_taking_context, vcpkg_root_file);
}
else
{
auto maybe_file_lock_handle =
fs.try_take_exclusive_file_lock(*lock_taking_context, vcpkg_root_file);
if (auto got_handle = maybe_file_lock_handle.get())
{
file_lock_handle = std::move(*got_handle);
}
}
if (!file_lock_handle && !allow_errors)
{
stderr_diagnostic_context.report_error(msgFailedToTakeFileSystemLock);
Checks::exit_fail(VCPKG_LINE_INFO);
}
}
m_manifest_doc = load_manifest(fs, m_manifest_dir);
}
}
@@ -647,8 +623,6 @@ namespace vcpkg
std::vector<Path> triplets_dirs;
const Path m_artifacts_dir;
std::unique_ptr<IExclusiveFileLock> file_lock_handle;
Optional<ManifestAndPath> m_manifest_doc;
ConfigurationAndSource m_config;
};
@@ -660,10 +634,8 @@ namespace vcpkg
, m_pimpl(std::make_unique<VcpkgPathsImpl>(filesystem, args, bundle, root, original_cwd))
, scripts(m_pimpl->scripts)
, downloads(m_pimpl->downloads)
, tools(m_pimpl->tools)
, builtin_registry_versions(
process_output_directory(filesystem, args.builtin_registry_versions_dir.get(), root / "versions"))
, prefab(root / "prefab")
, buildsystems(scripts / "buildsystems")
, buildsystems_msbuild_targets(buildsystems / "msbuild" / "vcpkg.targets")
, buildsystems_msbuild_props(buildsystems / "msbuild" / "vcpkg.props")