예제 #1
0
    static void PackagePlugin(FileReference SourcePluginFile, IEnumerable <FileReference> BuildProducts, DirectoryReference TargetDir, bool bUnversioned)
    {
        DirectoryReference SourcePluginDir = SourcePluginFile.Directory;

        // Copy all the files to the output directory
        FileReference[] SourceFiles = FilterPluginFiles(SourcePluginFile, BuildProducts).ToArray();
        foreach (FileReference SourceFile in SourceFiles)
        {
            FileReference TargetFile = FileReference.Combine(TargetDir, SourceFile.MakeRelativeTo(SourcePluginDir));
            CommandUtils.CopyFile(SourceFile.FullName, TargetFile.FullName);
            CommandUtils.SetFileAttributes(TargetFile.FullName, ReadOnly: false);
        }

        // Get the output plugin filename
        FileReference    TargetPluginFile = FileReference.Combine(TargetDir, SourcePluginFile.GetFileName());
        PluginDescriptor NewDescriptor    = PluginDescriptor.FromFile(TargetPluginFile);

        NewDescriptor.bEnabledByDefault = null;
        NewDescriptor.bInstalled        = true;
        if (!bUnversioned)
        {
            BuildVersion Version;
            if (BuildVersion.TryRead(BuildVersion.GetDefaultFileName(), out Version))
            {
                NewDescriptor.EngineVersion = String.Format("{0}.{1}.0", Version.MajorVersion, Version.MinorVersion);
            }
        }
        NewDescriptor.Save(TargetPluginFile.FullName);
    }
예제 #2
0
    public override void ExecuteBuild()
    {
        // Get the output directory
        string TargetDirParam = ParseParamValue("TargetDir");

        if (TargetDirParam == null)
        {
            throw new AutomationException("Missing -TargetDir=... argument to CopyUAT");
        }

        // Construct a dummy UE4Build object to get a list of the UAT and UBT build products
        UE4Build Build = new UE4Build(this);

        Build.AddUATFilesToBuildProducts();
        if (ParseParam("WithLauncher"))
        {
            Build.AddUATLauncherFilesToBuildProducts();
        }
        Build.AddUBTFilesToBuildProducts();

        // Get a list of all the input files
        List <FileReference> SourceFiles = new List <FileReference>();

        foreach (string BuildProductFile in Build.BuildProductFiles)
        {
            FileReference SourceFile = new FileReference(BuildProductFile);
            SourceFiles.Add(SourceFile);

            FileReference SourceSymbolFile = SourceFile.ChangeExtension(".pdb");
            if (FileReference.Exists(SourceSymbolFile))
            {
                SourceFiles.Add(SourceSymbolFile);
            }

            FileReference DocumentationFile = SourceFile.ChangeExtension(".xml");
            if (FileReference.Exists(DocumentationFile))
            {
                SourceFiles.Add(DocumentationFile);
            }
        }

        // Copy all the files over
        DirectoryReference TargetDir = new DirectoryReference(TargetDirParam);

        foreach (FileReference SourceFile in SourceFiles)
        {
            FileReference TargetFile = FileReference.Combine(TargetDir, SourceFile.MakeRelativeTo(CommandUtils.RootDirectory));
            DirectoryReference.CreateDirectory(TargetFile.Directory);
            CommandUtils.CopyFile(SourceFile.FullName, TargetFile.FullName);
        }

        Log("Copied {0} files to {1}", SourceFiles.Count, TargetDir);
    }
    void StageBootstrapExecutable(DeploymentContext SC, string ExeName, string TargetFile, string StagedRelativeTargetPath, string StagedArguments)
    {
        string InputFile = CombinePaths(SC.LocalRoot, "Engine", "Binaries", SC.PlatformDir, String.Format("BootstrapPackagedGame-{0}-Shipping.exe", SC.PlatformDir));

        if (InternalUtils.SafeFileExists(InputFile))
        {
            // Create the new bootstrap program
            string IntermediateDir = CombinePaths(SC.ProjectRoot, "Intermediate", "Staging");
            InternalUtils.SafeCreateDirectory(IntermediateDir);

            string IntermediateFile = CombinePaths(IntermediateDir, ExeName);
            CommandUtils.CopyFile(InputFile, IntermediateFile);
            CommandUtils.SetFileAttributes(IntermediateFile, ReadOnly: false);

            // currently the icon updating doesn't run under mono
            if (UnrealBuildTool.BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Win64 ||
                UnrealBuildTool.BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Win32)
            {
                // Get the icon from the build directory if possible
                GroupIconResource GroupIcon = null;
                if (InternalUtils.SafeFileExists(CombinePaths(SC.ProjectRoot, "Build/Windows/Application.ico")))
                {
                    GroupIcon = GroupIconResource.FromIco(CombinePaths(SC.ProjectRoot, "Build/Windows/Application.ico"));
                }
                if (GroupIcon == null)
                {
                    GroupIcon = GroupIconResource.FromExe(TargetFile);
                }

                // Update the resources in the new file
                using (ModuleResourceUpdate Update = new ModuleResourceUpdate(IntermediateFile, true))
                {
                    const int IconResourceId = 101;
                    if (GroupIcon != null)
                    {
                        Update.SetIcons(IconResourceId, GroupIcon);
                    }

                    const int ExecFileResourceId = 201;
                    Update.SetData(ExecFileResourceId, ResourceType.RawData, Encoding.Unicode.GetBytes(StagedRelativeTargetPath + "\0"));

                    const int ExecArgsResourceId = 202;
                    Update.SetData(ExecArgsResourceId, ResourceType.RawData, Encoding.Unicode.GetBytes(StagedArguments + "\0"));
                }
            }

            // Copy it to the staging directory
            SC.StageFiles(StagedFileType.NonUFS, IntermediateDir, ExeName, false, null, "");
        }
    }
    static void PackagePlugin(FileReference SourcePluginFile, IEnumerable <FileReference> BuildProducts, DirectoryReference TargetDir)
    {
        DirectoryReference SourcePluginDir = SourcePluginFile.Directory;

        // Copy all the files to the output directory
        FileReference[] SourceFiles = FilterPluginFiles(SourcePluginFile, BuildProducts).ToArray();
        foreach (FileReference SourceFile in SourceFiles)
        {
            FileReference TargetFile = FileReference.Combine(TargetDir, SourceFile.MakeRelativeTo(SourcePluginDir));
            CommandUtils.CopyFile(SourceFile.FullName, TargetFile.FullName);
            CommandUtils.SetFileAttributes(TargetFile.FullName, ReadOnly: false);
        }

        // Get the output plugin filename
        FileReference    TargetPluginFile = FileReference.Combine(TargetDir, SourcePluginFile.GetFileName());
        PluginDescriptor NewDescriptor    = PluginDescriptor.FromFile(TargetPluginFile, false);

        NewDescriptor.bEnabledByDefault = true;
        NewDescriptor.bInstalled        = true;
        NewDescriptor.Save(TargetPluginFile.FullName, false);
    }
