コード例 #1
0
        private bool TryCreateLogFolder(string PossibleLogFolder)
        {
            bool Result = true;

            try
            {
                if (Directory.Exists(PossibleLogFolder))
                {
                    CommandUtils.DeleteDirectoryContents(PossibleLogFolder);

                    // Since the directory existed and might have been empty, we need to make sure
                    // we can actually write to it, so create and delete a temporary file.
                    var RandomFilename = Path.GetRandomFileName();
                    var RandomFilePath = CommandUtils.CombinePaths(PossibleLogFolder, RandomFilename);
                    File.WriteAllText(RandomFilePath, RandomFilename);
                    File.Delete(RandomFilePath);
                }
                else
                {
                    Directory.CreateDirectory(PossibleLogFolder);
                }
            }
            catch (UnauthorizedAccessException Ex)
            {
                Log.TraceInformation("No permission to use LogFolder={0} ({1})", PossibleLogFolder, Ex.Message);
                Result = false;
            }
            if (Result)
            {
                Environment.SetEnvironmentVariable(EnvVarNames.LogFolder, PossibleLogFolder);
            }
            return(Result);
        }
コード例 #2
0
        /// <summary>
        /// Clears out the contents of the given log folder
        /// </summary>
        /// <param name="LogFolder">The log folder to clear</param>
        private static void ClearLogFolder(string LogFolder)
        {
            try
            {
                if (Directory.Exists(LogFolder))
                {
                    CommandUtils.DeleteDirectoryContents(LogFolder);

                    // Since the directory existed and might have been empty, we need to make sure
                    // we can actually write to it, so create and delete a temporary file.
                    var RandomFilename = Path.GetRandomFileName();
                    var RandomFilePath = CommandUtils.CombinePaths(LogFolder, RandomFilename);
                    File.WriteAllText(RandomFilePath, RandomFilename);
                    File.Delete(RandomFilePath);
                }
                else
                {
                    Directory.CreateDirectory(LogFolder);
                }
            }
            catch (Exception Ex)
            {
                throw new AutomationException(Ex, "Unable to clear log folder ({0})", LogFolder);
            }
        }
コード例 #3
0
		/// <summary>
		/// Performs initial cleanup of target rules folder
		/// </summary>
		public static void CleanupFolders()
		{
			CommandUtils.LogVerbose("Cleaning up project rules folder");
			var RulesFolder = GetRulesAssemblyFolder();
			if (CommandUtils.DirectoryExists(RulesFolder))
			{
				CommandUtils.DeleteDirectoryContents(RulesFolder);
			}
		}
コード例 #4
0
        /// <summary>
        /// Cleans local build products for a given node. Does not modify shared storage.
        /// </summary>
        /// <param name="NodeName">Name of the node</param>
        public void CleanLocalNode(string NodeName)
        {
            DirectoryReference NodeDir = GetDirectoryForNode(LocalDir, NodeName);

            if (NodeDir.Exists())
            {
                CommandUtils.DeleteDirectoryContents(NodeDir.FullName);
                CommandUtils.DeleteDirectory_NoExceptions(NodeDir.FullName);
            }
        }
コード例 #5
0
        public override void ExecuteBuild()
        {
            // Parse all the arguments
            string TargetName   = ParseRequiredStringParam("Name");
            string PlatformName = ParseOptionalStringParam("Platform");
            UnrealTargetPlatform Platform;

            if (UnrealTargetPlatform.TryParse(PlatformName, out Platform))
            {
                Platform = HostPlatform.Current.HostEditorPlatform;
            }
            UnrealTargetConfiguration Configuration = ParseOptionalEnumParam <UnrealTargetConfiguration>("Configuration") ?? UnrealTargetConfiguration.Development;
            string             Architecture         = ParseOptionalStringParam("Architecture");
            FileReference      ProjectFile          = ParseOptionalFileReferenceParam("Project");
            DirectoryReference ToDir = ParseRequiredDirectoryReferenceParam("To");

            // Read the receipt
            FileReference ReceiptFile = TargetReceipt.GetDefaultPath(DirectoryReference.FromFile(ProjectFile) ?? EngineDirectory, TargetName, Platform, Configuration, Architecture);

            if (!FileReference.Exists(ReceiptFile))
            {
                throw new AutomationException("Unable to find '{0}'", ReceiptFile);
            }

            TargetReceipt Receipt = TargetReceipt.Read(ReceiptFile);

            // Enumerate all the files we want to move
            List <FileReference> FilesToMove = new List <FileReference>();

            FilesToMove.Add(ReceiptFile);
            FilesToMove.AddRange(Receipt.BuildProducts.Select(x => x.Path));

            // Move all the files to the output folder
            DirectoryReference.CreateDirectory(ToDir);
            CommandUtils.DeleteDirectoryContents(ToDir.FullName);
            foreach (FileReference SourceFile in FilesToMove)
            {
                FileReference TargetFile = FileReference.Combine(ToDir, SourceFile.MakeRelativeTo(RootDirectory));
                LogInformation("Copying {0} to {1}", SourceFile, TargetFile);
                CommandUtils.CopyFile(SourceFile.FullName, TargetFile.FullName);
            }
        }
