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 warning message for change in default triplet to host triplet #881

Merged
merged 15 commits into from
Feb 14, 2023
6 changes: 6 additions & 0 deletions include/vcpkg/base/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,12 @@ namespace vcpkg
DECLARE_MESSAGE(DateTableHeader, (), "", "Date");
DECLARE_MESSAGE(DefaultBrowserLaunched, (msg::url), "", "Default browser launched to {url}.");
DECLARE_MESSAGE(DefaultFlag, (msg::option), "", "Defaulting to --{option} being on.");
DECLARE_MESSAGE(DefaultTriplet,
(msg::triplet),
"",
"Starting with the September 2023 release, the default triplet for vcpkg libraries will change "
"from x86-windows to the detected host triplet ({triplet}). To resolve this message, add --triplet "
"x86-windows to keep the same behavior.");
DECLARE_MESSAGE(DeleteVcpkgConfigFromManifest,
(msg::path),
"",
Expand Down
1 change: 1 addition & 0 deletions include/vcpkg/triplet.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ namespace vcpkg

Triplet default_triplet(const VcpkgCmdArguments& args);
Triplet default_host_triplet(const VcpkgCmdArguments& args);
void print_default_triplet_warning(const VcpkgCmdArguments& args, View<std::string> specs);
}

VCPKG_FORMAT_AS(vcpkg::Triplet, vcpkg::StringView);
Expand Down
2 changes: 2 additions & 0 deletions locales/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@
"_DefaultBrowserLaunched.comment": "An example of {url} is https://github.com/microsoft/vcpkg.",
"DefaultFlag": "Defaulting to --{option} being on.",
"_DefaultFlag.comment": "An example of {option} is editable.",
"DefaultTriplet": "Starting with the September 2023 release, the default triplet for vcpkg libraries will change from x86-windows to the detected host triplet ({triplet}). To resolve this message, add --triplet x86-windows to keep the same behavior.",
"_DefaultTriplet.comment": "An example of {triplet} is x64-windows.",
"DeleteVcpkgConfigFromManifest": "-- Or remove \"vcpkg-configuration\" from the manifest file {path}.",
"_DeleteVcpkgConfigFromManifest.comment": "An example of {path} is /foo/bar.",
"DeprecatedPrefabDebugOption": "--prefab-debug is now deprecated.",
Expand Down
1 change: 1 addition & 0 deletions src/vcpkg/base/messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ namespace vcpkg
REGISTER_MESSAGE(DateTableHeader);
REGISTER_MESSAGE(DefaultBrowserLaunched);
REGISTER_MESSAGE(DefaultFlag);
REGISTER_MESSAGE(DefaultTriplet);
REGISTER_MESSAGE(DeleteVcpkgConfigFromManifest);
REGISTER_MESSAGE(DeprecatedPrefabDebugOption);
REGISTER_MESSAGE(DetectCompilerHash);
Expand Down
1 change: 1 addition & 0 deletions src/vcpkg/build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ namespace vcpkg::Build
BinaryCache binary_cache{args, paths};
const FullPackageSpec spec = check_and_get_full_package_spec(
std::move(first_arg), default_triplet, COMMAND_STRUCTURE.example_text, paths);
print_default_triplet_warning(args, {&args.command_arguments[0], 1});

auto& fs = paths.get_filesystem();
auto registry_set = paths.make_registry_set();
Expand Down
1 change: 1 addition & 0 deletions src/vcpkg/commands.check-support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ namespace vcpkg::Commands
return check_and_get_full_package_spec(
std::string(arg), default_triplet, COMMAND_STRUCTURE.example_text, paths);
});
print_default_triplet_warning(args, args.command_arguments);

