From a560297ab88bdcb4b06599fa87e981e92a25d9c6 Mon Sep 17 00:00:00 2001 From: Joao Matos Date: Tue, 29 Aug 2017 20:26:58 +0100 Subject: [PATCH] [driver] Compilation platform is now nullable by default and validated to the host platforms. --- src/Core/Compilation.cs | 2 +- src/Core/Platform.cs | 17 +++++++++++++++++ src/Generator/Driver.cs | 3 +++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Core/Compilation.cs b/src/Core/Compilation.cs index a5f715a3..4b3dcf28 100644 --- a/src/Core/Compilation.cs +++ b/src/Core/Compilation.cs @@ -12,7 +12,7 @@ namespace CppSharp /// /// Target platform for code compilation. /// - public TargetPlatform Platform; + public TargetPlatform? Platform; /// /// Specifies the VS version. diff --git a/src/Core/Platform.cs b/src/Core/Platform.cs index e3bc75a2..093f19da 100644 --- a/src/Core/Platform.cs +++ b/src/Core/Platform.cs @@ -77,5 +77,22 @@ namespace CppSharp return platform == PlatformID.Unix || platform == PlatformID.MacOSX; } } + + public static TargetPlatform Host + { + get + { + if (IsWindows) + return TargetPlatform.Windows; + + if (IsMacOS) + return TargetPlatform.MacOS; + + if (IsLinux) + return TargetPlatform.Linux; + + throw new NotImplementedException(); + } + } } } diff --git a/src/Generator/Driver.cs b/src/Generator/Driver.cs index c538e939..0fe95a5a 100644 --- a/src/Generator/Driver.cs +++ b/src/Generator/Driver.cs @@ -48,6 +48,9 @@ namespace CppSharp void ValidateOptions() { + if (!Options.Compilation.Platform.HasValue) + Options.Compilation.Platform = Platform.Host; + foreach (var module in Options.Modules) { if (string.IsNullOrWhiteSpace(module.LibraryName))