예제 #5
0
    static void PackagePlugin(string PluginFileName, List <BuildProduct> BuildProducts, string PackageDirectory)
    {
        // Clear the output directory
        CommandUtils.DeleteDirectoryContents(PackageDirectory);

        // Copy all the files to the output directory
        List <string> MatchingFileNames = FilterPluginFiles(PluginFileName, BuildProducts);

        foreach (string MatchingFileName in MatchingFileNames)
        {
            string SourceFileName = Path.Combine(Path.GetDirectoryName(PluginFileName), MatchingFileName);
            string TargetFileName = Path.Combine(PackageDirectory, MatchingFileName);
            CommandUtils.CopyFile(SourceFileName, TargetFileName);
            CommandUtils.SetFileAttributes(TargetFileName, ReadOnly: false);
        }

        // Get the output plugin filename
        string           TargetPluginFileName = CommandUtils.MakeRerootedFilePath(Path.GetFullPath(PluginFileName), Path.GetDirectoryName(Path.GetFullPath(PluginFileName)), PackageDirectory);
        PluginDescriptor NewDescriptor        = PluginDescriptor.FromFile(TargetPluginFileName);

        NewDescriptor.bEnabledByDefault = true;
        NewDescriptor.bInstalled        = true;
        NewDescriptor.Save(TargetPluginFileName);
    }
        /// <summary>
        /// Execute the task.
        /// </summary>
        /// <param name="Job">Information about the current job</param>
        /// <param name="BuildProducts">Set of build products produced by this node.</param>
        /// <param name="TagNameToFileSet">Mapping from tag names to the set of files they include</param>
        /// <returns>True if the task succeeded</returns>
        public override bool Execute(JobContext Job, HashSet <FileReference> BuildProducts, Dictionary <string, HashSet <FileReference> > TagNameToFileSet)
        {
            // Get the project path, and check it exists
            FileReference ProjectFile = null;

            if (Parameters.Project != null)
            {
                ProjectFile = ResolveFile(Parameters.Project);
                if (!ProjectFile.Exists())
                {
                    CommandUtils.LogError("Couldn't find project '{0}'", ProjectFile.FullName);
                    return(false);
                }
            }

            // Get the directories used for staging this project
            DirectoryReference SourceEngineDir  = UnrealBuildTool.UnrealBuildTool.EngineDirectory;
            DirectoryReference SourceProjectDir = (ProjectFile == null)? SourceEngineDir : ProjectFile.Directory;

            // Get the output directories. We flatten the directory structure on output.
            DirectoryReference TargetDir        = ResolveDirectory(Parameters.ToDir);
            DirectoryReference TargetEngineDir  = DirectoryReference.Combine(TargetDir, "Engine");
            DirectoryReference TargetProjectDir = DirectoryReference.Combine(TargetDir, ProjectFile.GetFileNameWithoutExtension());

            // Get the path to the receipt
            string ReceiptFileName = TargetReceipt.GetDefaultPath(SourceProjectDir.FullName, Parameters.Target, Parameters.Platform, Parameters.Configuration, Parameters.Architecture);

            // Try to load it
            TargetReceipt Receipt;

            if (!TargetReceipt.TryRead(ReceiptFileName, out Receipt))
            {
                CommandUtils.LogError("Couldn't read receipt '{0}'", ReceiptFileName);
                return(false);
            }

            // Expand all the paths from the receipt
            Receipt.ExpandPathVariables(SourceEngineDir, SourceProjectDir);

            // Stage all the build products needed at runtime
            HashSet <FileReference> SourceFiles = new HashSet <FileReference>();

            foreach (BuildProduct BuildProduct in Receipt.BuildProducts.Where(x => x.Type != BuildProductType.StaticLibrary && x.Type != BuildProductType.ImportLibrary))
            {
                SourceFiles.Add(new FileReference(BuildProduct.Path));
            }
            foreach (RuntimeDependency RuntimeDependency in Receipt.RuntimeDependencies.Where(x => x.Type != StagedFileType.UFS))
            {
                SourceFiles.UnionWith(CommandUtils.ResolveFilespec(CommandUtils.RootDirectory, RuntimeDependency.Path, new string[] { ".../*.umap", ".../*.uasset" }));
            }

            // Get all the target files
            List <FileReference> TargetFiles = new List <FileReference>();

            foreach (FileReference SourceFile in SourceFiles)
            {
                // Get the destination file to copy to, mapping to the new engine and project directories as appropriate
                FileReference TargetFile;
                if (SourceFile.IsUnderDirectory(SourceEngineDir))
                {
                    TargetFile = FileReference.Combine(TargetEngineDir, SourceFile.MakeRelativeTo(SourceEngineDir));
                }
                else
                {
                    TargetFile = FileReference.Combine(TargetProjectDir, SourceFile.MakeRelativeTo(SourceProjectDir));
                }

                // Fixup the case of the output file. Would expect Platform.DeployLowerCaseFilenames() to return true here, but seems not to be the case.
                if (Parameters.Platform == UnrealTargetPlatform.PS4)
                {
                    TargetFile = FileReference.Combine(TargetDir, TargetFile.MakeRelativeTo(TargetDir).ToLowerInvariant());
                }

                // Only copy the output file if it doesn't already exist. We can stage multiple targets to the same output directory.
                if (Parameters.Overwrite || !TargetFile.Exists())
                {
                    TargetFile.Directory.CreateDirectory();
                    CommandUtils.CopyFile(SourceFile.FullName, TargetFile.FullName);
                }

                // Add it to the list of target files
                TargetFiles.Add(TargetFile);
            }

            // Apply the optional tag to the build products
            foreach (string TagName in FindTagNamesFromList(Parameters.Tag))
            {
                FindOrAddTagSet(TagNameToFileSet, TagName).UnionWith(TargetFiles);
            }

            // Add the target file to the list of build products
            BuildProducts.UnionWith(TargetFiles);
            return(true);
        }