auto& fs = paths.get_filesystem();
auto registry_set = paths.make_registry_set();
Expand Down
2 changes: 2 additions & 0 deletions src/vcpkg/commands.ci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ namespace vcpkg::Commands::CI
{
msg::println_warning(msgInternalCICommand);

print_default_triplet_warning(args, {});

const ParsedArguments options = args.parse_arguments(COMMAND_STRUCTURE);
const auto& settings = options.settings;

Expand Down
1 change: 1 addition & 0 deletions src/vcpkg/commands.dependinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ namespace vcpkg::Commands::DependInfo
return check_and_get_full_package_spec(
std::string{arg}, default_triplet, COMMAND_STRUCTURE.example_text, paths);
});
print_default_triplet_warning(args, args.command_arguments);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think it would be better to do this as part of check_and_get_full_package_spec but that's nitpick territory.


auto& fs = paths.get_filesystem();
auto registry_set = paths.make_registry_set();
Expand Down
1 change: 1 addition & 0 deletions src/vcpkg/commands.setinstalled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ namespace vcpkg::Commands::SetInstalled
return check_and_get_full_package_spec(
std::string(arg), default_triplet, COMMAND_STRUCTURE.example_text, paths);
});
print_default_triplet_warning(args, args.command_arguments);

BinaryCache binary_cache{args, paths};

Expand Down
2 changes: 2 additions & 0 deletions src/vcpkg/commands.upgrade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ namespace vcpkg::Commands::Upgrade
}
else
{
print_default_triplet_warning(args, args.command_arguments);

std::vector<PackageSpec> not_installed;
std::vector<PackageSpec> no_control_file;
std::vector<PackageSpec> to_upgrade;
Expand Down
1 change: 1 addition & 0 deletions src/vcpkg/export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ namespace vcpkg::Export
return check_and_get_package_spec(
std::string(arg), default_triplet, COMMAND_STRUCTURE.example_text, paths);
});
print_default_triplet_warning(args, args.command_arguments);
}

if (!ret.raw && !ret.nuget && !ret.ifw && !ret.zip && !ret.seven_zip && !ret.dry_run && !ret.chocolatey &&
Expand Down
2 changes: 2 additions & 0 deletions src/vcpkg/install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,7 @@ namespace vcpkg
print_usage(MANIFEST_COMMAND_STRUCTURE);
Checks::exit_fail(VCPKG_LINE_INFO);
}
print_default_triplet_warning(args, {});
}
else
{
Expand Down Expand Up @@ -1188,6 +1189,7 @@ namespace vcpkg
return check_and_get_full_package_spec(
std::string(arg), default_triplet, COMMAND_STRUCTURE.example_text, paths);
});
print_default_triplet_warning(args, args.command_arguments);

// create the plan
msg::println(msgComputingInstallPlan);
Expand Down
1 change: 1 addition & 0 deletions src/vcpkg/remove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ namespace vcpkg::Remove
return check_and_get_package_spec(
std::string(arg), default_triplet, COMMAND_STRUCTURE.example_text, paths);
});
print_default_triplet_warning(args, args.command_arguments);
}

const bool no_purge = Util::Sets::contains(options.switches, OPTION_NO_PURGE);
Expand Down
28 changes: 28 additions & 0 deletions src/vcpkg/triplet.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <vcpkg/base/strings.h>

#include <vcpkg/packagespec.h>
#include <vcpkg/triplet.h>
#include <vcpkg/vcpkgcmdarguments.h>

Expand Down Expand Up @@ -112,4 +113,31 @@ namespace vcpkg
}
return system_triplet();
}

void print_default_triplet_warning(const VcpkgCmdArguments& args, View<std::string> specs)
{
(void)args;
(void)specs;
#if defined(_WIN32)
// The triplet is not set by --triplet or VCPKG_DEFAULT_TRIPLET
if (!args.triplet.has_value())
{
if (specs.size() == 0)
{
msg::println_warning(msgDefaultTriplet, msg::triplet = default_host_triplet(args));
return;
}
for (auto&& arg : specs)
{
const std::string as_lowercase = Strings::ascii_to_lowercase(std::string{arg});
auto maybe_qpkg = parse_qualified_specifier(as_lowercase);
if (maybe_qpkg.has_value() && !maybe_qpkg.get()->triplet.has_value())
{
msg::println_warning(msgDefaultTriplet, msg::triplet = default_host_triplet(args));
return;
}
}
}
#endif
}
}