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 override void GeneratePlatformSpecificProjectDescription(IVcxprojGenerationContext context, IFileGenerator generator) { generator.Write(_projectStartPlatformConditional); string msBuildPathOverrides = 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.vs2017: case DevEnv.vs2019: case DevEnv.vs2022: { // _PlatformFolder override is not enough for android, we need to know the AdditionalVCTargetsPath // Note that AdditionalVCTargetsPath is not officially supported by vs2017, but we use the variable anyway for convenience and consistency if (!string.IsNullOrEmpty(MSBuildGlobalSettings.GetCppPlatformFolder(devEnv, SharpmakePlatform))) { throw new Error($"SetCppPlatformFolder is not supported by {devEnv}: use of MSBuildGlobalSettings.SetCppPlatformFolder should be replaced by use of MSBuildGlobalSettings.SetAdditionalVCTargetsPath."); } string additionalVCTargetsPath = MSBuildGlobalSettings.GetAdditionalVCTargetsPath(devEnv, SharpmakePlatform); if (!string.IsNullOrEmpty(additionalVCTargetsPath)) { using (generator.Declare("additionalVCTargetsPath", Sharpmake.Util.EnsureTrailingSeparator(additionalVCTargetsPath))) msBuildPathOverrides += generator.Resolver.Resolve(Vcxproj.Template.Project.AdditionalVCTargetsPath); } } break; } } using (generator.Declare("androidApplicationModule", Options.GetOptionValue("androidApplicationModule", context.ProjectConfigurationOptions.Values))) using (generator.Declare("androidHome", Options.GetOptionValue("androidHome", context.ProjectConfigurationOptions.Values))) using (generator.Declare("javaHome", Options.GetOptionValue("javaHome", context.ProjectConfigurationOptions.Values))) using (generator.Declare("androidNdkVersion", Options.GetOptionValue("androidNdkVersion", context.ProjectConfigurationOptions.Values))) using (generator.Declare("androidMinSdkVersion", Options.GetOptionValue("androidMinSdkVersion", context.ProjectConfigurationOptions.Values))) using (generator.Declare("ndkRoot", Options.GetOptionValue("ndkRoot", context.ProjectConfigurationOptions.Values))) using (generator.Declare("androidEnablePackaging", Options.GetOptionValue("androidEnablePackaging", context.ProjectConfigurationOptions.Values))) using (generator.Declare("androidGradleBuildDir", Options.GetOptionValue("androidGradleBuildDir", context.ProjectConfigurationOptions.Values))) { generator.Write(_projectDescriptionPlatformSpecific); } if (!string.IsNullOrEmpty(msBuildPathOverrides)) { if (context.DevelopmentEnvironmentsRange.MinDevEnv != context.DevelopmentEnvironmentsRange.MaxDevEnv) { throw new Error("Different vs versions not supported in the same vcxproj"); } generator.WriteVerbatim(msBuildPathOverrides); } generator.Write(Vcxproj.Template.Project.ProjectDescriptionEnd); }
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 override void GeneratePostDefaultPropsImport(IVcxprojGenerationContext context, IFileGenerator generator) { base.GeneratePostDefaultPropsImport(context, generator); var devEnv = context.DevelopmentEnvironmentsRange.MinDevEnv; if (devEnv == DevEnv.vs2017 || devEnv == DevEnv.vs2019) { // in case we've written an additional vc targets path, we need to set a couple of properties to avoid a warning if (!string.IsNullOrEmpty(MSBuildGlobalSettings.GetAdditionalVCTargetsPath(devEnv, SharpmakePlatform))) { generator.WriteVerbatim(_postImportAppTypeProps); } } }
public override void GenerateProjectPlatformSdkDirectoryDescription(IVcxprojGenerationContext context, IFileGenerator generator) { base.GenerateProjectPlatformSdkDirectoryDescription(context, generator); var devEnv = context.DevelopmentEnvironmentsRange.MinDevEnv; if (devEnv == DevEnv.vs2019) { string additionalVCTargetsPath = MSBuildGlobalSettings.GetAdditionalVCTargetsPath(devEnv, SharpmakePlatform); if (!string.IsNullOrEmpty(additionalVCTargetsPath)) { generator.WriteVerbatim(_projectImportAppTypeProps); } } }
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 override void GeneratePlatformSpecificProjectDescription(IVcxprojGenerationContext context, IFileGenerator generator) { generator.Write(_projectStartPlatformConditional); string applicationType = "Android"; string applicationTypeRevision = Options.GetOptionValue("applicationTypeRevision", context.ProjectConfigurationOptions.Values); string msBuildPathOverrides = 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.vs2017: case DevEnv.vs2019: { // _PlatformFolder override is not enough for android, we need to know the AdditionalVCTargetsPath // Note that AdditionalVCTargetsPath is not officially supported by vs2017, but we use the variable anyway for convenience and consistency if (!string.IsNullOrEmpty(MSBuildGlobalSettings.GetCppPlatformFolder(devEnv, SharpmakePlatform))) { throw new Error("SetCppPlatformFolder is not supported by AndroidPlatform correctly: use of MSBuildGlobalSettings.SetCppPlatformFolder should be replaced by use of MSBuildGlobalSettings.SetAdditionalVCTargetsPath."); } string additionalVCTargetsPath = MSBuildGlobalSettings.GetAdditionalVCTargetsPath(devEnv, SharpmakePlatform); if (!string.IsNullOrEmpty(additionalVCTargetsPath)) { using (generator.Declare("additionalVCTargetsPath", Sharpmake.Util.EnsureTrailingSeparator(additionalVCTargetsPath))) msBuildPathOverrides += generator.Resolver.Resolve(Vcxproj.Template.Project.AdditionalVCTargetsPath); // with vs2017, we need to set the _PlatformDefaultPropsPath property // otherwise the Microsoft.Cpp.Default.props won't be able to find the default platform props correctly if (devEnv == DevEnv.vs2017) { using (generator.Declare("applicationTypeRevision", applicationTypeRevision)) msBuildPathOverrides += generator.Resolver.Resolve(_projectPlatformDefaultPropsPath); // application type and revisions need to be cleared otherwise // the inclusion of the cpp default props will use the files from // the local vs installation and not the redirected one.. applicationType = RemoveLineTag; applicationTypeRevision = RemoveLineTag; } } } break; } } using (generator.Declare("applicationType", applicationType)) using (generator.Declare("applicationTypeRevision", applicationTypeRevision)) using (generator.Declare("androidHome", Options.GetOptionValue("androidHome", context.ProjectConfigurationOptions.Values))) using (generator.Declare("antHome", Options.GetOptionValue("antHome", context.ProjectConfigurationOptions.Values))) using (generator.Declare("javaHome", Options.GetOptionValue("javaHome", context.ProjectConfigurationOptions.Values))) using (generator.Declare("ndkRoot", Options.GetOptionValue("ndkRoot", context.ProjectConfigurationOptions.Values))) { generator.Write(_projectDescriptionPlatformSpecific); } if (!string.IsNullOrEmpty(msBuildPathOverrides)) { if (context.DevelopmentEnvironmentsRange.MinDevEnv != context.DevelopmentEnvironmentsRange.MaxDevEnv) { throw new Error("Different vs versions not supported in the same vcxproj"); } generator.WriteVerbatim(msBuildPathOverrides); } generator.Write(Vcxproj.Template.Project.ProjectDescriptionEnd); }
public override void GeneratePlatformSpecificProjectDescription(IVcxprojGenerationContext context, IFileGenerator generator) { // When writing android properties section, do not add conditional properties for x64 and x86 if those // android targets are not used. This allows arm only projects to live alongside windows x64/x86 projects in the same file var buildTargets = context.ProjectConfigurationOptions .Where(conf => conf.Key.Platform == Platform.android && conf.Key.Target.HaveFragment <AndroidBuildTargets>()) .Select(conf => conf.Key.Target.GetFragment <AndroidBuildTargets>()) .Distinct() .Select(bt => { if (bt == AndroidBuildTargets.arm64_v8a) { return("ARM64"); } if (bt == AndroidBuildTargets.armeabi_v7a) { return("ARM"); } if (bt == AndroidBuildTargets.x86) { return("x86"); } /*if (bt == AndroidBuildTargets.x86_64)*/ return("x64"); }) .Select(bt => { using (generator.Declare("platform", bt)) return(generator.Resolver.Resolve(_projectStartPlatformConditionalPart)); }); using (generator.Declare("condition", string.Join(" OR ", buildTargets))) { generator.Write(_projectStartPlatformConditional); } string applicationType = "Android"; string applicationTypeRevision = Options.GetOptionValue("applicationTypeRevision", context.ProjectConfigurationOptions.Values, Options.Android.General.ApplicationTypeRevision.Default); string msBuildPathOverrides = 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.vs2017: case DevEnv.vs2019: case DevEnv.vs2022: { // _PlatformFolder override is not enough for android, we need to know the AdditionalVCTargetsPath // Note that AdditionalVCTargetsPath is not officially supported by vs2017, but we use the variable anyway for convenience and consistency if (!string.IsNullOrEmpty(MSBuildGlobalSettings.GetCppPlatformFolder(devEnv, SharpmakePlatform))) { throw new Error($"SetCppPlatformFolder is not supported by {devEnv}: use of MSBuildGlobalSettings.SetCppPlatformFolder should be replaced by use of MSBuildGlobalSettings.SetAdditionalVCTargetsPath."); } string additionalVCTargetsPath = MSBuildGlobalSettings.GetAdditionalVCTargetsPath(devEnv, SharpmakePlatform); if (!string.IsNullOrEmpty(additionalVCTargetsPath)) { using (generator.Declare("additionalVCTargetsPath", Sharpmake.Util.EnsureTrailingSeparator(additionalVCTargetsPath))) msBuildPathOverrides += generator.Resolver.Resolve(Vcxproj.Template.Project.AdditionalVCTargetsPath); // with vs2017, we need to set the _PlatformDefaultPropsPath property // otherwise the Microsoft.Cpp.Default.props won't be able to find the default platform props correctly if (devEnv == DevEnv.vs2017) { using (generator.Declare("applicationTypeRevision", applicationTypeRevision)) msBuildPathOverrides += generator.Resolver.Resolve(_projectPlatformDefaultPropsPath); // application type and revisions need to be cleared otherwise // the inclusion of the cpp default props will use the files from // the local vs installation and not the redirected one.. applicationType = RemoveLineTag; applicationTypeRevision = RemoveLineTag; } } } break; } } using (generator.Declare("applicationType", applicationType)) using (generator.Declare("applicationTypeRevision", applicationTypeRevision)) using (generator.Declare("androidHome", Options.GetOptionValue("androidHome", context.ProjectConfigurationOptions.Values))) using (generator.Declare("antHome", Options.GetOptionValue("antHome", context.ProjectConfigurationOptions.Values))) using (generator.Declare("javaHome", Options.GetOptionValue("javaHome", context.ProjectConfigurationOptions.Values))) using (generator.Declare("ndkRoot", Options.GetOptionValue("ndkRoot", context.ProjectConfigurationOptions.Values))) { generator.Write(_projectDescriptionPlatformSpecific); } if (!string.IsNullOrEmpty(msBuildPathOverrides)) { if (context.DevelopmentEnvironmentsRange.MinDevEnv != context.DevelopmentEnvironmentsRange.MaxDevEnv) { throw new Error("Different vs versions not supported in the same vcxproj"); } generator.WriteVerbatim(msBuildPathOverrides); } generator.Write(Vcxproj.Template.Project.ProjectDescriptionEnd); }
public override void GeneratePlatformSpecificProjectDescription(IVcxprojGenerationContext context, IFileGenerator generator) { if (GlobalSettings.OverridenDurangoXDK) { string durangoXdkKitPath = FileGeneratorUtilities.RemoveLineTag; string xdkEditionTarget = FileGeneratorUtilities.RemoveLineTag; string targetPlatformSdkPath = FileGeneratorUtilities.RemoveLineTag; string durangoXdkCompilers = FileGeneratorUtilities.RemoveLineTag; string gameOSFilePath = FileGeneratorUtilities.RemoveLineTag; string durangoXdkTasks = FileGeneratorUtilities.RemoveLineTag; string targetPlatformIdentifier = FileGeneratorUtilities.RemoveLineTag; string platformFolder = MSBuildGlobalSettings.GetCppPlatformFolder(context.DevelopmentEnvironmentsRange.MinDevEnv, Platform.durango); string xdkEditionRootVS2015 = FileGeneratorUtilities.RemoveLineTag; string xdkEditionRootVS2017 = FileGeneratorUtilities.RemoveLineTag; string enableLegacyXdkHeaders = FileGeneratorUtilities.RemoveLineTag; if (!Util.IsDurangoSideBySideXDK()) { durangoXdkKitPath = Sharpmake.Util.EnsureTrailingSeparator(Path.Combine(GlobalSettings.DurangoXDK, "xdk")); // Set only if the machine has a SideBySide XDK installed, but we don't generate for one if (Util.IsDurangoSideBySideXDKInstalled()) { if (context.ProjectConfigurations.Any(conf => !conf.IsFastBuild)) { durangoXdkCompilers = durangoXdkKitPath; } gameOSFilePath = Path.Combine(GlobalSettings.DurangoXDK, "sideload", "era.xvd"); // Use the tasks of the system durangoXdkTasks = Sharpmake.Util.EnsureTrailingSeparator(Path.Combine(Util.GetDurangoXDKInstallPath(), Util.GetLatestDurangoSideBySideXDKInstalled(), "PC", "tasks")); targetPlatformIdentifier = "Xbox.xdk"; } } else { xdkEditionTarget = GlobalSettings.XdkEditionTarget; targetPlatformSdkPath = Util.GetDurangoExtensionXDK(); } generator.Write(Vcxproj.Template.Project.ProjectDescriptionStartPlatformConditional); { if (!string.IsNullOrEmpty(platformFolder)) { using (generator.Declare("custompropertyname", "_PlatformFolder")) using (generator.Declare("custompropertyvalue", Sharpmake.Util.EnsureTrailingSeparator(platformFolder))) // _PlatformFolder require the path to end with a "\" generator.Write(Vcxproj.Template.Project.CustomProperty); } if (DevEnv.vs2015 >= context.DevelopmentEnvironmentsRange.MinDevEnv && DevEnv.vs2015 <= context.DevelopmentEnvironmentsRange.MaxDevEnv) { var vs2015PlatformFolder = MSBuildGlobalSettings.GetCppPlatformFolder(DevEnv.vs2015, Platform.durango); if (!string.IsNullOrEmpty(vs2015PlatformFolder)) { xdkEditionRootVS2015 = vs2015PlatformFolder; } } if (DevEnv.vs2017 >= context.DevelopmentEnvironmentsRange.MinDevEnv && DevEnv.vs2017 <= context.DevelopmentEnvironmentsRange.MaxDevEnv) { var vs2017PlatformFolder = MSBuildGlobalSettings.GetCppPlatformFolder(DevEnv.vs2017, Platform.durango); if (!string.IsNullOrEmpty(vs2017PlatformFolder)) { xdkEditionRootVS2017 = vs2017PlatformFolder; } int xdkEdition; bool isMinFeb2018Xdk = Util.TryParseXdkEditionTarget(GlobalSettings.XdkEditionTarget, out xdkEdition) && xdkEdition >= GlobalSettings._feb2018XdkEditionTarget; if (GlobalSettings.EnableLegacyXdkHeaders && isMinFeb2018Xdk) { enableLegacyXdkHeaders = "true"; } } using (generator.Declare("durangoXdkInstallPath", GlobalSettings.DurangoXDK)) using (generator.Declare("sdkReferenceDirectoryRoot", GlobalSettings.XboxOneExtensionSDK)) using (generator.Declare("durangoXdkKitPath", durangoXdkKitPath)) using (generator.Declare("xdkEditionTarget", xdkEditionTarget)) using (generator.Declare("targetPlatformSdkPath", targetPlatformSdkPath)) using (generator.Declare("durangoXdkCompilers", durangoXdkCompilers)) using (generator.Declare("gameOSFilePath", gameOSFilePath)) using (generator.Declare("durangoXdkTasks", durangoXdkTasks)) using (generator.Declare("targetPlatformIdentifier", targetPlatformIdentifier)) using (generator.Declare("xdkEditionRootVS2015", xdkEditionRootVS2015)) using (generator.Declare("xdkEditionRootVS2017", xdkEditionRootVS2017)) using (generator.Declare("enableLegacyXdkHeaders", enableLegacyXdkHeaders)) { generator.Write(_projectDescriptionPlatformSpecific); } } generator.Write(Vcxproj.Template.Project.PropertyGroupEnd); } }