You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3233612 on 2016/12/13 by Ben.Marsh UGS: Fix cases where precompiled binaries are submitted for a content change. Change 3235584 on 2016/12/14 by Ben.Marsh UBT: Deprecate the overridable TargetRules.ShouldUseSharedBuildEnvironment() function; targets should specify which build environment to use by setting the BuildEnvironment field in their constructor instead. Change 3235741 on 2016/12/14 by Ben.Marsh UBT: Deprecate the SetupBinaries() callback on the TargetRules class. Instead of overriding this, targets may override their launch module through the "LaunchModuleName" property in their constructor, and add extra modules to the "ExtraModuleNames" field on the TargetRules object itself. Change 3238176 on 2016/12/16 by Ben.Marsh UBT: New XML config file parser. Now reads once at startup and can be applied to instanced objects rather than global fields, and caches parsed output in a binary form for quicker initialization on subsequent runs. Change 3238249 on 2016/12/16 by Ben.Marsh UBT: Add attribute-driven command line parser. Change 3238462 on 2016/12/16 by Ben.Marsh UBT: Include the Platform, Configuration and Architecture on the TargetRules. Add a constructor which takes the TargetInfo object and deprecate the parameterless one; these fields are currently initialized before invoking the constructor in RulesAssembly. Change 3238564 on 2016/12/16 by Ben.Marsh UBT: Deprecate the ModuleRules constructor which takes a TargetInfo argument. Replace it with a read-only wrapper around the target rules instead, so target-specific configuration options can be read without needing to access global static variables. Also require that it's passed to the base class constructor. Change 3239919 on 2016/12/19 by Ben.Marsh UBT: Remove the "PreferredSubPlatform" property. This is only used for Windows XP support, which is being retired anyway. Having the target define its own architecture is an awkward contractiction to maintain support for, since the target rules are constructed after the architecture already has been determined. Change3240061on 2016/12/19 by Ben.Marsh UBT: Remove ThirdPartyHeaderFinder. I don't think anything is using this any more. Change 3240175 on 2016/12/19 by Ben.Marsh UBT: Add the target name and project file location to the target rules. Change 3240490 on 2016/12/19 by Ben.Marsh UAT: Remove Mac staging code that requires UAT to compile and construct .target.cs files when packaging, to check bUseSteam and bUseCEF3 flags. libsteam_api.dylib is now staged at build time by adding it as a bundle resource, CEF3 is already marked as a runtime dependency by CEF3.build.cs, and UnrealCEFSubProcess.app is already marked as a runtime dependency from WebBrowser.build.cs. Change 3240717 on 2016/12/20 by Ben.Marsh UAT: Allow configuring UAT to run as if on a build machine by passing the -buildmachine argument on the command line. Change 3240718 on 2016/12/20 by Ben.Marsh UAT: Remove target-specific properties that are no longer used by staging (bUsesSlate, bUsesCEF3, etc...). This stuff should all be handled inside UBT. Change 3241002 on 2016/12/20 by Ben.Marsh UBT: Move most target configuration settings from UEBuildConfiguration to TargetRules. This encapsulates target specific settings that will allow instancing multiple targets in the future. To facilitate migration of settings to their new location, "UEBuildConfiguration" is now a property that returns the current target rules instance. Change 3241027 on 2016/12/20 by Ben.Marsh Only copy the Steamworks dylib into the app bundle for monolithic builds. For all other times, just add it as a runtime dependency. Change 3241055 on 2016/12/20 by Ben.Marsh UBT: Only store a ReadOnlyTargetRules object on the instanced build target; finalize the configuration before it's instantiated. Change 3241156 on 2016/12/20 by Ben.Marsh Update SwarmInterface.csproj to .NET framework 4.5, to match what all other C# tools are using. Change 3241205 on 2016/12/20 by Ben.Marsh Replace all uses of TargetRules.TargetType with TargetType. Change 3241881 on 2016/12/21 by Ben.Marsh UBT: Remove project file information from UEBuildContext base class. As configurable properties are moved on to the TargetRules object, it will no longer be a dependency to instantiate the platform with this path. Change 3241895 on 2016/12/21 by Ben.Marsh UBT: Remove toolchain support for Windows XP. Change 3241908 on 2016/12/21 by Ben.Marsh UBT: Move settings for windows targets into a WindowsTargetRules class, which is exposed for targets to modify via the TargetRules.WindowsPlatform field. Change 3242835 on 2016/12/22 by Ben.Marsh UBT: Fix multiple binaries being created if plugins specify module names more than once. MfMedia.uplugin has MfMediaFactory listed twice. Change 3242837 on 2016/12/22 by Ben.Marsh Change UE4EditorServices to include MacSystemIncludes rather than Cocoa.h directly; causes FVector to be defined incorrectly in non-unity builds. Change 3242923 on 2016/12/22 by Ben.Marsh Build: Fixes for conforming incremental workspaces: * P4 have table is now reset before deleting all the files. This prevents Perforce being out of sync if the delete fails for some reason. * Incremental workspaces are skipped when running a clean operation, because they do not have a workspace capture file (causing a full re-sync, always). The "P4 Clean" option is still effective for cleaning these workspaces. Change 3242961 on 2016/12/22 by Ben.Marsh UBT: Move entry points from PreBuildSync() and PostBuildSync() from UEToolChain to UEBuildPlatform, and make the original toolchain versions static. These functions are already at odds with the rest of the data flow within UBT because they rely on global state cached outside the toolchain instance, making assumptions that UBT is only ever going to be invoked with one target that's constructed in the same run and that nothing is being cached (eg. UBT makefiles). Moving them onto UEBuildPlatform simplifies the toolchain lifecycle for other platforms without leaving Mac and IOS any more limited than they were before. Change 3242981 on 2016/12/22 by Ben.Marsh UBT: Remove symbol server handling code into UAT's platform library, since it's never needed from inside UBT. Change 3242999 on 2016/12/22 by Ben.Marsh UBT: Remove the StripSymbols() function from the UEToolChain base class. This functionality is only required by UAT, so it's better suited to being exposed through UAT's modular platform classes. Change 3243022 on 2016/12/22 by Ben.Marsh UBT: Require an instance of the target rules to be able to construct a toolchain in UBT. This will allow configuring toolchain-specific options from the target, using reflection from config files, and the command line. Change 3243083 on 2016/12/22 by Ben.Marsh UBT: Move settings for the Windows compiler version to use onto the Windows-specific target rules. Change 3243090 on 2016/12/22 by Ben.Marsh UBT: Change the third party paths in UEBuildConfiguration to constants. Changing these would not work. Change 3243423 on 2016/12/23 by Ben.Marsh UBT: Move a lot of settings from BuildConfiguration to TargetRules. This allows different targets to have different settings, naturally, and moves converts argument parsing and config to be driven by attributes. Change 3243516 on 2016/12/23 by Ben.Marsh UBT: Remove the ValidateUEBuildConfiguration callback, which is no longer used. (XGE settings validation occurs in XGE.cs) Change 3244020 on 2016/12/28 by Ben.Marsh UBT: Remove the BaseIntermediatePath static property. Precursor to removing RelativeEnginePath and IntermediateFolder properties. Change 3244074 on 2016/12/28 by Ben.Marsh UBT: Remove the RelativeEnginePath variable from BuildConfiguration. UnrealBuildTool.EngineDirectory gives the absolute path, and can be used to construct a relative path when necessary. Change 3244076 on 2016/12/28 by Ben.Marsh UBT: Remove BuildConfiguration.BaseIntermediateFolder; just use a fixed directory everywhere instead. Change 3244083 on 2016/12/28 by Ben.Marsh UBT: Replace FileReference and DirectoryReference instance methods for manipulating files and directories with static methods, to mirror the System.IO.File and System.IO.Directory classes. Change 3244441 on 2016/12/31 by Ben.Marsh UBT: Remove code to force PDBs when building with no debug info under XGE. Verified described symptoms (that it causes PCH generation to be serialized) no longer occur. Change 3244687 on 2017/01/03 by Matthew.Griffin Changed Exception to use FirstInclude.IncludeName as PrecompiledHeaderIncludeFilename can be null when this occurs Change 3246112 on 2017/01/04 by Ben.Marsh UBT: Fix UHT failures building some targets with the -useprecompiled option, due to differences in the order that circularly dependent modules are parsed. Precompiled binaries are now kept in the regular AppBinaries list, but are excluded from the build at the last minute. Also change some checks from IsEngineInstalled() to bUsePrecompiled, to prevent headers being overwritten when running in a non-installed precompiled build. Change 3246223 on 2017/01/04 by Ben.Marsh UBT: Prevent version manifests being overridden if a file is not being built as part of the target. Change 3246387 on 2017/01/04 by Ben.Marsh UBT: Remove BuildConfiguration settings for UnrealCodeAnalyzer. This tool isn't used at the moment, but it's configured using global variables accessed from all over the UBT codebase, making it difficult to refactor the build options into an instanced object. If we bring this tool back from the dead in the future, it should be possible to implement it using the exported JSON target definition or the XGE manifest, similarly to how IncludeTool uses it. Change 3247004 on 2017/01/04 by Ben.Marsh UBT: Simplify the logic for cleaning targets in UBT. Now uses FileReference/DirectoryReference objects everywhere, doesn't require the compile/link environment, and does all the checking to avoid deleting precompiled binaries in one place. Change 3247250 on 2017/01/04 by Ben.Marsh UBT: Prevent precompiled binaries being added to the list of app binaries twice. Change3247594on 2017/01/05 by Ben.Marsh Build: Run sample and template editors on the same agents as the other incremental builds. Remove ProtoStar, which does not have any non-precompiled editor target to build. Change 3247763 on 2017/01/05 by Ben.Marsh UBT: Allow the toolchain to update the list of build products for each module linked into a binary. Allows Mac to add dylibs and bundle resources specified per-module without having to construct a link environment and try to link them. Change 3247775 on 2017/01/05 by Ben.Marsh UBT: Instance the target compile and link environments when they are required during building, and don't persist them on the UEBuildTarget instance. Change 3247811 on 2017/01/05 by Ben.Marsh EC: Add a batch file for testing postp filters. Change 3247839 on 2017/01/05 by Ben.Marsh EC: Include the name of the file being compiled when parsing MSVC errors and warnings. Change 3248101 on 2017/01/05 by Ben.Marsh UBT: Fix Android support for force included headers. Change 3248533 on 2017/01/05 by Ben.Marsh PR #3097: UBT project supports optional platforms (Contributed by PrimalJohnScott) Change 3249205 on 2017/01/06 by Ben.Marsh UAT: Fix ParseTaggedP4Output throwing an exception if the same key name is specified more than once. This can happen when parsing the output from "P4 INFO", where multiple brokers are present. Change 3249249 on 2017/01/06 by Ben.Marsh UBT: Check for the existance of AndroidManifest.xml within extracted AAR directories, rather than just checking for the existance of the directory itself. Perforce does not remove empty directories when cleaning a workspace unless the rmdir option is on the workspace, so this can cause incremental build failures to fail on build machines. Change 3249486 on 2017/01/06 by Ben.Marsh UBT: Use relative paths in unity files when compiling for Mac/IOS, rather than generating a separate local/remote version of the file for gathering include dependencies. Absolute paths are only used to work around the way that MSVC concatenates paths internally; we don't hit the same problems when checking dependencies. Change 3249736 on 2017/01/06 by Ben.Marsh UBT: Rename CPPEnvironment to CppCompileEnvironment, and remove the separate CPPEnvironmentConfiguration object. All settings are now stored directly on the CppCompileEnvironment object. Change 3250179 on 2017/01/07 by Ben.Marsh Fix creating installed build when root directory contains a space in the name. Change 3250181 on 2017/01/07 by Ben.Marsh UBT: Remove some esoteric (and unused, AFAIK) options for orthogonally building different platforms. Change 3250223 on 2017/01/07 by Ben.Marsh UBT: Merge the LinkEnvironment and LinkEnvironmentConfiguration classes together. Change 3250233 on 2017/01/07 by Ben.Marsh UGS: Allow specifying a workspace-specific sync filter, which is applied on top of the standard filter. Also fix filter being cleared if the cancel button is pressed, and help text being stripped out. Change 3250241 on 2017/01/07 by Ben.Marsh UBT: Move the options for specifying additional Android architectures to target onto an Android-specific object on the TargetRules. Change 3250400 on 2017/01/08 by Ben.Marsh UBT: Move executor config settings onto the executor instances. Change 3257708 on 2017/01/13 by Ben.Marsh UBT: Remove the ThirdPartySourceDirectory constant; there are many places which hard-code or assume this location anyway, and it's not going to change. Change 3260535 on 2017/01/17 by Ben.Marsh Add an optional "RequiredSubmittedChange" setting to EC settings files. Allows a scheduled job to run even if there have been no code changes submitted. Test with the utilization capture job. Change 3260875 on 2017/01/17 by Ben.Marsh EC: Fix workspaces getting out of sync wrt. newly added files when jobs are aborted during a sync. In such cases, the P4 have table indicates the new files have been synced locally, but the workspace is forced back to a state before it had them due to the capture file. When a following sync tries to add them again, P4 believes the workspace already has them synced. To work around this, we now write an additional file to the root folder of a workspace containing the last CL that was captured, and sync back to it before doing the reconcile. Change 3261724 on 2017/01/18 by Ben.Marsh Allow filtering job types from the list view in EC. Hide the utilization capture job by default. Also set up notifications for the utilization capture job. Change 3261756 on 2017/01/18 by Ben.Marsh IncludeTool: Prevent matching a full enum declaration as a forward declaration. Change 3261932 on 2017/01/18 by Ben.Marsh EC: Add support for specifying days of the week in schedules. The following syntaxes are supported: "Monday, Tuesday and Wednesday at 10:30" "Daily except Sunday and Wednesday at 14:30" Also tweak display of dates relative to now to handle dates/times in the future, and include the date when specifying a day name. #jira UEB-729 Change 3262676 on 2017/01/18 by Ben.Marsh UBT: Split UBTMakefile into its own file. (From PR #3106) Change 3263893 on 2017/01/19 by Ben.Marsh UBT: Stop exporting platform classes from UBT, as well as all the referenced classes that have to be made public as a result. Any platform-specific functionality that needs to be shared with UAT is now exposed through wrappers in separate public classes, eg. WindowsExports.cs, IOSExports.cs, etc... Change 3264291 on 2017/01/19 by Ben.Marsh UBT: Fix errors generating documentation in UBT, and enable it by default. Will catch more errors with new code being added. Originally in PR #3106, but redone due to conflicts. Change 3264534 on 2017/01/19 by Ben.Marsh UBT: Include plugin config files in generated projects. Change 3264571 on 2017/01/19 by Ben.Marsh UBT: Prevent overwriting .modules files if nothing has changed. On builders, it's common to build multiple editors in the same workspace, and changing the last modified timestamp causes BuildGraph to fail due to tampered files. Change 3265745 on 2017/01/20 by Ben.Marsh UGS: Automatically open UGS when running the launcher for a second time, rather than prompting to close the original instance. Change 3265777 on 2017/01/20 by Ben.Marsh UGS: Automatically close and reopen when UGS is re-ran with the shift key held down to switch into unstable mode. Change 3268314 on 2017/01/23 by Ben.Marsh UBT: Make sure version manifests are stable by sorting the list of build products, so they are only touched if the contents have really changed. Change 3269601 on 2017/01/24 by Ben.Marsh UBT: Fix symbol files being added to manifest for some platforms even though debug info is disabled. Change 3269607 on 2017/01/24 by Ben.Marsh UBT: Fix bug where UBT would need to be invoked when switching between two editors sharing the same engine binaries on Mac. The location of the .modules file cannot be guessed on Mac by looking in the same directory as the primary output executable because it's an .app bundle, and the actual modules are nested several directories below that. Change 3269608 on 2017/01/24 by Ben.Marsh UBT: Fix additional files copied into the app bundle always being updated on Mac. Now uses rsync --checksum to make sure only modified files are updated. Change 3271062 on 2017/01/24 by Ben.Marsh UBT: Fixes for bugs detected by PVS Studio (PR #3161) Change 3272421 on 2017/01/25 by Ben.Marsh Fix commends regarding DDC in BaseEngine.ini #jira UE-41076 Change3272810on 2017/01/25 by Ben.Marsh Fix VS2017 being displayed as 'Visual Studio 15' in the Windows target settings panel. Change 3272935 on 2017/01/25 by Ben.Marsh Fix Metal errors launching on Mac due to use of OSX environment settings before they are initialized. Toolchain settings are now constructed on demand in a separate class, for Mac, iOS and TVOS. Change 3274167 on 2017/01/26 by Ben.Marsh Fix resource files not being compiled in installed builds on Windows. Was causing metadata not to be embedded into executables. #jira UE-36457 Change 3275557 on 2017/01/27 by Ben.Marsh Expand checks for propagation of restricted folder names to include source files, and to ensure that each restricted folder is represented in the output. Also improve messaging to show the dependency chain leading to a restricted folder being referenced, and which folder it is. Change 3275628 on 2017/01/27 by Ben.Marsh UBT: Splitting configuration files into one class per-file. Change 3276784 on 2017/01/29 by Ben.Marsh Add an authoritative list of confidential folder names, and expose it through global BuildGraph properties ($(RestrictedFolderNames) and $(RestrictedFolderFilter)). Also switch existing scripts to use it. Change 3276792 on 2017/01/29 by Ben.Marsh UBT: Use UE4CSharp.prog files to indicate which projects should be included in the solution without having to hard-code a list of them in UBT. Change 3277263 on 2017/01/30 by Ben.Marsh IncludeTool: Merging various fixes. * Fix warnings about #include directives after first code block from parsing monolithic headers. * Fix exception on startup if the intermediate directory does not already exist. * Add a special case for ignoring missing header guards from MonolithicHeaderBoilerplate.h, rather than marking it as an inline header. Marking it as inline prevents parsing include directives, which results in including CoreTypes.h from the wrong location. * Create job objects for spawned compiler instances to prevent them trying allocating more memory than the system can spare. * Remove (unused) code which makes assumptions about files ending with "Classes.h". * Add a verbose per-file output log to aid with debugging. * Negate the MakeStandalone command line option, which was added to allow tweaking forward declarations in already optimized files, so the optimized output does not have missing headers by default. * Fix missing headers when creating standalone files, due to incorrect list of previous files being passed in to the OutputFile constructor. Now passes the original list of included files, not the output list. * Fix initial header for a cpp file sometimes being removed. Forcibly including a header at the start of the file does not use the normal pathway for spidering through includes, so a second include of the same file was being generated. Any includes of that header were being forced into output, and the earlier include was then removed due to being redundant. * Prevent forward declaring enums which have to be parsed by UHT. UHT relies on includes to determine a parse order, and will fail if the enum definition has not been parsed first. * Use a relative path for private includes in the same module if there are any. Fixes some incorrect paths, and makes it clearer that we're doing something we shouldn't. Change 3277307 on 2017/01/30 by Ben.Marsh UBT: Fix private PCHs not using correct header. Causes custom definitions to be excluded from the command line. [CL 3278101 by Ben Marsh in Main branch]
1788 lines
69 KiB
C#
1788 lines
69 KiB
C#
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
|
|
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Diagnostics;
|
|
using System.Security.AccessControl;
|
|
using System.Text;
|
|
using System.Linq;
|
|
using Ionic.Zip;
|
|
|
|
namespace UnrealBuildTool
|
|
{
|
|
class MacToolChainSettings : AppleToolChainSettings
|
|
{
|
|
/***********************************************************************
|
|
* NOTE:
|
|
* Do NOT change the defaults to set your values, instead you should set the environment variables
|
|
* properly in your system, as other tools make use of them to work properly!
|
|
* The defaults are there simply for examples so you know what to put in your env vars...
|
|
***********************************************************************/
|
|
|
|
/// <summary>
|
|
/// Which version of the Mac OS SDK to target at build time
|
|
/// </summary>
|
|
public string MacOSSDKVersion = "latest";
|
|
public float MacOSSDKVersionFloat = 0.0f;
|
|
|
|
/// <summary>
|
|
/// Which version of the Mac OS X to allow at run time
|
|
/// </summary>
|
|
public string MacOSVersion = "10.9";
|
|
|
|
/// <summary>
|
|
/// Minimum version of Mac OS X to actually run on, running on earlier versions will display the system minimum version error dialog and exit.
|
|
/// </summary>
|
|
public string MinMacOSVersion = "10.11.6";
|
|
|
|
/// <summary>
|
|
/// Directory for the developer binaries
|
|
/// </summary>
|
|
public string ToolchainDir = "";
|
|
|
|
/// <summary>
|
|
/// Location of the SDKs
|
|
/// </summary>
|
|
public string BaseSDKDir;
|
|
|
|
/// <summary>
|
|
/// Constructor
|
|
/// </summary>
|
|
/// <param name="bVerbose">Whether to output verbose logging</param>
|
|
public MacToolChainSettings(bool bVerbose) : base(bVerbose)
|
|
{
|
|
BaseSDKDir = XcodeDeveloperDir + "Platforms/MacOSX.platform/Developer/SDKs";
|
|
ToolchainDir = XcodeDeveloperDir + "Toolchains/XcodeDefault.xctoolchain/usr/bin/";
|
|
|
|
SelectSDK(BaseSDKDir, "MacOSX", ref MacOSSDKVersion, bVerbose);
|
|
|
|
// convert to float for easy comparison
|
|
MacOSSDKVersionFloat = float.Parse(MacOSSDKVersion, System.Globalization.CultureInfo.InvariantCulture);
|
|
}
|
|
}
|
|
|
|
class MacToolChain : AppleToolChain
|
|
{
|
|
public MacToolChain(FileReference InProjectFile)
|
|
: base(CppPlatform.Mac, UnrealTargetPlatform.Mac, InProjectFile)
|
|
{
|
|
}
|
|
|
|
public static Lazy<MacToolChainSettings> SettingsPrivate = new Lazy<MacToolChainSettings>(() => new MacToolChainSettings(false));
|
|
|
|
public static MacToolChainSettings Settings
|
|
{
|
|
get { return SettingsPrivate.Value; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Which compiler frontend to use
|
|
/// </summary>
|
|
private const string MacCompiler = "clang++";
|
|
|
|
/// <summary>
|
|
/// Which linker frontend to use
|
|
/// </summary>
|
|
private const string MacLinker = "clang++";
|
|
|
|
/// <summary>
|
|
/// Which archiver to use
|
|
/// </summary>
|
|
private const string MacArchiver = "libtool";
|
|
|
|
/// <summary>
|
|
/// Track which scripts need to be deleted before appending to
|
|
/// </summary>
|
|
private bool bHasWipedCopyDylibScript = false;
|
|
private bool bHasWipedFixDylibScript = false;
|
|
|
|
private static List<FileItem> BundleDependencies = new List<FileItem>();
|
|
|
|
private static void SetupXcodePaths(bool bVerbose)
|
|
{
|
|
}
|
|
|
|
public override void SetUpGlobalEnvironment(ReadOnlyTargetRules Target)
|
|
{
|
|
base.SetUpGlobalEnvironment(Target);
|
|
|
|
SetupXcodePaths(true);
|
|
}
|
|
|
|
static string GetCompileArguments_Global(CppCompileEnvironment CompileEnvironment)
|
|
{
|
|
string Result = "";
|
|
|
|
Result += " -fmessage-length=0";
|
|
Result += " -pipe";
|
|
Result += " -fpascal-strings";
|
|
|
|
Result += " -fexceptions";
|
|
Result += " -fasm-blocks";
|
|
|
|
string SanitizerMode = Environment.GetEnvironmentVariable("CLANG_ADDRESS_SANITIZER");
|
|
if(SanitizerMode != null && SanitizerMode == "YES")
|
|
{
|
|
Result += " -fsanitize=address";
|
|
}
|
|
|
|
Result += " -Wall -Werror";
|
|
//Result += " -Wsign-compare"; // fed up of not seeing the signed/unsigned warnings we get on Windows - lets enable them here too.
|
|
|
|
Result += " -Wno-unused-variable";
|
|
Result += " -Wno-unused-value";
|
|
// This will hide the warnings about static functions in headers that aren't used in every single .cpp file
|
|
Result += " -Wno-unused-function";
|
|
// This hides the "enumeration value 'XXXXX' not handled in switch [-Wswitch]" warnings - we should maybe remove this at some point and add UE_LOG(, Fatal, ) to default cases
|
|
Result += " -Wno-switch";
|
|
// This hides the "warning : comparison of unsigned expression < 0 is always false" type warnings due to constant comparisons, which are possible with template arguments
|
|
Result += " -Wno-tautological-compare";
|
|
// This will prevent the issue of warnings for unused private variables.
|
|
Result += " -Wno-unused-private-field";
|
|
// needed to suppress warnings about using offsetof on non-POD types.
|
|
Result += " -Wno-invalid-offsetof";
|
|
// we use this feature to allow static FNames.
|
|
Result += " -Wno-gnu-string-literal-operator-template";
|
|
// Needed for Alembic third party lib
|
|
Result += " -Wno-deprecated-register";
|
|
|
|
if (Settings.MacOSSDKVersionFloat < 10.9f && Settings.MacOSSDKVersionFloat >= 10.11f)
|
|
{
|
|
Result += " -Wno-inconsistent-missing-override"; // too many missing overrides...
|
|
Result += " -Wno-unused-local-typedef"; // PhysX has some, hard to remove
|
|
}
|
|
|
|
if (CompileEnvironment.bEnableShadowVariableWarnings)
|
|
{
|
|
Result += " -Wshadow" + (CompileEnvironment.bShadowVariableWarningsAsErrors ? "" : " -Wno-error=shadow");
|
|
}
|
|
|
|
if (CompileEnvironment.bEnableUndefinedIdentifierWarnings)
|
|
{
|
|
Result += " -Wundef" + (CompileEnvironment.bUndefinedIdentifierWarningsAsErrors ? "" : " -Wno-error=undef");
|
|
}
|
|
|
|
// @todo: Remove these two when the code is fixed and they're no longer needed
|
|
Result += " -Wno-logical-op-parentheses";
|
|
Result += " -Wno-unknown-pragmas";
|
|
|
|
Result += " -c";
|
|
|
|
Result += " -arch x86_64";
|
|
Result += " -isysroot " + Settings.BaseSDKDir + "/MacOSX" + Settings.MacOSSDKVersion + ".sdk";
|
|
Result += " -mmacosx-version-min=" + (CompileEnvironment.bEnableOSX109Support ? "10.9" : Settings.MacOSVersion);
|
|
|
|
// Optimize non- debug builds.
|
|
// Don't optimise if using AddressSanitizer or you'll get false positive errors due to erroneous optimisation of necessary AddressSanitizer instrumentation.
|
|
if (CompileEnvironment.bOptimizeCode && (SanitizerMode == null || SanitizerMode != "YES"))
|
|
{
|
|
if (CompileEnvironment.bOptimizeForSize)
|
|
{
|
|
Result += " -Oz";
|
|
}
|
|
else
|
|
{
|
|
Result += " -O3";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Result += " -O0";
|
|
}
|
|
|
|
// Create DWARF format debug info if wanted,
|
|
if (CompileEnvironment.bCreateDebugInfo)
|
|
{
|
|
Result += " -gdwarf-2";
|
|
}
|
|
|
|
string StaticAnalysisMode = Environment.GetEnvironmentVariable("CLANG_STATIC_ANALYZER_MODE");
|
|
if(StaticAnalysisMode != null && StaticAnalysisMode != "")
|
|
{
|
|
Result += " --analyze";
|
|
}
|
|
|
|
return Result;
|
|
}
|
|
|
|
static string GetCompileArguments_CPP()
|
|
{
|
|
string Result = "";
|
|
Result += " -x objective-c++";
|
|
Result += " -fobjc-abi-version=2";
|
|
Result += " -fobjc-legacy-dispatch";
|
|
Result += " -std=c++14";
|
|
Result += " -stdlib=libc++";
|
|
return Result;
|
|
}
|
|
|
|
static string GetCompileArguments_MM()
|
|
{
|
|
string Result = "";
|
|
Result += " -x objective-c++";
|
|
Result += " -fobjc-abi-version=2";
|
|
Result += " -fobjc-legacy-dispatch";
|
|
Result += " -std=c++14";
|
|
Result += " -stdlib=libc++";
|
|
return Result;
|
|
}
|
|
|
|
static string GetCompileArguments_M()
|
|
{
|
|
string Result = "";
|
|
Result += " -x objective-c";
|
|
Result += " -fobjc-abi-version=2";
|
|
Result += " -fobjc-legacy-dispatch";
|
|
Result += " -std=c++14";
|
|
Result += " -stdlib=libc++";
|
|
return Result;
|
|
}
|
|
|
|
static string GetCompileArguments_C()
|
|
{
|
|
string Result = "";
|
|
Result += " -x c";
|
|
return Result;
|
|
}
|
|
|
|
static string GetCompileArguments_PCH()
|
|
{
|
|
string Result = "";
|
|
Result += " -x objective-c++-header";
|
|
Result += " -fobjc-abi-version=2";
|
|
Result += " -fobjc-legacy-dispatch";
|
|
Result += " -std=c++14";
|
|
Result += " -stdlib=libc++";
|
|
return Result;
|
|
}
|
|
|
|
// Conditionally enable (default disabled) generation of information about every class with virtual functions for use by the C++ runtime type identification features
|
|
// (`dynamic_cast' and `typeid'). If you don't use those parts of the language, you can save some space by using -fno-rtti.
|
|
// Note that exception handling uses the same information, but it will generate it as needed.
|
|
static string GetRTTIFlag(CppCompileEnvironment CompileEnvironment)
|
|
{
|
|
string Result = "";
|
|
|
|
if (CompileEnvironment.bUseRTTI)
|
|
{
|
|
Result = " -frtti";
|
|
}
|
|
else
|
|
{
|
|
Result = " -fno-rtti";
|
|
}
|
|
|
|
return Result;
|
|
}
|
|
|
|
string AddFrameworkToLinkCommand(string FrameworkName, string Arg = "-framework")
|
|
{
|
|
string Result = "";
|
|
if (FrameworkName.EndsWith(".framework"))
|
|
{
|
|
Result += " -F \"" + ConvertPath(Path.GetDirectoryName(Path.GetFullPath(FrameworkName))) + "\"";
|
|
FrameworkName = Path.GetFileNameWithoutExtension(FrameworkName);
|
|
}
|
|
Result += " " + Arg + " \"" + FrameworkName + "\"";
|
|
return Result;
|
|
}
|
|
|
|
string GetLinkArguments_Global(LinkEnvironment LinkEnvironment)
|
|
{
|
|
string Result = "";
|
|
|
|
Result += " -arch x86_64";
|
|
Result += " -isysroot " + Settings.BaseSDKDir + "/MacOSX" + Settings.MacOSSDKVersion + ".sdk";
|
|
Result += " -mmacosx-version-min=" + Settings.MacOSVersion;
|
|
Result += " -dead_strip";
|
|
|
|
string SanitizerMode = Environment.GetEnvironmentVariable("CLANG_ADDRESS_SANITIZER");
|
|
if(SanitizerMode != null && SanitizerMode == "YES")
|
|
{
|
|
Result += " -fsanitize=address";
|
|
}
|
|
|
|
if (LinkEnvironment.bIsBuildingDLL)
|
|
{
|
|
Result += " -dynamiclib";
|
|
}
|
|
|
|
// Needed to make sure install_name_tool will be able to update paths in Mach-O headers
|
|
Result += " -headerpad_max_install_names";
|
|
|
|
Result += " -lc++";
|
|
|
|
return Result;
|
|
}
|
|
|
|
static string GetArchiveArguments_Global(LinkEnvironment LinkEnvironment)
|
|
{
|
|
string Result = "";
|
|
Result += " -static";
|
|
return Result;
|
|
}
|
|
|
|
public override CPPOutput CompileCPPFiles(CppCompileEnvironment CompileEnvironment, List<FileItem> SourceFiles, string ModuleName, ActionGraph ActionGraph)
|
|
{
|
|
var Arguments = new StringBuilder();
|
|
var PCHArguments = new StringBuilder();
|
|
|
|
Arguments.Append(GetCompileArguments_Global(CompileEnvironment));
|
|
|
|
if (CompileEnvironment.PrecompiledHeaderAction == PrecompiledHeaderAction.Include)
|
|
{
|
|
// Add the precompiled header file's path to the include path so GCC can find it.
|
|
// This needs to be before the other include paths to ensure GCC uses it instead of the source header file.
|
|
var PrecompiledFileExtension = UEBuildPlatform.GetBuildPlatform(UnrealTargetPlatform.Mac).GetBinaryExtension(UEBuildBinaryType.PrecompiledHeader);
|
|
PCHArguments.Append(" -include \"");
|
|
PCHArguments.Append(CompileEnvironment.PrecompiledHeaderFile.AbsolutePath.Replace(PrecompiledFileExtension, ""));
|
|
PCHArguments.Append("\"");
|
|
}
|
|
|
|
foreach(FileReference ForceIncludeFile in CompileEnvironment.ForceIncludeFiles)
|
|
{
|
|
PCHArguments.Append(String.Format(" -include \"{0}\"", ForceIncludeFile.FullName));
|
|
}
|
|
|
|
// Add include paths to the argument list.
|
|
HashSet<string> AllIncludes = new HashSet<string>(CompileEnvironment.IncludePaths.UserIncludePaths);
|
|
AllIncludes.UnionWith(CompileEnvironment.IncludePaths.SystemIncludePaths);
|
|
foreach (string IncludePath in AllIncludes)
|
|
{
|
|
Arguments.Append(" -I\"");
|
|
|
|
if (BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Mac)
|
|
{
|
|
Arguments.Append(ConvertPath(Path.GetFullPath(IncludePath)));
|
|
|
|
// sync any third party headers we may need
|
|
if (IncludePath.Contains("ThirdParty"))
|
|
{
|
|
string[] FileList = Directory.GetFiles(IncludePath, "*.h", SearchOption.AllDirectories);
|
|
foreach (string File in FileList)
|
|
{
|
|
FileItem ExternalDependency = FileItem.GetItemByPath(File);
|
|
LocalToRemoteFileItem(ExternalDependency, true);
|
|
}
|
|
|
|
FileList = Directory.GetFiles(IncludePath, "*.cpp", SearchOption.AllDirectories);
|
|
foreach (string File in FileList)
|
|
{
|
|
FileItem ExternalDependency = FileItem.GetItemByPath(File);
|
|
LocalToRemoteFileItem(ExternalDependency, true);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Arguments.Append(IncludePath);
|
|
}
|
|
|
|
Arguments.Append("\"");
|
|
}
|
|
|
|
foreach (string Definition in CompileEnvironment.Definitions)
|
|
{
|
|
string DefinitionArgument = Definition.Contains("\"") ? Definition.Replace("\"", "\\\"") : Definition;
|
|
Arguments.Append(" -D\"");
|
|
Arguments.Append(DefinitionArgument);
|
|
Arguments.Append("\"");
|
|
}
|
|
|
|
CPPOutput Result = new CPPOutput();
|
|
// Create a compile action for each source file.
|
|
foreach (FileItem SourceFile in SourceFiles)
|
|
{
|
|
Action CompileAction = ActionGraph.Add(ActionType.Compile);
|
|
string FileArguments = "";
|
|
string Extension = Path.GetExtension(SourceFile.AbsolutePath).ToUpperInvariant();
|
|
|
|
if (CompileEnvironment.PrecompiledHeaderAction == PrecompiledHeaderAction.Create)
|
|
{
|
|
// Compile the file as a C++ PCH.
|
|
FileArguments += GetCompileArguments_PCH();
|
|
FileArguments += GetRTTIFlag(CompileEnvironment);
|
|
}
|
|
else if (Extension == ".C")
|
|
{
|
|
// Compile the file as C code.
|
|
FileArguments += GetCompileArguments_C();
|
|
}
|
|
else if (Extension == ".CC")
|
|
{
|
|
// Compile the file as C++ code.
|
|
FileArguments += GetCompileArguments_CPP();
|
|
FileArguments += GetRTTIFlag(CompileEnvironment);
|
|
}
|
|
else if (Extension == ".MM")
|
|
{
|
|
// Compile the file as Objective-C++ code.
|
|
FileArguments += GetCompileArguments_MM();
|
|
FileArguments += GetRTTIFlag(CompileEnvironment);
|
|
}
|
|
else if (Extension == ".M")
|
|
{
|
|
// Compile the file as Objective-C++ code.
|
|
FileArguments += GetCompileArguments_M();
|
|
}
|
|
else
|
|
{
|
|
// Compile the file as C++ code.
|
|
FileArguments += GetCompileArguments_CPP();
|
|
FileArguments += GetRTTIFlag(CompileEnvironment);
|
|
|
|
// only use PCH for .cpp files
|
|
FileArguments += PCHArguments.ToString();
|
|
}
|
|
|
|
// Add the C++ source file and its included files to the prerequisite item list.
|
|
AddPrerequisiteSourceFile(CompileEnvironment, SourceFile, CompileAction.PrerequisiteItems);
|
|
|
|
if (CompileEnvironment.PrecompiledHeaderAction == PrecompiledHeaderAction.Create)
|
|
{
|
|
var PrecompiledHeaderExtension = UEBuildPlatform.GetBuildPlatform(UnrealTargetPlatform.Mac).GetBinaryExtension(UEBuildBinaryType.PrecompiledHeader);
|
|
// Add the precompiled header file to the produced item list.
|
|
FileItem PrecompiledHeaderFile = FileItem.GetItemByFileReference(
|
|
FileReference.Combine(
|
|
CompileEnvironment.OutputDirectory,
|
|
Path.GetFileName(SourceFile.AbsolutePath) + PrecompiledHeaderExtension
|
|
)
|
|
);
|
|
|
|
FileItem RemotePrecompiledHeaderFile = LocalToRemoteFileItem(PrecompiledHeaderFile, false);
|
|
CompileAction.ProducedItems.Add(RemotePrecompiledHeaderFile);
|
|
Result.PrecompiledHeaderFile = RemotePrecompiledHeaderFile;
|
|
|
|
// Add the parameters needed to compile the precompiled header file to the command-line.
|
|
FileArguments += string.Format(" -o \"{0}\"", RemotePrecompiledHeaderFile.AbsolutePath);
|
|
}
|
|
else
|
|
{
|
|
if (CompileEnvironment.PrecompiledHeaderAction == PrecompiledHeaderAction.Include)
|
|
{
|
|
CompileAction.bIsUsingPCH = true;
|
|
CompileAction.PrerequisiteItems.Add(CompileEnvironment.PrecompiledHeaderFile);
|
|
}
|
|
var ObjectFileExtension = UEBuildPlatform.GetBuildPlatform(UnrealTargetPlatform.Mac).GetBinaryExtension(UEBuildBinaryType.Object);
|
|
// Add the object file to the produced item list.
|
|
FileItem ObjectFile = FileItem.GetItemByFileReference(
|
|
FileReference.Combine(
|
|
CompileEnvironment.OutputDirectory,
|
|
Path.GetFileName(SourceFile.AbsolutePath) + ObjectFileExtension
|
|
)
|
|
);
|
|
|
|
FileItem RemoteObjectFile = LocalToRemoteFileItem(ObjectFile, false);
|
|
CompileAction.ProducedItems.Add(RemoteObjectFile);
|
|
Result.ObjectFiles.Add(RemoteObjectFile);
|
|
FileArguments += string.Format(" -o \"{0}\"", RemoteObjectFile.AbsolutePath);
|
|
}
|
|
|
|
// Add the source file path to the command-line.
|
|
FileArguments += string.Format(" \"{0}\"", ConvertPath(SourceFile.AbsolutePath));
|
|
|
|
if (BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Mac)
|
|
{
|
|
CompileAction.ActionHandler = new Action.BlockingActionHandler(RPCUtilHelper.RPCActionHandler);
|
|
}
|
|
|
|
CompileAction.WorkingDirectory = GetMacDevSrcRoot();
|
|
CompileAction.CommandPath = Settings.ToolchainDir + MacCompiler;
|
|
CompileAction.CommandArguments = Arguments + FileArguments + CompileEnvironment.AdditionalArguments;
|
|
CompileAction.CommandDescription = "Compile";
|
|
CompileAction.StatusDescription = Path.GetFileName(SourceFile.AbsolutePath);
|
|
CompileAction.bIsGCCCompiler = true;
|
|
// We're already distributing the command by execution on Mac.
|
|
CompileAction.bCanExecuteRemotely = false;
|
|
CompileAction.OutputEventHandler = new DataReceivedEventHandler(RemoteOutputReceivedEventHandler);
|
|
}
|
|
return Result;
|
|
}
|
|
|
|
private void AppendMacLine(StreamWriter Writer, string Format, params object[] Arg)
|
|
{
|
|
string PreLine = String.Format(Format, Arg);
|
|
Writer.Write(PreLine + "\n");
|
|
}
|
|
|
|
private int LoadEngineCL()
|
|
{
|
|
BuildVersion Version;
|
|
if (BuildVersion.TryRead(out Version))
|
|
{
|
|
return Version.Changelist;
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
public static string LoadEngineDisplayVersion(bool bIgnorePatchVersion = false)
|
|
{
|
|
BuildVersion Version;
|
|
if (BuildVersion.TryRead(out Version))
|
|
{
|
|
return String.Format("{0}.{1}.{2}", Version.MajorVersion, Version.MinorVersion, bIgnorePatchVersion? 0 : Version.PatchVersion);
|
|
}
|
|
else
|
|
{
|
|
return "4.0.0";
|
|
}
|
|
}
|
|
|
|
private int LoadBuiltFromChangelistValue()
|
|
{
|
|
return LoadEngineCL();
|
|
}
|
|
|
|
private int LoadIsLicenseeVersionValue()
|
|
{
|
|
BuildVersion Version;
|
|
if (BuildVersion.TryRead(out Version))
|
|
{
|
|
return Version.IsLicenseeVersion;
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
private string LoadEngineAPIVersion()
|
|
{
|
|
int CL = 0;
|
|
|
|
BuildVersion Version;
|
|
if (BuildVersion.TryRead(out Version))
|
|
{
|
|
CL = Version.EffectiveCompatibleChangelist;
|
|
}
|
|
|
|
return String.Format("{0}.{1}.{2}", CL / (100 * 100), (CL / 100) % 100, CL % 100);
|
|
}
|
|
|
|
private void AddLibraryPathToRPaths(string Library, string ExeAbsolutePath, ref List<string> RPaths, ref string LinkCommand, bool bIsBuildingAppBundle)
|
|
{
|
|
string LibraryFullPath = Path.GetFullPath(Library);
|
|
string LibraryDir = Path.GetDirectoryName(LibraryFullPath);
|
|
string ExeDir = Path.GetDirectoryName(ExeAbsolutePath);
|
|
|
|
// Only dylibs and frameworks, and only those that are outside of Engine/Binaries/Mac and Engine/Source/ThirdParty, and outside of the folder where the executable is need an additional RPATH entry
|
|
if ((Library.EndsWith("dylib") || Library.EndsWith(".framework")) && !LibraryFullPath.Contains("/Engine/Binaries/Mac/")
|
|
&& !LibraryFullPath.Contains("/Engine/Source/ThirdParty/") && LibraryDir != ExeDir && !RPaths.Contains(LibraryDir))
|
|
{
|
|
// macOS gatekeeper erroneously complains about not seeing the CEF3 framework in the codesigned Launcher because it's only present in one of the folders specified in RPATHs.
|
|
// To work around this we will only add a single RPATH entry for it, for the framework stored in .app/Contents/UE4/ subfolder of the packaged app bundle
|
|
bool bCanUseMultipleRPATHs = !ExeAbsolutePath.Contains("EpicGamesLauncher-Mac-Shipping") || !Library.Contains("CEF3");
|
|
|
|
// First, add a path relative to the executable.
|
|
string RelativePath = Utils.MakePathRelativeTo(LibraryDir, ExeDir).Replace("\\", "/");
|
|
if (bCanUseMultipleRPATHs)
|
|
{
|
|
LinkCommand += " -rpath \"@loader_path/" + RelativePath + "\"";
|
|
}
|
|
|
|
// If building an app bundle, we also need an RPATH for use in packaged game and a separate one for staged builds
|
|
if (bIsBuildingAppBundle)
|
|
{
|
|
string EngineDir = UnrealBuildTool.RootDirectory.ToString();
|
|
|
|
// In packaged games dylibs are stored in Contents/UE4 subfolders, for example in GameName.app/Contents/UE4/Engine/Binaries/ThirdParty/PhysX/Mac
|
|
string BundleUE4Dir = Path.GetFullPath(ExeDir + "/../../Contents/UE4");
|
|
string BundleLibraryDir = LibraryDir.Replace(EngineDir, BundleUE4Dir);
|
|
string BundleRelativeDir = Utils.MakePathRelativeTo(BundleLibraryDir, ExeDir).Replace("\\", "/");
|
|
LinkCommand += " -rpath \"@loader_path/" + BundleRelativeDir + "\"";
|
|
|
|
// For staged code-based games we need additional entry if the game is not stored directly in the engine's root directory
|
|
if (bCanUseMultipleRPATHs)
|
|
{
|
|
string StagedUE4Dir = Path.GetFullPath(ExeDir + "/../../../../../..");
|
|
string StagedLibraryDir = LibraryDir.Replace(EngineDir, StagedUE4Dir);
|
|
string StagedRelativeDir = Utils.MakePathRelativeTo(StagedLibraryDir, ExeDir).Replace("\\", "/");
|
|
if (StagedRelativeDir != RelativePath)
|
|
{
|
|
LinkCommand += " -rpath \"@loader_path/" + StagedRelativeDir + "\"";
|
|
}
|
|
}
|
|
}
|
|
|
|
RPaths.Add(LibraryDir);
|
|
}
|
|
}
|
|
|
|
public override FileItem LinkFiles(LinkEnvironment LinkEnvironment, bool bBuildImportLibraryOnly, ActionGraph ActionGraph)
|
|
{
|
|
bool bIsBuildingLibrary = LinkEnvironment.bIsBuildingLibrary || bBuildImportLibraryOnly;
|
|
|
|
// Create an action that invokes the linker.
|
|
Action LinkAction = ActionGraph.Add(ActionType.Link);
|
|
|
|
if (BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Mac)
|
|
{
|
|
LinkAction.ActionHandler = new Action.BlockingActionHandler(RPCUtilHelper.RPCActionHandler);
|
|
}
|
|
|
|
LinkAction.WorkingDirectory = GetMacDevSrcRoot();
|
|
LinkAction.CommandPath = "/bin/sh";
|
|
LinkAction.CommandDescription = "Link";
|
|
|
|
string EngineAPIVersion = LoadEngineAPIVersion();
|
|
string EngineDisplayVersion = LoadEngineDisplayVersion(true);
|
|
string VersionArg = LinkEnvironment.bIsBuildingDLL ? " -current_version " + EngineAPIVersion + " -compatibility_version " + EngineDisplayVersion : "";
|
|
|
|
string Linker = bIsBuildingLibrary ? MacArchiver : MacLinker;
|
|
string LinkCommand = Settings.ToolchainDir + Linker + VersionArg + " " + (bIsBuildingLibrary ? GetArchiveArguments_Global(LinkEnvironment) : GetLinkArguments_Global(LinkEnvironment));
|
|
|
|
// Tell the action that we're building an import library here and it should conditionally be
|
|
// ignored as a prerequisite for other actions
|
|
LinkAction.bProducesImportLibrary = !Utils.IsRunningOnMono && (bBuildImportLibraryOnly || LinkEnvironment.bIsBuildingDLL);
|
|
|
|
// Add the output file as a production of the link action.
|
|
FileItem OutputFile = FileItem.GetItemByFileReference(LinkEnvironment.OutputFilePath);
|
|
OutputFile.bNeedsHotReloadNumbersDLLCleanUp = LinkEnvironment.bIsBuildingDLL;
|
|
|
|
FileItem RemoteOutputFile = LocalToRemoteFileItem(OutputFile, false);
|
|
|
|
// To solve the problem with cross dependencies, for now we create a broken dylib that does not link with other engine dylibs.
|
|
// This is fixed in later step, FixDylibDependencies. For this and to know what libraries to copy whilst creating an app bundle,
|
|
// we gather the list of engine dylibs.
|
|
List<string> EngineAndGameLibraries = new List<string>();
|
|
|
|
string DylibsPath = "@rpath";
|
|
|
|
string AbsolutePath = OutputFile.AbsolutePath.Replace("\\", "/");
|
|
if (!bIsBuildingLibrary)
|
|
{
|
|
LinkCommand += " -rpath @loader_path/ -rpath @executable_path/";
|
|
}
|
|
|
|
List<string> ThirdPartyLibraries = new List<string>();
|
|
|
|
if (BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Mac)
|
|
{
|
|
// Add any additional files that we'll need in order to link the app
|
|
foreach (string AdditionalShadowFile in LinkEnvironment.AdditionalShadowFiles)
|
|
{
|
|
FileItem ShadowFile = FileItem.GetExistingItemByPath(AdditionalShadowFile);
|
|
if (ShadowFile != null)
|
|
{
|
|
QueueFileForBatchUpload(ShadowFile);
|
|
LinkAction.PrerequisiteItems.Add(ShadowFile);
|
|
}
|
|
else
|
|
{
|
|
throw new BuildException("Couldn't find required additional file to shadow: {0}", AdditionalShadowFile);
|
|
}
|
|
}
|
|
|
|
// Add any frameworks to be shadowed to the remote
|
|
foreach (string FrameworkPath in LinkEnvironment.Frameworks)
|
|
{
|
|
if (FrameworkPath.EndsWith(".framework"))
|
|
{
|
|
foreach (string FrameworkFile in Directory.EnumerateFiles(FrameworkPath, "*", SearchOption.AllDirectories))
|
|
{
|
|
FileItem FrameworkFileItem = FileItem.GetExistingItemByPath(FrameworkFile);
|
|
QueueFileForBatchUpload(FrameworkFileItem);
|
|
LinkAction.PrerequisiteItems.Add(FrameworkFileItem);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
bool bIsBuildingAppBundle = !LinkEnvironment.bIsBuildingDLL && !LinkEnvironment.bIsBuildingLibrary && !LinkEnvironment.bIsBuildingConsoleApplication;
|
|
|
|
List<string> RPaths = new List<string>();
|
|
|
|
if (!bIsBuildingLibrary || LinkEnvironment.bIncludeDependentLibrariesInLibrary)
|
|
{
|
|
// Add the additional libraries to the argument list.
|
|
foreach (string AdditionalLibrary in LinkEnvironment.AdditionalLibraries)
|
|
{
|
|
// Can't link dynamic libraries when creating a static one
|
|
if (bIsBuildingLibrary && (Path.GetExtension(AdditionalLibrary) == ".dylib" || AdditionalLibrary == "z"))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (Path.GetDirectoryName(AdditionalLibrary) != "" &&
|
|
(Path.GetDirectoryName(AdditionalLibrary).Contains("Binaries/Mac") ||
|
|
Path.GetDirectoryName(AdditionalLibrary).Contains("Binaries\\Mac")))
|
|
{
|
|
// It's an engine or game dylib. Save it for later
|
|
EngineAndGameLibraries.Add(ConvertPath(Path.GetFullPath(AdditionalLibrary)));
|
|
|
|
if (!Utils.IsRunningOnMono)
|
|
{
|
|
FileItem EngineLibDependency = FileItem.GetItemByPath(AdditionalLibrary);
|
|
LinkAction.PrerequisiteItems.Add(EngineLibDependency);
|
|
FileItem RemoteEngineLibDependency = FileItem.GetRemoteItemByPath(ConvertPath(Path.GetFullPath(AdditionalLibrary)), UnrealTargetPlatform.Mac);
|
|
LinkAction.PrerequisiteItems.Add(RemoteEngineLibDependency);
|
|
//Log.TraceInformation("Adding {0} / {1} as a prereq to {2}", EngineLibDependency.AbsolutePath, RemoteEngineLibDependency.AbsolutePath, RemoteOutputFile.AbsolutePath);
|
|
}
|
|
else if (LinkEnvironment.bIsCrossReferenced == false)
|
|
{
|
|
FileItem EngineLibDependency = FileItem.GetItemByPath(AdditionalLibrary);
|
|
LinkAction.PrerequisiteItems.Add(EngineLibDependency);
|
|
}
|
|
}
|
|
else if (AdditionalLibrary.Contains(".framework/"))
|
|
{
|
|
LinkCommand += string.Format(" \'{0}\'", AdditionalLibrary);
|
|
}
|
|
else if (string.IsNullOrEmpty(Path.GetDirectoryName(AdditionalLibrary)) && string.IsNullOrEmpty(Path.GetExtension(AdditionalLibrary)))
|
|
{
|
|
LinkCommand += string.Format(" -l{0}", AdditionalLibrary);
|
|
}
|
|
else
|
|
{
|
|
LinkCommand += string.Format(" \"{0}\"", ConvertPath(Path.GetFullPath(AdditionalLibrary)));
|
|
if (Path.GetExtension(AdditionalLibrary) == ".dylib")
|
|
{
|
|
ThirdPartyLibraries.Add(AdditionalLibrary);
|
|
}
|
|
|
|
if (BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Mac)
|
|
{
|
|
// copy over libs we may need
|
|
FileItem ShadowFile = FileItem.GetExistingItemByPath(AdditionalLibrary);
|
|
if (ShadowFile != null)
|
|
{
|
|
QueueFileForBatchUpload(ShadowFile);
|
|
}
|
|
}
|
|
}
|
|
|
|
AddLibraryPathToRPaths(AdditionalLibrary, AbsolutePath, ref RPaths, ref LinkCommand, bIsBuildingAppBundle);
|
|
}
|
|
|
|
foreach (string AdditionalLibrary in LinkEnvironment.DelayLoadDLLs)
|
|
{
|
|
// Can't link dynamic libraries when creating a static one
|
|
if (bIsBuildingLibrary && (Path.GetExtension(AdditionalLibrary) == ".dylib" || AdditionalLibrary == "z"))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
LinkCommand += string.Format(" -weak_library \"{0}\"", ConvertPath(Path.GetFullPath(AdditionalLibrary)));
|
|
|
|
AddLibraryPathToRPaths(AdditionalLibrary, AbsolutePath, ref RPaths, ref LinkCommand, bIsBuildingAppBundle);
|
|
|
|
if (BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Mac)
|
|
{
|
|
// copy over libs we may need
|
|
FileItem ShadowFile = FileItem.GetExistingItemByPath(AdditionalLibrary);
|
|
if (ShadowFile != null)
|
|
{
|
|
QueueFileForBatchUpload(ShadowFile);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Add frameworks
|
|
Dictionary<string, bool> AllFrameworks = new Dictionary<string, bool>();
|
|
foreach (string Framework in LinkEnvironment.Frameworks)
|
|
{
|
|
if (!AllFrameworks.ContainsKey(Framework))
|
|
{
|
|
AllFrameworks.Add(Framework, false);
|
|
}
|
|
}
|
|
foreach (UEBuildFramework Framework in LinkEnvironment.AdditionalFrameworks)
|
|
{
|
|
if (!AllFrameworks.ContainsKey(Framework.FrameworkName))
|
|
{
|
|
AllFrameworks.Add(Framework.FrameworkName, false);
|
|
}
|
|
}
|
|
foreach (string Framework in LinkEnvironment.WeakFrameworks)
|
|
{
|
|
if (!AllFrameworks.ContainsKey(Framework))
|
|
{
|
|
AllFrameworks.Add(Framework, true);
|
|
}
|
|
}
|
|
|
|
if (!bIsBuildingLibrary)
|
|
{
|
|
foreach (var Framework in AllFrameworks)
|
|
{
|
|
LinkCommand += AddFrameworkToLinkCommand(Framework.Key, Framework.Value ? "-weak_framework" : "-framework");
|
|
AddLibraryPathToRPaths(Framework.Key, AbsolutePath, ref RPaths, ref LinkCommand, bIsBuildingAppBundle);
|
|
}
|
|
}
|
|
|
|
// Add the input files to a response file, and pass the response file on the command-line.
|
|
List<string> InputFileNames = new List<string>();
|
|
foreach (FileItem InputFile in LinkEnvironment.InputFiles)
|
|
{
|
|
if (bIsBuildingLibrary)
|
|
{
|
|
InputFileNames.Add(string.Format("\"{0}\"", InputFile.AbsolutePath));
|
|
}
|
|
else
|
|
{
|
|
string EnginePath = ConvertPath(Path.GetDirectoryName(Directory.GetCurrentDirectory()));
|
|
string InputFileRelativePath = InputFile.AbsolutePath.Replace(EnginePath, "..");
|
|
InputFileNames.Add(string.Format("\"{0}\"", InputFileRelativePath));
|
|
}
|
|
LinkAction.PrerequisiteItems.Add(InputFile);
|
|
}
|
|
|
|
if (bIsBuildingLibrary)
|
|
{
|
|
foreach (string Filename in InputFileNames)
|
|
{
|
|
LinkCommand += " " + Filename;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Write the list of input files to a response file, with a tempfilename, on remote machine
|
|
FileReference ResponsePath = FileReference.Combine(LinkEnvironment.IntermediateDirectory, Path.GetFileName(OutputFile.AbsolutePath) + ".response");
|
|
|
|
// Never create response files when we are only generating IntelliSense data
|
|
if (!ProjectFileGenerator.bGenerateProjectFiles)
|
|
{
|
|
ResponseFile.Create(ResponsePath, InputFileNames);
|
|
|
|
if (BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Mac)
|
|
{
|
|
RPCUtilHelper.CopyFile(ResponsePath.FullName, ConvertPath(ResponsePath.FullName), true);
|
|
}
|
|
}
|
|
|
|
LinkCommand += string.Format(" @\"{0}\"", ConvertPath(ResponsePath.FullName));
|
|
}
|
|
|
|
if (LinkEnvironment.bIsBuildingDLL)
|
|
{
|
|
// Add the output file to the command-line.
|
|
string Filename = "";
|
|
int Index = OutputFile.AbsolutePath.LastIndexOf(".app/Contents/MacOS/");
|
|
if (Index > -1)
|
|
{
|
|
Index += ".app/Contents/MacOS/".Length;
|
|
Filename = OutputFile.AbsolutePath.Substring(Index);
|
|
}
|
|
else
|
|
{
|
|
Filename = Path.GetFileName(OutputFile.AbsolutePath);
|
|
}
|
|
LinkCommand += string.Format(" -install_name {0}/{1}", DylibsPath, Filename);
|
|
}
|
|
|
|
if (!bIsBuildingLibrary)
|
|
{
|
|
if (UnrealBuildTool.IsEngineInstalled() || (Utils.IsRunningOnMono && LinkEnvironment.bIsCrossReferenced == false))
|
|
{
|
|
foreach (string Library in EngineAndGameLibraries)
|
|
{
|
|
string LibraryPath = Library;
|
|
if (!File.Exists(Library))
|
|
{
|
|
string LibraryDir = Path.GetDirectoryName(Library);
|
|
string LibraryName = Path.GetFileName(Library);
|
|
string AppBundleName = "UE4Editor";
|
|
if (LibraryName.Contains("UE4Editor-Mac-"))
|
|
{
|
|
string[] Parts = LibraryName.Split('-');
|
|
AppBundleName += "-" + Parts[1] + "-" + Parts[2];
|
|
}
|
|
AppBundleName += ".app";
|
|
LibraryPath = LibraryDir + "/" + AppBundleName + "/Contents/MacOS/" + LibraryName;
|
|
if (!File.Exists(LibraryPath))
|
|
{
|
|
LibraryPath = Library;
|
|
}
|
|
}
|
|
LinkCommand += " \"" + LibraryPath + "\"";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Tell linker to ignore unresolved symbols, so we don't have a problem with cross dependent dylibs that do not exist yet.
|
|
// This is fixed in later step, FixDylibDependencies.
|
|
LinkCommand += string.Format(" -undefined dynamic_lookup");
|
|
}
|
|
}
|
|
|
|
// Add the output file to the command-line.
|
|
LinkCommand += string.Format(" -o \"{0}\"", RemoteOutputFile.AbsolutePath);
|
|
|
|
// Add the additional arguments specified by the environment.
|
|
LinkCommand += LinkEnvironment.AdditionalArguments;
|
|
|
|
if (!bIsBuildingLibrary)
|
|
{
|
|
// Fix the paths for third party libs
|
|
foreach (string Library in ThirdPartyLibraries)
|
|
{
|
|
string LibraryFileName = Path.GetFileName(Library);
|
|
LinkCommand += "; " + Settings.ToolchainDir + "install_name_tool -change " + LibraryFileName + " " + DylibsPath + "/" + LibraryFileName + " \"" + ConvertPath(OutputFile.AbsolutePath) + "\"";
|
|
}
|
|
}
|
|
|
|
string ReadyFilePath = LinkEnvironment.IntermediateDirectory + "/" + LinkEnvironment.OutputFilePath.GetFileName() + ".ready";
|
|
FileItem DylibReadyOutputFile = FileItem.GetItemByPath(ReadyFilePath);
|
|
FileItem RemoteDylibReadyOutputFile = LocalToRemoteFileItem(DylibReadyOutputFile, false);
|
|
|
|
LinkAction.CommandArguments = "-c '" + LinkCommand + "; echo \"-\" >> \"" + RemoteDylibReadyOutputFile.AbsolutePath + "\"'";
|
|
|
|
// Only execute linking on the local Mac.
|
|
LinkAction.bCanExecuteRemotely = false;
|
|
|
|
LinkAction.StatusDescription = Path.GetFileName(OutputFile.AbsolutePath);
|
|
LinkAction.OutputEventHandler = new DataReceivedEventHandler(RemoteOutputReceivedEventHandler);
|
|
|
|
LinkAction.ProducedItems.Add(RemoteOutputFile);
|
|
LinkAction.ProducedItems.Add(RemoteDylibReadyOutputFile);
|
|
|
|
if (!DirectoryReference.Exists(LinkEnvironment.IntermediateDirectory))
|
|
{
|
|
return OutputFile;
|
|
}
|
|
|
|
if (!bIsBuildingLibrary)
|
|
{
|
|
// Prepare a script that will run later, once every dylibs and the executable are created. This script will be called by action created in FixDylibDependencies()
|
|
FileReference FixDylibDepsScriptPath = FileReference.Combine(LinkEnvironment.LocalShadowDirectory, "FixDylibDependencies.sh");
|
|
if (!bHasWipedFixDylibScript)
|
|
{
|
|
if (FileReference.Exists(FixDylibDepsScriptPath))
|
|
{
|
|
FileReference.Delete(FixDylibDepsScriptPath);
|
|
}
|
|
bHasWipedFixDylibScript = true;
|
|
}
|
|
|
|
if (!DirectoryReference.Exists(LinkEnvironment.LocalShadowDirectory))
|
|
{
|
|
DirectoryReference.CreateDirectory(LinkEnvironment.LocalShadowDirectory);
|
|
}
|
|
|
|
StreamWriter FixDylibDepsScript = File.AppendText(FixDylibDepsScriptPath.FullName);
|
|
|
|
if (LinkEnvironment.bIsCrossReferenced || !Utils.IsRunningOnMono)
|
|
{
|
|
string EngineAndGameLibrariesString = "";
|
|
foreach (string Library in EngineAndGameLibraries)
|
|
{
|
|
EngineAndGameLibrariesString += " \"" + Library + "\"";
|
|
}
|
|
string FixDylibLine = "pushd \"" + ConvertPath(Directory.GetCurrentDirectory()) + "\" > /dev/null; ";
|
|
FixDylibLine += string.Format("TIMESTAMP=`stat -n -f \"%Sm\" -t \"%Y%m%d%H%M.%S\" \"{0}\"`; ", RemoteOutputFile.AbsolutePath);
|
|
FixDylibLine += LinkCommand.Replace("-undefined dynamic_lookup", EngineAndGameLibrariesString).Replace("$", "\\$");
|
|
FixDylibLine += string.Format("; touch -t $TIMESTAMP \"{0}\"; if [[ $? -ne 0 ]]; then exit 1; fi; ", RemoteOutputFile.AbsolutePath);
|
|
FixDylibLine += "popd > /dev/null";
|
|
AppendMacLine(FixDylibDepsScript, FixDylibLine);
|
|
}
|
|
|
|
FixDylibDepsScript.Close();
|
|
|
|
// Prepare a script that will be called by FinalizeAppBundle.sh to copy all necessary third party dylibs to the app bundle
|
|
// This is done this way as FinalizeAppBundle.sh script can be created before all the libraries are processed, so
|
|
// at the time of it's creation we don't have the full list of third party dylibs all modules need.
|
|
FileReference DylibCopyScriptPath = FileReference.Combine(LinkEnvironment.IntermediateDirectory, "DylibCopy.sh");
|
|
if (!bHasWipedCopyDylibScript)
|
|
{
|
|
if (FileReference.Exists(DylibCopyScriptPath))
|
|
{
|
|
FileReference.Delete(DylibCopyScriptPath);
|
|
}
|
|
bHasWipedCopyDylibScript = true;
|
|
}
|
|
string ExistingScript = FileReference.Exists(DylibCopyScriptPath) ? File.ReadAllText(DylibCopyScriptPath.FullName) : "";
|
|
StreamWriter DylibCopyScript = File.AppendText(DylibCopyScriptPath.FullName);
|
|
foreach (string Library in ThirdPartyLibraries)
|
|
{
|
|
string CopyCommandLineEntry = FormatCopyCommand(ConvertPath(Path.GetFullPath(Library)).Replace("$", "\\$"), "$1.app/Contents/MacOS");
|
|
if (!ExistingScript.Contains(CopyCommandLineEntry))
|
|
{
|
|
AppendMacLine(DylibCopyScript, CopyCommandLineEntry);
|
|
}
|
|
}
|
|
DylibCopyScript.Close();
|
|
|
|
// For non-console application, prepare a script that will create the app bundle. It'll be run by FinalizeAppBundle action
|
|
if (bIsBuildingAppBundle)
|
|
{
|
|
FileReference FinalizeAppBundleScriptPath = FileReference.Combine(LinkEnvironment.IntermediateDirectory, "FinalizeAppBundle.sh");
|
|
StreamWriter FinalizeAppBundleScript = File.CreateText(FinalizeAppBundleScriptPath.FullName);
|
|
AppendMacLine(FinalizeAppBundleScript, "#!/bin/sh");
|
|
string BinariesPath = Path.GetDirectoryName(OutputFile.AbsolutePath);
|
|
BinariesPath = Path.GetDirectoryName(BinariesPath.Substring(0, BinariesPath.IndexOf(".app")));
|
|
AppendMacLine(FinalizeAppBundleScript, "cd \"{0}\"", ConvertPath(BinariesPath).Replace("$", "\\$"));
|
|
|
|
string BundleVersion = LinkEnvironment.BundleVersion;
|
|
if(BundleVersion == null)
|
|
{
|
|
BundleVersion = LoadEngineDisplayVersion();
|
|
}
|
|
|
|
string ExeName = Path.GetFileName(OutputFile.AbsolutePath);
|
|
bool bIsLauncherProduct = ExeName.StartsWith("EpicGamesLauncher") || ExeName.StartsWith("EpicGamesBootstrapLauncher");
|
|
string[] ExeNameParts = ExeName.Split('-');
|
|
string GameName = ExeNameParts[0];
|
|
FileReference UProjectFilePath = null;
|
|
|
|
if (GameName == "EpicGamesBootstrapLauncher")
|
|
{
|
|
GameName = "EpicGamesLauncher";
|
|
}
|
|
else if (GameName == "UE4" && ProjectFile != null)
|
|
{
|
|
UProjectFilePath = ProjectFile;
|
|
GameName = UProjectFilePath.GetFileNameWithoutAnyExtensions();
|
|
}
|
|
|
|
AppendMacLine(FinalizeAppBundleScript, "mkdir -p \"{0}.app/Contents/MacOS\"", ExeName);
|
|
AppendMacLine(FinalizeAppBundleScript, "mkdir -p \"{0}.app/Contents/Resources\"", ExeName);
|
|
|
|
// Copy third party dylibs by calling additional script prepared earlier
|
|
AppendMacLine(FinalizeAppBundleScript, "sh \"{0}\" \"{1}\"", ConvertPath(DylibCopyScriptPath.FullName).Replace("$", "\\$"), ExeName);
|
|
|
|
string IconName = "UE4";
|
|
string EngineSourcePath = ConvertPath(Directory.GetCurrentDirectory()).Replace("$", "\\$");
|
|
string CustomResourcesPath = "";
|
|
string CustomBuildPath = "";
|
|
if (UProjectFilePath == null && !UProjectInfo.TryGetProjectFileName(GameName, out UProjectFilePath))
|
|
{
|
|
string[] TargetFiles = Directory.GetFiles(Directory.GetCurrentDirectory(), GameName + ".Target.cs", SearchOption.AllDirectories);
|
|
if (TargetFiles.Length == 1)
|
|
{
|
|
CustomResourcesPath = Path.GetDirectoryName(TargetFiles[0]) + "/Resources/Mac";
|
|
CustomBuildPath = Path.GetDirectoryName(TargetFiles[0]) + "../Build/Mac";
|
|
}
|
|
else
|
|
{
|
|
Log.TraceWarning("Found {0} Target.cs files for {1} in alldir search of directory {2}", TargetFiles.Length, GameName, Directory.GetCurrentDirectory());
|
|
}
|
|
}
|
|
else
|
|
{
|
|
string ResourceParentFolderName = bIsLauncherProduct ? "Application" : GameName;
|
|
CustomResourcesPath = Path.GetDirectoryName(UProjectFilePath.FullName) + "/Source/" + ResourceParentFolderName + "/Resources/Mac";
|
|
CustomBuildPath = Path.GetDirectoryName(UProjectFilePath.FullName) + "/Build/Mac";
|
|
}
|
|
|
|
bool bBuildingEditor = GameName.EndsWith("Editor");
|
|
|
|
// Copy resources
|
|
string DefaultIcon = EngineSourcePath + "/Runtime/Launch/Resources/Mac/" + IconName + ".icns";
|
|
string CustomIcon = "";
|
|
if (bBuildingEditor)
|
|
{
|
|
CustomIcon = DefaultIcon;
|
|
}
|
|
else
|
|
{
|
|
CustomIcon = CustomBuildPath + "/Application.icns";
|
|
if (!File.Exists(CustomIcon))
|
|
{
|
|
CustomIcon = CustomResourcesPath + "/" + GameName + ".icns";
|
|
if (!File.Exists(CustomIcon))
|
|
{
|
|
CustomIcon = DefaultIcon;
|
|
}
|
|
}
|
|
|
|
if (CustomIcon != DefaultIcon)
|
|
{
|
|
QueueFileForBatchUpload(FileItem.GetItemByFileReference(new FileReference(CustomIcon)));
|
|
CustomIcon = ConvertPath(CustomIcon);
|
|
}
|
|
}
|
|
AppendMacLine(FinalizeAppBundleScript, FormatCopyCommand(CustomIcon, String.Format("{0}.app/Contents/Resources/{1}.icns", ExeName, GameName)));
|
|
|
|
if (ExeName.StartsWith("UE4Editor"))
|
|
{
|
|
AppendMacLine(FinalizeAppBundleScript, FormatCopyCommand(String.Format("{0}/Runtime/Launch/Resources/Mac/UProject.icns", EngineSourcePath), String.Format("{0}.app/Contents/Resources/UProject.icns", ExeName)));
|
|
}
|
|
|
|
string InfoPlistFile = CustomResourcesPath + "/Info.plist";
|
|
if (!File.Exists(InfoPlistFile))
|
|
{
|
|
InfoPlistFile = EngineSourcePath + "/Runtime/Launch/Resources/Mac/" + (bBuildingEditor ? "Info-Editor.plist" : "Info.plist");
|
|
}
|
|
else
|
|
{
|
|
QueueFileForBatchUpload(FileItem.GetItemByFileReference(new FileReference(InfoPlistFile)));
|
|
InfoPlistFile = ConvertPath(InfoPlistFile);
|
|
}
|
|
|
|
string TempInfoPlist = "$TMPDIR/TempInfo.plist";
|
|
AppendMacLine(FinalizeAppBundleScript, FormatCopyCommand(InfoPlistFile, TempInfoPlist));
|
|
|
|
// Fix contents of Info.plist
|
|
AppendMacLine(FinalizeAppBundleScript, "sed -i \"\" \"s/\\${0}/{1}/g\" \"{2}\"", "{EXECUTABLE_NAME}", ExeName, TempInfoPlist);
|
|
AppendMacLine(FinalizeAppBundleScript, "sed -i \"\" \"s/\\${0}/{1}/g\" \"{2}\"", "{APP_NAME}", GameName, TempInfoPlist);
|
|
AppendMacLine(FinalizeAppBundleScript, "sed -i \"\" \"s/\\${0}/{1}/g\" \"{2}\"", "{MACOSX_DEPLOYMENT_TARGET}", Settings.MinMacOSVersion, TempInfoPlist);
|
|
AppendMacLine(FinalizeAppBundleScript, "sed -i \"\" \"s/\\${0}/{1}/g\" \"{2}\"", "{ICON_NAME}", GameName, TempInfoPlist);
|
|
AppendMacLine(FinalizeAppBundleScript, "sed -i \"\" \"s/\\${0}/{1}/g\" \"{2}\"", "{BUNDLE_VERSION}", BundleVersion, TempInfoPlist);
|
|
|
|
// Copy it into place
|
|
AppendMacLine(FinalizeAppBundleScript, FormatCopyCommand(TempInfoPlist, String.Format("{0}.app/Contents/Info.plist", ExeName)));
|
|
AppendMacLine(FinalizeAppBundleScript, "chmod 644 \"{0}.app/Contents/Info.plist\"", ExeName);
|
|
|
|
// Generate PkgInfo file
|
|
string TempPkgInfo = "$TMPDIR/TempPkgInfo";
|
|
AppendMacLine(FinalizeAppBundleScript, "echo 'echo -n \"APPL????\"' | bash > \"{0}\"", TempPkgInfo);
|
|
AppendMacLine(FinalizeAppBundleScript, FormatCopyCommand(TempPkgInfo, String.Format("{0}.app/Contents/PkgInfo", ExeName)));
|
|
|
|
// Make sure OS X knows the bundle was updated
|
|
AppendMacLine(FinalizeAppBundleScript, "touch -c \"{0}.app\"", ExeName);
|
|
|
|
FinalizeAppBundleScript.Close();
|
|
|
|
// copy over some needed files
|
|
// @todo mac: Make a QueueDirectoryForBatchUpload
|
|
QueueFileForBatchUpload(FileItem.GetItemByFileReference(new FileReference("../../Engine/Source/Runtime/Launch/Resources/Mac/" + GameName + ".icns")));
|
|
QueueFileForBatchUpload(FileItem.GetItemByFileReference(new FileReference("../../Engine/Source/Runtime/Launch/Resources/Mac/UProject.icns")));
|
|
QueueFileForBatchUpload(FileItem.GetItemByFileReference(new FileReference("../../Engine/Source/Runtime/Launch/Resources/Mac/Info.plist")));
|
|
QueueFileForBatchUpload(FileItem.GetItemByFileReference(FileReference.Combine(LinkEnvironment.IntermediateDirectory, "DylibCopy.sh")));
|
|
}
|
|
}
|
|
|
|
return RemoteOutputFile;
|
|
}
|
|
|
|
static string FormatCopyCommand(string SourceFile, string TargetFile)
|
|
{
|
|
return String.Format("rsync --checksum \"{0}\" \"{1}\"", SourceFile, TargetFile);
|
|
}
|
|
|
|
FileItem FixDylibDependencies(LinkEnvironment LinkEnvironment, FileItem Executable, ActionGraph ActionGraph)
|
|
{
|
|
Action LinkAction = ActionGraph.Add(ActionType.Link);
|
|
LinkAction.WorkingDirectory = UnrealBuildTool.EngineSourceDirectory.FullName;
|
|
LinkAction.CommandPath = "/bin/sh";
|
|
LinkAction.CommandDescription = "";
|
|
|
|
// Call the FixDylibDependencies.sh script which will link the dylibs and the main executable, this time proper ones, as it's called
|
|
// once all are already created, so the cross dependency problem no longer prevents linking.
|
|
// The script is deleted after it's executed so it's empty when we start appending link commands for the next executable.
|
|
FileItem FixDylibDepsScript = FileItem.GetItemByFileReference(FileReference.Combine(LinkEnvironment.LocalShadowDirectory, "FixDylibDependencies.sh"));
|
|
FileItem RemoteFixDylibDepsScript = LocalToRemoteFileItem(FixDylibDepsScript, true);
|
|
|
|
LinkAction.CommandArguments = "-c 'chmod +x \"" + RemoteFixDylibDepsScript.AbsolutePath + "\"; \"" + RemoteFixDylibDepsScript.AbsolutePath + "\"; if [[ $? -ne 0 ]]; then exit 1; fi; ";
|
|
|
|
if (BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Mac)
|
|
{
|
|
LinkAction.ActionHandler = new Action.BlockingActionHandler(RPCUtilHelper.RPCActionHandler);
|
|
}
|
|
|
|
// Make sure this action is executed after all the dylibs and the main executable are created
|
|
|
|
foreach (FileItem Dependency in BundleDependencies)
|
|
{
|
|
LinkAction.PrerequisiteItems.Add(Dependency);
|
|
}
|
|
|
|
BundleDependencies.Clear();
|
|
|
|
LinkAction.StatusDescription = string.Format("Fixing dylib dependencies for {0}", Path.GetFileName(Executable.AbsolutePath));
|
|
LinkAction.bCanExecuteRemotely = false;
|
|
|
|
FileItem OutputFile = FileItem.GetItemByFileReference(FileReference.Combine(LinkEnvironment.LocalShadowDirectory, Path.GetFileNameWithoutExtension(Executable.AbsolutePath) + ".link"));
|
|
FileItem RemoteOutputFile = LocalToRemoteFileItem(OutputFile, false);
|
|
|
|
LinkAction.CommandArguments += "echo \"Dummy\" >> \"" + RemoteOutputFile.AbsolutePath + "\"";
|
|
LinkAction.CommandArguments += "'";
|
|
|
|
LinkAction.ProducedItems.Add(RemoteOutputFile);
|
|
|
|
return RemoteOutputFile;
|
|
}
|
|
|
|
private static Dictionary<Action, string> DebugOutputMap = new Dictionary<Action, string>();
|
|
static public void RPCDebugInfoActionHandler(Action Action, out int ExitCode, out string Output)
|
|
{
|
|
RPCUtilHelper.RPCActionHandler(Action, out ExitCode, out Output);
|
|
if (DebugOutputMap.ContainsKey(Action))
|
|
{
|
|
if (ExitCode == 0)
|
|
{
|
|
RPCUtilHelper.CopyDirectory(Action.ProducedItems[0].AbsolutePath, DebugOutputMap[Action], RPCUtilHelper.ECopyOptions.None);
|
|
}
|
|
DebugOutputMap.Remove(Action);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Generates debug info for a given executable
|
|
/// </summary>
|
|
/// <param name="MachOBinary">FileItem describing the executable or dylib to generate debug info for</param>
|
|
/// <param name="LinkEnvironment"></param>
|
|
/// <param name="ActionGraph"></param>
|
|
public FileItem GenerateDebugInfo(FileItem MachOBinary, LinkEnvironment LinkEnvironment, ActionGraph ActionGraph)
|
|
{
|
|
string BinaryPath = MachOBinary.AbsolutePath;
|
|
if (BinaryPath.Contains(".app"))
|
|
{
|
|
while (BinaryPath.Contains(".app"))
|
|
{
|
|
BinaryPath = Path.GetDirectoryName(BinaryPath);
|
|
}
|
|
BinaryPath = Path.Combine(BinaryPath, Path.GetFileName(Path.ChangeExtension(MachOBinary.AbsolutePath, ".dSYM")));
|
|
}
|
|
else
|
|
{
|
|
BinaryPath = Path.ChangeExtension(BinaryPath, ".dSYM");
|
|
}
|
|
|
|
string ReadyFilePath = LinkEnvironment.IntermediateDirectory + "/" + Path.GetFileName(MachOBinary.AbsolutePath) + ".ready";
|
|
FileItem ReadyFile = FileItem.GetItemByPath(ReadyFilePath);
|
|
|
|
FileItem OutputFile = FileItem.GetItemByPath(BinaryPath);
|
|
FileItem DestFile = LocalToRemoteFileItem(OutputFile, false);
|
|
FileItem InputFile = LocalToRemoteFileItem(MachOBinary, false);
|
|
|
|
// Delete on the local machine
|
|
if (Directory.Exists(OutputFile.AbsolutePath))
|
|
{
|
|
Directory.Delete(OutputFile.AbsolutePath, true);
|
|
}
|
|
|
|
// Make the compile action
|
|
Action GenDebugAction = ActionGraph.Add(ActionType.GenerateDebugInfo);
|
|
if (BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Mac)
|
|
{
|
|
DebugOutputMap.Add(GenDebugAction, OutputFile.AbsolutePath);
|
|
GenDebugAction.ActionHandler = new Action.BlockingActionHandler(MacToolChain.RPCDebugInfoActionHandler);
|
|
}
|
|
GenDebugAction.WorkingDirectory = GetMacDevSrcRoot();
|
|
GenDebugAction.CommandPath = "sh";
|
|
|
|
// Deletes ay existing file on the building machine,
|
|
// note that the source and dest are switched from a copy command
|
|
GenDebugAction.CommandArguments = string.Format("-c 'rm -rf \"{2}\"; \"{0}\"dsymutil -f \"{1}\" -o \"{2}\"'",
|
|
Settings.ToolchainDir,
|
|
InputFile.AbsolutePath,
|
|
DestFile.AbsolutePath);
|
|
GenDebugAction.PrerequisiteItems.Add(LocalToRemoteFileItem(ReadyFile, false));
|
|
GenDebugAction.ProducedItems.Add(DestFile);
|
|
GenDebugAction.CommandDescription = "";
|
|
GenDebugAction.StatusDescription = "Generating " + Path.GetFileName(BinaryPath);
|
|
GenDebugAction.bCanExecuteRemotely = false;
|
|
|
|
return DestFile;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates app bundle for a given executable
|
|
/// </summary>
|
|
/// <param name="LinkEnvironment"></param>
|
|
/// <param name="Executable">FileItem describing the executable to generate app bundle for</param>
|
|
/// <param name="FixDylibOutputFile"></param>
|
|
/// <param name="ActionGraph"></param>
|
|
FileItem FinalizeAppBundle(LinkEnvironment LinkEnvironment, FileItem Executable, FileItem FixDylibOutputFile, ActionGraph ActionGraph)
|
|
{
|
|
// Make a file item for the source and destination files
|
|
string FullDestPath = Executable.AbsolutePath.Substring(0, Executable.AbsolutePath.IndexOf(".app") + 4);
|
|
FileItem DestFile = FileItem.GetItemByPath(FullDestPath);
|
|
FileItem RemoteDestFile = LocalToRemoteFileItem(DestFile, false);
|
|
|
|
// Make the compile action
|
|
Action FinalizeAppBundleAction = ActionGraph.Add(ActionType.CreateAppBundle);
|
|
FinalizeAppBundleAction.WorkingDirectory = GetMacDevSrcRoot(); // Path.GetFullPath(".");
|
|
FinalizeAppBundleAction.CommandPath = "/bin/sh";
|
|
FinalizeAppBundleAction.CommandDescription = "";
|
|
|
|
// make path to the script
|
|
FileItem BundleScript = FileItem.GetItemByFileReference(FileReference.Combine(LinkEnvironment.IntermediateDirectory, "FinalizeAppBundle.sh"));
|
|
FileItem RemoteBundleScript = LocalToRemoteFileItem(BundleScript, true);
|
|
|
|
if (BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Mac)
|
|
{
|
|
FinalizeAppBundleAction.ActionHandler = new Action.BlockingActionHandler(RPCUtilHelper.RPCActionHandler);
|
|
}
|
|
|
|
FinalizeAppBundleAction.CommandArguments = "\"" + RemoteBundleScript.AbsolutePath + "\"";
|
|
FinalizeAppBundleAction.PrerequisiteItems.Add(FixDylibOutputFile);
|
|
FinalizeAppBundleAction.ProducedItems.Add(RemoteDestFile);
|
|
FinalizeAppBundleAction.StatusDescription = string.Format("Finalizing app bundle: {0}.app", Path.GetFileName(Executable.AbsolutePath));
|
|
FinalizeAppBundleAction.bCanExecuteRemotely = false;
|
|
|
|
return RemoteDestFile;
|
|
}
|
|
|
|
FileItem CopyBundleResource(UEBuildBundleResource Resource, FileItem Executable, ActionGraph ActionGraph)
|
|
{
|
|
Action CopyAction = ActionGraph.Add(ActionType.CreateAppBundle);
|
|
CopyAction.WorkingDirectory = GetMacDevSrcRoot(); // Path.GetFullPath(".");
|
|
CopyAction.CommandPath = "/bin/sh";
|
|
CopyAction.CommandDescription = "";
|
|
|
|
string BundlePath = Executable.AbsolutePath.Substring(0, Executable.AbsolutePath.IndexOf(".app") + 4);
|
|
string SourcePath = Path.Combine(Path.GetFullPath("."), Resource.ResourcePath);
|
|
string TargetPath = Path.Combine(BundlePath, "Contents", Resource.BundleContentsSubdir, Path.GetFileName(Resource.ResourcePath));
|
|
|
|
FileItem TargetItem;
|
|
if (BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Mac)
|
|
{
|
|
TargetItem = FileItem.GetItemByPath(TargetPath);
|
|
}
|
|
else
|
|
{
|
|
TargetItem = FileItem.GetRemoteItemByPath(TargetPath, RemoteToolChainPlatform);
|
|
}
|
|
|
|
CopyAction.CommandArguments = string.Format("-c 'cp -f -R \"{0}\" \"{1}\"; touch -c \"{2}\"'", ConvertPath(SourcePath), Path.GetDirectoryName(TargetPath).Replace('\\', '/') + "/", TargetPath.Replace('\\', '/'));
|
|
CopyAction.PrerequisiteItems.Add(Executable);
|
|
CopyAction.ProducedItems.Add(TargetItem);
|
|
CopyAction.bShouldOutputStatusDescription = Resource.bShouldLog;
|
|
CopyAction.StatusDescription = string.Format("Copying {0} to app bundle", Path.GetFileName(Resource.ResourcePath));
|
|
CopyAction.bCanExecuteRemotely = false;
|
|
|
|
if (BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Mac)
|
|
{
|
|
CopyAction.ActionHandler = new Action.BlockingActionHandler(RPCUtilHelper.RPCActionHandler);
|
|
}
|
|
|
|
if (Directory.Exists(Resource.ResourcePath))
|
|
{
|
|
foreach (string ResourceFile in Directory.GetFiles(Resource.ResourcePath, "*", SearchOption.AllDirectories))
|
|
{
|
|
QueueFileForBatchUpload(FileItem.GetItemByFileReference(new FileReference(ResourceFile)));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
QueueFileForBatchUpload(FileItem.GetItemByFileReference(new FileReference(SourcePath)));
|
|
}
|
|
|
|
return TargetItem;
|
|
}
|
|
|
|
public override void SetupBundleDependencies(List<UEBuildBinary> Binaries, string GameName)
|
|
{
|
|
base.SetupBundleDependencies(Binaries, GameName);
|
|
|
|
foreach (UEBuildBinary Binary in Binaries)
|
|
{
|
|
BundleDependencies.Add(FileItem.GetItemByFileReference(Binary.Config.OutputFilePath));
|
|
}
|
|
}
|
|
|
|
public override void FixBundleBinariesPaths(UEBuildTarget Target, List<UEBuildBinary> Binaries)
|
|
{
|
|
base.FixBundleBinariesPaths(Target, Binaries);
|
|
|
|
string BundleContentsPath = Target.OutputPath.FullName + ".app/Contents/";
|
|
foreach (UEBuildBinary Binary in Binaries)
|
|
{
|
|
string BinaryFileName = Path.GetFileName(Binary.Config.OutputFilePath.FullName);
|
|
if (BinaryFileName.EndsWith(".dylib"))
|
|
{
|
|
// Only dylibs from the same folder as the executable should be moved to the bundle. UE4Editor-*Game* dylibs and plugins will be loaded
|
|
// from their Binaries/Mac folders.
|
|
string DylibDir = Path.GetDirectoryName(Path.GetFullPath(Binary.Config.OutputFilePath.FullName));
|
|
string ExeDir = Path.GetDirectoryName(Path.GetFullPath(Target.OutputPath.FullName));
|
|
if (DylibDir.StartsWith(ExeDir))
|
|
{
|
|
// get the subdir, which is the DylibDir - ExeDir
|
|
string SubDir = DylibDir.Replace(ExeDir, "");
|
|
Binary.Config.OutputFilePaths[0] = new FileReference(BundleContentsPath + "MacOS" + SubDir + "/" + BinaryFileName);
|
|
}
|
|
}
|
|
else if (!BinaryFileName.EndsWith(".a") && !Binary.Config.OutputFilePath.FullName.Contains(".app/Contents/MacOS/")) // Binaries can contain duplicates
|
|
{
|
|
Binary.Config.OutputFilePaths[0] += ".app/Contents/MacOS/" + BinaryFileName;
|
|
}
|
|
}
|
|
}
|
|
|
|
static private DirectoryReference BundleContentsDirectory;
|
|
|
|
public static Dictionary<UEBuildBinary, Dictionary<FileReference, BuildProductType>> AllBuildProducts = new Dictionary<UEBuildBinary, Dictionary<FileReference, BuildProductType>>();
|
|
|
|
public override void ModifyBuildProducts(ReadOnlyTargetRules Target, UEBuildBinary Binary, List<string> Libraries, List<UEBuildBundleResource> BundleResources, Dictionary<FileReference, BuildProductType> BuildProducts)
|
|
{
|
|
if (Target.bUsePDBFiles == true)
|
|
{
|
|
KeyValuePair<FileReference, BuildProductType>[] BuildProductsArray = BuildProducts.ToArray();
|
|
|
|
foreach (KeyValuePair<FileReference, BuildProductType> BuildProductPair in BuildProductsArray)
|
|
{
|
|
string DebugExtension = "";
|
|
switch (BuildProductPair.Value)
|
|
{
|
|
case BuildProductType.Executable:
|
|
DebugExtension = UEBuildPlatform.GetBuildPlatform(Target.Platform).GetDebugInfoExtension(Target, UEBuildBinaryType.Executable);
|
|
break;
|
|
case BuildProductType.DynamicLibrary:
|
|
DebugExtension = UEBuildPlatform.GetBuildPlatform(Target.Platform).GetDebugInfoExtension(Target, UEBuildBinaryType.DynamicLinkLibrary);
|
|
break;
|
|
}
|
|
if (DebugExtension == ".dSYM")
|
|
{
|
|
string BinaryPath = BuildProductPair.Key.FullName;
|
|
if(BinaryPath.Contains(".app"))
|
|
{
|
|
while(BinaryPath.Contains(".app"))
|
|
{
|
|
BinaryPath = Path.GetDirectoryName(BinaryPath);
|
|
}
|
|
BinaryPath = Path.Combine(BinaryPath, BuildProductPair.Key.GetFileName());
|
|
BinaryPath = Path.ChangeExtension(BinaryPath, DebugExtension);
|
|
FileReference Ref = new FileReference(BinaryPath);
|
|
BuildProducts[Ref] = BuildProductType.SymbolFile;
|
|
}
|
|
}
|
|
else if(BuildProductPair.Value == BuildProductType.SymbolFile && BuildProductPair.Key.FullName.Contains(".app"))
|
|
{
|
|
BuildProducts.Remove(BuildProductPair.Key);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (Target.bIsBuildingConsoleApplication)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (BundleContentsDirectory == null && Binary.Config.Type == UEBuildBinaryType.Executable)
|
|
{
|
|
BundleContentsDirectory = Binary.Config.OutputFilePath.Directory.ParentDirectory;
|
|
}
|
|
|
|
// We need to know what third party dylibs would be copied to the bundle
|
|
if (Binary.Config.Type != UEBuildBinaryType.StaticLibrary)
|
|
{
|
|
foreach (string AdditionalLibrary in Libraries)
|
|
{
|
|
string LibName = Path.GetFileName(AdditionalLibrary);
|
|
if (LibName.StartsWith("lib"))
|
|
{
|
|
if (Path.GetExtension(AdditionalLibrary) == ".dylib" && BundleContentsDirectory != null)
|
|
{
|
|
FileReference Entry = FileReference.Combine(BundleContentsDirectory, "MacOS", LibName);
|
|
if (!BuildProducts.ContainsKey(Entry))
|
|
{
|
|
BuildProducts.Add(Entry, BuildProductType.DynamicLibrary);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach (UEBuildBundleResource Resource in BundleResources)
|
|
{
|
|
if (Directory.Exists(Resource.ResourcePath))
|
|
{
|
|
foreach (string ResourceFile in Directory.GetFiles(Resource.ResourcePath, "*", SearchOption.AllDirectories))
|
|
{
|
|
BuildProducts.Add(FileReference.Combine(BundleContentsDirectory, Resource.BundleContentsSubdir, ResourceFile.Substring(Path.GetDirectoryName(Resource.ResourcePath).Length + 1)), BuildProductType.RequiredResource);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
BuildProducts.Add(FileReference.Combine(BundleContentsDirectory, Resource.BundleContentsSubdir, Path.GetFileName(Resource.ResourcePath)), BuildProductType.RequiredResource);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (Binary.Config.Type == UEBuildBinaryType.Executable)
|
|
{
|
|
// And we also need all the resources
|
|
BuildProducts.Add(FileReference.Combine(BundleContentsDirectory, "Info.plist"), BuildProductType.RequiredResource);
|
|
BuildProducts.Add(FileReference.Combine(BundleContentsDirectory, "PkgInfo"), BuildProductType.RequiredResource);
|
|
|
|
if (Target.Type == TargetType.Editor)
|
|
{
|
|
BuildProducts.Add(FileReference.Combine(BundleContentsDirectory, "Resources/UE4Editor.icns"), BuildProductType.RequiredResource);
|
|
BuildProducts.Add(FileReference.Combine(BundleContentsDirectory, "Resources/UProject.icns"), BuildProductType.RequiredResource);
|
|
}
|
|
else
|
|
{
|
|
string IconName = Target.Name;
|
|
if (IconName == "EpicGamesBootstrapLauncher")
|
|
{
|
|
IconName = "EpicGamesLauncher";
|
|
}
|
|
BuildProducts.Add(FileReference.Combine(BundleContentsDirectory, "Resources/" + IconName + ".icns"), BuildProductType.RequiredResource);
|
|
}
|
|
}
|
|
|
|
AllBuildProducts.Add(Binary, new Dictionary<FileReference, BuildProductType>(BuildProducts));
|
|
}
|
|
|
|
// @todo Mac: Full implementation.
|
|
public override void CompileCSharpProject(CSharpEnvironment CompileEnvironment, FileReference ProjectFileName, FileReference DestinationFile, ActionGraph ActionGraph)
|
|
{
|
|
string ProjectDirectory = Path.GetDirectoryName(ProjectFileName.FullName);
|
|
|
|
if (BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Mac)
|
|
{
|
|
RPCUtilHelper.CopyFile(ProjectFileName.FullName, ConvertPath(ProjectFileName.FullName), true);
|
|
RPCUtilHelper.CopyFile("Engine/Source/Programs/DotNETCommon/MetaData.cs", ConvertPath("Engine/Source/Programs/DotNETCommon/MetaData.cs"), true);
|
|
|
|
string[] FileList = Directory.GetFiles(ProjectDirectory, "*.cs", SearchOption.AllDirectories);
|
|
foreach (string File in FileList)
|
|
{
|
|
RPCUtilHelper.CopyFile(File, ConvertPath(File), true);
|
|
}
|
|
}
|
|
|
|
string XBuildArgs = "/verbosity:quiet /nologo /target:Rebuild /property:Configuration=Development /property:Platform=AnyCPU " + ProjectFileName.GetFileName();
|
|
|
|
if (BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Mac)
|
|
{
|
|
RPCUtilHelper.Command(ConvertPath(ProjectDirectory), "xbuild", XBuildArgs, null);
|
|
}
|
|
else
|
|
{
|
|
Process XBuildProcess = new Process();
|
|
XBuildProcess.StartInfo.WorkingDirectory = ProjectDirectory;
|
|
XBuildProcess.StartInfo.FileName = "sh";
|
|
XBuildProcess.StartInfo.Arguments = "-c 'xbuild " + XBuildArgs + " |grep -i error; if [ $? -ne 1 ]; then exit 1; else exit 0; fi'";
|
|
XBuildProcess.OutputDataReceived += new DataReceivedEventHandler(OutputReceivedDataEventHandler);
|
|
XBuildProcess.ErrorDataReceived += new DataReceivedEventHandler(OutputReceivedDataEventHandler);
|
|
Utils.RunLocalProcess(XBuildProcess);
|
|
}
|
|
}
|
|
|
|
public static void PostBuildSync(UEBuildTarget InTarget)
|
|
{
|
|
if (BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Mac)
|
|
{
|
|
List<string> BuiltBinaries = new List<string>();
|
|
foreach (UEBuildBinary Binary in InTarget.AppBinaries)
|
|
{
|
|
BuiltBinaries.Add(Path.GetFullPath(Binary.ToString()));
|
|
BuiltBinaries.Add(Path.GetFullPath(Binary.ToString() + ".ready"));
|
|
|
|
string DebugExtension = UEBuildPlatform.GetBuildPlatform(InTarget.Platform).GetDebugInfoExtension(InTarget.Rules, Binary.Config.Type);
|
|
if (DebugExtension == ".dSYM")
|
|
{
|
|
Dictionary<FileReference, BuildProductType> BuildProducts = AllBuildProducts[Binary];
|
|
foreach (KeyValuePair<FileReference, BuildProductType> BuildProductPair in BuildProducts)
|
|
{
|
|
if (BuildProductPair.Value == BuildProductType.SymbolFile)
|
|
{
|
|
BuiltBinaries.Add(BuildProductPair.Key.FullName);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
string IntermediateDirectory = InTarget.EngineIntermediateDirectory.FullName;
|
|
if (!Directory.Exists(IntermediateDirectory))
|
|
{
|
|
IntermediateDirectory = Path.GetFullPath("../../" + InTarget.AppName + "/Intermediate/Build/Mac/" + InTarget.AppName + "/" + InTarget.Configuration);
|
|
if (!Directory.Exists(IntermediateDirectory))
|
|
{
|
|
IntermediateDirectory = Path.GetFullPath("../../Engine/Intermediate/Build/Mac/" + InTarget.AppName + "/" + InTarget.Configuration);
|
|
}
|
|
}
|
|
|
|
string FixDylibDepsScript = Path.Combine(IntermediateDirectory, "FixDylibDependencies.sh");
|
|
string FinalizeAppBundleScript = Path.Combine(IntermediateDirectory, "FinalizeAppBundle.sh");
|
|
|
|
string RemoteWorkingDir = "";
|
|
|
|
bool bIsStaticLibrary = InTarget.OutputPath.HasExtension(".a");
|
|
|
|
if (!bIsStaticLibrary)
|
|
{
|
|
// Copy the command scripts to the intermediate on the target Mac.
|
|
string RemoteFixDylibDepsScript = ConvertPath(Path.GetFullPath(FixDylibDepsScript));
|
|
RemoteFixDylibDepsScript = RemoteFixDylibDepsScript.Replace("../../../../", "../../");
|
|
RPCUtilHelper.CopyFile(Path.GetFullPath(FixDylibDepsScript), RemoteFixDylibDepsScript, true);
|
|
|
|
if (!InTarget.Rules.bIsBuildingConsoleApplication)
|
|
{
|
|
string RemoteFinalizeAppBundleScript = ConvertPath(Path.GetFullPath(FinalizeAppBundleScript));
|
|
RemoteFinalizeAppBundleScript = RemoteFinalizeAppBundleScript.Replace("../../../../", "../../");
|
|
RPCUtilHelper.CopyFile(Path.GetFullPath(FinalizeAppBundleScript), RemoteFinalizeAppBundleScript, true);
|
|
}
|
|
|
|
|
|
// run it remotely
|
|
RemoteWorkingDir = ConvertPath(Path.GetDirectoryName(Path.GetFullPath(FixDylibDepsScript)));
|
|
|
|
Log.TraceInformation("Running FixDylibDependencies.sh...");
|
|
Hashtable Results = RPCUtilHelper.Command(RemoteWorkingDir, "/bin/sh", "FixDylibDependencies.sh", null);
|
|
if (Results != null)
|
|
{
|
|
string Result = (string)Results["CommandOutput"];
|
|
if (Result != null)
|
|
{
|
|
Log.TraceInformation(Result);
|
|
}
|
|
}
|
|
|
|
if (!InTarget.Rules.bIsBuildingConsoleApplication)
|
|
{
|
|
Log.TraceInformation("Running FinalizeAppBundle.sh...");
|
|
Results = RPCUtilHelper.Command(RemoteWorkingDir, "/bin/sh", "FinalizeAppBundle.sh", null);
|
|
if (Results != null)
|
|
{
|
|
string Result = (string)Results["CommandOutput"];
|
|
if (Result != null)
|
|
{
|
|
Log.TraceInformation(Result);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// If it is requested, send the app bundle back to the platform executing these commands.
|
|
if (InTarget.Rules.bCopyAppBundleBackToDevice)
|
|
{
|
|
Log.TraceInformation("Copying binaries back to this device...");
|
|
|
|
try
|
|
{
|
|
string BinaryDir = InTarget.OutputPath.Directory + "\\";
|
|
if (BinaryDir.EndsWith(InTarget.AppName + "\\Binaries\\Mac\\") && InTarget.TargetType != TargetType.Game)
|
|
{
|
|
BinaryDir = BinaryDir.Replace(InTarget.TargetType.ToString(), "Game");
|
|
}
|
|
|
|
string RemoteBinariesDir = ConvertPath(BinaryDir);
|
|
string LocalBinariesDir = BinaryDir;
|
|
|
|
// Get the app bundle's name
|
|
string AppFullName = InTarget.AppName;
|
|
if (InTarget.Configuration != InTarget.Rules.UndecoratedConfiguration)
|
|
{
|
|
AppFullName += "-" + InTarget.Platform.ToString();
|
|
AppFullName += "-" + InTarget.Configuration.ToString();
|
|
}
|
|
|
|
if (!InTarget.Rules.bIsBuildingConsoleApplication)
|
|
{
|
|
AppFullName += ".app";
|
|
}
|
|
|
|
List<string> NotBundledBinaries = new List<string>();
|
|
foreach (string BinaryPath in BuiltBinaries)
|
|
{
|
|
if (InTarget.Rules.bIsBuildingConsoleApplication || bIsStaticLibrary || !BinaryPath.StartsWith(LocalBinariesDir + AppFullName))
|
|
{
|
|
NotBundledBinaries.Add(BinaryPath);
|
|
}
|
|
}
|
|
|
|
// Zip the app bundle for transferring.
|
|
if (!InTarget.Rules.bIsBuildingConsoleApplication && !bIsStaticLibrary)
|
|
{
|
|
string ZipCommand = "zip -0 -r -y -T \"" + AppFullName + ".zip\" \"" + AppFullName + "\"";
|
|
RPCUtilHelper.Command(RemoteBinariesDir, ZipCommand, "", null);
|
|
|
|
// Copy the AppBundle back to the source machine
|
|
string LocalZipFileLocation = LocalBinariesDir + AppFullName + ".zip ";
|
|
string RemoteZipFileLocation = RemoteBinariesDir + AppFullName + ".zip";
|
|
|
|
RPCUtilHelper.CopyFile(RemoteZipFileLocation, LocalZipFileLocation, false);
|
|
|
|
// Extract the copied app bundle (in zip format) to the local binaries directory
|
|
using (ZipFile AppBundleZip = ZipFile.Read(LocalZipFileLocation))
|
|
{
|
|
foreach (ZipEntry Entry in AppBundleZip)
|
|
{
|
|
Entry.Extract(LocalBinariesDir, ExtractExistingFileAction.OverwriteSilently);
|
|
}
|
|
}
|
|
|
|
// Delete the zip as we no longer need/want it.
|
|
File.Delete(LocalZipFileLocation);
|
|
RPCUtilHelper.Command(RemoteBinariesDir, "rm -f \"" + AppFullName + ".zip\"", "", null);
|
|
}
|
|
|
|
if (NotBundledBinaries.Count > 0)
|
|
{
|
|
|
|
foreach (string BinaryPath in NotBundledBinaries)
|
|
{
|
|
RPCUtilHelper.CopyFile(ConvertPath(BinaryPath), BinaryPath, false);
|
|
}
|
|
}
|
|
|
|
Log.TraceInformation("Copied binaries successfully.");
|
|
}
|
|
catch (Exception)
|
|
{
|
|
Log.TraceInformation("Copying binaries back to this device failed.");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public override ICollection<FileItem> PostBuild(FileItem Executable, LinkEnvironment BinaryLinkEnvironment, ActionGraph ActionGraph)
|
|
{
|
|
var OutputFiles = base.PostBuild(Executable, BinaryLinkEnvironment, ActionGraph);
|
|
|
|
if (BinaryLinkEnvironment.bIsBuildingLibrary)
|
|
{
|
|
return OutputFiles;
|
|
}
|
|
|
|
if(Executable.AbsolutePath.Contains(".app"))
|
|
{
|
|
foreach (UEBuildBundleResource Resource in BinaryLinkEnvironment.AdditionalBundleResources)
|
|
{
|
|
OutputFiles.Add(CopyBundleResource(Resource, Executable, ActionGraph));
|
|
}
|
|
}
|
|
|
|
// For Mac, generate the dSYM file if the config file is set to do so
|
|
if (BinaryLinkEnvironment.bUsePDBFiles == true)
|
|
{
|
|
// We want dsyms to be created after all dylib dependencies are fixed. If FixDylibDependencies action was not created yet, save the info for later.
|
|
if (FixDylibOutputFile != null)
|
|
{
|
|
OutputFiles.Add(GenerateDebugInfo(Executable, BinaryLinkEnvironment, ActionGraph));
|
|
}
|
|
else
|
|
{
|
|
ExecutablesThatNeedDsyms.Add(Executable);
|
|
}
|
|
}
|
|
|
|
// If building for Mac on a Mac, use actions to finalize the builds (otherwise, we use Deploy)
|
|
if (BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Mac)
|
|
{
|
|
return OutputFiles;
|
|
}
|
|
|
|
if (BinaryLinkEnvironment.bIsBuildingDLL)
|
|
{
|
|
return OutputFiles;
|
|
}
|
|
|
|
FixDylibOutputFile = FixDylibDependencies(BinaryLinkEnvironment, Executable, ActionGraph);
|
|
OutputFiles.Add(FixDylibOutputFile);
|
|
if (!BinaryLinkEnvironment.bIsBuildingConsoleApplication)
|
|
{
|
|
OutputFiles.Add(FinalizeAppBundle(BinaryLinkEnvironment, Executable, FixDylibOutputFile, ActionGraph));
|
|
}
|
|
|
|
// Add dsyms that we couldn't add before FixDylibDependencies action was created
|
|
foreach (FileItem Exe in ExecutablesThatNeedDsyms)
|
|
{
|
|
OutputFiles.Add(GenerateDebugInfo(Exe, BinaryLinkEnvironment, ActionGraph));
|
|
}
|
|
ExecutablesThatNeedDsyms.Clear();
|
|
|
|
return OutputFiles;
|
|
}
|
|
|
|
private FileItem FixDylibOutputFile = null;
|
|
private List<FileItem> ExecutablesThatNeedDsyms = new List<FileItem>();
|
|
|
|
public void StripSymbols(string SourceFileName, string TargetFileName)
|
|
{
|
|
SetupXcodePaths(false);
|
|
|
|
StripSymbolsWithXcode(SourceFileName, TargetFileName, Settings.ToolchainDir);
|
|
}
|
|
};
|
|
}
|