Files
UnrealEngineUWP/Engine/Source/Programs/UnrealBuildTool/Platform/HTML5/HTML5ToolChain.cs
chris babcock 016d94e747 Copying //UE4/Dev-Mobile to //UE4/Dev-Main (Source: //UE4/Dev-Mobile [at] 4355761)
#lockdown Nick.Penwarden
#rb Jack.Porter

============================
  MAJOR FEATURES & CHANGES
============================

Change 4066430 by Nick.Shin

	HTML5 - fix merge stomping and add in missing SC.Metadatadir (null) object to last {if else} block

	#jira UE-58423  HTML5 Quicklaunch through UnrealFrontEnd fails on Stage Command: Error: System.NullReferenceExeception

Change 4067037 by Bogdan.Vasilache

	#jira UE-57406

	Shaders compiled for GLSL_ES2 with CFLAG_FeatureLevelES31 compiler flag will now shift to GLSL_ES3_1_ANDROID profile instead of GLSL_310_ES_EXT.

Change 4067649 by Jack.Porter

	Remove obsolete cvars from ini files
	#jira UE-54768

Change 4071833 by Bogdan.Vasilache

	#jira UE-57406

	ShaderVersion guid updated to reflect changes in the OpenGL shader compiler.

Change 4075162 by Bogdan.Vasilache

	#jira UE-53195

Change 4099176 by Jack.Porter

	Fix SpeedTree node not working on ES3_1 (Contributed by PicaroonX)

	#jira UE-59685
	PR #4761

Change 4124398 by Mi.Wang

	Add particle cutout support for feature level es31.

Change 4129400 by Sorin.Gradinaru

	UE-60226 Web Browser widget is completely white on Android

	#jira UE-60226
	#jira UE-53247
	#Android
	#4.21

	from Release-4.20 CL 4122319

	The URL from the sample app is malformed (http:www.google.com).
	Since the phone's default browser is able to correct this problem for http and https URLs, I've added this exception to the code that checks the URL prefix, re-writing the fix for UE-53247.

Change 4164212 by Nick.Shin

	minor fixes to merge from Main

	#jira none

Change 4165606 by Nick.Shin

	#jira UE-57006  QA-Promotion WebGL1 HTML5 Launch On has numerous graphical errors

	in order for UNROLL to work -- break statement needs to be removed

Change 4165823 by Nick.Shin

	HTML5 - split single large template file to smaller component (e.g. js & css) files

	custom template files are also supported on a per-project basis:

	copy
	.../Engine/Build/HTML5/GameX.*.template
	to
	<project>/Build/HTML5/.

	build will automatically pick it the project's path (otherwise fallback to the Engine's version)

	this is based on GitHub PR #4780

	#jira UE-60136  GitHub 4780 : Proposed HTML5 Changes

Change 4202481 by Sorin.Gradinaru

	UE-50492 OnUrlChanged does not fire on mobile

	#jira UE-50492
	#iOS
	#4.21

	Adding the events for load started & finished with errors

Change 4202484 by Sorin.Gradinaru

	UEMOB-454 Move the virtual keyboard out of Experimental and make it enabled by default

	#jira UEMOB-454
	#4.21

Change 4202583 by Bogdan.Vasilache

	[UE-53816] Allow texture sampling in vertex shaders for ES2 feature level
	#jira UE-53816

Change 4214064 by Nick.Shin

	Epic's GitHub policy is to treat "unknown" file extensions as "binary"

	changing filenames so that they will show up GitHub's repo

	this is in reference to GitHub PR #4780

	#jira UE-60136  GitHub 4780 : Proposed HTML5 Changes

Change 4224514 by Mi.Wang

	We should not Tick USceneCaptureComponent on DS by default.

Change 4230192 by Nick.Shin

	HTML5 READMEs

	updating old ones - and putting new ones in

	these originally came from (mostly) onboarding the chrome team on UE4 emails.  capturing most of that in markdown format.

	#jria UEMOB-255  HTML5 Multithreading

Change 4232460 by Nick.Shin

	HTML5 - fix UE_MakeHTTPDataRequest() crash

	#jira  UE-38351  ( Pri:1 - 4.21 )  Red and Blue color channels flipped on materials called from HTML5 server

Change 4234647 by Nick.Shin

	HTML5 - ERGBFormat::RGBA  vs  ERGBFormat::BGRA

	- make use of the enums in UAsyncTaskDownloadImage::HandleImageRequest()
	- enable RGBA  vs  BGRA options for JPG decoder

	#jira  UE-38351  ( Pri:1 - 4.21 )  Red and Blue color channels flipped on materials called from HTML5 server

Change 4240086 by Sorin.Gradinaru

	UE-61345 Decals in Remote Session are not rendering on some iOS devices

	#jira UE-61345
	#4.21
	#iOS

	Changed the texture compression from DXT5 to RGBA

Change 4240234 by Sorin.Gradinaru

	UE-61838 Android 'Launch On All' can't run during an existing launch on session on Windows

	#jira UE-61838
	#4.21

	Cancel previous sessions before launching the selected configuration.

