Ejemplo n.º 1
0
		static public bool DownloadFile(string MacName, string SourceFilename, string DestFilename)
		{
			Hashtable Results = null;

			if (Config.bUseRPCUtil)
			{
				if (!ConditionalInitRemoting(MacName))
				{
					return false;
				}

				Results = RPCCommandHelper.RPCDownload(RPCSocket, SourceFilename, DestFilename);
			}
			else
			{
				Results = SSHCommandHelper.DownloadFile(MacName, SourceFilename, DestFilename);
			}

			// success if exitcode is 0 or unspecified
			if (Results["ExitCode"] != null)
			{
				return (Int64)Results["ExitCode"] == 0;
			}
			return true;
		}
Ejemplo n.º 2
0
        /**
         * Handle the plethora of environment variables required to remote to the Mac
         */
        static public void ConfigurePaths()
        {
            string MachineName = Environment.MachineName;

            XcodeDeveloperDir = Utilities.GetEnvironmentVariable("ue.XcodeDeveloperDir", "/Applications/Xcode.app/Contents/Developer/");

            // MacName=%ue4.iPhone_SigningServerName%
            MacName = Config.OverrideMacName != null ? Config.OverrideMacName : Utilities.GetEnvironmentVariable("ue.IOSSigningServer", "a1487");
            iPhone_SigningDevRootMac = Config.OverrideDevRoot != null ? Config.OverrideDevRoot : "/UE4/Builds";

            if (!Config.bUseRPCUtil)
            {
                bool Results = SSHCommandHelper.Command(MacName, "xcode-select --print-path", "/usr/bin");
                if (Results)
                {
                    XcodeDeveloperDir = (string)SSHCommandHelper.SSHReturn["CommandOutput"] + "/";
                    XcodeDeveloperDir = XcodeDeveloperDir.TrimEnd();
                }
            }

            // get the path to mirror into on the Mac
            string BinariesDir = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, @"..\.."));
            string Root        = Path.GetPathRoot(BinariesDir);
            string BranchPath  = MachineName + "/" + Root[0].ToString() + "/" + BinariesDir.Substring(Root.Length);

            BranchPath = BranchPath.Replace('\\', '/');

            // similar for the game path (strip off the D:\ tpe root)
            BinariesDir = Path.GetFullPath(Path.Combine(Config.BinariesDirectory, ".."));
            Root        = Path.GetPathRoot(BinariesDir);

            string GameBranchPath;

            if (Program.GameName == "UE4Game")
            {
                GameBranchPath = BranchPath;
            }
            else
            {
                GameBranchPath = MachineName + "/" + Root[0].ToString() + "/" + BinariesDir.Substring(Root.Length);
                GameBranchPath = GameBranchPath.Replace('\\', '/');
            }

            Console.WriteLine("BranchPath = {0} --- GameBranchPath = {1}", BranchPath, GameBranchPath);

            // generate the directories to recursively copy into later on
            MacStagingRootDir  = string.Format("{0}/{1}/" + Config.OSString, iPhone_SigningDevRootMac, GameBranchPath);
            MacStagingRootDir  = MacStagingRootDir.Replace("//", "/");
            MacBinariesDir     = string.Format("{0}/{1}/" + Config.OSString, iPhone_SigningDevRootMac, GameBranchPath);
            MacBinariesDir     = MacBinariesDir.Replace("//", "/");
            MacXcodeStagingDir = string.Format("{0}/{1}/" + Config.OSString + "/XcodeSupportFiles", iPhone_SigningDevRootMac, GameBranchPath);
            MacXcodeStagingDir = MacXcodeStagingDir.Replace("//", "/");

            MacMobileProvisionFilename = MachineName + "_UE4Temp.mobileprovision";
            MacSigningIdentityFilename = MachineName + "_UE4Temp.p12";
        }