예제 #7
0
    public override void GetTargetFile(string RemoteFilePath, string LocalFile, ProjectParams Params)
    {
        var SourceFile = FileReference.Combine(new DirectoryReference(Params.BaseStageDirectory), GetCookPlatform(Params.HasServerCookedTargets, Params.HasClientTargetDetected), RemoteFilePath);

        CommandUtils.CopyFile(SourceFile.FullName, LocalFile);
    }
예제 #8
0
    public override void ExecuteBuild()
    {
        // Get the list of platform names
        string[]             FeaturePacks    = ParseParamValue("FeaturePacks").Split(';');
        string               TempDir         = ParseParamValue("TempDir");
        UnrealTargetPlatform HostPlatform    = BuildHostPlatform.Current.Platform;
        string               TargetPlatforms = ParseParamValue("TargetPlatforms");
        string               SavedDir        = ParseParamValue("SavedDir");
        string               BackendName     = ParseParamValue("BackendName", "CreateInstalledEnginePak");
        string               RelativePakPath = ParseParamValue("RelativePakPath", "Engine/DerivedDataCache/Compressed.ddp");
        bool bSkipEngine = ParseParam("SkipEngine");


        // Get paths to everything within the temporary directory
        string EditorExe     = CommandUtils.GetEditorCommandletExe(TempDir, HostPlatform);
        string OutputPakFile = CommandUtils.CombinePaths(TempDir, RelativePakPath);
        string OutputCsvFile = Path.ChangeExtension(OutputPakFile, ".csv");


        List <string> ProjectPakFiles  = new List <string>();
        List <string> FeaturePackPaths = new List <string>();

        // loop through all the projects first and bail out if one of them doesn't exist.
        foreach (string FeaturePack in FeaturePacks)
        {
            if (!String.IsNullOrWhiteSpace(FeaturePack))
            {
                string FeaturePackPath = CommandUtils.CombinePaths(CommandUtils.RootDirectory.FullName, FeaturePack);
                if (!CommandUtils.FileExists(FeaturePackPath))
                {
                    throw new AutomationException("Could not find project: " + FeaturePack);
                }
                FeaturePackPaths.Add(FeaturePackPath);
            }
        }

        // loop through all the paths and generate ddc data for them
        foreach (string FeaturePackPath in FeaturePackPaths)
        {
            string            ProjectSpecificPlatforms = TargetPlatforms;
            FileReference     FileRef  = new FileReference(FeaturePackPath);
            string            GameName = FileRef.GetFileNameWithoutAnyExtensions();
            ProjectDescriptor Project  = ProjectDescriptor.FromFile(FileRef);

            if (Project.TargetPlatforms != null && Project.TargetPlatforms.Length > 0)
            {
                // Restrict target platforms used to those specified in project file
                List <string> FilteredPlatforms = new List <string>();

                // Always include the editor platform for cooking
                string EditorCookPlatform = Platform.GetPlatform(HostPlatform).GetEditorCookPlatform();
                if (TargetPlatforms.Contains(EditorCookPlatform))
                {
                    FilteredPlatforms.Add(EditorCookPlatform);
                }

                foreach (string TargetPlatform in Project.TargetPlatforms)
                {
                    if (TargetPlatforms.Contains(TargetPlatform))
                    {
                        FilteredPlatforms.Add(TargetPlatform);
                    }
                }
                if (FilteredPlatforms.Count == 0)
                {
                    LogInformation("Did not find any project specific platforms for FeaturePack {0} out of supplied TargetPlatforms {1}, skipping it!", GameName, ProjectSpecificPlatforms);
                    continue;
                }
                ProjectSpecificPlatforms = CommandUtils.CombineCommandletParams(FilteredPlatforms.Distinct().ToArray());
            }
            CommandUtils.LogInformation("Generating DDC data for {0} on {1}", GameName, ProjectSpecificPlatforms);
            CommandUtils.DDCCommandlet(FileRef, EditorExe, null, ProjectSpecificPlatforms, String.Format("-fill -DDC={0} -ProjectOnly", BackendName));

            string ProjectPakFile = CommandUtils.CombinePaths(Path.GetDirectoryName(OutputPakFile), String.Format("Compressed-{0}.ddp", GameName));
            CommandUtils.DeleteFile(ProjectPakFile);
            CommandUtils.RenameFile(OutputPakFile, ProjectPakFile);

            string ProjectCsvFile = Path.ChangeExtension(ProjectPakFile, ".csv");
            CommandUtils.DeleteFile(ProjectCsvFile);
            CommandUtils.RenameFile(OutputCsvFile, ProjectCsvFile);

            ProjectPakFiles.Add(Path.GetFileName(ProjectPakFile));
        }

        // Generate DDC for the editor, and merge all the other PAK files in
        CommandUtils.LogInformation("Generating DDC data for engine content on {0}", TargetPlatforms);
        CommandUtils.DDCCommandlet(null, EditorExe, null, TargetPlatforms, String.Format("-fill -DDC={0} -MergePaks={1}{2}", BackendName, CommandUtils.MakePathSafeToUseWithCommandLine(String.Join("+", ProjectPakFiles)), bSkipEngine? " -projectonly" : ""));

        string SavedPakFile = CommandUtils.CombinePaths(SavedDir, RelativePakPath);

        CommandUtils.CopyFile(OutputPakFile, SavedPakFile);
    }
    public override void ExecuteBuild()
    {
        // Command parameters - not all required if using existing manifest
        string             ProjectPath     = ParseParamValue("ProjectPath");
        string             ManifestFile    = ParseParamValue("ManifestFile");
        string             UE4Exe          = ParseParamValue("UE4Exe", "UE4Editor-Cmd.exe");
        string             ReplacedPaths   = ParseParamValue("ReplacedPaths", "");
        string             ReplacedClasses = ParseParamValue("ReplacedClasses", "");
        string             ExcludedPaths   = ParseParamValue("ExcludedPaths", "");
        string             ExcludedClasses = ParseParamValue("ExcludedClasses", "");
        DirectoryReference BaseDir         = new DirectoryReference(ParseParamValue("BaseDir"));
        DirectoryReference AssetSourcePath = new DirectoryReference(ParseParamValue("AssetSourcePath"));
        bool UseExistingManifest           = ParseParam("UseExistingManifest");

        if (!UseExistingManifest || !FileExists_NoExceptions(ManifestFile))
        {
            // Run commandlet to generate list of assets to replace
            FileReference Project  = new FileReference(ProjectPath);
            var           Dir      = Path.GetDirectoryName(ManifestFile);
            var           Filename = Path.GetFileName(ManifestFile);
            if (String.IsNullOrEmpty(Dir) || String.IsNullOrEmpty(Filename))
            {
                throw new AutomationException("GenerateDistillFileSets should have a full path and file for {0}.", ManifestFile);
            }
            CreateDirectory_NoExceptions(Dir);
            if (FileExists_NoExceptions(ManifestFile))
            {
                DeleteFile(ManifestFile);
            }

            RunCommandlet(Project, UE4Exe, "GenerateAssetManifest", String.Format("-ManifestFile={0} -IncludedPaths={1} -IncludedClasses={2} -ExcludedPaths={3} -ExcludedClasses={4}", CommandUtils.MakePathSafeToUseWithCommandLine(ManifestFile), ReplacedPaths, ReplacedClasses, ExcludedPaths, ExcludedClasses));

            if (!FileExists_NoExceptions(ManifestFile))
            {
                throw new AutomationException("GenerateAssetManifest did not produce a manifest for {0}.", Project);
            }
        }

        // Read Source Files from Manifest
        List <string> Lines = new List <string>(ReadAllLines(ManifestFile));

        if (Lines.Count < 1)
        {
            throw new AutomationException("Manifest file {0} does not list any files.", ManifestFile);
        }
        List <string> SourceFiles = new List <string>();

        foreach (var ThisFile in Lines)
        {
            var TestFile = CombinePaths(ThisFile);
            if (!FileExists_NoExceptions(TestFile))
            {
                throw new AutomationException("GenerateAssetManifest produced {0}, but {1} doesn't exist.", ThisFile, TestFile);
            }
            // we correct the case here
            var TestFileInfo = new FileInfo(TestFile);
            var FinalFile    = CombinePaths(TestFileInfo.FullName);
            if (!FileExists_NoExceptions(FinalFile))
            {
                throw new AutomationException("GenerateDistillFileSets produced {0}, but {1} doesn't exist.", ThisFile, FinalFile);
            }
            SourceFiles.Add(FinalFile);
        }

        // Delete all original files - might not always be an asset to replace them with
        foreach (string SourceFile in SourceFiles)
        {
            CommandUtils.DeleteFile(SourceFile);
        }

        // Convert Source file paths to Asset Source Paths
        foreach (string ReplacedFile in SourceFiles)
        {
            FileReference ReplacementFile = FileReference.Combine(AssetSourcePath, new FileReference(ReplacedFile).MakeRelativeTo(BaseDir));
            if (FileReference.Exists(ReplacementFile))
            {
                CommandUtils.CopyFile(ReplacementFile.FullName, ReplacedFile);
            }
        }
    }
