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 3175510 on 2016/10/26 by Josh.Adams - New Wolf SDK support (11). - Added new input plugin now that extra NDA is lifted Change 3176629 on 2016/10/27 by Josh.Adams Merging //UE4/Dev-Main to Dev-Platform (//UE4/Dev-Platform) Change 3177232 on 2016/10/27 by Josh.Adams - Minor comment change Change 3177348 on 2016/10/27 by Dmitry.Rekman Linux: default to GL4. Change 3177523 on 2016/10/27 by Dmitry.Rekman Linux: update libc++ to 3.9 and add AArch64. Change 3178208 on 2016/10/28 by Daniel.Lamb Enable multithreaded lightmap encoding. Change 3178273 on 2016/10/28 by Luke.Thatcher [PLATFORM] [PS4] [!] Fix crash in PS4 packaging step. - Parallel-for accessing the same log files, causing IOException. Change 3178573 on 2016/10/28 by Dmitry.Rekman Linux: fix for projects not having proper version associations (UE-5954). - Fixed by CengizT. Change3180487on 2016/10/31 by Josh.Adams Moved new file to peoper spot Change 3180508 on 2016/10/31 by Josh.Adams - Fixed crash on audio free for Wolf Change 3181821 on 2016/11/01 by Josh.Adams - Fixed ShooterGame cooking after sync from main Change 3182469 on 2016/11/01 by Josh.Adams - test/shipping build wolf fixes Change 3183078 on 2016/11/02 by Josh.Adams - Added AllDesktop back in for Windows (File | Package) Change 3183229 on 2016/11/02 by Josh.Adams - Fixed wrong path in JunkManifest.txt Change 3184245 on 2016/11/02 by Dmitry.Rekman Linux: add AArch64 (ARM64) libs. Change 3184326 on 2016/11/02 by Dmitry.Rekman Linux: add more files for AArch64. Change 3184353 on 2016/11/02 by Dmitry.Rekman Linux: Add missed AArch64 libpng. Change 3184871 on 2016/11/03 by Luke.Thatcher [PLATFORM] [PS4] [!] Fix broken DownloadImage blueprint node on PS4. - Node should return a UTexture2DDynamic, otherwise the RHI assumes the data has been pre-formatted for the GPU, and we get pitch/layout issues. #jira UE-36365 Change 3185407 on 2016/11/03 by Dmitry.Rekman Linux: fix PhysX on AArch64. (Edigrating 3184484 from Wombat to Dev-Platform). Change 3187488 on 2016/11/04 by Josh.Adams Copying //Tasks/UE4/Private-Platform-Switch to Dev-Platform-Minimal (//UE4/Dev-Platform-Minimal) Change 3187740 on 2016/11/04 by Josh.Adams - Re-copying the Switch files, now with proper case in the directory names Change 3188304 on 2016/11/07 by Dan.Mahashin - Removed deprecated functions in NVN window creation Change3188865on 2016/11/07 by Luke.Thatcher [PLATFORM] [PS4] [~] Move PS4 console input handler into engine classes from OrionGame. - Enables console input from Sony's "Console Output" tool for all games, in debug/development builds. #jira UE-37672 Change 3189517 on 2016/11/07 by Jeff.Campeau Fix incorrect local platform identification in device manager. #jira UE-38312 Change 3189897 on 2016/11/08 by Luke.Thatcher [PLATFORM] [!] Fix width/height mismatch in DownloadImage blueprint node. Change 3190042 on 2016/11/08 by Josh.Adams - Fixed default and Shooter App Ids for Switch Change 3190181 on 2016/11/08 by Joe.Barnes [UE-37275] Split reflection capture error message into two UE_LOG()s. Line length causes truncation and line wrap on some platforms. Change 3190185 on 2016/11/08 by Joe.Barnes Fix another instance of UE_LOG() where the string was being truncated on Switch platform. Change 3190272 on 2016/11/08 by Daniel.Lamb Add file hashes to depependency tracking info. Moved partial gc controlling code outside of the cooker. Store cooked file hashes in cooked asset registry. Cooked asset registry is now part of the cooker instead of chunking manifest. #test cook paragon Change 3190332 on 2016/11/08 by Omar.Rodriguez Fixing issues with iOS remote notifications * Update UPlatformGameInstance::FPlatformRegisteredForRemoteNotificationsDelegate signature so the parameter is const& which will work with BlueprintAssignable * Fix misspelling when doing respondsToSelector check * Update generated Xcode project to use the generated entitlements file * Add remote-notification as a background mode * Update the generated entitlements file contents to include APS environment for push notifications * Added bEnableRemoteNotificationsSupport ini parameter to control whether iOS push notifications code is compiled Change 3190391 on 2016/11/08 by Brent.Pease UE-31739 - Crash when Deploying to iPad Air with BC4 Texture Compression Setting (Josh's suggestion worked out of the box) Change 3190786 on 2016/11/08 by Bart.Hawthorne Fix some missing PLATFORM_WOLF changes to PLATFORM_SWITCH in ShooterGame Change 3190902 on 2016/11/08 by Alicia.Cano Allow RTTI and exceptions to be enabled for Android #jira UE-37845 #android Change 3190973 on 2016/11/08 by Chris.Babcock Add ability to set element value field with new text parameter for UPL #jira UE-37390 #PR #2869 #ue4 #upl Change 3191411 on 2016/11/09 by Josh.Stoddard Warn when user tries to use a shared pak reader on the wrong thread #jira UE-38049 Change 3191635 on 2016/11/09 by Josh.Stoddard More useful message during cook when AT9 assets fail to encode using SCE's tool #jira UE-38053 Change 3191663 on 2016/11/09 by Peter.Sauerbrei fix for ios build from PC Change 3191701 on 2016/11/09 by Brent.Pease implement iOS device logs on windows Change 3191794 on 2016/11/09 by Daniel.Lamb Fixed up compile error missing header file. #test Compile editor #jira UE-38414 Change 3191807 on 2016/11/09 by Josh.Adams - Fixed one chage that was missed in the WolfPlat->Switch rename Change 3191867 on 2016/11/09 by Josh.Adams - Enabled Switch for ShooterGame project Change 3191958 on 2016/11/09 by Jeff.Campeau Add warning for anyone still using XP Change 3192185 on 2016/11/09 by Josh.Adams - Updated to SDK 0.11.12 - Added TrackLotCheckItem API to track guidelines with limits (nothing using it yet) Change 3192241 on 2016/11/09 by Josh.Adams Merging //UE4/Dev-Main to Dev-Platform (//UE4/Dev-Platform) Change 3192324 on 2016/11/09 by Josh.Adams - Worked around an issue with RunOnTarget stripping quotes around paths with spaces #jira UE-38388 Change 3192387 on 2016/11/09 by Josh.Adams - Updating editor icon for Switch #jira UE-38295 Change 3192476 on 2016/11/09 by Dmitry.Rekman Linux: put correct OpenAL lib per architecture. (Edigrating CL 3185947 from Wombat to Dev-Platform) Change 3192527 on 2016/11/09 by Josh.Adams - Fixed a shadow variable warning #jira UE-38408 Change 3192606 on 2016/11/09 by Jeff.Campeau XP option removed #jira UEPLAT-1542 Change 3192644 on 2016/11/09 by Josh.Adams - Fixed a CIS error (not sure why I don't get it, but hey) Change 3192659 on 2016/11/09 by Josh.Adams - Fixed a crash in DeploymentServer Change 3192672 on 2016/11/09 by Jeff.Campeau Fix WinXP message spamming Change 3193252 on 2016/11/10 by Josh.Adams - Remove assertion in SwitchTextureFormat when the SDK can't be found (if you are sharing DLLs) Change 3193756 on 2016/11/10 by Dmitry.Rekman Linux: add support for touch events. (Edigrating CL 3188159 from Wombat to Dev-Platform). Change 3194297 on 2016/11/10 by Jeff.Campeau HarfBuzz implementation for Xbox One #jira UE-28590 Change 3194299 on 2016/11/10 by Jeff.Campeau Pump Xbox One messaging during slow startup tasks #jira UEPLAT-1276 Change 3194300 on 2016/11/10 by Jeff.Campeau Use response files when building for Xbox One #jira UEPLAT-1296 Change 3194313 on 2016/11/11 by Jeff.Campeau Stop uploading symbols on the first error Show a more detailed error message if symbol uploading fails Add a command line option to disable upload of symbols #1852 #jira UE-24425 Change 3194327 on 2016/11/11 by Jeff.Campeau Deduplicate Xbox One build.cs setup for several modules #jira UE-37540 Change 3194402 on 2016/11/11 by Dmitry.Rekman Linux: do not apply mouse workaround unnecessarily. - Only matters when there is more than one window. (Edigrating 3194399 from Wombat to Dev-Platform). Change 3194434 on 2016/11/11 by Dan.Mahashin - Ported fix CL 3193690: Add workaround to file I/O error about ResultInvalidCurrentMemory when reloading levels - remove uncached attribute during memory pool finalization Change 3194569 on 2016/11/11 by Daniel.Lamb Fixed issue with CreateLinker failing to return LinkerLoad but creating a UPackage which can't be cleaned up. Change 3194570 on 2016/11/11 by Daniel.Lamb Fix for DiffSerializeArchive not using the correct archive when saving packages. #test Cook paragon Change 3194571 on 2016/11/11 by Daniel.Lamb Make sure dependent packages are valid before using them. Added FastBuildCookRun bat file for paragon testing. #test Cook Paragon Change 3194575 on 2016/11/11 by Daniel.Lamb Reworked a warning for the cooker. Change 3194698 on 2016/11/11 by Daniel.Lamb Skip skin verify only runs on build machines now. Saves paragon cook time. Change 3194699 on 2016/11/11 by Daniel.Lamb Changed the wording of skip editor content setting so it's more clear. #test none Change 3194702 on 2016/11/11 by Daniel.Lamb Potential fix for default materials not being in chunk zero. #test run ps4 cooked build paragon Change3194711on 2016/11/11 by Alicia.Cano Allow RTTI and exceptions to be enabled for Android Allow RTTI to be enabled for IOS, Mac #jira UE-37845, UE-20314 #android #ios #mac Change 3194956 on 2016/11/11 by Josh.Adams - Removed the crash with unknown socket error code, left in the warning Change 3195028 on 2016/11/11 by Dmitry.Rekman Linux: repair launch on. (Edigrating 3194384 from //UE4/Private-Wombat/... to //UE4/Dev-Platform/...) Change 3195041 on 2016/11/11 by Dmitry.Rekman Linux: support selecting architectures per project. (Edigrating 3192783 from Wombat to Dev-Platform). Change 3195058 on 2016/11/11 by Dmitry.Rekman Linux: fix code to determine number of cores. - ARM topology seems not to be in line with the assumptions made by x86-centric code. (Merging 3184632 from Wombat to Dev-Platform). Change 3195082 on 2016/11/11 by Josh.Adams - Fixed name of packaged Switch builds to have the config in it (Shipping, etc) #jira UE-38394 Change 3195151 on 2016/11/11 by Bart.Hawthorne - Add game server settings to project settings to connect to the actual game server, instead of the debug login - Use the system software dialog box to show error codes for login failures Change 3195153 on 2016/11/11 by Josh.Adams - Fixed copy and paste logs errors Change 3195156 on 2016/11/11 by Josh.Adams - Fixed some default values, especially for save games (uses their default of 4MB size) - Added some LotCheck write tracking Change 3195285 on 2016/11/11 by Jeff.Campeau Fix HarfBuzz warning on Xbox One Change 3195477 on 2016/11/11 by Josh.Adams - Fixed up some IsGameOnly calls #jira UE-37575 Change 3195490 on 2016/11/11 by Dmitry.Rekman UAT: fix CIS (removed old variables). Change 3195724 on 2016/11/11 by Josh.Adams - Final fix for name of .nsp (content only projects in Shipping config, etc) #jira UE-38394 Change 3195755 on 2016/11/11 by Josh.Adams - Made translucent Switch icons Change 3195771 on 2016/11/11 by Josh.Adams - Fixed some Switch "space in path" issues #jira UE-38393 Change 3195801 on 2016/11/11 by Josh.Adams - Handle making sure the save is completed before we shutdown #jira UE-38215 Change 3196593 on 2016/11/14 by Michael.Trepka Implemented Info string in AvfMedia for display in Media Player Editor #jira UE-35386 Change 3196782 on 2016/11/14 by Josh.Adams - Added a comment for a workaround Change 3196784 on 2016/11/14 by Michael.Trepka Alembic importer for Mac #jira UE-37708 Change 3196901 on 2016/11/14 by Alicia.Cano ADB over wifi fails to deploy on Launch on. #jira UE-37957 #android Change 3197055 on 2016/11/14 by Josh.Adams - Fixed BinnedAllocator crash that happened with PoisonProxy and large allocations with large alignment Change 3197059 on 2016/11/14 by Josh.Adams - Removed some stat code with no STATS Change 3197066 on 2016/11/14 by Josh.Adams - Fixed the generic growableallocator to not free metadata before it's used for stats, and cleaned up a couple minor things Change 3197176 on 2016/11/14 by Josh.Adams - Added some helper scripts to switch in and out of debug mode on Switch Change 3197183 on 2016/11/14 by Bart.Hawthorne Error dialog fixes based on peer review feedback from JoshA Change 3197339 on 2016/11/14 by Josh.Adams Allow -htcs on the commandline now to override disabling Htcs in packaged builds Change 3197401 on 2016/11/14 by Josh.Adams - Fixed the Switch package installation script to remove the path of the package, since it causes problems with spaces, and also it makes the script less portable! #jira UE-38556 Change 3197691 on 2016/11/14 by Dmitry.Rekman Linux: save added devices. (Edigrating 3196529 from Wombat to Dev-Platform). Change 3197854 on 2016/11/15 by Dan.Mahashin - MemoryProfiler2: fixed Switch parser file path in the csproj Change 3197960 on 2016/11/15 by Dan.Mahashin - NVN RHITransitionResources() directly uses a barrier instead of relying on CopyToResolveTarget() side effect (UE-33834) Change 3198488 on 2016/11/15 by Bart.Hawthorne Submit missing NoRedist/DefaultEngine.ini file Change 3198970 on 2016/11/15 by Michael.Trepka Don't try to use installed Mono 4.6 on Mac as it's known to have issues on macOS 10.12 (for example building the editor with UBT often fails with Mono running out of file desriptors) Change 3199050 on 2016/11/15 by Daniel.Lamb Some more output to help track down iterative cooking scenarios #test Cook paragon Change 3199097 on 2016/11/15 by Josh.Adams - Fixed up Switch packaging to re-generate the meta data in case it changed since compile time (esp with content only projects - Fixed default Program Id in code - Fixed a problem with Run with a space in the path #jira UE-38608 Change 3199181 on 2016/11/15 by Dmitry.Rekman Fix CIS (compiling LinuxTargetDevice without engine). Change 3199253 on 2016/11/15 by Dmitry.Rekman Hopeful fix for a static analysis warning. Change 3199325 on 2016/11/15 by Joe.Barnes Start a new CommandBuffer immediately upon ending one. Prevents fetching when there's no CommandBuffer. Needed for Loading Screen movie playback. Change 3199814 on 2016/11/15 by Dmitry.Rekman Linux: remove forced -windowed when launching. (Merging CL 3199789 from Wombat to Dev-Platform) Change 3200580 on 2016/11/16 by Josh.Adams Updasted DeploymentServer Change 3200595 on 2016/11/16 by Joe.Barnes Removed inadvertent SleepThread() when starting movie playback. Change 3200604 on 2016/11/16 by Josh.Adams - Added NN_MIDDLEWARE macros to tag ths apps as using UE4 middleware Change 3200632 on 2016/11/16 by Brent.Pease Update PlatformShowcase with latest tests Change 3200704 on 2016/11/16 by Dmitry.Rekman Linux: fix native compilation. Change 3200711 on 2016/11/16 by Brent.Pease - Support ios audio streaming from disk - Flushed out ADPCMAudioInfo to be more flexible with buffer management in addition to support streaming from disk. This should make more code platform independent. + Other platforms should work fine but will need to be updated to use the new buffer flexability (and hence simplify their own code and buffer management) - IOS audio implementation simplified to use new ADPCMAudioInfo functionality - Fixed adpcm seamless looping NOTE: While everything works with my testing (admittedly simple tests) a little more code cleanup needs to happen... Change 3201015 on 2016/11/16 by Josh.Adams Merging //UE4/Dev-Main to Dev-Platform (//UE4/Dev-Platform) Change 3201023 on 2016/11/16 by Josh.Stoddard Fix splash screen assignment for iPad #jira UE-38623 Change 3201215 on 2016/11/16 by Brent.Pease Hopefully final fix for build breakage Change 3201259 on 2016/11/16 by Josh.Adams - Removed the clock rate settings from the Project Settings, and the cvars - it was just confusing - Further improved the metadata recreation during packaging (can get rid of the temp meta/desc files now I believe) - Reduced audio pool alignment to not waste massive memory from it Change3202332on 2016/11/17 by Daniel.Lamb Changed build scripts to support iterative cooking #test Ran new build scripts Change 3202371 on 2016/11/17 by Michael.Trepka Changed FAppleHttpResponse::GetContentLength to return expected content size instead of payload size so it's consistent with other implementations #jira UE-38392 Change 3202421 on 2016/11/17 by Michael.Trepka Decrease the number of max open files for a thread on Apple platforms from 256 to 192 to leave more file descriptors to Cocoa #jira UE-18343 Change 3202462 on 2016/11/17 by Michael.Trepka Fixed HTTP If-None-Match response code on Mac and iOS Fixed by iktomi, https://answers.unrealengine.com/questions/492514/http-if-none-match-logic-isnt-working-on-mac-due-t.html #jira UE-36317 Change 3202620 on 2016/11/17 by Daniel.Lamb Fixed issue with some objects being garbage collected which shouldn't be because the collection handler didn't get registered. Commandlets now do not always have GIsRequestingExit true. Made crash handler check for commandlets running and exit appropriately. #test Rebuild lighting QAGame Change 3202955 on 2016/11/17 by Daniel.Lamb Add support for clearing all the cached cooked platform data for a platform when requested. #test cook QA game #jira UE-38361 Change 3202983 on 2016/11/17 by Daniel.Lamb Added support to rebuild lightmaps commandlet for building lightmaps in seperate files. #test rebuild lighting Custom QAGame maps. #jira OR-31907 Change 3203128 on 2016/11/17 by Josh.Adams - Fixed split screen user selection in ShooterGame (brought over some changes from NickD for it as well) Change 3203537 on 2016/11/18 by Dmitry.Rekman Fix ProjectWorldToScreen node for letterboxed viewports. (Merging CL 3201546 from Wombat to Dev-Platform). Change 3203540 on 2016/11/18 by Dmitry.Rekman Linux: be more verbose when setting vblank sync. (Merging CL 3199633 from Private-Wombat to Dev-Platform). Change 3203599 on 2016/11/18 by Dmitry.Rekman Speedup bForceCompilationAtStartup=True when nothing changed (UE-37067). - PR #2849: Contributed by slonopotamus. Change 3203610 on 2016/11/18 by Dmitry.Rekman Add CEF support for Linux (UE-6743). Change 3203615 on 2016/11/18 by Dmitry.Rekman Linux: fix bootstrap script so it is independent of working dir (UE-37016). - PR #2842 contributed by slonopotamus Change 3203645 on 2016/11/18 by Dmitry.Rekman Linux: fix UnrealCEFSubProcess. Change 3203658 on 2016/11/18 by Dmitry.Rekman Remove hard-coded paths to mono binary (UE-35228). - Another way to implement pull request #2741. Change 3203770 on 2016/11/18 by Josh.Adams - Brought over some changes from Dev-Core to not crash in AsyncLoading with debug code Change 3204244 on 2016/11/18 by Dmitry.Rekman Unsuppress mistakenly suppressed warnings and fix one more (UE-38788). Change 3204277 on 2016/11/18 by Brent.Pease + Fix seamless looping bug found on Dan's QAGame test + Fix static analyzer warning (which was a real bug with uncompressed streaming) + Code review feedback from Aaron + Small addition from channel sync ios bug fix Change 3204576 on 2016/11/18 by Omar.Rodriguez Expose the bEnableRemoteNotificationsSupport ini setting in the iOS project settings. Change 3204629 on 2016/11/18 by Chris.Babcock Fix case of VulkanSwapChain.h #include #jira UE-38843 #ue4 #vulkan Change 3204708 on 2016/11/18 by Josh.Adams - Set SwitchMoviePlayer to include the libs from the proper directory Change 3204730 on 2016/11/18 by Josh.Adams - Changed a check to a checkf to narrow down why FMaterialUniformExpressionType::GetTypeMap().FindRef(TypeName) is returning nullptr on tvOS Change 3204865 on 2016/11/18 by Brent.Pease + Turn off ios console logs on Windows to help sort through ios packaging and launch-on issues - This is NOT a fix but it should make it easier to track down the problem with it off. Change 3204883 on 2016/11/18 by Dmitry.Rekman Linux: fix native LaunchOn (UE-38616). Change 3204914 on 2016/11/18 by Brent.Pease + Turn off the device check to prevent it from conflicting with remote packaging/launch-on Change 3204940 on 2016/11/18 by Josh.Adams Backing out changes to the profiler for Switch. Shouldn't have checked it in today during smoke Change 3204952 on 2016/11/18 by Dmitry.Rekman Linux: fix bootstrap script (UE-38851). - Caused by UE-37016. Change 3205630 on 2016/11/21 by Brent.Pease + Fix audio sound queuing bug by ensuring audio buffers are not reused by different sound source objects. + Cleaned up the locking mechanism around stopping sound sources to make its intent and function are clear + Cleaned up memory tracking and freeing. #jira ue-38846 Change 3205787 on 2016/11/21 by Josh.Adams Merging //UE4/Dev-Main to Dev-Platform (//UE4/Dev-Platform) [CL 3206922 by Josh Adams in Main branch]
1380 lines
51 KiB
C#
1380 lines
51 KiB
C#
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text.RegularExpressions;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using Microsoft.Win32;
|
|
|
|
namespace UnrealBuildTool
|
|
{
|
|
class LinuxToolChain : UEToolChain
|
|
{
|
|
LinuxPlatformContext PlatformContext;
|
|
|
|
public LinuxToolChain(LinuxPlatformContext InPlatformContext)
|
|
: base(CPPTargetPlatform.Linux)
|
|
{
|
|
PlatformContext = InPlatformContext;
|
|
if (!CrossCompiling())
|
|
{
|
|
// use native linux toolchain
|
|
string[] ClangNames = { "clang++", "clang++-3.9", "clang++-3.8", "clang++-3.7", "clang++-3.6", "clang++-3.5" };
|
|
foreach (var ClangName in ClangNames)
|
|
{
|
|
ClangPath = Which(ClangName);
|
|
if (!String.IsNullOrEmpty(ClangPath))
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
GCCPath = Which("g++");
|
|
ArPath = Which("ar");
|
|
RanlibPath = Which("ranlib");
|
|
StripPath = Which("strip");
|
|
|
|
// if clang is available, zero out gcc (@todo: support runtime switching?)
|
|
if (!String.IsNullOrEmpty(ClangPath))
|
|
{
|
|
GCCPath = null;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// if new multi-arch toolchain is used, prefer it
|
|
string MultiArchRoot = Environment.GetEnvironmentVariable("LINUX_MULTIARCH_ROOT");
|
|
|
|
if (MultiArchRoot != null)
|
|
{
|
|
// FIXME: UBT should loop across all the architectures and compile for all the selected ones.
|
|
BaseLinuxPath = Path.Combine(MultiArchRoot, PlatformContext.GetActiveArchitecture());
|
|
|
|
Console.WriteLine("Using LINUX_MULTIARCH_ROOT, building with toolchain '{0}'", BaseLinuxPath);
|
|
}
|
|
else
|
|
{
|
|
// use cross linux toolchain if LINUX_ROOT is specified
|
|
BaseLinuxPath = Environment.GetEnvironmentVariable("LINUX_ROOT");
|
|
|
|
Console.WriteLine("Using LINUX_ROOT (deprecated, consider LINUX_MULTIARCH_ROOT), building with toolchain '{0}'", BaseLinuxPath);
|
|
}
|
|
|
|
// don't register if we don't have an LINUX_ROOT specified
|
|
if (String.IsNullOrEmpty(BaseLinuxPath))
|
|
{
|
|
throw new BuildException("LINUX_ROOT environment variable is not set; cannot instantiate Linux toolchain");
|
|
}
|
|
|
|
BaseLinuxPath = BaseLinuxPath.Replace("\"", "");
|
|
|
|
// set up the path to our toolchains
|
|
GCCPath = "";
|
|
ClangPath = Path.Combine(BaseLinuxPath, @"bin\clang++.exe");
|
|
// ar and ranlib will be switched later to match the architecture
|
|
ArPath = "ar.exe";
|
|
RanlibPath = "ranlib.exe";
|
|
StripPath = "strip.exe";
|
|
}
|
|
|
|
if (!DetermineCompilerVersion())
|
|
{
|
|
throw new BuildException("Could not determine version of the compiler, not registering Linux toolchain.");
|
|
}
|
|
|
|
// refuse to use compilers that we know won't work
|
|
// disable that only if you are a dev and you know what you are doing
|
|
if (!UsingClang())
|
|
{
|
|
throw new BuildException("This version of the engine can only be compiled by clang - refusing to register the Linux toolchain.");
|
|
}
|
|
else if (CompilerVersionMajor == 3 && CompilerVersionMinor == 4)
|
|
{
|
|
throw new BuildException("clang 3.4.x is known to miscompile the engine - refusing to register the Linux toolchain.");
|
|
}
|
|
// prevent unknown clangs since the build is likely to fail on too old or too new compilers
|
|
else if ((CompilerVersionMajor * 10 + CompilerVersionMinor) > 39 || (CompilerVersionMajor * 10 + CompilerVersionMinor) < 35)
|
|
{
|
|
throw new BuildException(
|
|
string.Format("This version of the Unreal Engine can only be compiled with clang 3.9, 3.8, 3.7, 3.6 and 3.5. clang {0} may not build it - please use a different version.",
|
|
CompilerVersionString)
|
|
);
|
|
}
|
|
}
|
|
|
|
protected static bool CrossCompiling()
|
|
{
|
|
return BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Linux;
|
|
}
|
|
|
|
protected static bool UsingClang()
|
|
{
|
|
return !String.IsNullOrEmpty(ClangPath);
|
|
}
|
|
|
|
private string Which(string name)
|
|
{
|
|
Process proc = new Process();
|
|
proc.StartInfo.FileName = "/bin/sh";
|
|
proc.StartInfo.Arguments = String.Format("-c 'which {0}'", name);
|
|
proc.StartInfo.UseShellExecute = false;
|
|
proc.StartInfo.CreateNoWindow = true;
|
|
proc.StartInfo.RedirectStandardOutput = true;
|
|
proc.StartInfo.RedirectStandardError = true;
|
|
|
|
proc.Start();
|
|
proc.WaitForExit();
|
|
|
|
string path = proc.StandardOutput.ReadLine();
|
|
Log.TraceVerbose(String.Format("which {0} result: ({1}) {2}", name, proc.ExitCode, path));
|
|
|
|
if (proc.ExitCode == 0 && String.IsNullOrEmpty(proc.StandardError.ReadToEnd()))
|
|
{
|
|
return path;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Splits compiler version string into numerical components, leaving unchanged if not known
|
|
/// </summary>
|
|
private void DetermineCompilerMajMinPatchFromVersionString()
|
|
{
|
|
string[] Parts = CompilerVersionString.Split('.');
|
|
if (Parts.Length >= 1)
|
|
{
|
|
CompilerVersionMajor = Convert.ToInt32(Parts[0]);
|
|
}
|
|
if (Parts.Length >= 2)
|
|
{
|
|
CompilerVersionMinor = Convert.ToInt32(Parts[1]);
|
|
}
|
|
if (Parts.Length >= 3)
|
|
{
|
|
CompilerVersionPatch = Convert.ToInt32(Parts[2]);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Queries compiler for the version
|
|
/// </summary>
|
|
private bool DetermineCompilerVersion()
|
|
{
|
|
CompilerVersionString = null;
|
|
CompilerVersionMajor = -1;
|
|
CompilerVersionMinor = -1;
|
|
CompilerVersionPatch = -1;
|
|
|
|
Process Proc = new Process();
|
|
Proc.StartInfo.UseShellExecute = false;
|
|
Proc.StartInfo.CreateNoWindow = true;
|
|
Proc.StartInfo.RedirectStandardOutput = true;
|
|
Proc.StartInfo.RedirectStandardError = true;
|
|
|
|
if (!String.IsNullOrEmpty(GCCPath) && File.Exists(GCCPath))
|
|
{
|
|
Proc.StartInfo.FileName = GCCPath;
|
|
Proc.StartInfo.Arguments = " -dumpversion";
|
|
|
|
Proc.Start();
|
|
Proc.WaitForExit();
|
|
|
|
if (Proc.ExitCode == 0)
|
|
{
|
|
// read just the first string
|
|
CompilerVersionString = Proc.StandardOutput.ReadLine();
|
|
DetermineCompilerMajMinPatchFromVersionString();
|
|
}
|
|
}
|
|
else if (!String.IsNullOrEmpty(ClangPath) && File.Exists(ClangPath))
|
|
{
|
|
Proc.StartInfo.FileName = ClangPath;
|
|
Proc.StartInfo.Arguments = " --version";
|
|
|
|
Proc.Start();
|
|
Proc.WaitForExit();
|
|
|
|
if (Proc.ExitCode == 0)
|
|
{
|
|
// read just the first string
|
|
string VersionString = Proc.StandardOutput.ReadLine();
|
|
|
|
Regex VersionPattern = new Regex("version \\d+(\\.\\d+)+");
|
|
Match VersionMatch = VersionPattern.Match(VersionString);
|
|
|
|
// version match will be like "version 3.3", so remove the "version"
|
|
if (VersionMatch.Value.StartsWith("version "))
|
|
{
|
|
CompilerVersionString = VersionMatch.Value.Replace("version ", "");
|
|
|
|
DetermineCompilerMajMinPatchFromVersionString();
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// icl?
|
|
}
|
|
|
|
if (!CrossCompiling() && !ProjectFileGenerator.bGenerateProjectFiles)
|
|
{
|
|
Console.WriteLine("Using {0} version '{1}' (string), {2} (major), {3} (minor), {4} (patch)",
|
|
String.IsNullOrEmpty(ClangPath) ? "gcc" : "clang",
|
|
CompilerVersionString, CompilerVersionMajor, CompilerVersionMinor, CompilerVersionPatch);
|
|
}
|
|
return !String.IsNullOrEmpty(CompilerVersionString);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Checks if compiler version matches the requirements
|
|
/// </summary>
|
|
private static bool CompilerVersionGreaterOrEqual(int Major, int Minor, int Patch)
|
|
{
|
|
return CompilerVersionMajor > Major ||
|
|
(CompilerVersionMajor == Major && CompilerVersionMinor > Minor) ||
|
|
(CompilerVersionMajor == Major && CompilerVersionMinor == Minor && CompilerVersionPatch >= Patch);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Architecture-specific compiler switches
|
|
/// </summary>
|
|
static string ArchitectureSpecificSwitches(string Architecture)
|
|
{
|
|
string Result = "";
|
|
|
|
if (Architecture.StartsWith("arm") || Architecture.StartsWith("aarch64"))
|
|
{
|
|
Result += " -fsigned-char";
|
|
}
|
|
|
|
return Result;
|
|
}
|
|
|
|
static string ArchitectureSpecificDefines(string Architecture)
|
|
{
|
|
string Result = "";
|
|
|
|
if (Architecture.StartsWith("x86_64") || Architecture.StartsWith("aarch64"))
|
|
{
|
|
Result += " -D_LINUX64";
|
|
}
|
|
|
|
return Result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets architecture-specific ar paths
|
|
/// </summary>
|
|
private static string GetArPath(string Architecture)
|
|
{
|
|
if (CrossCompiling())
|
|
{
|
|
return Path.Combine(Path.Combine(BaseLinuxPath, String.Format("bin/{0}-{1}", Architecture, ArPath)));
|
|
}
|
|
|
|
return ArPath;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets architecture-specific ranlib paths
|
|
/// </summary>
|
|
private static string GetRanlibPath(string Architecture)
|
|
{
|
|
if (CrossCompiling())
|
|
{
|
|
return Path.Combine(Path.Combine(BaseLinuxPath, String.Format("bin/{0}-{1}", Architecture, RanlibPath)));
|
|
}
|
|
|
|
return RanlibPath;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets architecture-specific strip path
|
|
/// </summary>
|
|
private static string GetStripPath(string Architecture)
|
|
{
|
|
if (CrossCompiling())
|
|
{
|
|
return Path.Combine(Path.Combine(BaseLinuxPath, String.Format("bin/{0}-{1}", Architecture, StripPath)));
|
|
}
|
|
|
|
return StripPath;
|
|
}
|
|
|
|
private static bool ShouldUseLibcxx(NativeBuildEnvironmentConfiguration.TargetInfo Target)
|
|
{
|
|
// set UE4_LINUX_USE_LIBCXX to either 0 or 1. If unset, defaults to 1.
|
|
string UseLibcxxEnvVarOverride = Environment.GetEnvironmentVariable("UE4_LINUX_USE_LIBCXX");
|
|
if (UseLibcxxEnvVarOverride != null && (UseLibcxxEnvVarOverride == "1"))
|
|
{
|
|
return true;
|
|
}
|
|
|
|
// at the moment only x86_64 is supported
|
|
return Target.Architecture.StartsWith("x86_64") || Target.Architecture.StartsWith("aarch64");
|
|
}
|
|
|
|
static string GetCLArguments_Global(CPPEnvironment CompileEnvironment)
|
|
{
|
|
string Result = "";
|
|
|
|
// build up the commandline common to C and C++
|
|
Result += " -c";
|
|
Result += " -pipe";
|
|
|
|
if (ShouldUseLibcxx(CompileEnvironment.Config.Target))
|
|
{
|
|
Result += " -nostdinc++";
|
|
Result += " -I" + UEBuildConfiguration.UEThirdPartySourceDirectory + "Linux/LibCxx/include/";
|
|
Result += " -I" + UEBuildConfiguration.UEThirdPartySourceDirectory + "Linux/LibCxx/include/c++/v1";
|
|
}
|
|
|
|
Result += " -Wall -Werror";
|
|
// test without this next line?
|
|
Result += " -funwind-tables"; // generate unwind tables as they seem to be needed for stack tracing (why??)
|
|
Result += " -Wsequence-point"; // additional warning not normally included in Wall: warns if order of operations is ambigious
|
|
//Result += " -Wunreachable-code"; // additional warning not normally included in Wall: warns if there is code that will never be executed - not helpful due to bIsGCC and similar
|
|
//Result += " -Wshadow"; // additional warning not normally included in Wall: warns if there variable/typedef shadows some other variable - not helpful because we have gobs of code that shadows variables
|
|
|
|
Result += ArchitectureSpecificSwitches(CompileEnvironment.Config.Target.Architecture);
|
|
|
|
Result += " -fno-math-errno"; // do not assume that math ops have side effects
|
|
|
|
Result += GetRTTIFlag(CompileEnvironment); // flag for run-time type info
|
|
|
|
if (String.IsNullOrEmpty(ClangPath))
|
|
{
|
|
// GCC only option
|
|
Result += " -fno-strict-aliasing";
|
|
Result += " -Wno-sign-compare"; // needed to suppress: comparison between signed and unsigned integer expressions
|
|
Result += " -Wno-enum-compare"; // Stats2.h triggers this (ALIGNOF(int64) <= DATA_ALIGN)
|
|
Result += " -Wno-return-type"; // Variant.h triggers this
|
|
Result += " -Wno-unused-local-typedefs";
|
|
Result += " -Wno-multichar";
|
|
Result += " -Wno-unused-but-set-variable";
|
|
Result += " -Wno-strict-overflow"; // Array.h:518
|
|
}
|
|
else
|
|
{
|
|
// Clang only options
|
|
if (CrossCompiling())
|
|
{
|
|
Result += " -fdiagnostics-format=msvc"; // make diagnostics compatible with MSVC when cross-compiling
|
|
}
|
|
Result += " -Wno-unused-private-field"; // MultichannelTcpSocket.h triggers this, possibly more
|
|
// 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 switch is understood by clang 3.5.0, but not clang-3.5 as packaged by Ubuntu 14.04 atm
|
|
if (CompilerVersionGreaterOrEqual(3, 5, 0))
|
|
{
|
|
Result += " -Wno-undefined-bool-conversion"; // hides checking if 'this' pointer is null
|
|
}
|
|
|
|
if (CompilerVersionGreaterOrEqual(3, 6, 0))
|
|
{
|
|
Result += " -Wno-unused-local-typedef"; // clang is being overly strict here? PhysX headers trigger this.
|
|
Result += " -Wno-inconsistent-missing-override"; // these have to be suppressed for UE 4.8, should be fixed later.
|
|
}
|
|
|
|
if (CompilerVersionGreaterOrEqual(3, 9, 0))
|
|
{
|
|
Result += " -Wno-undefined-var-template"; // not really a good warning to disable
|
|
}
|
|
}
|
|
|
|
Result += " -Wno-unused-variable";
|
|
// 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";
|
|
Result += " -Wno-unknown-pragmas"; // Slate triggers this (with its optimize on/off pragmas)
|
|
// 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";
|
|
|
|
if (CompileEnvironment.Config.bEnableShadowVariableWarning)
|
|
{
|
|
Result += " -Wshadow" + (BuildConfiguration.bShadowVariableErrors ? "" : " -Wno-error=shadow");
|
|
}
|
|
|
|
//Result += " -DOPERATOR_NEW_INLINE=FORCENOINLINE";
|
|
|
|
// shipping builds will cause this warning with "ensure", so disable only in those case
|
|
if (CompileEnvironment.Config.Target.Configuration == CPPTargetConfiguration.Shipping)
|
|
{
|
|
Result += " -Wno-unused-value";
|
|
Result += " -fomit-frame-pointer";
|
|
}
|
|
// switches to help debugging
|
|
else if (CompileEnvironment.Config.Target.Configuration == CPPTargetConfiguration.Debug)
|
|
{
|
|
Result += " -fno-inline"; // disable inlining for better debuggability (e.g. callstacks, "skip file" in gdb)
|
|
Result += " -fno-omit-frame-pointer"; // force not omitting fp
|
|
Result += " -fstack-protector"; // detect stack smashing
|
|
//Result += " -fsanitize=address"; // detect address based errors (support properly and link to libasan)
|
|
}
|
|
|
|
// debug info
|
|
// bCreateDebugInfo is normally set for all configurations, including Shipping - this is needed to enable callstack in Shipping builds (proper resolution: UEPLAT-205, separate files with debug info)
|
|
if (CompileEnvironment.Config.bCreateDebugInfo)
|
|
{
|
|
// libdwarf (from elftoolchain 0.6.1) doesn't support DWARF4
|
|
Result += " -gdwarf-3";
|
|
}
|
|
|
|
// optimization level
|
|
if (CompileEnvironment.Config.Target.Configuration == CPPTargetConfiguration.Debug)
|
|
{
|
|
Result += " -O0";
|
|
}
|
|
else
|
|
{
|
|
Result += " -O2"; // warning: as of now (2014-09-28), clang 3.5.0 miscompiles PlatformerGame with -O3 (bitfields?)
|
|
}
|
|
|
|
if (CompileEnvironment.Config.bIsBuildingDLL)
|
|
{
|
|
Result += " -fPIC";
|
|
// Use local-dynamic TLS model. This generates less efficient runtime code for __thread variables, but avoids problems of running into
|
|
// glibc/ld.so limit (DTV_SURPLUS) for number of dlopen()'ed DSOs with static TLS (see e.g. https://www.cygwin.com/ml/libc-help/2013-11/msg00033.html)
|
|
Result += " -ftls-model=local-dynamic";
|
|
}
|
|
|
|
if (CompileEnvironment.Config.bEnableExceptions || UEBuildConfiguration.bForceEnableExceptions)
|
|
{
|
|
Result += " -fexceptions";
|
|
Result += " -DPLATFORM_EXCEPTIONS_DISABLED=0";
|
|
}
|
|
else
|
|
{
|
|
Result += " -fno-exceptions"; // no exceptions
|
|
Result += " -DPLATFORM_EXCEPTIONS_DISABLED=1";
|
|
}
|
|
|
|
//Result += " -v"; // for better error diagnosis
|
|
|
|
Result += ArchitectureSpecificDefines(CompileEnvironment.Config.Target.Architecture);
|
|
if (CrossCompiling())
|
|
{
|
|
if (UsingClang())
|
|
{
|
|
Result += String.Format(" -target {0}", CompileEnvironment.Config.Target.Architecture); // Set target triple
|
|
}
|
|
Result += String.Format(" --sysroot=\"{0}\"", BaseLinuxPath);
|
|
}
|
|
|
|
return Result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sanitizes a definition argument if needed.
|
|
/// </summary>
|
|
/// <param name="definition">A string in the format "foo=bar".</param>
|
|
/// <returns></returns>
|
|
internal static string EscapeArgument(string definition)
|
|
{
|
|
string[] splitData = definition.Split('=');
|
|
string myKey = splitData.ElementAtOrDefault(0);
|
|
string myValue = splitData.ElementAtOrDefault(1);
|
|
|
|
if (string.IsNullOrEmpty(myKey)) { return ""; }
|
|
if (!string.IsNullOrEmpty(myValue))
|
|
{
|
|
if (!myValue.StartsWith("\"") && (myValue.Contains(" ") || myValue.Contains("$")))
|
|
{
|
|
myValue = myValue.Trim('\"'); // trim any leading or trailing quotes
|
|
myValue = "\"" + myValue + "\""; // ensure wrap string with double quotes
|
|
}
|
|
|
|
// replace double quotes to escaped double quotes if exists
|
|
myValue = myValue.Replace("\"", "\\\"");
|
|
}
|
|
|
|
return myValue == null
|
|
? string.Format("{0}", myKey)
|
|
: string.Format("{0}={1}", myKey, myValue);
|
|
}
|
|
|
|
static string GetCompileArguments_CPP()
|
|
{
|
|
string Result = "";
|
|
Result += " -x c++";
|
|
Result += " -std=c++11";
|
|
return Result;
|
|
}
|
|
|
|
static string GetCompileArguments_C()
|
|
{
|
|
string Result = "";
|
|
Result += " -x c";
|
|
return Result;
|
|
}
|
|
|
|
static string GetCompileArguments_MM()
|
|
{
|
|
string Result = "";
|
|
Result += " -x objective-c++";
|
|
Result += " -fobjc-abi-version=2";
|
|
Result += " -fobjc-legacy-dispatch";
|
|
Result += " -std=c++11";
|
|
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(CPPEnvironment CompileEnvironment)
|
|
{
|
|
string Result = "";
|
|
|
|
if (CompileEnvironment.Config.bUseRTTI)
|
|
{
|
|
Result = " -frtti";
|
|
}
|
|
else
|
|
{
|
|
Result = " -fno-rtti";
|
|
}
|
|
|
|
return Result;
|
|
}
|
|
|
|
static string GetCompileArguments_M()
|
|
{
|
|
string Result = "";
|
|
Result += " -x objective-c";
|
|
Result += " -fobjc-abi-version=2";
|
|
Result += " -fobjc-legacy-dispatch";
|
|
Result += " -std=c++11";
|
|
return Result;
|
|
}
|
|
|
|
static string GetCompileArguments_PCH()
|
|
{
|
|
string Result = "";
|
|
Result += " -x c++-header";
|
|
Result += " -std=c++11";
|
|
return Result;
|
|
}
|
|
|
|
string GetLinkArguments(LinkEnvironment LinkEnvironment)
|
|
{
|
|
string Result = "";
|
|
|
|
// debugging symbols
|
|
// Applying to all configurations @FIXME: temporary hack for FN to enable callstack in Shipping builds (proper resolution: UEPLAT-205)
|
|
Result += " -rdynamic"; // needed for backtrace_symbols()...
|
|
|
|
if (LinkEnvironment.Config.bIsBuildingDLL)
|
|
{
|
|
Result += " -shared";
|
|
}
|
|
else
|
|
{
|
|
// ignore unresolved symbols in shared libs
|
|
Result += string.Format(" -Wl,--unresolved-symbols=ignore-in-shared-libs");
|
|
}
|
|
|
|
// RPATH for third party libs
|
|
Result += " -Wl,-rpath=${ORIGIN}";
|
|
Result += " -Wl,-rpath-link=${ORIGIN}";
|
|
Result += " -Wl,-rpath=${ORIGIN}/../../../Engine/Binaries/Linux";
|
|
Result += " -Wl,-rpath=${ORIGIN}/.."; // for modules that are in sub-folders of the main Engine/Binary/Linux folder
|
|
// FIXME: really ugly temp solution. Modules need to be able to specify this
|
|
Result += " -Wl,-rpath=${ORIGIN}/../../../Engine/Binaries/ThirdParty/Steamworks/Steamv132/Linux";
|
|
if (LinkEnvironment.Config.Target.Architecture.StartsWith("x86_64"))
|
|
{
|
|
Result += " -Wl,-rpath=${ORIGIN}/../../../Engine/Binaries/ThirdParty/Qualcomm/Linux";
|
|
}
|
|
else
|
|
{
|
|
// x86_64 is now using updated ICU that doesn't need extra .so
|
|
Result += " -Wl,-rpath=${ORIGIN}/../../../Engine/Binaries/ThirdParty/ICU/icu4c-53_1/Linux/" + LinkEnvironment.Config.Target.Architecture;
|
|
}
|
|
Result += " -Wl,-rpath=${ORIGIN}/../../../Engine/Binaries/ThirdParty/OpenAL/Linux/" + LinkEnvironment.Config.Target.Architecture;
|
|
Result += " -Wl,-rpath=${ORIGIN}/../../../Engine/Binaries/ThirdParty/CEF3/Linux";
|
|
|
|
// Some OS ship ld with new ELF dynamic tags, which use DT_RUNPATH vs DT_RPATH. Since DT_RUNPATH do not propagate to dlopen()ed DSOs,
|
|
// this breaks the editor on such systems. See https://kenai.com/projects/maxine/lists/users/archive/2011-01/message/12 for details
|
|
Result += " -Wl,--disable-new-dtags";
|
|
|
|
// This severely improves dynamic linker performance, but affects iteration times. Do not do it in Debug,
|
|
// because taking a hit of several tens of seconds on startup is better than linking for ~4 more minutes when iterating
|
|
if (LinkEnvironment.Config.Target.Configuration != CPPTargetConfiguration.Debug)
|
|
{
|
|
Result += " -Wl,--as-needed";
|
|
}
|
|
// Additionally speeds up editor startup by 1-2s
|
|
Result += " -Wl,--hash-style=gnu";
|
|
|
|
if (CrossCompiling())
|
|
{
|
|
if (UsingClang())
|
|
{
|
|
Result += String.Format(" -target {0}", LinkEnvironment.Config.Target.Architecture); // Set target triple
|
|
}
|
|
string SysRootPath = BaseLinuxPath.TrimEnd(new char[] { '\\', '/' });
|
|
Result += String.Format(" \"--sysroot={0}\"", SysRootPath);
|
|
}
|
|
|
|
return Result;
|
|
}
|
|
|
|
static string GetArchiveArguments(LinkEnvironment LinkEnvironment)
|
|
{
|
|
return " rc";
|
|
}
|
|
|
|
public static void CrossCompileOutputReceivedDataEventHandler(Object Sender, DataReceivedEventArgs e)
|
|
{
|
|
Debug.Assert(CrossCompiling());
|
|
|
|
string Output = e.Data;
|
|
if (String.IsNullOrEmpty(Output))
|
|
{
|
|
return;
|
|
}
|
|
|
|
// format the string so the output errors are clickable in Visual Studio
|
|
|
|
// Need to match following for clickable links
|
|
string RegexFilePath = @"^[A-Z]\:([\\\/][A-Za-z0-9_\-\.]*)+\.(cpp|c|mm|m|hpp|h)";
|
|
string RegexLineNumber = @"\:\d+\:\d+\:";
|
|
string RegexDescription = @"(\serror:\s|\swarning:\s|\snote:\s).*";
|
|
|
|
// Get Matches
|
|
string MatchFilePath = Regex.Match(Output, RegexFilePath).Value.Replace("Engine\\Source\\..\\..\\", "");
|
|
string MatchLineNumber = Regex.Match(Output, RegexLineNumber).Value;
|
|
string MatchDescription = Regex.Match(Output, RegexDescription).Value;
|
|
|
|
// If any of the above matches failed, do nothing
|
|
if (MatchFilePath.Length == 0 ||
|
|
MatchLineNumber.Length == 0 ||
|
|
MatchDescription.Length == 0)
|
|
{
|
|
Console.WriteLine(Output);
|
|
return;
|
|
}
|
|
|
|
// Convert Path
|
|
string RegexStrippedPath = @"\\Engine\\.*"; //@"(Engine\/|[A-Za-z0-9_\-\.]*\/).*";
|
|
string ConvertedFilePath = Regex.Match(MatchFilePath, RegexStrippedPath).Value;
|
|
ConvertedFilePath = Path.GetFullPath("..\\.." + ConvertedFilePath);
|
|
|
|
// Extract Line + Column Number
|
|
string ConvertedLineNumber = Regex.Match(MatchLineNumber, @"\d+").Value;
|
|
string ConvertedColumnNumber = Regex.Match(MatchLineNumber, @"(?<=:\d+:)\d+").Value;
|
|
|
|
// Write output
|
|
string ConvertedExpression = " " + ConvertedFilePath + "(" + ConvertedLineNumber + "," + ConvertedColumnNumber + "):" + MatchDescription;
|
|
Console.WriteLine(ConvertedExpression); // To create clickable vs link
|
|
}
|
|
|
|
// cache the location of NDK tools
|
|
static string BaseLinuxPath;
|
|
static string ClangPath;
|
|
static string GCCPath;
|
|
static string ArPath;
|
|
static string RanlibPath;
|
|
static string StripPath;
|
|
|
|
/// <summary>
|
|
/// Version string of the current compiler, whether clang or gcc or whatever
|
|
/// </summary>
|
|
static string CompilerVersionString;
|
|
/// <summary>
|
|
/// Major version of the current compiler, whether clang or gcc or whatever
|
|
/// </summary>
|
|
static int CompilerVersionMajor = -1;
|
|
/// <summary>
|
|
/// Minor version of the current compiler, whether clang or gcc or whatever
|
|
/// </summary>
|
|
static int CompilerVersionMinor = -1;
|
|
/// <summary>
|
|
/// Patch version of the current compiler, whether clang or gcc or whatever
|
|
/// </summary>
|
|
static int CompilerVersionPatch = -1;
|
|
|
|
/// <summary>
|
|
/// Track which scripts need to be deleted before appending to
|
|
/// </summary>
|
|
private bool bHasWipedFixDepsScript = false;
|
|
|
|
/// <summary>
|
|
/// Tracks that information about used C++ library is only printed once
|
|
/// </summary>
|
|
private bool bHasPrintedLibcxxInformation = false;
|
|
|
|
private static List<FileItem> BundleDependencies = new List<FileItem>();
|
|
|
|
public override CPPOutput CompileCPPFiles(UEBuildTarget Target, CPPEnvironment CompileEnvironment, List<FileItem> SourceFiles, string ModuleName)
|
|
{
|
|
string Arguments = GetCLArguments_Global(CompileEnvironment);
|
|
string PCHArguments = "";
|
|
|
|
if (!bHasPrintedLibcxxInformation)
|
|
{
|
|
// inform the user which C++ library the engine is going to be compiled against - important for compatibility with third party code that uses STL
|
|
bool bUseLibCxx = ShouldUseLibcxx(CompileEnvironment.Config.Target);
|
|
Console.WriteLine("Using {0} standard C++ library.", bUseLibCxx ? "bundled libc++" : "compiler default (most likely libstdc++)");
|
|
bHasPrintedLibcxxInformation = true;
|
|
}
|
|
|
|
if (CompileEnvironment.Config.PrecompiledHeaderAction == PrecompiledHeaderAction.Include)
|
|
{
|
|
// Add the precompiled header file's path to the include path so Clang can find it.
|
|
// This needs to be before the other include paths to ensure Clang uses it instead of the source header file.
|
|
var PrecompiledFileExtension = UEBuildPlatform.GetBuildPlatform(UnrealTargetPlatform.Linux).GetBinaryExtension(UEBuildBinaryType.PrecompiledHeader);
|
|
PCHArguments += string.Format(" -include \"{0}\"", CompileEnvironment.PrecompiledHeaderFile.AbsolutePath.Replace(PrecompiledFileExtension, ""));
|
|
}
|
|
|
|
// Add include paths to the argument list.
|
|
foreach (string IncludePath in CompileEnvironment.Config.CPPIncludeInfo.IncludePaths)
|
|
{
|
|
Arguments += string.Format(" -I\"{0}\"", IncludePath);
|
|
}
|
|
foreach (string IncludePath in CompileEnvironment.Config.CPPIncludeInfo.SystemIncludePaths)
|
|
{
|
|
Arguments += string.Format(" -I\"{0}\"", IncludePath);
|
|
}
|
|
|
|
// Add preprocessor definitions to the argument list.
|
|
foreach (string Definition in CompileEnvironment.Config.Definitions)
|
|
{
|
|
Arguments += string.Format(" -D \"{0}\"", EscapeArgument(Definition));
|
|
}
|
|
|
|
var BuildPlatform = UEBuildPlatform.GetBuildPlatformForCPPTargetPlatform(CompileEnvironment.Config.Target.Platform);
|
|
|
|
// Create a compile action for each source file.
|
|
CPPOutput Result = new CPPOutput();
|
|
foreach (FileItem SourceFile in SourceFiles)
|
|
{
|
|
Action CompileAction = new Action(ActionType.Compile);
|
|
string FileArguments = "";
|
|
string Extension = Path.GetExtension(SourceFile.AbsolutePath).ToUpperInvariant();
|
|
|
|
// Add C or C++ specific compiler arguments.
|
|
if (CompileEnvironment.Config.PrecompiledHeaderAction == PrecompiledHeaderAction.Create)
|
|
{
|
|
FileArguments += GetCompileArguments_PCH();
|
|
}
|
|
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();
|
|
}
|
|
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
|
|
{
|
|
FileArguments += GetCompileArguments_CPP();
|
|
|
|
// only use PCH for .cpp files
|
|
FileArguments += PCHArguments;
|
|
}
|
|
|
|
// Add the C++ source file and its included files to the prerequisite item list.
|
|
AddPrerequisiteSourceFile(Target, BuildPlatform, CompileEnvironment, SourceFile, CompileAction.PrerequisiteItems);
|
|
|
|
if (CompileEnvironment.Config.PrecompiledHeaderAction == PrecompiledHeaderAction.Create)
|
|
{
|
|
var PrecompiledFileExtension = UEBuildPlatform.GetBuildPlatform(UnrealTargetPlatform.Linux).GetBinaryExtension(UEBuildBinaryType.PrecompiledHeader);
|
|
// Add the precompiled header file to the produced item list.
|
|
FileItem PrecompiledHeaderFile = FileItem.GetItemByFileReference(
|
|
FileReference.Combine(
|
|
CompileEnvironment.Config.OutputDirectory,
|
|
Path.GetFileName(SourceFile.AbsolutePath) + PrecompiledFileExtension
|
|
)
|
|
);
|
|
|
|
CompileAction.ProducedItems.Add(PrecompiledHeaderFile);
|
|
Result.PrecompiledHeaderFile = PrecompiledHeaderFile;
|
|
|
|
// Add the parameters needed to compile the precompiled header file to the command-line.
|
|
FileArguments += string.Format(" -o \"{0}\"", PrecompiledHeaderFile.AbsolutePath, false);
|
|
}
|
|
else
|
|
{
|
|
if (CompileEnvironment.Config.PrecompiledHeaderAction == PrecompiledHeaderAction.Include)
|
|
{
|
|
CompileAction.bIsUsingPCH = true;
|
|
CompileAction.PrerequisiteItems.Add(CompileEnvironment.PrecompiledHeaderFile);
|
|
}
|
|
|
|
var ObjectFileExtension = UEBuildPlatform.GetBuildPlatform(UnrealTargetPlatform.Linux).GetBinaryExtension(UEBuildBinaryType.Object);
|
|
// Add the object file to the produced item list.
|
|
FileItem ObjectFile = FileItem.GetItemByFileReference(
|
|
FileReference.Combine(
|
|
CompileEnvironment.Config.OutputDirectory,
|
|
Path.GetFileName(SourceFile.AbsolutePath) + ObjectFileExtension
|
|
)
|
|
);
|
|
CompileAction.ProducedItems.Add(ObjectFile);
|
|
Result.ObjectFiles.Add(ObjectFile);
|
|
|
|
FileArguments += string.Format(" -o \"{0}\"", ObjectFile.AbsolutePath, false);
|
|
}
|
|
|
|
// Add the source file path to the command-line.
|
|
FileArguments += string.Format(" \"{0}\"", SourceFile.AbsolutePath);
|
|
|
|
CompileAction.WorkingDirectory = UnrealBuildTool.EngineSourceDirectory.FullName;
|
|
if (!UsingClang())
|
|
{
|
|
CompileAction.CommandPath = GCCPath;
|
|
}
|
|
else
|
|
{
|
|
CompileAction.CommandPath = ClangPath;
|
|
}
|
|
CompileAction.CommandArguments = Arguments + FileArguments + CompileEnvironment.Config.AdditionalArguments;
|
|
CompileAction.CommandDescription = "Compile";
|
|
CompileAction.StatusDescription = Path.GetFileName(SourceFile.AbsolutePath);
|
|
CompileAction.bIsGCCCompiler = true;
|
|
|
|
// Don't farm out creation of pre-compiled headers as it is the critical path task.
|
|
CompileAction.bCanExecuteRemotely =
|
|
CompileEnvironment.Config.PrecompiledHeaderAction != PrecompiledHeaderAction.Create ||
|
|
BuildConfiguration.bAllowRemotelyCompiledPCHs;
|
|
|
|
// piping output through the handler during native builds is unnecessary and reportedly causes problems with tools like octobuild.
|
|
if (CrossCompiling())
|
|
{
|
|
CompileAction.OutputEventHandler = new DataReceivedEventHandler(CrossCompileOutputReceivedDataEventHandler);
|
|
}
|
|
}
|
|
|
|
return Result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates an action to archive all the .o files into single .a file
|
|
/// </summary>
|
|
public FileItem CreateArchiveAndIndex(LinkEnvironment LinkEnvironment)
|
|
{
|
|
// Create an archive action
|
|
Action ArchiveAction = new Action(ActionType.Link);
|
|
ArchiveAction.WorkingDirectory = UnrealBuildTool.EngineSourceDirectory.FullName;
|
|
bool bUsingSh = BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Win64 && BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Win32;
|
|
if (bUsingSh)
|
|
{
|
|
ArchiveAction.CommandPath = "/bin/sh";
|
|
ArchiveAction.CommandArguments = "-c '";
|
|
}
|
|
else
|
|
{
|
|
ArchiveAction.CommandPath = "cmd.exe";
|
|
ArchiveAction.CommandArguments = "/c \"";
|
|
}
|
|
|
|
// this will produce a final library
|
|
ArchiveAction.bProducesImportLibrary = true;
|
|
|
|
// Add the output file as a production of the link action.
|
|
FileItem OutputFile = FileItem.GetItemByFileReference(LinkEnvironment.Config.OutputFilePath);
|
|
ArchiveAction.ProducedItems.Add(OutputFile);
|
|
ArchiveAction.CommandDescription = "Archive";
|
|
ArchiveAction.StatusDescription = Path.GetFileName(OutputFile.AbsolutePath);
|
|
ArchiveAction.CommandArguments += string.Format("\"{0}\" {1} \"{2}\"", GetArPath(LinkEnvironment.Config.Target.Architecture), GetArchiveArguments(LinkEnvironment), OutputFile.AbsolutePath);
|
|
|
|
// 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)
|
|
{
|
|
string InputAbsolutePath = InputFile.AbsolutePath.Replace("\\", "/");
|
|
InputFileNames.Add(string.Format("\"{0}\"", InputAbsolutePath));
|
|
ArchiveAction.PrerequisiteItems.Add(InputFile);
|
|
ArchiveAction.CommandArguments += string.Format(" \"{0}\"", InputAbsolutePath);
|
|
}
|
|
|
|
// add ranlib
|
|
ArchiveAction.CommandArguments += string.Format(" && \"{0}\" \"{1}\"", GetRanlibPath(LinkEnvironment.Config.Target.Architecture), OutputFile.AbsolutePath);
|
|
|
|
// Add the additional arguments specified by the environment.
|
|
ArchiveAction.CommandArguments += LinkEnvironment.Config.AdditionalArguments;
|
|
ArchiveAction.CommandArguments.Replace("\\", "/");
|
|
|
|
if (bUsingSh)
|
|
{
|
|
ArchiveAction.CommandArguments += "'";
|
|
}
|
|
else
|
|
{
|
|
ArchiveAction.CommandArguments += "\"";
|
|
}
|
|
|
|
// Only execute linking on the local PC.
|
|
ArchiveAction.bCanExecuteRemotely = false;
|
|
|
|
// piping output through the handler during native builds is unnecessary and reportedly causes problems with tools like octobuild.
|
|
if (CrossCompiling())
|
|
{
|
|
ArchiveAction.OutputEventHandler = new DataReceivedEventHandler(CrossCompileOutputReceivedDataEventHandler);
|
|
}
|
|
|
|
return OutputFile;
|
|
}
|
|
|
|
public FileItem FixDependencies(LinkEnvironment LinkEnvironment, FileItem Executable)
|
|
{
|
|
if (!LinkEnvironment.Config.bIsCrossReferenced)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
Log.TraceVerbose("Adding postlink step");
|
|
|
|
bool bUseCmdExe = BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Win64 || BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Win32;
|
|
string ShellBinary = bUseCmdExe ? "cmd.exe" : "/bin/sh";
|
|
string ExecuteSwitch = bUseCmdExe ? " /C" : ""; // avoid -c so scripts don't need +x
|
|
string ScriptName = bUseCmdExe ? "FixDependencies.bat" : "FixDependencies.sh";
|
|
|
|
FileItem FixDepsScript = FileItem.GetItemByFileReference(FileReference.Combine(LinkEnvironment.Config.LocalShadowDirectory, ScriptName));
|
|
|
|
Action PostLinkAction = new Action(ActionType.Link);
|
|
PostLinkAction.WorkingDirectory = UnrealBuildTool.EngineSourceDirectory.FullName;
|
|
PostLinkAction.CommandPath = ShellBinary;
|
|
PostLinkAction.StatusDescription = string.Format("{0}", Path.GetFileName(Executable.AbsolutePath));
|
|
PostLinkAction.CommandDescription = "FixDeps";
|
|
PostLinkAction.bCanExecuteRemotely = false;
|
|
PostLinkAction.CommandArguments = ExecuteSwitch;
|
|
|
|
PostLinkAction.CommandArguments += bUseCmdExe ? " \"" : " -c '";
|
|
|
|
FileItem OutputFile = FileItem.GetItemByFileReference(FileReference.Combine(LinkEnvironment.Config.LocalShadowDirectory, Path.GetFileNameWithoutExtension(Executable.AbsolutePath) + ".link"));
|
|
|
|
// Make sure we don't run this script until the all executables and shared libraries
|
|
// have been built.
|
|
PostLinkAction.PrerequisiteItems.Add(Executable);
|
|
foreach (FileItem Dependency in BundleDependencies)
|
|
{
|
|
PostLinkAction.PrerequisiteItems.Add(Dependency);
|
|
}
|
|
|
|
PostLinkAction.CommandArguments += ShellBinary + ExecuteSwitch + " \"" + FixDepsScript.AbsolutePath + "\" && ";
|
|
|
|
// output file should not be empty or it will be rebuilt next time
|
|
string Touch = bUseCmdExe ? "echo \"Dummy\" >> \"{0}\" && copy /b \"{0}\" +,," : "echo \"Dummy\" >> \"{0}\"";
|
|
|
|
PostLinkAction.CommandArguments += String.Format(Touch, OutputFile.AbsolutePath);
|
|
PostLinkAction.CommandArguments += bUseCmdExe ? "\"" : "'";
|
|
|
|
System.Console.WriteLine("{0} {1}", PostLinkAction.CommandPath, PostLinkAction.CommandArguments);
|
|
|
|
// piping output through the handler during native builds is unnecessary and reportedly causes problems with tools like octobuild.
|
|
if (CrossCompiling())
|
|
{
|
|
PostLinkAction.OutputEventHandler = new DataReceivedEventHandler(CrossCompileOutputReceivedDataEventHandler);
|
|
}
|
|
|
|
PostLinkAction.ProducedItems.Add(OutputFile);
|
|
return OutputFile;
|
|
}
|
|
|
|
|
|
public override FileItem LinkFiles(LinkEnvironment LinkEnvironment, bool bBuildImportLibraryOnly)
|
|
{
|
|
Debug.Assert(!bBuildImportLibraryOnly);
|
|
|
|
List<string> RPaths = new List<string>();
|
|
|
|
if (LinkEnvironment.Config.bIsBuildingLibrary || bBuildImportLibraryOnly)
|
|
{
|
|
return CreateArchiveAndIndex(LinkEnvironment);
|
|
}
|
|
|
|
// Create an action that invokes the linker.
|
|
Action LinkAction = new Action(ActionType.Link);
|
|
LinkAction.WorkingDirectory = UnrealBuildTool.EngineSourceDirectory.FullName;
|
|
if (String.IsNullOrEmpty(ClangPath))
|
|
{
|
|
LinkAction.CommandPath = GCCPath;
|
|
}
|
|
else
|
|
{
|
|
LinkAction.CommandPath = ClangPath;
|
|
}
|
|
|
|
// Get link arguments.
|
|
LinkAction.CommandArguments = GetLinkArguments(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 = LinkEnvironment.Config.bIsBuildingDLL;
|
|
|
|
// Add the output file as a production of the link action.
|
|
FileItem OutputFile = FileItem.GetItemByFileReference(LinkEnvironment.Config.OutputFilePath);
|
|
LinkAction.ProducedItems.Add(OutputFile);
|
|
LinkAction.CommandDescription = "Link";
|
|
LinkAction.StatusDescription = Path.GetFileName(OutputFile.AbsolutePath);
|
|
|
|
// Add the output file to the command-line.
|
|
LinkAction.CommandArguments += string.Format(" -o \"{0}\"", OutputFile.AbsolutePath);
|
|
|
|
// 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)
|
|
{
|
|
InputFileNames.Add(string.Format("\"{0}\"", InputFile.AbsolutePath.Replace("\\", "/")));
|
|
LinkAction.PrerequisiteItems.Add(InputFile);
|
|
}
|
|
|
|
FileReference ResponseFileName = GetResponseFileName(LinkEnvironment, OutputFile);
|
|
LinkAction.CommandArguments += string.Format(" -Wl,@\"{0}\"", ResponseFile.Create(ResponseFileName, InputFileNames));
|
|
|
|
if (LinkEnvironment.Config.bIsBuildingDLL)
|
|
{
|
|
LinkAction.CommandArguments += string.Format(" -Wl,-soname={0}", OutputFile);
|
|
}
|
|
|
|
// Start with the configured LibraryPaths and also add paths to any libraries that
|
|
// we depend on (libraries that we've build ourselves).
|
|
List<string> AllLibraryPaths = LinkEnvironment.Config.LibraryPaths;
|
|
foreach (string AdditionalLibrary in LinkEnvironment.Config.AdditionalLibraries)
|
|
{
|
|
string PathToLib = Path.GetDirectoryName(AdditionalLibrary);
|
|
if (!String.IsNullOrEmpty(PathToLib))
|
|
{
|
|
// make path absolute, because FixDependencies script may be executed in a different directory
|
|
string AbsolutePathToLib = Path.GetFullPath(PathToLib);
|
|
if (!AllLibraryPaths.Contains(AbsolutePathToLib))
|
|
{
|
|
AllLibraryPaths.Add(AbsolutePathToLib);
|
|
}
|
|
}
|
|
|
|
if ((AdditionalLibrary.Contains("Plugins") || AdditionalLibrary.Contains("Binaries/ThirdParty") || AdditionalLibrary.Contains("Binaries\\ThirdParty")) && Path.GetDirectoryName(AdditionalLibrary) != Path.GetDirectoryName(OutputFile.AbsolutePath))
|
|
{
|
|
string RelativePath = Utils.MakePathRelativeTo(Path.GetDirectoryName(AdditionalLibrary), Path.GetDirectoryName(OutputFile.AbsolutePath));
|
|
if (!RPaths.Contains(RelativePath))
|
|
{
|
|
RPaths.Add(RelativePath);
|
|
LinkAction.CommandArguments += string.Format(" -Wl,-rpath=\"${{ORIGIN}}/{0}\"", RelativePath);
|
|
}
|
|
}
|
|
}
|
|
|
|
LinkAction.CommandArguments += string.Format(" -Wl,-rpath-link=\"{0}\"", Path.GetDirectoryName(OutputFile.AbsolutePath));
|
|
|
|
// Add the library paths to the argument list.
|
|
foreach (string LibraryPath in AllLibraryPaths)
|
|
{
|
|
// use absolute paths because of FixDependencies script again
|
|
LinkAction.CommandArguments += string.Format(" -L\"{0}\"", Path.GetFullPath(LibraryPath));
|
|
}
|
|
|
|
List<string> EngineAndGameLibraries = new List<string>();
|
|
|
|
// Pre-2.25 ld has symbol resolution problems when .so are mixed with .a in a single --start-group/--end-group
|
|
// when linking with --as-needed.
|
|
// Move external libraries to a separate --start-group/--end-group to fix it (and also make groups smaller and faster to link).
|
|
// See https://github.com/EpicGames/UnrealEngine/pull/2778 and https://github.com/EpicGames/UnrealEngine/pull/2793 for discussion
|
|
string ExternalLibraries = "";
|
|
|
|
// add libraries in a library group
|
|
LinkAction.CommandArguments += string.Format(" -Wl,--start-group");
|
|
|
|
foreach (string AdditionalLibrary in LinkEnvironment.Config.AdditionalLibraries)
|
|
{
|
|
if (String.IsNullOrEmpty(Path.GetDirectoryName(AdditionalLibrary)))
|
|
{
|
|
// library was passed just like "jemalloc", turn it into -ljemalloc
|
|
ExternalLibraries += string.Format(" -l{0}", AdditionalLibrary);
|
|
}
|
|
else if (Path.GetExtension(AdditionalLibrary) == ".a")
|
|
{
|
|
// static library passed in, pass it along but make path absolute, because FixDependencies script may be executed in a different directory
|
|
string AbsoluteAdditionalLibrary = Path.GetFullPath(AdditionalLibrary);
|
|
if (AbsoluteAdditionalLibrary.Contains(" "))
|
|
{
|
|
AbsoluteAdditionalLibrary = string.Format("\"{0}\"", AbsoluteAdditionalLibrary);
|
|
}
|
|
LinkAction.CommandArguments += (" " + AbsoluteAdditionalLibrary);
|
|
LinkAction.PrerequisiteItems.Add(FileItem.GetItemByPath(AdditionalLibrary));
|
|
}
|
|
else
|
|
{
|
|
// Skip over full-pathed library dependencies when building DLLs to avoid circular
|
|
// dependencies.
|
|
FileItem LibraryDependency = FileItem.GetItemByPath(AdditionalLibrary);
|
|
|
|
var LibName = Path.GetFileNameWithoutExtension(AdditionalLibrary);
|
|
if (LibName.StartsWith("lib"))
|
|
{
|
|
// Remove lib prefix
|
|
LibName = LibName.Remove(0, 3);
|
|
}
|
|
string LibLinkFlag = string.Format(" -l{0}", LibName);
|
|
|
|
if (LinkEnvironment.Config.bIsBuildingDLL && LinkEnvironment.Config.bIsCrossReferenced)
|
|
{
|
|
// We are building a cross referenced DLL so we can't actually include
|
|
// dependencies at this point. Instead we add it to the list of
|
|
// libraries to be used in the FixDependencies step.
|
|
EngineAndGameLibraries.Add(LibLinkFlag);
|
|
if (!LinkAction.CommandArguments.Contains("--allow-shlib-undefined"))
|
|
{
|
|
LinkAction.CommandArguments += string.Format(" -Wl,--allow-shlib-undefined");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
LinkAction.PrerequisiteItems.Add(LibraryDependency);
|
|
ExternalLibraries += LibLinkFlag;
|
|
}
|
|
}
|
|
}
|
|
LinkAction.CommandArguments += " -Wl,--end-group";
|
|
|
|
LinkAction.CommandArguments += " -Wl,--start-group";
|
|
LinkAction.CommandArguments += ExternalLibraries;
|
|
LinkAction.CommandArguments += " -Wl,--end-group";
|
|
|
|
LinkAction.CommandArguments += " -lrt"; // needed for clock_gettime()
|
|
LinkAction.CommandArguments += " -lm"; // math
|
|
|
|
if (ShouldUseLibcxx(LinkEnvironment.Config.Target))
|
|
{
|
|
// libc++ and its abi lib
|
|
LinkAction.CommandArguments += " -nodefaultlibs";
|
|
LinkAction.CommandArguments += " -L" + UEBuildConfiguration.UEThirdPartySourceDirectory + "Linux/LibCxx/lib/Linux/" + LinkEnvironment.Config.Target.Architecture + "/";
|
|
LinkAction.CommandArguments += " " + UEBuildConfiguration.UEThirdPartySourceDirectory + "Linux/LibCxx/lib/Linux/" + LinkEnvironment.Config.Target.Architecture + "/libc++.a";
|
|
LinkAction.CommandArguments += " " + UEBuildConfiguration.UEThirdPartySourceDirectory + "Linux/LibCxx/lib/Linux/" + LinkEnvironment.Config.Target.Architecture + "/libc++abi.a";
|
|
LinkAction.CommandArguments += " -lm";
|
|
LinkAction.CommandArguments += " -lc";
|
|
LinkAction.CommandArguments += " -lgcc_s";
|
|
LinkAction.CommandArguments += " -lgcc";
|
|
}
|
|
|
|
// these can be helpful for understanding the order of libraries or library search directories
|
|
//LinkAction.CommandArguments += " -Wl,--verbose";
|
|
//LinkAction.CommandArguments += " -Wl,--trace";
|
|
//LinkAction.CommandArguments += " -v";
|
|
|
|
// Add the additional arguments specified by the environment.
|
|
LinkAction.CommandArguments += LinkEnvironment.Config.AdditionalArguments;
|
|
LinkAction.CommandArguments = LinkAction.CommandArguments.Replace("\\\\", "/");
|
|
LinkAction.CommandArguments = LinkAction.CommandArguments.Replace("\\", "/");
|
|
|
|
// prepare a linker script
|
|
FileReference LinkerScriptPath = FileReference.Combine(LinkEnvironment.Config.LocalShadowDirectory, "remove-sym.ldscript");
|
|
if (!LinkEnvironment.Config.LocalShadowDirectory.Exists())
|
|
{
|
|
LinkEnvironment.Config.LocalShadowDirectory.CreateDirectory();
|
|
}
|
|
if (LinkerScriptPath.Exists())
|
|
{
|
|
LinkerScriptPath.Delete();
|
|
}
|
|
|
|
using (StreamWriter Writer = File.CreateText(LinkerScriptPath.FullName))
|
|
{
|
|
Writer.WriteLine("UE4 {");
|
|
Writer.WriteLine(" global: *;");
|
|
Writer.WriteLine(" local: _Znwm;");
|
|
Writer.WriteLine(" _ZnwmRKSt9nothrow_t;");
|
|
Writer.WriteLine(" _Znam;");
|
|
Writer.WriteLine(" _ZnamRKSt9nothrow_t;");
|
|
Writer.WriteLine(" _ZdaPv;");
|
|
Writer.WriteLine(" _ZdaPvRKSt9nothrow_t;");
|
|
Writer.WriteLine(" _ZdlPv;");
|
|
Writer.WriteLine(" _ZdlPvRKSt9nothrow_t;");
|
|
// Hide ALL std:: symbols as they can collide
|
|
// with any c++ library out there (like LLVM)
|
|
// and this may lead to operator new/delete mismatches
|
|
Writer.WriteLine(" _ZNSt8*;");
|
|
// Hide OpenSSL symbols as they can collide with Steam runtime.
|
|
// @todo: hide all Steam runtime symbols
|
|
Writer.WriteLine(" DH_OpenSSL;");
|
|
Writer.WriteLine(" DSA_OpenSSL;");
|
|
Writer.WriteLine(" DSO_METHOD_openssl;");
|
|
Writer.WriteLine(" ECDH_OpenSSL;");
|
|
Writer.WriteLine(" ECDSA_OpenSSL;");
|
|
Writer.WriteLine(" OPENSSL_add_all_algorithms_noconf;");
|
|
Writer.WriteLine(" OpenSSL_add_all_ciphers;");
|
|
Writer.WriteLine(" OpenSSL_add_all_digests;");
|
|
Writer.WriteLine(" OPENSSL_asc2uni;");
|
|
Writer.WriteLine(" OPENSSL_atomic_add;");
|
|
Writer.WriteLine(" OPENSSL_cleanse;");
|
|
Writer.WriteLine(" OPENSSL_DIR_end;");
|
|
Writer.WriteLine(" OPENSSL_DIR_read;");
|
|
Writer.WriteLine(" openssl_dsa_meth;");
|
|
Writer.WriteLine(" openssl_ecdh_meth;");
|
|
Writer.WriteLine(" openssl_ecdsa_meth;");
|
|
Writer.WriteLine(" OPENSSL_gmtime;");
|
|
Writer.WriteLine(" OPENSSL_gmtime_adj;");
|
|
Writer.WriteLine(" OPENSSL_gmtime_diff;");
|
|
Writer.WriteLine(" OPENSSL_ia32_cpuid;");
|
|
Writer.WriteLine(" OPENSSL_ia32_rdrand;");
|
|
Writer.WriteLine(" OPENSSL_ia32_rdseed;");
|
|
Writer.WriteLine(" OPENSSL_ia32cap_loc;");
|
|
Writer.WriteLine(" OPENSSL_ia32cap_P;");
|
|
Writer.WriteLine(" OPENSSL_init;");
|
|
Writer.WriteLine(" OPENSSL_isservice;");
|
|
Writer.WriteLine(" OPENSSL_issetugid;");
|
|
Writer.WriteLine(" OPENSSL_load_builtin_modules;");
|
|
Writer.WriteLine(" OPENSSL_NONPIC_relocated;");
|
|
Writer.WriteLine(" OPENSSL_rdtsc;");
|
|
Writer.WriteLine(" OPENSSL_showfatal;");
|
|
Writer.WriteLine(" OPENSSL_stderr;");
|
|
Writer.WriteLine(" OPENSSL_uni2asc;");
|
|
Writer.WriteLine(" OPENSSL_wipe_cpu;");
|
|
Writer.WriteLine(" OpenSSLDie;");
|
|
Writer.WriteLine(" ui_openssl;");
|
|
Writer.WriteLine(" UI_OpenSSL;");
|
|
Writer.WriteLine("};");
|
|
};
|
|
|
|
LinkAction.CommandArguments += string.Format(" -Wl,--version-script=\"{0}\"", LinkerScriptPath);
|
|
|
|
// Only execute linking on the local PC.
|
|
LinkAction.bCanExecuteRemotely = false;
|
|
|
|
// Prepare a script that will run later, once all shared libraries and the executable
|
|
// are created. This script will be called by action created in FixDependencies()
|
|
if (LinkEnvironment.Config.bIsCrossReferenced && LinkEnvironment.Config.bIsBuildingDLL)
|
|
{
|
|
bool bUseCmdExe = BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Win64 || BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Win32;
|
|
string ScriptName = bUseCmdExe ? "FixDependencies.bat" : "FixDependencies.sh";
|
|
|
|
string FixDepsScriptPath = Path.Combine(LinkEnvironment.Config.LocalShadowDirectory.FullName, ScriptName);
|
|
if (!bHasWipedFixDepsScript)
|
|
{
|
|
bHasWipedFixDepsScript = true;
|
|
Log.TraceVerbose("Creating script: {0}", FixDepsScriptPath);
|
|
StreamWriter Writer = File.CreateText(FixDepsScriptPath);
|
|
|
|
if (bUseCmdExe)
|
|
{
|
|
Writer.Write("@echo off\n");
|
|
Writer.Write("rem Automatically generated by UnrealBuildTool\n");
|
|
Writer.Write("rem *DO NOT EDIT*\n\n");
|
|
}
|
|
else
|
|
{
|
|
Writer.Write("#!/bin/sh\n");
|
|
Writer.Write("# Automatically generated by UnrealBuildTool\n");
|
|
Writer.Write("# *DO NOT EDIT*\n\n");
|
|
Writer.Write("set -o errexit\n");
|
|
}
|
|
Writer.Close();
|
|
}
|
|
|
|
StreamWriter FixDepsScript = File.AppendText(FixDepsScriptPath);
|
|
|
|
string EngineAndGameLibrariesString = "";
|
|
foreach (string Library in EngineAndGameLibraries)
|
|
{
|
|
EngineAndGameLibrariesString += Library;
|
|
}
|
|
|
|
FixDepsScript.Write(string.Format("echo Fixing {0}\n", Path.GetFileName(OutputFile.AbsolutePath)));
|
|
if (!bUseCmdExe)
|
|
{
|
|
FixDepsScript.Write(string.Format("TIMESTAMP=`stat --format %y \"{0}\"`\n", OutputFile.AbsolutePath));
|
|
}
|
|
string FixDepsLine = LinkAction.CommandPath + " " + LinkAction.CommandArguments;
|
|
string Replace = "-Wl,--allow-shlib-undefined";
|
|
|
|
FixDepsLine = FixDepsLine.Replace(Replace, EngineAndGameLibrariesString);
|
|
string OutputFileForwardSlashes = OutputFile.AbsolutePath.Replace("\\", "/");
|
|
FixDepsLine = FixDepsLine.Replace(OutputFileForwardSlashes, OutputFileForwardSlashes + ".fixed");
|
|
FixDepsLine = FixDepsLine.Replace("$", "\\$");
|
|
FixDepsScript.Write(FixDepsLine + "\n");
|
|
if (bUseCmdExe)
|
|
{
|
|
FixDepsScript.Write(string.Format("move /Y \"{0}.fixed\" \"{0}\"\n", OutputFile.AbsolutePath));
|
|
}
|
|
else
|
|
{
|
|
FixDepsScript.Write(string.Format("mv \"{0}.fixed\" \"{0}\"\n", OutputFile.AbsolutePath));
|
|
FixDepsScript.Write(string.Format("touch -d \"$TIMESTAMP\" \"{0}\"\n\n", OutputFile.AbsolutePath));
|
|
}
|
|
FixDepsScript.Close();
|
|
}
|
|
|
|
if (CrossCompiling())
|
|
{
|
|
LinkAction.OutputEventHandler = new DataReceivedEventHandler(CrossCompileOutputReceivedDataEventHandler);
|
|
}
|
|
return OutputFile;
|
|
}
|
|
|
|
public override void CompileCSharpProject(CSharpEnvironment CompileEnvironment, FileReference ProjectFileName, FileReference DestinationFile)
|
|
{
|
|
throw new BuildException("Linux cannot compile C# files");
|
|
}
|
|
|
|
public override void SetupBundleDependencies(List<UEBuildBinary> Binaries, string GameName)
|
|
{
|
|
foreach (UEBuildBinary Binary in Binaries)
|
|
{
|
|
BundleDependencies.Add(FileItem.GetItemByFileReference(Binary.Config.OutputFilePath));
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Converts the passed in path from UBT host to compiler native format.
|
|
/// </summary>
|
|
public override string ConvertPath(string OriginalPath)
|
|
{
|
|
if (BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Linux)
|
|
{
|
|
return OriginalPath.Replace("\\", "/");
|
|
}
|
|
else
|
|
{
|
|
return OriginalPath;
|
|
}
|
|
}
|
|
|
|
public override ICollection<FileItem> PostBuild(FileItem Executable, LinkEnvironment BinaryLinkEnvironment)
|
|
{
|
|
var OutputFiles = base.PostBuild(Executable, BinaryLinkEnvironment);
|
|
|
|
if (BinaryLinkEnvironment.Config.bIsBuildingDLL || BinaryLinkEnvironment.Config.bIsBuildingLibrary)
|
|
{
|
|
return OutputFiles;
|
|
}
|
|
|
|
FileItem FixDepsOutputFile = FixDependencies(BinaryLinkEnvironment, Executable);
|
|
if (FixDepsOutputFile != null)
|
|
{
|
|
OutputFiles.Add(FixDepsOutputFile);
|
|
}
|
|
|
|
return OutputFiles;
|
|
}
|
|
|
|
public override void StripSymbols(string SourceFileName, string TargetFileName)
|
|
{
|
|
File.Copy(SourceFileName, TargetFileName, true);
|
|
|
|
ProcessStartInfo StartInfo = new ProcessStartInfo();
|
|
StartInfo.FileName = GetStripPath(PlatformContext.GetActiveArchitecture());
|
|
StartInfo.Arguments = "--strip-debug \"" + TargetFileName + "\"";
|
|
StartInfo.UseShellExecute = false;
|
|
StartInfo.CreateNoWindow = true;
|
|
Utils.RunLocalProcessAndLogOutput(StartInfo);
|
|
}
|
|
}
|
|
}
|