Change 4244686 by Nick.Shin

	HTML5 - syncing build scripts

	#jria UEMOB-255  HTML5 Multithreading

Change 4246399 by Nick.Shin

	HTML5 - syncing PhysX build scripts

	#jria UEMOB-255  HTML5 Multithreading

Change 4267990 by Bogdan.Vasilache

	[UEMOB-405] - Mobile PIE polishing - Bezel & Rotation + related subtasks

	#jira UEMOB-405
	#jira UEMOB-458
	#jira UEMOB-459
	#jira UEMOB-460

Change 4280211 by Chris.Babcock

	Fix FD_SET macro invoke crash when Socket FD exceed 1023 (contributed by scahp)

	#jira UE-62290
	#PR #4912
	#ue4
	#android

Change 4300275 by Nick.Shin

	HTML5 - Unreal File Server - css response header fixes

	#jira UE-63009 HTML5 template page has non-centered viewport and loading banner stretches the entire screen

Change 4302328 by Nick.Shin

	#jira UE-63108  HTML5 RunMacHTML5LauncherHelper.command files do not have appropriate permissions to run on Mac

Change 4303428 by Jack.Porter

	Fixed crash during cooking for certain landscapes with collision data out of sync with render data.

Change 4307517 by Jack.Porter

	Fix warning on Mac/Linux

	#jira UE-62993

Change 4311437 by Nick.Shin

	HTML5 : re-enabling [ -s BINARYEN_TRAP_MODE='clamp'; ]

	warning: this is technically slower performing -- but, this fixes a lot of 64-bit issues (HTML5 is "only" 32-bits)

	#jira UE-63049  HTML5 Quicklaunch to Chrome crashes with RuntimeError: float unrepresentable in integer range

Change 4312602 by Chris.Babcock

	Allow some hardware buttons through if hardware keyboard disabled

	#jira UE-63260
	#ue4
	#android

Change 4312711 by Chris.Babcock

	Fix string formatting for some locales in GetMetaDataString Method (contributed by IlinAleksey)

	#jira UE-63252
	#PR #5026
	#ue4
	#android

Change 4321719 by Bogdan.Vasilache

	UE-63378 - Fixed static analysis warnings
	#jira UE-63378

Change 4331224 by Jack.Porter

	Fixed Mobile PIE resolution for iPhone 8 Plus

	#jira UE-63191

Change 4339446 by Jack.Porter

	Modified foliage thumbnail color to better show when it is inactive
	#jira UE-30824
	#5057

Change 4339458 by Dmitriy.Dyomin

	Fixed typos in glObjectPtrLabel type definitions (contributed by TheCodez)
	#4920
	#jira UE-62368

Change 4339460 by Dmitriy.Dyomin

	Fixed: bRenderInMainPass on SkeletalMeshes doesn't work on Mobile
	#jira UE-59077

Change 4339523 by Sorin.Gradinaru

	UE-61351 Error: Failed to send -1 bytes of data to RemoteConnection spammed in the editor log when closing RemoteSession on device during connection

	#jira UE-61351
	#4.21

	Not an real issue. The message is issued whenever the host (or the client) tries to send messages through an inactive channel. There is a "/ping" message sent back and forth between the host and the client, with high frequency (hence the spam) - if this message is no longer received, the host (or the client) decides to terminate the connection.

	"Downgrading" the message from Error to Log, to avoid spamming the log on release builds.

Change 4339590 by Sorin.Gradinaru

	UE-61554 Web Browser: No Transparency in 3D Widget Component on Mobile

	#jira UE-61554
	#Android
	#4.21

	Modified Web Texture Material's blend mode to "Translucent"

Change 4339595 by Sorin.Gradinaru

	[Build] UE4 Dev-Mobile - CL 4339590 - Incremental Editor Win64

Change 4339597 by Jack.Porter

	Fix static analysis CIS
	This function should be moved to SceneUtils.h and the dependency in AsyncTaskDownloadImage resolved another way.
	#jira UE-63378

Change 4339599 by Sorin.Gradinaru

	UE-56076 Android Launch On "Running..." toast intermittently doesn't appear
	#jira UE-56076
	#Android
	#4.21

	wait before getting the process list with "adb shell ps" - on some devices the list is not yet ready

Change 4339647 by Sorin.Gradinaru

	UE-54791 Planar Reflection gamma / brightness incorrect on Samsung Galaxy S5

	#jira UE-54791
	#Android
	#4.21

	The planar texture contains encoded data:
	- decode it immediately after sampling the texture
	- alpha channel was inverted during the PrefilterPlanarReflectionPS step

Change 4339654 by Sorin.Gradinaru

	UE-59697 WebBrowser SetVisibility not working on Android & iOS

	#jira UE-59697
	#4.21
	#iOS
	#Android

	SetVisibility implemented on iOS and Android's web browsers, by extending the implementation on Windows: use a list to store references to the webbrowsers in the scene , then in WebBrowserSingleton::Tick check if the cached web browsers windows or widgets ticked on the last frame

Change 4339656 by Sorin.Gradinaru

	Remove unnecessary comment in IOSPlatformWebBrowser.cpp

