bool IsFileForOtherPlatform(FileReference InputFile)
 {
     foreach (UnrealTargetPlatform Plat in Enum.GetValues(typeof(UnrealTargetPlatform)))
     {
         bool bMatchesIniPlatform    = (InputFile.HasExtension(".ini") && Plat == StageTargetPlatform.IniPlatformType);          // filter ini files for the ini file platform
         bool bMatchesTargetPlatform = (Plat == StageTargetPlatform.PlatformType || Plat == UnrealTargetPlatform.Unknown);       // filter platform files for the target platform
         if (!bMatchesIniPlatform && !bMatchesTargetPlatform)
         {
             FileSystemName PlatformName = new FileSystemName(Plat.ToString());
             if (InputFile.IsUnderDirectory(ProjectRoot))
             {
                 if (InputFile.ContainsName(PlatformName, ProjectRoot))
                 {
                     return(true);
                 }
             }
             else if (InputFile.IsUnderDirectory(LocalRoot))
             {
                 if (InputFile.ContainsName(PlatformName, LocalRoot))
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Exemplo n.º 2
0
    /// <summary>
    /// Gets the default location to stage an input file
    /// </summary>
    /// <param name="InputFile">Location of the file in the file system</param>
    /// <returns>Staged file location</returns>
    public StagedFileReference GetStagedFileLocation(FileReference InputFile)
    {
        StagedFileReference OutputFile;

        if (InputFile.IsUnderDirectory(ProjectRoot))
        {
            OutputFile = StagedFileReference.Combine(RelativeProjectRootForStage, InputFile.MakeRelativeTo(ProjectRoot));
        }
        else if (InputFile.HasExtension(".uplugin"))
        {
            DirectoryReference EnterpriseRoot = DirectoryReference.Combine(EngineRoot, "..", "Enterprise");             // Enterprise plugins aren't under the project additional plugin directories, so they shouldn't be remapped
            if (InputFile.IsUnderDirectory(EngineRoot) || InputFile.IsUnderDirectory(EnterpriseRoot))
            {
                OutputFile = new StagedFileReference(InputFile.MakeRelativeTo(LocalRoot));
            }
            else
            {
                // This is a plugin that lives outside of the Engine/Plugins or Game/Plugins directory so needs to be remapped for staging/packaging
                // We need to remap C:\SomePath\PluginName\PluginName.uplugin to RemappedPlugins\PluginName\PluginName.uplugin
                OutputFile = new StagedFileReference(String.Format("RemappedPlugins/{0}/{1}", InputFile.GetFileNameWithoutExtension(), InputFile.GetFileName()));
            }
        }
        else if (InputFile.IsUnderDirectory(LocalRoot))
        {
            OutputFile = new StagedFileReference(InputFile.MakeRelativeTo(LocalRoot));
        }
        else
        {
            throw new AutomationException("Can't deploy {0} because it doesn't start with {1} or {2}", InputFile, ProjectRoot, LocalRoot);
        }
        return(OutputFile);
    }
Exemplo n.º 3
0
    /// <summary>
    /// Stage a single file to its default location
    /// </summary>
    /// <param name="FileType">The type of file being staged</param>
    /// <param name="InputFile">Path to the file</param>
    public void StageFile(StagedFileType FileType, FileReference InputFile)
    {
        StagedFileReference OutputFile;

        if (InputFile.IsUnderDirectory(ProjectRoot))
        {
            OutputFile = StagedFileReference.Combine(RelativeProjectRootForStage, InputFile.MakeRelativeTo(ProjectRoot));
        }
        else if (InputFile.HasExtension(".uplugin"))
        {
            if (InputFile.IsUnderDirectory(EngineRoot))
            {
                OutputFile = new StagedFileReference(InputFile.MakeRelativeTo(LocalRoot));
            }
            else
            {
                // This is a plugin that lives outside of the Engine/Plugins or Game/Plugins directory so needs to be remapped for staging/packaging
                // We need to remap C:\SomePath\PluginName\PluginName.uplugin to RemappedPlugins\PluginName\PluginName.uplugin
                OutputFile = new StagedFileReference(String.Format("RemappedPlugins/{0}/{1}", InputFile.GetFileNameWithoutExtension(), InputFile.GetFileName()));
            }
        }
        else if (InputFile.IsUnderDirectory(LocalRoot))
        {
            OutputFile = new StagedFileReference(InputFile.MakeRelativeTo(LocalRoot));
        }
        else
        {
            throw new AutomationException("Can't deploy {0} because it doesn't start with {1} or {2}", InputFile, ProjectRoot, LocalRoot);
        }
        StageFile(FileType, InputFile, OutputFile);
    }
Exemplo n.º 4
0
        /// <summary>
        /// Format an include of the given file
        /// </summary>
        /// <param name="FromDirectory">The directory containing the file with the #include directive</param>
        /// <param name="IncludeFile">File to include</param>
        /// <param name="IncludePaths">Directories to base relative include paths from</param>
        /// <param name="SystemIncludePaths">Directories to base system include paths from</param>
        /// <returns>Formatted include path, with surrounding quotes</returns>
        public static bool TryFormatInclude(DirectoryReference FromDirectory, FileReference IncludeFile, IEnumerable <DirectoryReference> IncludePaths, IEnumerable <DirectoryReference> SystemIncludePaths, out string IncludeText)
        {
            // Generated headers are always included without a path
            if (IncludeFile.FullName.Contains(".generated.") || IncludeFile.FullName.EndsWith("Classes.h"))
            {
                IncludeText = String.Format("\"{0}\"", IncludeFile.GetFileName());
                return(true);
            }

            // Try to write an include relative to one of the system include paths
            foreach (DirectoryReference SystemIncludePath in SystemIncludePaths)
            {
                if (IncludeFile.IsUnderDirectory(SystemIncludePath))
                {
                    IncludeText = String.Format("<{0}>", IncludeFile.MakeRelativeTo(SystemIncludePath).Replace('\\', '/'));
                    return(true);
                }
            }

            // Try to write an include relative to one of the standard include paths
            foreach (DirectoryReference IncludePath in IncludePaths)
            {
                if (IncludeFile.IsUnderDirectory(IncludePath))
                {
                    IncludeText = String.Format("\"{0}\"", IncludeFile.MakeRelativeTo(IncludePath).Replace('\\', '/'));
                    return(true);
                }
            }

            // Try to write an include relative to the file
            if (IncludeFile.IsUnderDirectory(FromDirectory))
            {
                IncludeText = String.Format("\"{0}\"", IncludeFile.MakeRelativeTo(FromDirectory).Replace('\\', '/'));
                return(true);
            }

            // HACK: VsPerf.h is in the compiler environment, but the include path is added directly
            if (IncludeFile.FullName.EndsWith("\\PerfSDK\\VSPerf.h", StringComparison.InvariantCultureIgnoreCase))
            {
                IncludeText = "\"VSPerf.h\"";
                return(true);
            }

            // HACK: public Paper2D header in classes folder including private Paper2D header
            if (IncludeFile.FullName.IndexOf("\\Paper2D\\Private\\", StringComparison.InvariantCultureIgnoreCase) != -1)
            {
                IncludeText = "\"" + IncludeFile.GetFileName() + "\"";
                return(true);
            }
            if (IncludeFile.FullName.IndexOf("\\OnlineSubsystemUtils\\Private\\", StringComparison.InvariantCultureIgnoreCase) != -1)
            {
                IncludeText = "\"" + IncludeFile.GetFileName() + "\"";
                return(true);
            }

            // Otherwise we don't know where it came from
            IncludeText = null;
            return(false);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Converts a file into a more readable form for diangostic messages
 /// </summary>
 /// <param name="File">Path to the file</param>
 /// <returns>Readable form of the path</returns>
 static string GetReadablePathForDiagnostics(FileReference File)
 {
     if (File.IsUnderDirectory(CommandUtils.RootDirectory))
     {
         return(File.MakeRelativeTo(CommandUtils.RootDirectory));
     }
     else
     {
         return(File.FullName);
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Checks whether the given assembly is a publically distributed engine assembly.
        /// </summary>
        /// <param name="File">Assembly location</param>
        /// <returns>True if the assembly is distributed publically</returns>
        static bool IsPublicAssembly(FileReference File)
        {
            DirectoryReference EngineDirectory = CommandUtils.EngineDirectory;

            if (File.IsUnderDirectory(EngineDirectory))
            {
                string[] PathFragments = File.MakeRelativeTo(EngineDirectory).Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
                if (PathFragments.All(x => !x.Equals("NotForLicensees", StringComparison.InvariantCultureIgnoreCase) && !x.Equals("NoRedist", StringComparison.InvariantCultureIgnoreCase)))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Find the shortest relative path of the given file from a set of base directories.
        /// </summary>
        /// <param name="File">Full path to a file</param>
        /// <param name="RebaseDirs">Possible base directories</param>
        /// <returns>The shortest relative path, or null if the file is not under any of them</returns>
        public static string FindShortestRelativePath(FileReference File, IEnumerable <DirectoryReference> RebaseDirs)
        {
            string RelativePath = null;

            foreach (DirectoryReference RebaseDir in RebaseDirs)
            {
                if (File.IsUnderDirectory(RebaseDir))
                {
                    string NewRelativePath = File.MakeRelativeTo(RebaseDir);
                    if (RelativePath == null || NewRelativePath.Length < RelativePath.Length)
                    {
                        RelativePath = NewRelativePath;
                    }
                }
            }
            return(RelativePath);
        }
    public UnrealPakViewer(ReadOnlyTargetRules Target) : base(Target)
    {
        PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
        PublicIncludePaths.Add(Path.Combine(EngineDirectory, "Source/Runtime/Launch/Public"));
        PrivateIncludePaths.Add(Path.Combine(EngineDirectory, "Source/Runtime/Launch/Private"));              // For LaunchEngineLoop.cpp include

        PrivateDependencyModuleNames.AddRange(
            new string[]
        {
            "AppFramework",
            "Core",
            "ApplicationCore",
            "Slate",
            "SlateCore",
            "StandaloneRenderer",
            "DesktopPlatform",
            "Projects",
            "EditorStyle",
            "PakAnalyzer",
            "Json",
            "ImageWrapper",
            "Oodle",
        }
            );

        if (Target.Platform == UnrealTargetPlatform.Linux)
        {
            PrivateDependencyModuleNames.AddRange(
                new string[] {
                "UnixCommonStartup"
            }
                );
        }

        DirectoryReference EngineSourceProgramsDirectory = new DirectoryReference(Path.Combine(EngineDirectory, "Source", "Programs"));
        FileReference      CurrentModuleDirectory        = new FileReference(ModuleDirectory);

        if (!CurrentModuleDirectory.IsUnderDirectory(EngineSourceProgramsDirectory))
        {
            string ProjectName = Target.ProjectFile.GetFileNameWithoutExtension();
            Log.TraceInformation("UnrealPakViewer is outside engine source directory, parent project is: {0}", ProjectName);

            PrivateDefinitions.Add(string.Format("ParentProjectName=TEXT(\"{0}\")", ProjectName));
        }
    }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="FileInfo">File to be added</param>
        /// <param name="RootDir">Root directory to store paths relative to</param>
        public TempStorageFile(FileInfo FileInfo, DirectoryReference RootDir)
        {
            // Check the file exists and is in the right location
            FileReference File = new FileReference(FileInfo);

            if (!File.IsUnderDirectory(RootDir))
            {
                throw new AutomationException("Attempt to add file to temp storage manifest that is outside the root directory ({0})", File.FullName);
            }
            if (!FileInfo.Exists)
            {
                throw new AutomationException("Attempt to add file to temp storage manifest that does not exist ({0})", File.FullName);
            }

            RelativePath          = File.MakeRelativeTo(RootDir).Replace(Path.DirectorySeparatorChar, '/');
            LastWriteTimeUtcTicks = FileInfo.LastWriteTimeUtc.Ticks;
            Length = FileInfo.Length;
        }
Exemplo n.º 10
0
    public MyBlankProgram(ReadOnlyTargetRules Target) : base(Target)
    {
        PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
        PublicIncludePaths.Add(Path.Combine(EngineDirectory, "Source/Runtime/Launch/Public"));
        PrivateIncludePaths.Add(Path.Combine(EngineDirectory, "Source/Runtime/Launch/Private"));      // For LaunchEngineLoop.cpp include

        PrivateDependencyModuleNames.Add("Core");
        PrivateDependencyModuleNames.Add("Projects");

        DirectoryReference EngineSourceProgramsDirectory = new DirectoryReference(Path.Combine(EngineDirectory, "Source", "Programs"));
        FileReference      CurrentModuleDirectory        = new FileReference(ModuleDirectory);

        if (!CurrentModuleDirectory.IsUnderDirectory(EngineSourceProgramsDirectory))
        {
            string ProjectName = Target.ProjectFile.GetFileNameWithoutExtension();
            Log.TraceInformation("MyBlankProgram is outside engine source directory, parent project is: {0}", ProjectName);

            PrivateDefinitions.Add(string.Format("ParentProjectName=TEXT(\"{0}\")", ProjectName));
        }
    }
Exemplo n.º 11
0
        public virtual List <FileReference> GetExecutableNames(DeploymentContext SC)
        {
            List <FileReference> ExecutableNames = new List <FileReference>();

            foreach (StageTarget Target in SC.StageTargets)
            {
                foreach (BuildProduct Product in Target.Receipt.BuildProducts)
                {
                    if (Product.Type == BuildProductType.Executable)
                    {
                        FileReference BuildProductFile = Product.Path;
                        if (BuildProductFile.IsUnderDirectory(SC.ProjectRoot))
                        {
                            ExecutableNames.Add(FileReference.Combine(SC.RuntimeProjectRootDir, BuildProductFile.MakeRelativeTo(SC.ProjectRoot)));
                        }
                        else
                        {
                            ExecutableNames.Add(FileReference.Combine(SC.RuntimeRootDir, BuildProductFile.MakeRelativeTo(RootDirectory)));
                        }
                    }
                }
            }
            return(ExecutableNames);
        }
Exemplo n.º 12
0
		/// <summary>
		/// Find the shortest relative path of the given file from a set of base directories.
		/// </summary>
		/// <param name="File">Full path to a file</param>
		/// <param name="RebaseDirs">Possible base directories</param>
		/// <returns>The shortest relative path, or null if the file is not under any of them</returns>
		public static string FindShortestRelativePath(FileReference File, IEnumerable<DirectoryReference> RebaseDirs)
		{
			string RelativePath = null;
			foreach(DirectoryReference RebaseDir in RebaseDirs)
			{
				if(File.IsUnderDirectory(RebaseDir))
				{
					string NewRelativePath = File.MakeRelativeTo(RebaseDir);
					if(RelativePath == null || NewRelativePath.Length < RelativePath.Length)
					{
						RelativePath = NewRelativePath;
					}
				}
			}
			return RelativePath;
		}
Exemplo n.º 13
0
    public override void ExecuteBuild()
    {
        // Get the plugin filename
        string PluginParam = ParseParamValue("Plugin");

        if (PluginParam == null)
        {
            throw new AutomationException("Missing -Plugin=... argument");
        }

        // Check it exists
        FileReference PluginFile = new FileReference(PluginParam);

        if (!FileReference.Exists(PluginFile))
        {
            throw new AutomationException("Plugin '{0}' not found", PluginFile.FullName);
        }

        // Get the output directory
        string PackageParam = ParseParamValue("Package");

        if (PackageParam == null)
        {
            throw new AutomationException("Missing -Package=... argument");
        }

        // Option for verifying that all include directive s
        bool bStrictIncludes = ParseParam("StrictIncludes");

        // Whether to use VS2019 for compiling all targets. By default, we currently use 2017 for compiling static libraries for maximum compatibility.
        bool bVS2019 = ParseParam("VS2019");

        // Make sure the packaging directory is valid
        DirectoryReference PackageDir = new DirectoryReference(PackageParam);

        if (PluginFile.IsUnderDirectory(PackageDir))
        {
            throw new AutomationException("Packaged plugin output directory must be different to source");
        }
        if (PackageDir.IsUnderDirectory(DirectoryReference.Combine(CommandUtils.RootDirectory, "Engine")))
        {
            throw new AutomationException("Output directory for packaged plugin must be outside engine directory");
        }

        // Clear the output directory of existing stuff
        if (DirectoryReference.Exists(PackageDir))
        {
            CommandUtils.DeleteDirectoryContents(PackageDir.FullName);
        }
        else
        {
            DirectoryReference.CreateDirectory(PackageDir);
        }

        // Create a placeholder FilterPlugin.ini with instructions on how to use it
        FileReference SourceFilterFile = FileReference.Combine(PluginFile.Directory, "Config", "FilterPlugin.ini");

        if (!FileReference.Exists(SourceFilterFile))
        {
            List <string> Lines = new List <string>();
            Lines.Add("[FilterPlugin]");
            Lines.Add("; This section lists additional files which will be packaged along with your plugin. Paths should be listed relative to the root plugin directory, and");
            Lines.Add("; may include \"...\", \"*\", and \"?\" wildcards to match directories, files, and individual characters respectively.");
            Lines.Add(";");
            Lines.Add("; Examples:");
            Lines.Add(";    /README.txt");
            Lines.Add(";    /Extras/...");
            Lines.Add(";    /Binaries/ThirdParty/*.dll");
            DirectoryReference.CreateDirectory(SourceFilterFile.Directory);
            CommandUtils.WriteAllLines_NoExceptions(SourceFilterFile.FullName, Lines.ToArray());
        }

        // Create a host project for the plugin. For script generator plugins, we need to have UHT be able to load it, which can only happen if it's enabled in a project.
        FileReference HostProjectFile       = FileReference.Combine(PackageDir, "HostProject", "HostProject.uproject");
        FileReference HostProjectPluginFile = CreateHostProject(HostProjectFile, PluginFile);

        // Read the plugin
        CommandUtils.LogInformation("Reading plugin from {0}...", HostProjectPluginFile);
        PluginDescriptor Plugin = PluginDescriptor.FromFile(HostProjectPluginFile);

        // Get the arguments for the compile
        StringBuilder AdditionalArgs = new StringBuilder();

        if (bStrictIncludes)
        {
            CommandUtils.LogInformation("Building with precompiled headers and unity disabled");
            AdditionalArgs.Append(" -NoPCH -NoSharedPCH -DisableUnity");
        }

        // Compile the plugin for all the target platforms
        List <UnrealTargetPlatform> HostPlatforms = ParseParam("NoHostPlatform")? new List <UnrealTargetPlatform>() : new List <UnrealTargetPlatform> {
            BuildHostPlatform.Current.Platform
        };
        List <UnrealTargetPlatform> TargetPlatforms = GetTargetPlatforms(this, BuildHostPlatform.Current.Platform);

        FileReference[] BuildProducts = CompilePlugin(HostProjectFile, HostProjectPluginFile, Plugin, HostPlatforms, TargetPlatforms, AdditionalArgs.ToString(), bVS2019);

        // Package up the final plugin data
        PackagePlugin(HostProjectPluginFile, BuildProducts, PackageDir, ParseParam("unversioned"));

        // Remove the host project
        if (!ParseParam("NoDeleteHostProject"))
        {
            CommandUtils.DeleteDirectory(HostProjectFile.Directory.FullName);
        }
    }
		/// <summary>
		/// Find the game which contains a given input file.
		/// </summary>
		/// <param name="AllGameFolders">All game folders</param>
		/// <param name="File">Full path of the file to search for</param>
		protected UProjectInfo FindGameContainingFile(List<UProjectInfo> AllGames, FileReference File)
		{
			foreach (UProjectInfo Game in AllGames)
			{
				if (File.IsUnderDirectory(Game.Folder))
				{
					return Game;
				}
			}
			return null;
		}
Exemplo n.º 15
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="FileInfo">File to be added</param>
		/// <param name="RootDir">Root directory to store paths relative to</param>
		public TempStorageFile(FileInfo FileInfo, DirectoryReference RootDir)
		{
			// Check the file exists and is in the right location
			FileReference File = new FileReference(FileInfo);
			if(!File.IsUnderDirectory(RootDir))
			{
				throw new AutomationException("Attempt to add file to temp storage manifest that is outside the root directory ({0})", File.FullName);
			}
			if(!FileInfo.Exists)
			{
				throw new AutomationException("Attempt to add file to temp storage manifest that does not exist ({0})", File.FullName);
			}

			RelativePath = File.MakeRelativeTo(RootDir).Replace(Path.DirectorySeparatorChar, '/');
			LastWriteTimeUtcTicks = FileInfo.LastWriteTimeUtc.Ticks;
			Length = FileInfo.Length;
		}
	public override void ExecuteBuild()
	{
		// Get the plugin filename
		string PluginParam = ParseParamValue("Plugin");
		if(PluginParam == null)
		{
			throw new AutomationException("Missing -Plugin=... argument");
		}

		// Check it exists
		FileReference PluginFile = new FileReference(PluginParam);
		if (!PluginFile.Exists())
		{
			throw new AutomationException("Plugin '{0}' not found", PluginFile.FullName);
		}

		// Get the output directory
		string PackageParam = ParseParamValue("Package");
		if (PackageParam == null)
		{
			throw new AutomationException("Missing -Package=... argument");
		}

		// Make sure the packaging directory is valid
		DirectoryReference PackageDir = new DirectoryReference(PackageParam);
		if (PluginFile.IsUnderDirectory(PackageDir))
		{
			throw new AutomationException("Packaged plugin output directory must be different to source");
		}
		if (PackageDir.IsUnderDirectory(DirectoryReference.Combine(CommandUtils.RootDirectory, "Engine")))
		{
			throw new AutomationException("Output directory for packaged plugin must be outside engine directory");
		}

		// Clear the output directory of existing stuff
		if (PackageDir.Exists())
		{
			CommandUtils.DeleteDirectoryContents(PackageDir.FullName);
		}
		else
		{
			PackageDir.CreateDirectory();
		}

		// Create a placeholder FilterPlugin.ini with instructions on how to use it
		FileReference SourceFilterFile = FileReference.Combine(PluginFile.Directory, "Config", "FilterPlugin.ini");
		if (!SourceFilterFile.Exists())
		{
			List<string> Lines = new List<string>();
			Lines.Add("[FilterPlugin]");
			Lines.Add("; This section lists additional files which will be packaged along with your plugin. Paths should be listed relative to the root plugin directory, and");
			Lines.Add("; may include \"...\", \"*\", and \"?\" wildcards to match directories, files, and individual characters respectively.");
			Lines.Add(";");
			Lines.Add("; Examples:");
			Lines.Add(";    /README.txt");
			Lines.Add(";    /Extras/...");
			Lines.Add(";    /Binaries/ThirdParty/*.dll");
			SourceFilterFile.Directory.CreateDirectory();
			CommandUtils.WriteAllLines_NoExceptions(SourceFilterFile.FullName, Lines.ToArray());
		}

		// Create a host project for the plugin. For script generator plugins, we need to have UHT be able to load it, which can only happen if it's enabled in a project.
		FileReference HostProjectFile = FileReference.Combine(PackageDir, "HostProject", "HostProject.uproject");
		FileReference HostProjectPluginFile = CreateHostProject(HostProjectFile, PluginFile);

		// Read the plugin
		CommandUtils.Log("Reading plugin from {0}...", HostProjectPluginFile);
		PluginDescriptor Plugin = PluginDescriptor.FromFile(HostProjectPluginFile, false);

		// Compile the plugin for all the target platforms
		List<UnrealTargetPlatform> HostPlatforms = ParseParam("NoHostPlatform")? new List<UnrealTargetPlatform>() : new List<UnrealTargetPlatform> { BuildHostPlatform.Current.Platform };
		List<UnrealTargetPlatform> TargetPlatforms = GetTargetPlatforms(this, BuildHostPlatform.Current.Platform).Where(x => IsCodeTargetPlatform(BuildHostPlatform.Current.Platform, x)).ToList();
		FileReference[] BuildProducts = CompilePlugin(HostProjectFile, HostProjectPluginFile, Plugin, HostPlatforms, TargetPlatforms, "");

		// Package up the final plugin data
		PackagePlugin(HostProjectPluginFile, BuildProducts, PackageDir);

		// Remove the host project
		if(!ParseParam("NoDeleteHostProject"))
		{
			CommandUtils.DeleteDirectory(HostProjectFile.Directory.FullName);
		}
	}
Exemplo n.º 17
0
        public virtual List <string> GetExecutableNames(DeploymentContext SC, bool bIsRun = false)
        {
            var    ExecutableNames = new List <String>();
            string Ext             = AutomationTool.Platform.GetExeExtension(SC.StageTargetPlatform.TargetPlatformType);

            if (!String.IsNullOrEmpty(SC.CookPlatform))
            {
                if (SC.StageTargets.Count() > 0)
                {
                    DirectoryReference ProjectRoot = new DirectoryReference(SC.ProjectRoot);
                    foreach (StageTarget Target in SC.StageTargets)
                    {
                        foreach (BuildProduct Product in Target.Receipt.BuildProducts)
                        {
                            if (Product.Type == BuildProductType.Executable)
                            {
                                FileReference BuildProductFile = new FileReference(Product.Path);
                                if (BuildProductFile.IsUnderDirectory(ProjectRoot))
                                {
                                    ExecutableNames.Add(CombinePaths(SC.RuntimeProjectRootDir, BuildProductFile.MakeRelativeTo(ProjectRoot)));
                                }
                                else
                                {
                                    ExecutableNames.Add(CombinePaths(SC.RuntimeRootDir, BuildProductFile.MakeRelativeTo(RootDirectory)));
                                }
                            }
                        }
                    }
                }
                //@todo, probably the rest of this can go away once everything passes it through
                else if (SC.DedicatedServer)
                {
                    if (!SC.IsCodeBasedProject)
                    {
                        string ExeName = SC.StageTargetPlatform.GetPlatformExecutableName("UE4Server");
                        ExecutableNames.Add(CombinePaths(SC.RuntimeRootDir, "Engine/Binaries", SC.PlatformDir, ExeName + Ext));
                    }
                    else
                    {
                        string ExeName   = SC.StageTargetPlatform.GetPlatformExecutableName(SC.ShortProjectName + "Server");
                        string ClientApp = CombinePaths(SC.RuntimeProjectRootDir, "Binaries", SC.PlatformDir, ExeName + Ext);
                        var    TestApp   = CombinePaths(SC.ProjectRoot, "Binaries", SC.PlatformDir, SC.ShortProjectName + "Server" + Ext);
                        string Game      = "Game";
                        //@todo, this is sketchy, someone might ask what the exe is before it is compiled
                        if (!FileExists_NoExceptions(ClientApp) && !FileExists_NoExceptions(TestApp) && SC.ShortProjectName.EndsWith(Game, StringComparison.InvariantCultureIgnoreCase))
                        {
                            ExeName   = SC.StageTargetPlatform.GetPlatformExecutableName(SC.ShortProjectName.Substring(0, SC.ShortProjectName.Length - Game.Length) + "Server");
                            ClientApp = CombinePaths(SC.RuntimeProjectRootDir, "Binaries", SC.PlatformDir, ExeName + Ext);
                        }
                        ExecutableNames.Add(ClientApp);
                    }
                }
                else
                {
                    if (!SC.IsCodeBasedProject)
                    {
                        string ExeName = SC.StageTargetPlatform.GetPlatformExecutableName("UE4Game");
                        ExecutableNames.Add(CombinePaths(SC.RuntimeRootDir, "Engine/Binaries", SC.PlatformDir, ExeName + Ext));
                    }
                    else
                    {
                        string ExeName = SC.StageTargetPlatform.GetPlatformExecutableName(SC.ShortProjectName);
                        ExecutableNames.Add(CombinePaths(SC.RuntimeProjectRootDir, "Binaries", SC.PlatformDir, ExeName + Ext));
                    }
                }
            }
            else
            {
                string ExeName = SC.StageTargetPlatform.GetPlatformExecutableName("UE4Editor");
                ExecutableNames.Add(CombinePaths(SC.RuntimeRootDir, "Engine/Binaries", SC.PlatformDir, ExeName + Ext));
            }
            return(ExecutableNames);
        }
Exemplo n.º 18
0
    public int ArchiveFiles(string InPath, string Wildcard = "*", bool bRecursive = true, string[] ExcludeWildcard = null, string NewPath = null)
    {
        int FilesAdded = 0;

        if (CommandUtils.DirectoryExists(InPath))
        {
            var All = CommandUtils.FindFiles(Wildcard, bRecursive, InPath);

            var Exclude = new HashSet <string>();
            if (ExcludeWildcard != null)
            {
                foreach (var Excl in ExcludeWildcard)
                {
                    var Remove = CommandUtils.FindFiles(Excl, bRecursive, InPath);
                    foreach (var File in Remove)
                    {
                        Exclude.Add(CommandUtils.CombinePaths(File));
                    }
                }
            }
            foreach (var AllFile in All)
            {
                var FileToCopy = CommandUtils.CombinePaths(AllFile);
                if (Exclude.Contains(FileToCopy))
                {
                    continue;
                }

                if (!bIsCombiningMultiplePlatforms)
                {
                    FileReference InputFile = new FileReference(FileToCopy);

                    bool OtherPlatform = false;
                    foreach (UnrealTargetPlatform Plat in Enum.GetValues(typeof(UnrealTargetPlatform)))
                    {
                        if (Plat != StageTargetPlatform.PlatformType && Plat != UnrealTargetPlatform.Unknown)
                        {
                            var Search = FileToCopy;
                            if (InputFile.IsUnderDirectory(LocalRoot))
                            {
                                Search = InputFile.MakeRelativeTo(LocalRoot);
                            }
                            else if (InputFile.IsUnderDirectory(ProjectRoot))
                            {
                                Search = InputFile.MakeRelativeTo(ProjectRoot);
                            }
                            if (Search.IndexOf(CommandUtils.CombinePaths("/" + Plat.ToString() + "/"), 0, StringComparison.InvariantCultureIgnoreCase) >= 0)
                            {
                                OtherPlatform = true;
                                break;
                            }
                        }
                    }
                    if (OtherPlatform)
                    {
                        continue;
                    }
                }

                string Dest;
                if (!FileToCopy.StartsWith(InPath))
                {
                    throw new AutomationException("Can't archive {0}; it was supposed to start with {1}", FileToCopy, InPath);
                }

                // If the specified a new directory, first we deal with that, then apply the other things
                // this is used to collapse the sandbox, among other things
                if (NewPath != null)
                {
                    Dest = FileToCopy.Substring(InPath.Length);
                    if (Dest.StartsWith("/") || Dest.StartsWith("\\"))
                    {
                        Dest = Dest.Substring(1);
                    }
                    Dest = CommandUtils.CombinePaths(NewPath, Dest);
                }
                else
                {
                    Dest = FileToCopy.Substring(InPath.Length);
                }

                if (Dest.StartsWith("/") || Dest.StartsWith("\\"))
                {
                    Dest = Dest.Substring(1);
                }

                if (ArchivedFiles.ContainsKey(FileToCopy))
                {
                    if (ArchivedFiles[FileToCopy] != Dest)
                    {
                        throw new AutomationException("Can't archive {0}: it was already in the files to archive with a different destination '{1}'", FileToCopy, Dest);
                    }
                }
                else
                {
                    ArchivedFiles.Add(FileToCopy, Dest);
                }

                FilesAdded++;
            }
        }

        return(FilesAdded);
    }
Exemplo n.º 19
0
		/// <summary>
		/// Checks whether the given assembly is a publically distributed engine assembly.
		/// </summary>
		/// <param name="File">Assembly location</param>
		/// <returns>True if the assembly is distributed publically</returns>
		static bool IsPublicAssembly(FileReference File)
		{
			DirectoryReference EngineDirectory = UnrealBuildTool.UnrealBuildTool.EngineDirectory;
			if(File.IsUnderDirectory(EngineDirectory))
			{
				string[] PathFragments = File.MakeRelativeTo(EngineDirectory).Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
				if(PathFragments.All(x => !x.Equals("NotForLicensees", StringComparison.InvariantCultureIgnoreCase) && !x.Equals("NoRedist", StringComparison.InvariantCultureIgnoreCase)))
				{
					return true;
				}
			}
			return false;
		}