Browse Source

Merge pull request #790 from realvictorprm/master

Added complete support for VS 2017
pull/791/head
João Matos 8 years ago committed by GitHub
parent
commit
a954c54a6c
  1. 1
      .gitignore
  2. BIN
      deps/vs2017/Microsoft.VisualStudio.Setup.Configuration.Interop.dll
  3. 485
      deps/vs2017/Microsoft.VisualStudio.Setup.Configuration.Interop.xml
  4. 229
      src/Core/Toolchains/MSVCToolchain.cs
  5. 5
      src/Core/premake5.lua
  6. 3
      src/Parser/ParserOptions.cs

1
.gitignore vendored

@ -8,7 +8,6 @@ autom4te.cache @@ -8,7 +8,6 @@ autom4te.cache
missing
*Makefile
*Makefile.in
*.dll
*.exe
bin/
*.userprefs

BIN
deps/vs2017/Microsoft.VisualStudio.Setup.Configuration.Interop.dll vendored

Binary file not shown.

485
deps/vs2017/Microsoft.VisualStudio.Setup.Configuration.Interop.xml vendored

@ -0,0 +1,485 @@ @@ -0,0 +1,485 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>Microsoft.VisualStudio.Setup.Configuration.Interop</name>
</assembly>
<members>
<member name="T:Microsoft.VisualStudio.Setup.Configuration.IEnumSetupInstances">
<summary>
A enumerator of installed <see cref="T:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance"/> objects.
</summary>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.IEnumSetupInstances.Next(System.Int32,Microsoft.VisualStudio.Setup.Configuration.ISetupInstance[],System.Int32@)">
<summary>
Retrieves the next set of product instances in the enumeration sequence.
</summary>
<param name="celt">The number of product instances to retrieve.</param>
<param name="rgelt">A pointer to an array of <see cref="T:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance"/>.</param>
<param name="pceltFetched">A pointer to the number of product instances retrieved. If celt is 1 this parameter may be NULL.</param>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.IEnumSetupInstances.Skip(System.Int32)">
<summary>
Skips the next set of product instances in the enumeration sequence.
</summary>
<param name="celt">The number of product instances to skip.</param>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.IEnumSetupInstances.Reset">
<summary>
Resets the enumeration sequence to the beginning.
</summary>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.IEnumSetupInstances.Clone">
<summary>
Creates a new enumeration object in the same state as the current enumeration object: the new object points to the same place in the enumeration sequence.
</summary>
<returns>A pointer to a pointer to a new <see cref="T:Microsoft.VisualStudio.Setup.Configuration.IEnumSetupInstances"/> interface. If the method fails, this parameter is undefined.</returns>
</member>
<member name="T:Microsoft.VisualStudio.Setup.Configuration.InstanceState">
<summary>
The state of an <see cref="T:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance2"/>.
</summary>
</member>
<member name="F:Microsoft.VisualStudio.Setup.Configuration.InstanceState.None">
<summary>
The instance state has not been determined.
</summary>
</member>
<member name="F:Microsoft.VisualStudio.Setup.Configuration.InstanceState.Local">
<summary>
The instance installation path exists.
</summary>
</member>
<member name="F:Microsoft.VisualStudio.Setup.Configuration.InstanceState.Registered">
<summary>
A product is registered to the instance.
</summary>
</member>
<member name="F:Microsoft.VisualStudio.Setup.Configuration.InstanceState.NoRebootRequired">
<summary>
No reboot is required for the instance.
</summary>
</member>
<member name="F:Microsoft.VisualStudio.Setup.Configuration.InstanceState.NoErrors">
<summary>
No errors were reported for the instance.
</summary>
</member>
<member name="F:Microsoft.VisualStudio.Setup.Configuration.InstanceState.Complete">
<summary>
The instance represents a complete install.
</summary>
</member>
<member name="T:Microsoft.VisualStudio.Setup.Configuration.ISetupConfiguration2">
<summary>
Gets information about product instances set up on the machine.
</summary>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupConfiguration2.EnumInstances">
<summary>
Enumerates all completed product instances installed.
</summary>
<returns>An enumeration of installed product instances.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupConfiguration2.GetInstanceForCurrentProcess">
<summary>
Gets the instance for the current process path.
</summary>
<returns>The instance for the current process path.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupConfiguration2.GetInstanceForPath(System.String)">
<summary>
Gets the instance for the given path.
</summary>
<param name="path">Path used to determine instance</param>
<returns>The instance for the given path.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupConfiguration2.EnumAllInstances">
<summary>
Enumerates all product instances.
</summary>
<returns>An enumeration of all product instances.</returns>
</member>
<member name="T:Microsoft.VisualStudio.Setup.Configuration.ISetupConfiguration">
<summary>
Gets information about product instances set up on the machine.
</summary>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupConfiguration.EnumInstances">
<summary>
Enumerates all product instances installed.
</summary>
<returns>An enumeration of installed product instances.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupConfiguration.GetInstanceForCurrentProcess">
<summary>
Gets the instance for the current process path.
</summary>
<returns>The instance for the current process path.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupConfiguration.GetInstanceForPath(System.String)">
<summary>
Gets the instance for the given path.
</summary>
<param name="path">Path used to determine instance</param>
<returns>The instance for the given path.</returns>
</member>
<member name="T:Microsoft.VisualStudio.Setup.Configuration.ISetupErrorState">
<summary>
Information about the error state of the instance.
</summary>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupErrorState.GetFailedPackages">
<summary>
Gets an array of failed package references.
</summary>
<returns>An array of failed package references.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupErrorState.GetSkippedPackages">
<summary>
Gets an array of skipped package references.
</summary>
<returns>An array of skipped package references.</returns>
</member>
<member name="T:Microsoft.VisualStudio.Setup.Configuration.ISetupFailedPackageReference">
<summary>
A reference to a failed package.
</summary>
<remarks>
You can enumerate all properties of basic types by casting to an <see cref="T:Microsoft.VisualStudio.Setup.Configuration.ISetupPropertyStore"/>.
</remarks>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupFailedPackageReference.GetId">
<summary>
Gets the general package identifier.
</summary>
<returns>The general package identifier.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupFailedPackageReference.GetVersion">
<summary>
Gets the version of the package.
</summary>
<returns>The version of the package.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupFailedPackageReference.GetChip">
<summary>
Gets the target process architecture of the package.
</summary>
<returns>The target process architecture of the package.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupFailedPackageReference.GetLanguage">
<summary>
Gets the language and optional region identifier.
</summary>
<returns>The language and optional region identifier.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupFailedPackageReference.GetBranch">
<summary>
Gets the build branch of the package.
</summary>
<returns>The build branch of the package.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupFailedPackageReference.GetType">
<summary>
Gets the type of the package.
</summary>
<returns>The type of the package.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupFailedPackageReference.GetUniqueId">
<summary>
Gets the unique identifier consisting of all defined tokens.
</summary>
<returns>The unique identifier consisting of all defined tokens.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupFailedPackageReference.GetIsExtension">
<summary>
Gets a value indicating whether the package refers to an external extension.
</summary>
<returns>A value indicating whether the package refers to an external extension.</returns>
</member>
<member name="T:Microsoft.VisualStudio.Setup.Configuration.ISetupHelper">
<summary>
Helper functions.
</summary>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupHelper.ParseVersion(System.String)">
<summary>
Parses a dotted quad version string into a 64-bit unsigned integer.
</summary>
<param name="version">The dotted quad version string to parse, e.g. 1.2.3.4.</param>
<returns>A 64-bit unsigned integer representing the version. You can compare this to other versions.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupHelper.ParseVersionRange(System.String,System.UInt64@,System.UInt64@)">
<summary>
Parses a dotted quad version string into a 64-bit unsigned integer.
</summary>
<param name="versionRange">The string containing 1 or 2 dotted quad version strings to parse, e.g. [1.0,) that means 1.0.0.0 or newer.</param>
<param name="minVersion">A 64-bit unsigned integer representing the minimum version, which may be 0. You can compare this to other versions.</param>
<param name="maxVersion">A 64-bit unsigned integer representing the maximum version, which may be MAXULONGLONG. You can compare this to other versions.</param>
</member>
<member name="T:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance2">
<summary>
Information about an instance of a product.
</summary>
<remarks>
You can enumerate all properties of basic types by casting to an <see cref="T:Microsoft.VisualStudio.Setup.Configuration.ISetupPropertyStore"/>.
</remarks>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance2.GetInstanceId">
<summary>
Gets the instance identifier (should match the name of the parent instance directory).
</summary>
<returns>The instance identifier.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance2.GetInstallDate">
<summary>
Gets the local date and time when the installation was originally installed.
</summary>
<returns>The local date and time when the installation was originally installed.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance2.GetInstallationName">
<summary>
Gets the unique name of the installation, often indicating the branch and other information used for telemetry.
</summary>
<returns>The unique name of the installation, often indicating the branch and other information used for telemetry.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance2.GetInstallationPath">
<summary>
Gets the path to the installation root of the product.
</summary>
<returns>The path to the installation root of the product.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance2.GetInstallationVersion">
<summary>
Gets the version of the product installed in this instance.
</summary>
<returns>The version of the product installed in this instance.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance2.GetDisplayName(System.Int32)">
<summary>
Gets the display name (title) of the product installed in this instance.
</summary>
<param name="lcid">The LCID for the display name.</param>
<returns>The display name (title) of the product installed in this instance.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance2.GetDescription(System.Int32)">
<summary>
Gets the description of the product installed in this instance.
</summary>
<param name="lcid">The LCID for the description.</param>
<returns>The description of the product installed in this instance.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance2.ResolvePath(System.String)">
<summary>
Resolves the optional relative path to the root path of the instance.
</summary>
<param name="pwszRelativePath">A relative path within the instance to resolve, or NULL to get the root path.</param>
<returns>The full path to the optional relative path within the instance. If the relative path is NULL, the root path will always terminate in a backslash.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance2.GetState">
<summary>
Gets the state of the instance.
</summary>
<returns>The state of the instance.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance2.GetPackages">
<summary>
Gets an array of package references registered to the instance.
</summary>
<returns>An array of package references registered to the instance.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance2.GetProduct">
<summary>
Gets a package reference to the product registered to the instance
</summary>
<returns>A package reference to the product registered to the instance. This may be null if <see cref="M:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance2.GetState"/> does not return <see cref="F:Microsoft.VisualStudio.Setup.Configuration.InstanceState.Complete"/>.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance2.GetProductPath">
<summary>
Gets the relative path to the product application, if available.
</summary>
<returns>The relative path to the product application, if available.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance2.GetErrors">
<summary>
Gets the error state of the instance, if available.
</summary>
<returns>The error state of the instance, if available.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance2.IsLaunchable">
<summary>
Gets a value indicating whether the instance can be launched.
</summary>
<returns>Whether the instance can be launched.</returns>
<remarks>
An instance could have had errors during install but still be launched. Some features may not work correctly, but others will.
</remarks>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance2.IsComplete">
<summary>
Gets a value indicating whether the instance is complete.
</summary>
<returns>Whether the instance is complete.</returns>
<remarks>
An instance is complete if it had no errors during install, resume, or repair.
</remarks>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance2.GetProperties">
<summary>
Gets product-specific properties.
</summary>
<returns>An <see cref="T:Microsoft.VisualStudio.Setup.Configuration.ISetupPropertyStore"/> of product-specific properties, or null if no properties are defined.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance2.GetEnginePath">
<summary>
Gets the directory path to the setup engine that installed the instance.
</summary>
<returns>The directory path to the setup engine that installed the instance.</returns>
</member>
<member name="T:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance">
<summary>
Information about an instance of a product.
</summary>
<remarks>
You can enumerate all properties of basic types by casting to an <see cref="T:Microsoft.VisualStudio.Setup.Configuration.ISetupPropertyStore"/>.
</remarks>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance.GetInstanceId">
<summary>
Gets the instance identifier (should match the name of the parent instance directory).
</summary>
<returns>The instance identifier.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance.GetInstallDate">
<summary>
Gets the local date and time when the installation was originally installed.
</summary>
<returns>The local date and time when the installation was originally installed.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance.GetInstallationName">
<summary>
Gets the unique name of the installation, often indicating the branch and other information used for telemetry.
</summary>
<returns>The unique name of the installation, often indicating the branch and other information used for telemetry.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance.GetInstallationPath">
<summary>
Gets the path to the installation root of the product.
</summary>
<returns>The path to the installation root of the product.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance.GetInstallationVersion">
<summary>
Gets the version of the product installed in this instance.
</summary>
<returns>The version of the product installed in this instance.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance.GetDisplayName(System.Int32)">
<summary>
Gets the display name (title) of the product installed in this instance.
</summary>
<param name="lcid">The LCID for the display name.</param>
<returns>The display name (title) of the product installed in this instance.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance.GetDescription(System.Int32)">
<summary>
Gets the description of the product installed in this instance.
</summary>
<param name="lcid">The LCID for the description.</param>
<returns>The description of the product installed in this instance.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance.ResolvePath(System.String)">
<summary>
Resolves the optional relative path to the root path of the instance.
</summary>
<param name="pwszRelativePath">A relative path within the instance to resolve, or NULL to get the root path.</param>
<returns>The full path to the optional relative path within the instance. If the relative path is NULL, the root path will always terminate in a backslash.</returns>
</member>
<member name="T:Microsoft.VisualStudio.Setup.Configuration.ISetupPackageReference">
<summary>
A reference to a package.
</summary>
<remarks>
You can enumerate all properties of basic types by casting to an <see cref="T:Microsoft.VisualStudio.Setup.Configuration.ISetupPropertyStore"/>.
</remarks>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupPackageReference.GetId">
<summary>
Gets the general package identifier.
</summary>
<returns>The general package identifier.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupPackageReference.GetVersion">
<summary>
Gets the version of the package.
</summary>
<returns>The version of the package.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupPackageReference.GetChip">
<summary>
Gets the target process architecture of the package.
</summary>
<returns>The target process architecture of the package.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupPackageReference.GetLanguage">
<summary>
Gets the language and optional region identifier.
</summary>
<returns>The language and optional region identifier.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupPackageReference.GetBranch">
<summary>
Gets the build branch of the package.
</summary>
<returns>The build branch of the package.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupPackageReference.GetType">
<summary>
Gets the type of the package.
</summary>
<returns>The type of the package.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupPackageReference.GetUniqueId">
<summary>
Gets the unique identifier consisting of all defined tokens.
</summary>
<returns>The unique identifier consisting of all defined tokens.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupPackageReference.GetIsExtension">
<summary>
Gets a value indicating whether the package refers to an external extension.
</summary>
<returns>A value indicating whether the package refers to an external extension.</returns>
</member>
<member name="T:Microsoft.VisualStudio.Setup.Configuration.ISetupPropertyStore">
<summary>
Provides named properties.
</summary>
<remarks>
You can get this from an <see cref="T:Microsoft.VisualStudio.Setup.Configuration.ISetupInstance"/>, <see cref="T:Microsoft.VisualStudio.Setup.Configuration.ISetupPackageReference"/>, or derivative.
</remarks>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupPropertyStore.GetNames">
<summary>
Gets an array of property names in this property store.
</summary>
<returns>An array of property names in this property store.</returns>
</member>
<member name="M:Microsoft.VisualStudio.Setup.Configuration.ISetupPropertyStore.GetValue(System.String)">
<summary>
Gets the value of a named property in this property store.
</summary>
<param name="pwszName">The name of the property to get.</param>
<returns>The value of the property.</returns>
</member>
<member name="T:Microsoft.VisualStudio.Setup.Configuration.SetupConfiguration">
<summary>
The implementation of <see cref="T:Microsoft.VisualStudio.Setup.Configuration.ISetupConfiguration2"/>.
</summary>
</member>
<member name="T:Microsoft.VisualStudio.Setup.Configuration.SetupConfigurationClass">
<summary>
Class that implements <see cref="T:Microsoft.VisualStudio.Setup.Configuration.ISetupConfiguration"/>.
</summary>
</member>
</members>
</doc>

