Ejemplo n.º 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);
    }
        public override void ExecuteBuild()
        {
            string FileName = ParseParamValue("FileName", null);

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

            CommandUtils.SetFileAttributes(FileName, ReadOnly: false);

            PluginDescriptor Plugin = PluginDescriptor.FromFile(new FileReference(FileName));

            Plugin.bEnabledByDefault = true;
            Plugin.Save(FileName);
        }
    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);
    }
Ejemplo n.º 4
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);
    }
Ejemplo n.º 5
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);
        }
    }
Ejemplo n.º 6
0
    public override void ExecuteBuild()
    {
        // Get the plugin filename
        string PluginFileName = ParseParamValue("Plugin");

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

        // Read the plugin
        PluginDescriptor Plugin = PluginDescriptor.FromFile(PluginFileName);

        // Clean the intermediate build directory
        string IntermediateBuildDirectory = Path.Combine(Path.GetDirectoryName(PluginFileName), "Intermediate", "Build");

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

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

        if (ParseParam("Rocket"))
        {
            AdditionalArgs += " -Rocket";
        }

        // Build the host platforms
        List <string> ReceiptFileNames = new List <string>();

        UE4Build.BuildAgenda Agenda       = new UE4Build.BuildAgenda();
        UnrealTargetPlatform HostPlatform = BuildHostPlatform.Current.Platform;

        if (!ParseParam("NoHostPlatform"))
        {
            AddPluginToAgenda(Agenda, PluginFileName, Plugin, "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))
            {
                AddPluginToAgenda(Agenda, PluginFileName, Plugin, "UE4Game", TargetRules.TargetType.Game, TargetPlatform, UnrealTargetConfiguration.Development, ReceiptFileNames, AdditionalArgs);
                AddPluginToAgenda(Agenda, PluginFileName, Plugin, "UE4Game", TargetRules.TargetType.Game, TargetPlatform, UnrealTargetConfiguration.Shipping, ReceiptFileNames, AdditionalArgs);
            }
        }

        // Build it
        UE4Build Build = new UE4Build(this);

        Build.Build(Agenda, InDeleteBuildProducts: true, InUpdateVersionFiles: false);

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

        if (PackageDirectory != null)
        {
            List <BuildProduct> BuildProducts = GetBuildProductsFromReceipts(ReceiptFileNames);
            PackagePlugin(PluginFileName, BuildProducts, PackageDirectory);
        }
    }
Ejemplo n.º 7
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);
            }
        }
Ejemplo n.º 8
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);
        }
    }