Change 4339666 by Bogdan.Vasilache

	[UEMOB-455] Make editor tool to dump out a device .json file for a connected Android device
	#jira UEMOB-455

Change 4339667 by Bogdan.Vasilache

	Mobile PIE bugfixes
	#jira UE-63288
	#jira UE-63282

Change 4339700 by Bogdan.Vasilache

	[bugfix] Accidentally disabled SetPreviewPlatform() call for mobile PIE simulation.

Change 4339733 by Sorin.Gradinaru

	UE-59381 Ios application default orientation

	#jira UE-59381
	#iOS
	#4.21

	- added Initial interface orientation in the generated Plist file (UIInterfaceOrientation key)
	- implemented preferredInterfaceOrientationForPresentation in the IOSViewController
	- re-arranged the orientation list in the Plist file

Change 4339781 by Sorin.Gradinaru

	UE-60716 Show cursor in Editor text boxes when focused on Android

	#jira UE-60716
	#Android
	#4.21

	Updating the widget's cursor position from the native code.
	This also overrides the fix for UE49124 Cursor in virtual keyboard and UMG don't match - initially the solution was to hide the widget's cursor.

Change 4340037 by Jack.Porter

	Added an Android Project Settings checkbox to enable detection of Vulkan device support by default. If unchecked, the -detectvulkan command line parameter can be used.

Change 4340076 by Jack.Porter

	Fix warning seen by CIS

	#jira UE-63377

Change 4340212 by Sorin.Gradinaru

	UE-63224 Android DLC profile in Project Launcher fails if there is a space in the path for the destination directory

	#jira UE-63224
	#4.21
	#Android

	Avoid enclosing path arguments in double quotes (""<path>""). MakePathSafeToUseWithCommandLine(<path>) already adds quotes when needed.

Change 4340721 by Andrew.Grant

	Fixed -vsmac argument not working with GenerateProjectFiles

	#jira nojira

