Browse Source

[cli] Improve platform detection so the current platform is set by default.

pull/914/head
Joao Matos 9 years ago
parent
commit
eac99badd4
  1. 16
      src/CLI/Generator.cs
  2. 2
      src/CLI/Options.cs

16
src/CLI/Generator.cs

@ -25,8 +25,24 @@ namespace CppSharp @@ -25,8 +25,24 @@ namespace CppSharp
this.options = options;
}
static TargetPlatform GetCurrentPlatform()
{
if (Platform.IsWindows)
return TargetPlatform.Windows;
if (Platform.IsMacOS)
return TargetPlatform.MacOS;
if (Platform.IsLinux)
return TargetPlatform.Linux;
throw new System.NotImplementedException("Unknown host platform");
}
public bool ValidateOptions(List<string> messages)
{
if (!options.Platform.HasValue)
options.Platform = GetCurrentPlatform();
if (Platform.IsWindows && options.Platform != TargetPlatform.Windows)
{
messages.Add("Cannot create bindings for a platform other that Windows from a Windows running machine");

2
src/CLI/Options.cs

@ -29,7 +29,7 @@ namespace CppSharp @@ -29,7 +29,7 @@ namespace CppSharp
public string InputLibraryName { get; set; }
public TargetPlatform Platform { get; set; } = TargetPlatform.Windows;
public TargetPlatform? Platform { get; set; }
public TargetArchitecture Architecture { get; set; } = TargetArchitecture.x86;

Loading…
Cancel
Save