Esempio n. 1
0
    void StageBootstrapExecutable(DeploymentContext SC, string ExeName, FileReference TargetFile, StagedFileReference StagedRelativeTargetPath, string StagedArguments)
    {
        FileReference InputFile = FileReference.Combine(SC.LocalRoot, "Engine", "Binaries", SC.PlatformDir, String.Format("BootstrapPackagedGame-{0}-Shipping.exe", SC.PlatformDir));

        if (FileReference.Exists(InputFile))
        {
            // Create the new bootstrap program
            DirectoryReference IntermediateDir = DirectoryReference.Combine(SC.ProjectRoot, "Intermediate", "Staging");
            DirectoryReference.CreateDirectory(IntermediateDir);

            FileReference IntermediateFile = FileReference.Combine(IntermediateDir, ExeName);
            CommandUtils.CopyFile(InputFile.FullName, IntermediateFile.FullName);
            CommandUtils.SetFileAttributes(IntermediateFile.FullName, 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 (FileReference.Exists(FileReference.Combine(SC.ProjectRoot, "Build/Windows/Application.ico")))
                {
                    GroupIcon = GroupIconResource.FromIco(FileReference.Combine(SC.ProjectRoot, "Build/Windows/Application.ico").FullName);
                }
                if (GroupIcon == null)
                {
                    GroupIcon = GroupIconResource.FromExe(TargetFile.FullName);
                }

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

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

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

            // Copy it to the staging directory
            SC.StageFile(StagedFileType.SystemNonUFS, IntermediateFile, new StagedFileReference(ExeName));
        }
    }