예제 #10
0
    public override bool PublishSymbols(DirectoryReference SymbolStoreDirectory, List <FileReference> Files, string Product, string BuildVersion = null)
    {
        // Get the SYMSTORE.EXE path, using the latest SDK version we can find.
        FileReference SymStoreExe = GetSymStoreExe();

        List <FileReference> FilesToAdd = Files.Where(x => x.HasExtension(".pdb") || x.HasExtension(".exe") || x.HasExtension(".dll")).ToList();

        if (FilesToAdd.Count > 0)
        {
            DateTime           Start           = DateTime.Now;
            DirectoryReference TempSymStoreDir = DirectoryReference.Combine(RootDirectory, "Saved", "SymStore");
            DirectoryReference.CreateDirectory(TempSymStoreDir);
            DeleteDirectoryContents(TempSymStoreDir);

            string TempFileName = Path.GetTempFileName();
            try
            {
                File.WriteAllLines(TempFileName, FilesToAdd.Select(x => x.FullName), Encoding.ASCII);

                // Copy everything to the temp symstore
                ProcessStartInfo StartInfo = new ProcessStartInfo();
                StartInfo.FileName        = SymStoreExe.FullName;
                StartInfo.Arguments       = string.Format("add /f \"@{0}\" /s \"{1}\" /t \"{2}\" /compress", TempFileName, TempSymStoreDir, Product);
                StartInfo.UseShellExecute = false;
                StartInfo.CreateNoWindow  = true;
                if (Utils.RunLocalProcessAndLogOutput(StartInfo) != 0)
                {
                    return(false);
                }
            }
            finally
            {
                File.Delete(TempFileName);
            }
            DateTime CompressDone = DateTime.Now;
            LogInformation("Took {0}s to compress the symbol files", (CompressDone - Start).TotalSeconds);

            // Take each new compressed file made and try and copy it to the real symstore.  Exclude any symstore admin files
            foreach (FileReference File in DirectoryReference.EnumerateFiles(TempSymStoreDir, "*.*", SearchOption.AllDirectories).Where(File => File.HasExtension(".dl_") || File.HasExtension(".ex_") || File.HasExtension(".pd_")))
            {
                string        RelativePath          = File.MakeRelativeTo(DirectoryReference.Combine(TempSymStoreDir));
                FileReference ActualDestinationFile = FileReference.Combine(SymbolStoreDirectory, RelativePath);

                // Try and add a version file.  Do this before checking to see if the symbol is there already in the case of exact matches (multiple builds could use the same pdb, for example)
                if (!string.IsNullOrWhiteSpace(BuildVersion))
                {
                    FileReference BuildVersionFile = FileReference.Combine(ActualDestinationFile.Directory, string.Format("{0}.version", BuildVersion));
                    // Attempt to create the file. Just continue if it fails.
                    try
                    {
                        DirectoryReference.CreateDirectory(BuildVersionFile.Directory);
                        FileReference.WriteAllText(BuildVersionFile, string.Empty);
                    }
                    catch (Exception Ex)
                    {
                        LogWarning("Failed to write the version file, reason {0}", Ex.ToString());
                    }
                }

                // Don't bother copying the temp file if the destination file is there already.
                if (FileReference.Exists(ActualDestinationFile))
                {
                    LogInformation("Destination file {0} already exists, skipping", ActualDestinationFile.FullName);
                    continue;
                }

                FileReference TempDestinationFile = new FileReference(ActualDestinationFile.FullName + Guid.NewGuid().ToString());
                try
                {
                    CommandUtils.CopyFile(File.FullName, TempDestinationFile.FullName);
                }
                catch (Exception Ex)
                {
                    throw new AutomationException("Couldn't copy the symbol file to the temp store! Reason: {0}", Ex.ToString());
                }
                // Move the file in the temp store over.
                try
                {
                    FileReference.Move(TempDestinationFile, ActualDestinationFile);
                }
                catch (Exception Ex)
                {
                    // If the file is there already, it was likely either copied elsewhere (and this is an ioexception) or it had a file handle open already.
                    // Either way, it's fine to just continue on.
                    if (FileReference.Exists(ActualDestinationFile))
                    {
                        LogInformation("Destination file {0} already exists or was in use, skipping.", ActualDestinationFile.FullName);
                        continue;
                    }
                    // If it doesn't exist, we actually failed to copy it entirely.
                    else
                    {
                        LogWarning("Couldn't move temp file {0} to the symbol store at location {1}! Reason: {2}", TempDestinationFile.FullName, ActualDestinationFile.FullName, Ex.ToString());
                    }
                }
                // Delete the temp one no matter what, don't want them hanging around in the symstore
                finally
                {
                    FileReference.Delete(TempDestinationFile);
                }
            }
            LogInformation("Took {0}s to copy the symbol files to the store", (DateTime.Now - CompressDone).TotalSeconds);
        }

        return(true);
    }
