Example #1
0
    public override void UnityExport(BuildStage stage, string[] scenesPath,
                                     out string projPath)
    {
        platformTarget.RunAditionalSteps();
        string containerPath = SelectProjectPath(PlayerSettings.productName);

        projPath = containerPath + "/" + PlayerSettings.productName;

        EditorUserBuildSettings.SwitchActiveBuildTarget(buildTargetGroup,
                                                        buildTarget);

        UnityEditor.Build.Reporting.BuildReport error =
            BuildPipeline.BuildPlayer(scenesPath, containerPath, buildTarget,
                                      buildOptions);

        // Check if export failed.
        bool fail = (
            error.summary.result ==
            UnityEditor.Build.Reporting.BuildResult.Failed ||
            error.summary.result ==
            UnityEditor.Build.Reporting.BuildResult.Cancelled
            );

        if (fail)
        {
            throw new ExportProjectFailedException();
        }
    }
Example #2
0
    public override void UnityExport(BuildStage stage, string[] scenesPath,
                                     out string projPath)
    {
        platformTarget.RunAditionalSteps();

        string containerPath = SelectProjectPath(PlayerSettings.productName);

        projPath = containerPath + "/" + PlayerSettings.productName;

        EditorUserBuildSettings.SwitchActiveBuildTarget(
            BuildTargetGroup.Android, BuildTarget.Android);

        // Remove AppcoinsUnityTests.dll from the project
        //File.Move(rightDllLoc, tempDllLoc);
        //AssetDatabase.Refresh();

        if (EditorUserBuildSettings.development)
        {
            buildOptions = buildOptions | BuildOptions.Development | BuildOptions.AllowDebugging;
        }

        string s = BuildPipeline.BuildPlayer(scenesPath, containerPath,
                                             buildTarget,
                                             buildOptions).ToString();

        // Add AppcoinsUnityTests.dll to the project
        //File.Move(tempDllLoc, rightDllLoc);
        //AssetDatabase.Refresh();

        // If Export failed 's' contains something.
        if (!s.Equals(""))
        {
            throw new ExportProjectFailedException();
        }
    }
Example #3
0
    //Create the custom Editor Window
    public static void CreateCustomBuildWindow(BuildStage s,
                                               CustomBuildWindow w,
                                               SelectScenes sel,
                                               BuildStageEvent ev
                                               )
    {
        CustomBuildWindow.instance = (CustomBuildWindow)
                                     EditorWindow.GetWindowWithRect(
            typeof(CustomBuildWindow),
            new Rect(0, 0, 600, 500),
            true,
            "Custom Build Settings"
            );

        instance.stage              = s;
        instance.innerInstance      = w;
        instance.unityEvent         = ev;
        instance.selector           = sel;
        instance.buildScenesEnabled =
            instance.selector.GetBuildSettingsScenesEnabled();

        instance.minSize = new Vector2(600, 500);
        instance.autoRepaintOnSceneChange = true;

        instance.innerInstance.LoadCustomBuildPrefs();
        instance.ShowUtility();
    }
