private static string FindIOSDeploy()
        {
            var shellArgs = new ShellProcessArguments
            {
                Executable = "ls",
                Arguments  = new[]
                {
                    iOSDeployFolder
                },
                ThrowOnError = false
            };
            var output = ShellProcess.Run(shellArgs);

            var versionStr = "0.0.0";

            if (output.ExitCode == 0)
            {
                var versions = output.FullOutput.Split('\n');
                foreach (var v in versions)
                {
                    if (v.Length > 0 && (new System.Version(v)).CompareTo(new System.Version(versionStr)) > 0)
                    {
                        versionStr = v;
                    }
                }
            }
            if (versionStr == "0.0.0")
            {
                throw new Exception($"iOS deploy is required in order to install and launch the app, to install it simply run \"brew install ios-deploy\"");
            }
            return($"{iOSDeployFolder}/{versionStr}/bin/ios-deploy");
        }
Ejemplo n.º 2
0
 public static void Main()
 {
     foreach (ProcessComponent pc in ShellProcess.Make())
     {
         Console.WriteLine(pc);
     }
 }
        internal override ShellProcessOutput RunTestMode(string exeName, string workingDirPath, int timeout)
        {
            var app = $"{workingDirPath}/{exeName}{ExecutableExtension}";

            if (!Directory.Exists(app))
            {
                throw new Exception($"Couldn't find iOS app at: {app} ");
            }
            using (var progress = new BuildProgress("Running the iOS app", "Please wait..."))
            {
                var shellArgs = new ShellProcessArguments
                {
                    Executable = FindIOSDeploy(),
                    Arguments  = new[]
                    {
                        "--noninteractive",
                        "--debug",
                        "--uninstall",
                        "--bundle",
                        app
                    },
                    WorkingDirectory = new DirectoryInfo(workingDirPath)
                };
                if (timeout > 0)
                {
                    shellArgs.MaxIdleTimeInMilliseconds = timeout;
                    shellArgs.MaxIdleKillIsAnError      = false;
                }

                return(ShellProcess.Run(shellArgs));
            }
        }
Ejemplo n.º 4
0
    /// <summary>
    /// The main entry point to this program.
    /// </summary>
    public static void Main()
    {
        ProcessComponent p = ShellProcess.Make();
        PrettyVisitor    v = new PrettyVisitor();

        Console.WriteLine(v.GetPretty(p));
    }
Ejemplo n.º 5
0
 private ShellProcessOutput InstallApk(string apkName, string buildDir)
 {
     return(ShellProcess.Run(new ShellProcessArguments()
     {
         ThrowOnError = false,
         Executable = AdbPath,
         Arguments = new string[] { "install", "\"" + apkName + "\"" },
         WorkingDirectory = new DirectoryInfo(buildDir)
     }));
 }
        private static Process StartPosixSocketBridgeProcess()
        {
            var shellArgs = new ShellProcessArguments
            {
                Executable = SocketBridgeExecutable,
                Arguments  = new [] { "6690" },
            };

            var posixSocketBridgeProcess = ShellProcess.Start(shellArgs);

            return(posixSocketBridgeProcess.Process);
        }
Ejemplo n.º 7
0
        public static ShellProcess RunShellProcess(ShellProcess shProcess)
        {
            if (LOGGER.IsDebugEnabled)
            {
                LOGGER.DebugFormat("Running Command: {0} {1}",
                    shProcess.ProcStartInfo.FileName,
                    shProcess.ProcStartInfo.Arguments);
            }

            shProcess.Run();
            return shProcess;
        }
Ejemplo n.º 8
0
    public static void Main()
    {
        CompositeEnumerator e = (CompositeEnumerator)ShellProcess.Make().GetEnumerator();

        while (e.MoveNext())
        {
            for (int i = 0; i < e.Depth(); i++)
            {
                Console.Write("    ");
            }
            Console.WriteLine(e.Current);
        }
    }
Ejemplo n.º 9
0
        internal static ShellProcessOutput RunTestMode(ShellProcessArguments shellArgs, string workingDirPath, int timeout)
        {
            shellArgs.WorkingDirectory = new DirectoryInfo(workingDirPath);
            shellArgs.ThrowOnError     = false;

            // samples should be killed on timeout
            if (timeout > 0)
            {
                shellArgs.MaxIdleTimeInMilliseconds = timeout;
                shellArgs.MaxIdleKillIsAnError      = false;
            }

            return(ShellProcess.Run(shellArgs));
        }
Ejemplo n.º 10
0
 private ShellProcessOutput LaunchApp(string buildDir)
 {
     return(ShellProcess.Run(new ShellProcessArguments()
     {
         ThrowOnError = false,
         Executable = AdbPath,
         Arguments = new string[] {
             "shell", "am", "start",
             "-a", "android.intent.action.MAIN",
             "-c", "android.intent.category.LAUNCHER",
             "-f", "0x10200000",
             "-S",
             "-n", $"{PackageName}/com.unity3d.tinyplayer.UnityTinyActivity"
         },
         WorkingDirectory = new DirectoryInfo(buildDir)
     }));
 }
