Files
UnrealEngineUWP/Engine/Source/Programs/UnrealBuildTool/HTML5/UEBuildHTML5.cs
Josh Adams db43da290b Copying //UE4/Dev-Platform to Dev-Main (//UE4/Dev-Main)
Change 2783376 on 2015/11/30 by Nick.Shin

	upgrading emscripten SDK to 1.35.9
	following instruction from the README file

Change 2787414 on 2015/12/02 by Nick.Shin

	upgrading emscripten to 1.35.0
	removing old SDK and tools for Mac and Win64

Change 2790218 on 2015/12/04 by Nick.Shin

	merge (CL: #2790164) from //UE4/Dev-Physics to //UE4/Dev-Platform
	PhysX HTML5 bc files

Change 2794786 on 2015/12/08 by Nick.Shin

	merge CL #2794757 part 1 of 2
	from //UE4/Dev-Physics/PhysX/PhysX_3.3/Lib/html5
	to //UE4/Dev-Platform/Engine/Source/ThirdParty/PhysX/PhysX-3.3/lib/HTML5/

Change 2794789 on 2015/12/08 by Nick.Shin

	merge CL #2794758 part 2 of 2
	from //UE4/Dev-Physics/PhysX/PhysX_3.3/Lib/html5
	to //UE4/Dev-Platform/Engine/Source/ThirdParty/PhysX/PhysX-3.3/lib/HTML5/

Change 2799151 on 2015/12/10 by Dmitry.Rekman

	Guarantee XGE.xml sorting order for 10+ builds.

	- A licensee pointed out the problem that AutomationTool.UE4Build.FindXGEFiles() sorts the files by filename, so e.g. UBTExport.10.xge.xml takes priority over UBTExport.2.xge.xml.

	#codereview Ben.Marsh

Change 2799440 on 2015/12/11 by Mark.Satterthwaite

	Duplicate CL #2790251: Temporarily revert some of the changes for Mac mouse cursor locking as they were causing more problems than they solved.

Change 2799441 on 2015/12/11 by Mark.Satterthwaite

	Duplicate CL #2796111 & #2796158: Fix cooking shader cache files - it wasn't being enabled despite a cached shader format being listed.

Change 2799442 on 2015/12/11 by Mark.Satterthwaite

	Duplicate CL #2797758: Defer calls to AUGraphUpdate into FCoreAudioDevice::UpdateHardware - this call will synchronise the calling thread with the CoreAudio thread/run-loop so that the CoreAudio graph is safe to modify and this may incur a significant stall. This means it is far more efficient to amortise the cost of all changes to the graph with a single call. To ensure correctness the audio format conversion components are cached and disposed of after the call to AUGraphUpdate so that any existing operations on the CoreAudio thread are completed prior to disposal.

Change 2799601 on 2015/12/11 by Mark.Satterthwaite

	Implement background reading of NSPipe's in Mac ExecProcess to avoid the sub-process blocking trying to write to the meagre 8kb internal buffers. This may fix problems with SVN on Mac.

Change 2799657 on 2015/12/11 by Mark.Satterthwaite

	Remove the hlslcc major version from the Metal and OpenGL shader formats to ensure that there are enough bits to represent the different version components. There's no expectation that the major version of hlslcc will change and it will soon be removed entirely.

Change 2799691 on 2015/12/11 by Mark.Satterthwaite

	Merging final internal-only changes from WWDC.

Change 2800182 on 2015/12/11 by Mark.Satterthwaite

	Capture the system.log contents from the moment we boot to the point we crash to report GPU restarts and other system errors not written into our own logs.

Change 2801395 on 2015/12/14 by Mark.Satterthwaite

	Fix the Metal shader compiler so that it properly reports the number of sampler objects in use, not the number of textures as Metal separates its 16 samplers and up-to 128 textures in a single shader stage, like D3D and unlike OpenGL. This fixes a lot of material compile errors in newer projects which aren't being designed for obsolete OpenGL.

Change 2801653 on 2015/12/14 by Daniel.Lamb

	Load package differ can now diff header part of packages.
	Changed the way IsChildCooker is handled improves performance of multiprocess cooker.

Change 2801655 on 2015/12/14 by Daniel.Lamb

	Added cooker warning to resave packages if they don't have collision data for their static meshes.
	Added NavCollision creation on static mesh import so that we save out the NavCollision.

Change 2801923 on 2015/12/14 by Daniel.Lamb

	Fix compilation error with CreateLoader.

Change 2802076 on 2015/12/14 by Daniel.Lamb

	Remove some debugging assistance code.

Change 2803207 on 2015/12/15 by Mark.Satterthwaite

	Add missing Metal formats for PF_R16_SINT/UINT.

Change 2803254 on 2015/12/15 by Mark.Satterthwaite

	Add additional uint/2/3/4 overrides for SV_Target(x) to MetalUtils and when generating the output variable look for an exact type match before restoring to the first match with the correct number of elements. This ensures that we generate uint/2/3/4 writes when required for CopyStencilToLightingChannelsPS without breaking anything else.

Change 2803259 on 2015/12/15 by Mark.Satterthwaite

	Fix stencil texture swizzle for Metal which uses .x not .g for stencil value.

Change 2803262 on 2015/12/15 by Mark.Satterthwaite

	Fix FMetalRHICommandContext::RHISetScissorRect  handling 0 sized rects when RHISetScissorRect is called before RHISetViewport.

Change 2803321 on 2015/12/15 by Mark.Satterthwaite

	Duplicate CL #2786291: Fix Metal validation errors caused by incorrect instance count and also a crash-bug caused by accessing a defunct depth-stencil texture. This should be enough to ensure Metal works even if you've been playing previously with OpenGL.

Change 2803413 on 2015/12/15 by Mark.Satterthwaite

	Workaround the Material Editor's unfortunate habit of rendering tiles without a depth/stencil-buffer attached despite tiles wanting to write to depth - in Metal we have to create a temporary Depth-Stencil texture so that we don't crash the driver because it won't rewrite the shaders for us (unlike D3D/GL).

Change 2806247 on 2015/12/16 by Daniel.Lamb

	Fixed UParticleRequiredModule deterministic cook issue.
	#codereview Olaf.Piesche

Change 2806834 on 2015/12/17 by Mark.Satterthwaite

	Temporarily work around absence of Checked & Shipping APEX/PhysX binaries on Mac.

Change 2807017 on 2015/12/17 by Mark.Satterthwaite

	Handle the shader cache being initialised for cooking multiple times until I can sort out the implementation properly.

Change 2807027 on 2015/12/17 by Daniel.Lamb

	Enabled DDC stats.
2016-01-19 09:54:25 -05:00

426 lines
14 KiB
C#

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.IO;
namespace UnrealBuildTool
{
class HTML5PlatformContext : UEBuildPlatformContext
{
public HTML5PlatformContext(FileReference InProjectFile) : base(UnrealTargetPlatform.HTML5, InProjectFile)
{
}
// The current architecture - affects everything about how UBT operates on HTML5
public override string GetActiveArchitecture()
{
// by default, use an empty architecture (which is really just a modifier to the platform for some paths/names)
return HTML5Platform.HTML5Architecture;
}
/// <summary>
/// Modify the rules for a newly created module, in a target that's being built for this platform.
/// This is not required - but allows for hiding details of a particular platform.
/// </summary>
/// <param name="ModuleName">The name of the module</param>
/// <param name="Rules">The module rules</param>
/// <param name="Target">The target being build</param>
public override void ModifyModuleRulesForActivePlatform(string ModuleName, ModuleRules Rules, TargetInfo Target)
{
if (ModuleName == "Core")
{
Rules.PublicIncludePaths.Add("Runtime/Core/Public/HTML5");
Rules.PublicDependencyModuleNames.Add("zlib");
}
else if (ModuleName == "Engine")
{
Rules.PrivateDependencyModuleNames.Add("zlib");
Rules.PrivateDependencyModuleNames.Add("UElibPNG");
Rules.PublicDependencyModuleNames.Add("UEOgg");
Rules.PublicDependencyModuleNames.Add("Vorbis");
}
}
/// <summary>
/// Gives the platform a chance to 'override' the configuration settings
/// that are overridden on calls to RunUBT.
/// </summary>
/// <param name="Configuration"> The UnrealTargetConfiguration being built</param>
/// <returns>bool true if debug info should be generated, false if not</returns>
public override void ResetBuildConfiguration(UnrealTargetConfiguration Configuration)
{
ValidateUEBuildConfiguration();
}
/// <summary>
/// Validate the UEBuildConfiguration for this platform
/// This is called BEFORE calling UEBuildConfiguration to allow setting
/// various fields used in that function such as CompileLeanAndMean...
/// </summary>
public override void ValidateUEBuildConfiguration()
{
UEBuildConfiguration.bCompileLeanAndMeanUE = true;
UEBuildConfiguration.bCompileAPEX = false;
UEBuildConfiguration.bCompilePhysX = true;
UEBuildConfiguration.bRuntimePhysicsCooking = false;
UEBuildConfiguration.bCompileSimplygon = false;
UEBuildConfiguration.bCompileForSize = true;
}
/// <summary>
/// Setup the target environment for building
/// </summary>
/// <param name="InBuildTarget"> The target being built</param>
public override void SetUpEnvironment(UEBuildTarget InBuildTarget)
{
if (GetActiveArchitecture() == "-win32")
InBuildTarget.GlobalLinkEnvironment.Config.ExcludedLibraries.Add("LIBCMT");
InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("PLATFORM_HTML5=1");
if (InBuildTarget.GlobalCompileEnvironment.Config.Target.Architecture == "-win32")
{
InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("PLATFORM_HTML5_WIN32=1");
InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("delayimp.lib");
}
else
{
InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("PLATFORM_HTML5_BROWSER=1");
}
// @todo needed?
InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("UNICODE");
InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("_UNICODE");
InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("WITH_AUTOMATION_WORKER=0");
InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("REQUIRES_ALIGNED_INT_ACCESS");
InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("WITH_OGGVORBIS=1");
InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("USE_SCENE_LOCK=0");
BuildConfiguration.bDeployAfterCompile = true;
}
/// <summary>
/// Whether this platform should create debug information or not
/// </summary>
/// <param name="Configuration">The UnrealTargetConfiguration being built</param>
/// <returns>true if debug info should be generated, false if not</returns>
public override bool ShouldCreateDebugInfo(UnrealTargetConfiguration Configuration)
{
switch (Configuration)
{
case UnrealTargetConfiguration.Development:
case UnrealTargetConfiguration.Shipping:
case UnrealTargetConfiguration.Test:
return !BuildConfiguration.bOmitPCDebugInfoInDevelopment;
case UnrealTargetConfiguration.Debug:
default:
// We don't need debug info for Emscripten, and it causes a bunch of issues with linking
return true;
};
}
/// <summary>
/// Creates a toolchain instance for the given platform.
/// </summary>
/// <param name="Platform">The platform to create a toolchain for</param>
/// <returns>New toolchain instance.</returns>
public override UEToolChain CreateToolChain(CPPTargetPlatform Platform)
{
return new HTML5ToolChain();
}
/// <summary>
/// Create a build deployment handler
/// </summary>
/// <param name="ProjectFile">The project file of the target being deployed. Used to find any deployment specific settings.</param>
/// <param name="DeploymentHandler">The output deployment handler</param>
/// <returns>True if the platform requires a deployment handler, false otherwise</returns>
public override UEBuildDeploy CreateDeploymentHandler()
{
return null;
}
}
class HTML5Platform : UEBuildPlatform
{
// use -win32 for win32 builds. ( build html5 platform as a win32 binary for debugging )
[XmlConfig]
public static string HTML5Architecture = "";
HTML5PlatformSDK SDK;
public HTML5Platform(HTML5PlatformSDK InSDK) : base(UnrealTargetPlatform.HTML5, CPPTargetPlatform.HTML5)
{
SDK = InSDK;
}
/// <summary>
/// Whether the required external SDKs are installed for this platform. Could be either a manual install or an AutoSDK.
/// </summary>
public override SDKStatus HasRequiredSDKsInstalled()
{
return SDK.HasRequiredSDKsInstalled();
}
// F5 should always try to run the Win32 version
public override FileReference ModifyNMakeOutput(FileReference ExeName)
{
// nmake Run should always run the win32 version
return (ExeName + "-win32").ChangeExtension(".exe");
}
public override bool CanUseXGE()
{
return (HTML5Architecture == "-win32");
}
/// <summary>
/// Get the extension to use for the given binary type
/// </summary>
/// <param name="InBinaryType"> The binary type being built</param>
/// <returns>string The binary extension (ie 'exe' or 'dll')</returns>
public override string GetBinaryExtension(UEBuildBinaryType InBinaryType)
{
if (HTML5Architecture == "-win32")
{
switch (InBinaryType)
{
case UEBuildBinaryType.DynamicLinkLibrary:
return ".dll";
case UEBuildBinaryType.Executable:
return ".exe";
case UEBuildBinaryType.StaticLibrary:
return ".lib";
case UEBuildBinaryType.Object:
return ".o";
case UEBuildBinaryType.PrecompiledHeader:
return ".gch";
}
return base.GetBinaryExtension(InBinaryType);
}
else
{
switch (InBinaryType)
{
case UEBuildBinaryType.DynamicLinkLibrary:
return ".js";
case UEBuildBinaryType.Executable:
return ".js";
case UEBuildBinaryType.StaticLibrary:
return ".bc";
case UEBuildBinaryType.Object:
return ".bc";
case UEBuildBinaryType.PrecompiledHeader:
return ".gch";
}
return base.GetBinaryExtension(InBinaryType);
}
}
/// <summary>
/// Get the extension to use for debug info for the given binary type
/// </summary>
/// <param name="InBinaryType"> The binary type being built</param>
/// <returns>string The debug info extension (i.e. 'pdb')</returns>
public override string GetDebugInfoExtension(UEBuildBinaryType InBinaryType)
{
if (HTML5Architecture == "-win32")
{
switch (InBinaryType)
{
case UEBuildBinaryType.DynamicLinkLibrary:
return ".pdb";
case UEBuildBinaryType.Executable:
return ".pdb";
}
return "";
}
else
{
return "";
}
}
/// <summary>
/// Whether this platform should build a monolithic binary
/// </summary>
public override bool ShouldCompileMonolithicBinary(UnrealTargetPlatform InPlatform)
{
// This platform currently always compiles monolithic
return true;
}
/// <summary>
/// Whether PDB files should be used
/// </summary>
/// <param name="InPlatform"> The CPPTargetPlatform being built</param>
/// <param name="InConfiguration"> The CPPTargetConfiguration being built</param>
/// <param name="bInCreateDebugInfo">true if debug info is getting create, false if not</param>
/// <returns>bool true if PDB files should be used, false if not</returns>
public override bool ShouldUsePDBFiles(CPPTargetPlatform Platform, CPPTargetConfiguration Configuration, bool bCreateDebugInfo)
{
return bCreateDebugInfo;
}
/// <summary>
/// Whether PCH files should be used
/// </summary>
/// <param name="InPlatform"> The CPPTargetPlatform being built</param>
/// <param name="InConfiguration"> The CPPTargetConfiguration being built</param>
/// <returns>bool true if PCH files should be used, false if not</returns>
public override bool ShouldUsePCHFiles(CPPTargetPlatform Platform, CPPTargetConfiguration Configuration)
{
return false;
}
/// <summary>
/// Whether the editor should be built for this platform or not
/// </summary>
/// <param name="InPlatform"> The UnrealTargetPlatform being built</param>
/// <param name="InConfiguration">The UnrealTargetConfiguration being built</param>
/// <returns>bool true if the editor should be built, false if not</returns>
public override bool ShouldNotBuildEditor(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration)
{
return true;
}
public override bool BuildRequiresCookedData(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration)
{
return true;
}
/// <summary>
/// Modify the rules for a newly created module, where the target is a different host platform.
/// This is not required - but allows for hiding details of a particular platform.
/// </summary>
/// <param name="ModuleName">The name of the module</param>
/// <param name="Rules">The module rules</param>
/// <param name="Target">The target being build</param>
public override void ModifyModuleRulesForOtherPlatform(string ModuleName, ModuleRules Rules, TargetInfo Target)
{
if (Target.Platform == UnrealTargetPlatform.Win32 || Target.Platform == UnrealTargetPlatform.Win64 || Target.Platform == UnrealTargetPlatform.Mac)
{
// allow standalone tools to use targetplatform modules, without needing Engine
if ((!UEBuildConfiguration.bBuildRequiresCookedData
&& ModuleName == "Engine"
&& UEBuildConfiguration.bBuildDeveloperTools)
|| (UEBuildConfiguration.bForceBuildTargetPlatforms && ModuleName == "TargetPlatform"))
{
Rules.PlatformSpecificDynamicallyLoadedModuleNames.Add("HTML5TargetPlatform");
}
}
}
/// <summary>
/// Creates a context for the given project on the current platform.
/// </summary>
/// <param name="ProjectFile">The project file for the current target</param>
/// <returns>New platform context object</returns>
public override UEBuildPlatformContext CreateContext(FileReference ProjectFile)
{
return new HTML5PlatformContext(ProjectFile);
}
}
class HTML5PlatformSDK : UEBuildPlatformSDK
{
/// <summary>
/// Whether platform supports switching SDKs during runtime
/// </summary>
/// <returns>true if supports</returns>
protected override bool PlatformSupportsAutoSDKs()
{
return true;
}
// platforms can choose if they prefer a correct the the AutoSDK install over the manual install.
protected override bool PreferAutoSDK()
{
return false;
}
public override string GetSDKTargetPlatformName()
{
return "HTML5";
}
/// <summary>
/// Returns SDK string as required by the platform
/// </summary>
/// <returns>Valid SDK string</returns>
protected override string GetRequiredSDKString()
{
return HTML5SDKInfo.EmscriptenVersion();
}
protected override String GetRequiredScriptVersionString()
{
return "3.0";
}
/// <summary>
/// Whether the required external SDKs are installed for this platform
/// </summary>
protected override SDKStatus HasRequiredManualSDKInternal()
{
if (!HTML5SDKInfo.IsSDKInstalled())
{
return SDKStatus.Invalid;
}
return SDKStatus.Valid;
}
}
class HTML5PlatformFactory : UEBuildPlatformFactory
{
protected override UnrealTargetPlatform TargetPlatform
{
get { return UnrealTargetPlatform.HTML5; }
}
/// <summary>
/// Register the platform with the UEBuildPlatform class
/// </summary>
protected override void RegisterBuildPlatforms()
{
HTML5PlatformSDK SDK = new HTML5PlatformSDK();
SDK.ManageAndValidateSDK();
// Make sure the SDK is installed
if ((ProjectFileGenerator.bGenerateProjectFiles == true) || (SDK.HasRequiredSDKsInstalled() == SDKStatus.Valid))
{
bool bRegisterBuildPlatform = true;
// make sure we have the HTML5 files; if not, then this user doesn't really have HTML5 access/files, no need to compile HTML5!
string EngineSourcePath = Path.Combine(ProjectFileGenerator.EngineRelativePath, "Source");
string HTML5TargetPlatformFile = Path.Combine(EngineSourcePath, "Developer", "HTML5", "HTML5TargetPlatform", "HTML5TargetPlatform.Build.cs");
if ((File.Exists(HTML5TargetPlatformFile) == false))
{
bRegisterBuildPlatform = false;
Log.TraceWarning("Missing required components (.... HTML5TargetPlatformFile, others here...). Check source control filtering, or try resyncing.");
}
if (bRegisterBuildPlatform == true)
{
// Register this build platform for HTML5
Log.TraceVerbose(" Registering for {0}", UnrealTargetPlatform.HTML5.ToString());
UEBuildPlatform.RegisterBuildPlatform(new HTML5Platform(SDK));
if (HTML5Platform.HTML5Architecture == "-win32")
{
UEBuildPlatform.RegisterPlatformWithGroup(UnrealTargetPlatform.HTML5, UnrealPlatformGroup.Simulator);
}
else
{
UEBuildPlatform.RegisterPlatformWithGroup(UnrealTargetPlatform.HTML5, UnrealPlatformGroup.Device);
}
}
}
}
}
}