Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="PlatformType"></param>
        /// <param name="SourceFile"></param>
        /// <param name="TargetFile"></param>
        public static void StripSymbols(UnrealTargetPlatform PlatformType, FileReference SourceFile, FileReference TargetFile)
        {
            IOSProjectSettings ProjectSettings = ((IOSPlatform)UEBuildPlatform.GetBuildPlatform(PlatformType)).ReadProjectSettings(null);
            IOSToolChain       ToolChain       = new IOSToolChain(null, ProjectSettings);

            ToolChain.StripSymbols(SourceFile, TargetFile);
        }
Пример #2
0
 public override void ValidateBuildConfiguration(CPPTargetConfiguration Configuration, CPPTargetPlatform Platform, bool bCreateDebugInfo)
 {
     BuildConfiguration.bUsePCHFiles   = false;
     BuildConfiguration.bUseSharedPCHs = false;
     BuildConfiguration.bCheckExternalHeadersForModification = false;
     BuildConfiguration.bCheckSystemHeadersForModification   = false;
     BuildConfiguration.ProcessorCountMultiplier             = IOSToolChain.GetAdjustedProcessorCountMultiplier();
     BuildConfiguration.bDeployAfterCompile = true;
 }
        public override int Execute(CommandLineArguments Arguments)
        {
            Arguments.ApplyTo(this);
            Arguments.CheckAllArgumentsUsed();

            // Run the PostBuildSync command
            IOSPostBuildSyncTarget Target = BinaryFormatterUtils.Load <IOSPostBuildSyncTarget>(InputFile);

            IOSToolChain.PostBuildSync(Target);

            return(0);
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ProjectFile"></param>
        /// <param name="Executable"></param>
        /// <param name="StageDirectory"></param>
        /// <param name="PlatformType"></param>
        public static void GenerateAssetCatalog(FileReference ProjectFile, FileReference Executable, DirectoryReference StageDirectory, UnrealTargetPlatform PlatformType)
        {
            CppPlatform Platform = PlatformType == UnrealTargetPlatform.IOS ? CppPlatform.IOS : CppPlatform.TVOS;

            // Determine whether the user has modified icons that require a remote Mac to build.
            bool bUserImagesExist           = false;
            DirectoryReference ResourcesDir = IOSToolChain.GenerateAssetCatalog(ProjectFile, Platform, ref bUserImagesExist);

            // Don't attempt to do anything remotely if the user is using the default UE4 images.
            if (!bUserImagesExist)
            {
                return;
            }

            // Also don't attempt to use a remote Mac if packaging for TVOS on PC.
            if (Platform == CppPlatform.TVOS && BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Mac)
            {
                return;
            }

            // Compile the asset catalog immediately
            if (BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Mac)
            {
                FileReference OutputFile = FileReference.Combine(StageDirectory, "Assets.car");

                RemoteMac Remote = new RemoteMac(ProjectFile);
                Remote.RunAssetCatalogTool(Platform, ResourcesDir, OutputFile);
            }
            else
            {
                // Get the output file
                FileReference OutputFile = IOSToolChain.GetAssetCatalogFile(Platform, Executable);

                // Delete the Assets.car file to force the asset catalog to build every time, because
                // removals of files or copies of icons (for instance) with a timestamp earlier than
                // the last generated Assets.car will result in nothing built.
                if (FileReference.Exists(OutputFile))
                {
                    FileReference.Delete(OutputFile);
                }

                // Run the process locally
                using (Process Process = new Process())
                {
                    Process.StartInfo.FileName        = "/usr/bin/xcrun";
                    Process.StartInfo.Arguments       = IOSToolChain.GetAssetCatalogArgs(Platform, ResourcesDir.FullName, OutputFile.Directory.FullName);;
                    Process.StartInfo.UseShellExecute = false;
                    Utils.RunLocalProcess(Process);
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Runs the actool utility on a directory to create an Assets.car file
        /// </summary>
        /// <param name="Platform">The target platform</param>
        /// <param name="InputDir">Input directory containing assets</param>
        /// <param name="OutputFile">Path to the Assets.car file to produce</param>
        public void RunAssetCatalogTool(CppPlatform Platform, DirectoryReference InputDir, FileReference OutputFile)
        {
            Log.TraceInformation("Running asset catalog tool for {0}: {1} -> {2}", Platform, InputDir, OutputFile);

            string RemoteInputDir = GetRemotePath(InputDir);

            UploadDirectory(InputDir);

            string RemoteOutputFile = GetRemotePath(OutputFile);

            Execute(RemoteBaseDir, String.Format("rm -f {0}", EscapeShellArgument(RemoteOutputFile)));

            string RemoteOutputDir = Path.GetDirectoryName(RemoteOutputFile).Replace(Path.DirectorySeparatorChar, '/');

            Execute(RemoteBaseDir, String.Format("mkdir -p {0}", EscapeShellArgument(RemoteOutputDir)));

            string RemoteArguments = IOSToolChain.GetAssetCatalogArgs(Platform, RemoteInputDir, RemoteOutputDir);

            if (Execute(RemoteBaseDir, String.Format("/usr/bin/xcrun {0}", RemoteArguments)) != 0)
            {
                throw new BuildException("Failed to run actool.");
            }
            DownloadFile(OutputFile);
        }
Пример #6
0
 /// <summary>
 /// Converts the passed in path from UBT host to compiler native format.
 /// </summary>
 /// <param name="OriginalPath">The path to convert</param>
 /// <returns>The path in native format for the toolchain</returns>
 public override string ConvertPath(string OriginalPath)
 {
     return(IOSToolChain.ConvertPath(OriginalPath));
 }
Пример #7
0
 public override void PostCodeGeneration(UHTManifest Manifest)
 {
     IOSToolChain.PostCodeGeneration(Manifest);
 }
Пример #8
0
 public override void PostBuildSync(UEBuildTarget Target)
 {
     IOSToolChain.PostBuildSync(Target);
 }
Пример #9
0
 public override void PreBuildSync()
 {
     IOSToolChain.PreBuildSync();
 }
Пример #10
0
        public override bool PrepTargetForDeployment(UEBuildTarget InTarget)
        {
            string GameName         = InTarget.TargetName;
            string BuildPath        = (GameName == "UE4Game" ? "../../Engine" : InTarget.ProjectDirectory) + "/Binaries/IOS";
            string ProjectDirectory = InTarget.ProjectDirectory;
            bool   bIsUE4Game       = GameName.Contains("UE4Game");

            string DecoratedGameName;

            if (InTarget.Configuration == UnrealTargetConfiguration.Development)
            {
                DecoratedGameName = GameName;
            }
            else
            {
                DecoratedGameName = String.Format("{0}-{1}-{2}", GameName, InTarget.Platform.ToString(), InTarget.Configuration.ToString());
            }

            if (BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Mac && Environment.GetEnvironmentVariable("UBT_NO_POST_DEPLOY") != "true")
            {
                return(PrepForUATPackageOrDeploy(GameName, ProjectDirectory, BuildPath + "/" + DecoratedGameName, "../../Engine", false, "", false));
            }
            else
            {
                // If it is requested, send the app bundle back to the platform executing these commands.
                if (BuildConfiguration.bCopyAppBundleBackToDevice)
                {
                    Log.TraceInformation("Copying binaries back to this device...");

                    IOSToolChain Toolchain = UEToolChain.GetPlatformToolChain(CPPTargetPlatform.IOS) as IOSToolChain;

                    try
                    {
                        string BinaryDir = Path.GetDirectoryName(InTarget.OutputPath) + "\\";
                        if (BinaryDir.EndsWith(InTarget.AppName + "\\Binaries\\IOS\\") && InTarget.TargetType != TargetRules.TargetType.Game)
                        {
                            BinaryDir = BinaryDir.Replace(InTarget.TargetType.ToString(), "Game");
                        }

                        // Get the app bundle's name
                        string AppFullName = InTarget.AppName;
                        if (InTarget.Configuration != UnrealTargetConfiguration.Development)
                        {
                            AppFullName += "-" + InTarget.Platform.ToString();
                            AppFullName += "-" + InTarget.Configuration.ToString();
                        }

                        foreach (string BinaryPath in Toolchain.BuiltBinaries)
                        {
                            if (!BinaryPath.Contains("Dummy"))
                            {
                                RPCUtilHelper.CopyFile(Toolchain.ConvertPath(BinaryPath), BinaryPath, false);
                            }
                        }
                        Log.TraceInformation("Copied binaries successfully.");
                    }
                    catch (Exception)
                    {
                        Log.TraceInformation("Copying binaries back to this device failed.");
                    }
                }

                GeneratePList(ProjectDirectory, bIsUE4Game, GameName, Path.GetFileNameWithoutExtension(UnrealBuildTool.GetUProjectFile()), "../../Engine", "");
            }
            return(true);
        }
Пример #11
0
		public override bool PrepTargetForDeployment(UEBuildTarget InTarget)
		{
			string GameName = InTarget.AppName;
			string BuildPath = InTarget.ProjectDirectory + "/Binaries/IOS";
			string ProjectDirectory = InTarget.ProjectDirectory;

			if (BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Mac && Environment.GetEnvironmentVariable("UBT_NO_POST_DEPLOY") != "true")
			{
				string DecoratedGameName;
				if (InTarget.Configuration == UnrealTargetConfiguration.Development)
				{
					DecoratedGameName = GameName;
				}
				else
				{
					DecoratedGameName = String.Format("{0}-{1}-{2}", GameName, InTarget.Platform.ToString(), InTarget.Configuration.ToString());
				}

				return PrepForUATPackageOrDeploy(GameName, ProjectDirectory, BuildPath + "/" + DecoratedGameName, "../../Engine", false, "");
			}
			else
			{
				// If it is requested, send the app bundle back to the platform executing these commands.
				if (BuildConfiguration.bCopyAppBundleBackToDevice)
				{
					Log.TraceInformation("Copying binaries back to this device...");

					IOSToolChain Toolchain = UEToolChain.GetPlatformToolChain(CPPTargetPlatform.IOS) as IOSToolChain;

					try
					{
						string BinaryDir = Path.GetDirectoryName(InTarget.OutputPath) + "\\";
						if (BinaryDir.EndsWith(InTarget.AppName + "\\Binaries\\IOS\\") && InTarget.TargetType != TargetRules.TargetType.Game)
						{
							BinaryDir = BinaryDir.Replace(InTarget.TargetType.ToString(), "Game");
						}

						// Get the app bundle's name
						string AppFullName = InTarget.AppName;
						if (InTarget.Configuration != UnrealTargetConfiguration.Development)
						{
							AppFullName += "-" + InTarget.Platform.ToString();
							AppFullName += "-" + InTarget.Configuration.ToString();
						}

						foreach (string BinaryPath in Toolchain.BuiltBinaries)
						{
							if (!BinaryPath.Contains("Dummy"))
							{
								RPCUtilHelper.CopyFile(Toolchain.ConvertPath(BinaryPath), BinaryPath, false);
							}
						}
						Log.TraceInformation("Copied binaries successfully.");
					}
					catch (Exception)
					{
						Log.TraceInformation("Copying binaries back to this device failed.");
					}
				}

				// install the provision
/*				string ProvisionWithPrefix = "../../Engine/Build/IOS/UE4Game.mobileprovision";
				if (File.Exists(BuildPath + "/" + GameName + ".mobileprovision"))
				{
					ProvisionWithPrefix = BuildPath + "/" + GameName + ".mobileprovision";
				}
				else
				{
					if (File.Exists(BuildPath + "/NotForLicensees/" + GameName + ".mobileprovision"))
					{
						ProvisionWithPrefix = BuildPath + "/NotForLicensees/" + GameName + ".mobileprovision";
					}
					else if (!File.Exists(ProvisionWithPrefix))
					{
						ProvisionWithPrefix = "../../Engine/Build/IOS/NotForLicensees/UE4Game.mobileprovision";
					}
				}
				string LibraryDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "/Apple Computer/MobileDevice/Provisioning Profiles/";
				if (File.Exists(ProvisionWithPrefix))
				{
					Directory.CreateDirectory(LibraryDir);
					File.Copy(ProvisionWithPrefix, LibraryDir + GameName + ".mobileprovision", true);
					FileInfo DestFileInfo = new FileInfo(LibraryDir + GameName + ".mobileprovision");
					DestFileInfo.Attributes = DestFileInfo.Attributes & ~FileAttributes.ReadOnly;
				}

				// install the distribution provision
				ProvisionWithPrefix = "../../Engine/Build/IOS/UE4Game_Distro.mobileprovision";
				if (File.Exists(BuildPath + "/" + GameName + "_Distro.mobileprovision"))
				{
					ProvisionWithPrefix = BuildPath + "/" + GameName + "_Distro.mobileprovision";
				}
				else
				{
					if (File.Exists(BuildPath + "/NotForLicensees/" + GameName + "_Distro.mobileprovision"))
					{
						ProvisionWithPrefix = BuildPath + "/NotForLicensees/" + GameName + "_Distro.mobileprovision";
					}
					else if (!File.Exists(ProvisionWithPrefix))
					{
						ProvisionWithPrefix = "../../Engine/Build/IOS/NotForLicensees/UE4Game_Distro.mobileprovision";
					}
				}
				if (File.Exists(ProvisionWithPrefix))
				{
					File.Copy(ProvisionWithPrefix, LibraryDir + GameName + "_Distro.mobileprovision", true);
					FileInfo DestFileInfo = new FileInfo(LibraryDir + GameName + "_Distro.mobileprovision");
					DestFileInfo.Attributes = DestFileInfo.Attributes & ~FileAttributes.ReadOnly;
				}*/
			}
			return true;
		}
Пример #12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ProjectFile"></param>
        /// <param name="Executable"></param>
        /// <param name="StageDirectory"></param>
        /// <param name="PlatformType"></param>
        public static void GenerateAssetCatalog(FileReference ProjectFile, string Executable, string StageDirectory, UnrealTargetPlatform PlatformType)
        {
            // Initialize the toolchain.
            IOSProjectSettings ProjectSettings = ((IOSPlatform)UEBuildPlatform.GetBuildPlatform(PlatformType)).ReadProjectSettings(null);
            IOSToolChain       ToolChain       = new IOSToolChain(ProjectFile, ProjectSettings);

            // Determine whether the user has modified icons that require a remote Mac to build.
            CppPlatform Platform         = PlatformType == UnrealTargetPlatform.IOS ? CppPlatform.IOS : CppPlatform.TVOS;
            bool        bUserImagesExist = false;

            ToolChain.GenerateAssetCatalog(Platform, ref bUserImagesExist);

            // Don't attempt to do anything remotely if the user is using the default UE4 images.
            if (!bUserImagesExist)
            {
                return;
            }

            // Also don't attempt to use a remote Mac if packaging for TVOS on PC.
            if (Platform == CppPlatform.TVOS && BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Mac)
            {
                return;
            }

            // Save off the current bUseRPCUtil setting to restore at the end of this function.
            // At this time, iPhonePackager needs to be called with bUseRPCUtil == true.
            bool bSaveUseRPCUtil = RemoteToolChain.bUseRPCUtil;

            // Initialize the remote calling environment, taking into account the user's SSH setting.
            ToolChain.SetUpGlobalEnvironment(false);

            // Build the asset catalog ActionGraph.
            ActionGraph     ActionGraph = new ActionGraph();
            List <FileItem> OutputFiles = new List <FileItem>();

            ToolChain.CompileAssetCatalog(FileItem.GetItemByPath(Executable), Platform, ActionGraph, OutputFiles);

            ActionGraph.FinalizeActionGraph();

            // I'm not sure how to derive the UE4Game and Development arguments programmatically.
            string[] Arguments = new string[] { "UE4Game", (PlatformType == UnrealTargetPlatform.IOS ? "IOS" : "TVOS"), "Development", "-UniqueBuildEnvironment" };

            // Perform all of the setup necessary to actually execute the ActionGraph instance.
            ReadOnlyBuildVersion Version        = new ReadOnlyBuildVersion(BuildVersion.ReadDefault());
            List <string[]>      TargetSettings = new List <string[]>();

            TargetSettings.Add(Arguments);
            var Targets = new List <UEBuildTarget>();
            Dictionary <UEBuildTarget, CPPHeaders> TargetToHeaders = new Dictionary <UEBuildTarget, CPPHeaders>();
            List <TargetDescriptor> TargetDescs = new List <TargetDescriptor>();

            foreach (string[] TargetSetting in TargetSettings)
            {
                TargetDescs.AddRange(TargetDescriptor.ParseCommandLine(TargetSetting, ref ProjectFile));
            }
            foreach (TargetDescriptor TargetDesc in TargetDescs)
            {
                UEBuildTarget Target = UEBuildTarget.CreateTarget(TargetDesc, Arguments, false, Version);
                if (Target == null)
                {
                    continue;
                }
                Targets.Add(Target);
                TargetToHeaders.Add(Target, null);
            }

            bool bIsRemoteCompile = BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Mac;

            // Create the build configuration object, and read the settings
            BuildConfiguration BuildConfiguration = new BuildConfiguration();

            XmlConfig.ApplyTo(BuildConfiguration);
            CommandLine.ParseArguments(Arguments, BuildConfiguration);
            BuildConfiguration.bUseUBTMakefiles = false;

            Action[] PrerequisiteActions;
            {
                HashSet <Action> PrerequisiteActionsSet = new HashSet <Action>();
                foreach (FileItem OutputFile in OutputFiles)
                {
                    ActionGraph.GatherPrerequisiteActions(OutputFile, ref PrerequisiteActionsSet);
                }
                PrerequisiteActions = PrerequisiteActionsSet.ToArray();
            }

            // Copy any asset catalog files to the remote Mac, if necessary.
            foreach (UEBuildTarget Target in Targets)
            {
                UEBuildPlatform.GetBuildPlatform(Target.Platform).PreBuildSync();
            }

            // Begin execution of the ActionGraph.
            Dictionary <UEBuildTarget, List <FileItem> > TargetToOutdatedPrerequisitesMap;
            List <Action> ActionsToExecute = ActionGraph.GetActionsToExecute(BuildConfiguration, PrerequisiteActions, Targets, TargetToHeaders, true, true, out TargetToOutdatedPrerequisitesMap);
            string        ExecutorName     = "Unknown";
            bool          bSuccess         = ActionGraph.ExecuteActions(BuildConfiguration, ActionsToExecute, bIsRemoteCompile, out ExecutorName, "", EHotReload.Disabled);

            if (bSuccess)
            {
                if (bIsRemoteCompile)
                {
                    // Copy the remotely built AssetCatalog directory locally.
                    foreach (FileItem OutputFile in OutputFiles)
                    {
                        string   RemoteDirectory = System.IO.Path.GetDirectoryName(OutputFile.AbsolutePath).Replace("\\", "/");
                        FileItem LocalExecutable = ToolChain.RemoteToLocalFileItem(FileItem.GetItemByPath(Executable));
                        string   LocalDirectory  = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(LocalExecutable.AbsolutePath), "AssetCatalog");
                        LocalDirectory = StageDirectory;
                        RPCUtilHelper.CopyDirectory(RemoteDirectory, LocalDirectory, RPCUtilHelper.ECopyOptions.DoNotReplace);
                    }
                }
                else
                {
                    // Copy the built AssetCatalog directory to the StageDirectory.
                    foreach (FileItem OutputFile in OutputFiles)
                    {
                        string SourceDirectory = System.IO.Path.GetDirectoryName(OutputFile.AbsolutePath).Replace("\\", "/");
                        System.IO.DirectoryInfo SourceDirectoryInfo = new System.IO.DirectoryInfo(SourceDirectory);
                        if (!System.IO.Directory.Exists(StageDirectory))
                        {
                            System.IO.Directory.CreateDirectory(StageDirectory);
                        }
                        System.IO.FileInfo[] SourceFiles = SourceDirectoryInfo.GetFiles();
                        foreach (System.IO.FileInfo SourceFile in SourceFiles)
                        {
                            string DestinationPath = System.IO.Path.Combine(StageDirectory, SourceFile.Name);
                            SourceFile.CopyTo(DestinationPath, true);
                        }
                    }
                }
            }

            // Restore the former bUseRPCUtil setting.
            RemoteToolChain.bUseRPCUtil = bSaveUseRPCUtil;
        }