public override void ModifyBuildProducts(UEBuildBinary Binary, Dictionary<FileReference, BuildProductType> BuildProducts)
		{
			// the binary will have all of the .so's in the output files, we need to trim down to the shared apk (which is what needs to go into the manifest)
			if (Binary.Config.Type != UEBuildBinaryType.StaticLibrary)
			{
				foreach (FileReference BinaryPath in Binary.Config.OutputFilePaths)
				{
					FileReference ApkFile = BinaryPath.ChangeExtension(".apk");
					BuildProducts.Add(ApkFile, BuildProductType.Executable);
				}
			}
		}
Exemple #2
0
        public override bool PrepTargetForDeployment(UEBuildTarget InTarget)
        {
            Log.TraceInformation("Deploying now!");

            string IntermediateDirectory = InTarget.AppName + "/Intermediate/Build/Mac/" + InTarget.AppName + "/" + InTarget.Configuration;

            if (!Directory.Exists("../../" + IntermediateDirectory))
            {
                IntermediateDirectory = "Engine/Intermediate/Build/Mac/" + InTarget.AppName + "/" + InTarget.Configuration;
            }

            MacToolChain Toolchain = UEToolChain.GetPlatformToolChain(CPPTargetPlatform.Mac) as MacToolChain;

            string FixDylibDepsScript      = Path.Combine(IntermediateDirectory, "FixDylibDependencies.sh");
            string FinalizeAppBundleScript = Path.Combine(IntermediateDirectory, "FinalizeAppBundle.sh");

            string RemoteWorkingDir = "";

            bool bIsStaticLibrary = InTarget.OutputPath.EndsWith(".a");

            if (BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Mac)
            {
                if (!bIsStaticLibrary)
                {
                    // Copy the command scripts to the intermediate on the target Mac.
                    string RemoteFixDylibDepsScript = Toolchain.ConvertPath(Path.GetFullPath(FixDylibDepsScript));
                    RemoteFixDylibDepsScript = RemoteFixDylibDepsScript.Replace("../../../../", "../../");
                    RPCUtilHelper.CopyFile("../../" + FixDylibDepsScript, RemoteFixDylibDepsScript, true);

                    if (!InTarget.GlobalLinkEnvironment.Config.bIsBuildingConsoleApplication)
                    {
                        string RemoteFinalizeAppBundleScript = Toolchain.ConvertPath(Path.GetFullPath(FinalizeAppBundleScript));
                        RemoteFinalizeAppBundleScript = RemoteFinalizeAppBundleScript.Replace("../../../../", "../../");
                        RPCUtilHelper.CopyFile("../../" + FinalizeAppBundleScript, RemoteFinalizeAppBundleScript, true);
                    }


                    // run it remotely
                    RemoteWorkingDir = Toolchain.ConvertPath(Path.GetDirectoryName(Path.GetFullPath(FixDylibDepsScript)));

                    Log.TraceInformation("Running FixDylibDependencies.sh...");
                    Hashtable Results = RPCUtilHelper.Command(RemoteWorkingDir, "/bin/sh", "FixDylibDependencies.sh", null);
                    if (Results != null)
                    {
                        string Result = (string)Results["CommandOutput"];
                        if (Result != null)
                        {
                            Log.TraceInformation(Result);
                        }
                    }

                    if (!InTarget.GlobalLinkEnvironment.Config.bIsBuildingConsoleApplication)
                    {
                        Log.TraceInformation("Running FinalizeAppBundle.sh...");
                        Results = RPCUtilHelper.Command(RemoteWorkingDir, "/bin/sh", "FinalizeAppBundle.sh", null);
                        if (Results != null)
                        {
                            string Result = (string)Results["CommandOutput"];
                            if (Result != null)
                            {
                                Log.TraceInformation(Result);
                            }
                        }
                    }
                }


                // If it is requested, send the app bundle back to the platform executing these commands.
                if (BuildConfiguration.bCopyAppBundleBackToDevice)
                {
                    Log.TraceInformation("Copying binaries back to this device...");

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

                        string RemoteBinariesDir = Toolchain.ConvertPath(BinaryDir);
                        string LocalBinariesDir  = BinaryDir;

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

                        if (!InTarget.GlobalLinkEnvironment.Config.bIsBuildingConsoleApplication)
                        {
                            AppFullName += ".app";
                        }

                        List <string> NotBundledBinaries = new List <string>();
                        foreach (string BinaryPath in Toolchain.BuiltBinaries)
                        {
                            if (InTarget.GlobalLinkEnvironment.Config.bIsBuildingConsoleApplication || bIsStaticLibrary || !BinaryPath.StartsWith(LocalBinariesDir + AppFullName))
                            {
                                NotBundledBinaries.Add(BinaryPath);
                            }
                        }

                        // Zip the app bundle for transferring.
                        if (!InTarget.GlobalLinkEnvironment.Config.bIsBuildingConsoleApplication && !bIsStaticLibrary)
                        {
                            string ZipCommand = "zip -0 -r -y -T \"" + AppFullName + ".zip\" \"" + AppFullName + "\"";
                            RPCUtilHelper.Command(RemoteBinariesDir, ZipCommand, "", null);

                            // Copy the AppBundle back to the source machine
                            string LocalZipFileLocation  = LocalBinariesDir + AppFullName + ".zip ";
                            string RemoteZipFileLocation = RemoteBinariesDir + AppFullName + ".zip";

                            RPCUtilHelper.CopyFile(RemoteZipFileLocation, LocalZipFileLocation, false);

                            // Extract the copied app bundle (in zip format) to the local binaries directory
                            using (ZipFile AppBundleZip = ZipFile.Read(LocalZipFileLocation))
                            {
                                foreach (ZipEntry Entry in AppBundleZip)
                                {
                                    Entry.Extract(LocalBinariesDir, ExtractExistingFileAction.OverwriteSilently);
                                }
                            }

                            // Delete the zip as we no longer need/want it.
                            File.Delete(LocalZipFileLocation);
                            RPCUtilHelper.Command(RemoteBinariesDir, "rm -f \"" + AppFullName + ".zip\"", "", null);
                        }

                        if (NotBundledBinaries.Count > 0)
                        {
                            foreach (string BinaryPath in NotBundledBinaries)
                            {
                                RPCUtilHelper.CopyFile(Toolchain.ConvertPath(BinaryPath), BinaryPath, false);
                            }
                        }

                        Log.TraceInformation("Copied binaries successfully.");
                    }
                    catch (Exception)
                    {
                        Log.TraceInformation("Copying binaries back to this device failed.");
                    }
                }
            }

            return(true);
        }
Exemple #3
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);
        }
Exemple #4
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;
		}