Files
UnrealEngineUWP/Engine/Source/Programs/UnrealBuildTool/Android/UEBuildAndroid.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

543 lines
20 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;
using System.Xml;
using System.Linq;
namespace UnrealBuildTool
{
class AndroidPlatformContext : UEBuildPlatformContext
{
public AndroidPlatformContext(FileReference InProjectFile) : base(UnrealTargetPlatform.Android, InProjectFile)
{
}
// The current architecture - affects everything about how UBT operates on Android
public override string GetActiveArchitecture()
{
// internal architectures are handled inside the toolchain to be able to build all at once, so we no longer need an architecture here
return base.GetActiveArchitecture();
}
public override void AddExtraModules(TargetInfo Target, List<string> PlatformExtraModules)
{
}
/// <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)
{
}
public override void ResetBuildConfiguration(UnrealTargetConfiguration Configuration)
{
ValidateUEBuildConfiguration();
//BuildConfiguration.bDeployAfterCompile = true;
}
public override void ValidateUEBuildConfiguration()
{
BuildConfiguration.bUseUnityBuild = true;
UEBuildConfiguration.bCompileLeanAndMeanUE = true;
UEBuildConfiguration.bCompilePhysX = true;
UEBuildConfiguration.bCompileAPEX = false;
UEBuildConfiguration.bRuntimePhysicsCooking = false;
UEBuildConfiguration.bBuildEditor = false;
UEBuildConfiguration.bBuildDeveloperTools = false;
UEBuildConfiguration.bCompileSimplygon = false;
UEBuildConfiguration.bCompileRecast = true;
// Don't stop compilation at first error...
BuildConfiguration.bStopXGECompilationAfterErrors = true;
BuildConfiguration.bUseSharedPCHs = false;
}
public override void SetUpEnvironment(UEBuildTarget InBuildTarget)
{
// we want gcc toolchain 4.9, but fall back to 4.8 or 4.6 for now if it doesn't exist
string NDKPath = Environment.GetEnvironmentVariable("NDKROOT");
NDKPath = NDKPath.Replace("\"", "");
AndroidToolChain ToolChain = new AndroidToolChain(InBuildTarget.ProjectFile);
string GccVersion = "4.6";
int NDKVersionInt = ToolChain.GetNdkApiLevelInt();
if (Directory.Exists(Path.Combine(NDKPath, @"sources/cxx-stl/gnu-libstdc++/4.8")))
{
GccVersion = "4.8";
}
// only use 4.9 if NDK version > 19
if (NDKVersionInt > 19 && Directory.Exists(Path.Combine(NDKPath, @"sources/cxx-stl/gnu-libstdc++/4.9")))
{
GccVersion = "4.9";
}
Log.TraceInformation("NDK version: {0}, GccVersion: {1}", NDKVersionInt.ToString(), GccVersion);
InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("PLATFORM_DESKTOP=0");
InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("PLATFORM_CAN_SUPPORT_EDITORONLY_DATA=0");
InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("WITH_OGGVORBIS=1");
InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("UNICODE");
InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("_UNICODE");
InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("PLATFORM_ANDROID=1");
InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("ANDROID=1");
InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("WITH_DATABASE_SUPPORT=0");
InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("WITH_EDITOR=0");
InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("USE_NULL_RHI=0");
InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("REQUIRES_ALIGNED_INT_ACCESS");
InBuildTarget.GlobalCompileEnvironment.Config.CPPIncludeInfo.SystemIncludePaths.Add("$(NDKROOT)/sources/cxx-stl/gnu-libstdc++/" + GccVersion + "/include");
// the toolchain will actually filter these out
InBuildTarget.GlobalCompileEnvironment.Config.CPPIncludeInfo.SystemIncludePaths.Add("$(NDKROOT)/sources/cxx-stl/gnu-libstdc++/" + GccVersion + "/libs/armeabi-v7a/include");
InBuildTarget.GlobalCompileEnvironment.Config.CPPIncludeInfo.SystemIncludePaths.Add("$(NDKROOT)/sources/cxx-stl/gnu-libstdc++/" + GccVersion + "/libs/arm64-v8a/include");
InBuildTarget.GlobalCompileEnvironment.Config.CPPIncludeInfo.SystemIncludePaths.Add("$(NDKROOT)/sources/cxx-stl/gnu-libstdc++/" + GccVersion + "/libs/x86/include");
InBuildTarget.GlobalCompileEnvironment.Config.CPPIncludeInfo.SystemIncludePaths.Add("$(NDKROOT)/sources/cxx-stl/gnu-libstdc++/" + GccVersion + "/libs/x86_64/include");
InBuildTarget.GlobalLinkEnvironment.Config.LibraryPaths.Add("$(NDKROOT)/sources/cxx-stl/gnu-libstdc++/" + GccVersion + "/libs/armeabi-v7a");
InBuildTarget.GlobalLinkEnvironment.Config.LibraryPaths.Add("$(NDKROOT)/sources/cxx-stl/gnu-libstdc++/" + GccVersion + "/libs/arm64-v8a");
InBuildTarget.GlobalLinkEnvironment.Config.LibraryPaths.Add("$(NDKROOT)/sources/cxx-stl/gnu-libstdc++/" + GccVersion + "/libs/x86");
InBuildTarget.GlobalLinkEnvironment.Config.LibraryPaths.Add("$(NDKROOT)/sources/cxx-stl/gnu-libstdc++/" + GccVersion + "/libs/x86_64");
InBuildTarget.GlobalCompileEnvironment.Config.CPPIncludeInfo.SystemIncludePaths.Add("$(NDKROOT)/sources/android/native_app_glue");
InBuildTarget.GlobalCompileEnvironment.Config.CPPIncludeInfo.SystemIncludePaths.Add("$(NDKROOT)/sources/android/cpufeatures");
// Add path to statically compiled version of cxa_demangle
InBuildTarget.GlobalLinkEnvironment.Config.LibraryPaths.Add(UEBuildConfiguration.UEThirdPartySourceDirectory + "Android/cxa_demangle/armeabi-v7a");
InBuildTarget.GlobalLinkEnvironment.Config.LibraryPaths.Add(UEBuildConfiguration.UEThirdPartySourceDirectory + "Android/cxa_demangle/arm64-v8a");
InBuildTarget.GlobalLinkEnvironment.Config.LibraryPaths.Add(UEBuildConfiguration.UEThirdPartySourceDirectory + "Android/cxa_demangle/x86");
InBuildTarget.GlobalLinkEnvironment.Config.LibraryPaths.Add(UEBuildConfiguration.UEThirdPartySourceDirectory + "Android/cxa_demangle/x64");
//@TODO: Tegra Gfx Debugger - standardize locations - for now, change the hardcoded paths and force this to return true to test
if (UseTegraGraphicsDebugger(InBuildTarget))
{
//InBuildTarget.GlobalLinkEnvironment.Config.LibraryPaths.Add(UEBuildConfiguration.UEThirdPartySourceDirectory + "NVIDIA/TegraGfxDebugger");
//InBuildTarget.GlobalLinkEnvironment.Config.LibraryPaths.Add("F:/NVPACK/android-kk-egl-t124-a32/stub");
//InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("Nvidia_gfx_debugger_stub");
}
InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("gnustl_shared");
InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("gcc");
InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("z");
InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("c");
InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("m");
InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("log");
InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("dl");
if (!UseTegraGraphicsDebugger(InBuildTarget))
{
InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("GLESv2");
InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("EGL");
}
InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("OpenSLES");
InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("android");
InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("cxa_demangle");
UEBuildConfiguration.bCompileSimplygon = false;
BuildConfiguration.bDeployAfterCompile = true;
}
private bool UseTegraGraphicsDebugger(UEBuildTarget InBuildTarget)
{
// Disable for now
return false;
}
public override bool ShouldCreateDebugInfo(UnrealTargetConfiguration Configuration)
{
switch (Configuration)
{
case UnrealTargetConfiguration.Development:
case UnrealTargetConfiguration.Shipping:
case UnrealTargetConfiguration.Test:
case UnrealTargetConfiguration.Debug:
default:
return true;
};
}
public override UEToolChain CreateToolChain(CPPTargetPlatform Platform)
{
return new AndroidToolChain(ProjectFile);
}
public override UEBuildDeploy CreateDeploymentHandler()
{
return new UEDeployAndroid(ProjectFile);
}
}
class AndroidPlatform : UEBuildPlatform
{
AndroidPlatformSDK SDK;
public AndroidPlatform(AndroidPlatformSDK InSDK) : base(UnrealTargetPlatform.Android, CPPTargetPlatform.Android)
{
SDK = InSDK;
}
public override SDKStatus HasRequiredSDKsInstalled()
{
return SDK.HasRequiredSDKsInstalled();
}
public override bool CanUseXGE()
{
return false;
}
public override string GetBinaryExtension(UEBuildBinaryType InBinaryType)
{
switch (InBinaryType)
{
case UEBuildBinaryType.DynamicLinkLibrary:
return ".so";
case UEBuildBinaryType.Executable:
return ".so";
case UEBuildBinaryType.StaticLibrary:
return ".a";
case UEBuildBinaryType.Object:
return ".o";
case UEBuildBinaryType.PrecompiledHeader:
return ".gch";
}
return base.GetBinaryExtension(InBinaryType);
}
public override bool ShouldUsePCHFiles(CPPTargetPlatform Platform, CPPTargetConfiguration Configuration)
{
return true;
}
public override string GetDebugInfoExtension(UEBuildBinaryType InBinaryType)
{
return "";
}
public override bool HasDefaultBuildConfig(UnrealTargetPlatform Platform, DirectoryReference ProjectPath)
{
string[] BoolKeys = new string[] {
"bBuildForArmV7", "bBuildForArm64", "bBuildForX86", "bBuildForX8664",
"bBuildForES2", "bBuildForES31",
};
// look up iOS specific settings
if (!DoProjectSettingsMatchDefault(Platform, ProjectPath, "/Script/AndroidRuntimeSettings.AndroidRuntimeSettings",
BoolKeys, null, null))
{
return false;
}
// check the base settings
return base.HasDefaultBuildConfig(Platform, ProjectPath);
}
public override bool ShouldCompileMonolithicBinary(UnrealTargetPlatform InPlatform)
{
// This platform currently always compiles monolithic
return true;
}
public override bool ShouldUsePDBFiles(CPPTargetPlatform Platform, CPPTargetConfiguration Configuration, bool bCreateDebugInfo)
{
return true;
}
public override bool ShouldNotBuildEditor(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration)
{
return true;
}
public override bool BuildRequiresCookedData(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration)
{
return true;
}
public override bool RequiresDeployPrepAfterCompile()
{
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))
{
bool bBuildShaderFormats = UEBuildConfiguration.bForceBuildShaderFormats;
if (!UEBuildConfiguration.bBuildRequiresCookedData)
{
if (ModuleName == "Engine")
{
if (UEBuildConfiguration.bBuildDeveloperTools)
{
Rules.PlatformSpecificDynamicallyLoadedModuleNames.Add("AndroidTargetPlatform");
Rules.PlatformSpecificDynamicallyLoadedModuleNames.Add("Android_PVRTCTargetPlatform");
Rules.PlatformSpecificDynamicallyLoadedModuleNames.Add("Android_ATCTargetPlatform");
Rules.PlatformSpecificDynamicallyLoadedModuleNames.Add("Android_DXTTargetPlatform");
Rules.PlatformSpecificDynamicallyLoadedModuleNames.Add("Android_ETC1TargetPlatform");
Rules.PlatformSpecificDynamicallyLoadedModuleNames.Add("Android_ETC2TargetPlatform");
Rules.PlatformSpecificDynamicallyLoadedModuleNames.Add("Android_ASTCTargetPlatform");
Rules.PlatformSpecificDynamicallyLoadedModuleNames.Add("Android_MultiTargetPlatform");
}
}
else if (ModuleName == "TargetPlatform")
{
bBuildShaderFormats = true;
Rules.DynamicallyLoadedModuleNames.Add("TextureFormatPVR");
Rules.DynamicallyLoadedModuleNames.Add("TextureFormatDXT");
Rules.DynamicallyLoadedModuleNames.Add("TextureFormatASTC");
Rules.PlatformSpecificDynamicallyLoadedModuleNames.Add("TextureFormatAndroid"); // ATITC, ETC1 and ETC2
if (UEBuildConfiguration.bBuildDeveloperTools)
{
//Rules.DynamicallyLoadedModuleNames.Add("AudioFormatADPCM"); //@todo android: android audio
}
}
}
// allow standalone tools to use targetplatform modules, without needing Engine
if (ModuleName == "TargetPlatform")
{
if (UEBuildConfiguration.bForceBuildTargetPlatforms)
{
Rules.PlatformSpecificDynamicallyLoadedModuleNames.Add("AndroidTargetPlatform");
Rules.PlatformSpecificDynamicallyLoadedModuleNames.Add("Android_PVRTCTargetPlatform");
Rules.PlatformSpecificDynamicallyLoadedModuleNames.Add("Android_ATCTargetPlatform");
Rules.PlatformSpecificDynamicallyLoadedModuleNames.Add("Android_DXTTargetPlatform");
Rules.PlatformSpecificDynamicallyLoadedModuleNames.Add("Android_ETC1TargetPlatform");
Rules.PlatformSpecificDynamicallyLoadedModuleNames.Add("Android_ETC2TargetPlatform");
Rules.PlatformSpecificDynamicallyLoadedModuleNames.Add("Android_ASTCTargetPlatform");
Rules.PlatformSpecificDynamicallyLoadedModuleNames.Add("Android_MultiTargetPlatform");
}
if (bBuildShaderFormats)
{
//Rules.DynamicallyLoadedModuleNames.Add("ShaderFormatAndroid"); //@todo android: ShaderFormatAndroid
}
}
}
}
public override List<FileReference> FinalizeBinaryPaths(FileReference BinaryName, FileReference ProjectFile)
{
AndroidToolChain ToolChain = new AndroidToolChain(ProjectFile);
var Architectures = ToolChain.GetAllArchitectures();
var GPUArchitectures = ToolChain.GetAllGPUArchitectures();
// make multiple output binaries
List<FileReference> AllBinaries = new List<FileReference>();
foreach (string Architecture in Architectures)
{
foreach (string GPUArchitecture in GPUArchitectures)
{
AllBinaries.Add(new FileReference(AndroidToolChain.InlineArchName(BinaryName.FullName, Architecture, GPUArchitecture)));
}
}
return AllBinaries;
}
/// <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 AndroidPlatformContext(ProjectFile);
}
}
class AndroidPlatformSDK : UEBuildPlatformSDK
{
protected override bool PlatformSupportsAutoSDKs()
{
return true;
}
public override string GetSDKTargetPlatformName()
{
return "Android";
}
protected override string GetRequiredSDKString()
{
return "-19";
}
protected override String GetRequiredScriptVersionString()
{
return "3.0";
}
// prefer auto sdk on android as correct 'manual' sdk detection isn't great at the moment.
protected override bool PreferAutoSDK()
{
return true;
}
/// <summary>
/// checks if the sdk is installed or has been synced
/// </summary>
/// <returns></returns>
private bool HasAnySDK()
{
string NDKPath = Environment.GetEnvironmentVariable("NDKROOT");
{
var configCacheIni = ConfigCacheIni.CreateConfigCacheIni(UnrealTargetPlatform.Unknown, "Engine", (DirectoryReference)null);
var AndroidEnv = new Dictionary<string, string>();
Dictionary<string, string> EnvVarNames = new Dictionary<string, string> {
{"ANDROID_HOME", "SDKPath"},
{"NDKROOT", "NDKPath"},
{"ANT_HOME", "ANTPath"},
{"JAVA_HOME", "JavaPath"}
};
string path;
foreach (var kvp in EnvVarNames)
{
if (configCacheIni.GetPath("/Script/AndroidPlatformEditor.AndroidSDKSettings", kvp.Value, out path) && !string.IsNullOrEmpty(path))
{
AndroidEnv.Add(kvp.Key, path);
}
else
{
var envValue = Environment.GetEnvironmentVariable(kvp.Key);
if (!String.IsNullOrEmpty(envValue))
{
AndroidEnv.Add(kvp.Key, envValue);
}
}
}
// If we are on Mono and we are still missing a key then go and find it from the .bash_profile
if (Utils.IsRunningOnMono && !EnvVarNames.All(s => AndroidEnv.ContainsKey(s.Key)))
{
string BashProfilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), ".bash_profile");
if (File.Exists(BashProfilePath))
{
string[] BashProfileContents = File.ReadAllLines(BashProfilePath);
// Walk backwards so we keep the last export setting instead of the first
for (int LineIndex = BashProfileContents.Length - 1; LineIndex >= 0; --LineIndex)
{
foreach (var kvp in EnvVarNames)
{
if (AndroidEnv.ContainsKey(kvp.Key))
{
continue;
}
if (BashProfileContents[LineIndex].StartsWith("export " + kvp.Key + "="))
{
string PathVar = BashProfileContents[LineIndex].Split('=')[1].Replace("\"", "");
AndroidEnv.Add(kvp.Key, PathVar);
}
}
}
}
}
// Set for the process
foreach (var kvp in AndroidEnv)
{
Environment.SetEnvironmentVariable(kvp.Key, kvp.Value);
}
// See if we have an NDK path now...
AndroidEnv.TryGetValue("NDKROOT", out NDKPath);
}
// we don't have an NDKROOT specified
if (String.IsNullOrEmpty(NDKPath))
{
return false;
}
NDKPath = NDKPath.Replace("\"", "");
// need a supported llvm
if (!Directory.Exists(Path.Combine(NDKPath, @"toolchains/llvm-3.6")) &&
!Directory.Exists(Path.Combine(NDKPath, @"toolchains/llvm-3.5")) &&
!Directory.Exists(Path.Combine(NDKPath, @"toolchains/llvm-3.3")) &&
!Directory.Exists(Path.Combine(NDKPath, @"toolchains/llvm-3.1")))
{
return false;
}
return true;
}
protected override SDKStatus HasRequiredManualSDKInternal()
{
// if any autosdk setup has been done then the local process environment is suspect
if (HasSetupAutoSDK())
{
return SDKStatus.Invalid;
}
if (HasAnySDK())
{
return SDKStatus.Valid;
}
return SDKStatus.Invalid;
}
}
public class AndroidPlatformFactory : UEBuildPlatformFactory
{
protected override UnrealTargetPlatform TargetPlatform
{
get { return UnrealTargetPlatform.Android; }
}
protected override void RegisterBuildPlatforms()
{
AndroidPlatformSDK SDK = new AndroidPlatformSDK();
SDK.ManageAndValidateSDK();
if ((ProjectFileGenerator.bGenerateProjectFiles == true) || (SDK.HasRequiredSDKsInstalled() == SDKStatus.Valid) || Environment.GetEnvironmentVariable("IsBuildMachine") == "1")
{
bool bRegisterBuildPlatform = true;
FileReference AndroidTargetPlatformFile = FileReference.Combine(UnrealBuildTool.EngineSourceDirectory, "Developer", "Android", "AndroidTargetPlatform", "AndroidTargetPlatform.Build.cs");
if (AndroidTargetPlatformFile.Exists() == false)
{
bRegisterBuildPlatform = false;
}
if (bRegisterBuildPlatform == true)
{
// Register this build platform
Log.TraceVerbose(" Registering for {0}", UnrealTargetPlatform.Android.ToString());
UEBuildPlatform.RegisterBuildPlatform(new AndroidPlatform(SDK));
UEBuildPlatform.RegisterPlatformWithGroup(UnrealTargetPlatform.Android, UnrealPlatformGroup.Android);
}
}
}
}
}