diff --git a/src/CLI/Generator.cs b/src/CLI/Generator.cs index 69f42fa6..9a2f3911 100644 --- a/src/CLI/Generator.cs +++ b/src/CLI/Generator.cs @@ -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 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"); diff --git a/src/CLI/Options.cs b/src/CLI/Options.cs index 18075af4..1b43cdd0 100644 --- a/src/CLI/Options.cs +++ b/src/CLI/Options.cs @@ -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;