예제 #11
0
        /// <summary>
        /// Execute the task.
        /// </summary>
        /// <param name="Job">Information about the current job</param>
        /// <param name="BuildProducts">Set of build products produced by this node.</param>
        /// <param name="TagNameToFileSet">Mapping from tag names to the set of files they include</param>
        public override void Execute(JobContext Job, HashSet <FileReference> BuildProducts, Dictionary <string, HashSet <FileReference> > TagNameToFileSet)
        {
            // Get the project path, and check it exists
            FileReference ProjectFile = Parameters.Project;

            if (Parameters.Project != null && !FileReference.Exists(ProjectFile))
            {
                throw new AutomationException("Couldn't find project '{0}'", ProjectFile.FullName);
            }

            // Get the directories used for staging this project
            DirectoryReference SourceEngineDir  = CommandUtils.EngineDirectory;
            DirectoryReference SourceProjectDir = (ProjectFile == null)? SourceEngineDir : ProjectFile.Directory;

            // Get the output directories. We flatten the directory structure on output.
            DirectoryReference TargetDir        = Parameters.ToDir;
            DirectoryReference TargetEngineDir  = DirectoryReference.Combine(TargetDir, "Engine");
            DirectoryReference TargetProjectDir = DirectoryReference.Combine(TargetDir, ProjectFile.GetFileNameWithoutExtension());

            // Get the path to the receipt
            FileReference ReceiptFileName = TargetReceipt.GetDefaultPath(SourceProjectDir, Parameters.Target, Parameters.Platform, Parameters.Configuration, Parameters.Architecture);

            // Try to load it
            TargetReceipt Receipt;

            if (!TargetReceipt.TryRead(ReceiptFileName, out Receipt))
            {
                throw new AutomationException("Couldn't read receipt '{0}'", ReceiptFileName);
            }

            // Stage all the build products needed at runtime
            HashSet <FileReference> SourceFiles = new HashSet <FileReference>();

            foreach (BuildProduct BuildProduct in Receipt.BuildProducts)
            {
                SourceFiles.Add(BuildProduct.Path);
            }
            foreach (RuntimeDependency RuntimeDependency in Receipt.RuntimeDependencies.Where(x => x.Type != StagedFileType.UFS))
            {
                SourceFiles.Add(RuntimeDependency.Path);
            }

            // Get all the target files
            List <FileReference> TargetFiles = new List <FileReference>();

            foreach (FileReference SourceFile in SourceFiles)
            {
                // Get the destination file to copy to, mapping to the new engine and project directories as appropriate
                FileReference TargetFile;
                if (SourceFile.IsUnderDirectory(SourceEngineDir))
                {
                    TargetFile = FileReference.Combine(TargetEngineDir, SourceFile.MakeRelativeTo(SourceEngineDir));
                }
                else
                {
                    TargetFile = FileReference.Combine(TargetProjectDir, SourceFile.MakeRelativeTo(SourceProjectDir));
                }

                // Fixup the case of the output file. Would expect Platform.DeployLowerCaseFilenames() to return true here, but seems not to be the case.
                if (Parameters.Platform == UnrealTargetPlatform.PS4)
                {
                    TargetFile = FileReference.Combine(TargetDir, TargetFile.MakeRelativeTo(TargetDir).ToLowerInvariant());
                }

                // Only copy the output file if it doesn't already exist. We can stage multiple targets to the same output directory.
                if (Parameters.Overwrite || !FileReference.Exists(TargetFile))
                {
                    DirectoryReference.CreateDirectory(TargetFile.Directory);
                    CommandUtils.CopyFile(SourceFile.FullName, TargetFile.FullName);
                    // Force all destination files to not readonly.
                    CommandUtils.SetFileAttributes(TargetFile.FullName, ReadOnly: false);
                }

                // Add it to the list of target files
                TargetFiles.Add(TargetFile);
            }

            // Apply the optional tag to the build products
            foreach (string TagName in FindTagNamesFromList(Parameters.Tag))
            {
                FindOrAddTagSet(TagNameToFileSet, TagName).UnionWith(TargetFiles);
            }

            // Add the target file to the list of build products
            BuildProducts.UnionWith(TargetFiles);
        }