Example #4
0
    protected void LoadErrorEditorPrefbs(BuildStage[] allStages)
    {
        string[] genericErrorTitles =
        {
            "Setup Android Enviornment: ",
            "(GUI) Chose Custom Build Process: ",
            "Export Unity Project: ",
            "Build Exported Project: ",
            "Install .apk to device: ",
            "Run .apk in the device: "
        };

        failStage = (BuildStage)EditorPrefs.GetInt("appcoins_error_stage", 0);
        lastStage = (BuildStage)
                    EditorPrefs.GetInt("appcoins_last_error_stage", 2);

        errorMessage = EditorPrefs.GetString("appcoins_error_message", "");

        errorTitles = new string[allStages.Length];
        for (int i = 0; i < allStages.Length; i++)
        {
            errorTitles[i] =
                EditorPrefs.GetString("appcoins_error_title_" + i.ToString(),
                                      genericErrorTitles[i]);
        }
    }
        private void CreateBatchFileToExecuteCommand(BuildStage stage, string cmd, string cmdArgs, bool debugMode, string path)
        {
            
            if(!Directory.Exists(Application.dataPath + "\\AppcoinsUnity\\Tools"))
            {
                Directory.CreateDirectory(Application.dataPath + "\\AppcoinsUnity\\Tools");
            }
            
            else
            {
                // Delete all temporary files.
                if (File.Exists(Application.dataPath + "\\AppcoinsUnity\\Tools\\ProcessCompleted.out"))
                {
                    File.Delete(Application.dataPath + "\\AppcoinsUnity\\Tools\\ProcessCompleted.out");
                }

                if (File.Exists(Application.dataPath + "\\AppcoinsUnity\\Tools\\ProcessError.out"))
                {
                    File.Delete(Application.dataPath + "\\AppcoinsUnity\\Tools\\stderr.out");
                }

                if (File.Exists(Application.dataPath + "\\AppcoinsUnity\\Tools\\BashCommand.bat"))
                {
                    File.Delete(Application.dataPath + "\\AppcoinsUnity\\Tools\\BashCommand.bat");
                }

                if (File.Exists(Application.dataPath + "\\AppcoinsUnity\\Tools\\BashCommand.sh"))
                {
                    File.Delete(Application.dataPath + "\\AppcoinsUnity\\Tools\\BashCommand.sh");
                }
            }

            StreamWriter writer = new StreamWriter(Application.dataPath + "\\AppcoinsUnity\\Tools\\BashCommand.bat", false);

            writer.WriteLine("cd " + path);

            if (stage == BuildStage.PROJECT_INSTALL || stage == BuildStage.PROJECT_RUN)
            {
                writer.WriteLine("set var=error");
                writer.WriteLine("for /f \"tokens=*\" %%a in ('" + cmd + " get-state') do set var=%%a");
                writer.WriteLine("if \"%var%\" == \"device\" (" + cmd + " " + cmdArgs + " 2>\"" + Application.dataPath + "\\AppcoinsUnity\\Tools\\ProcessError.out\")");
                writer.WriteLine("if \"%var%\" == \"error\" ( echo error: no usb device found >\"" + Application.dataPath + "\\AppcoinsUnity\\Tools\\ProcessError.out\")");
            }

            else
            {
                writer.WriteLine("call " + cmd + " " + cmdArgs + " 2>\"" + Application.dataPath + "\\AppcoinsUnity\\Tools\\ProcessError.out\"");
            }

            if (stage == BuildStage.PROJECT_BUILD && debugMode)
            {
                writer.WriteLine("set /p DUMMY=Press ENTER to continue...");
            }

            writer.WriteLine("echo done >\"" + Application.dataPath + "\\AppcoinsUnity\\Tools\\ProcessCompleted.out\"");
            writer.Close();
        }
    internal override void InstallProject(BuildStage stage, string projPath)
    {
        string command = Tools.FixAppPath(
            EditorPrefs.GetString("appcoins_adb_path", ""),
            "adb");

        GetAdbInstallArgs(out string adbOptions, out string adbArgs);
        terminal.RunCommand(stage, command, adbOptions, adbArgs, projPath,
                            false);
    }
 private static string GetNameOfStage(BuildStage stage)
 {
     switch(stage)
     {
         case BuildStage.WaitingToStart: return "Starting engines";
         case BuildStage.BuildProject: return "Build .app";
         case BuildStage.PackageIPA: return "Package .ipa";
         case BuildStage.UploadIPA: return "Upload .ipa";
         default: return "Just a moment";
     }
 }
Example #8
0
 public static LogEvent ForBuildStage(BuildStage buildStage, Level level, string format, params object[] args)
 {
     return(new LogEvent(
                string.Format(
                    CultureInfo.InvariantCulture,
                    "Project.{0}.Stage.{1}",
                    buildStage.Project.ProjectId,
                    buildStage.StageId),
                level,
                format,
                args));
 }
    private void TurnGradleIntoExe(BuildStage stage, string gradlePath)
    {
        // If we're not in windows we need to make sure that the gradle file has
        // exec permission and if not, set them
        if (SystemInfo.operatingSystemFamily == OperatingSystemFamily.MacOSX ||
            SystemInfo.operatingSystemFamily == OperatingSystemFamily.Linux)
        {
            string chmodCmd = "chmod";

            terminal.RunCommand(stage, chmodCmd, "+x", gradlePath, ".", false);
        }
    }
Example #10
0
 public void SetBuildProject(BuildC __buildPrject)
 {
     _buildProject = __buildPrject;
     if (_buildProject != null)
     {
         Debug.Log("Build Success");
     }
     else
     {
         Debug.Log("Build Fail");
     }
     _buildStage = BuildStage.Location;
 }
Example #11
0
        private void BuildDependencyGraph(BuildStage stage)
        {
            foreach (BuildStage dependency in stage.DependsOn)
            {
                BuildDependencyGraph(dependency);
            }

            if (false == stagesOrdered.Contains(stage))
            {
                stagesOrdered.Add(stage);
                stagesStatuses.Add(stage.StageId, new StageStatus(stage));
            }
        }