Ejemplo n.º 3
0
        static public bool BatchUploadFolder(string MacName, string SourceFolder, string DestFolder, bool bDeleteTarget)
        {
            if (Config.bUseRPCUtil)
            {
                if (!ConditionalInitRemoting(MacName))
                {
                    return(false);
                }


                if (bDeleteTarget)
                {
                    // tell Mac to delete target if requested
                    RPCUtility.CommandHelper.RemoveDirectory(RPCSocket, DestFolder);
                }
            }

            Program.Log(" ... '" + SourceFolder + "' -> '" + DestFolder + "'");

            DirectoryInfo SourceFolderInfo = new DirectoryInfo(SourceFolder);

            if (!SourceFolderInfo.Exists)
            {
                Program.Error("Source folder does not exist");
                return(false);
            }

            // gather the files to batch upload
            List <string> FilesToUpload = new List <string>();

            RecursiveBatchUploadFolder(SourceFolderInfo, DestFolder, FilesToUpload);

            if (Config.bUseRPCUtil)
            {
                // send them off!
                RPCUtility.CommandHelper.RPCBatchUpload(RPCSocket, FilesToUpload.ToArray());
            }
            else
            {
                SSHCommandHelper.BatchUpload(MacName, FilesToUpload.ToArray());
            }

            return(true);
        }
