diff options
| author | ivey <[email protected]> | 2020-06-15 15:54:16 -0400 |
|---|---|---|
| committer | ivey <[email protected]> | 2020-06-15 15:54:16 -0400 |
| commit | d5310c3455f9849243b7b950deb4e910aa1f24dd (patch) | |
| tree | 994a81eec10538d2a1efd9ed78469a249ff086f2 /Build/Scripts | |
| parent | Updated image paths. (diff) | |
| download | ugcexample-d5310c3455f9849243b7b950deb4e910aa1f24dd.tar.xz ugcexample-d5310c3455f9849243b7b950deb4e910aa1f24dd.zip | |
Initial commit of the UGCExample Project
Diffstat (limited to 'Build/Scripts')
| -rw-r--r-- | Build/Scripts/EnablePluginByDefault.cs | 37 | ||||
| -rw-r--r-- | Build/Scripts/PackageSimpleUGCPlugin.cs | 129 | ||||
| -rw-r--r-- | Build/Scripts/Properties/AssemblyInfo.cs | 36 | ||||
| -rw-r--r-- | Build/Scripts/SimpleUGC.Automation.csproj | 79 |
4 files changed, 281 insertions, 0 deletions
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<TargetPlatformDescriptor>(){ 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="SimpleUGC.Automation.csproj.props" Condition="Exists('SimpleUGC.Automation.csproj.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{5EA4677F-4A4B-4B92-9D07-33687A0C4CEA}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>SimpleUGC.Automation</RootNamespace> + <AssemblyName>SimpleUGC.Automation</AssemblyName> + <TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <TargetFrameworkProfile /> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>..\..\..\..\..\Engine\Binaries\DotNET\AutomationScripts\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <PlatformTarget>AnyCPU</PlatformTarget> + <TreatWarningsAsErrors>true</TreatWarningsAsErrors> + <Prefer32Bit>false</Prefer32Bit> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Development|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>false</Optimize> + <OutputPath>..\..\..\..\..\Engine\Binaries\DotNET\AutomationScripts\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <PlatformTarget>AnyCPU</PlatformTarget> + <TreatWarningsAsErrors>true</TreatWarningsAsErrors> + <Prefer32Bit>false</Prefer32Bit> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Core" /> + <Reference Include="System.IO.Compression.FileSystem" /> + <Reference Include="System.Net.Http" /> + <Reference Include="System.Runtime.Serialization" /> + <Reference Include="System.Web" /> + <Reference Include="System.Web.Extensions" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="EnablePluginByDefault.cs" /> + <Compile Include="PackageSimpleUGCPlugin.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="$(EngineDir)\Source\Programs\AutomationTool\AutomationUtils\AutomationUtils.Automation.csproj"> + <Project>{2c96a7f2-b1a3-4258-8e0a-e588ff41a53e}</Project> + <Name>AutomationUtils.Automation</Name> + </ProjectReference> + <ProjectReference Include="$(EngineDir)\Source\Programs\DotNETCommon\DotNETUtilities\DotNETUtilities.csproj"> + <Project>{5d7d66e8-8c76-4af9-b3ec-2ef03421d730}</Project> + <Name>DotNETUtilities</Name> + </ProjectReference> + <ProjectReference Include="$(EngineDir)\Source\Programs\AutomationTool\Scripts\AutomationScripts.Automation.csproj"> + <Project>{8aa00d65-0954-4a27-ac0d-fb8b1106120f}</Project> + <Name>AutomationScripts.Automation</Name> + <Private>False</Private> + </ProjectReference> + <ProjectReference Include="$(EngineDir)\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj"> + <Project>{fd7c5e1a-cfe4-4fd5-a525-1eb1599a39ac}</Project> + <Name>UnrealBuildTool</Name> + <Private>False</Private> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> +</Project>
\ No newline at end of file |