void WriteOpenProjects(BinaryWriter Writer, VCProjectFileFormat Format) { if (Format >= VCProjectFileFormat.VisualStudio2017) { Writer.Write(4 + (4 + 4 + 1) + 2 + OpenProjects.Sum(x => GetStringSize(x.Item1) + 2 + x.Item2.Sum(y => GetStringSize(y)))); Writer.Write(15); Writer.Write(65536); Writer.Write((byte)0); } else { Writer.Write(4 + (4 + 2 + 1) + 2 + OpenProjects.Sum(x => GetStringSize(x.Item1) + 2 + x.Item2.Sum(y => GetStringSize(y)))); Writer.Write(11); Writer.Write((short)1); Writer.Write((byte)0); } Writer.Write((short)OpenProjects.Count); foreach (Tuple <string, string[]> OpenProject in OpenProjects) { WriteString(Writer, OpenProject.Item1); Writer.Write((short)OpenProject.Item2.Length); foreach (string OpenFolder in OpenProject.Item2) { WriteString(Writer, OpenFolder); } } }
/// <summary> /// Selects which platforms and build configurations we want in the project file /// </summary> /// <param name="IncludeAllPlatforms">True if we should include ALL platforms that are supported on this machine. Otherwise, only desktop platforms will be included.</param> /// <param name="SupportedPlatformNames">Output string for supported platforms, returned as comma-separated values.</param> protected override void SetupSupportedPlatformsAndConfigurations(bool IncludeAllPlatforms, out string SupportedPlatformNames) { // Call parent implementation to figure out the actual platforms base.SetupSupportedPlatformsAndConfigurations(IncludeAllPlatforms, out SupportedPlatformNames); // Certain platforms override the project file format because their debugger add-ins may not yet support the latest // version of Visual Studio. This is their chance to override that. foreach (var SupportedPlatform in SupportedPlatforms) { var BuildPlatform = UEBuildPlatform.GetBuildPlatform(SupportedPlatform, true); if (BuildPlatform != null) { // Don't worry about platforms that we're missing SDKs for if (BuildPlatform.HasRequiredSDKsInstalled() == SDKStatus.Valid) { // Make sure Visual Studio 2013 project files will work... if (ProjectFileFormat == VCProjectFileFormat.VisualStudio2013) { // ...but only if the user didn't override this via the command-line. if (!UnrealBuildTool.CommandLineContains("-2013")) { // Visual Studio 2013 is not supported by Xbox One debugger add-in yet if (SupportedPlatform == UnrealTargetPlatform.XboxOne) { Log.TraceInformation("Forcing Visual Studio 2012 projects for Xbox One compatibility (use '-2013' to override.)"); ProjectFileFormat = VCProjectFileFormat.VisualStudio2012; } } } } } } }
/// <summary> /// Configures project generator based on command-line options /// </summary> /// <param name="Arguments">Arguments passed into the program</param> /// <param name="IncludeAllPlatforms">True if all platforms should be included</param> protected override void ConfigureProjectFileGeneration(String[] Arguments, ref bool IncludeAllPlatforms) { // Call parent implementation first base.ConfigureProjectFileGeneration(Arguments, ref IncludeAllPlatforms); // Default the project file format to whatever UBT is using { switch (WindowsPlatform.Compiler) { case WindowsCompiler.VisualStudio2012: ProjectFileFormat = VCProjectFileFormat.VisualStudio2012; break; case WindowsCompiler.VisualStudio2013: ProjectFileFormat = VCProjectFileFormat.VisualStudio2013; break; } } foreach (var CurArgument in Arguments) { switch (CurArgument.ToUpperInvariant()) { case "-2012": ProjectFileFormat = VCProjectFileFormat.VisualStudio2012; break; case "-2013": ProjectFileFormat = VCProjectFileFormat.VisualStudio2013; break; } } }
public void Write(Stream OutputStream, VCProjectFileFormat Format) { BinaryWriter Writer = new BinaryWriter(OutputStream, Encoding.Unicode); WriteOpenProjects(Writer, Format); WriteSelectedProjects(Writer); WriteEpilogue(Writer); }
public void Read(Stream InputStream, VCProjectFileFormat Format) { BinaryReader Reader = new BinaryReader(InputStream, Encoding.Unicode); ReadOpenProjects(Reader, Format); ReadSelectedProjects(Reader); ReadEpilogue(Reader); }
/// <summary> /// Gets the default compiler which should be used, if it's not set explicitly by the target, command line, or config file. /// </summary> /// <returns>The default compiler version</returns> internal static WindowsCompiler GetDefaultCompiler() { // If there's no specific compiler set, try to pick the matching compiler for the selected IDE object ProjectFormatObject; if (XmlConfig.TryGetValue(typeof(VCProjectFileGenerator), "Version", out ProjectFormatObject)) { VCProjectFileFormat ProjectFormat = (VCProjectFileFormat)ProjectFormatObject; if (ProjectFormat == VCProjectFileFormat.VisualStudio2017) { return(WindowsCompiler.VisualStudio2017); } else if (ProjectFormat == VCProjectFileFormat.VisualStudio2015) { return(WindowsCompiler.VisualStudio2015); } else if (ProjectFormat == VCProjectFileFormat.VisualStudio2013) { return(WindowsCompiler.VisualStudio2013); } } // Second, default based on what's installed, test for 2015 first DirectoryReference VCInstallDir; if (TryGetVCInstallDir(WindowsCompiler.VisualStudio2015, out VCInstallDir)) { return(WindowsCompiler.VisualStudio2015); } if (TryGetVCInstallDir(WindowsCompiler.VisualStudio2013, out VCInstallDir)) { return(WindowsCompiler.VisualStudio2013); } if (TryGetVCInstallDir(WindowsCompiler.VisualStudio2017, out VCInstallDir)) { return(WindowsCompiler.VisualStudio2017); } // If we do have a Visual Studio installation, but we're missing just the C++ parts, warn about that. DirectoryReference VSInstallDir; if (TryGetVSInstallDir(WindowsCompiler.VisualStudio2015, out VSInstallDir)) { Log.TraceWarning("Visual Studio 2015 is installed, but is missing the C++ toolchain. Please verify that \"Common Tools for Visual C++ 2015\" are selected from the Visual Studio 2015 installation options."); } else if (TryGetVSInstallDir(WindowsCompiler.VisualStudio2017, out VSInstallDir)) { Log.TraceWarning("Visual Studio 2017 is installed, but is missing the C++ toolchain. Please verify that \"Common Tools for Visual C++ 2015\" are selected from the Visual Studio 2015 installation options."); } else { Log.TraceWarning("No Visual C++ installation was found. Please download and install Visual Studio 2015 with C++ components."); } // Finally, default to VS2015 anyway return(WindowsCompiler.VisualStudio2015); }
private bool IsVSLuminSupportInstalled(VCProjectFileFormat ProjectFileFormat) { if (!VSSupportChecked) { // TODO: add a registry check or file exists check to confirm if MLExtension is installed on the given ProjectFileFormat. VSDebuggingEnabled = (ProjectFileFormat == VCProjectFileFormat.VisualStudio2015 || ProjectFileFormat == VCProjectFileFormat.VisualStudio2017); VSSupportChecked = true; } return(VSDebuggingEnabled); }
/// Just set up the defaults, later this will be overridden by command line or other options static VCProjectFileGenerator() { switch (WindowsPlatform.Compiler) { case WindowsCompiler.VisualStudio2012: ProjectFileFormat = VCProjectFileFormat.VisualStudio2012; break; case WindowsCompiler.VisualStudio2013: ProjectFileFormat = VCProjectFileFormat.VisualStudio2013; break; case WindowsCompiler.VisualStudio2015: ProjectFileFormat = VCProjectFileFormat.VisualStudio2015; break; } }
/// for instance: <PlatformToolset>v110</PlatformToolset> static public string GetProjectFilePlatformToolsetVersionString(VCProjectFileFormat ProjectFileFormat) { switch (ProjectFileFormat) { case VCProjectFileFormat.VisualStudio2012: return("v110"); case VCProjectFileFormat.VisualStudio2013: return("v120"); case VCProjectFileFormat.VisualStudio2015: return("v140"); case VCProjectFileFormat.VisualStudio2017: return("v141"); } return(string.Empty); }
/// "4.0", "12.0", or "14.0", etc... static public string GetProjectFileToolVersionString(VCProjectFileFormat ProjectFileFormat) { switch (ProjectFileFormat) { case VCProjectFileFormat.VisualStudio2012: return("4.0"); case VCProjectFileFormat.VisualStudio2013: return("12.0"); case VCProjectFileFormat.VisualStudio2015: return("14.0"); case VCProjectFileFormat.VisualStudio2017: return("15.0"); } return(string.Empty); }
/// <summary> /// Default constructor /// </summary> /// <param name="InOnlyGameProject">The single project to generate project files for, or null</param> /// <param name="InProjectFileFormat">Override the project file format to use</param> /// <param name="InOverrideCompiler">Override the compiler version to use</param> public VCProjectFileGenerator(FileReference InOnlyGameProject, VCProjectFileFormat InProjectFileFormat, WindowsCompiler InOverrideCompiler) : base(InOnlyGameProject) { XmlConfig.ApplyTo(this); if (InProjectFileFormat != VCProjectFileFormat.Default) { ProjectFileFormat = InProjectFileFormat; } if (InOverrideCompiler == WindowsCompiler.VisualStudio2015) { BuildToolOverride = "-2015"; } else if (InOverrideCompiler == WindowsCompiler.VisualStudio2017) { BuildToolOverride = "-2017"; } }
void ReadOpenProjects(BinaryReader Reader, VCProjectFileFormat Format) { long OpenFoldersEnd = Reader.BaseStream.Position + Reader.ReadInt32(); if (Format >= VCProjectFileFormat.VisualStudio2017) { int Header1 = Reader.ReadInt32(); int Header2 = Reader.ReadInt32(); int Header3 = Reader.ReadByte(); if (Header1 != 15) { throw new BuildException("Unexpected data in open projects section"); } } else { int Header1 = Reader.ReadInt32(); int Header2 = Reader.ReadInt32(); int Header3 = Reader.ReadByte(); if (Header1 != 11 || Header2 != 1 || Header3 != 0) { throw new BuildException("Unexpected data in open projects section"); } } int NumProjects = Reader.ReadInt16(); for (int ProjectIdx = 0; ProjectIdx < NumProjects; ProjectIdx++) { string ProjectName = ReadString(Reader); string[] Folders = new string[Reader.ReadInt16()]; for (int FolderIdx = 0; FolderIdx < Folders.Length; FolderIdx++) { Folders[FolderIdx] = ReadString(Reader); } OpenProjects.Add(new Tuple <string, string[]>(ProjectName, Folders)); } Debug.Assert(Reader.BaseStream.Position == OpenFoldersEnd); }
/// <summary> /// Default constructor /// </summary> /// <param name="InOnlyGameProject">The single project to generate project files for, or null</param> /// <param name="InProjectFileFormat">Override the project file format to use</param> /// <param name="InArguments">Additional command line arguments</param> public VCProjectFileGenerator(FileReference InOnlyGameProject, VCProjectFileFormat InProjectFileFormat, CommandLineArguments InArguments) : base(InOnlyGameProject) { XmlConfig.ApplyTo(this); if (InProjectFileFormat != VCProjectFileFormat.Default) { ProjectFileFormat = InProjectFileFormat; } if (InArguments.HasOption("-2015")) { BuildToolOverride = "-2015"; } else if (InArguments.HasOption("-2017")) { BuildToolOverride = "-2017"; } else if (InArguments.HasOption("-2019")) { BuildToolOverride = "-2019"; } }
/// <summary> /// Whether this build platform has native support for VisualStudio /// </summary> /// <param name="InPlatform"> The UnrealTargetPlatform being built</param> /// <param name="InConfiguration"> The UnrealTargetConfiguration being built</param> /// <param name="ProjectFileFormat"></param> /// <returns>bool true if native VisualStudio support (or custom VSI) is available</returns> public override bool HasVisualStudioSupport(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, VCProjectFileFormat ProjectFileFormat) { // Debugging, etc. are dependent on the TADP being installed return(IsNsightInstalled(ProjectFileFormat) || IsVSAndroidSupportInstalled()); }
/// <summary> /// Return any custom property group lines /// </summary> /// <param name="InPlatform"> The UnrealTargetPlatform being built</param> /// <param name="ProjectFileFormat"></param> /// <returns>string The custom property import lines for the project file; Empty string if it doesn't require one</returns> public override string GetAdditionalVisualStudioPropertyGroups(UnrealTargetPlatform InPlatform, VCProjectFileFormat ProjectFileFormat) { if (IsVSAndroidSupportInstalled() || !IsNsightInstalled(ProjectFileFormat)) { return(base.GetAdditionalVisualStudioPropertyGroups(InPlatform, ProjectFileFormat)); } return(" <PropertyGroup Label=\"NsightTegraProject\">"+ ProjectFileGenerator.NewLine + " <NsightTegraProjectRevisionNumber>"+ NsightVersionCode.ToString() + "</NsightTegraProjectRevisionNumber>" + ProjectFileGenerator.NewLine + " </PropertyGroup>"+ ProjectFileGenerator.NewLine); }
/// <summary> /// Return any custom paths for VisualStudio this platform requires /// This include ReferencePath, LibraryPath, LibraryWPath, IncludePath and ExecutablePath. /// </summary> /// <param name="InPlatform">The UnrealTargetPlatform being built</param> /// <param name="InConfiguration">The configuration being built</param> /// <param name="TargetType">The type of target (game or program)</param> /// <param name="TargetRulesPath">Path to the target.cs file</param> /// <param name="ProjectFilePath">Path to the project file</param> /// <param name="NMakeOutputPath"></param> /// <param name="InProjectFileFormat">Format for the generated project files</param> /// <param name="ProjectFileBuilder">The project file content</param> /// <returns>The custom path lines for the project file; Empty string if it doesn't require one</returns> public override void GetVisualStudioPathsEntries(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, TargetType TargetType, FileReference TargetRulesPath, FileReference ProjectFilePath, FileReference NMakeOutputPath, VCProjectFileFormat InProjectFileFormat, StringBuilder ProjectFileBuilder) { base.GetVisualStudioPathsEntries(InPlatform, InConfiguration, TargetType, TargetRulesPath, ProjectFilePath, NMakeOutputPath, InProjectFileFormat, ProjectFileBuilder); if (IsVSLuminSupportInstalled(InProjectFileFormat) && TargetType == TargetType.Game && InPlatform == UnrealTargetPlatform.Lumin) { string MLSDK = Utils.CleanDirectorySeparators(Environment.GetEnvironmentVariable("MLSDK"), '\\'); // TODO: Check if MPK name can be other than the project name. string GameName = TargetRulesPath.GetFileNameWithoutExtension(); GameName = Path.GetFileNameWithoutExtension(GameName); string PackageFile = Utils.MakePathRelativeTo(NMakeOutputPath.Directory.FullName, ProjectFilePath.Directory.FullName); string PackageName = GameName; if (InConfiguration != UnrealTargetConfiguration.Development) { PackageName = GameName + "-" + InPlatform.ToString() + "-" + InConfiguration.ToString(); } PackageFile = Path.Combine(PackageFile, PackageName + ".mpk"); // Can't use $(NMakeOutput) directly since that is defined after <ELFFile> tag and thus ends up being translated as an empty string. string ELFFile = Utils.MakePathRelativeTo(NMakeOutputPath.Directory.FullName, ProjectFilePath.Directory.FullName); // Provide path to stripped executable so all symbols are resolved from the external sym file instead. ELFFile = Path.Combine(ELFFile, "..\\..\\Intermediate\\Lumin\\Mabu\\Binaries", GetElfName(NMakeOutputPath)); string DebuggerFlavor = "MLDebugger"; string SymFile = Utils.MakePathRelativeTo(NMakeOutputPath.Directory.FullName, ProjectFilePath.Directory.FullName); SymFile = Path.Combine(SymFile, "..\\..\\Intermediate\\Lumin\\Mabu\\Binaries", Path.ChangeExtension(NMakeOutputPath.GetFileName(), ".sym")); // following are defaults for debugger options string Attach = "false"; string EnableAutoStop = "true"; string AutoStopAtFunction = "main"; string EnablePrettyPrinting = "true"; string MLDownloadOnStart = "true"; string CustomPathEntriesTemplate = "<MLSDK>{0}</MLSDK>" + ProjectFileGenerator.NewLine + "<PackageFile>{1}</PackageFile>" + ProjectFileGenerator.NewLine + "<ELFFile>{2}</ELFFile>" + ProjectFileGenerator.NewLine + "<DebuggerFlavor>{3}</DebuggerFlavor>" + ProjectFileGenerator.NewLine + "<Attach>{4}</Attach>" + ProjectFileGenerator.NewLine + "<EnableAutoStop>{5}</EnableAutoStop>" + ProjectFileGenerator.NewLine + "<AutoStopAtFunction>{6}</AutoStopAtFunction>" + ProjectFileGenerator.NewLine + "<EnablePrettyPrinting>{7}</EnablePrettyPrinting>" + ProjectFileGenerator.NewLine + "<MLDownloadOnStart>{8}</MLDownloadOnStart>" + ProjectFileGenerator.NewLine; // No need to provide SymFile path. The file is automatically picked up when it resides in the same folder and has the same name as the ElfFile // "<SymFile>{9}</SymFile>" + ProjectFileGenerator.NewLine; ProjectFileBuilder.Append(ProjectFileGenerator.NewLine + string.Format(CustomPathEntriesTemplate, MLSDK, PackageFile, ELFFile, DebuggerFlavor, Attach, EnableAutoStop, AutoStopAtFunction, EnablePrettyPrinting, MLDownloadOnStart)); } }
/// <summary> /// Return any custom property group lines /// </summary> /// <param name="InPlatform"> The UnrealTargetPlatform being built</param> /// <returns>string The custom property import lines for the project file; Empty string if it doesn't require one</returns> public override string GetVisualStudioPlatformConfigurationType(UnrealTargetPlatform InPlatform, VCProjectFileFormat ProjectFileFormat) { if (!IsNsightInstalled(ProjectFileFormat)) { return(base.GetVisualStudioPlatformConfigurationType(InPlatform, ProjectFileFormat)); } return("ExternalBuildSystem"); }
/// <summary> /// Selects which platforms and build configurations we want in the project file /// </summary> /// <param name="IncludeAllPlatforms">True if we should include ALL platforms that are supported on this machine. Otherwise, only desktop platforms will be included.</param> /// <param name="SupportedPlatformNames">Output string for supported platforms, returned as comma-separated values.</param> protected override void SetupSupportedPlatformsAndConfigurations( bool IncludeAllPlatforms, out string SupportedPlatformNames ) { // Call parent implementation to figure out the actual platforms base.SetupSupportedPlatformsAndConfigurations( IncludeAllPlatforms, out SupportedPlatformNames ); // Certain platforms override the project file format because their debugger add-ins may not yet support the latest // version of Visual Studio. This is their chance to override that. foreach( var SupportedPlatform in SupportedPlatforms ) { var BuildPlatform = UEBuildPlatform.GetBuildPlatform( SupportedPlatform, true ); if( BuildPlatform != null ) { // Don't worry about platforms that we're missing SDKs for if (BuildPlatform.HasRequiredSDKsInstalled() == SDKStatus.Valid) { // ...but only if the user didn't override this via the command-line. if (!UnrealBuildTool.CommandLineContains("-2015") && !UnrealBuildTool.CommandLineContains("-2013") && !UnrealBuildTool.CommandLineContains("-2012")) { VCProjectFileFormat ProposedFormat = ProjectFileFormat; // Visual Studio 2015 is not supported by PS4 VSI if( SupportedPlatform == UnrealTargetPlatform.PS4 ) { Log.TraceInformation("Forcing Visual Studio max version to 2013 projects for PS4 compatibility (use '-2015' to override.)"); ProposedFormat = VCProjectFileFormat.VisualStudio2013; } // Visual Studio 2015 is not supported by the Android debugger we currently furnish if (SupportedPlatform == UnrealTargetPlatform.Android) { Log.TraceInformation("Android debugging may not be available (requires Visual Studio max version of 2013, use '-2013' to override.)"); // ProposedFormat = VCProjectFileFormat.VisualStudio2013; } // Reduce the Visual Studio version to the max supported by each platform we plan to include. if (ProposedFormat < ProjectFileFormat) { ProjectFileFormat = ProposedFormat; } } } } } }
/// <summary> /// Return any custom layout directory sections /// </summary> /// <param name="InPlatform"> The UnrealTargetPlatform being built</param> /// <param name="TargetType"> The type of target (game or program)</param> /// <param name="InProjectFileFormat">The visual studio project file format being generated</param> /// <returns>string The custom property import lines for the project file; Empty string if it doesn't require one</returns> public virtual string GetVisualStudioLayoutDirSection(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, string InConditionString, TargetRules.TargetType TargetType, FileReference TargetRulesPath, FileReference ProjectFilePath, FileReference NMakeOutputPath, VCProjectFileFormat InProjectFileFormat) { return(""); }
/// <summary> /// Selects which platforms and build configurations we want in the project file /// </summary> /// <param name="IncludeAllPlatforms">True if we should include ALL platforms that are supported on this machine. Otherwise, only desktop platforms will be included.</param> /// <param name="SupportedPlatformNames">Output string for supported platforms, returned as comma-separated values.</param> protected override void SetupSupportedPlatformsAndConfigurations(bool IncludeAllPlatforms, out string SupportedPlatformNames) { // Call parent implementation to figure out the actual platforms base.SetupSupportedPlatformsAndConfigurations(IncludeAllPlatforms, out SupportedPlatformNames); // Certain platforms override the project file format because their debugger add-ins may not yet support the latest // version of Visual Studio. This is their chance to override that. // ...but only if the user didn't override this via the command-line. if (!UnrealBuildTool.CommandLineContains("-2015") && !UnrealBuildTool.CommandLineContains("-2013") && !UnrealBuildTool.CommandLineContains("-2012unsupported")) { foreach (UnrealTargetPlatform SupportedPlatform in SupportedPlatforms) { UEBuildPlatform BuildPlatform = UEBuildPlatform.GetBuildPlatform(SupportedPlatform, true); if (BuildPlatform != null) { // Don't worry about platforms that we're missing SDKs for if (BuildPlatform.HasRequiredSDKsInstalled() == SDKStatus.Valid) { VCProjectFileFormat ProposedFormat = ProjectFileFormat; // Reduce the Visual Studio version to the max supported by each platform we plan to include. if (ProposedFormat < ProjectFileFormat) { ProjectFileFormat = ProposedFormat; } } } } } }
/// <summary> /// Return any custom paths for VisualStudio this platform requires /// This include ReferencePath, LibraryPath, LibraryWPath, IncludePath and ExecutablePath. /// </summary> /// <param name="InPlatform">The UnrealTargetPlatform being built</param> /// <param name="InConfiguration">The configuration being built</param> /// <param name="TargetType">The type of target (game or program)</param> /// <param name="TargetRulesPath">Path to the target.cs file</param> /// <param name="ProjectFilePath">Path to the project file</param> /// <param name="NMakeOutputPath"></param> /// <param name="InProjectFileFormat">Format for the generated project files</param> /// <returns>The custom path lines for the project file; Empty string if it doesn't require one</returns> public override string GetVisualStudioPathsEntries(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, TargetType TargetType, FileReference TargetRulesPath, FileReference ProjectFilePath, FileReference NMakeOutputPath, VCProjectFileFormat InProjectFileFormat) { string PathsLines = ""; if (!IsVSAndroidSupportInstalled() && IsNsightInstalled(InProjectFileFormat)) { // NOTE: We are intentionally overriding defaults for these paths with empty strings. We never want Visual Studio's // defaults for these fields to be propagated, since they are version-sensitive paths that may not reflect // the environment that UBT is building in. We'll set these environment variables ourselves! // NOTE: We don't touch 'ExecutablePath' because that would result in Visual Studio clobbering the system "Path" // environment variable //@todo android: clean up debug path generation string GameName = TargetRulesPath.GetFileNameWithoutExtension(); GameName = Path.GetFileNameWithoutExtension(GameName); // intermediate path for Engine or Game's intermediate string IntermediateDirectoryPath; IntermediateDirectoryPath = Path.GetDirectoryName(NMakeOutputPath.FullName) + "/../../Intermediate/Android/APK"; // string for <OverrideAPKPath> string APKPath = Path.Combine( Path.GetDirectoryName(NMakeOutputPath.FullName), Path.GetFileNameWithoutExtension(NMakeOutputPath.FullName) + "-armv7-es2.apk"); // string for <BuildXmlPath> and <AndroidManifestPath> string BuildXmlPath = IntermediateDirectoryPath; string AndroidManifestPath = Path.Combine(IntermediateDirectoryPath, "AndroidManifest.xml"); // string for <AdditionalLibraryDirectories> string AdditionalLibDirs = ""; AdditionalLibDirs += IntermediateDirectoryPath + @"\obj\local\armeabi-v7a"; AdditionalLibDirs += ";" + IntermediateDirectoryPath + @"\obj\local\x86"; AdditionalLibDirs += @";$(AdditionalLibraryDirectories)"; PathsLines = " <IncludePath />"+ ProjectFileGenerator.NewLine + " <ReferencePath />"+ ProjectFileGenerator.NewLine + " <LibraryPath />"+ ProjectFileGenerator.NewLine + " <LibraryWPath />"+ ProjectFileGenerator.NewLine + " <SourcePath />"+ ProjectFileGenerator.NewLine + " <ExcludePath />"+ ProjectFileGenerator.NewLine + " <AndroidAttach>False</AndroidAttach>"+ ProjectFileGenerator.NewLine + " <DebuggerFlavor>AndroidDebugger</DebuggerFlavor>"+ ProjectFileGenerator.NewLine + " <OverrideAPKPath>"+ APKPath + "</OverrideAPKPath>" + ProjectFileGenerator.NewLine + " <AdditionalLibraryDirectories>"+ AdditionalLibDirs + "</AdditionalLibraryDirectories>" + ProjectFileGenerator.NewLine + " <BuildXmlPath>"+ BuildXmlPath + "</BuildXmlPath>" + ProjectFileGenerator.NewLine + " <AndroidManifestPath>"+ AndroidManifestPath + "</AndroidManifestPath>" + ProjectFileGenerator.NewLine; } else { PathsLines = base.GetVisualStudioPathsEntries(InPlatform, InConfiguration, TargetType, TargetRulesPath, ProjectFilePath, NMakeOutputPath, InProjectFileFormat); } return(PathsLines); }
/// <summary> /// Return the platform toolset string to write into the project configuration /// </summary> /// <param name="InPlatform"> The UnrealTargetPlatform being built</param> /// <param name="InConfiguration"> The UnrealTargetConfiguration being built</param> /// <param name="InProjectFileFormat"> The verison of VS</param> /// <param name="ProjectFileBuilder">String builder for the project file</param> /// <returns>string The custom configuration section for the project file; Empty string if it doesn't require one</returns> public override void GetVisualStudioPlatformToolsetString(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, VCProjectFileFormat InProjectFileFormat, StringBuilder ProjectFileBuilder) { VCProjectFileGenerator.AppendPlatformToolsetProperty(ProjectFileBuilder, InProjectFileFormat); }
/// <summary> /// Configures project generator based on command-line options /// </summary> /// <param name="Arguments">Arguments passed into the program</param> /// <param name="IncludeAllPlatforms">True if all platforms should be included</param> protected override void ConfigureProjectFileGeneration(String[] Arguments, ref bool IncludeAllPlatforms) { // Call parent implementation first base.ConfigureProjectFileGeneration(Arguments, ref IncludeAllPlatforms); // Default the project file format to whatever UBT is using { switch (WindowsPlatform.Compiler) { case WindowsCompiler.VisualStudio2013: ProjectFileFormat = VCProjectFileFormat.VisualStudio2013; break; case WindowsCompiler.VisualStudio2015: ProjectFileFormat = VCProjectFileFormat.VisualStudio2015; break; case WindowsCompiler.VisualStudio2017: ProjectFileFormat = VCProjectFileFormat.VisualStudio2017; break; } } foreach (string CurArgument in Arguments) { switch (CurArgument.ToUpperInvariant()) { // Visual Studio 2012 project generation has been deprecated and is no longer maintained. case "-2012UNSUPPORTED": ProjectFileFormat = VCProjectFileFormat.VisualStudio2012; break; case "-2013": ProjectFileFormat = VCProjectFileFormat.VisualStudio2013; break; case "-2015": ProjectFileFormat = VCProjectFileFormat.VisualStudio2015; break; case "-2017": ProjectFileFormat = VCProjectFileFormat.VisualStudio2017; break; } } }
/// <summary> /// Configures project generator based on command-line options /// </summary> /// <param name="Arguments">Arguments passed into the program</param> /// <param name="IncludeAllPlatforms">True if all platforms should be included</param> protected override void ConfigureProjectFileGeneration( String[] Arguments, ref bool IncludeAllPlatforms ) { // Call parent implementation first base.ConfigureProjectFileGeneration( Arguments, ref IncludeAllPlatforms ); // Default the project file format to whatever UBT is using { switch( WindowsPlatform.Compiler ) { case WindowsCompiler.VisualStudio2012: ProjectFileFormat = VCProjectFileFormat.VisualStudio2012; break; case WindowsCompiler.VisualStudio2013: ProjectFileFormat = VCProjectFileFormat.VisualStudio2013; break; case WindowsCompiler.VisualStudio2015: ProjectFileFormat = VCProjectFileFormat.VisualStudio2015; break; } } foreach( var CurArgument in Arguments ) { switch( CurArgument.ToUpperInvariant() ) { case "-2012": ProjectFileFormat = VCProjectFileFormat.VisualStudio2012; break; case "-2013": ProjectFileFormat = VCProjectFileFormat.VisualStudio2013; break; case "-2015": ProjectFileFormat = VCProjectFileFormat.VisualStudio2015; break; } } // By default VS2015 doesn't install the C++ toolchain. Help developers out with a special message. if (ProjectFileFormat == VCProjectFileFormat.VisualStudio2015) { string CompilerExe = Path.Combine(WindowsPlatform.GetVSComnToolsPath(WindowsCompiler.VisualStudio2015), "../../VC/bin/cl.exe"); if (!File.Exists(CompilerExe)) { Log.TraceInformation("Visual C++ 2015 toolchain does not appear to be correctly installed. Please verify that \"Common Tools for Visual C++ 2015\" was selected when installing Visual Studio 2015."); } } }
public override string GetVisualStudioLayoutDirSection(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, string InConditionString, TargetType TargetType, FileReference TargetRulesPath, FileReference ProjectFilePath, FileReference NMakeOutputPath, VCProjectFileFormat InProjectFileFormat) { string LayoutDirString = ""; if (IsValidHoloLensTarget(InPlatform, TargetType, TargetRulesPath)) { LayoutDirString += " <PropertyGroup "+ InConditionString + ">" + ProjectFileGenerator.NewLine; LayoutDirString += " <RemoveExtraDeployFiles>false</RemoveExtraDeployFiles>"+ ProjectFileGenerator.NewLine; LayoutDirString += " <LayoutDir>"+ DirectoryReference.Combine(NMakeOutputPath.Directory, "AppX").FullName + "</LayoutDir>" + ProjectFileGenerator.NewLine; LayoutDirString += " <AppxPackageRecipe>"+ FileReference.Combine(NMakeOutputPath.Directory, ProjectFilePath.GetFileNameWithoutExtension() + ".build.appxrecipe").FullName + "</AppxPackageRecipe>" + ProjectFileGenerator.NewLine; LayoutDirString += " </PropertyGroup>"+ ProjectFileGenerator.NewLine; // another hijack - this is a convenient point to make sure that HoloLens-appropriate debuggers are available // in the project property pages. LayoutDirString += " <ItemGroup " + InConditionString + ">" + ProjectFileGenerator.NewLine; LayoutDirString += " <PropertyPageSchema Include=\"$(VCTargetsPath)$(LangID)\\AppHostDebugger_Local.xml\" />"+ ProjectFileGenerator.NewLine; LayoutDirString += " <PropertyPageSchema Include=\"$(VCTargetsPath)$(LangID)\\AppHostDebugger_Simulator.xml\" />"+ ProjectFileGenerator.NewLine; LayoutDirString += " <PropertyPageSchema Include=\"$(VCTargetsPath)$(LangID)\\AppHostDebugger_Remote.xml\" />"+ ProjectFileGenerator.NewLine; LayoutDirString += " </ItemGroup>" + ProjectFileGenerator.NewLine; } return(LayoutDirString); }
/// <summary> /// Get the output manifest section, if required /// </summary> /// <param name="InPlatform"> The UnrealTargetPlatform being built</param> /// <param name="InProjectFileFormat">The visual studio project file format being generated</param> /// <returns>string The output manifest section for the project file; Empty string if it doesn't require one</returns> public virtual string GetVisualStudioOutputManifestSection(UnrealTargetPlatform InPlatform, TargetRules.TargetType TargetType, FileReference TargetRulesPath, FileReference ProjectFilePath, VCProjectFileFormat InProjectFileFormat) { return(""); }
/// <summary> /// Return any custom property group lines /// </summary> /// <param name="InPlatform"> The UnrealTargetPlatform being built</param> /// <param name="ProjectFileFormat"></param> /// <returns>string The custom property import lines for the project file; Empty string if it doesn't require one</returns> public override string GetVisualStudioPlatformConfigurationType(UnrealTargetPlatform InPlatform, VCProjectFileFormat ProjectFileFormat) { string ConfigurationType = ""; if (IsVSAndroidSupportInstalled()) { ConfigurationType = "Makefile"; } else if (IsNsightInstalled(ProjectFileFormat)) { ConfigurationType = "ExternalBuildSystem"; } else { ConfigurationType = base.GetVisualStudioPlatformConfigurationType(InPlatform, ProjectFileFormat); } return(ConfigurationType); }
/// <summary> /// Configures project generator based on command-line options /// </summary> /// <param name="Arguments">Arguments passed into the program</param> /// <param name="IncludeAllPlatforms">True if all platforms should be included</param> protected override void ConfigureProjectFileGeneration( String[] Arguments, ref bool IncludeAllPlatforms ) { // Call parent implementation first base.ConfigureProjectFileGeneration( Arguments, ref IncludeAllPlatforms ); // Default the project file format to whatever UBT is using { switch( WindowsPlatform.Compiler ) { case WindowsCompiler.VisualStudio2012: ProjectFileFormat = VCProjectFileFormat.VisualStudio2012; break; case WindowsCompiler.VisualStudio2013: ProjectFileFormat = VCProjectFileFormat.VisualStudio2013; break; case WindowsCompiler.VisualStudio2015: ProjectFileFormat = VCProjectFileFormat.VisualStudio2015; break; } } foreach( var CurArgument in Arguments ) { switch( CurArgument.ToUpperInvariant() ) { case "-2012": ProjectFileFormat = VCProjectFileFormat.VisualStudio2012; break; case "-2013": ProjectFileFormat = VCProjectFileFormat.VisualStudio2013; break; case "-2015": ProjectFileFormat = VCProjectFileFormat.VisualStudio2015; break; } } }
/// <summary> /// Return the platform toolset string to write into the project configuration /// </summary> /// <param name="InPlatform"> The UnrealTargetPlatform being built</param> /// <param name="InConfiguration"> The UnrealTargetConfiguration being built</param> /// <param name="InProjectFileFormat">The version of Visual Studio to target</param> /// <returns>string The custom configuration section for the project file; Empty string if it doesn't require one</returns> public override string GetVisualStudioPlatformToolsetString(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, VCProjectFileFormat InProjectFileFormat) { if (IsVSAndroidSupportInstalled() || !IsNsightInstalled(InProjectFileFormat)) { return("\t\t<PlatformToolset>" + VCProjectFileGenerator.GetProjectFilePlatformToolsetVersionString(InProjectFileFormat) + "</PlatformToolset>" + ProjectFileGenerator.NewLine); } return("\t\t<PlatformToolset>" + VCProjectFileGenerator.GetProjectFilePlatformToolsetVersionString(InProjectFileFormat) + "</PlatformToolset>" + ProjectFileGenerator.NewLine + "\t\t<AndroidNativeAPI>UseTarget</AndroidNativeAPI>" + ProjectFileGenerator.NewLine); }
/// <summary> /// Whether this build platform has native support for VisualStudio /// </summary> /// <param name="InPlatform"> The UnrealTargetPlatform being built</param> /// <param name="InConfiguration"> The UnrealTargetConfiguration being built</param> /// <param name="ProjectFileFormat"> Which version of VS</param> /// <returns>bool true if native VisualStudio support (or custom VSI) is available</returns> public override bool HasVisualStudioSupport(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, VCProjectFileFormat ProjectFileFormat) { // TODO: Returning true from here is resulting in VS erroring out when trying to build a game project for Lumin. return(false); //IsVSLuminSupportInstalled(ProjectFileFormat); }
/// <summary> /// Check to see if a recent enough version of Nsight is installed. /// </summary> bool IsNsightInstalled(VCProjectFileFormat ProjectFileFormat) { // cache the results since this gets called a number of times if (CheckedForNsight) { return(NsightInstalled); } CheckedForNsight = true; // NOTE: there is now a registry key that we can use instead at: // HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\NVIDIA Corporation\Nsight Tegra\Version string ProgramFilesPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86); string PlatformToolsetVersion = VCProjectFileGenerator.GetProjectFilePlatformToolsetVersionString(ProjectFileFormat); if (String.IsNullOrEmpty(PlatformToolsetVersion)) { // future maintainer: add toolset version and verify that the rest of the msbuild path, version, and location in ProgramFiles(x86) is still valid Log.TraceInformation("Android project generation needs to be updated for this version of Visual Studio."); return(false); } // build the path to where the Nsight DLL we'll be checking should sit string NsightDllPath = Path.Combine(ProgramFilesPath, @"MSBuild\Microsoft.Cpp\v4.0", PlatformToolsetVersion, @"Platforms\Tegra-Android\Nvidia.Build.CPPTasks.Tegra-Android.Extensibility.dll"); if (!File.Exists(NsightDllPath)) { return(false); } // grab the version info from the DLL FileVersionInfo NsightVersion = FileVersionInfo.GetVersionInfo(NsightDllPath); if (NsightVersion.ProductMajorPart > 3) { // Mark as Nsight 3.1 (project will be updated) NsightVersionCode = 11; NsightInstalled = true; } else if (NsightVersion.ProductMajorPart == 3) { // Nsight 3.0 supported NsightVersionCode = 9; NsightInstalled = true; if (NsightVersion.ProductMinorPart >= 1) { // Nsight 3.1+ should be valid (will update project if newer) NsightVersionCode = 11; } } else if (NsightVersion.ProductMajorPart == 2) { // Nsight 2.0+ should be valid NsightVersionCode = 6; NsightInstalled = true; } else if ((NsightVersion.ProductMajorPart == 1) && (NsightVersion.ProductMinorPart >= 5)) { // Nsight 1.5+ should be valid NsightVersionCode = 6; NsightInstalled = true; } if (!NsightInstalled) { Log.TraceInformation("\nNsight Tegra {0}.{1} found, but Nsight Tegra 1.5 or higher is required for debugging support.", NsightVersion.ProductMajorPart, NsightVersion.ProductMinorPart); } return(NsightInstalled); }
/// <summary> /// Return the platform toolset string to write into the project configuration /// </summary> /// <param name="InPlatform"> The UnrealTargetPlatform being built</param> /// <param name="InConfiguration"> The UnrealTargetConfiguration being built</param> /// <param name="InProjectFileFormat"> The verison of VS</param> /// <param name="ProjectFileBuilder">String builder for the project file</param> /// <returns>string The custom configuration section for the project file; Empty string if it doesn't require one</returns> public override void GetVisualStudioPlatformToolsetString(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, VCProjectFileFormat InProjectFileFormat, StringBuilder ProjectFileBuilder) { ProjectFileBuilder.AppendLine(" <PlatformToolset>" + VCProjectFileGenerator.GetProjectFilePlatformToolsetVersionString(InProjectFileFormat) + "</PlatformToolset>"); }
/// /// VisualStudio project generation functions /// /// <summary> /// Whether this build platform has native support for VisualStudio /// </summary> /// <param name="InPlatform"> The UnrealTargetPlatform being built</param> /// <param name="InConfiguration"> The UnrealTargetConfiguration being built</param> /// <returns>bool true if native VisualStudio support (or custom VSI) is available</returns> public override bool HasVisualStudioSupport(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, VCProjectFileFormat ProjectFileFormat) { // iOS is not supported in VisualStudio return(false); }
/// <summary> /// Selects which platforms and build configurations we want in the project file /// </summary> /// <param name="IncludeAllPlatforms">True if we should include ALL platforms that are supported on this machine. Otherwise, only desktop platforms will be included.</param> /// <param name="SupportedPlatformNames">Output string for supported platforms, returned as comma-separated values.</param> protected override void SetupSupportedPlatformsAndConfigurations( bool IncludeAllPlatforms, out string SupportedPlatformNames ) { // Call parent implementation to figure out the actual platforms base.SetupSupportedPlatformsAndConfigurations( IncludeAllPlatforms, out SupportedPlatformNames ); // Certain platforms override the project file format because their debugger add-ins may not yet support the latest // version of Visual Studio. This is their chance to override that. foreach( var SupportedPlatform in SupportedPlatforms ) { var BuildPlatform = UEBuildPlatform.GetBuildPlatform( SupportedPlatform, true ); if( BuildPlatform != null ) { // Don't worry about platforms that we're missing SDKs for if (BuildPlatform.HasRequiredSDKsInstalled() == SDKStatus.Valid) { // Make sure Visual Studio 2013 project files will work... if( ProjectFileFormat == VCProjectFileFormat.VisualStudio2013 ) { // ...but only if the user didn't override this via the command-line. if( !UnrealBuildTool.CommandLineContains( "-2013" ) ) { // Visual Studio 2013 is not supported by Xbox One debugger add-in yet if( SupportedPlatform == UnrealTargetPlatform.XboxOne ) { Log.TraceInformation( "Forcing Visual Studio 2012 projects for Xbox One compatibility (use '-2013' to override.)"); ProjectFileFormat = VCProjectFileFormat.VisualStudio2012; } } } } } } }
/// /// VisualStudio project generation functions /// /// <summary> /// Whether this build platform has native support for VisualStudio /// </summary> /// <param name="InPlatform"> The UnrealTargetPlatform being built</param> /// <param name="InConfiguration"> The UnrealTargetConfiguration being built</param> /// <param name="ProjectFileFormat"></param> /// <returns>bool true if native VisualStudio support (or custom VSI) is available</returns> public override bool HasVisualStudioSupport(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, VCProjectFileFormat ProjectFileFormat) { return(true); }
/// <summary> /// Selects which platforms and build configurations we want in the project file /// </summary> /// <param name="IncludeAllPlatforms">True if we should include ALL platforms that are supported on this machine. Otherwise, only desktop platforms will be included.</param> /// <param name="SupportedPlatformNames">Output string for supported platforms, returned as comma-separated values.</param> protected override void SetupSupportedPlatformsAndConfigurations(bool IncludeAllPlatforms, out string SupportedPlatformNames) { // Call parent implementation to figure out the actual platforms base.SetupSupportedPlatformsAndConfigurations(IncludeAllPlatforms, out SupportedPlatformNames); // If we have a non-default setting for visual studio, check the compiler exists. If not, revert to the default. if (ProjectFileFormat == VCProjectFileFormat.VisualStudio2015) { if (!WindowsPlatform.HasCompiler(WindowsCompiler.VisualStudio2015_DEPRECATED)) { Log.TraceWarning("Visual Studio C++ 2015 installation not found - ignoring preferred project file format."); ProjectFileFormat = VCProjectFileFormat.Default; } } else if (ProjectFileFormat == VCProjectFileFormat.VisualStudio2017) { if (!WindowsPlatform.HasCompiler(WindowsCompiler.VisualStudio2017)) { Log.TraceWarning("Visual Studio C++ 2017 installation not found - ignoring preferred project file format."); ProjectFileFormat = VCProjectFileFormat.Default; } } else if (ProjectFileFormat == VCProjectFileFormat.VisualStudio2019) { if (!WindowsPlatform.HasCompiler(WindowsCompiler.VisualStudio2019)) { Log.TraceWarning("Visual Studio C++ 2019 installation not found - ignoring preferred project file format."); ProjectFileFormat = VCProjectFileFormat.Default; } } // Certain platforms override the project file format because their debugger add-ins may not yet support the latest // version of Visual Studio. This is their chance to override that. // ...but only if the user didn't override this via the command-line. if (ProjectFileFormat == VCProjectFileFormat.Default) { // Pick the best platform installed by default if (WindowsPlatform.HasCompiler(WindowsCompiler.VisualStudio2017) && WindowsPlatform.HasIDE(WindowsCompiler.VisualStudio2017)) { ProjectFileFormat = VCProjectFileFormat.VisualStudio2017; } else if (WindowsPlatform.HasCompiler(WindowsCompiler.VisualStudio2015_DEPRECATED) && WindowsPlatform.HasIDE(WindowsCompiler.VisualStudio2015_DEPRECATED)) { ProjectFileFormat = VCProjectFileFormat.VisualStudio2015; } else if (WindowsPlatform.HasCompiler(WindowsCompiler.VisualStudio2019) && WindowsPlatform.HasIDE(WindowsCompiler.VisualStudio2019)) { ProjectFileFormat = VCProjectFileFormat.VisualStudio2019; } // Allow the SDKs to override foreach (UnrealTargetPlatform SupportedPlatform in SupportedPlatforms) { UEBuildPlatform BuildPlatform = UEBuildPlatform.GetBuildPlatform(SupportedPlatform, true); if (BuildPlatform != null) { // Don't worry about platforms that we're missing SDKs for if (BuildPlatform.HasRequiredSDKsInstalled() == SDKStatus.Valid) { VCProjectFileFormat ProposedFormat = BuildPlatform.GetRequiredVisualStudioVersion(); if (ProposedFormat != VCProjectFileFormat.Default) { // Reduce the Visual Studio version to the max supported by each platform we plan to include. if (ProjectFileFormat == VCProjectFileFormat.Default || ProposedFormat < ProjectFileFormat) { ProjectFileFormat = ProposedFormat; } } } } } } }