Ejemplo n.º 4
0
        /**
         * Handle spawning of the RPCUtility with parameters
         */
        public static bool RunRPCUtilty(string RPCCommand, bool bIsSilent = false)
        {
            string     CommandLine        = "";
            string     WorkingFolder      = "";
            string     DisplayCommandLine = "";
            string     TempKeychain       = "$HOME/Library/Keychains/UE4TempKeychain.keychain";
            string     Certificate        = "XcodeSupportFiles/" + MacSigningIdentityFilename;
            string     LoginKeychain      = "$HOME/Library/Keychains/login.keychain";
            ErrorCodes Error = ErrorCodes.Error_Unknown;

            switch (RPCCommand.ToLowerInvariant())
            {
            case "deletemacstagingfiles":
                Program.Log(" ... deleting staging files on the Mac");
                DisplayCommandLine = "rm -rf Payload";
                CommandLine        = "\"" + MacStagingRootDir + "\" " + DisplayCommandLine;
                WorkingFolder      = "\"" + MacStagingRootDir + "\"";
                break;

            case "ensureprovisiondirexists":
                Program.Log(" ... creating provisioning profiles directory");

                DisplayCommandLine = String.Format("mkdir -p ~/Library/MobileDevice/Provisioning\\ Profiles");

                CommandLine   = "\"" + MacXcodeStagingDir + "\" " + DisplayCommandLine;
                WorkingFolder = "\"" + MacXcodeStagingDir + "\"";
                break;

            case "installprovision":
                // Note: The provision must have already been copied over to the Mac
                Program.Log(" ... installing .mobileprovision");

                DisplayCommandLine = String.Format("cp -f {0} ~/Library/MobileDevice/Provisioning\\ Profiles", MacMobileProvisionFilename);

                CommandLine   = "\"" + MacXcodeStagingDir + "\" " + DisplayCommandLine;
                WorkingFolder = "\"" + MacXcodeStagingDir + "\"";
                break;

            case "removeprovision":
                Program.Log(" ... removing .mobileprovision");
                DisplayCommandLine = String.Format("rm -f ~/Library/MobileDevice/Provisioning\\ Profiles/{0}", MacMobileProvisionFilename);
                CommandLine        = "\"" + MacXcodeStagingDir + "\" " + DisplayCommandLine;
                WorkingFolder      = "\"" + MacXcodeStagingDir + "\"";
                break;

            case "setexec":
                // Note: The executable must have already been copied over
                Program.Log(" ... setting executable bit");
                DisplayCommandLine = "chmod a+x \'" + RemoteExecutablePath + "\'";
                CommandLine        = "\"" + MacStagingRootDir + "\" " + DisplayCommandLine;
                WorkingFolder      = "\"" + MacStagingRootDir + "\"";
                break;

            case "prepackage":
                Program.Log(" ... running prepackage script remotely ");
                DisplayCommandLine = String.Format("sh prepackage.sh {0} " + Config.OSString + " {1} {2}", Program.GameName, Program.GameConfiguration, Program.Architecture);
                CommandLine        = "\"" + MacXcodeStagingDir + "\" " + DisplayCommandLine;
                WorkingFolder      = "\"" + MacXcodeStagingDir + "\"";
                break;

            case "makeapp":
                Program.Log(" ... making application (codesign, etc...)");
                Program.Log("  Using signing identity '{0}'", Config.CodeSigningIdentity);
                DisplayCommandLine = "security -v unlock-keychain -p \"A\" \"" + TempKeychain + "\" && " + CurrentBaseXCodeCommandLine;
                CommandLine        = "\"" + MacXcodeStagingDir + "/..\" " + DisplayCommandLine;
                WorkingFolder      = "\"" + MacXcodeStagingDir + "/..\"";
                Error = ErrorCodes.Error_RemoteCertificatesNotFound;
                break;

            case "createkeychain":
                Program.Log(" ... creating temporary key chain with signing certificate");
                Program.Log("  Using signing identity '{0}'", Config.CodeSigningIdentity);
                DisplayCommandLine = "security create-keychain -p \"A\" \"" + TempKeychain + "\" && security list-keychains -s \"" + TempKeychain + "\" && security list-keychains && security set-keychain-settings -t 3600 -l  \"" + TempKeychain + "\" && security -v unlock-keychain -p \"A\" \"" + TempKeychain + "\" && security import " + Certificate + " -k \"" + TempKeychain + "\" -P \"A\" -T /usr/bin/codesign -T /usr/bin/security -t agg && CERT_IDENTITY=$(security find-identity -v -p codesigning \"" + TempKeychain + "\" | head -1 | grep '\"' | sed -e 's/[^\"]*\"//' -e 's/\".*//') && security default-keychain -s \"" + TempKeychain + "\" && security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k \"A\" -D \"$CERT_IDENTITY\" -t private " + TempKeychain;
                CommandLine        = "\"" + MacXcodeStagingDir + "/..\" " + DisplayCommandLine;
                WorkingFolder      = "\"" + MacXcodeStagingDir + "/..\"";
                break;

            case "deletekeychain":
                Program.Log(" ... remove temporary key chain");
                Program.Log("  Using signing identity '{0}'", Config.CodeSigningIdentity);
                DisplayCommandLine = "security list-keychains -s \"" + LoginKeychain + "\" && security delete-keychain \"" + TempKeychain + "\"";
                CommandLine        = "\"" + MacXcodeStagingDir + "/..\" " + DisplayCommandLine;
                WorkingFolder      = "\"" + MacXcodeStagingDir + "/..\"";
                break;

            case "validation":
                Program.Log(" ... validating distribution package");
                DisplayCommandLine = XcodeDeveloperDir + "Platforms/iPhoneOS.platform/Developer/usr/bin/Validation " + RemoteAppDirectory;
                CommandLine        = "\"" + MacStagingRootDir + "\" " + DisplayCommandLine;
                WorkingFolder      = "\"" + MacStagingRootDir + "\"";
                break;

            case "deleteipa":
                Program.Log(" ... deleting IPA on Mac");
                DisplayCommandLine = "rm -f " + Config.IPAFilenameOnMac;
                CommandLine        = "\"" + MacStagingRootDir + "\" " + DisplayCommandLine;
                WorkingFolder      = "\"" + MacStagingRootDir + "\"";
                break;

            case "kill":
                Program.Log(" ... killing");
                DisplayCommandLine = "killall " + Program.GameName;
                CommandLine        = ". " + DisplayCommandLine;
                WorkingFolder      = ".";
                break;

            case "strip":
                Program.Log(" ... stripping");
                DisplayCommandLine = "/usr/bin/xcrun strip '" + RemoteExecutablePath + "'";
                CommandLine        = "\"" + MacStagingRootDir + "\" " + DisplayCommandLine;
                WorkingFolder      = "\"" + MacStagingRootDir + "\"";
                break;

            case "resign":
                Program.Log("... resigning");
                DisplayCommandLine = "bash -c '" + "chmod a+x ResignScript" + ";" + "./ResignScript" + "'";
                CommandLine        = "\"" + MacStagingRootDir + "\" " + DisplayCommandLine;
                WorkingFolder      = "\"" + MacStagingRootDir + "\"";
                break;

            case "zip":
                Program.Log(" ... zipping");

                // NOTE: -y preserves symbolic links which is needed for iOS distro builds
                // -x excludes a file (excluding the dSYM keeps sizes smaller, and it shouldn't be in the IPA anyways)
                string dSYMName = "Payload/" + Program.GameName + Program.Architecture + ".app.dSYM";
                DisplayCommandLine = String.Format("zip -q -r -y -{0} -T {1} Payload iTunesArtwork -x {2}/ -x {2}/* " +
                                                   "-x {2}/Contents/ -x {2}/Contents/* -x {2}/Contents/Resources/ -x {2}/Contents/Resources/* " +
                                                   " -x {2}/Contents/Resources/DWARF/ -x {2}/Contents/Resources/DWARF/*",
                                                   (int)Config.RecompressionSetting,
                                                   Config.IPAFilenameOnMac,
                                                   dSYMName);

                CommandLine   = "\"" + MacStagingRootDir + "\" " + DisplayCommandLine;
                WorkingFolder = "\"" + MacStagingRootDir + "\"";
                break;

            case "gendsym":
                Program.Log(" ... generating DSYM");

                string ExePath  = "Payload/" + Program.GameName + ".app/" + Program.GameName;
                string dSYMPath = Program.GameName + ".app.dSYM";
                DisplayCommandLine = String.Format("dsymutil -o {0} {1}", dSYMPath, ExePath);

                CommandLine   = "\"" + MacStagingRootDir + "\"" + DisplayCommandLine;
                WorkingFolder = "\"" + MacStagingRootDir + "\"";
                break;

            default:
                Program.Error("Unrecognized RPC command");
                return(false);
            }

            Program.Log(" ... working folder: " + WorkingFolder);
            Program.Log(" ... " + DisplayCommandLine);
            Program.Log(" ... full command: " + MacName + " " + CommandLine);

            bool bSuccess = false;

            if (Config.bUseRPCUtil)
            {
                Program.Log("Running RPC on " + MacName + " ... ");

                Process RPCUtil = new Process();
                RPCUtil.StartInfo.FileName               = @"..\RPCUtility.exe";
                RPCUtil.StartInfo.UseShellExecute        = false;
                RPCUtil.StartInfo.Arguments              = MacName + " " + CommandLine;
                RPCUtil.StartInfo.RedirectStandardOutput = true;
                RPCUtil.StartInfo.RedirectStandardError  = true;
                RPCUtil.OutputDataReceived              += new DataReceivedEventHandler(OutputReceivedRemoteProcessCall);
                RPCUtil.ErrorDataReceived += new DataReceivedEventHandler(OutputReceivedRemoteProcessCall);

                RPCUtil.Start();

                RPCUtil.BeginOutputReadLine();
                RPCUtil.BeginErrorReadLine();

                RPCUtil.WaitForExit();

                bSuccess = (RPCUtil.ExitCode == 0);
                if (bSuccess == false && !bIsSilent)
                {
                    Program.Error("RPCCommand {0} failed with return code {1}", RPCCommand, RPCUtil.ExitCode);
                    switch (RPCCommand.ToLowerInvariant())
                    {
                    case "installprovision":
                        Program.Error("Ensure your access permissions for '~/Library/MobileDevice/Provisioning Profiles' are set correctly.");
                        break;

                    default:
                        break;
                    }
                }
            }
            else
            {
                Program.Log("Running SSH on " + MacName + " ... ");
                bSuccess = SSHCommandHelper.Command(MacName, DisplayCommandLine, WorkingFolder);
                if (bSuccess == false && !bIsSilent)
                {
                    Program.Error("RPCCommand {0} failed with return code {1}", RPCCommand, Error);
                    Program.ReturnCode = (int)Error;
                }
            }


            return(bSuccess);
        }