Example #12
0
        public void Setup()
        {
            mother = new HeadlessMother();

            mockBuildTrafficSignals     = MockRepository.GenerateMock <IBuildTrafficSignals>();
            mockBuildStageRunnerFactory = MockRepository.GenerateMock <IBuildStageRunnerFactory>();
            logger = new DefaultHeadlessLogger();

            project = new Project("Headless");

            buildStage1           = new BuildStage("stage1", this.project);
            buildStage2           = new BuildStage("stage2", this.project);
            buildStageAcceptTests = new BuildStage("accept.tests", this.project);

            buildStageAcceptTests.BuildComputer = "other";

            buildStage2.DependsOn.Add(this.buildStage1);
            buildStageAcceptTests.DependsOn.Add(this.buildStage1);

            project.BuildStages.Add(this.buildStage1);
            project.BuildStages.Add(this.buildStage2);
            project.BuildStages.Add(this.buildStageAcceptTests);

            IStageRunner stageRunner1 = new LocalStageRunner(this.logger);

            stageRunner1.SetBuildStage(this.buildStage1);
            IStageRunner stageRunner2 = new LocalStageRunner(this.logger);

            stageRunner2.SetBuildStage(this.buildStage2);
            IStageRunner stageRunner3 = new LocalStageRunner(this.logger);

            stageRunner3.SetBuildStage(this.buildStageAcceptTests);

            this.mockBuildStageRunnerFactory.Expect(factory => factory.CreateStageRunner(this.buildStage1)).Return(stageRunner1).Repeat.Once();
            this.mockBuildStageRunnerFactory.Expect(factory => factory.CreateStageRunner(this.buildStage2)).Return(stageRunner2).Repeat.Once();
            this.mockBuildStageRunnerFactory.Expect(factory => factory.CreateStageRunner(this.buildStageAcceptTests)).Return(stageRunner3).Repeat.Once();

            mockBuildTaskSuccess = MockRepository.GenerateMock <IBuildTask>();
            this.mockBuildTaskSuccess.Expect(task => task.Execute()).WhenCalled(delegate { Thread.Sleep(3000); });

            mockBuildTaskFailure = MockRepository.GenerateMock <IBuildTask>();
            this.mockBuildTaskFailure.Expect(task => task.Execute()).WhenCalled(delegate
            {
                Thread.Sleep(3000);
                throw new InvalidOperationException();
            });

            this.mockBuildTrafficSignals.Expect(cop => cop.WaitForControlSignal(TimeSpan.Zero))
            .IgnoreArguments().WhenCalled(delegate { Thread.Sleep(5000); }).Return(BuildTrafficCopSignal.NoSignal)
            .Repeat.Any();
        }
Example #13
0
    public override void RunCommand(BuildStage stage, string cmd, string cmdOptions, string cmdArgs, string path, bool debugMode)
    {
        cmd = "\"" + cmd + "\"";

        if (cmdArgs.Equals(""))
        {
            cmdArgs = cmdOptions;
        }

        else
        {
            cmdArgs = cmdOptions.Equals("") ? "\"" + cmdArgs + "\"" : cmdOptions + " \"" + cmdArgs + "\"";
        }

        path = "\"" + path + "\"";

        CreateBatchFileToExecuteCommand(stage, cmd, cmdArgs, debugMode, path);

        ProcessStartInfo processInfo = InitializeProcessInfo(TERMINAL_PATH);

        processInfo.CreateNoWindow  = NO_GUI;
        processInfo.UseShellExecute = true;

        processInfo.Arguments = "/c \"" + Application.dataPath + "\\AppcoinsUnity\\Tools\\BashCommand.bat\"";

        Process newProcess = Process.Start(processInfo);

        bool fileExists;
        bool condition;

        do
        {
            fileExists = File.Exists(Application.dataPath + "\\AppcoinsUnity\\Tools\\ProcessCompleted.out");
            condition  = !fileExists;
            Thread.Sleep(2000);
        }while (condition);

        //Now we can safely kill the process
        if (!newProcess.HasExited)
        {
            newProcess.Kill();
        }

        if (ProcessFailed() == true)
        {
            throw new TerminalProcessFailedException();
        }
    }
    internal override void BuildProject(BuildStage stage, string projPath)
    {
        string command = Tools.FixAppPath(
            EditorPrefs.GetString("appcoins_gradle_path", ""),
            "gradle"
            );

        TurnGradleIntoExe(stage, command);

        string gradleArgs = GetGradleArgs();

        terminal.RunCommand(stage, command, gradleArgs, "", projPath,
                            gradleDebugMode);

        ChangeGradleMem(projPath);
    }
        public override void RunCommand(BuildStage stage, string cmd, string cmdOptions, string cmdArgs, string path, bool debugMode)
        {
            string terminalPath = null;
            int version = -1;
            int.TryParse(Application.unityVersion.Split('.')[0], out version);

            if (Directory.Exists("/Applications/Utilities/Terminal.app") && version > 5)
            {
                terminalPath = "/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal";
            }

            else
            {
                terminalPath = "/bin/bash";
            }

            RunBashCommand(terminalPath, stage, cmd, cmdOptions, cmdArgs, path, debugMode);
        }
    internal override void UnityExport(BuildStage stage, string[] scenesPath,
                                       out string projPath)
    {
        platformTarget.RunAditionalSteps();
        string containerPath = SelectProjectPath(PlayerSettings.productName);

        projPath = containerPath + "/" + PlayerSettings.productName;

        EditorUserBuildSettings.SwitchActiveBuildTarget(buildTargetGroup,
                                                        buildTarget);

        string s = BuildPipeline.BuildPlayer(
            scenesPath, containerPath, buildTarget, buildOptions);

        // If Export is done succesfully s is: "".
        if (!s.Equals(""))
        {
            throw new ExportProjectFailedException();
        }
    }
    // Run all custom build phases
    public virtual void RunProcess()
    {
        // Phase 1: Setup Enviornment
        try
        {
            StateSetupEnv();
            customBuildSetup.Setup();
        }
        catch (Exception e)
        {
            HandleExceptions(e);
            return;
        }

        // Phase 2: GUI (Chose custom build process)
        try
        {
            StateBuildIdle();
            CustomBuildWindow.CreateCustomBuildWindow(stage,
                                                      customBuildWindow,
                                                      scenesSelector,
                                                      buildStagesToRun
                                                      );
            buildStagesToRun.AddListener(
                delegate(BuildStage lastStage)
            {
                lastBuildStage = lastStage;
                scenesPath     = scenesSelector.ScenesToString();
                RunInstalationProcess();
            }
                );
        }
        catch (Exception e)
        {
            HandleExceptions(e);
            return;
        }
    }
