/// <summary> /// Allow various platform project generators to generate stub projects if required /// </summary> /// <param name="InGenerator"></param> /// <param name="InTargetName"></param> /// <param name="InTargetFilepath"></param> /// <param name="InTargetRules"></param> /// <param name="InPlatforms"></param> /// <param name="InConfigurations"></param> /// <returns></returns> public bool GenerateGameProjectStubs(ProjectFileGenerator InGenerator, string InTargetName, string InTargetFilepath, TargetRules InTargetRules, List <UnrealTargetPlatform> InPlatforms, List <UnrealTargetConfiguration> InConfigurations) { foreach (KeyValuePair <UnrealTargetPlatform, PlatformProjectGenerator> Entry in ProjectGeneratorDictionary) { PlatformProjectGenerator ProjGen = Entry.Value; ProjGen.GenerateGameProjectStub(InGenerator, InTargetName, InTargetFilepath, InTargetRules, InPlatforms, InConfigurations); } return(true); }
public bool PlatformRequiresVSUserFileGeneration(List <UnrealTargetPlatform> InPlatforms, List <UnrealTargetConfiguration> InConfigurations) { bool bRequiresVSUserFileGeneration = false; foreach (KeyValuePair <UnrealTargetPlatform, PlatformProjectGenerator> Entry in ProjectGeneratorDictionary) { if (InPlatforms.Contains(Entry.Key)) { PlatformProjectGenerator ProjGen = Entry.Value; bRequiresVSUserFileGeneration |= ProjGen.RequiresVSUserFileGeneration(); } } return(bRequiresVSUserFileGeneration); }
protected override void WriteDebugSolutionFiles(PlatformProjectGeneratorCollection PlatformProjectGenerators, DirectoryReference IntermediateProjectFilesPath) { //build and collect UnrealVS configuration StringBuilder UnrealVSContent = new StringBuilder(); foreach (UnrealTargetPlatform SupportedPlatform in SupportedPlatforms) { PlatformProjectGenerator ProjGenerator = PlatformProjectGenerators.GetPlatformProjectGenerator(SupportedPlatform, true); if (ProjGenerator != null) { ProjGenerator.GetUnrealVSConfigurationEntries(UnrealVSContent); } } if (UnrealVSContent.Length > 0) { UnrealVSContent.Insert(0, "<UnrealVS>" + ProjectFileGenerator.NewLine); UnrealVSContent.Append("</UnrealVS>" + ProjectFileGenerator.NewLine); string ConfigFilePath = FileReference.Combine(IntermediateProjectFilesPath, "UnrealVS.xml").FullName; bool bSuccess = ProjectFileGenerator.WriteFileIfChanged(ConfigFilePath, UnrealVSContent.ToString()); } }
/// <summary> /// Register the given platforms UEPlatformProjectGenerator instance /// </summary> /// <param name="InPlatform"> The UnrealTargetPlatform to register with</param> /// <param name="InProjectGenerator">The UEPlatformProjectGenerator instance to use for the InPlatform</param> public void RegisterPlatformProjectGenerator(UnrealTargetPlatform InPlatform, PlatformProjectGenerator InProjectGenerator) { // Make sure the build platform is legal UEBuildPlatform BuildPlatform = UEBuildPlatform.GetBuildPlatform(InPlatform, true); if (BuildPlatform != null) { if (ProjectGeneratorDictionary.ContainsKey(InPlatform) == true) { Log.TraceInformation("RegisterPlatformProjectGenerator Warning: Registering project generator {0} for {1} when it is already set to {2}", InProjectGenerator.ToString(), InPlatform.ToString(), ProjectGeneratorDictionary[InPlatform].ToString()); ProjectGeneratorDictionary[InPlatform] = InProjectGenerator; } else { ProjectGeneratorDictionary.Add(InPlatform, InProjectGenerator); } } else { Log.TraceVerbose("Skipping project file generator registration for {0} due to no valid BuildPlatform.", InPlatform.ToString()); } }
/// <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); }