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 all available options for 'build_policy' according to Conan documentation #142

Merged
merged 1 commit into from Jul 17, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 19 additions & 22 deletions Conan.VisualStudio.Core/ConanRunner.cs
Expand Up @@ -19,6 +19,23 @@ public ConanRunner(ConanSettings conanSettings, string executablePath)
private string Escape(string arg) =>
arg.Contains(" ") ? $"\"{arg}\"" : arg;

private string BuildOptions(ConanBuildType build, bool update)
{
string options = "";
if (build != ConanBuildType.none)
{
if (build == ConanBuildType.always)
options += " --build";
else
options += " --build=" + build.ToString();
}
if (update)
{
options += " --update";
}
return options;
}

public ProcessStartInfo Install(ConanProject project, ConanConfiguration configuration, ConanGeneratorType generator, ConanBuildType build, bool update, Core.IErrorListService errorListService)
{
string ProcessArgument(string name, string value) => $"-s {name}={Escape(value)}";
Expand All @@ -29,21 +46,11 @@ public ProcessStartInfo Install(ConanProject project, ConanConfiguration configu
if (profile != null)
{
string generatorName = generator.ToString();
string options = "";
if (build != ConanBuildType.none)
{
options += " --build " + build.ToString();
}
if (update)
{
options += " --update";
}

arguments = $"install {Escape(project.Path)} " +
$"-g {generatorName} " +
$"--install-folder {Escape(configuration.InstallPath)} " +
$"--profile {Escape(profile)}" +
$"{options}";
$"{BuildOptions(build, update)}";

}
else if (_conanSettings != null)
Expand All @@ -65,16 +72,6 @@ public ProcessStartInfo Install(ConanProject project, ConanConfiguration configu
{
settingValues = settingValues.Concat(new[] { ("compiler.runtime", configuration.RuntimeLibrary) }).ToArray();
}
string options = "";
if (build != ConanBuildType.none)
{
options += "--build " + build.ToString();
}

if (update)
{
options += " --update";
}

var settings = string.Join(" ", settingValues.Where(pair => pair.Item2 != null).Select(pair =>
{
Expand All @@ -84,7 +81,7 @@ public ProcessStartInfo Install(ConanProject project, ConanConfiguration configu
arguments = $"install {Escape(project.Path)} " +
$"-g {generatorName} " +
$"--install-folder {Escape(configuration.InstallPath)} " +
$"{settings} {options}";
$"{settings} {BuildOptions(build, update)}";
}

var startInfo = new ProcessStartInfo
Expand Down
8 changes: 5 additions & 3 deletions Conan.VisualStudio.Core/ConanSettings.cs
Expand Up @@ -21,9 +21,11 @@ public enum ConanGeneratorType

public enum ConanBuildType
{
none,
missing,
always,
outdated
never,
missing,
cascade,
outdated,
none
}
}
2 changes: 1 addition & 1 deletion Conan.VisualStudio/ConanOptionsPage.cs
Expand Up @@ -86,7 +86,7 @@ public bool ConanInstallAutomatically

[Category("Conan")]
[DisplayName("Build policy")]
[Description(@"--build argument (missing, outdated, always or none)")]
[Description(@"--build argument (always, never, missing, cascade, outdated or none)")]
public ConanBuildType ConanBuild
{
get => _conanBuild ?? ConanBuildType.missing;
Expand Down