Change 4340822 by Andrew.Grant

	Replaced default iOS splashcreens with UE logo
	Added missing resolutions (iPhone 5 portrait, iPad 10.5")
	Removed custom splash images from RemoteSessionApp

	#jira UE-59864, UE-61939

Change 4340857 by Chris.Babcock

	Fix virtual keyboard crashes on Android

	#jira none

Change 4341047 by Andrew.Grant

	Prevent Xcode upgrade warnings for >9.0 versions

Change 4343797 by Cosmin.Sulea

	iOS - iPhonePackager ExportCertificate command failing 100%

Change 4343823 by Sorin.Gradinaru

	UE-63334 Unreal Remote 2 does not send information about motion control

	#jira UE-63334
	#iOS
	#Android

	The functionality was commented out. Tested it for performance and it seems OK (despite the high frequency of /motion signals)

Change 4343824 by Sorin.Gradinaru

	UEMOB-185 Implement the equivalent of FAndroidJSScripting for iOS
	UE-59488 FWebBrowserWindow::UnbindUObject of IOSPlatformWebBrowser.cpp is not implemented yet

	#jira UEMOB-185
	#jira UE-59488
	#4.21
	#iOS

	New methods (using WebKit, matching the Android implementation):
	- Go back/forward
	- HandlePageLoading (loading/didCommitNavigation, loaded/didFinishNavigation)
	- HandleReceivedError (didFailNavigation)
	- execute JS code
	- controlling the client using JS commands (WKWebViewConfiguration & WKUserContentController):
		- in Android we using shouldInterceptRequest to intercept a custom resource URL (JS: XMLHttpRequest.send, document.location)
		- iOS will register handlers (JS: window.webkit.messageHandlers.<FMobileJSScripting::JSMessageHandler>.postMessage)

Change 4343845 by Sorin.Gradinaru

	Adding the signatures for FJavaWrapper's CallLongMethod, CallFloatMethod and CallDoubleMethod in the AndroidJNI.h

	#4.21
	#Android

Change 4343893 by Cosmin.Sulea

	UEMOB-465 - Add Device Output Log support for iOS
	#jira UEMOB-465

Change 4343895 by Dmitriy.Dyomin

	Fixed: DepthFade does not work in mobile emulation while MobileMSAA enabled
	#jira UE-60404

Change 4343899 by Dmitriy.Dyomin

	GitHub 4851 : Fix layer info property bNoWeightBlend not being saved after tiled landscape import (contributed by cmp-)
	#4851
	#jira UE-61437

Change 4343906 by Bogdan.Vasilache

	Editor's feature level is now saved and restored between sessions
	#jira UE-55506
	#jira UE-59688

Change 4346729 by Jack.Porter

	Fix CIS
	#jira UE-63716

Change 4347811 by Jack.Porter

	Fix dependency chain while including PIEPreviewDeviceSpecification
	#jira UE-63755

Change 4348580 by Jack.Porter

	Fix CIS issues in IOSPlatformWebBrowser
	#jira UE-63809

Change 4350092 by Jack.Porter

	Fix null pointer exception in iPhonePackager when a matching certificate cannot be found

	#jira UE-63821

Change 4350968 by Jack.Porter

	Update binaries for deployment server
	#jira UEMOB-332

Change 4353925 by Jack.Porter

	Merging //UE4/Dev-Main to Dev-Mobile (//UE4/Dev-Mobile)
	Rework PR 4912 from CL 4280211

	#jira UE-62290

Change 4354034 by Jack.Porter

	Rebuilt deployment server after backing out changes

	#jira UE-63826

Change 4354338 by Ben.Marsh

	Attempted fix for incorrect certificate errors when compiling remotely.

	* Overloaded meaning of the -Certificate argument (ie. as the output path rather than as the desired certificate when selecting a provision) was causing certificate name check to fail. Now uses a different parameter to specify the output path.
	* TVOS argument was not being passed when exporting the certificate, also causing the wrong provision/certificate pair to be selected.
	* Add support for the -bundlename argument, though it shouldn't be necessary when invoked from UBT since the UUID discovered in a previous invocation of IPP is explicitly specified.

	Since the provision UUID is already being specified to IPP, it should be able to identify the correct provision on phase -1 using this info.

	#jira UE-63859

Change 4354459 by Chris.Babcock

	Fix issue with Android PCH include files

	#jira UE-63909
	#ue4
	#android

Change 4255761 by Peter.Sauerbrei

	fix for space in manifest name
	#jira UE-63868

#ROBOMERGE-OWNER: jason.bestimt
#ROBOMERGE-SOURCE: CL 4356719 in //UE4/Main/...
#ROBOMERGE-BOT: DEVVR (Main -> Dev-VR)

[CL 4356730 by chris babcock in Dev-VR branch]
2018-09-10 21:28:08 -04:00

547 lines
22 KiB
C#

// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Tools.DotNETCommon;
namespace UnrealBuildTool
{
class HTML5ToolChain : UEToolChain
{
// ini configurations
static bool enableSIMD = false;
static bool enableMultithreading = false;
static bool bEnableTracing = false; // Debug option
// verbose feedback
delegate void VerbosePrint(CppConfiguration Configuration, bool bOptimizeForSize); // proto
static VerbosePrint PrintOnce = new VerbosePrint(PrintOnceOn); // fn ptr
static void PrintOnceOff(CppConfiguration Configuration, bool bOptimizeForSize) {} // noop
static void PrintOnceOn(CppConfiguration Configuration, bool bOptimizeForSize)
{
if (Configuration == CppConfiguration.Debug)
Log.TraceInformation("HTML5ToolChain: " + Configuration + " -O0 faster compile time");
else if (bOptimizeForSize)
Log.TraceInformation("HTML5ToolChain: " + Configuration + " -Oz favor size over speed");
else if (Configuration == CppConfiguration.Development)
Log.TraceInformation("HTML5ToolChain: " + Configuration + " -O2 aggressive size and speed optimization");
else if (Configuration == CppConfiguration.Shipping)
Log.TraceInformation("HTML5ToolChain: " + Configuration + " -O3 favor speed over size");
PrintOnce = new VerbosePrint(PrintOnceOff); // clear
}
public HTML5ToolChain(FileReference InProjectFile)
: base(CppPlatform.HTML5)
{
if (!HTML5SDKInfo.IsSDKInstalled())
{
throw new BuildException("HTML5 SDK is not installed; cannot use toolchain.");
}
// ini configs
// - normal ConfigCache w/ UnrealBuildTool.ProjectFile takes all game config ini files
// (including project config ini files)
// - but, during packaging, if -remoteini is used -- need to use UnrealBuildTool.GetRemoteIniPath()
// (note: ConfigCache can take null ProjectFile)
string EngineIniPath = UnrealBuildTool.GetRemoteIniPath();
DirectoryReference ProjectDir = !String.IsNullOrEmpty(EngineIniPath) ? new DirectoryReference(EngineIniPath)
: DirectoryReference.FromFile(InProjectFile);
ConfigHierarchy Ini = ConfigCache.ReadHierarchy(ConfigHierarchyType.Engine, ProjectDir, UnrealTargetPlatform.HTML5);
// Ini.GetBool("/Script/HTML5PlatformEditor.HTML5TargetSettings", "EnableSIMD", out enableSIMD);
// Ini.GetBool("/Script/HTML5PlatformEditor.HTML5TargetSettings", "EnableMultithreading", out enableMultithreading);
Ini.GetBool("/Script/HTML5PlatformEditor.HTML5TargetSettings", "EnableTracing", out bEnableTracing);
// TODO: remove this "fix" when emscripten supports (SIMD & pthreads) + WASM
enableSIMD = false;
// TODO: double check Engine/Source/Runtime/Core/Private/HTML5/HTML5PlatformProcess.cpp::SupportsMultithreading()
enableMultithreading = false;
Log.TraceInformation("HTML5ToolChain: EnableSIMD = " + enableSIMD );
Log.TraceInformation("HTML5ToolChain: EnableMultithreading " + enableMultithreading );
Log.TraceInformation("HTML5ToolChain: EnableTracing = " + bEnableTracing );
PrintOnce = new VerbosePrint(PrintOnceOn); // reset
}
public static void PreBuildSync()
{
Log.TraceInformation("Setting Emscripten SDK: located in " + HTML5SDKInfo.EMSCRIPTEN_ROOT);
HTML5SDKInfo.SetupEmscriptenTemp();
HTML5SDKInfo.SetUpEmscriptenConfigFile();
if (Environment.GetEnvironmentVariable("EMSDK") == null) // If EMSDK is present, Emscripten is already configured by the developer
{
// If not using preset emsdk, configure our generated .emscripten config, instead of autogenerating one in the user's home directory.
Environment.SetEnvironmentVariable("EM_CONFIG", HTML5SDKInfo.DOT_EMSCRIPTEN);
Environment.SetEnvironmentVariable("EM_CACHE", HTML5SDKInfo.EMSCRIPTEN_CACHE);
}
}
string GetSharedArguments_Global(CppConfiguration Configuration, bool bOptimizeForSize, string Architecture, bool bEnableShadowVariableWarnings, bool bShadowVariableWarningsAsErrors, bool bEnableUndefinedIdentifierWarnings, bool bUndefinedIdentifierWarningsAsErrors, bool bUseInlining)
{
string Result = " ";
// string Result = " -Werror";
Result += " -fdiagnostics-format=msvc";
Result += " -fno-exceptions";
Result += " -Wdelete-non-virtual-dtor";
Result += " -Wno-switch"; // many unhandled cases
Result += " -Wno-tautological-constant-out-of-range-compare"; // comparisons from TCHAR being a char
Result += " -Wno-tautological-compare"; // comparison of unsigned expression < 0 is always false" (constant comparisons, which are possible with template arguments)
Result += " -Wno-tautological-undefined-compare"; // pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate
Result += " -Wno-inconsistent-missing-override"; // as of 1.35.0, overriding a member function but not marked as 'override' triggers warnings
Result += " -Wno-undefined-var-template"; // 1.36.11
Result += " -Wno-invalid-offsetof"; // using offsetof on non-POD types
Result += " -Wno-gnu-string-literal-operator-template"; // allow static FNames
// no longer needed as of UE4.18
// Result += " -Wno-array-bounds"; // some VectorLoads go past the end of the array, but it's okay in that case
if (bEnableShadowVariableWarnings)
{
Result += " -Wshadow" ;//+ (bShadowVariableWarningsAsErrors ? "" : " -Wno-error=shadow");
}
if (bEnableUndefinedIdentifierWarnings)
{
Result += " -Wundef" ;//+ (bUndefinedIdentifierWarningsAsErrors ? "" : " -Wno-error=undef");
}
// --------------------------------------------------------------------------------
if (Configuration == CppConfiguration.Debug)
{ // WARNING: UEBuildTarget.cs :: GetCppConfiguration()
Result += " -O0"; // faster compile time // DebugGame is forced to Development
} // i.e. this will never get hit...
else if (bOptimizeForSize)
{ // Engine/Source/Programs/UnrealBuildTool/HTML5/UEBuildHTML5.cs
Result += " -Oz"; // favor size over speed // bCompileForSize=true; // set false, to build -O2 or -O3
} // SOURCE BUILD ONLY
else if (Configuration == CppConfiguration.Development)
{
Result += " -O2"; // aggressive size and speed optimization
}
else if (Configuration == CppConfiguration.Shipping)
{
Result += " -O3"; // favor speed over size
}
if (!bUseInlining)
{
Result += " -fno-inline-functions";
}
PrintOnce(Configuration, bOptimizeForSize);
// --------------------------------------------------------------------------------
// JavaScript option overrides (see src/settings.js)
if (enableSIMD)
{
Result += " -msse2 -s SIMD=1";
}
if (enableMultithreading)
{
Result += " -s USE_PTHREADS=1";
}
// --------------------------------------------------------------------------------
// Expect that Emscripten SDK has been properly set up ahead in time (with emsdk and prebundled toolchains this is always the case)
// This speeds up builds a tiny bit.
Environment.SetEnvironmentVariable("EMCC_SKIP_SANITY_CHECK", "1");
// THESE ARE TEST/DEBUGGING
// Environment.SetEnvironmentVariable("EMCC_DEBUG", "1");
// Environment.SetEnvironmentVariable("EMCC_CORES", "8");
// Environment.SetEnvironmentVariable("EMCC_OPTIMIZE_NORMALLY", "1");
// Linux builds needs this - or else system clang will be attempted to be picked up instead of UE4's
// TODO: test on other platforms to remove this if() check
if (BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Linux)
{
Environment.SetEnvironmentVariable(HTML5SDKInfo.PLATFORM_USER_HOME, HTML5SDKInfo.HTML5Intermediatory);
}
return Result;
}
string GetCLArguments_Global(CppCompileEnvironment CompileEnvironment)
{
string Result = GetSharedArguments_Global(CompileEnvironment.Configuration, CompileEnvironment.bOptimizeForSize, CompileEnvironment.Architecture, CompileEnvironment.bEnableShadowVariableWarnings, CompileEnvironment.bShadowVariableWarningsAsErrors, CompileEnvironment.bEnableUndefinedIdentifierWarnings, CompileEnvironment.bUndefinedIdentifierWarningsAsErrors, CompileEnvironment.bUseInlining);
// no longer needed as of UE4.18
// Result += " -Wno-reorder"; // we disable constructor order warnings.
return Result;
}
static string GetCLArguments_CPP(CppCompileEnvironment CompileEnvironment)
{
string Result = " -std=c++14";
return Result;
}
static string GetCLArguments_C(string Architecture)
{
string Result = "";
return Result;
}
string GetLinkArguments(LinkEnvironment LinkEnvironment)
{
string Result = GetSharedArguments_Global(LinkEnvironment.Configuration, LinkEnvironment.bOptimizeForSize, LinkEnvironment.Architecture, false, false, false, false, false);
/* N.B. When editing link flags in this function, UnrealBuildTool does not seem to automatically pick them up and do an incremental
* relink only of UE4Game.js (at least when building blueprints projects). Therefore after editing, delete the old build
* outputs to force UE4 to relink:
*
* > rm Engine/Binaries/HTML5/UE4Game.js*
*/
// suppress link time warnings
// no longer needed as of UE4.18
// Result += " -Wno-parentheses"; // precedence order
// enable verbose mode
Result += " -v";
// do we want debug info?
if (LinkEnvironment.Configuration == CppConfiguration.Debug || LinkEnvironment.bCreateDebugInfo)
{
// TODO: Would like to have -g2 enabled here, but the UE4 manifest currently requires that UE4Game.js.symbols
// is always generated to the build, but that file is redundant if -g2 is passed (i.e. --emit-symbol-map gets ignored)
// so in order to enable -g2 builds, the UE4 packager should be made aware that .symbols file might not always exist.
// Result += " -g2";
// As a lightweight alternative, just retain function names in output.
Result += " --profiling-funcs";
// dump headers: http://stackoverflow.com/questions/42308/tool-to-track-include-dependencies
// Result += " -H";
}
else if (LinkEnvironment.Configuration == CppConfiguration.Development)
{
// Development builds always have their function names intact.
Result += " --profiling-funcs";
}
// Emit a .symbols map file of the minified function names. (on -g2 builds this has no effect)
Result += " --emit-symbol-map";
// if (LinkEnvironment.Configuration != CppConfiguration.Debug)
// {
// if (LinkEnvironment.bOptimizeForSize) Result += " -s OUTLINING_LIMIT=40000";
// else Result += " -s OUTLINING_LIMIT=110000";
// }
if (LinkEnvironment.Configuration == CppConfiguration.Debug || LinkEnvironment.Configuration == CppConfiguration.Development)
{
// check for alignment/etc checking
// Result += " -s SAFE_HEAP=1";
//Result += " -s CHECK_HEAP_ALIGN=1";
//Result += " -s SAFE_DYNCALLS=1";
// enable assertions in non-Shipping/Release builds
Result += " -s ASSERTIONS=1";
Result += " -s GL_ASSERTIONS=1";
// Result += " -s ASSERTIONS=2";
// Result += " -s GL_ASSERTIONS=2";
// In non-shipping builds, don't run ctol evaller, it can take a bit of extra time.
Result += " -s EVAL_CTORS=0";
// // add source map loading to code
// string source_map = Path.Combine(HTML5SDKInfo.EMSCRIPTEN_ROOT, "src", "emscripten-source-map.min.js");
// source_map = source_map.Replace("\\", "/").Replace(" ","\\ "); // use "unix path" and escape spaces
// Result += " --pre-js " + source_map;
// link in libcxxabi demangling
Result += " -s DEMANGLE_SUPPORT=1";
}
Result += " -s BINARYEN=1 -s ALLOW_MEMORY_GROWTH=1";
// Result += " -s BINARYEN_METHOD=\\'native-wasm\\'";
// Result += " -s BINARYEN_MEM_MAX=-1";
Result += " -s BINARYEN_TRAP_MODE=\\'clamp\\'";
// no need for exceptions
Result += " -s DISABLE_EXCEPTION_CATCHING=1";
// NOTE: UE-51094 UE-51267 -- always USE_WEBGL2, webgl1 only feature can be switched on the fly via url paramater "?webgl1"
// if (targetWebGL2)
{
// Enable targeting WebGL 2 when available.
Result += " -s USE_WEBGL2=1";
// Also enable WebGL 1 emulation in WebGL 2 contexts. This adds backwards compatibility related features to WebGL 2,
// such as:
// - keep supporting GL_EXT_shader_texture_lod extension in GLSLES 1.00 shaders
// - support for WebGL1 unsized internal texture formats
// - mask the GL_HALF_FLOAT_OES != GL_HALF_FLOAT mixup
Result += " -s WEBGL2_BACKWARDS_COMPATIBILITY_EMULATION=1";
// Result += " -s FULL_ES3=1";
}
// else
// {
// Result += " -s FULL_ES2=1";
// }
// The HTML page template precreates the WebGL context, so instruct the runtime to hook into that if available.
Result += " -s GL_PREINITIALIZED_CONTEXT=1";
// export console command handler. Export main func too because default exports ( e.g Main ) are overridden if we use custom exported functions.
Result += " -s EXPORTED_FUNCTIONS=\"['_main', '_on_fatal']\"";
Result += " -s NO_EXIT_RUNTIME=1";
Result += " -s ERROR_ON_UNDEFINED_SYMBOLS=1";
if (bEnableTracing)
{
Result += " --tracing";
}
Result += " -s CASE_INSENSITIVE_FS=1";
// if (enableMultithreading)
// {
// Result += " -s ASYNCIFY=1"; // alllow BLOCKING calls (i.e. sleep)
// }
return Result;
}
static string GetLibArguments(LinkEnvironment LinkEnvironment)
{
string Result = "";
return Result;
}
public void AddIncludePath(ref string Arguments, DirectoryReference IncludePath)
{
if(IncludePath.IsUnderDirectory(UnrealBuildTool.EngineDirectory))
{
Arguments += string.Format(" -I\"{0}\"", IncludePath.MakeRelativeTo(UnrealBuildTool.EngineSourceDirectory));
}
else
{
Arguments += string.Format(" -I\"{0}\"", IncludePath);
}
}
public override CPPOutput CompileCPPFiles(CppCompileEnvironment CompileEnvironment, List<FileItem> InputFiles, DirectoryReference OutputDir, string ModuleName, ActionGraph ActionGraph)
{
string Arguments = GetCLArguments_Global(CompileEnvironment);
CPPOutput Result = new CPPOutput();
// Add include paths to the argument list.
foreach (DirectoryReference IncludePath in CompileEnvironment.IncludePaths.UserIncludePaths)
{
AddIncludePath(ref Arguments, IncludePath);
}
foreach (DirectoryReference IncludePath in CompileEnvironment.IncludePaths.SystemIncludePaths)
{
AddIncludePath(ref Arguments, IncludePath);
}
// Add preprocessor definitions to the argument list.
foreach (string Definition in CompileEnvironment.Definitions)
{
Arguments += string.Format(" -D{0}", Definition);
}
if (bEnableTracing)
{
Arguments += string.Format(" -D__EMSCRIPTEN_TRACING__");
}
// Force include all the requested headers
foreach(FileItem ForceIncludeFile in CompileEnvironment.ForceIncludeFiles)
{
Arguments += String.Format(" -include \"{0}\"", ForceIncludeFile.Location);
}
foreach (FileItem SourceFile in InputFiles)
{
Action CompileAction = ActionGraph.Add(ActionType.Compile);
CompileAction.CommandDescription = "Compile";
CompileAction.PrerequisiteItems.AddRange(CompileEnvironment.ForceIncludeFiles);
// CompileAction.bPrintDebugInfo = true;
bool bIsPlainCFile = Path.GetExtension(SourceFile.AbsolutePath).ToUpperInvariant() == ".C";
// Add the C++ source file and its included files to the prerequisite item list.
AddPrerequisiteSourceFile(CompileEnvironment, SourceFile, CompileAction.PrerequisiteItems);
// Add the source file path to the command-line.
string FileArguments = string.Format(" \"{0}\"", SourceFile.AbsolutePath);
// Add the object file to the produced item list.
FileItem ObjectFile = FileItem.GetItemByFileReference(FileReference.Combine(OutputDir, Path.GetFileName(SourceFile.AbsolutePath) + ".bc"));
CompileAction.ProducedItems.Add(ObjectFile);
FileArguments += string.Format(" -o \"{0}\"", ObjectFile.AbsolutePath);
// Add C or C++ specific compiler arguments.
if (bIsPlainCFile)
{
FileArguments += GetCLArguments_C(CompileEnvironment.Architecture);
}
else
{
FileArguments += GetCLArguments_CPP(CompileEnvironment);
}
CompileAction.WorkingDirectory = UnrealBuildTool.EngineSourceDirectory.FullName;
CompileAction.CommandPath = HTML5SDKInfo.Python();
CompileAction.CommandArguments = HTML5SDKInfo.EmscriptenCompiler() + " " + Arguments + FileArguments + CompileEnvironment.AdditionalArguments;
//System.Console.WriteLine(CompileAction.CommandArguments);
CompileAction.StatusDescription = Path.GetFileName(SourceFile.AbsolutePath);
// Don't farm out creation of precomputed headers as it is the critical path task.
CompileAction.bCanExecuteRemotely = CompileEnvironment.PrecompiledHeaderAction != PrecompiledHeaderAction.Create;
// this is the final output of the compile step (a .abc file)
Result.ObjectFiles.Add(ObjectFile);
// VC++ always outputs the source file name being compiled, so we don't need to emit this ourselves
CompileAction.bShouldOutputStatusDescription = true;
// Don't farm out creation of precompiled headers as it is the critical path task.
CompileAction.bCanExecuteRemotely =
CompileEnvironment.PrecompiledHeaderAction != PrecompiledHeaderAction.Create ||
CompileEnvironment.bAllowRemotelyCompiledPCHs;
}
return Result;
}
public override CPPOutput CompileRCFiles(CppCompileEnvironment CompileEnvironment, List<FileItem> InputFiles, DirectoryReference OutputDir, ActionGraph ActionGraph)
{
CPPOutput Result = new CPPOutput();
return Result;
}
public override FileItem LinkFiles(LinkEnvironment LinkEnvironment, bool bBuildImportLibraryOnly, ActionGraph ActionGraph)
{
FileItem OutputFile;
// Make the final javascript file
Action LinkAction = ActionGraph.Add(ActionType.Link);
LinkAction.CommandDescription = "Link";
// LinkAction.bPrintDebugInfo = true;
// ResponseFile lines.
List<string> ReponseLines = new List<string>();
LinkAction.bCanExecuteRemotely = false;
LinkAction.WorkingDirectory = UnrealBuildTool.EngineSourceDirectory.FullName;
LinkAction.CommandPath = HTML5SDKInfo.Python();
LinkAction.CommandArguments = HTML5SDKInfo.EmscriptenCompiler();
// bool bIsBuildingLibrary = LinkEnvironment.bIsBuildingLibrary || bBuildImportLibraryOnly;
// ReponseLines.Add(
// bIsBuildingLibrary ?
// GetLibArguments(LinkEnvironment) :
// GetLinkArguments(LinkEnvironment)
// );
ReponseLines.Add(GetLinkArguments(LinkEnvironment));
// Add the input files to a response file, and pass the response file on the command-line.
foreach (FileItem InputFile in LinkEnvironment.InputFiles)
{
//System.Console.WriteLine("File {0} ", InputFile.AbsolutePath);
ReponseLines.Add(string.Format(" \"{0}\"", InputFile.AbsolutePath));
LinkAction.PrerequisiteItems.Add(InputFile);
}
if (!LinkEnvironment.bIsBuildingLibrary)
{
// Make sure ThirdParty libs are at the end.
List<string> ThirdParty = (from Lib in LinkEnvironment.AdditionalLibraries
where Lib.Contains("ThirdParty")
select Lib).ToList();
LinkEnvironment.AdditionalLibraries.RemoveAll(Element => Element.Contains("ThirdParty"));
LinkEnvironment.AdditionalLibraries.AddRange(ThirdParty);
foreach (string InputFile in LinkEnvironment.AdditionalLibraries)
{
FileItem Item = FileItem.GetItemByPath(InputFile);
if (Item.AbsolutePath.Contains(".lib"))
continue;
if (Item.ToString().EndsWith(".js"))
ReponseLines.Add(string.Format(" --js-library \"{0}\"", Item.AbsolutePath));
// WARNING: With --pre-js and --post-js, the order in which these directives are passed to
// the compiler is very critical, because that dictates the order in which they are appended.
//
// Set environment variable [ EMCC_DEBUG=1 ] to see the linker order used in packaging.
// See GetSharedArguments_Global() above to set this environment variable
else if (Item.ToString().EndsWith(".jspre"))
ReponseLines.Add(string.Format(" --pre-js \"{0}\"", Item.AbsolutePath));
else if (Item.ToString().EndsWith(".jspost"))
ReponseLines.Add(string.Format(" --post-js \"{0}\"", Item.AbsolutePath));
else
ReponseLines.Add(string.Format(" \"{0}\"", Item.AbsolutePath));
LinkAction.PrerequisiteItems.Add(Item);
}
}
// make the file we will create
OutputFile = FileItem.GetItemByFileReference(LinkEnvironment.OutputFilePath);
LinkAction.ProducedItems.Add(OutputFile);
ReponseLines.Add(string.Format(" -o \"{0}\"", OutputFile.AbsolutePath));
FileItem OutputBC = FileItem.GetItemByPath(LinkEnvironment.OutputFilePath.FullName.Replace(".js", ".bc").Replace(".html", ".bc"));
LinkAction.ProducedItems.Add(OutputBC);
ReponseLines.Add(string.Format(" --save-bc \"{0}\"", OutputBC.AbsolutePath));
LinkAction.StatusDescription = Path.GetFileName(OutputFile.AbsolutePath);
FileReference ResponseFileName = GetResponseFileName(LinkEnvironment, OutputFile);
FileItem ResponseFileItem = FileItem.CreateIntermediateTextFile(ResponseFileName, ReponseLines);
LinkAction.CommandArguments += string.Format(" @\"{0}\"", ResponseFileName);
LinkAction.PrerequisiteItems.Add(ResponseFileItem);
return OutputFile;
}
public override void ModifyBuildProducts(ReadOnlyTargetRules Target, UEBuildBinary Binary, List<string> Libraries, List<UEBuildBundleResource> BundleResources, Dictionary<FileReference, BuildProductType> BuildProducts)
{
// we need to include the generated .mem and .symbols file.
if (Binary.Type != UEBuildBinaryType.StaticLibrary)
{
BuildProducts.Add(Binary.OutputFilePath.ChangeExtension("wasm"), BuildProductType.RequiredResource);
BuildProducts.Add(Binary.OutputFilePath + ".symbols", BuildProductType.RequiredResource);
}
}
};
}