Beispiel #1
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";
        }
Beispiel #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";

            // 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}/IOS", iPhone_SigningDevRootMac, GameBranchPath);
            MacBinariesDir     = string.Format("{0}/{1}/IOS", iPhone_SigningDevRootMac, GameBranchPath);
            MacXcodeStagingDir = string.Format("{0}/{1}/IOS/XcodeSupportFiles", iPhone_SigningDevRootMac, GameBranchPath);

            MacMobileProvisionFilename = MachineName + "_UE4Temp.mobileprovision";

            CurrentBaseXCodeCommandLine = GetBaseXcodeCommandline();
        }
Beispiel #3
0
        static int Main(string[] args)
        {
            // remember the working directory at start, as the game path could be relative to this path
            string InitialCurrentDirectory = Environment.CurrentDirectory;

            // set the working directory to the location of the application (so relative paths always work)
            Environment.CurrentDirectory = Path.GetDirectoryName(Application.ExecutablePath);

            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);

            // A simple, top-level try-catch block
            try
            {
                if (!ParseCommandLine(ref args))
                {
                    Log("Usage: iPhonePackager <Command> <GameName> [RPCCommand &| Switch]");
                    Log("");
                    Log("Common commands:");
                    Log(" ... RepackageIPA GameName");
                    Log(" ... PackageIPA GameName");
                    Log(" ... PackageApp GameName");
                    Log(" ... Deploy PathToIPA");
                    Log(" ... RepackageFromStage GameName");
                    Log(" ... Devices");
                    Log(" ... Validate");
                    Log(" ... Install");
                    Log("");
                    Log("Configuration switches:");
                    Log("	 -stagedir <path>		  sets the directory to copy staged files from (defaults to none)");
                    Log("	 -project <path>		  path to the project being packaged");
                    Log("	 -compress=fast|best|none  packaging compression level (defaults to none)");
                    Log("	 -strip					strip symbols during packaging");
                    Log("	 -config				   game configuration (e.g., Shipping, Development, etc...)");
                    Log("	 -distribution			 packaging for final distribution");
                    Log("	 -createstub			   packaging stub IPA for later repackaging");
                    Log("	 -mac <MacName>			overrides the machine to use for any Mac operations");
                    Log("	 -arch <Architecture>	  sets the architecture to use (blank for default, -simulator for simulator builds)");
                    Log("	 -device <DeviceID>		sets the device to install the IPA on");
                    Log("");
                    Log("Commands: RPC, Clean");
                    Log("  StageMacFiles, GetIPA, Deploy, Install, Uninstall");
                    Log("");
                    Log("RPC Commands: SetExec, InstallProvision, MakeApp, DeleteIPA, Copy, Kill, Strip, Zip, GenDSYM");
                    Log("");
                    Log("Sample commandlines:");
                    Log(" ... iPhonePackager Deploy UDKGame Release");
                    Log(" ... iPhonePackager RPC SwordGame Shipping MakeApp");
                    return((int)ErrorCodes.Error_Arguments);
                }

                Log("Executing iPhonePackager " + String.Join(" ", args));
                Log("CWD: " + Directory.GetCurrentDirectory());
                Log("Initial Dir: " + InitialCurrentDirectory);
                Log("Env CWD: " + Environment.CurrentDirectory);

                // Ensure shipping configuration for final distributions
                if (Config.bForDistribution && (GameConfiguration != "Shipping"))
                {
                    Program.Warning("Distribution builds should be made in the Shipping configuration!");
                }

                // process the GamePath (if could be ..\Samples\MyDemo\ or ..\Samples\MyDemo\MyDemo.uproject
                GameName = Path.GetFileNameWithoutExtension(GamePath);
                if (GameName.Equals("UE4", StringComparison.InvariantCultureIgnoreCase) || GameName.Equals("Engine", StringComparison.InvariantCultureIgnoreCase))
                {
                    GameName = "UE4Game";
                }

                // setup configuration
                if (!Config.Initialize(InitialCurrentDirectory, GamePath))
                {
                    return((int)ErrorCodes.Error_Arguments);
                }

                switch (MainCommand.ToLowerInvariant())
                {
                case "validate":
                    // check to see if iTunes is installed
                    string dllPath = "";
                    if (Environment.OSVersion.Platform == PlatformID.MacOSX || Environment.OSVersion.Platform == PlatformID.Unix)
                    {
                        dllPath = "/Applications/Xcode.app/Contents/MacOS/Xcode";
                    }
                    else
                    {
                        dllPath = Microsoft.Win32.Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Apple Inc.\\Apple Mobile Device Support\\Shared", "iTunesMobileDeviceDLL", null) as string;
                        if (String.IsNullOrEmpty(dllPath) || !File.Exists(dllPath))
                        {
                            dllPath = Microsoft.Win32.Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Apple Inc.\\Apple Mobile Device Support\\Shared", "MobileDeviceDLL", null) as string;
                        }
                    }
                    if (String.IsNullOrEmpty(dllPath) || !File.Exists(dllPath))
                    {
                        Error("iTunes Not Found!!", (int)ErrorCodes.Error_SDKNotFound);
                    }
                    else
                    {
                        // validate there is a useable provision and cert
                        MobileProvision  Provision;
                        X509Certificate2 Cert;
                        bool             bHasOverrides;
                        bool             bNameMatch;
                        bool             foundPlist = CodeSignatureBuilder.FindRequiredFiles(out Provision, out Cert, out bHasOverrides, out bNameMatch);
                        if (!foundPlist)
                        {
                            Error("Could not find a valid plist file!!", (int)ErrorCodes.Error_InfoPListNotFound);
                        }
                        else if (Provision == null && Cert == null)
                        {
                            Error("No Provision or cert found!!", (int)ErrorCodes.Error_ProvisionAndCertificateNotFound);
                        }
                        else if (Provision == null)
                        {
                            Error("No Provision found!!", (int)ErrorCodes.Error_ProvisionNotFound);
                        }
                        else if (Cert == null)
                        {
                            Error("No Signing Certificate found!!", (int)ErrorCodes.Error_CertificateNotFound);
                        }
                    }
                    break;

                case "packageapp":
                    if (CheckArguments())
                    {
                        if (Config.bCreateStubSet)
                        {
                            Error("packageapp cannot be used with the -createstub switch");
                            Program.ReturnCode = (int)ErrorCodes.Error_Arguments;
                        }
                        else
                        {
                            // Create the .app on the Mac
                            CompileTime.CreateApplicationDirOnMac();
                        }
                    }
                    break;

                case "repackagefromstage":
                    if (CheckArguments())
                    {
                        if (Config.bCreateStubSet)
                        {
                            Error("repackagefromstage cannot be used with the -createstub switches");
                            Program.ReturnCode = (int)ErrorCodes.Error_Arguments;
                        }
                        else
                        {
                            bool bProbablyCreatedStub = Utilities.GetEnvironmentVariable("ue.IOSCreateStubIPA", true);
                            if (!bProbablyCreatedStub)
                            {
                                Warning("ue.IOSCreateStubIPA is currently FALSE, which means you may be repackaging with an out of date stub IPA!");
                            }

                            CookTime.RepackageIPAFromStub();
                        }
                    }
                    break;

                // this is the "super fast just move executable" mode for quick programmer iteration
                case "dangerouslyfast":
                    if (CheckArguments())
                    {
                        CompileTime.DangerouslyFastMode();
                    }
                    break;

                case "packageipa":
                    if (CheckArguments())
                    {
                        CompileTime.PackageIPAOnMac();
                    }
                    break;

                case "install":
                    GameName = "";
                    if (Config.bProvision)
                    {
                        ToolsHub.TryInstallingMobileProvision(Config.Provision, false);
                    }
                    if (Config.bCert)
                    {
                        ToolsHub.TryInstallingCertificate_PromptForKey(Config.Certificate, false);
                    }
                    CodeSignatureBuilder.FindCertificates();
                    CodeSignatureBuilder.FindProvisions(Config.OverrideBundleName);
                    break;

                case "certificates":
                {
                    CodeSignatureBuilder.FindCertificates();
                    CodeSignatureBuilder.FindProvisions(Config.OverrideBundleName);
                }
                break;

                case "resigntool":
                    RunInVisualMode(delegate { return(new GraphicalResignTool()); });
                    break;

                case "certrequest":
                    RunInVisualMode(delegate { return(new GenerateSigningRequestDialog()); });
                    break;

                case "gui":
                    RunInVisualMode(delegate { return(ToolsHub.CreateShowingTools()); });
                    break;

                case "devices":
                    ListDevices();
                    break;

                default:
                    // Commands by themself default to packaging for the device
                    if (CheckArguments())
                    {
                        ExecuteCommand(MainCommand, MainRPCCommand);
                    }
                    break;
                }
            }
            catch (Exception Ex)
            {
                Error("Application exception: " + Ex.ToString());
                if (ReturnCode == 0)
                {
                    Program.ReturnCode = (int)ErrorCodes.Error_Unknown;
                }
            }
            finally
            {
                if (DeploymentHelper.DeploymentServerProcess != null)
                {
                    DeploymentHelper.DeploymentServerProcess.Close();
                }
            }

            Environment.ExitCode = ReturnCode;
            return(ReturnCode);
        }
