/// <summary>
        /// Writes the project files to disk
        /// </summary>
        /// <returns>True if successful</returns>
        protected override bool WriteProjectFiles(PlatformProjectGeneratorCollection PlatformProjectGenerators)
        {
            if (!base.WriteProjectFiles(PlatformProjectGenerators))
            {
                return(false);
            }

            // Write AutomationReferences file
            if (AutomationProjectFiles.Any())
            {
                XNamespace NS = XNamespace.Get("http://schemas.microsoft.com/developer/msbuild/2003");

                DirectoryReference AutomationToolDir = DirectoryReference.Combine(UnrealBuildTool.EngineSourceDirectory, "Programs", "AutomationTool");
                new XDocument(
                    new XElement(NS + "Project",
                                 new XAttribute("ToolsVersion", VCProjectFileGenerator.GetProjectFileToolVersionString(ProjectFileFormat)),
                                 new XAttribute("DefaultTargets", "Build"),
                                 new XElement(NS + "ItemGroup",
                                              from AutomationProject in AutomationProjectFiles
                                              select new XElement(NS + "ProjectReference",
                                                                  new XAttribute("Include", AutomationProject.ProjectFilePath.MakeRelativeTo(AutomationToolDir)),
                                                                  new XElement(NS + "Project", (AutomationProject as VCSharpProjectFile).ProjectGUID.ToString("B")),
                                                                  new XElement(NS + "Name", AutomationProject.ProjectFilePath.GetFileNameWithoutExtension()),
                                                                  new XElement(NS + "Private", "false")
                                                                  )
                                              )
                                 )
                    ).Save(FileReference.Combine(AutomationToolDir, "AutomationTool.csproj.References").FullName);
            }

            return(true);
        }
Пример #2
0
        /// <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>
 /// 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>
 /// <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)
 {
     if (IsVSAndroidSupportInstalled() || !IsNsightInstalled(InProjectFileFormat))
     {
         ProjectFileBuilder.AppendLine("    <PlatformToolset>" + VCProjectFileGenerator.GetProjectFilePlatformToolsetVersionString(InProjectFileFormat) + "</PlatformToolset>");
     }
     else
     {
         ProjectFileBuilder.AppendLine("    <PlatformToolset>" + VCProjectFileGenerator.GetProjectFilePlatformToolsetVersionString(InProjectFileFormat) + "</PlatformToolset>");
         ProjectFileBuilder.AppendLine("    <AndroidNativeAPI>UseTarget</AndroidNativeAPI>");
     }
 }
Пример #4
0
        /// <summary>
        /// Writes the project files to disk
        /// </summary>
        /// <returns>True if successful</returns>
        protected override bool WriteProjectFiles(PlatformProjectGeneratorCollection PlatformProjectGenerators)
        {
            // This can be reset by higher level code when it detects that we don't have
            // VS2015 installed (TODO - add custom format for Mac?)
            ProjectFileFormat = VCProjectFileFormat.VisualStudio2015;

            // we can't generate native projects so clear them here, we will just
            // write out OtherProjectFiles and AutomationProjectFiles
            GeneratedProjectFiles.Clear();

            if (!base.WriteProjectFiles(PlatformProjectGenerators))
            {
                return(false);
            }


            // Write AutomationReferences file
            if (AutomationProjectFiles.Any())
            {
                XNamespace NS = XNamespace.Get("http://schemas.microsoft.com/developer/msbuild/2003");

                DirectoryReference AutomationToolDir = DirectoryReference.Combine(UnrealBuildTool.EngineSourceDirectory, "Programs", "AutomationTool");
                new XDocument(
                    new XElement(NS + "Project",
                                 new XAttribute("ToolsVersion", VCProjectFileGenerator.GetProjectFileToolVersionString(ProjectFileFormat)),
                                 new XAttribute("DefaultTargets", "Build"),
                                 new XElement(NS + "ItemGroup",
                                              from AutomationProject in AutomationProjectFiles
                                              select new XElement(NS + "ProjectReference",
                                                                  new XAttribute("Include", AutomationProject.ProjectFilePath.MakeRelativeTo(AutomationToolDir)),
                                                                  new XElement(NS + "Project", (AutomationProject as VCSharpProjectFile).ProjectGUID.ToString("B")),
                                                                  new XElement(NS + "Name", AutomationProject.ProjectFilePath.GetFileNameWithoutExtension()),
                                                                  new XElement(NS + "Private", "false")
                                                                  )
                                              )
                                 )
                    ).Save(FileReference.Combine(AutomationToolDir, "AutomationTool.csproj.References").FullName);
            }

            return(true);
        }
