本文整理汇总了C#中UnrealBuildTool.ProjectFile类的典型用法代码示例。如果您正苦于以下问题:C# ProjectFile类的具体用法?C# ProjectFile怎么用?C# ProjectFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProjectFile类属于UnrealBuildTool命名空间,在下文中一共展示了ProjectFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindFolderForProject
/// <summary>
/// Recursively searches for the specified project and returns the folder that it lives in, or null if not found
/// </summary>
/// <param name="Project">The project file to look for</param>
/// <returns>The found folder that the project is in, or null</returns>
public MasterProjectFolder FindFolderForProject( ProjectFile Project )
{
foreach( var CurFolder in SubFolders )
{
MasterProjectFolder FoundFolder = CurFolder.FindFolderForProject( Project );
if( FoundFolder != null )
{
return FoundFolder;
}
}
foreach( var ChildProject in ChildProjects )
{
if( ChildProject == Project )
{
return this;
}
}
return null;
}
示例2: AddProjectsForAllTargets
/// <summary>
/// Creates project entries for all known targets (*.Target.cs files)
/// </summary>
/// <param name="AllGameFolders">All game folders</param>
/// <param name="EngineProject">The engine project we created</param>
/// <param name="GameProjects">Map of game folder name to all of the game projects we created</param>
/// <param name="ProgramProjects">Map of program names to all of the program projects we created</param>
/// <param name="TemplateGameProjects">Set of template game projects we found. These will also be in the GameProjects map</param>
private void AddProjectsForAllTargets( List<UProjectInfo> AllGames, out ProjectFile EngineProject, out Dictionary<DirectoryReference, ProjectFile> GameProjects, out Dictionary<string, ProjectFile> ProgramProjects, out HashSet<ProjectFile> TemplateGameProjects )
{
// As we're creating project files, we'll also keep track of whether we created an "engine" project and return that if we have one
EngineProject = null;
GameProjects = new Dictionary<DirectoryReference,ProjectFile>();
ProgramProjects = new Dictionary<string,ProjectFile>( StringComparer.InvariantCultureIgnoreCase );
TemplateGameProjects = new HashSet<ProjectFile>();
// Get some standard directories
DirectoryReference EngineSourceProgramsDirectory = DirectoryReference.Combine(UnrealBuildTool.EngineSourceDirectory, "Programs");
DirectoryReference TemplatesDirectory = DirectoryReference.Combine(UnrealBuildTool.EngineDirectory, "..", "Templates");
// Find all of the target files. This will filter out any modules or targets that don't
// belong to platforms we're generating project files for.
List<FileReference> AllTargetFiles = DiscoverTargets(AllGames);
foreach( FileReference TargetFilePath in AllTargetFiles )
{
string TargetName = TargetFilePath.GetFileNameWithoutAnyExtensions(); // Remove both ".cs" and ".Target"
// Check to see if this is an Engine target. That is, the target is located under the "Engine" folder
bool IsEngineTarget = false;
bool WantProjectFileForTarget = true;
if(TargetFilePath.IsUnderDirectory(UnrealBuildTool.EngineDirectory))
{
// This is an engine target
IsEngineTarget = true;
if(TargetFilePath.IsUnderDirectory(EngineSourceProgramsDirectory))
{
WantProjectFileForTarget = IncludeEnginePrograms;
}
else if(TargetFilePath.IsUnderDirectory(UnrealBuildTool.EngineSourceDirectory))
{
WantProjectFileForTarget = IncludeEngineSource;
}
}
if (WantProjectFileForTarget)
{
RulesAssembly RulesAssembly;
FileReference CheckProjectFile;
if(!UProjectInfo.TryGetProjectForTarget(TargetName, out CheckProjectFile))
{
RulesAssembly = RulesCompiler.CreateEngineRulesAssembly();
}
else
{
RulesAssembly = RulesCompiler.CreateProjectRulesAssembly(CheckProjectFile);
}
// Create target rules for all of the platforms and configuration combinations that we want to enable support for.
// Just use the current platform as we only need to recover the target type and both should be supported for all targets...
TargetRules TargetRulesObject = RulesAssembly.CreateTargetRules(TargetName, new TargetInfo(BuildHostPlatform.Current.Platform, UnrealTargetConfiguration.Development, ""), false);
bool IsProgramTarget = false;
DirectoryReference GameFolder = null;
string ProjectFileNameBase = null;
if (TargetRulesObject.Type == TargetRules.TargetType.Program)
{
IsProgramTarget = true;
ProjectFileNameBase = TargetName;
}
else if (IsEngineTarget)
{
ProjectFileNameBase = EngineProjectFileNameBase;
}
else
{
// Figure out which game project this target belongs to
UProjectInfo ProjectInfo = FindGameContainingFile(AllGames, TargetFilePath);
if (ProjectInfo == null)
{
throw new BuildException("Found a non-engine target file (" + TargetFilePath + ") that did not exist within any of the known game folders");
}
GameFolder = ProjectInfo.Folder;
ProjectFileNameBase = ProjectInfo.GameName;
}
// @todo projectfiles: We should move all of the Target.cs files out of sub-folders to clean up the project directories a bit (e.g. GameUncooked folder)
FileReference ProjectFilePath = FileReference.Combine(IntermediateProjectFilesPath, ProjectFileNameBase + ProjectFileExtension);
if (TargetRules.IsGameType(TargetRulesObject.Type) &&
(TargetRules.IsEditorType(TargetRulesObject.Type) == false))
{
// Allow platforms to generate stub projects here...
UEPlatformProjectGenerator.GenerateGameProjectStubs(
InGenerator: this,
InTargetName: TargetName,
InTargetFilepath: TargetFilePath.FullName,
//.........这里部分代码省略.........
示例3: AddEngineShaderSource
/// Adds shader source code to the specified project
protected void AddEngineShaderSource( ProjectFile EngineProject )
{
// Setup a project file entry for this module's project. Remember, some projects may host multiple modules!
var ShadersDirectory = Path.Combine( EngineRelativePath, "Shaders" );
var DirectoriesToSearch = new List<string>();
DirectoriesToSearch.Add( ShadersDirectory );
var SubdirectoryNamesToExclude = new List<string>();
{
// Don't include binary shaders in the project file.
SubdirectoryNamesToExclude.Add( "Binaries" );
// We never want shader intermediate files in our project file
SubdirectoryNamesToExclude.Add( "PDBDump" );
SubdirectoryNamesToExclude.Add( "WorkingDirectory" );
}
EngineProject.AddFilesToProject( SourceFileSearch.FindFiles(
DirectoriesToSearch: DirectoriesToSearch,
ExcludeNoRedistFiles: bExcludeNoRedistFiles,
SubdirectoryNamesToExclude: SubdirectoryNamesToExclude ), EngineRelativePath );
}
示例4: AddEngineBuildFiles
/// Adds engine build infrastructure files to the specified project
protected void AddEngineBuildFiles( ProjectFile EngineProject )
{
var BuildDirectory = Path.Combine( EngineRelativePath, "Build" );
var DirectoriesToSearch = new List<string>();
DirectoriesToSearch.Add( BuildDirectory );
var SubdirectoryNamesToExclude = new List<string>();
{
// Nothing to exclude, yet!
// SubdirectoryNamesToExclude.Add( "DirectoryName" );
}
EngineProject.AddFilesToProject( SourceFileSearch.FindFiles(
DirectoriesToSearch: DirectoriesToSearch,
ExcludeNoRedistFiles: bExcludeNoRedistFiles,
SubdirectoryNamesToExclude: SubdirectoryNamesToExclude ), EngineRelativePath );
}
示例5: AddExistingProjectFile
/// <summary>
/// Adds the given project to the OtherProjects list
/// </summary>
/// <param name="InProject">The project to add</param>
/// <returns>True if successful</returns>
public void AddExistingProjectFile(ProjectFile InProject, bool bNeedsAllPlatformAndConfigurations = false, bool bForceDevelopmentConfiguration = false, bool bProjectDeploys = false, List<UnrealTargetPlatform> InSupportedPlatforms = null, List<UnrealTargetConfiguration> InSupportedConfigurations = null)
{
if( InProject.ProjectTargets.Count != 0 )
{
throw new BuildException( "Expecting existing project to not have any ProjectTargets defined yet." );
}
var ProjectTarget = new ProjectTarget();
if( bForceDevelopmentConfiguration )
{
ProjectTarget.ForceDevelopmentConfiguration = true;
}
ProjectTarget.ProjectDeploys = bProjectDeploys;
if (bNeedsAllPlatformAndConfigurations)
{
// Add all platforms
var AllPlatforms = Enum.GetValues(typeof(UnrealTargetPlatform));
foreach (UnrealTargetPlatform CurPlatfrom in AllPlatforms)
{
ProjectTarget.ExtraSupportedPlatforms.Add(CurPlatfrom);
}
// Add all configurations
var AllConfigurations = Enum.GetValues(typeof(UnrealTargetConfiguration));
foreach (UnrealTargetConfiguration CurConfiguration in AllConfigurations)
{
ProjectTarget.ExtraSupportedConfigurations.Add( CurConfiguration );
}
}
else if (InSupportedPlatforms != null || InSupportedConfigurations != null)
{
if (InSupportedPlatforms != null)
{
// Add all explicitly specified platforms
foreach (UnrealTargetPlatform CurPlatfrom in InSupportedPlatforms)
{
ProjectTarget.ExtraSupportedPlatforms.Add(CurPlatfrom);
}
}
else
{
// Otherwise, add all platforms
var AllPlatforms = Enum.GetValues(typeof(UnrealTargetPlatform));
foreach (UnrealTargetPlatform CurPlatfrom in AllPlatforms)
{
ProjectTarget.ExtraSupportedPlatforms.Add(CurPlatfrom);
}
}
if (InSupportedConfigurations != null)
{
// Add all explicitly specified configurations
foreach (UnrealTargetConfiguration CurConfiguration in InSupportedConfigurations)
{
ProjectTarget.ExtraSupportedConfigurations.Add(CurConfiguration);
}
}
else
{
// Otherwise, add all configurations
var AllConfigurations = Enum.GetValues(typeof(UnrealTargetConfiguration));
foreach (UnrealTargetConfiguration CurConfiguration in AllConfigurations)
{
ProjectTarget.ExtraSupportedConfigurations.Add(CurConfiguration);
}
}
}
else
{
// For existing project files, just support the default desktop platforms and configurations
UnrealBuildTool.GetAllDesktopPlatforms(ref ProjectTarget.ExtraSupportedPlatforms, false);
// Debug and Development only
ProjectTarget.ExtraSupportedConfigurations.Add(UnrealTargetConfiguration.Debug);
ProjectTarget.ExtraSupportedConfigurations.Add(UnrealTargetConfiguration.Development);
}
InProject.ProjectTargets.Add( ProjectTarget );
// Existing projects must always have a GUID. This will throw an exception if one isn't found.
InProject.LoadGUIDFromExistingProject();
OtherProjectFiles.Add( InProject );
}
示例6: AddUnrealBuildToolProject
/// <summary>
/// Adds UnrealBuildTool to the master project
/// </summary>
private void AddUnrealBuildToolProject( MasterProjectFolder ProgramsFolder, IEnumerable<ProjectFile> Dependencies )
{
var ProjectFileName = Utils.MakePathRelativeTo( Path.Combine( Path.Combine( EngineRelativePath, "Source" ), "Programs", "UnrealBuildTool", "UnrealBuildTool.csproj" ), MasterProjectRelativePath );
var UnrealBuildToolProject = new VCSharpProjectFile( ProjectFileName );
UnrealBuildToolProject.ShouldBuildForAllSolutionTargets = true;
foreach (var Dependent in Dependencies)
{
UnrealBuildToolProject.AddDependsOnProject( Dependent );
}
// Store it off as we need it when generating target projects.
UBTProject = UnrealBuildToolProject;
// Add the project
AddExistingProjectFile(UnrealBuildToolProject, bNeedsAllPlatformAndConfigurations:true, bForceDevelopmentConfiguration:true);
// Put this in a solution folder
ProgramsFolder.ChildProjects.Add( UnrealBuildToolProject );
}
示例7: AddProjectsForAllTargets
/// <summary>
/// Creates project entries for all known targets (*.Target.cs files)
/// </summary>
/// <param name="AllGameFolders">All game folders</param>
/// <param name="EngineProject">The engine project we created</param>
/// <param name="GameProjects">Map of game folder name to all of the game projects we created</param>
/// <param name="ProgramProjects">Map of program names to all of the program projects we created</param>
/// <param name="TemplateGameProjects">Set of template game projects we found. These will also be in the GameProjects map</param>
private void AddProjectsForAllTargets( List<UProjectInfo> AllGames, out ProjectFile EngineProject, out Dictionary<string, ProjectFile> GameProjects, out Dictionary<string, ProjectFile> ProgramProjects, out HashSet<ProjectFile> TemplateGameProjects )
{
// As we're creating project files, we'll also keep track of whether we created an "engine" project and return that if we have one
EngineProject = null;
GameProjects = new Dictionary<string,ProjectFile>( StringComparer.InvariantCultureIgnoreCase );
ProgramProjects = new Dictionary<string,ProjectFile>( StringComparer.InvariantCultureIgnoreCase );
TemplateGameProjects = new HashSet<ProjectFile>();
// Find all of the target files. This will filter out any modules or targets that don't
// belong to platforms we're generating project files for.
var AllTargetFiles = DiscoverTargets();
foreach( var TargetFilePath in AllTargetFiles )
{
var TargetName = Utils.GetFilenameWithoutAnyExtensions(TargetFilePath); // Remove both ".cs" and ".Target"
// Check to see if this is an Engine target. That is, the target is located under the "Engine" folder
bool IsEngineTarget = false;
string TargetFileRelativeToEngineDirectory = Utils.MakePathRelativeTo(TargetFilePath, Path.Combine(EngineRelativePath), AlwaysTreatSourceAsDirectory: false);
if (!TargetFileRelativeToEngineDirectory.StartsWith( ".." ) && !Path.IsPathRooted( TargetFileRelativeToEngineDirectory ))
{
// This is an engine target
IsEngineTarget = true;
}
if (IsEngineTarget && bGeneratingRocketProjectFiles)
{
// Rocket project file must never include engine targets.
continue;
}
bool WantProjectFileForTarget = true;
if(TargetFileRelativeToEngineDirectory.StartsWith(Path.Combine("Source", "Programs"), StringComparison.InvariantCultureIgnoreCase))
{
WantProjectFileForTarget = IncludeEnginePrograms;
}
else if(TargetFileRelativeToEngineDirectory.StartsWith(Path.Combine("Source"), StringComparison.InvariantCultureIgnoreCase))
{
WantProjectFileForTarget = IncludeEngineSource;
}
if (WantProjectFileForTarget)
{
// Create target rules for all of the platforms and configuration combinations that we want to enable support for.
// Just use the current platform as we only need to recover the target type and both should be supported for all targets...
string UnusedTargetFilePath;
var TargetRulesObject = RulesCompiler.CreateTargetRules(TargetName, new TargetInfo(BuildHostPlatform.Current.Platform, UnrealTargetConfiguration.Development), false, out UnusedTargetFilePath);
// Exclude client and server targets under binary Rocket; it's impossible to build without precompiled engine binaries
if (!UnrealBuildTool.RunningRocket() || (TargetRulesObject.Type != TargetRules.TargetType.Client && TargetRulesObject.Type != TargetRules.TargetType.Server))
{
bool IsProgramTarget = false;
string GameFolder = null;
string ProjectFileNameBase = null;
if (TargetRulesObject.Type == TargetRules.TargetType.Program)
{
IsProgramTarget = true;
ProjectFileNameBase = TargetName;
}
else if (IsEngineTarget)
{
ProjectFileNameBase = EngineProjectFileNameBase;
}
else
{
// Figure out which game project this target belongs to
UProjectInfo ProjectInfo = FindGameContainingFile(AllGames, TargetFilePath);
if (ProjectInfo == null)
{
throw new BuildException("Found a non-engine target file (" + TargetFilePath + ") that did not exist within any of the known game folders");
}
GameFolder = ProjectInfo.Folder;
ProjectFileNameBase = ProjectInfo.GameName;
}
// @todo projectfiles: We should move all of the Target.cs files out of sub-folders to clean up the project directories a bit (e.g. GameUncooked folder)
var ProjectFilePath = Path.Combine(IntermediateProjectFilesPath, ProjectFileNameBase + ProjectFileExtension);
if (TargetRules.IsGameType(TargetRulesObject.Type) &&
(TargetRules.IsEditorType(TargetRulesObject.Type) == false))
{
// Allow platforms to generate stub projects here...
UEPlatformProjectGenerator.GenerateGameProjectStubs(
InGenerator: this,
InTargetName: TargetName,
InTargetFilepath: TargetFilePath,
InTargetRules: TargetRulesObject,
InPlatforms: SupportedPlatforms,
InConfigurations: SupportedConfigurations);
}
//.........这里部分代码省略.........
示例8: WriteMasterProjectFile
/// <summary>
/// Writes the master project file (e.g. Visual Studio Solution file)
/// </summary>
/// <param name="UBTProject">The UnrealBuildTool project</param>
/// <returns>True if successful</returns>
protected abstract bool WriteMasterProjectFile( ProjectFile UBTProject );
示例9: AddEngineExtrasFiles
/// Adds all engine extras files to the specified project
protected virtual void AddEngineExtrasFiles(ProjectFile EngineProject)
{
}
示例10: AddEngineConfigFiles
/// Adds all engine config files to the specified project
private void AddEngineConfigFiles( ProjectFile EngineProject )
{
DirectoryReference EngineConfigDirectory = DirectoryReference.Combine(UnrealBuildTool.EngineDirectory, "Config" );
if( EngineConfigDirectory.Exists( ) )
{
EngineProject.AddFilesToProject( SourceFileSearch.FindFiles( EngineConfigDirectory ), UnrealBuildTool.EngineDirectory );
}
}
示例11: AddEngineTemplateFiles
/// Adds all engine template text files to the specified project
private void AddEngineTemplateFiles( ProjectFile EngineProject )
{
DirectoryReference EngineTemplateDirectory = DirectoryReference.Combine(UnrealBuildTool.EngineDirectory, "Content", "Editor", "Templates");
if (EngineTemplateDirectory.Exists())
{
EngineProject.AddFilesToProject( SourceFileSearch.FindFiles( EngineTemplateDirectory ), UnrealBuildTool.EngineDirectory );
}
}
示例12: AddEngineLocalizationFiles
/// Adds all engine localization text files to the specified project
private void AddEngineLocalizationFiles( ProjectFile EngineProject )
{
DirectoryReference EngineLocalizationDirectory = DirectoryReference.Combine( UnrealBuildTool.EngineDirectory, "Content", "Localization" );
if( EngineLocalizationDirectory.Exists( ) )
{
EngineProject.AddFilesToProject( SourceFileSearch.FindFiles( EngineLocalizationDirectory ), UnrealBuildTool.EngineDirectory );
}
}
示例13: AddEngineBuildFiles
/// Adds engine build infrastructure files to the specified project
protected void AddEngineBuildFiles( ProjectFile EngineProject )
{
DirectoryReference BuildDirectory = DirectoryReference.Combine( UnrealBuildTool.EngineDirectory, "Build" );
List<string> SubdirectoryNamesToExclude = new List<string>();
SubdirectoryNamesToExclude.Add("Receipts");
EngineProject.AddFilesToProject( SourceFileSearch.FindFiles( BuildDirectory, SubdirectoryNamesToExclude ), UnrealBuildTool.EngineDirectory );
}
示例14: AddEngineShaderSource
/// Adds shader source code to the specified project
protected void AddEngineShaderSource( ProjectFile EngineProject )
{
// Setup a project file entry for this module's project. Remember, some projects may host multiple modules!
DirectoryReference ShadersDirectory = DirectoryReference.Combine( UnrealBuildTool.EngineDirectory, "Shaders" );
List<string> SubdirectoryNamesToExclude = new List<string>();
{
// Don't include binary shaders in the project file.
SubdirectoryNamesToExclude.Add( "Binaries" );
// We never want shader intermediate files in our project file
SubdirectoryNamesToExclude.Add( "PDBDump" );
SubdirectoryNamesToExclude.Add( "WorkingDirectory" );
}
EngineProject.AddFilesToProject( SourceFileSearch.FindFiles( ShadersDirectory, SubdirectoryNamesToExclude ), UnrealBuildTool.EngineDirectory );
}
示例15: AddEngineExtrasFiles
/// <summary>
/// Adds Extra files that are specific to Visual Studio projects
/// </summary>
/// <param name="EngineProject">Project to add files to</param>
protected override void AddEngineExtrasFiles(ProjectFile EngineProject)
{
base.AddEngineExtrasFiles(EngineProject);
// Add our UE4.natvis file
var NatvisFilePath = FileReference.Combine(UnrealBuildTool.EngineDirectory, "Extras", "VisualStudioDebugging", "UE4.natvis");
if (NatvisFilePath.Exists())
{
EngineProject.AddFileToProject(NatvisFilePath, UnrealBuildTool.EngineDirectory);
}
}