Example #18
0
        public override BuildStep CreateStep(BuildContext context,
                                             BuildStage stage, string workingDir)
        {
            if (context == null || context.Settings == null)
            {
                return(null);
            }

            // Accessing the property will force a lookup for the compiler...
            BuildFilePath helpCompiler = this.CompilerFile;

            if (helpCompiler == null || !helpCompiler.Exists)
            {
                throw new BuildException(
                          "The CHM format compiler cannot be found. If installed, manually set its path.");
            }

            BuildSettings settings = context.Settings;

            string helpDirectory = context.OutputDirectory;

            if (String.IsNullOrEmpty(workingDir))
            {
                workingDir = context.WorkingDirectory;
            }

            string helpName = settings.HelpName;

            if (String.IsNullOrEmpty(helpName))
            {
                helpName = "Documentation";
            }
            string helpTitle = settings.HelpTitle;

            if (String.IsNullOrEmpty(helpTitle))
            {
                helpTitle = helpName;
            }
            string helpFolder = this.OutputFolder;
            string helpPath   = Path.Combine(helpDirectory,
                                             String.Format(@"{0}\{1}.chm", helpFolder, helpName));

            // Case 1: Closing the HtmlHelp 1.x viewer...
            if (stage == BuildStage.CloseViewer)
            {
                StepChmViewerClose chmClose = new StepChmViewerClose(
                    helpDirectory, helpPath, helpTitle);

                return(chmClose);
            }

            // Case 2: Starting the HtmlHelp 1.x viewer...
            if (stage == BuildStage.StartViewer)
            {
                StepChmViewerStart chmStart = new StepChmViewerStart(
                    helpDirectory, helpPath);

                return(chmStart);
            }

            // Case 3: Compiling the HtmlHelp 1.x help file...
            if (stage == BuildStage.Compilation)
            {
                string      sandassistDir = settings.SandAssistDirectory;
                CultureInfo culture       = settings.CultureInfo;
                int         lcid          = 1033;
                if (culture != null)
                {
                    lcid = culture.LCID;
                }
                string appLocale = null;
                if (lcid != 1033)
                {
                    string toolsDir = Path.Combine(sandassistDir, "Tools");
                    if (Directory.Exists(toolsDir))
                    {
                        appLocale = Path.Combine(toolsDir, "SBAppLocale.exe");
                    }
                }

                // If there is a customized or format specific TOC use it,
                // otherwise, use the default...
                string tocFile = context["$HelpTocFile"];

                FormatChmOptions options = new FormatChmOptions();
                options.ConfigFile       = Path.Combine(workingDir, "ChmBuilder.config");
                options.HtmlDirectory    = Path.Combine(workingDir, @"Output\html");
                options.LangID           = lcid;
                options.Metadata         = false;
                options.WorkingDirectory = workingDir;
                options.OutputDirectory  = Path.Combine(workingDir, helpFolder);
                options.ProjectName      = helpName;
                options.TocFile          = Path.Combine(workingDir, tocFile);

                BuildMultiStep listSteps = new BuildMultiStep();
                listSteps.LogTitle    = "Building document output format - " + this.Name;
                listSteps.LogTimeSpan = true;

                // 1. Prepare the help html files, and create the html project
                // ChmBuilder.exe
                // /project:Manual /html:Output\html
                //   /lcid:1041 /toc:Toc.xml /out:Help
                string application = Path.Combine(context.SandcastleToolsDirectory,
                                                  "ChmBuilder.exe");
                string arguments = String.Format(
                    "/project:{0} /html:Output\\html /lcid:{1} /toc:{2} /out:{3} /config:ChmBuilder.config",
                    helpName, lcid, tocFile, helpFolder);
                StepChmBuilder chmProcess = new StepChmBuilder(workingDir,
                                                               application, arguments);
                chmProcess.LogTitle        = String.Empty;
                chmProcess.Message         = "Creating project and HTML files for the compiler";
                chmProcess.CopyrightNotice = 2;
                chmProcess.HelpName        = helpName;
                chmProcess.HelpFolder      = helpFolder;
                chmProcess.HelpDirectory   = helpDirectory;
                chmProcess.Options         = options;
                chmProcess.OptimizeStyle   = this.OptimizeStyle;
                chmProcess.Format          = this;

                listSteps.Add(chmProcess);

                // 2. Fix the file encoding: DBCSFix.exe /d:Help /l:1033
                application = Path.Combine(context.SandcastleToolsDirectory,
                                           "DBCSFix.exe");
                arguments = String.Format("/d:{0} /l:{1}", helpFolder + @"\html", lcid);
                StepChmDbcsFix dbcsFixProcess = new StepChmDbcsFix(workingDir,
                                                                   application, arguments);
                dbcsFixProcess.LogTitle        = String.Empty;
                dbcsFixProcess.Message         = "Fixing the DBCS for the non-Unicode compiler";
                dbcsFixProcess.CopyrightNotice = 2;
                dbcsFixProcess.Options         = options;

                listSteps.Add(dbcsFixProcess);

                // 3. Compile the Html help files: hhc Help\Manual.hhp
                application = helpCompiler.Path;
                arguments   = String.Format(@"{0}\{1}.hhp", helpFolder, helpName);
                if (String.IsNullOrEmpty(appLocale) == false &&
                    File.Exists(appLocale))
                {
                    arguments = String.Format("$({0}) \"{1}\" {2}", lcid, application,
                                              arguments);
                    application = appLocale;
                }
                StepChmCompiler hhcProcess = new StepChmCompiler(workingDir,
                                                                 application, arguments);
                hhcProcess.LogTitle        = String.Empty;
                hhcProcess.Message         = "Compiling HtmlHelp 1.x help file";
                hhcProcess.CopyrightNotice = 2;
                hhcProcess.KeepSources     = _keepSources;
                hhcProcess.HelpName        = helpName;
                hhcProcess.HelpFolder      = helpFolder;
                hhcProcess.HelpDirectory   = helpDirectory;

                listSteps.Add(hhcProcess);

                return(listSteps);
            }

            return(null);
        }