Пример #5
0
        /// <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>
        /// Execute the tool mode
        /// </summary>
        /// <param name="Arguments">Command line arguments</param>
        /// <returns>Exit code</returns>
        public override int Execute(CommandLineArguments Arguments)
        {
            // Apply any command line arguments to this class
            Arguments.ApplyTo(this);

            // Apply the XML config to this class
            XmlConfig.ApplyTo(this);

            // Parse rocket-specific arguments.
            FileReference ProjectFile;

            TryParseProjectFileArgument(Arguments, out ProjectFile);

            // If there aren't any formats set, read the default project file format from the config file
            if (ProjectFileFormats.Count == 0)
            {
                // Read from the XML config
                if (!String.IsNullOrEmpty(ProjectFileGeneratorSettings.Format))
                {
                    ProjectFileFormats.UnionWith(ProjectFileGeneratorSettings.ParseFormatList(ProjectFileGeneratorSettings.Format));
                }

                // Read from the editor config
                ProjectFileFormat PreferredSourceCodeAccessor;
                if (ProjectFileGenerator.GetPreferredSourceCodeAccessor(ProjectFile, out PreferredSourceCodeAccessor))
                {
                    ProjectFileFormats.Add(PreferredSourceCodeAccessor);
                }

                // If there's still nothing set, get the default project file format for this platform
                if (ProjectFileFormats.Count == 0)
                {
                    ProjectFileFormats.UnionWith(BuildHostPlatform.Current.GetDefaultProjectFileFormats());
                }
            }

            // Register all the platform project generators
            PlatformProjectGeneratorCollection PlatformProjectGenerators = new PlatformProjectGeneratorCollection();

            foreach (Type CheckType in Assembly.GetExecutingAssembly().GetTypes())
            {
                if (CheckType.IsClass && !CheckType.IsAbstract && CheckType.IsSubclassOf(typeof(PlatformProjectGenerator)))
                {
                    PlatformProjectGenerator Generator = (PlatformProjectGenerator)Activator.CreateInstance(CheckType, Arguments);
                    foreach (UnrealTargetPlatform Platform in Generator.GetPlatforms())
                    {
                        if (DisablePlatformProjectGenerators == null || !DisablePlatformProjectGenerators.Any(x => x.Equals(Platform.ToString(), StringComparison.OrdinalIgnoreCase)))
                        {
                            Log.TraceVerbose("Registering project generator {0} for {1}", CheckType, Platform);
                            PlatformProjectGenerators.RegisterPlatformProjectGenerator(Platform, Generator);
                        }
                    }
                }
            }

            // Create each project generator and run it
            List <ProjectFileGenerator> Generators = new List <ProjectFileGenerator>();

            foreach (ProjectFileFormat ProjectFileFormat in ProjectFileFormats.Distinct())
            {
                ProjectFileGenerator Generator;
                switch (ProjectFileFormat)
                {
                case ProjectFileFormat.Make:
                    Generator = new MakefileGenerator(ProjectFile);
                    break;

                case ProjectFileFormat.CMake:
                    Generator = new CMakefileGenerator(ProjectFile);
                    break;

                case ProjectFileFormat.QMake:
                    Generator = new QMakefileGenerator(ProjectFile);
                    break;

                case ProjectFileFormat.KDevelop:
                    Generator = new KDevelopGenerator(ProjectFile);
                    break;

                case ProjectFileFormat.CodeLite:
                    Generator = new CodeLiteGenerator(ProjectFile, Arguments);
                    break;

                case ProjectFileFormat.VisualStudio:
                    Generator = new VCProjectFileGenerator(ProjectFile, VCProjectFileFormat.Default, Arguments);
                    break;

                case ProjectFileFormat.VisualStudio2012:
                    Generator = new VCProjectFileGenerator(ProjectFile, VCProjectFileFormat.VisualStudio2012, Arguments);
                    break;

                case ProjectFileFormat.VisualStudio2013:
                    Generator = new VCProjectFileGenerator(ProjectFile, VCProjectFileFormat.VisualStudio2013, Arguments);
                    break;

                case ProjectFileFormat.VisualStudio2015:
                    Generator = new VCProjectFileGenerator(ProjectFile, VCProjectFileFormat.VisualStudio2015, Arguments);
                    break;

                case ProjectFileFormat.VisualStudio2017:
                    Generator = new VCProjectFileGenerator(ProjectFile, VCProjectFileFormat.VisualStudio2017, Arguments);
                    break;

                case ProjectFileFormat.VisualStudio2019:
                    Generator = new VCProjectFileGenerator(ProjectFile, VCProjectFileFormat.VisualStudio2019, Arguments);
                    break;

                case ProjectFileFormat.XCode:
                    Generator = new XcodeProjectFileGenerator(ProjectFile, Arguments);
                    break;

                case ProjectFileFormat.Eddie:
                    Generator = new EddieProjectFileGenerator(ProjectFile);
                    break;

                case ProjectFileFormat.VisualStudioCode:
                    Generator = new VSCodeProjectFileGenerator(ProjectFile);
                    break;

                case ProjectFileFormat.CLion:
                    Generator = new CLionGenerator(ProjectFile);
                    break;

                case ProjectFileFormat.VisualStudioMac:
                    Generator = new VCMacProjectFileGenerator(ProjectFile, Arguments);
                    break;

                default:
                    throw new BuildException("Unhandled project file type '{0}", ProjectFileFormat);
                }
                Generators.Add(Generator);
            }

            // Check there are no superfluous command line arguments
            // TODO (still pass raw arguments below)
            // Arguments.CheckAllArgumentsUsed();

            // Now generate project files
            ProjectFileGenerator.bGenerateProjectFiles = true;
            foreach (ProjectFileGenerator Generator in Generators)
            {
                if (!Generator.GenerateProjectFiles(PlatformProjectGenerators, Arguments.GetRawArray()))
                {
                    return((int)CompilationResult.OtherCompilationError);
                }
            }
            return((int)CompilationResult.Succeeded);
        }
Пример #7
0
 /// <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>");
 }
Пример #8
0
 /// <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>
 /// 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>
 /// <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)
 {
     return("\t\t<PlatformToolset>" + VCProjectFileGenerator.GetProjectFilePlatformToolsetVersionString(InProjectFileFormat) + "</PlatformToolset>" + ProjectFileGenerator.NewLine);
 }