|
|
|
@ -32,6 +32,8 @@ namespace CppSharp |
|
|
|
/// <summary>Extra data value associated with the toolchain.</summary>
|
|
|
|
/// <summary>Extra data value associated with the toolchain.</summary>
|
|
|
|
public string Value; |
|
|
|
public string Value; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public bool IsValid => Version > 0 && !string.IsNullOrEmpty(Directory); |
|
|
|
|
|
|
|
|
|
|
|
public override string ToString() |
|
|
|
public override string ToString() |
|
|
|
{ |
|
|
|
{ |
|
|
|
return string.Format("{0} (version: {1})", Directory, Version); |
|
|
|
return string.Format("{0} (version: {1})", Directory, Version); |
|
|
|
@ -83,13 +85,14 @@ namespace CppSharp |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Dumps include directories for selected toolchain.</summary>
|
|
|
|
/// <summary>Dumps include directories for selected toolchain.</summary>
|
|
|
|
|
|
|
|
/// <param name="vsVersion">The version of Visual Studio to dump the SDK-s of.</param>
|
|
|
|
public static void DumpSdkIncludes(VisualStudioVersion vsVersion = |
|
|
|
public static void DumpSdkIncludes(VisualStudioVersion vsVersion = |
|
|
|
VisualStudioVersion.Latest) |
|
|
|
VisualStudioVersion.Latest) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Console.WriteLine("\nInclude search path (VS: {0}):", vsVersion); |
|
|
|
Console.WriteLine("\nInclude search path (VS: {0}):", vsVersion); |
|
|
|
var includes = GetSystemIncludes(vsVersion); |
|
|
|
VisualStudioVersion foundVsVersion; |
|
|
|
foreach (var include in includes) |
|
|
|
foreach (var include in GetSystemIncludes(vsVersion, out foundVsVersion)) |
|
|
|
Console.WriteLine("\t{0}", include); |
|
|
|
Console.WriteLine($"\t{include}"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static Version GetCLVersion(VisualStudioVersion vsVersion) |
|
|
|
public static Version GetCLVersion(VisualStudioVersion vsVersion) |
|
|
|
@ -143,12 +146,10 @@ namespace CppSharp |
|
|
|
if (vsSdks.Count == 0) |
|
|
|
if (vsSdks.Count == 0) |
|
|
|
throw new Exception("Could not find a valid Visual Studio toolchain"); |
|
|
|
throw new Exception("Could not find a valid Visual Studio toolchain"); |
|
|
|
|
|
|
|
|
|
|
|
var vsSdk = (vsVersion == VisualStudioVersion.Latest) |
|
|
|
return (vsVersion == VisualStudioVersion.Latest) |
|
|
|
? vsSdks.Last() |
|
|
|
? vsSdks.Last() |
|
|
|
: vsSdks.Find(version => |
|
|
|
: vsSdks.Find(version => |
|
|
|
(int)version.Version == GetVisualStudioVersion(vsVersion)); |
|
|
|
(int) version.Version == GetVisualStudioVersion(vsVersion)); |
|
|
|
|
|
|
|
|
|
|
|
return vsSdk; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static ToolchainVersion GetWindowsKitsToolchain(VisualStudioVersion vsVersion, |
|
|
|
public static ToolchainVersion GetWindowsKitsToolchain(VisualStudioVersion vsVersion, |
|
|
|
@ -188,27 +189,39 @@ namespace CppSharp |
|
|
|
windowsKitSdk = windowsKitsSdks.Last(); |
|
|
|
windowsKitSdk = windowsKitsSdks.Last(); |
|
|
|
return windowsKitSdk; |
|
|
|
return windowsKitSdk; |
|
|
|
} |
|
|
|
} |
|
|
|
/// Gets the system include folders for the given Visual Studio version.
|
|
|
|
|
|
|
|
public static List<string> GetSystemIncludes(VisualStudioVersion vsVersion) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var vsSdk = GetVSToolchain(vsVersion); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var vsDir = vsSdk.Directory; |
|
|
|
/// <summary>Gets the system include folders for the given Visual Studio version.</summary>
|
|
|
|
vsDir = vsDir.Substring(0, vsDir.LastIndexOf(@"\Common7\IDE", |
|
|
|
/// <param name="wantedVsVersion">The version of Visual Studio to get
|
|
|
|
StringComparison.Ordinal)); |
|
|
|
/// system includes from.</param>
|
|
|
|
|
|
|
|
/// <param name="foundVsVersion">The found version of Visual Studio
|
|
|
|
|
|
|
|
/// system includes are actually got from.</param>
|
|
|
|
|
|
|
|
public static List<string> GetSystemIncludes(VisualStudioVersion wantedVsVersion, |
|
|
|
|
|
|
|
out VisualStudioVersion foundVsVersion) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (wantedVsVersion != VisualStudioVersion.Latest) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var vsSdk = GetVSToolchain(wantedVsVersion); |
|
|
|
|
|
|
|
if (vsSdk.IsValid) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var vsDir = vsSdk.Directory; |
|
|
|
|
|
|
|
vsDir = vsDir.Substring(0, vsDir.LastIndexOf(@"\Common7\IDE", |
|
|
|
|
|
|
|
StringComparison.Ordinal)); |
|
|
|
|
|
|
|
|
|
|
|
if (vsVersion != VisualStudioVersion.Latest) |
|
|
|
foundVsVersion = wantedVsVersion; |
|
|
|
return GetSystemIncludes(vsVersion, vsDir); |
|
|
|
return GetSystemIncludes(wantedVsVersion, vsDir); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// we don't know what "latest" is on a given machine
|
|
|
|
// we don't know what "latest" is on a given machine
|
|
|
|
// because we do not (yet) pass a parameter from the build scripts
|
|
|
|
|
|
|
|
// so start from the latest specified version and loop until a match is found
|
|
|
|
// so start from the latest specified version and loop until a match is found
|
|
|
|
for (var i = VisualStudioVersion.Latest - 1; i >= VisualStudioVersion.VS2012; i--) |
|
|
|
for (var i = VisualStudioVersion.Latest - 1; i >= VisualStudioVersion.VS2012; i--) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var includes = GetSystemIncludes(i, vsDir); |
|
|
|
var includes = GetSystemIncludes(i, out foundVsVersion); |
|
|
|
if (includes.Any()) |
|
|
|
if (includes.Count > 0) |
|
|
|
return includes; |
|
|
|
return includes; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foundVsVersion = VisualStudioVersion.Latest; |
|
|
|
return new List<string>(); |
|
|
|
return new List<string>(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|