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);
            }
        }
    }
Пример #2
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);
    }
Пример #3
0
        public override void ExecuteBuild()
        {
            int           WorkingCL       = -1;
            FileReference PluginFile      = null;
            string        ProjectFileName = ParseParamValue("Project");

            if (ProjectFileName == null)
            {
                ProjectFileName = CombinePaths(CmdEnv.LocalRoot, "SimpleGame", "SimpleGame.uproject");
            }
            LogInformation(ProjectFileName);

            ProjectParams Params = GetParams(this, ProjectFileName, out PluginFile);

            // Check whether folder already exists so we know if we can delete it later
            string PlatformStageDir     = Path.Combine(Params.StageDirectoryParam, "WindowsNoEditor");
            bool   bPreExistingStageDir = Directory.Exists(PlatformStageDir);

            PluginDescriptor Plugin = PluginDescriptor.FromFile(PluginFile);

            FileReference ProjectFile = new FileReference(ProjectFileName);

            // Add Plugin to folders excluded for nativization in config file
            FileReference UserEditorIni             = new FileReference(Path.Combine(Path.GetDirectoryName(ProjectFileName), "Config", "UserEditor.ini"));
            bool          bPreExistingUserEditorIni = FileReference.Exists(UserEditorIni);

            if (!bPreExistingUserEditorIni)
            {
                // Expect this most of the time so we will create and clean up afterwards
                DirectoryReference.CreateDirectory(UserEditorIni.Directory);
                CommandUtils.WriteAllText(UserEditorIni.FullName, "");
            }

            const string ConfigSection = "BlueprintNativizationSettings";
            const string ConfigKey     = "ExcludedFolderPaths";
            string       ConfigValue   = "/" + PluginFile.GetFileNameWithoutAnyExtensions() + "/";

            ConfigFile        UserEditorConfig = new ConfigFile(UserEditorIni);
            ConfigFileSection BPNSection       = UserEditorConfig.FindOrAddSection(ConfigSection);
            bool bUpdateConfigFile             = !BPNSection.Lines.Exists(x => String.Equals(x.Key, ConfigKey, StringComparison.OrdinalIgnoreCase) && String.Equals(x.Value, ConfigValue, StringComparison.OrdinalIgnoreCase));

            if (bUpdateConfigFile)
            {
                BPNSection.Lines.Add(new ConfigLine(ConfigLineAction.Add, ConfigKey, ConfigValue));
                UserEditorConfig.Write(UserEditorIni);
            }

            Project.Cook(Params);
            if (!bPreExistingUserEditorIni)
            {
                FileReference.Delete(UserEditorIni);
            }

            Project.CopyBuildToStagingDirectory(Params);
            Project.Package(Params, WorkingCL);
            Project.Archive(Params);
            Project.Deploy(Params);

            // Get path to where the plugin was staged
            string StagedPluginDir = Path.Combine(PlatformStageDir, Path.GetFileNameWithoutExtension(ProjectFileName), PluginFile.Directory.MakeRelativeTo(ProjectFile.Directory));
            string ZipFile         = Path.Combine(Params.StageDirectoryParam, PluginFile.GetFileNameWithoutAnyExtensions());

            CommandUtils.DeleteFile(ZipFile);
            System.IO.Compression.ZipFile.CreateFromDirectory(StagedPluginDir, ZipFile + ".zip");

            if (!bPreExistingStageDir)
            {
                CommandUtils.DeleteDirectory(PlatformStageDir);
            }
        }