From d5310c3455f9849243b7b950deb4e910aa1f24dd Mon Sep 17 00:00:00 2001 From: ivey Date: Mon, 15 Jun 2020 15:54:16 -0400 Subject: Initial commit of the UGCExample Project --- Build/Scripts/EnablePluginByDefault.cs | 37 +++++++++ Build/Scripts/PackageSimpleUGCPlugin.cs | 129 ++++++++++++++++++++++++++++++ Build/Scripts/Properties/AssemblyInfo.cs | 36 +++++++++ Build/Scripts/SimpleUGC.Automation.csproj | 79 ++++++++++++++++++ 4 files changed, 281 insertions(+) create mode 100644 Build/Scripts/EnablePluginByDefault.cs create mode 100644 Build/Scripts/PackageSimpleUGCPlugin.cs create mode 100644 Build/Scripts/Properties/AssemblyInfo.cs create mode 100644 Build/Scripts/SimpleUGC.Automation.csproj (limited to 'Build/Scripts') diff --git a/Build/Scripts/EnablePluginByDefault.cs b/Build/Scripts/EnablePluginByDefault.cs new file mode 100644 index 0000000..64c25c1 --- /dev/null +++ b/Build/Scripts/EnablePluginByDefault.cs @@ -0,0 +1,37 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Threading; +using System.Reflection; +using AutomationTool; +using UnrealBuildTool; +using Tools.DotNETCommon; + +using System.Linq; +using System.Text; +using Microsoft.Win32; +using System.Diagnostics; + +namespace SimpleUGC.Automation +{ + [Help("Sets the EnabledByDefault flag for a plugin to true")] + public class EnablePluginByDefault : BuildCommand + { + 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); + } + } +} diff --git a/Build/Scripts/PackageSimpleUGCPlugin.cs b/Build/Scripts/PackageSimpleUGCPlugin.cs new file mode 100644 index 0000000..b14c5db --- /dev/null +++ b/Build/Scripts/PackageSimpleUGCPlugin.cs @@ -0,0 +1,129 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +using AutomationTool; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnrealBuildTool; +using Tools.DotNETCommon; + +using Microsoft.Win32; +using System.Diagnostics; + +namespace SimpleUGC.Automation +{ + public class PackageUGC : BuildCommand + { + static public ProjectParams GetParams(BuildCommand Cmd, string ProjectFileName, out FileReference PluginFile) + { + string VersionString = Cmd.ParseParamValue("Version", "NOVERSION"); + + // Get the plugin filename + string PluginPath = Cmd.ParseParamValue("PluginPath"); + if (PluginPath == null) + { + throw new AutomationException("Missing -PluginPath=... argument"); + } + + // Check it exists + PluginFile = new FileReference(PluginPath); + if (!FileReference.Exists(PluginFile)) + { + throw new AutomationException("Plugin '{0}' not found", PluginFile.FullName); + } + + string ReleaseVersion = Cmd.ParseParamValue("BasedOnReleaseVersion", "UGCExampleGame_v1"); + + FileReference ProjectFile = new FileReference(ProjectFileName); + + ProjectParams Params = new ProjectParams( + RawProjectPath: ProjectFile, + Command: Cmd, + ClientTargetPlatforms: new List(){ new TargetPlatformDescriptor(UnrealTargetPlatform.Win64) }, + Build: false, + Cook: true, + Stage: true, + Pak: true, + Manifests: true, + DLCIncludeEngineContent: true, // Need this to allow engine content that wasn't cooked in the base game to be included in the PAK file + BasedOnReleaseVersion: ReleaseVersion, + DLCName: PluginFile.GetFileNameWithoutAnyExtensions(), + + RunAssetNativization: true + ); + + Params.ValidateAndLog(); + return Params; + } + + 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); + } + } + } +} diff --git a/Build/Scripts/Properties/AssemblyInfo.cs b/Build/Scripts/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..67540f3 --- /dev/null +++ b/Build/Scripts/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SimpleUGC.Automation")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SimpleUGC.Automation")] +[assembly: AssemblyCopyright("Copyright 1998-2020 Epic Games")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("0C67E318-2918-47E5-91EC-043D9E042647")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Build/Scripts/SimpleUGC.Automation.csproj b/Build/Scripts/SimpleUGC.Automation.csproj new file mode 100644 index 0000000..b4fb06f --- /dev/null +++ b/Build/Scripts/SimpleUGC.Automation.csproj @@ -0,0 +1,79 @@ + + + + + Debug + AnyCPU + {5EA4677F-4A4B-4B92-9D07-33687A0C4CEA} + Library + Properties + SimpleUGC.Automation + SimpleUGC.Automation + v4.6.2 + 512 + + + + true + full + false + ..\..\..\..\..\Engine\Binaries\DotNET\AutomationScripts\ + DEBUG;TRACE + prompt + 4 + AnyCPU + true + false + + + pdbonly + false + ..\..\..\..\..\Engine\Binaries\DotNET\AutomationScripts\ + TRACE + prompt + 4 + AnyCPU + true + false + + + + + + + + + + + + + + + + + + + + + + + {2c96a7f2-b1a3-4258-8e0a-e588ff41a53e} + AutomationUtils.Automation + + + {5d7d66e8-8c76-4af9-b3ec-2ef03421d730} + DotNETUtilities + + + {8aa00d65-0954-4a27-ac0d-fb8b1106120f} + AutomationScripts.Automation + False + + + {fd7c5e1a-cfe4-4fd5-a525-1eb1599a39ac} + UnrealBuildTool + False + + + + \ No newline at end of file -- cgit v1.2.3