/// <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 ); }
/// <summary> /// Adds all .automation.csproj files to the solution. /// </summary> void AddAutomationModules(MasterProjectFolder ProgramsFolder) { var Folder = ProgramsFolder.AddSubFolder("Automation"); var AllGameFolders = UEBuildTarget.DiscoverAllGameFolders(); var BuildFolders = new List<string>(AllGameFolders.Count); foreach (var GameFolder in AllGameFolders) { var GameBuildFolder = Path.Combine(GameFolder, "Build"); if (Directory.Exists(GameBuildFolder)) { BuildFolders.Add(GameBuildFolder); } } // Find all the automation modules .csproj files to add var ModuleFiles = RulesCompiler.FindAllRulesSourceFiles(RulesCompiler.RulesFileType.AutomationModule, BuildFolders); foreach (var ProjectFile in ModuleFiles) { FileInfo Info = new FileInfo(Path.Combine(ProjectFile)); if (Info.Exists) { var RelativeFileName = Utils.MakePathRelativeTo(ProjectFile, MasterProjectRelativePath); var Project = new VCSharpProjectFile(RelativeFileName); Project.ShouldBuildForAllSolutionTargets = true; AddExistingProjectFile(Project, bForceDevelopmentConfiguration: true); Folder.ChildProjects.Add( Project ); } } }
/// <summary> /// Adds a C# project to the master project /// </summary> /// <param name="ProjectName">Name of project file to add</param> /// <returns>ProjectFile if the operation was successful, otherwise null.</returns> private VCSharpProjectFile AddSimpleCSharpProject(string ProjectName, bool bShouldBuildForAllSolutionTargets = false, bool bForceDevelopmentConfiguration = false, bool bShouldBuildByDefaultForSolutionTargets = true) { VCSharpProjectFile Project = null; var ProjectFileName = Path.Combine( EngineRelativePath, "Source", "Programs", ProjectName, Path.GetFileName( ProjectName ) + ".csproj" ); FileInfo Info = new FileInfo( ProjectFileName ); if( Info.Exists ) { var FileNameRelativeToMasterProject = Utils.MakePathRelativeTo( ProjectFileName, MasterProjectRelativePath ); Project = new VCSharpProjectFile(FileNameRelativeToMasterProject); Project.ShouldBuildForAllSolutionTargets = bShouldBuildForAllSolutionTargets; Project.ShouldBuildByDefaultForSolutionTargets = bShouldBuildByDefaultForSolutionTargets; AddExistingProjectFile(Project, bForceDevelopmentConfiguration: bForceDevelopmentConfiguration); } else { throw new BuildException( ProjectFileName + " doesn't exist!" ); } return Project; }
/// <summary> /// Adds UnrealBuildTool to the master project /// </summary> private void AddUnrealBuildToolProject( MasterProjectFolder ProgramsFolder ) { var ProjectFileName = Utils.MakePathRelativeTo( Path.Combine( Path.Combine( EngineRelativePath, "Source" ), "Programs", "UnrealBuildTool", "UnrealBuildTool.csproj" ), MasterProjectRelativePath ); var UnrealBuildToolProject = new VCSharpProjectFile( ProjectFileName ); // 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 ); }
public override void CompileCSharpProject(CSharpEnvironment CompileEnvironment, string ProjectFileName, string DestinationFile) { // Initialize environment variables required for spawned tools. var EnvVars = VCEnvironment.SetEnvironment(CompileEnvironment.EnvironmentTargetPlatform); var BuildProjectAction = new Action(ActionType.BuildProject); // Specify the source file (prerequisite) for the action var ProjectFileItem = FileItem.GetExistingItemByPath(ProjectFileName); if (ProjectFileItem == null) { throw new BuildException("Expected C# project file {0} to exist.", ProjectFileName); } // Add the project and the files contained to the prerequisites. BuildProjectAction.PrerequisiteItems.Add(ProjectFileItem); var ProjectFile = new VCSharpProjectFile( Utils.MakePathRelativeTo( ProjectFileName, ProjectFileGenerator.MasterProjectRelativePath ) ); var ProjectPreReqs = ProjectFile.GetCSharpDependencies(); var ProjectFolder = Path.GetDirectoryName(ProjectFileName); foreach( string ProjectPreReqRelativePath in ProjectPreReqs ) { string ProjectPreReqAbsolutePath = Path.Combine( ProjectFolder, ProjectPreReqRelativePath ); var ProjectPreReqFileItem = FileItem.GetExistingItemByPath(ProjectPreReqAbsolutePath); if( ProjectPreReqFileItem == null ) { throw new BuildException("Expected C# dependency {0} to exist.", ProjectPreReqAbsolutePath); } BuildProjectAction.PrerequisiteItems.Add(ProjectPreReqFileItem); } // We might be able to distribute this safely, but it doesn't take any time. BuildProjectAction.bCanExecuteRemotely = false; // Setup execution via MSBuild. BuildProjectAction.WorkingDirectory = Path.GetFullPath("."); BuildProjectAction.StatusDescription = Path.GetFileName(ProjectFileName); BuildProjectAction.CommandPath = EnvVars.MSBuildPath; if (CompileEnvironment.TargetConfiguration == CSharpTargetConfiguration.Debug) { BuildProjectAction.CommandArguments = " /target:rebuild /property:Configuration=Debug"; } else { BuildProjectAction.CommandArguments = " /target:rebuild /property:Configuration=Development"; } // Be less verbose BuildProjectAction.CommandArguments += " /nologo /verbosity:minimal"; // Add project BuildProjectAction.CommandArguments += String.Format(" \"{0}\"", ProjectFileItem.AbsolutePath); // Specify the output files. string PDBFilePath = Path.Combine( Path.GetDirectoryName(DestinationFile), Path.GetFileNameWithoutExtension(DestinationFile) + ".pdb" ); FileItem PDBFile = FileItem.GetItemByPath( PDBFilePath ); BuildProjectAction.ProducedItems.Add( FileItem.GetItemByPath(DestinationFile) ); BuildProjectAction.ProducedItems.Add( PDBFile ); }
/// <summary> /// Adds a C# project to the master project /// </summary> /// <param name="ProjectName">Name of project file to add</param> /// <returns>ProjectFile if the operation was successful, otherwise null.</returns> private ProjectFile AddSimpleCSharpProject(string ProjectName) { ProjectFile Project = null; var ProjectFileName = Path.Combine( EngineRelativePath, "Source", "Programs", ProjectName, Path.GetFileName( ProjectName ) + ".csproj" ); FileInfo Info = new FileInfo( ProjectFileName ); if( Info.Exists ) { var FileNameRelativeToMasterProject = Utils.MakePathRelativeTo( ProjectFileName, MasterProjectRelativePath ); Project = new VCSharpProjectFile(FileNameRelativeToMasterProject); AddExistingProjectFile(Project); } else { throw new BuildException( ProjectFileName + " doesn't exist!" ); } return Project; }
/// <summary> /// Finds all csproj within Engine/Source/Programs, and add them if their UE4CSharp.prog file exists. /// </summary> void DiscoverCSharpProgramProjects(MasterProjectFolder ProgramsFolder) { List<FileReference> FoundProjects = new List<FileReference>(); DirectoryReference EngineProgramsSource = DirectoryReference.Combine(UnrealBuildTool.EngineDirectory, "Source", "Programs"); DiscoverCSharpProgramProjectsRecursively(EngineProgramsSource, FoundProjects); foreach (FileReference FoundProject in FoundProjects) { VCSharpProjectFile Project = new VCSharpProjectFile(FoundProject); Project.ShouldBuildForAllSolutionTargets = false; Project.ShouldBuildByDefaultForSolutionTargets = true; AddExistingProjectFile(Project, bForceDevelopmentConfiguration: false); ProgramsFolder.ChildProjects.Add(Project); } }
/// <summary> /// Adds all .automation.csproj files to the solution. /// </summary> void AddAutomationModules(MasterProjectFolder ProgramsFolder) { MasterProjectFolder Folder = ProgramsFolder.AddSubFolder("Automation"); List<DirectoryReference> AllGameFolders = UEBuildTarget.DiscoverAllGameFolders(); List<DirectoryReference> BuildFolders = new List<DirectoryReference>(AllGameFolders.Count); foreach (DirectoryReference GameFolder in AllGameFolders) { DirectoryReference GameBuildFolder = DirectoryReference.Combine(GameFolder, "Build"); if (GameBuildFolder.Exists()) { BuildFolders.Add(GameBuildFolder); } } // Find all the automation modules .csproj files to add List<FileReference> ModuleFiles = RulesCompiler.FindAllRulesSourceFiles(RulesCompiler.RulesFileType.AutomationModule, null, ForeignPlugins:null, AdditionalSearchPaths: BuildFolders ); foreach (FileReference ProjectFile in ModuleFiles) { if (ProjectFile.Exists()) { VCSharpProjectFile Project = new VCSharpProjectFile(ProjectFile); Project.ShouldBuildForAllSolutionTargets = true; AddExistingProjectFile(Project, bForceDevelopmentConfiguration: true); AutomationProjectFiles.Add( Project ); Folder.ChildProjects.Add( Project ); } } }
/// <summary> /// Adds a C# project to the master project /// </summary> /// <param name="ProjectName">Name of project file to add</param> /// <returns>ProjectFile if the operation was successful, otherwise null.</returns> private VCSharpProjectFile AddSimpleCSharpProject(string ProjectName, bool bShouldBuildForAllSolutionTargets = false, bool bForceDevelopmentConfiguration = false, bool bShouldBuildByDefaultForSolutionTargets = true) { VCSharpProjectFile Project = null; FileReference ProjectFileName = FileReference.Combine( UnrealBuildTool.EngineSourceDirectory, "Programs", ProjectName, Path.GetFileName( ProjectName ) + ".csproj" ); FileInfo Info = new FileInfo( ProjectFileName.FullName ); if( Info.Exists ) { Project = new VCSharpProjectFile(ProjectFileName); Project.ShouldBuildForAllSolutionTargets = bShouldBuildForAllSolutionTargets; Project.ShouldBuildByDefaultForSolutionTargets = bShouldBuildByDefaultForSolutionTargets; AddExistingProjectFile(Project, bForceDevelopmentConfiguration: bForceDevelopmentConfiguration); } else { throw new BuildException( ProjectFileName.FullName + " doesn't exist!" ); } return Project; }
/// <summary> /// Adds UnrealBuildTool to the master project /// </summary> private void AddUnrealBuildToolProject( MasterProjectFolder ProgramsFolder, IEnumerable<ProjectFile> Dependencies ) { FileReference ProjectFileName = FileReference.Combine(UnrealBuildTool.EngineSourceDirectory, "Programs", "UnrealBuildTool", "UnrealBuildTool.csproj" ); VCSharpProjectFile UnrealBuildToolProject = new VCSharpProjectFile( ProjectFileName ); UnrealBuildToolProject.ShouldBuildForAllSolutionTargets = true; foreach (ProjectFile 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 ); }