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

Added settings to select preferred/required architecture. #1727

Merged
merged 6 commits into from
Dec 1, 2021
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
11 changes: 11 additions & 0 deletions doc/Settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ The `locale` behavior affects the choice of installer based on installer locale.
}
},
```
### Architectures

The `architectures` behavior affects what architectures will be selected when installing a package. The matching parameter is `--architecture`. Note that only architectures compatible with your system can be selected.

```json
"installBehavior": {
"preferences": {
"architectures": ["x64", "arm64"]
}
},
```

## Telemetry

Expand Down
17 changes: 17 additions & 0 deletions schemas/JSON/settings/settings.schema.0.2.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@
},
"minItems": 1,
"maxItems": 10
},
"architectures": {
"description": "The architecture(s) to use for a package install",
"type": "array",
"items": {
"uniqueItems": "true",
"type": "string",
"enum": [
"neutral",
"x64",
"x86",
"arm64",
"arm"
],
"minItems": 1,
"maxItems": 4
}
}
}
},
Expand Down
19 changes: 19 additions & 0 deletions src/AppInstallerCLICore/Workflows/WorkflowBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -962,14 +962,33 @@ namespace AppInstaller::CLI::Workflow
bool isUpdate = WI_IsFlagSet(context.GetFlags(), Execution::ContextFlag::InstallerExecutionUseUpdate);

IPackageVersion::Metadata installationMetadata;

if (isUpdate)
{
installationMetadata = context.Get<Execution::Data::InstalledPackageVersion>()->GetMetadata();
}
if (context.Args.Contains(Execution::Args::Type::InstallArchitecture))
{
// arguments override settings.
context.Add<Execution::Data::AllowedArchitectures>({ Utility::ConvertToArchitectureEnum(std::string(context.Args.GetArg(Execution::Args::Type::InstallArchitecture))) });
}
else
{
std::vector<Utility::Architecture> requiredArchitectures = Settings::User().Get<Settings::Setting::InstallArchitectureRequirement>();
std::vector<Utility::Architecture> optionalArchitectures = Settings::User().Get<Settings::Setting::InstallArchitecturePreference>();


if (!requiredArchitectures.empty())
{
context.Add<Execution::Data::AllowedArchitectures>({ requiredArchitectures.begin(), requiredArchitectures.end() });
}
else if (!optionalArchitectures.empty())
{
optionalArchitectures.emplace_back(Utility::Architecture::Unknown);
context.Add<Execution::Data::AllowedArchitectures>({ optionalArchitectures.begin(), optionalArchitectures.end() });

}
}
ManifestComparator manifestComparator(context, installationMetadata);
auto [installer, inapplicabilities] = manifestComparator.GetPreferredInstaller(context.Get<Execution::Data::Manifest>());

Expand Down
7 changes: 7 additions & 0 deletions src/AppInstallerCommonCore/Public/winget/UserSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <variant>
#include <vector>

#include "AppInstallerArchitecture.h"

using namespace std::chrono_literals;
using namespace std::string_view_literals;

Expand Down Expand Up @@ -54,6 +56,7 @@ namespace AppInstaller::Settings
DeliveryOptimization,
};


// Enum of settings.
// Must start at 0 to enable direct access to variant in UserSettings.
// Max must be last and unused.
Expand All @@ -73,6 +76,8 @@ namespace AppInstaller::Settings
InstallScopeRequirement,
NetworkDownloader,
NetworkDOProgressTimeoutInSeconds,
InstallArchitecturePreference,
InstallArchitectureRequirement,
InstallLocalePreference,
InstallLocaleRequirement,
EFDirectMSI,
Expand Down Expand Up @@ -116,6 +121,8 @@ namespace AppInstaller::Settings
SETTINGMAPPING_SPECIALIZATION(Setting::EFExperimentalArg, bool, bool, false, ".experimentalFeatures.experimentalArg"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::EFDependencies, bool, bool, false, ".experimentalFeatures.dependencies"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::TelemetryDisable, bool, bool, false, ".telemetry.disable"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::InstallArchitecturePreference, std::vector<std::string>, std::vector<Utility::Architecture>, {}, ".installBehavior.preferences.architectures"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::InstallArchitectureRequirement, std::vector<std::string>, std::vector<Utility::Architecture>, {}, ".installBehavior.requirements.architectures"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::InstallScopePreference, std::string, ScopePreference, ScopePreference::User, ".installBehavior.preferences.scope"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::InstallScopeRequirement, std::string, ScopePreference, ScopePreference::None, ".installBehavior.requirements.scope"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::NetworkDownloader, std::string, InstallerDownloader, InstallerDownloader::Default, ".network.downloader"sv);
Expand Down
Loading