Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add switch to force classic mode. #1535

Merged
merged 4 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions azure-pipelines/end-to-end-tests-dir/manifests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,17 @@ Throw-IfFailed
Write-Trace "test manifest features: self-reference, features = [a], with overlay"
Run-Vcpkg install @manifestDirArgs --x-feature=a "--overlay-ports=$manifestDir/manifest-test"
Throw-IfFailed

Write-Trace "test manifest install with specific package names fails"
$output = Run-VcpkgAndCaptureOutput install @manifestDirArgs vcpkg-empty-port
Throw-IfNotFailed
Throw-IfNonContains -Expected 'error: In manifest mode, `vcpkg install` does not support individual package arguments.' -Actual $output

Write-Trace "test manifest install with specific package names forced to classic mode succeeds"
$output = Run-VcpkgAndCaptureOutput install @manifestDirArgs --classic vcpkg-empty-port
Throw-IfFailed
$expected = @"
The following packages will be built and installed:
vcpkg-empty-port:
"@
Throw-IfNonContains -Expected $expected -Actual $output
1 change: 1 addition & 0 deletions include/vcpkg/base/contractual-constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ namespace vcpkg
inline constexpr StringLiteral SwitchBuiltinPortsRoot = "builtin-ports-root";
inline constexpr StringLiteral SwitchBuiltinRegistryVersionsDir = "builtin-registry-versions-dir";
inline constexpr StringLiteral SwitchCIBaseline = "ci-baseline";
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";
Expand Down
1 change: 1 addition & 0 deletions include/vcpkg/base/message-data.inc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,7 @@ DECLARE_MESSAGE(
(),
"",
"Environment variable VCPKG_FORCE_SYSTEM_BINARIES must be set on arm, s390x, ppc64le and riscv platforms.")
DECLARE_MESSAGE(ForceClassicMode, (), "", "Force classic mode, even if a manifest could be found.")
DECLARE_MESSAGE(FormattedParseMessageExpressionPrefix, (), "", "on expression:")
DECLARE_MESSAGE(ForMoreHelp,
(),
Expand Down
1 change: 1 addition & 0 deletions include/vcpkg/vcpkgcmdarguments.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ namespace vcpkg

Optional<std::string> vcpkg_root_dir_arg;
Optional<std::string> vcpkg_root_dir_env;
Optional<bool> force_classic_mode;
Optional<std::string> manifest_root_dir;

Optional<std::string> buildtrees_root_dir;
Expand Down
1 change: 1 addition & 0 deletions locales/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,7 @@
"FollowingPackagesUpgraded": "The following packages are up-to-date:",
"ForMoreHelp": "For More Help",
"_ForMoreHelp.comment": "Printed before a suggestion for the user to run `vcpkg help <topic>`",
"ForceClassicMode": "Force classic mode, even if a manifest could be found.",
"ForceSystemBinariesOnWeirdPlatforms": "Environment variable VCPKG_FORCE_SYSTEM_BINARIES must be set on arm, s390x, ppc64le and riscv platforms.",
"FormattedParseMessageExpressionPrefix": "on expression:",
"GHAParametersMissing": "The GHA binary source requires the ACTIONS_RUNTIME_TOKEN and ACTIONS_CACHE_URL environment variables to be set. See {url} for details.",
Expand Down
2 changes: 2 additions & 0 deletions src/vcpkg/vcpkgcmdarguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ namespace vcpkg
args.host_triplet,
msg::format(msgSpecifyHostArch,
msg::env_var = format_environment_variable(EnvironmentVariableVcpkgDefaultHostTriplet)));
args.parser.parse_switch(
SwitchClassic, StabilityTag::Standard, args.force_classic_mode, msg::format(msgForceClassicMode));
args.parser.parse_option(SwitchManifestRoot, StabilityTag::Experimental, args.manifest_root_dir);
args.parser.parse_option(SwitchBuildtreesRoot,
StabilityTag::Experimental,
Expand Down
11 changes: 7 additions & 4 deletions src/vcpkg/vcpkgpaths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,17 @@ namespace

Path compute_manifest_dir(const ReadOnlyFilesystem& fs, const VcpkgCmdArguments& args, const Path& original_cwd)
{
if (auto manifest_root_dir = args.manifest_root_dir.get())
if (args.force_classic_mode.value_or(false))
{
return fs.almost_canonical(*manifest_root_dir, VCPKG_LINE_INFO);
return Path{};
}
else

if (auto manifest_root_dir = args.manifest_root_dir.get())
{
return fs.find_file_recursively_up(original_cwd, "vcpkg.json", VCPKG_LINE_INFO);
return fs.almost_canonical(*manifest_root_dir, VCPKG_LINE_INFO);
}

return fs.find_file_recursively_up(original_cwd, FileVcpkgDotJson, VCPKG_LINE_INFO);
}

// This structure holds members for VcpkgPathsImpl that don't require explicit initialization/destruction
Expand Down
Loading