Ejemplo n.º 11
0
        public override bool Run(FileInfo buildTarget)
        {
            var buildDir = buildTarget.Directory.FullName;

            var result = UninstallApp(buildTarget.FullName, buildDir);

            if (ExportSettings?.TargetType == AndroidTargetType.AndroidAppBundle)
            {
                result = BuildApks(buildTarget.FullName, buildDir);
                // bundletool might write to stderr even if there are no errors
                if (result.ExitCode != 0)
                {
                    throw new Exception($"Cannot build APKS : {result.FullOutput}");
                }
                result = InstallApks(buildDir);
                if (result.ExitCode != 0)
                {
                    throw new Exception($"Cannot install APKS : {result.FullOutput}");
                }
            }
            else
            {
                result = InstallApk(buildTarget.FullName, buildDir);
                if (!result.FullOutput.Contains("Success"))
                {
                    throw new Exception($"Cannot install APK : {result.FullOutput}");
                }
            }
            result = LaunchApp(buildDir);
            // killing adb to unlock build folder
            ShellProcess.Run(new ShellProcessArguments()
            {
                ThrowOnError = false,
                Executable   = AdbPath,
                Arguments    = new string[] { "kill-server" }
            });
            if (result.Succeeded)
            {
                return(true);
            }
            else
            {
                throw new Exception($"Cannot launch APK : {result.FullOutput}");
            }
        }
Ejemplo n.º 12
0
        private ShellProcessOutput InstallApks(string buildDir)
        {
            var apksName = GetApksName(buildDir);

            return(ShellProcess.Run(new ShellProcessArguments()
            {
                ThrowOnError = false,
                Executable = JavaPath,
                Arguments = new string[] {
                    "-jar",
                    $"\"{BundleToolJar}\"",
                    "install-apks",
                    $"--apks=\"{apksName}\"",
                    $"--adb=\"{AdbPath}\""
                },
                WorkingDirectory = new DirectoryInfo(buildDir)
            }));
        }
Ejemplo n.º 13
0
        private ShellProcessOutput BuildApks(string aabName, string buildDir)
        {
            var apksName = GetApksName(buildDir);
            //TODO check for mutliple device installing

            string keystorePassFile = null;
            string keyaliasPassFile = null;

            if (UseKeystore)
            {
                keystorePassFile = Path.Combine(buildDir, "keystore.pass");
                keyaliasPassFile = Path.Combine(buildDir, "keyalias.pass");
                File.WriteAllText(keystorePassFile, Keystore.KeystorePass);
                File.WriteAllText(keyaliasPassFile, Keystore.KeyaliasPass);
            }
            var result = ShellProcess.Run(new ShellProcessArguments()
            {
                ThrowOnError = false,
                Executable   = JavaPath,
                Arguments    = new string[] {
                    "-jar",
                    $"\"{BundleToolJar}\"",
                    "build-apks",
                    $"--bundle=\"{aabName}\"",
                    $"--output=\"{apksName}\"",
                    "--overwrite",
                    (UseKeystore ? $"--ks=\"{Keystore.KeystoreFullPath}\" --ks-pass=file:\"{keystorePassFile}\" --ks-key-alias=\"{Keystore.KeyaliasName}\" --key-pass=file:\"{keyaliasPassFile}\"" : "")
                },
                WorkingDirectory = new DirectoryInfo(buildDir)
            });

            if (UseKeystore)
            {
                File.Delete(keystorePassFile);
                File.Delete(keyaliasPassFile);
            }
            return(result);
        }
Ejemplo n.º 14
0
        private ShellProcessOutput UninstallApp(string apkName, string buildDir)
        {
            // checking that app is already installed
            var result = ShellProcess.Run(new ShellProcessArguments()
            {
                ThrowOnError     = false,
                Executable       = AdbPath,
                Arguments        = new string[] { "shell", "pm", "list", "packages", PackageName },
                WorkingDirectory = new DirectoryInfo(buildDir)
            });

            if (result.FullOutput.Contains(PackageName))
            {
                // uninstall previous version, it may be signed with different key, so re-installing is not possible
                result = ShellProcess.Run(new ShellProcessArguments()
                {
                    ThrowOnError     = false,
                    Executable       = AdbPath,
                    Arguments        = new string[] { "uninstall", PackageName },
                    WorkingDirectory = new DirectoryInfo(buildDir)
                });
            }
            return(result);
        }