예제 #12
0
    public override void ExecuteBuild()
    {
        // Get the plugin filename
        string PluginParam = ParseParamValue("Plugin");

        if (PluginParam == null)
        {
            throw new AutomationException("Plugin file name was not specified via the -plugin argument");
        }

        // Read the plugin
        FileReference      PluginFile      = new FileReference(PluginParam);
        DirectoryReference PluginDirectory = PluginFile.Directory;
        PluginDescriptor   Plugin          = PluginDescriptor.FromFile(PluginFile);

        // Clean the intermediate build directory
        DirectoryReference IntermediateBuildDirectory = DirectoryReference.Combine(PluginDirectory, "Intermediate", "Build");

        if (CommandUtils.DirectoryExists(IntermediateBuildDirectory.FullName))
        {
            CommandUtils.DeleteDirectory(IntermediateBuildDirectory.FullName);
        }

        // Create a host project for the plugin. For script generator plugins, we need to have UHT be able to load it - and that can only happen if it's enabled in a project.
        DirectoryReference HostProjectDirectory = DirectoryReference.Combine(new DirectoryReference(CommandUtils.CmdEnv.LocalRoot), "HostProject");

        if (CommandUtils.DirectoryExists(HostProjectDirectory.FullName))
        {
            CommandUtils.DeleteDirectory(HostProjectDirectory.FullName);
        }

        DirectoryReference HostProjectPluginDirectory = DirectoryReference.Combine(HostProjectDirectory, "Plugins", PluginFile.GetFileNameWithoutExtension());

        string[] CopyPluginFiles = Directory.EnumerateFiles(PluginDirectory.FullName, "*", SearchOption.AllDirectories).ToArray();
        foreach (string CopyPluginFile in CopyPluginFiles)
        {
            CommandUtils.CopyFile(CopyPluginFile, CommandUtils.MakeRerootedFilePath(CopyPluginFile, PluginDirectory.FullName, HostProjectPluginDirectory.FullName));
        }

        FileReference HostProjectPluginFile = FileReference.Combine(HostProjectPluginDirectory, PluginFile.GetFileName());
        FileReference HostProjectFile       = FileReference.Combine(HostProjectDirectory, "HostProject.uproject");

        File.WriteAllText(HostProjectFile.FullName, "{ \"FileVersion\": 3, \"Plugins\": [ { \"Name\": \"" + PluginFile.GetFileNameWithoutExtension() + "\", \"Enabled\": true } ] }");

        // Get any additional arguments from the commandline
        string AdditionalArgs = "";

        // Build the host platforms
        List <string>        ReceiptFileNames = new List <string>();
        UnrealTargetPlatform HostPlatform     = BuildHostPlatform.Current.Platform;

        if (!ParseParam("NoHostPlatform"))
        {
            if (Plugin.bCanBeUsedWithUnrealHeaderTool)
            {
                BuildPluginWithUBT(PluginFile, Plugin, null, "UnrealHeaderTool", TargetRules.TargetType.Program, HostPlatform, UnrealTargetConfiguration.Development, ReceiptFileNames, String.Format("{0} -plugin {1}", AdditionalArgs, CommandUtils.MakePathSafeToUseWithCommandLine(HostProjectPluginFile.FullName)));
            }
            BuildPluginWithUBT(PluginFile, Plugin, HostProjectFile, "UE4Editor", TargetRules.TargetType.Editor, HostPlatform, UnrealTargetConfiguration.Development, ReceiptFileNames, AdditionalArgs);
        }

        // Add the game targets
        List <UnrealTargetPlatform> TargetPlatforms = Rocket.RocketBuild.GetTargetPlatforms(this, HostPlatform);

        foreach (UnrealTargetPlatform TargetPlatform in TargetPlatforms)
        {
            if (Rocket.RocketBuild.IsCodeTargetPlatform(HostPlatform, TargetPlatform))
            {
                BuildPluginWithUBT(PluginFile, Plugin, HostProjectFile, "UE4Game", TargetRules.TargetType.Game, TargetPlatform, UnrealTargetConfiguration.Development, ReceiptFileNames, AdditionalArgs);
                BuildPluginWithUBT(PluginFile, Plugin, HostProjectFile, "UE4Game", TargetRules.TargetType.Game, TargetPlatform, UnrealTargetConfiguration.Shipping, ReceiptFileNames, AdditionalArgs);
            }
        }

        // Package the plugin to the output folder
        string PackageDirectory = ParseParamValue("Package");

        if (PackageDirectory != null)
        {
            List <BuildProduct> BuildProducts = GetBuildProductsFromReceipts(UnrealBuildTool.UnrealBuildTool.EngineDirectory, HostProjectDirectory, ReceiptFileNames);
            PackagePlugin(HostProjectPluginFile, BuildProducts, PackageDirectory);
        }
    }