229
src/Core/Toolchains/MSVCToolchain.cs

@ -5,28 +5,31 @@ using System.IO; @@ -5,28 +5,31 @@ using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Microsoft.Win32;
using Microsoft.VisualStudio.Setup.Configuration;
using System.Runtime.InteropServices;
namespace CppSharp
{
/// Represents a Visual Studio version.
/// <summary>Represents a Visual Studio version.</summary>
public enum VisualStudioVersion
{
VS2012 = 11,
VS2013 = 12,
VS2015 = 14,
VS2017 = 15,
Latest,
}
/// Represents a toolchain with associated version and directory.
/// <summary>Represents a toolchain with associated version and directory.</summary>
public struct ToolchainVersion
{
/// Version of the toolchain.
/// <summary>Version of the toolchain.</summary>
public float Version;
/// Directory location of the toolchain.
/// <summary>Directory location of the toolchain.</summary>
public string Directory;
/// Extra data value associated with the toolchain.
/// <summary>Extra data value associated with the toolchain.</summary>
public string Value;
public override string ToString()
@ -35,6 +38,17 @@ namespace CppSharp @@ -35,6 +38,17 @@ namespace CppSharp
}
}
/// <summary>
/// Describes the major and minor version of something.
/// Each version must be at least non negative and smaller than 100
/// </summary>
public struct Version
{
public int Major;
public int Minor;
}
public static class MSVCToolchain
{
static void DumpSdks(string sku, IEnumerable<ToolchainVersion> sdks)
@ -44,7 +58,7 @@ namespace CppSharp @@ -44,7 +58,7 @@ namespace CppSharp
Console.WriteLine("\t({0}) {1}", sdk.Version, sdk.Directory);
}
/// Dumps the detected SDK versions.
/// <summary>Dumps the detected SDK versions.</summary>
public static void DumpSdks()
{
List<ToolchainVersion> vsSdks;
@ -68,7 +82,7 @@ namespace CppSharp @@ -68,7 +82,7 @@ namespace CppSharp
DumpSdks("MSBuild", msbuildSdks);
}
/// Dumps include directories for selected toolchain.
/// <summary>Dumps include directories for selected toolchain.</summary>
public static void DumpSdkIncludes(VisualStudioVersion vsVersion =
VisualStudioVersion.Latest)
{
@ -78,20 +92,23 @@ namespace CppSharp @@ -78,20 +92,23 @@ namespace CppSharp
Console.WriteLine("\t{0}", include);
}
public static int GetCLVersion(VisualStudioVersion vsVersion)
public static Version GetCLVersion(VisualStudioVersion vsVersion)
{
int clVersion;
Version clVersion;
switch (vsVersion)
{
case VisualStudioVersion.VS2012:
clVersion = 17;
clVersion = new Version { Major = 17, Minor = 0};
break;
case VisualStudioVersion.VS2013:
clVersion = 18;
clVersion = new Version { Major = 18, Minor = 0 };
break;
case VisualStudioVersion.VS2015:
clVersion = new Version { Major = 19, Minor = 0 };
break;
case VisualStudioVersion.VS2017:
case VisualStudioVersion.Latest:
clVersion = 19;
clVersion = new Version { Major = 19, Minor = 10 };
break;
default:
throw new Exception("Unknown Visual Studio version");
@ -109,8 +126,10 @@ namespace CppSharp @@ -109,8 +126,10 @@ namespace CppSharp
case VisualStudioVersion.VS2013:
return 12;
case VisualStudioVersion.VS2015:
case VisualStudioVersion.Latest:
return 14;
case VisualStudioVersion.VS2017:
case VisualStudioVersion.Latest:
return 15;
default:
throw new Exception("Unknown Visual Studio version");
}
@ -163,30 +182,30 @@ namespace CppSharp @@ -163,30 +182,30 @@ namespace CppSharp
var windowsKitSdk = (!string.IsNullOrWhiteSpace(kitsRootKey))
? windowsKitsSdks.Find(version => version.Value == kitsRootKey)
: windowsKitsSdks.Last();
// If for some reason we cannot find the SDK version reported by VS
// in the system, then fallback to the latest version found.
if (windowsKitSdk.Value == null)
windowsKitSdk = windowsKitsSdks.Last();
windowsKitSdk = windowsKitsSdks.Last();
return windowsKitSdk;
}
/// Gets the system include folders for the given Visual Studio version.
public static List<string> GetSystemIncludes(VisualStudioVersion vsVersion)
{
var vsSdk = GetVSToolchain(vsVersion);
int windowsSdkMajorVer;
var windowsKitSdk = GetWindowsKitsToolchain(vsVersion, out windowsSdkMajorVer);
var vsDir = vsSdk.Directory;
vsDir = vsDir.Substring(0, vsDir.LastIndexOf(@"\Common7\IDE",
StringComparison.Ordinal));
var includes = new List<string>();
if(vsVersion == VisualStudioVersion.VS2017 ||
vsVersion == VisualStudioVersion.Latest)
return GetSystemIncludesVS2017(vsDir);
includes.Add(Path.Combine(vsDir, @"VC\include"));
int windowsSdkMajorVer;
var windowsKitSdk = GetWindowsKitsToolchain(vsVersion, out windowsSdkMajorVer);
List<ToolchainVersion> windowsSdks;
GetWindowsSdks(out windowsSdks);
@ -283,7 +302,11 @@ namespace CppSharp @@ -283,7 +302,11 @@ namespace CppSharp
return includes;
}
/// <summary>
/// Gets .NET framework installation directories.
/// </summary>
/// <param name="versions">Collection holding information about available .Net-framework-sdks</param>
/// <returns>Success of the operation</returns>
public static bool GetNetFrameworkSdks(out List<ToolchainVersion> versions)
{
versions = new List<ToolchainVersion>();
@ -304,7 +327,11 @@ namespace CppSharp @@ -304,7 +327,11 @@ namespace CppSharp
return versions.Count != 0;
}
/// <summary>
/// Gets MSBuild installation directories.
/// </summary>
/// <param name="versions">Collection holding information about available ms-build-sdks</param>
/// <returns>Success of the operation</returns>
public static bool GetMSBuildSdks(out List<ToolchainVersion> versions)
{
versions = new List<ToolchainVersion>();
@ -325,7 +352,11 @@ namespace CppSharp @@ -325,7 +352,11 @@ namespace CppSharp
return versions.Count != 0;
}
/// <summary>
/// Gets Windows SDK installation directories.
/// </summary>
/// <param name="versions">Collection holding information about available windows-sdks</param>
/// <returns>Success of the operation</returns>
public static bool GetWindowsSdks(out List<ToolchainVersion> versions)
{
versions = new List<ToolchainVersion>();
@ -339,14 +370,16 @@ namespace CppSharp @@ -339,14 +370,16 @@ namespace CppSharp
GetToolchainsFromSystemRegistry(
"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows",
"InstallationFolder", versions, RegistryView.Registry64);
}
}
versions.Sort((v1, v2) => (int)(v1.Version - v2.Version));
return versions.Count != 0;
}
/// <summary>
/// Gets Windows Kits SDK installation directories.
/// </summary>
/// <param name="versions">Collection holding information about available WindowsKitsSdks</param>
/// <returns>Success of the operation</returns>
public static bool GetWindowsKitsSdks(out List<ToolchainVersion> versions)
{
versions = new List<ToolchainVersion>();
@ -367,7 +400,11 @@ namespace CppSharp @@ -367,7 +400,11 @@ namespace CppSharp
return true;
}
/// <summary>
/// Gets Visual Studio installation directories.
/// </summary>
/// <param name="versions">Collection holding information about available Visual Studio instances</param>
/// <returns>Success of the operation</returns>
public static bool GetVisualStudioSdks(out List<ToolchainVersion> versions)
{
versions = new List<ToolchainVersion>();
@ -394,8 +431,10 @@ namespace CppSharp @@ -394,8 +431,10 @@ namespace CppSharp
"InstallDir", versions, RegistryView.Registry64);
}
versions.Sort((v1, v2) => (int)(v1.Version - v2.Version));
//Check for VS 2017
GetVs2017Instances(versions);
versions.Sort((v1, v2) => (int)(v1.Version - v2.Version));
return true;
}
@ -539,5 +578,147 @@ namespace CppSharp @@ -539,5 +578,147 @@ namespace CppSharp
return hive;
}
#region VS2017
/// <summary>
/// Returns all system includes of the installed VS 2017 instance.
/// </summary>
/// <param name="vsDir">Path to the visual studio installation (for identifying the correct instance)</param>
/// <returns>The system includes</returns>
private static List<string> GetSystemIncludesVS2017(string vsDir)
{
List<string> includes = new List<string>();
//They includes are in a different folder
const int REGDB_E_CLASSNOTREG = unchecked((int)0x80040154);
try
{
var query = new SetupConfiguration();
var query2 = (ISetupConfiguration2)query;
var e = query2.EnumAllInstances();
var helper = (ISetupHelper)query;
int fetched;
var instances = new ISetupInstance[1];
do
{
e.Next(1, instances, out fetched);
if (fetched > 0)
{
var instance = (ISetupInstance2)instances[0];
if (instance.GetInstallationPath() != vsDir) continue;
var packages = instance.GetPackages();
var vc_tools = from package in packages
where package.GetId().Contains("Microsoft.VisualStudio.Component.VC.Tools")
orderby package.GetId()
select package;
if (vc_tools.Count() > 0)
{ // Tools found, get path
var path = instance.GetInstallationPath();
var versionFilePath = path + @"\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt";
var version = System.IO.File.ReadLines(versionFilePath).ElementAt(0).Trim();
includes.Add(path + @"\VC\Tools\MSVC\" + version + @"\include");
includes.Add(path + @"\VC\Tools\MSVC\" + version + @"\atlmfc\include");
}
var sdks = from package in packages
where package.GetId().Contains("Windows10SDK") || package.GetId().Contains("Windows81SDK") || package.GetId().Contains("Win10SDK_10")
select package;
var win10sdks = from sdk in sdks
where sdk.GetId().Contains("Windows10SDK")
select sdk;
var win8sdks = from sdk in sdks
where sdk.GetId().Contains("Windows81SDK")
select sdk;
if (win10sdks.Count() > 0)
{
var sdk = win10sdks.Last();
var path = @"C:\Program Files (x86)\Windows Kits\10\include\" + "10.0." + sdk.GetId().Substring(46) + ".0"; //Microsoft.VisualStudio.Component.Windows10SDK. = 46 chars
var shared = Path.Combine(path, "shared");
var um = Path.Combine(path, "um");
var winrt = Path.Combine(path, "winrt");
var ucrt = Path.Combine(path, "ucrt");
Console.WriteLine(path);
if (Directory.Exists(shared) &&
Directory.Exists(um) &&
Directory.Exists(winrt) &&
Directory.Exists(ucrt))
{
includes.Add(shared);
includes.Add(um);
includes.Add(winrt);
includes.Add(ucrt);
}
}
else if (win8sdks.Count() > 0)
{
includes.Add(@"C:\Program Files (x86)\Windows Kits\8.1\include\shared");
includes.Add(@"C:\Program Files (x86)\Windows Kits\8.1\include\um");
includes.Add(@"C:\Program Files (x86)\Windows Kits\8.1\include\winrt");
}
return includes; //We've collected all information.
}
}
while (fetched > 0);
}
catch (COMException ex) when (ex.HResult == REGDB_E_CLASSNOTREG)
{
Console.WriteLine("The query API is not registered. Assuming no instances are installed.");
}
catch (Exception ex)
{
Console.Error.WriteLine($"Error 0x{ex.HResult:x8}: {ex.Message}");
}
return includes;
}
/// <summary>
/// Tries to get all vs 2017 instances.
/// </summary>
/// <param name="versions">Collection holding available visual studio instances</param>
/// <returns>Success of the operation</returns>
private static bool GetVs2017Instances(ICollection<ToolchainVersion> versions)
{
const int REGDB_E_CLASSNOTREG = unchecked((int)0x80040154);
try
{
var query = new SetupConfiguration();
var query2 = (ISetupConfiguration2)query;
var e = query2.EnumAllInstances();
int fetched;
var instances = new ISetupInstance[1];
do
{
e.Next(1, instances, out fetched);
if (fetched > 0)
{
var instance = (ISetupInstance2)instances[0];
var packages = instance.GetPackages();
var toolchain = new ToolchainVersion
{
Directory = instance.GetInstallationPath() + @"\Common7\IDE",
Version = Single.Parse(instance.GetInstallationVersion().Remove(2)),
Value = null // Not used currently
};
versions.Add(toolchain);
}
}
while (fetched > 0);
}
catch (COMException ex) when (ex.HResult == REGDB_E_CLASSNOTREG)
{
Console.WriteLine("The query API is not registered. Assuming no instances are installed.");
return false;
}
catch (Exception ex)
{
Console.Error.WriteLine($"Error 0x{ex.HResult:x8}: {ex.Message}");
return false;
}
return true;
}
#endregion
}
}

5
src/Core/premake5.lua

@ -8,9 +8,12 @@ project "CppSharp" @@ -8,9 +8,12 @@ project "CppSharp"
files { "**.cs" }
vpaths { ["*"] = "*" }
libdirs{ depsdir .."/vs2017" }
links
{
"System",
"System.Core",
"Microsoft.VisualStudio.Setup.Configuration.Interop"
}

3
src/Parser/ParserOptions.cs

@ -20,7 +20,8 @@ namespace CppSharp.Parser @@ -20,7 +20,8 @@ namespace CppSharp.Parser
NoBuiltinIncludes = true;
NoStandardIncludes = true;
Abi = CppAbi.Microsoft;
ToolSetToUse = MSVCToolchain.GetCLVersion(vsVersion) * 10000000;
var clVersion = MSVCToolchain.GetCLVersion(vsVersion);
ToolSetToUse = clVersion.Major * 10000000 + clVersion.Minor * 100000;
AddArguments("-fms-extensions");
AddArguments("-fms-compatibility");

Loading…
Cancel
Save