Example #19
0
 public abstract void RunCommand(BuildStage stage, string cmd, string cmdOptions, string cmdArgs, string path, bool debugMode);
 public IStageRunner CreateStageRunner(BuildStage stage)
 {
     return(new LocalStageRunner(headlessLogger));
 }
Example #21
0
 public void RunTerminalCommand(BuildStage stage, string terminalPath, string cmd, string cmdOptions, string cmdArgs, bool debugMode)
 {
     RunCommand(stage, cmd, "", cmdArgs, ".", debugMode);
 }
Example #22
0
 public static BuildActionBag CreateBag(BuildStage buildStage, params IBuildAction[] buildActions) => new()
Example #23
0
 public StageStatus(BuildStage stage)
 {
     this.stage = stage;
 }
Example #24
0
 private StageStatus GetStageStatus(BuildStage stage)
 {
     return(stagesStatuses[stage.StageId]);
 }
Example #25
0
 public void SetBuildStage(BuildStage buildStage)
 {
     this.buildStage = buildStage;
 }
Example #26
0
    private bool CheckProcessErrors()
    {
        string errorString = "";
        int errorCode = 0;

        if(currentProcess == null || !currentProcess.HasExited)
            return false;

        if(currentProcess.ExitCode != 0)
        {
            errorCode = currentProcess.ExitCode;

            if(currentStage == BuildStage.BuildProject)
            {
                StringReader logFile = new System.IO.StringReader(buildAppStageLog);
                while(true)
                {
                    string result = logFile.ReadLine();
                    if(result == null)
                        break;

                    Match m = Regex.Match(result, @"\[BEROR\](.*)");
                    if(m.Success)
                    {
                        errorString += m.Groups[1].Captures[0].Value+"\n";
                        continue;
                    }

                    // 3 line compiple error
                    // we just give the first line of this as formatting makes them unreadable
                    m = Regex.Match(result, @":[0-9]+:[0-9]+: (error|warning):.*");
                    if(m.Success)
                    {
                        errorString += result+"\n\n";
                        continue;
                    }

                    // linker errors
                    m = Regex.Match(result, @"Undefined symbols for architecture");
                    if(m.Success)
                    {
                        do
                        {
                            errorString += result+"\n";
                            result = logFile.ReadLine();
                            m = Regex.Match(result, @"ld: symbol\(s\) not found for architecture");
                        } while(result != null && !m.Success);
                        errorString += "\n";
                    }
                }
            }
            else
                errorString = currentProcess.StandardError.ReadToEnd();
        }
        else if(currentStage == BuildStage.Upload)
        {
            while(!currentProcess.StandardOutput.EndOfStream)
            {
                string str = currentProcess.StandardOutput.ReadLine();

                if(currentProcess.StandardOutput.EndOfStream)
                {
                    if(str == "200")
                        break;
                    else
                        errorCode = int.Parse(str);
                }
                else
                {
                    errorString += str;

                    string[] tokens = str.Split(new char[]{' ', ',', '\n'}, System.StringSplitOptions.RemoveEmptyEntries);
                    if(tokens.Length == 2 && tokens[0] == "\"config_url\":")
                    {
                        resultURL = tokens[1].Trim(new char[]{'"'}).Replace("complete", "report");
                    }
                }
            }
        }

        if(errorCode == 0)
            return false;
        else if(currentStage == BuildStage.Upload)
        {
            if(uploadAttempsRemaining <= 0)
            {
                string uploadSuggestion = GetStageErrorSuggestion(currentStage, errorString);
                int result = EditorUtility.DisplayDialogComplex("Trouble Uploading",
                    "There was a problem uploading to testlight.\n" +
                    "This happens sometimes when their servers are busy, retrying the upload usually works after a few attempts." +
                    "\n\nError Message:\n"+GetStageErrorMessages(currentStage)+
                    (uploadSuggestion.Length > 0 ? ("\n\nKnown Causes for this error:\n"+uploadSuggestion):"")+
                    "\n\nAdditional Output:\n"+errorString,
                    "Retry",
                    "Cancel",
                    "Retry 10 times");

                Debug.LogError("AutoPilot: Stage "+currentStage+" failed:"+GetStageErrorMessages(currentStage)+"\nAdditional Output:"+errorString);

                if(result == 0)
                    uploadAttempsRemaining = 1;
                else if (result==2)
                    uploadAttempsRemaining = 10;
                else
                    return true;
            }

            if(uploadAttempsRemaining > 0)
            {
                currentStage = BuildStage.PackageIPA; // nextstage will be called, setting us to upload again
                return false;
            }
        }

        string suggestion = GetStageErrorSuggestion(currentStage, errorString);

        int option = EditorUtility.DisplayDialogComplex("AutoPilot: Build FAILED", "Stage "+currentStage+
                                    "\n\nError Message:\n"+GetStageErrorMessages(currentStage)+
                                    (suggestion.Length > 0 ? ("\n\nKnown Causes for this error:\n"+suggestion):"")+
                                    "\n\nIf you think this error is a bug with AutoPilot:\nPlease contact the developer ([email protected]) and provide the full error information from the console window."+
                                    "\n\nAdditional Output:\n"+errorString, "Ok", "Check on forums...", "Contact developer...");

           switch (option)
        {
                // Ok
                case 0:
                    break;

            // Check forums
                case 1:
                    Application.OpenURL("http://forum.unity3d.com/threads/100591-AutoPilot-for-Testflight-1.0-(deploy-iOS-builds-via-cloud!)-Now-on-the-asset-store");
                    break;

                // Email developer
                case 2:
                    string bodyString = "1. Describe the issue in detail\n" +
                                        "\n" +
                                        "\n" +
                                        "2. List steps that caused this issue\n" +
                                        "\n" +
                                        "\n" +
                                        "3. How often does this happen?\n" +
                                        "\n" +
                                        "\n" +
                                        "Build Stage: " + currentStage + "\n" +
                                        "\n" +
                                        "Build Error:\n" + errorString;

                    bodyString = Google.GData.Client.HttpUtility.UrlEncode(bodyString);
                    Debug.Log(bodyString);
                    Application.OpenURL("mailto:[email protected]?subject=Autopilot%20Issue&body="+bodyString);
                    break;
        }

        Debug.LogError("AutoPilot: Stage "+currentStage+" failed:"+GetStageErrorMessages(currentStage)+"\nAdditional Output:"+errorString);
        return true;
    }