コード例 #6
0
        /// <summary>
        /// Run the automated tests
        /// </summary>
        public override void ExecuteBuild()
        {
            // Get all the shared directories
            DirectoryReference RootDir = new DirectoryReference(CommandUtils.CmdEnv.LocalRoot);

            DirectoryReference LocalDir = DirectoryReference.Combine(RootDir, "Engine", "Saved", "TestTempStorage-Local");

            CommandUtils.CreateDirectory_NoExceptions(LocalDir.FullName);
            CommandUtils.DeleteDirectoryContents(LocalDir.FullName);

            DirectoryReference SharedDir = DirectoryReference.Combine(RootDir, "Engine", "Saved", "TestTempStorage-Shared");

            CommandUtils.CreateDirectory_NoExceptions(SharedDir.FullName);
            CommandUtils.DeleteDirectoryContents(SharedDir.FullName);

            DirectoryReference WorkingDir = DirectoryReference.Combine(RootDir, "Engine", "Saved", "TestTempStorage-Working");

            CommandUtils.CreateDirectory_NoExceptions(WorkingDir.FullName);
            CommandUtils.DeleteDirectoryContents(WorkingDir.FullName);

            // Create the temp storage object
            TempStorage TempStore = new TempStorage(WorkingDir, LocalDir, SharedDir, true);

            // Create a working directory, and copy some source files into it
            DirectoryReference SourceDir = DirectoryReference.Combine(RootDir, "Engine", "Source", "Runtime");

            if (!CommandUtils.CopyDirectory_NoExceptions(SourceDir.FullName, WorkingDir.FullName, true))
            {
                throw new AutomationException("Couldn't copy {0} to {1}", SourceDir.FullName, WorkingDir.FullName);
            }

            // Save the default output
            Dictionary <FileReference, DateTime> DefaultOutput = SelectFiles(WorkingDir, 'a', 'f');

            TempStore.Archive("TestNode", null, DefaultOutput.Keys.ToArray(), false);

            Dictionary <FileReference, DateTime> NamedOutput = SelectFiles(WorkingDir, 'g', 'i');

            TempStore.Archive("TestNode", "NamedOutput", NamedOutput.Keys.ToArray(), true);

            // Check both outputs are still ok
            TempStorageManifest DefaultManifest = TempStore.Retreive("TestNode", null);

            CheckManifest(WorkingDir, DefaultManifest, DefaultOutput);

            TempStorageManifest NamedManifest = TempStore.Retreive("TestNode", "NamedOutput");

            CheckManifest(WorkingDir, NamedManifest, NamedOutput);

            // Delete local temp storage and the working directory and try again
            CommandUtils.Log("Clearing local folders...");
            CommandUtils.DeleteDirectoryContents(WorkingDir.FullName);
            CommandUtils.DeleteDirectoryContents(LocalDir.FullName);

            // First output should fail
            CommandUtils.Log("Checking default manifest is now unavailable...");
            bool bGotManifest = false;

            try
            {
                TempStore.Retreive("TestNode", null);
            }
            catch
            {
                bGotManifest = false;
            }
            if (bGotManifest)
            {
                throw new AutomationException("Did not expect shared temp storage manifest to exist");
            }

            // Second one should be fine
            TempStorageManifest NamedManifestFromShared = TempStore.Retreive("TestNode", "NamedOutput");

            CheckManifest(WorkingDir, NamedManifestFromShared, NamedOutput);
        }
コード例 #7
0
 /// <summary>
 /// Cleans all cached local state. We never remove shared storage.
 /// </summary>
 public void CleanLocal()
 {
     CommandUtils.DeleteDirectoryContents(LocalDir.FullName);
 }