public override void GeneratePlatformSpecificProjectDescription(IVcxprojGenerationContext context, IFileGenerator generator) { string platformFolder = MSBuildGlobalSettings.GetCppPlatformFolder(context.DevelopmentEnvironmentsRange.MinDevEnv, Platform.win64); if (string.IsNullOrEmpty(platformFolder) || !ClangForWindows.Settings.OverridenLLVMInstallDir) { return; } generator.Write(Vcxproj.Template.Project.ProjectDescriptionStartPlatformConditional); { if (!string.IsNullOrEmpty(platformFolder)) { using (generator.Declare("custompropertyname", "_PlatformFolder")) using (generator.Declare("custompropertyvalue", Util.EnsureTrailingSeparator(platformFolder))) // _PlatformFolder require the path to end with a "\" generator.Write(Vcxproj.Template.Project.CustomProperty); } if (ClangForWindows.Settings.OverridenLLVMInstallDir) { using (generator.Declare("custompropertyname", "LLVMInstallDir")) using (generator.Declare("custompropertyvalue", ClangForWindows.Settings.LLVMInstallDir.TrimEnd(Util._pathSeparators))) // trailing separator will be added by LLVM.Cpp.Common.props generator.Write(Vcxproj.Template.Project.CustomProperty); } } generator.Write(Vcxproj.Template.Project.PropertyGroupEnd); }
public static string GetWindowsIncludePath(this DevEnv visualVersion) { string visualStudioDir = Util.EnsureTrailingSeparator(visualVersion.GetVisualStudioVCRootPath()); string visualStudioInclude = string.Format(@"{0}include;{0}atlmfc\include", visualStudioDir); KitsRootEnum useKitsRoot = KitsRootPaths.GetUseKitsRootForDevEnv(visualVersion); switch (useKitsRoot) { case KitsRootEnum.KitsRoot: { string kitsRoot = Util.EnsureTrailingSeparator(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot)); return(String.Format(@"{0};{1}Include\shared;{1}Include\um;{1}Include\WinRT;", visualStudioInclude, kitsRoot)); } case KitsRootEnum.KitsRoot81: { string kitsRoot = Util.EnsureTrailingSeparator(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot81)); return(String.Format(@"{0};{1}Include\shared;{1}Include\um;{1}Include\WinRT;", visualStudioInclude, kitsRoot)); } case KitsRootEnum.KitsRoot10: { string kitsRoot10 = Util.EnsureTrailingSeparator(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot10)); Options.Vc.General.WindowsTargetPlatformVersion windowsTargetPlatformVersion = KitsRootPaths.GetWindowsTargetPlatformVersionForDevEnv(visualVersion); string platformVersion = windowsTargetPlatformVersion.ToVersionString(); var paths = new List <string> { $@"{visualStudioInclude}", $@"{kitsRoot10}Include\{platformVersion}\um", // $(UM_IncludePath) $@"{kitsRoot10}Include\{platformVersion}\shared", // $(KIT_SHARED_IncludePath) $@"{kitsRoot10}Include\{platformVersion}\winrt", // $(WinRT_IncludePath) $@"{kitsRoot10}Include\{platformVersion}\ucrt", // $(UniversalCRT_IncludePath) }; if (windowsTargetPlatformVersion <= Options.Vc.General.WindowsTargetPlatformVersion.v10_0_10240_0) { // // Version 10.0.10240.0 and below only contain the UCRT libraries // and headers, not the usual Win32 stuff. So if we are using // version 10240 or older, also include the Windows 8.1 paths so we // have a complete Win32 support. // string kitsRoot81 = Util.EnsureTrailingSeparator(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot81)); paths.AddRange(new[] { $@"{kitsRoot81}Include\um", $@"{kitsRoot81}Include\shared" }); } return(string.Join(";", paths)); } default: throw new NotImplementedException("No WindowsResourceCompiler associated with " + visualVersion); } }
public static string GetDurangoLibraryPath(this DevEnv visualVersion) { string durangoXDKPath = Util.EnsureTrailingSeparator( Path.Combine( GlobalSettings.DurangoXDK, Durango.Util.IsDurangoSideBySideXDK() ? GlobalSettings.XdkEditionTarget : string.Empty ) ); switch (visualVersion) { case DevEnv.vs2012: { if (Durango.Util.IsDurangoSideBySideXDK()) { return(string.Format( string.Concat( @"{0}xdk\lib\amd64;", @"{0}Compilers\dev11.1\crt\lib\amd64;", @"{0}Compilers\dev11.1\crt\platform\amd64;" ), durangoXDKPath )); } else { return(string.Format( string.Concat( @"{0}xdk\lib\amd64;", @"{0}xdk\crt\lib\amd64;", @"{0}xdk\crt\platform\amd64;" ), durangoXDKPath )); } } case DevEnv.vs2015: case DevEnv.vs2017: { // Paths are the same regardless of what version of XDK you are using unlike VS2012 return(string.Format( string.Concat( @"{0}xdk\Lib\amd64;", @"{0}xdk\ucrt\lib\amd64;", @"{0}xdk\VS2015\vc\lib\amd64;", @"{0}xdk\VS2015\vc\platform\amd64;" ), durangoXDKPath )); } default: throw new NotImplementedException("No DurangoLibraryPath associated with " + visualVersion); } }
public override void GeneratePlatformSpecificProjectDescription(IVcxprojGenerationContext context, IFileGenerator generator) { if (!ClangForWindows.Settings.OverridenLLVMInstallDir) { return; } if (context.DevelopmentEnvironmentsRange.MinDevEnv != context.DevelopmentEnvironmentsRange.MaxDevEnv) { throw new Error("Different vs versions not supported in the same vcxproj"); } DevEnv uniqueDevEnv = context.DevelopmentEnvironmentsRange.MinDevEnv; using (generator.Declare("platformName", SimplePlatformString)) { generator.Write(Vcxproj.Template.Project.ProjectDescriptionStartPlatformConditional); { switch (uniqueDevEnv) { case DevEnv.vs2017: { string platformFolder = MSBuildGlobalSettings.GetCppPlatformFolder(context.DevelopmentEnvironmentsRange.MinDevEnv, Platform.win64); if (!string.IsNullOrEmpty(platformFolder)) { using (generator.Declare("platformFolder", Util.EnsureTrailingSeparator(platformFolder))) // _PlatformFolder require the path to end with a "\" generator.Write(Vcxproj.Template.Project.PlatformFolderOverride); } } break; case DevEnv.vs2019: { // Note1: _PlatformFolder override is deprecated starting with vs2019, so we write AdditionalVCTargetsPath instead // Note2: MSBuildGlobalSettings.SetCppPlatformFolder for vs2019 is no more the valid way to handle it. Older buildtools packages can anyway contain it, and need upgrade. if (!string.IsNullOrEmpty(MSBuildGlobalSettings.GetCppPlatformFolder(uniqueDevEnv, Platform.win64))) { throw new Error("SetCppPlatformFolder is not supported by VS2019 correctly: use of MSBuildGlobalSettings.SetCppPlatformFolder should be replaced by use of MSBuildGlobalSettings.SetAdditionalVCTargetsPath."); } // vs2019 use AdditionalVCTargetsPath string additionalVCTargetsPath = MSBuildGlobalSettings.GetAdditionalVCTargetsPath(uniqueDevEnv, Platform.win64); using (generator.Declare("additionalVCTargetsPath", Util.EnsureTrailingSeparator(additionalVCTargetsPath))) // the path shall end with a "\" generator.Write(Vcxproj.Template.Project.AdditionalVCTargetsPath); } break; default: throw new Error(uniqueDevEnv + " is not supported."); } ClangForWindows.WriteLLVMOverrides(context, generator); } generator.Write(Vcxproj.Template.Project.PropertyGroupEnd); } }
public static string GetDurangoIncludePath(this DevEnv visualVersion) { string durangoXDKPath = Util.EnsureTrailingSeparator( Path.Combine( GlobalSettings.DurangoXDK, Durango.Util.IsDurangoSideBySideXDK() ? GlobalSettings.XdkEditionTarget : string.Empty ) ); List <string> includePath = new List <string>(); includePath.Add(@"{0}xdk\Include\um;"); includePath.Add(@"{0}xdk\Include\shared;"); includePath.Add(@"{0}xdk\Include\winrt;"); switch (visualVersion) { case DevEnv.vs2012: { if (Durango.Util.IsDurangoSideBySideXDK()) { includePath.Add(@"{0}Compilers\dev11.1\crt\include;"); includePath.Add(@"{0}Compilers\dev11.1\crt\platform\amd64;"); } else { includePath.Add(@"{0}xdk\crt\include;"); includePath.Add(@"{0}xdk\crt\platform\amd64;"); } } break; case DevEnv.vs2015: case DevEnv.vs2017: { // Paths are the same regardless of what version of XDK you are using unlike VS2012 includePath.Add(@"{0}xdk\ucrt\inc;"); includePath.Add(@"{0}xdk\VS2015\vc\include;"); includePath.Add(@"{0}xdk\VS2015\vc\platform\amd64;"); } break; default: throw new NotImplementedException("No DurangoIncludePath associated with " + visualVersion); } includePath.Add(@"{0}xdk;"); // needed? return(string.Format(string.Join("", includePath), durangoXDKPath)); }
public override void GeneratePlatformSpecificProjectDescription(IVcxprojGenerationContext context, IFileGenerator generator) { string propertyGroups = string.Empty; // MSBuild override when mixing devenvs in the same vcxproj is not supported, // but before throwing an exception check if we have some override for (DevEnv devEnv = context.DevelopmentEnvironmentsRange.MinDevEnv; devEnv <= context.DevelopmentEnvironmentsRange.MaxDevEnv; devEnv = (DevEnv)((int)devEnv << 1)) { switch (devEnv) { case DevEnv.vs2015: case DevEnv.vs2017: { string platformFolder = MSBuildGlobalSettings.GetCppPlatformFolder(devEnv, Platform.win64); if (!string.IsNullOrEmpty(platformFolder)) { using (generator.Declare("platformFolder", Util.EnsureTrailingSeparator(platformFolder))) // _PlatformFolder require the path to end with a "\" propertyGroups += generator.Resolver.Resolve(Vcxproj.Template.Project.PlatformFolderOverride); } } break; case DevEnv.vs2019: case DevEnv.vs2022: { // Note1: _PlatformFolder override is deprecated starting with vs2019, so we write AdditionalVCTargetsPath instead // Note2: MSBuildGlobalSettings.SetCppPlatformFolder for vs2019 and above is no more the valid way to handle it. if (!string.IsNullOrEmpty(MSBuildGlobalSettings.GetCppPlatformFolder(devEnv, Platform.win64))) { throw new Error($"SetCppPlatformFolder is not supported by {devEnv}: use of MSBuildGlobalSettings.SetCppPlatformFolder should be replaced by use of MSBuildGlobalSettings.SetAdditionalVCTargetsPath."); } // vs2019 and up use AdditionalVCTargetsPath string additionalVCTargetsPath = MSBuildGlobalSettings.GetAdditionalVCTargetsPath(devEnv, Platform.win64); if (!string.IsNullOrEmpty(additionalVCTargetsPath)) { using (generator.Declare("additionalVCTargetsPath", Util.EnsureTrailingSeparator(additionalVCTargetsPath))) // the path shall end with a "\" propertyGroups += generator.Resolver.Resolve(Vcxproj.Template.Project.AdditionalVCTargetsPath); } } break; } } string llvmOverrideSection = ClangForWindows.GetLLVMOverridesSection(context, generator.Resolver); if (!string.IsNullOrEmpty(llvmOverrideSection)) { propertyGroups += llvmOverrideSection; } if (!string.IsNullOrEmpty(propertyGroups)) { if (context.DevelopmentEnvironmentsRange.MinDevEnv != context.DevelopmentEnvironmentsRange.MaxDevEnv) { throw new Error("Different vs versions not supported in the same vcxproj"); } using (generator.Declare("platformName", SimplePlatformString)) { generator.Write(Vcxproj.Template.Project.ProjectDescriptionStartPlatformConditional); generator.WriteVerbatim(propertyGroups); generator.Write(Vcxproj.Template.Project.PropertyGroupEnd); } } }
public static string GetWindowsLibraryPath(this DevEnv visualVersion, Platform platform, DotNetFramework?dotNetFramework = null) { string visualStudioVCDir = Util.EnsureTrailingSeparator(visualVersion.GetVisualStudioVCRootPath()); string subDir = platform == Platform.win64 ? @"\amd64" : ""; if ((visualVersion == DevEnv.vs2017) || (visualVersion == DevEnv.vs2019)) { subDir = platform == Platform.win64 ? @"\x64" : @"\x86"; } string visualStudioLib = string.Format(@"{0}lib{1};{0}atlmfc\lib{1};", visualStudioVCDir, subDir); if (visualVersion == DevEnv.vs2010) { return(visualStudioLib); } else { KitsRootEnum useKitsRoot = KitsRootPaths.GetUseKitsRootForDevEnv(visualVersion); string targetPlatform = platform == Platform.win64 ? "x64" : "x86"; switch (useKitsRoot) { case KitsRootEnum.KitsRoot: { string kitsRoot = Util.EnsureTrailingSeparator(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot)); return(string.Format(@"{0};{1}lib\win8\um\{2};{1}References\CommonConfiguration\Neutral;", visualStudioLib, kitsRoot, targetPlatform)); } case KitsRootEnum.KitsRoot81: { string kitsRoot = Util.EnsureTrailingSeparator(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot81)); return(string.Format(@"{0};{1}lib\winv6.3\um\{2};{1}References\CommonConfiguration\Neutral;", visualStudioLib, kitsRoot, targetPlatform)); } case KitsRootEnum.KitsRoot10: { string netFxPath = string.Empty; if (dotNetFramework.HasValue && visualVersion >= DevEnv.vs2015) { string netFXKitsDir = Util.EnsureTrailingSeparator(KitsRootPaths.GetNETFXKitsDir(dotNetFramework.Value < DotNetFramework.v4_6 ? DotNetFramework.v4_6 : dotNetFramework.Value)); netFxPath = Path.Combine(netFXKitsDir, "Lib", "um", targetPlatform); } string kitsRoot10 = KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot10); Options.Vc.General.WindowsTargetPlatformVersion windowsTargetPlatformVersion = KitsRootPaths.GetWindowsTargetPlatformVersionForDevEnv(visualVersion); string platformVersion = windowsTargetPlatformVersion.ToVersionString(); var paths = new[] { visualStudioLib, Path.Combine(kitsRoot10, "Lib", platformVersion, "ucrt", targetPlatform), // $(UniversalCRT_LibraryPath_x86) or $(UniversalCRT_LibraryPath_x64) Path.Combine(kitsRoot10, "Lib", platformVersion, "um", targetPlatform), // $(WindowsSDK_LibraryPath_x86) or $(WindowsSDK_LibraryPath_x64) netFxPath }.ToList(); if (windowsTargetPlatformVersion <= Options.Vc.General.WindowsTargetPlatformVersion.v10_0_10240_0) { string kitsRoot81 = KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot81); paths.AddRange(new[] { Path.Combine(kitsRoot81, "lib", "winv6.3", "um", targetPlatform), Path.Combine(kitsRoot81, "References", "CommonConfiguration", "Neutral") }); } return(string.Join(";", paths)); } default: throw new NotImplementedException("No WindowsResourceCompiler associated with " + visualVersion); } } }
protected virtual void WriteWindowsKitsOverrides(IVcxprojGenerationContext context, IFileGenerator fileGenerator) { KitsRootEnum?kitsRootWritten = null; for (DevEnv devEnv = context.DevelopmentEnvironmentsRange.MinDevEnv; devEnv <= context.DevelopmentEnvironmentsRange.MaxDevEnv; devEnv = (DevEnv)((int)devEnv << 1)) { // there's no need to write the properties with older versions of vs, as we override // completely the VC++ directories entries in the vcxproj if (devEnv < DevEnv.vs2015) { continue; } KitsRootEnum kitsRootVersion = KitsRootPaths.GetUseKitsRootForDevEnv(devEnv); if (kitsRootWritten == null) { kitsRootWritten = kitsRootVersion; } else if (kitsRootWritten != kitsRootVersion) { throw new Error($"Different values of kitsRoot in the same vcxproj {context.ProjectFileName}"); } else { continue; } string windowsSdkDirKey = FileGeneratorUtilities.RemoveLineTag; string windowsSdkDirValue = FileGeneratorUtilities.RemoveLineTag; string UniversalCRTSdkDir_10 = FileGeneratorUtilities.RemoveLineTag; string UCRTContentRoot = FileGeneratorUtilities.RemoveLineTag; string targetPlatformVersionString = FileGeneratorUtilities.RemoveLineTag; if (kitsRootVersion != KitsRootEnum.KitsRoot81) // 8.1 is the default value for vs2015 and vs2017, so only specify a different platformVersion if we need to { targetPlatformVersionString = KitsRootPaths.GetWindowsTargetPlatformVersionForDevEnv(devEnv).ToVersionString(); } if (devEnv.OverridenWindowsPath()) { windowsSdkDirValue = Util.EnsureTrailingSeparator(KitsRootPaths.GetRoot(kitsRootVersion)); switch (kitsRootVersion) { case KitsRootEnum.KitsRoot: windowsSdkDirKey = "WindowsSdkDir_80"; break; case KitsRootEnum.KitsRoot81: windowsSdkDirKey = "WindowsSdkDir_81"; break; case KitsRootEnum.KitsRoot10: { windowsSdkDirKey = "WindowsSdkDir_10"; UniversalCRTSdkDir_10 = windowsSdkDirValue; // this variable is found in Windows Kits\10\DesignTime\CommonConfiguration\Neutral\uCRT.props // it is always read from the registry unless overridden, so we need to explicitly set it UCRTContentRoot = windowsSdkDirValue; } break; default: throw new NotImplementedException($"Unsupported kitsRoot '{kitsRootVersion}'"); } } using (fileGenerator.Declare("windowsSdkDirKey", windowsSdkDirKey)) using (fileGenerator.Declare("windowsSdkDirValue", windowsSdkDirValue)) using (fileGenerator.Declare("UniversalCRTSdkDir_10", UniversalCRTSdkDir_10)) using (fileGenerator.Declare("UCRTContentRoot", UCRTContentRoot)) using (fileGenerator.Declare("targetPlatformVersion", targetPlatformVersionString)) { fileGenerator.Write(_windowsSDKOverridesBegin); // vs2015 specific, we need to set the UniversalCRTSdkDir to $(UniversalCRTSdkDir_10) because it is not done in the .props if (devEnv == DevEnv.vs2015 && !string.Equals(UniversalCRTSdkDir_10, FileGeneratorUtilities.RemoveLineTag, StringComparison.Ordinal)) { using (fileGenerator.Declare("custompropertyname", "UniversalCRTSdkDir")) using (fileGenerator.Declare("custompropertyvalue", "$(UniversalCRTSdkDir_10)")) { fileGenerator.Write(fileGenerator.Resolver.Resolve(Vcxproj.Template.Project.CustomProperty)); } } fileGenerator.Write(_windowsSDKOverridesEnd); } } }