Example #27
0
        public override BuildStep CreateStep(BuildContext context,
                                             BuildStage stage, string workingDir)
        {
            if (context == null || context.Settings == null)
            {
                return(null);
            }

            BuildSettings settings = context.Settings;

            string helpDirectory = context.OutputDirectory;

            if (String.IsNullOrEmpty(workingDir))
            {
                workingDir = context.WorkingDirectory;
            }

            string helpName = settings.HelpName;

            if (String.IsNullOrEmpty(helpName))
            {
                helpName = "Documentation";
            }
            string helpTitle = settings.HelpTitle;

            if (String.IsNullOrEmpty(helpTitle))
            {
                helpTitle = helpName;
            }
            string helpFolder = this.OutputFolder;
            string helpPath   = Path.Combine(helpDirectory,
                                             String.Format(@"{0}\{1}.mshc", helpFolder, helpName));
            string helpSetup = Path.Combine(helpDirectory,
                                            String.Format(@"{0}\{1}", helpFolder,
                                                          StepMhvBuilder.HelpContentSetup));

            // Case 1: Closing the HtmlHelp 3.x viewer...
            if (stage == BuildStage.CloseViewer)
            {
                StepMhvViewerClose mhvClose = new StepMhvViewerClose(workingDir);

                return(mhvClose);
            }

            // Case 2: Starting the HtmlHelp 3.x viewer...
            if (stage == BuildStage.StartViewer)
            {
                StepMhvViewerStart mhvStart = new StepMhvViewerStart(
                    helpDirectory, helpPath, helpSetup);

                return(mhvStart);
            }

            // Case 3: Compiling the HtmlHelp 3.x help file...
            if (stage == BuildStage.Compilation)
            {
                CultureInfo culture = settings.CultureInfo;
                int         lcid    = 1033;
                if (culture != null)
                {
                    lcid = culture.LCID;
                }

                BuildMultiStep listSteps = new BuildMultiStep();
                listSteps.LogTitle    = "Building document output format - " + this.Name;
                listSteps.LogTimeSpan = true;

                // 1. Move the output html files to the help folder for compilation...
                StepDirectoryMove dirMove = new StepDirectoryMove(workingDir);
                dirMove.LogTitle = String.Empty;
                dirMove.Message  = "Moving the output html files to the help folder for compilation";
                dirMove.Add(@"Output\" + this.FormatFolder, helpFolder + @"\html");

                listSteps.Add(dirMove);

                // 2. Compile or build the HtmlHelp 3.x format...
                StepMhvBuilder mhvBuilder = new StepMhvBuilder(workingDir);

                mhvBuilder.Message       = "Compiling the help file.";
                mhvBuilder.LogTitle      = String.Empty;
                mhvBuilder.HelpName      = helpName;
                mhvBuilder.HelpFolder    = helpFolder;
                mhvBuilder.HelpDirectory = helpDirectory;
                mhvBuilder.OptimizeStyle = this.OptimizeStyle;

                listSteps.Add(mhvBuilder);

                return(listSteps);
            }

            return(null);
        }
Example #28
0
    private void RunBashCommand(string terminalPath, BuildStage stage, string cmd, string cmdOptions, string cmdArgs, string path, bool debugMode)
    {
        bool GUI = false;

        cmd = "'" + cmd + "'";

        if (cmdArgs.Equals(""))
        {
            cmdArgs = cmdOptions;
        }

        else
        {
            cmdArgs = cmdOptions.Equals("") ? "'" + cmdArgs + "'" : cmdOptions + " '" + cmdArgs + "'";
        }

        path = "'" + path + "'";

        ProcessStartInfo processInfo = InitializeProcessInfo(terminalPath);

        processInfo.CreateNoWindow = false;

        if (terminalPath.Equals("/bin/bash"))
        {
            processInfo.Arguments = "-c \"'" + Application.dataPath + "/AppcoinsUnity/Tools/BashCommand.sh'\"";
        }

        else
        {
            processInfo.Arguments = "'" + Application.dataPath + "/AppcoinsUnity/Tools/BashCommand.sh'";
            GUI = true;
        }

        CreateSHFileToExecuteCommand(stage, cmd, cmdArgs, path, debugMode, GUI);

        Process execScript = Process.Start("/bin/bash", "-c \"chmod +x '" + Application.dataPath + "/AppcoinsUnity/Tools/BashCommand.sh'\"");

        execScript.WaitForExit();


        Process newProcess = new Process();

        newProcess.StartInfo = processInfo;
        newProcess.Start();

        //For the process to complete we check with, 5s interval, for the existence of ProcessCompleted.out
        bool fileExists;
        bool condition;

        do
        {
            fileExists = File.Exists(Application.dataPath + "/AppcoinsUnity/Tools/ProcessCompleted.out");
            condition  = !fileExists;
            Thread.Sleep(2000);
        }while (condition);

        //Now we can safely kill the process
        if (!newProcess.HasExited)
        {
            newProcess.Kill();
        }

        if (ProcessFailed() == true)
        {
            throw new TerminalProcessFailedException();
        }
    }
 private void ChangeStage(BuildStage theStage)
 {
     stage = theStage;
 }
Example #30
0
 private string GetStageErrorMessages(BuildStage stage)
 {
     switch(stage)
     {
     case BuildStage.BuildProject: return 	"An error occured trying to build the .app file, please ensure you can manually build an iPhone project at the build location: "+preferences.teamPrefs.buildPath;
     case BuildStage.PackageIPA: return 		"An error occured while packaging the .ipa file, please retry this build... if that does not work build your iPhone project manually and ensure you are able to \"Build & Archive\" within XCode without errors.";
     case BuildStage.Upload: return 			"An error occured uploading to testflight. Please check that you can access testflightapp.com";
     default: return "";
     }
 }
 public abstract void UnityExport(BuildStage stage, string[] scenesPath,
                                  out string projPath);
Example #32
0
    private string GetStageErrorSuggestion(BuildStage stage, string errorString)
    {
        switch(stage)
        {
        case BuildStage.BuildProject:
            if(errorString.Contains("Reason for failure: -[__NSCFDictionary setObject:forKey:]: attempt to insert nil key"))
                return "1. The selected Developer Identity may be invalid, or not compatible with this project.\n" +
                       "2. If you selected the default 'iPhone Distribution' identity, XCode may not have a default for this. Try using a specific certificate.";
            else
                return "";

        case BuildStage.PackageIPA:
            return "";

        case BuildStage.Upload:
            if(errorString.Contains("curl: (6) Could not resolve host:"))
                return "1. Cannot connect to testfight. It may be down, or there may be network issues. Check that you can access testflightapp.com";
            if(errorString.Contains("Invalid Profile: developer build entitlements must have get-task-allow set to true."))
                return  "1. Attempting to upload Ad-hoc build using a 'Developer' identity certificate instead of the 'Distribution' identity it's built against";
            else
                return "";

        default:
            return "";
        }
    }
Example #33
0
    private void SetBuildTime(BuildStage stage, float time)
    {
        switch(stage)
        {
        case BuildStage.BuildProject:
            preferences.userPrefs.lastBuildAppTime = time;
            preferences.userPrefs.Save();
            break;

        case BuildStage.PackageIPA:
            preferences.userPrefs.lastPackageIpaTime = time;
            preferences.userPrefs.Save();
            break;

        case BuildStage.Upload:
            preferences.userPrefs.lastUploadTime = time;
            preferences.userPrefs.Save();
            break;
        }
    }
Example #34
0
 private void SetStage(BuildStage stage)
 {
     currentStage = stage;
     Repaint();
 }
Example #35
0
 private void DrawStageLabel(BuildStage targetStage)
 {
     string text = GetNameOfStage(targetStage);
     if(targetStage==currentStage)
         GUILayout.Label(text, (targetStage != currentStage) ? "Label":"Foldout");
     else
         GUILayout.Toggle((int)targetStage<(int)currentStage, text);
 }
Example #36
0
    //This creates a bash file that gets executed in the specified path
    protected void CreateSHFileToExecuteCommand(BuildStage stage, string cmd, string cmdArgs, string path, bool debugMode, bool GUI)
    {
        if (!Directory.Exists(Application.dataPath + "/AppcoinsUnity/Tools"))
        {
            Directory.CreateDirectory(Application.dataPath + "/AppcoinsUnity/Tools");
        }

        else
        {
            // Delete all temporary files.
            if (File.Exists(Application.dataPath + "/AppcoinsUnity/Tools/ProcessCompleted.out"))
            {
                File.Delete(Application.dataPath + "/AppcoinsUnity/Tools/ProcessCompleted.out");
            }

            if (File.Exists(Application.dataPath + "/AppcoinsUnity/Tools/ProcessError.out"))
            {
                File.Delete(Application.dataPath + "/AppcoinsUnity/Tools/stderr.out");
            }

            if (File.Exists(Application.dataPath + "/AppcoinsUnity/Tools/BashCommand.bat"))
            {
                File.Delete(Application.dataPath + "/AppcoinsUnity/Tools/BashCommand.bat");
            }

            if (File.Exists(Application.dataPath + "/AppcoinsUnity/Tools/BashCommand.sh"))
            {
                File.Delete(Application.dataPath + "/AppcoinsUnity/Tools/BashCommand.sh");
            }
        }

        StreamWriter writer = new StreamWriter(Application.dataPath + "/AppcoinsUnity/Tools/BashCommand.sh", false);

        writer.WriteLine("#!/bin/sh");

        //Put terminal as first foreground application
        if (GUI)
        {
            writer.WriteLine("osascript -e 'activate application \"/Applications/Utilities/Terminal.app\"'");
        }

        writer.WriteLine("cd " + path);
        //writer.WriteLine(cmd);
        if (stage == BuildStage.PROJECT_INSTALL || stage == BuildStage.PROJECT_RUN)
        {
            writer.WriteLine("if [ \"$(" + cmd + " get-state)\" == \"device\" ]\nthen");
        }

        // writer.WriteLine(cmd + " " + cmdArgs + " 2> '" + Application.dataPath + "/AppcoinsUnity/Tools/ProcessLog.out' | tee '" + Application.dataPath + "/AppcoinsUnity/Tools/ProcessLog.out'");
        writer.WriteLine(cmd + " " + cmdArgs + " 2>&1 2>'" + Application.dataPath + "/AppcoinsUnity/Tools/ProcessError.out'");

        if (stage == BuildStage.PROJECT_INSTALL || stage == BuildStage.PROJECT_RUN)
        {
            writer.WriteLine("else\necho error: no usb device found > '" + Application.dataPath + "/AppcoinsUnity/Tools/ProcessError.out'");
            writer.WriteLine("fi");
        }

        if (stage == BuildStage.PROJECT_BUILD && debugMode)
        {
            writer.WriteLine("read -p '\n\nPress enter to continue...'");
        }

        writer.WriteLine("echo 'done' > '" + Application.dataPath + "/AppcoinsUnity/Tools/ProcessCompleted.out'");
        writer.WriteLine("exit");
        // writer.WriteLine("osascript -e 'tell application \"Terminal\" to close first window'");
        writer.Close();
    }
 internal abstract void InstallProject(BuildStage stage, string projPath);
Example #38
0
 private float GetLastBuildTime(BuildStage stage)
 {
     switch(stage)
     {
     case BuildStage.WaitingToStart: return 2;
     case BuildStage.BuildProject: 	return preferences.userPrefs.lastBuildAppTime;
     case BuildStage.PackageIPA: 	return preferences.userPrefs.lastPackageIpaTime;
     case BuildStage.Upload: 		return preferences.userPrefs.lastUploadTime;
     }
     return -1;
 }