Skip to content

Commit

Permalink
- synchronize build policy
Browse files Browse the repository at this point in the history
Signed-off-by: SSE4 <tomskside@gmail.com>
  • Loading branch information
SSE4 authored and jgsogo committed Jul 17, 2019
1 parent 2cf0625 commit 7ca814d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 26 deletions.
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

0 comments on commit 7ca814d

Please sign in to comment.