Ejemplo n.º 5
0
        /**
         * Handle spawning of the RPCUtility with parameters
         */
        public static bool RunRPCUtilty(string RPCCommand)
        {
            string CommandLine        = "";
            string WorkingFolder      = "";
            string DisplayCommandLine = "";

            switch (RPCCommand.ToLowerInvariant())
            {
            case "deletemacstagingfiles":
                Program.Log(" ... deleting staging files on the Mac");
                DisplayCommandLine = "rm -rf Payload";
                CommandLine        = "\"" + MacStagingRootDir + "\" " + DisplayCommandLine;
                WorkingFolder      = MacStagingRootDir;
                break;

            case "ensureprovisiondirexists":
                Program.Log(" ... creating provisioning profiles directory");

                DisplayCommandLine = String.Format("mkdir -p ~/Library/MobileDevice/Provisioning\\ Profiles");

                CommandLine   = "\"" + MacXcodeStagingDir + "\" " + DisplayCommandLine;
                WorkingFolder = MacXcodeStagingDir;
                break;

            case "installprovision":
                // Note: The provision must have already been copied over to the Mac
                Program.Log(" ... installing .mobileprovision");

                DisplayCommandLine = String.Format("cp -f {0} ~/Library/MobileDevice/Provisioning\\ Profiles", MacMobileProvisionFilename);

                CommandLine   = "\"" + MacXcodeStagingDir + "\" " + DisplayCommandLine;
                WorkingFolder = MacXcodeStagingDir;
                break;

            case "removeprovision":
                Program.Log(" ... removing .mobileprovision");
                DisplayCommandLine = String.Format("rm -f ~/Library/MobileDevice/Provisioning\\ Profiles/{0}", MacMobileProvisionFilename);
                CommandLine        = "\"" + MacXcodeStagingDir + "\" " + DisplayCommandLine;
                WorkingFolder      = MacXcodeStagingDir;
                break;

            case "setexec":
                // Note: The executable must have already been copied over
                Program.Log(" ... setting executable bit");
                DisplayCommandLine = "chmod a+x \'" + RemoteExecutablePath + "\'";
                CommandLine        = "\"" + MacStagingRootDir + "\" " + DisplayCommandLine;
                WorkingFolder      = MacStagingRootDir;
                break;

            case "prepackage":
                Program.Log(" ... running prepackage script remotely ");
                DisplayCommandLine = String.Format("sh prepackage.sh {0} IOS {1} {2}", Program.GameName, Program.GameConfiguration, Program.Architecture);
                CommandLine        = "\"" + MacXcodeStagingDir + "\" " + DisplayCommandLine;
                WorkingFolder      = MacXcodeStagingDir;
                break;

            case "makeapp":
                Program.Log(" ... making application (codesign, etc...)");
                Program.Log("  Using signing identity '{0}'", Config.CodeSigningIdentity);
                DisplayCommandLine = CurrentBaseXCodeCommandLine;
                CommandLine        = "\"" + MacXcodeStagingDir + "/..\" " + DisplayCommandLine;
                WorkingFolder      = "\"" + MacXcodeStagingDir + "/..\"";
                break;

            case "validation":
                Program.Log(" ... validating distribution package");
                DisplayCommandLine = XcodeDeveloperDir + "Platforms/iPhoneOS.platform/Developer/usr/bin/Validation " + RemoteAppDirectory;
                CommandLine        = "\"" + MacStagingRootDir + "\" " + DisplayCommandLine;
                WorkingFolder      = MacStagingRootDir;
                break;

            case "deleteipa":
                Program.Log(" ... deleting IPA on Mac");
                DisplayCommandLine = "rm -f " + Config.IPAFilenameOnMac;
                CommandLine        = "\"" + MacStagingRootDir + "\" " + DisplayCommandLine;
                WorkingFolder      = MacStagingRootDir;
                break;

            case "kill":
                Program.Log(" ... killing");
                DisplayCommandLine = "killall " + Program.GameName;
                CommandLine        = ". " + DisplayCommandLine;
                WorkingFolder      = ".";
                break;

            case "strip":
                Program.Log(" ... stripping");
                DisplayCommandLine = XcodeDeveloperDir + "Platforms/iPhoneOS.platform/Developer/usr/bin/strip '" + RemoteExecutablePath + "'";
                CommandLine        = "\"" + MacStagingRootDir + "\" " + DisplayCommandLine;
                WorkingFolder      = MacStagingRootDir;
                break;

            case "resign":
                Program.Log("... resigning");
                DisplayCommandLine = "bash -c '" + "chmod a+x ResignScript" + ";" + "./ResignScript" + "'";
                CommandLine        = "\"" + MacStagingRootDir + "\" " + DisplayCommandLine;
                WorkingFolder      = MacStagingRootDir;
                break;

            case "zip":
                Program.Log(" ... zipping");

                // NOTE: -y preserves symbolic links which is needed for iOS distro builds
                // -x excludes a file (excluding the dSYM keeps sizes smaller, and it shouldn't be in the IPA anyways)
                string dSYMName = "Payload/" + Program.GameName + Program.Architecture + ".app.dSYM";
                DisplayCommandLine = String.Format("zip -q -r -y -{0} -T {1} Payload iTunesArtwork -x {2}/ -x {2}/* " +
                                                   "-x {2}/Contents/ -x {2}/Contents/* -x {2}/Contents/Resources/ -x {2}/Contents/Resources/* " +
                                                   " -x {2}/Contents/Resources/DWARF/ -x {2}/Contents/Resources/DWARF/*",
                                                   (int)Config.RecompressionSetting,
                                                   Config.IPAFilenameOnMac,
                                                   dSYMName);

                CommandLine   = "\"" + MacStagingRootDir + "\" " + DisplayCommandLine;
                WorkingFolder = MacStagingRootDir;
                break;

            case "gendsym":
                Program.Log(" ... generating DSYM");

                string ExePath  = "Payload/" + Program.GameName + ".app/" + Program.GameName;
                string dSYMPath = Program.GameName + ".app.dSYM";
                DisplayCommandLine = String.Format("dsymutil -o {0} {1}", dSYMPath, ExePath);

                CommandLine   = "\"" + MacStagingRootDir + "\"" + DisplayCommandLine;
                WorkingFolder = MacStagingRootDir;
                break;

            default:
                Program.Error("Unrecognized RPC command");
                return(false);
            }

            Program.Log(" ... working folder: " + WorkingFolder);
            Program.Log(" ... " + DisplayCommandLine);
            Program.Log(" ... full command: " + MacName + " " + CommandLine);

            bool bSuccess = false;

            if (Config.bUseRPCUtil)
            {
                Program.Log("Running RPC on " + MacName + " ... ");

                Process RPCUtil = new Process();
                RPCUtil.StartInfo.FileName               = @"..\RPCUtility.exe";
                RPCUtil.StartInfo.UseShellExecute        = false;
                RPCUtil.StartInfo.Arguments              = MacName + " " + CommandLine;
                RPCUtil.StartInfo.RedirectStandardOutput = true;
                RPCUtil.StartInfo.RedirectStandardError  = true;
                RPCUtil.OutputDataReceived              += new DataReceivedEventHandler(OutputReceivedRemoteProcessCall);
                RPCUtil.ErrorDataReceived += new DataReceivedEventHandler(OutputReceivedRemoteProcessCall);

                RPCUtil.Start();

                RPCUtil.BeginOutputReadLine();
                RPCUtil.BeginErrorReadLine();

                RPCUtil.WaitForExit();

                bSuccess = (RPCUtil.ExitCode == 0);
                if (bSuccess == false)
                {
                    Program.Error("RPCCommand {0} failed with return code {1}", RPCCommand, RPCUtil.ExitCode);
                    switch (RPCCommand.ToLowerInvariant())
                    {
                    case "installprovision":
                        Program.Error("Ensure your access permissions for '~/Library/MobileDevice/Provisioning Profiles' are set correctly.");
                        break;

                    default:
                        break;
                    }
                }
            }
            else
            {
                Program.Log("Running SSH on " + MacName + " ... ");
                bSuccess = SSHCommandHelper.Command(MacName, DisplayCommandLine, WorkingFolder);
            }


            return(bSuccess);
        }