Beispiel #4
0
        public static bool Initialize(string InitialCurrentDirectory, string GamePath)
        {
            bool bIsEpicInternal = File.Exists(@"..\..\EpicInternal.txt");


            // if the path is a directory (relative to where the game was launched from), then get the absolute directory
            string FullGamePath = Path.GetFullPath(Path.Combine(InitialCurrentDirectory, GamePath));
            string OrigGamePath = GamePath;

            if (Directory.Exists(FullGamePath))
            {
                GameDirectory = FullGamePath;
            }
            // is it a file? if so, just use the file's directory
            else if (File.Exists(FullGamePath))
            {
                GameDirectory = Path.GetDirectoryName(FullGamePath);
            }
            // else we assume old school game name and look for it
            else
            {
                if (Program.GameName == "UE4Game")
                {
                    GameDirectory = Path.GetFullPath(Path.Combine(Config.RootRelativePath, GamePath));
                }
                else
                {
                    GameDirectory = Path.GetFullPath(Path.Combine(Config.RootRelativePath, Program.GameName));
                }
            }

            if (!Directory.Exists(GameDirectory))
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine();
                Console.WriteLine("Unable to find a game or program {0}. You may need to specify a path to the program", OrigGamePath);
                Console.ResetColor();
                return(false);
            }

            // special case handling for anything inside Engine/Source, it will go to the Engine/Binaries directory, not the Game's binaries directory
            if (OrigGamePath.Replace("\\", "/").Contains("Engine/Source"))
            {
                BinariesDirectory = Path.Combine(RootRelativePath, @"Engine\Binaries\" + Config.OSString + @"\");
            }
            else if (!OrigGamePath.Contains(@"Binaries\" + Config.OSString))
            {
                // no sense in adding Binaries\IOS when it's already there. This is a special case to handle packaging UnrealLaunchDaemon from the command line.
                BinariesDirectory = Path.Combine(GameDirectory, @"Binaries\" + Config.OSString + @"\");
            }
            else
            {
                BinariesDirectory = GameDirectory;
            }

            // Root directory on PC for staging files to copy to Mac
            Config.PCStagingRootDir = String.Format(@"{0}-Deploy\{1}\{2}{3}\",
                                                    IntermediateDirectory,
                                                    Program.GameName,
                                                    Program.GameConfiguration,
                                                    Program.Architecture);

            // make a directory for the shared XcodeSupportFiles directory
            Config.PCXcodeStagingDir = Path.Combine(Config.PCStagingRootDir, @"..\XcodeSupportFiles");

            // Code signing identity
            // Rules:
            //   An environment variable wins if set
            //   Otherwise for internal development builds, an internal identity is used
            //   Otherwise, developer or distribution are used
            // Distro builds won't succeed on a machine with multiple distro certs installed unless the environment variable is set.
            Config.CodeSigningIdentity = Config.bForDistribution ? "iPhone Distribution" : "iPhone Developer";


            if (Config.bForDistribution)
            {
                Config.CodeSigningIdentity = Utilities.GetEnvironmentVariable("ue.IOSDistributionSigningIdentity", Config.CodeSigningIdentity);
            }
            else
            {
                Config.CodeSigningIdentity = Utilities.GetEnvironmentVariable("ue.IOSDeveloperSigningIdentity", Config.CodeSigningIdentity);
            }

            // Remember to also change the default min version in UBT (iPhoneToolChain.cs)
            Config.MinOSVersion = Utilities.GetEnvironmentVariable("ue3.iPhone_MinOSVersion", "6.0");

            // look for the signing prefix environment variable
            string DefaultPrefix = "";

            if (bIsEpicInternal)
            {
                // default Epic to "Epic_" prefix
                DefaultPrefix = "Epic_";
            }

            if (Config.bForDistribution)
            {
                DefaultPrefix = "Distro_";
            }
            Config.SigningPrefix = Utilities.GetEnvironmentVariable("ue.IOSSigningPrefix", DefaultPrefix);

            // Windows doesn't allow environment vars to be set to blank so detect "none" and treat it as such
            if (Config.SigningPrefix == "none")
            {
                Config.SigningPrefix = Config.bForDistribution ? "Distro_" : "";
            }

            CompileTime.ConfigurePaths();
            return(true);
        }