Ejemplo n.º 15
0
        static IEnumerator <BeeProgressInfo> Run(string arguments, StringBuilder command, StringBuilder output, DirectoryInfo workingDirectory = null)
        {
            var beeExe     = Path.GetFullPath($"{Constants.DotsRuntimePackagePath}/bee~/bee.exe");
            var executable = beeExe;

            arguments = "--no-colors " + arguments;

#if !UNITY_EDITOR_WIN
            arguments  = "\"" + executable + "\" " + arguments;
            executable = Path.Combine(UnityEditor.EditorApplication.applicationContentsPath,
                                      "MonoBleedingEdge/bin/mono");
#endif

            command.Append(executable);
            command.Append(" ");
            command.Append(arguments);

            var progressInfo = new BeeProgressInfo()
            {
                Progress = 0.0f,
                Info     = null
            };

            void ProgressHandler(object sender, DataReceivedEventArgs args)
            {
                if (string.IsNullOrWhiteSpace(args.Data))
                {
                    return;
                }

                var match = BeeProgressRegex.Match(args.Data);

                if (match.Success)
                {
                    var num = match.Groups["nominator"].Value;
                    var den = match.Groups["denominator"].Value;
                    if (int.TryParse(num, out var numInt) && int.TryParse(den, out var denInt))
                    {
                        progressInfo.Progress = (float)numInt / denInt;
                    }
                    progressInfo.Info = ShortenAnnotation(match.Groups["annotation"].Value);
                }

                var busyMatch = BeeBusyRegex.Match(args.Data);

                if (busyMatch.Success)
                {
                    progressInfo.Info = ShortenAnnotation(busyMatch.Groups["annotation"].Value);
                }

                progressInfo.FullInfo = args.Data;
                lock (output)
                {
                    output.AppendLine(args.Data);
                }
            }

            var config = new ShellProcessArguments()
            {
                Executable       = executable,
                Arguments        = new[] { arguments },
                WorkingDirectory = workingDirectory,
#if !UNITY_EDITOR_WIN
                // bee requires external programs to perform build actions
                EnvironmentVariables = new Dictionary <string, string>()
                {
                    { "PATH", string.Join(":",
                                          Path.Combine(UnityEditor.EditorApplication.applicationContentsPath,
                                                       "MonoBleedingEdge/bin"),
                                          "/bin",
                                          "/usr/bin",
                                          "/usr/local/bin") }
                },
#else
                EnvironmentVariables = null,
#endif
                OutputDataReceived = ProgressHandler,
                ErrorDataReceived  = ProgressHandler
            };

            var bee = ShellProcess.Start(config);
            progressInfo.Process = bee;

            yield return(progressInfo);

            const int maxBuildTimeInMs = 30 * 60 * 1000; // 30 minutes

            var statusEnum = bee.WaitForProcess(maxBuildTimeInMs);
            while (statusEnum.MoveNext())
            {
                yield return(progressInfo);
            }

            progressInfo.Progress = 1.0f;
            progressInfo.IsDone   = true;
            progressInfo.ExitCode = bee.Process.ExitCode;
            progressInfo.Info     = "Build completed";
            yield return(progressInfo);
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Test liczenia etapów dla procesu produkcji petardy powietrznej.
 /// </summary>
 public void TestShell()
 {
     Assertion.AssertEquals(4, ShellProcess.Make().GetStepCount());
 }
Ejemplo n.º 17
0
 public int Release(ShellProcess process)
 {
     process.Close();
     return(process.ExitCode);
 }
Ejemplo n.º 18
0
        internal override ShellProcessOutput RunTestMode(string exeName, string workingDirPath, int timeout)
        {
            var executable = $"{workingDirPath}/{exeName}{ExecutableExtension}";
            var output     = UninstallApp(executable, workingDirPath);

            if (ExportSettings?.TargetType == AndroidTargetType.AndroidAppBundle)
            {
                output = BuildApks(executable, workingDirPath);
                // bundletool might write to stderr even if there are no errors
                if (output.ExitCode != 0)
                {
                    return(output);
                }
                output = InstallApks(workingDirPath);
                if (output.ExitCode != 0)
                {
                    return(output);
                }
            }
            else
            {
                output = InstallApk(executable, workingDirPath);
                if (!output.FullOutput.Contains("Success"))
                {
                    return(output);
                }
            }

            // clear logcat
            ShellProcess.Run(new ShellProcessArguments()
            {
                ThrowOnError = false,
                Executable   = AdbPath,
                Arguments    = new string[] {
                    "logcat", "-c"
                },
                WorkingDirectory = new DirectoryInfo(workingDirPath)
            });

            output = LaunchApp(workingDirPath);

            System.Threading.Thread.Sleep(timeout == 0 ? 2000 : timeout); // to kill process anyway,
                                                                          // should be rewritten to support tests which quits after execution

            // killing on timeout
            ShellProcess.Run(new ShellProcessArguments()
            {
                ThrowOnError = false,
                Executable   = AdbPath,
                Arguments    = new string[] {
                    "shell", "am", "force-stop",
                    PackageName
                },
                WorkingDirectory = new DirectoryInfo(workingDirPath)
            });

            // get logcat
            output = ShellProcess.Run(new ShellProcessArguments()
            {
                ThrowOnError = false,
                Executable   = AdbPath,
                Arguments    = new string[] {
                    "logcat", "-d"
                },
                WorkingDirectory = new DirectoryInfo(workingDirPath)
            });
            if (timeout == 0) // non-sample test, TODO invent something better
            {
                output.Succeeded = output.FullOutput.Contains("Test suite: SUCCESS");
            }
            return(output);
        }
Ejemplo n.º 19
0
 public void TestShell()
 {
     Assert.AreEqual(4, ShellProcess.Make().GetStepCount());
 }