Ejemplo n.º 6
0
        static private bool ParseCommandLine(ref string[] Arguments)
        {
            if (Arguments.Length == 0)
            {
                StartVisuals();

                // we NEED a project, so show a uproject picker
                string UProjectFile;
                string StartingDir = "";
                if (ToolsHub.ShowOpenFileDialog("Unreal Project Files (*.uproject)|*.uproject;", "IPhonePackager now requires a .uproject file for certificate/provisioning setup", "mobileprovision", "", ref StartingDir, out UProjectFile))
                {
                    Arguments = new string[] { UProjectFile };
                }
                else
                {
                    Arguments = new string[] { "gui" };
                }
            }

            if (Arguments.Length == 1)
            {
                // if the only argument is a uproject, then assume gui mode, with the uproject as the project
                if (Arguments[0].EndsWith(".uproject"))
                {
                    Config.ProjectFile = GamePath = Arguments[0];

                    MainCommand = "gui";
                }
                else
                {
                    MainCommand = Arguments[0];
                }
            }
            else if (Arguments.Length == 2)
            {
                MainCommand = Arguments[0];
                GamePath    = Arguments[1];
            }
            else if (Arguments.Length >= 2)
            {
                MainCommand = Arguments[0];
                GamePath    = Arguments[1];

                for (int ArgIndex = 2; ArgIndex < Arguments.Length; ArgIndex++)
                {
                    string Arg = Arguments[ArgIndex].ToLowerInvariant();

                    if (Arg.StartsWith("-"))
                    {
                        // Behavior switches
                        switch (Arg)
                        {
                        case "-verbose":
                            Config.bVerbose = true;
                            break;

                        case "-strip":
                            Config.bForceStripSymbols = true;
                            break;

                        case "-compress=best":
                            Config.RecompressionSetting = (int)CompressionLevel.BestCompression;
                            break;

                        case "-compress=fast":
                            Config.RecompressionSetting = (int)CompressionLevel.BestSpeed;
                            break;

                        case "-compress=none":
                            Config.RecompressionSetting = (int)CompressionLevel.None;
                            break;

                        case "-distribution":
                            Config.bForDistribution = true;
                            break;

                        case "-createstub":
                            Config.bCreateStubSet = true;
                            break;

                        case "-sign":
                            Config.bPerformResignWhenRepackaging = true;
                            break;

                        case "-cookonthefly":
                            Config.bCookOnTheFly = true;
                            break;

                        case "-iterate":
                            Config.bIterate = true;
                            break;
                        }

                        // get the stage dir path
                        if (Arg == "-stagedir")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.RepackageStagingDirectory = Arguments [++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-manifest")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.DeltaManifest = Arguments[++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-backup")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.FilesForBackup.Add(Arguments[++ArgIndex]);
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-config")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                GameConfiguration = Arguments [++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        // append a name to the bungle identifier and display name
                        else if (Arg == "-bundlename")
                        {
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.OverrideBundleName = Arguments [++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-mac")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.OverrideMacName = Arguments [++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-architecture" || Arg == "-arch")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Architecture = "-" + Arguments [++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-project")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.ProjectFile = Arguments [++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-device")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.DeviceId = Arguments [++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-additionalcommandline")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                AdditionalCommandline = Arguments [++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-provision")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.Provision  = Arguments [++ArgIndex];
                                Config.bProvision = true;
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-certificate")
                        {
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.Certificate = Arguments [++ArgIndex];
                                Config.bCert       = true;
                            }
                            else
                            {
                                return(false);
                            }
                        }
                    }
                    else
                    {
                        // RPC command
                        MainRPCCommand = Arguments[ArgIndex];
                    }
                }

                if (!SSHCommandHelper.ParseSSHProperties(Arguments))
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 7
0
        static private bool ParseCommandLine(ref string[] Arguments)
        {
            if (Arguments.Length == 0)
            {
                StartVisuals();

                // we NEED a project, so show a uproject picker
                string UProjectFile;
                string StartingDir = "";
                if (ToolsHub.ShowOpenFileDialog("Unreal Project Files (*.uproject)|*.uproject;", "IPhonePackager now requires a .uproject file for certificate/provisioning setup", "mobileprovision", "", ref StartingDir, out UProjectFile))
                {
                    Arguments = new string[] { UProjectFile };
                }
                else
                {
                    Arguments = new string[] { "gui" };
                }
            }

            if (Arguments.Length == 1)
            {
                // if the only argument is a uproject, then assume gui mode, with the uproject as the project
                if (Arguments[0].EndsWith(".uproject"))
                {
                    Config.ProjectFile = GamePath = Arguments[0];

                    MainCommand = "gui";
                }
                else
                {
                    MainCommand = Arguments[0];
                }
            }
            else if (Arguments.Length == 2)
            {
                MainCommand = Arguments[0];
                GamePath    = Arguments[1];
                if (GamePath.EndsWith(".uproject"))
                {
                    Config.ProjectFile = GamePath;
                }
            }
            else if (Arguments.Length >= 2)
            {
                MainCommand = Arguments[0];
                GamePath    = Arguments[1];
                if (GamePath.EndsWith(".uproject"))
                {
                    Config.ProjectFile = GamePath;
                }

                for (int ArgIndex = 2; ArgIndex < Arguments.Length; ArgIndex++)
                {
                    string Arg = Arguments[ArgIndex].ToLowerInvariant();

                    if (Arg.StartsWith("-"))
                    {
                        // Behavior switches
                        switch (Arg)
                        {
                        case "-verbose":
                            Config.bVerbose = true;
                            break;

                        case "-strip":
                            Config.bForceStripSymbols = true;
                            break;

                        case "-compress=best":
                            Config.RecompressionSetting = (int)CompressionLevel.BestCompression;
                            break;

                        case "-compress=fast":
                            Config.RecompressionSetting = (int)CompressionLevel.BestSpeed;
                            break;

                        case "-compress=none":
                            Config.RecompressionSetting = (int)CompressionLevel.None;
                            break;

                        case "-distribution":
                            Config.bForDistribution = true;
                            break;

                        case "-codebased":
                            Config.bIsCodeBasedProject = true;
                            break;

                        case "-createstub":
                            Config.bCreateStubSet = true;
                            break;

                        case "-sign":
                            Config.bPerformResignWhenRepackaging = true;
                            break;

                        case "-cookonthefly":
                            Config.bCookOnTheFly = true;
                            break;

                        case "-iterate":
                            Config.bIterate = true;
                            break;

                        case "-tvos":
                            Config.OSString = "TVOS";
                            break;

                        case "-autosigning":
                            Config.bAutomaticSigning = true;
                            break;
                        }

                        // get the stage dir path
                        if (Arg == "-stagedir")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.RepackageStagingDirectory = Arguments [++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        // get the provisioning uuid
                        else if (Arg == "-provisioninguuid")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.ProvisionUUID = Arguments[++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-teamID")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.TeamID = Arguments[++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-manifest")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.DeltaManifest = Arguments[++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-backup")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.FilesForBackup.Add(Arguments[++ArgIndex]);
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-config")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                GameConfiguration = Arguments [++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        // append a name to the bungle identifier and display name
                        else if (Arg == "-bundlename")
                        {
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                string projectName = "[PROJECT_NAME]";
                                string bundleId    = Arguments[++ArgIndex];

                                // Check for an illegal bundle id
                                for (int i = 0; i < bundleId.Length; ++i)
                                {
                                    char c = bundleId[i];

                                    if (c == '[')
                                    {
                                        if (bundleId.IndexOf(projectName, i) != i)
                                        {
                                            Error("Illegal character in bundle ID");
                                            return(false);
                                        }
                                        i += projectName.Length;
                                    }
                                    else if ((c < '0' || c > '9') && (c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && c != '.' && c != '-')
                                    {
                                        Error("Illegal character in bundle ID");
                                        return(false);
                                    }
                                }

                                // Save the verified bundle id
                                Config.OverrideBundleName = bundleId;
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-schemename")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                SchemeName = Arguments[++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-schemeconfig")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                SchemeConfiguration = Arguments[++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-mac")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.OverrideMacName = Arguments [++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-architecture" || Arg == "-arch")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Architecture = "-" + Arguments [++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-project")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.ProjectFile = Arguments [++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-device")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.DeviceId = Arguments [++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-additionalcommandline")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                AdditionalCommandline = Arguments [++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-provision")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.Provision  = Arguments [++ArgIndex];
                                Config.bProvision = !String.IsNullOrEmpty(Config.Provision);
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-certificate")
                        {
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.Certificate = Arguments [++ArgIndex];
                                Config.bCert       = !String.IsNullOrEmpty(Config.Certificate);
                            }
                            else
                            {
                                return(false);
                            }
                        }
                    }
                    else
                    {
                        // RPC command
                        MainRPCCommand = Arguments[ArgIndex];
                    }
                }

                if (!SSHCommandHelper.ParseSSHProperties(Arguments))
                {
                    return(false);
                }
            }

            return(true);
        }