Example #1
0
        public static void Run(string[] args)
        {
            if (args.FirstOrDefault() != MagicArgument)
            {
                return;
            }

            if (args.Length < 2)
            {
                Console.Error.WriteLine("Expected second argument to be the unique identifier for the pipe.");
                return;
            }

            var systemId  = SystemGuidLoader.LoadOrCreateOrEmpty();
            var sessionId = Guid.NewGuid();
            var reporter  = ReportFactory.GetReporter(systemId, sessionId, "SimulatorHost");

            AppDomain.CurrentDomain.ReportUnhandledExceptions(reporter);

            var inputPipe  = Platform.CreateStream("input");
            var outputPipe = Platform.CreateStream("output");

            var input = ReadInput(inputPipe);

            var output = Run(input, SystemInfoFactory.GetBuildVersion(typeof(FuseApi).Assembly));

            using (output.WriteOutput(outputPipe))
                using (input.Connect())
                {
                    input.LastAsync().Wait();
                }
        }
Example #2
0
        public static IFuse Initialize(string programName, List <string> args)
        {
            var systemId  = SystemGuidLoader.LoadOrCreateOrEmpty();
            var sessionId = Guid.NewGuid();

            var report = ReportFactory.GetReporter(systemId, sessionId, programName);

            AppDomain.CurrentDomain.ReportUnhandledExceptions(report);
            report.Info("Initializing with arguments '" + args.Join(" ") + "'");

            // Report running mono version
            Type type = Type.GetType("Mono.Runtime");

            if (type != null)
            {
                MethodInfo displayName = type.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
                if (displayName != null)
                {
                    report.Info("Running with Mono " + displayName.Invoke(null, null));
                }
            }

            EnsureSpecialFoldersExist();

            var fuseExeOverride = args
                                  .TryParse("override-fuse-exe")
                                  .SelectMany(AbsoluteFilePath.TryParse);

            var rootDirSetByArgs = Optional.None <AbsoluteDirectoryPath>();            /*args
                                                                                        * .FirstOrNone(a => a.StartsWith("fuse-root"))
                                                                                        * .Select(a => a.Substring(a.IndexOf("=", StringComparison.InvariantCulture) + 1, a.Length - 1 - a.IndexOf("=", StringComparison.InvariantCulture)))
                                                                                        * .Select(AbsoluteDirectoryPath.Parse);*/

            var os = Platform.OperatingSystem;

            var fuseRoot = rootDirSetByArgs
                           .Or(() => GetFuseRoot(os))
                           .OrThrow(new FuseRootDirectoryWasNotFound());

            if (os != OS.Mac && os != OS.Windows)
            {
                throw new UnsupportedPlatformException(os);
            }

            var isMac = os == OS.Mac;


            var mono = isMac ? Optional.Some(FindMonoExe(fuseRoot)) : Optional.None();

            var codeAssistanceService = new FileName("Fuse.CodeAssistanceService.exe");

            var fuseExe = fuseExeOverride.Or(isMac
                                ? fuseRoot / "MacOS" / new FileName("Fuse")
                                : fuseRoot / new FileName("Fuse.exe"));

            var unoExe = FindUnoExe(fuseRoot);

            var impl = new FuseImpl
            {
                FuseRoot = fuseRoot,
                Version  = SystemInfoFactory.GetBuildVersion(),

                UnoExe  = unoExe,
                FuseExe = fuseExe,
                MonoExe = mono,

                Fuse = ExternalApplication.FromNativeExe(fuseExe),

                // Tools

                Designer = isMac
                                        ? ExternalApplication.FromAppBundle(fuseRoot / new FileName("Fuse Studio.app"))
                                        : ExternalApplication.FromNativeExe(fuseRoot / new FileName("Fuse Studio.exe")),

                // Services

                CodeAssistance = isMac
                                        ? ExternalApplication.FromMonoExe(fuseRoot / "MonoBundle" / codeAssistanceService, mono)
                                        : ExternalApplication.FromNativeExe(fuseRoot / codeAssistanceService),

                Tray = isMac
                                        ? ExternalApplication.FromNativeExe(fuseRoot / "Fuse Tray.app" / "Contents" / "MacOS" / new FileName("Fuse Tray"))
                                        : ExternalApplication.FromNativeExe(fuseRoot / new FileName("Fuse-Tray.exe")),

                LogServer = isMac
                                        ? ExternalApplication.FromNativeExe(fuseRoot / new FileName("fuse-logserver"))
                                        : null,

                // Uno

                Uno = isMac
                                        ? ExternalApplication.FromMonoExe(unoExe, mono)
                                        : ExternalApplication.FromNativeExe(unoExe),

                // System paths

                UserDataDir = isMac
                                        ? AbsoluteDirectoryPath.Parse(Environment.GetFolderPath(Environment.SpecialFolder.Personal)) / ".fuse"
                                        : AbsoluteDirectoryPath.Parse(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)) /
                              "Fusetools" / "Fuse",

                ProjectsDir =
                    AbsoluteDirectoryPath.Parse(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)) / "Fuse",

                SystemId  = systemId,
                SessionId = sessionId,
                Report    = report
            };

            var partial = args.Remove("--partial") | args.Remove("-p");

            if (!partial)
            {
                impl.CheckCompleteness();
            }

            // Set assembly configuration for .unoconfig, to be able to find correct bin/$(Configuration) directories.
#if DEBUG
            UnoConfigFile.Constants["Configuration"] = "Debug";
#else
            UnoConfigFile.Constants["Configuration"] = "Release";
#endif
            return(impl);
        }