Beispiel #1
0
        public async Task <bool> Restore(IConsole console, IStatusBar statusBar = null)
        {
            return(await Task.Factory.StartNew(() =>
            {
                var exitCode = PlatformSupport.ExecuteShellCommand(DotNetCliService.Instance.Info.Executable, $"restore {Path.GetFileName(Location)}", (s, e) =>
                {
                    if (statusBar != null)
                    {
                        if (!string.IsNullOrWhiteSpace(e.Data))
                        {
                            Dispatcher.UIThread.InvokeAsync(() =>
                            {
                                statusBar.SetText(e.Data.Trim());
                            });
                        }
                    }

                    console?.WriteLine(e.Data);
                }, (s, e) =>
                {
                    if (e.Data != null)
                    {
                        if (console != null)
                        {
                            console.WriteLine();
                            console.WriteLine(e.Data);
                        }
                    }
                },
                                                                   false, CurrentDirectory, false);

                return exitCode == 0;
            }));
        }
Beispiel #2
0
        public override CompileResult Compile(IConsole console, IStandardProject superProject, IStandardProject project, ISourceFile file, string outputFile)
        {
            var result = new CompileResult();

            string commandName = file.Extension == ".cpp" ? CPPExecutable : CCExecutable;

            var fileArguments = string.Empty;

            if (file.Extension == ".cpp")
            {
                fileArguments = "-x c++ -fno-use-cxa-atexit";
            }

            var arguments = string.Format("{0} {1} {2} -o{3} -MMD -MP", fileArguments, GetCompilerArguments(superProject, project, file), file.Location, outputFile);

            result.ExitCode = PlatformSupport.ExecuteShellCommand(commandName, arguments, (s, e) => console.WriteLine(e.Data), (s, e) =>
            {
                if (e.Data != null)
                {
                    console.WriteLine();
                    console.WriteLine(e.Data);
                }
            },
                                                                  false, file.CurrentDirectory, false);

            //console.WriteLine(Path.GetFileNameWithoutExtension(commandName) + " " + arguments);

            return(result);
        }
Beispiel #3
0
        public async Task <bool> Build(IConsole console, IProject project, string label = "", IEnumerable <string> definitions = null)
        {
            return(await Task.Factory.StartNew(() =>
            {
                string lastLine = string.Empty;

                var exitCode = PlatformSupport.ExecuteShellCommand(Path.Combine(BinDirectory, "dotnet" + Platform.ExecutableExtension), "build", (s, e) =>
                {
                    console.WriteLine(e.Data);

                    if (!string.IsNullOrEmpty(e.Data))
                    {
                        lastLine = e.Data;
                    }
                }, (s, e) =>
                {
                    if (e.Data != null)
                    {
                        console.WriteLine();
                        console.WriteLine(e.Data);
                    }
                },
                                                                   false, project.CurrentDirectory, false);

                if (exitCode == 0 && lastLine.StartsWith($"  {project.Name} -> "))
                {
                    project.Executable = lastLine.Substring($"  {project.Name} -> ".Length);
                }
                ;

                return exitCode == 0;
            }));
        }
Beispiel #4
0
        public async Task <bool> Build(IConsole console, IProject project, string label = "", IEnumerable <string> definitions = null)
        {
            return(await Task.Factory.StartNew(() =>
            {
                var settings = SettingsBase.GetSettings <DotNetToolchainSettings>();

                var exitCode = PlatformSupport.ExecuteShellCommand(settings.DotNetPath, "build", (s, e) =>
                {
                    console.WriteLine(e.Data);

                    if (!string.IsNullOrEmpty(e.Data))
                    {
                        if (e.Data.StartsWith($"  {project.Name} -> "))
                        {
                            project.Executable = e.Data.Substring($"  {project.Name} -> ".Length);
                        }
                    }
                }, (s, e) =>
                {
                    if (e.Data != null)
                    {
                        console.WriteLine();
                        console.WriteLine(e.Data);
                    }
                },
                                                                   false, project.CurrentDirectory, false);

                return exitCode == 0;
            }));
        }
Beispiel #5
0
        public Task <bool> Build(IConsole console, IProject project, string label = "", IEnumerable <string> definitions = null)
        {
            console.WriteLine($"Build Started - {project.Name}");
            //Make sure tools are available
            if (!PlatformSupport.CheckExecutableAvailability("tsc"))
            {
                //TypeScript compiler missing
                console.WriteLine("The TypeScript compiler `tsc` is not available on your path. Please install it with `npm install -g typescript`");
                //Check if they're also missing Node
                if (!PlatformSupport.CheckExecutableAvailability("node"))
                {
                    console.WriteLine("You seem to be missing Node.js. Please install Node.js and TypeScript globally.");
                }
                console.WriteLine("Build failed.");
                return(Task.FromResult(false)); //Fail build
            }
            var tscVersionResult = PlatformSupport.ExecuteShellCommand("tsc", "-v");

            //Run build
            console.WriteLine($"Using TypeScript compiler {tscVersionResult.Output}");

            console.WriteLine($"TypeScript compile started...");
            var compileExitCode = PlatformSupport.ExecuteShellCommand("tsc", $"-p {project.CurrentDirectory}", (s, a) => console.WriteLine(a.Data));

            if (compileExitCode != 0)
            {
                console.WriteLine($"Build completed with code {compileExitCode}");
            }
            else
            {
                console.WriteLine("Build completed successfully.");
            }

            return(Task.FromResult(compileExitCode == 0));
        }
Beispiel #6
0
        public static void Initialise()
        {
            if (!Directory.Exists(BaseDirectory))
            {
                Directory.CreateDirectory(BaseDirectory);
            }

            if (!Directory.Exists(PackageDirectory))
            {
                Directory.CreateDirectory(PackageDirectory);
            }

            if (!Directory.Exists(SettingsDirectory))
            {
                Directory.CreateDirectory(SettingsDirectory);
            }

            if (!Directory.Exists(CacheDirectory))
            {
                Directory.CreateDirectory(CacheDirectory);
            }

            if (!Directory.Exists(AppDataDirectory))
            {
                Directory.CreateDirectory(AppDataDirectory);
            }

            if (!Directory.Exists(ReposDirectory))
            {
                Directory.CreateDirectory(ReposDirectory);
            }

            if (!Directory.Exists(RepoCatalogDirectory))
            {
                Directory.CreateDirectory(RepoCatalogDirectory);
            }

            if (!Directory.Exists(SnippetsFolder))
            {
                Directory.CreateDirectory(SnippetsFolder);
            }

            if (!Directory.Exists(InBuiltSnippetsFolder))
            {
                Directory.CreateDirectory(InBuiltSnippetsFolder);
            }

            if (!Directory.Exists(ExtensionsFolder))
            {
                Directory.CreateDirectory(ExtensionsFolder);
            }

            if (Platform.PlatformIdentifier == PlatformID.MacOSX)
            {
                var paths = PlatformSupport.GetSystemPaths();

                Environment.SetEnvironmentVariable("PATH", string.Join(":", paths));
            }
        }
Beispiel #7
0
        public override ProcessResult Size(IConsole console, IStandardProject project, LinkResult linkResult)
        {
            var result = new ProcessResult();

            result.ExitCode = PlatformSupport.ExecuteShellCommand(SizeExecutable, linkResult.Executable,
                                                                  (s, e) => console.WriteLine(e.Data),
                                                                  (s, e) => console.WriteLine(e.Data),
                                                                  false, string.Empty, false, RunWithSystemPaths);

            return(result);
        }
Beispiel #8
0
        private bool CheckFile(IConsole console, string file)
        {
            bool result = true;

            if (Platform.PlatformIdentifier != PlatformID.Unix && !PlatformSupport.CheckExecutableAvailability(file))
            {
                console.WriteLine("Unable to find tool (" + file + ") Please check project toolchain settings.");
                result = false;
            }

            return(result);
        }
Beispiel #9
0
        public static Runner For(RuntimePlatform platform)
        {
            Runner runner;

            PlatformSupport.For(platform).RegisterRunner();
            _platformRunners.TryGetValue(platform.GetType(), out runner);
            if (runner == null)
            {
                throw new ArgumentException($"Can't find runner for platform {platform}!");
            }
            return(runner);
        }
Beispiel #10
0
        public async Task <ProcessResult> ObjCopy(IConsole console, IProject project, LinkResult linkResult, AssemblyFormat format)
        {
            var result = new ProcessResult();

            var commandName = Path.Combine(BinDirectory, $"{SizePrefix}objcopy" + Platform.ExecutableExtension);

            if (PlatformSupport.CheckExecutableAvailability(commandName, BinDirectory))
            {
                string formatArg = "binary";

                switch (format)
                {
                case AssemblyFormat.Binary:
                    formatArg = "binary";
                    break;

                case AssemblyFormat.IntelHex:
                    formatArg = "ihex";
                    break;
                }

                string outputExtension = ".bin";

                switch (format)
                {
                case AssemblyFormat.Binary:
                    outputExtension = ".bin";
                    break;

                case AssemblyFormat.IntelHex:
                    outputExtension = ".hex";
                    break;

                case AssemblyFormat.Elf32:
                    outputExtension = ".elf";
                    break;
                }

                var arguments = $"-O {formatArg} {linkResult.Executable} {Path.GetDirectoryName(linkResult.Executable)}{Platform.DirectorySeperator}{Path.GetFileNameWithoutExtension(linkResult.Executable)}{outputExtension}";

                console.WriteLine($"Converting to {format.ToString()}");

                result.ExitCode = PlatformSupport.ExecuteShellCommand(commandName, arguments, (s, e) => console.WriteLine(e.Data), (s, e) => console.WriteLine(e.Data), false, string.Empty, false);
            }
            else
            {
                console.WriteLine("Unable to find tool (" + commandName + ") check project compiler settings.");
                result.ExitCode = -1;
            }

            return(result);
        }
Beispiel #11
0
        public override CompileResult Compile(IConsole console, IStandardProject superProject, IStandardProject project, ISourceFile file, string outputFile)
        {
            var result = new CompileResult();

            var settings = superProject.GetToolchainSettingsIfExists <GccToolchainSettings>().CompileSettings;

            string commandName = file.Extension == ".cpp" ? CPPExecutable : CCExecutable;

            var fileArguments = string.Empty;

            if (file.Extension.ToLower() == ".cpp" || (settings != null && settings.CompileExtensions.Select(ext => "." + ext.ToLower()).Contains(file.Extension.ToLower())))
            {
                fileArguments = "-x c++ -fno-use-cxa-atexit";
            }

            if (file.Extension.ToLower() == ".s" || (settings != null && settings.AssembleExtensions.Select(ext => "." + ext.ToLower()).Contains(file.Extension.ToLower())))
            {
                fileArguments = "-x assembler-with-cpp";
            }

            var environment = superProject.GetEnvironmentVariables().AppendRange(Platform.EnvironmentVariables);

            var arguments = "";

            if (!string.IsNullOrWhiteSpace(SysRoot))
            {
                arguments = string.Format("{0} {1} {2} -o{3} -MMD -MP --sysroot=\"{4}\"", fileArguments, GetCompilerArguments(superProject, project, file), file.Location, outputFile, SysRoot).ExpandVariables(environment);
            }
            else
            {
                arguments = string.Format("{0} {1} {2} -o{3} -MMD -MP", fileArguments, GetCompilerArguments(superProject, project, file), file.Location, outputFile).ExpandVariables(environment);
            }

            result.ExitCode = PlatformSupport.ExecuteShellCommand(commandName, arguments, (s, e) => console.WriteLine(e.Data), (s, e) =>
            {
                if (e.Data != null)
                {
                    ParseOutputForErrors(result.Diagnostics, file, e.Data);
                    console.WriteLine();
                    console.WriteLine(e.Data);
                }
            },
                                                                  false, "", false, RunWithSystemPaths, ExtraPaths);

            if (Studio.DebugMode)
            {
                console.WriteLine(Path.GetFileNameWithoutExtension(commandName) + " " + arguments);
            }

            return(result);
        }
Beispiel #12
0
        public Task EnsureConnectionAsync()
        {
            return(Task.Run(() =>
            {
                if (_connection == null || !_client.Connected)
                {
                    _client?.Dispose();

                    using (var l = new OneShotTcpServer())
                    {
                        var path = typeof(NextRequestType).Assembly.GetModules()[0].FullyQualifiedName;
                        path = Path.Combine(Path.GetDirectoryName(path), "host.csproj");

                        string args = $"msbuild /p:AvaloniaIdePort={l.Port} {path}";

                        Console.WriteLine(args);

                        hostProcess = PlatformSupport.LaunchShellCommand("dotnet", args,
                                                                         (sender, e) =>
                        {
                            if (e.Data != null)
                            {
                                lock (outputLines)
                                {
                                    outputLines.Add(e.Data);
                                }

                                if (e.Data == "*** Request Handled")
                                {
                                    requestComplete.Set();
                                }
                            }
                        },
                                                                         (sender, e) =>
                        {
                            if (e.Data != null)
                            {
                                lock (errorLines)
                                {
                                    errorLines.Add(e.Data);
                                }
                            }
                        }, false, Platforms.Platform.ExecutionPath, false);

                        _client = l.WaitForOneConnection();
                        _connection = new WireHelper(_client.GetStream());
                    }
                }
            }));
        }
Beispiel #13
0
 public async Task Clean(IConsole console, IProject project)
 {
     await Task.Factory.StartNew(() =>
     {
         var exitCode = PlatformSupport.ExecuteShellCommand(Path.Combine(BinDirectory, "dotnet" + Platform.ExecutableExtension), "clean", (s, e) => console.WriteLine(e.Data), (s, e) =>
         {
             if (e.Data != null)
             {
                 console.WriteLine();
                 console.WriteLine(e.Data);
             }
         },
                                                            false, project.CurrentDirectory, false);
     });
 }
        private void CreateConnection(string workingDirectory = null)
        {
            lock (_createLock)
            {
                if (workingDirectory == null)
                {
                    _studio = IoC.Get <IStudio>();

                    workingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);

                    var solution = _studio.CurrentSolution;

                    if (solution != null)
                    {
                        if (solution?.StartupProject != null)
                        {
                            workingDirectory = solution.StartupProject.CurrentDirectory;
                        }
                        else
                        {
                            workingDirectory = solution.CurrentDirectory;
                        }
                    }
                }

                CloseConnection();

                var args = new List <string>();

                if (Platform.PlatformIdentifier == Platforms.PlatformID.MacOSX)
                {
                    args.Add("-l");
                }

                var shellExecutable = PlatformSupport.ResolveFullExecutablePath((Platform.PlatformIdentifier == Platforms.PlatformID.Win32NT ? "powershell" : "bash") + Platform.ExecutableExtension);

                if (shellExecutable != null)
                {
                    var terminal = s_provider.Create(80, 32, workingDirectory, null, shellExecutable, args.ToArray());

                    Connection = new PsuedoTerminalConnection(terminal);

                    TerminalVisible = true;

                    Connection.Closed += Connection_Closed;
                }
            }
        }
Beispiel #15
0
        public override async Task BeforeBuild(IConsole console, IProject project)
        {
            await base.BeforeBuild(console, project);

            var process = PlatformSupport.LaunchShellCommand($"{CCExecutable}", "--version", (s, e) =>
            {
                if (e.Data != null)
                {
                    console.WriteLine(e.Data);
                }
            }, (s, e) => { },
                                                             false, BinDirectory, false, RunWithSystemPaths);

            await process.WaitForExitAsync();

            console.WriteLine();
        }
Beispiel #16
0
        public async Task Clean(IConsole console, IProject project)
        {
            await Task.Factory.StartNew(() =>
            {
                console.Write($"Cleaning Project: {project.Name}...");
                var exitCode = PlatformSupport.ExecuteShellCommand(DotNetCliService.Instance.DotNetPath, "clean /nologo", (s, e) => console.WriteLine(e.Data), (s, e) =>
                {
                    if (e.Data != null)
                    {
                        console.WriteLine();
                        console.WriteLine(e.Data);
                    }
                },
                                                                   false, project.CurrentDirectory, false);
            });

            console.WriteLine("Done.");
        }
Beispiel #17
0
        private int ExecuteCommand(IConsole console, IProject project, string command, string args)
        {
            var environment = project.GetEnvironmentVariables().AppendRange(Platform.EnvironmentVariables);

            command = command.ExpandVariables(environment);
            args    = args.ExpandVariables(environment);

            console.WriteLine($"[CMD] {command} {args}");

            var exitCode = PlatformSupport.ExecuteShellCommand(command, args, (s, e) =>
            {
                console.WriteLine(e.Data);
            }, (s, ee) =>
            {
                if (ee.Data != null)
                {
                    console.WriteLine(ee.Data);
                }
            }, false, project.CurrentDirectory, true, true, project.ToolChain?.BinDirectory);

            return(exitCode);
        }
Beispiel #18
0
        private async Task <List <string> > CalculateToolchainIncludes(bool cpp)
        {
            bool foundListStart = false;

            var result = new List <string>();

            string args = cpp ? "-xc++" : "-E";

            var process = PlatformSupport.LaunchShellCommand("echo", $" | {LibraryQueryCommand} {args} -Wp,-v -", (s, e) => { }, (s, e) =>
            {
                if (e.Data != null)
                {
                    if (!foundListStart)
                    {
                        if (e.Data == "#include <...> search starts here:")
                        {
                            foundListStart = true;
                        }
                    }
                    else
                    {
                        if (e.Data == "End of search list.")
                        {
                            foundListStart = false;
                        }
                        else
                        {
                            result.Add(e.Data.NormalizePath());
                        }
                    }
                }
            },
                                                             false, BinDirectory, true, RunWithSystemPaths);

            await process.WaitForExitAsync();

            return(result);
        }
        private async Task <int> ExecuteCommand(IConsole console, IProject project, string command, string args)
        {
            var environment = project.GetEnvironmentVariables().AppendRange(Platform.EnvironmentVariables);

            if (command.Contains('{') && command.Contains('}') && command.Contains('?'))
            {
                var index    = command.IndexOf("{?") + 1;
                var indexEnd = command.IndexOf('}');

                var packageInfo = PackageManager.ParseUrl(command.Substring(index, indexEnd - index));

                await PackageManager.EnsurePackage(packageInfo.package, packageInfo.version, console);

                var directory = PackageManager.GetPackageDirectory(packageInfo.package, packageInfo.version);

                command = command.Remove(index - 1, indexEnd - index + 2);

                command = command.Insert(index - 1, directory);
            }

            command = command.ExpandVariables(environment);
            args    = args.ExpandVariables(environment);

            console.WriteLine($"[CMD] {command} {args}");

            var exitCode = PlatformSupport.ExecuteShellCommand(command, args, (s, e) =>
            {
                console.WriteLine(e.Data);
            }, (s, ee) =>
            {
                if (ee.Data != null)
                {
                    console.WriteLine(ee.Data);
                }
            }, false, project.CurrentDirectory, true, true, project.ToolChain?.BinDirectory);

            return(exitCode);
        }
Beispiel #20
0
        public async Task Clean(IConsole console, IProject project)
        {
            await Task.Factory.StartNew(() =>
            {
                var settings = SettingsBase.GetSettings <DotNetToolchainSettings>();

                if (string.IsNullOrEmpty(settings.DotNetPath))
                {
                    console.WriteLine("Please configure the location of the dotnet runtime and sdk.");
                    return;
                }

                var exitCode = PlatformSupport.ExecuteShellCommand(settings.DotNetPath, "clean", (s, e) => console.WriteLine(e.Data), (s, e) =>
                {
                    if (e.Data != null)
                    {
                        console.WriteLine();
                        console.WriteLine(e.Data);
                    }
                },
                                                                   false, project.CurrentDirectory, false);
            });
        }
        private static string ResolveShimVersion()
        {
            var settings = SettingsBase.GetSettings <DotNetToolchainSettings>();

            bool inHostSection = false;

            string result = string.Empty;

            var exitCode = PlatformSupport.ExecuteShellCommand(settings.DotNetPath, "--info", (s, e) =>
            {
                if (!string.IsNullOrEmpty(e.Data))
                {
                    if (inHostSection)
                    {
                        if (e.Data.Trim().StartsWith("Version"))
                        {
                            var parts = e.Data.Split(':');

                            if (parts.Length >= 2)
                            {
                                result = parts[1].Trim();
                            }
                        }
                    }
                    else
                    {
                        if (e.Data.Trim().StartsWith("Microsoft .NET Core Shared Framework Host"))
                        {
                            inHostSection = true;
                        }
                    }
                }
            }, (s, e) => { }, false, "", false);

            return(result);
        }
Beispiel #22
0
        public async Task <bool> BuildAsync(IConsole console, IProject project, string label = "", IEnumerable <string> definitions = null)
        {
            var diagnosticEntries = new Dictionary <string, List <Diagnostic> >();

            var errorList = IoC.Get <IErrorList>();

            errorList.Remove(this);

            var result = await Task.Factory.StartNew(() =>
            {
                var exitCode = PlatformSupport.ExecuteShellCommand(DotNetCliService.Instance.Info.Executable, $"build {Path.GetFileName(project.Location)}", (s, e) =>
                {
                    console.WriteLine(e.Data);
                    ParseOutputForErrors(diagnosticEntries, e.Data);
                }, (s, e) =>
                {
                    if (e.Data != null)
                    {
                        console.WriteLine();
                        console.WriteLine(e.Data);

                        ParseOutputForErrors(diagnosticEntries, e.Data);
                    }
                },
                                                                   false, project.CurrentDirectory, false);

                return(exitCode == 0);
            });

            foreach (var key in diagnosticEntries.Keys)
            {
                errorList.Create(this, key, DiagnosticSourceKind.Build, diagnosticEntries[key].ToImmutableArray());
            }

            return(result);
        }
Beispiel #23
0
        public Task RestoreAsync(string workingDirectory, string arguments = null, Action onFailure = null)
        {
            return(Task.Factory.StartNew(() =>
            {
                _console.WriteLine($"Begin dotnet restore in '{workingDirectory}'");

                var restoreLock = _locks.GetOrAdd(workingDirectory, new object());
                lock (restoreLock)
                {
                    ShellExecuteResult?exitStatus = null;
                    //_eventEmitter.RestoreStarted(workingDirectory);
                    _semaphore.Wait();
                    try
                    {
                        // A successful restore will update the project lock file which is monitored
                        // by the dotnet project system which eventually update the Roslyn model
                        exitStatus = PlatformSupport.ExecuteShellCommand(Path.Combine(workingDirectory, _dotnetPath), $"restore {arguments}");// updateEnvironment: RemoveMSBuildEnvironmentVariables);
                    }
                    finally
                    {
                        _semaphore.Release();

                        _locks.TryRemove(workingDirectory, out _);

                        //_eventEmitter.RestoreFinished(workingDirectory, exitStatus.Succeeded);

                        if (exitStatus?.ExitCode != 0 && onFailure != null)
                        {
                            onFailure();
                        }

                        _console.WriteLine($"Finish restoring project {workingDirectory}. Exit code {exitStatus}");
                    }
                }
            }));
        }
Beispiel #24
0
        protected override void OnRun(DebuggerStartInfo startInfo)
        {
            var settings    = _project.GetDebuggerSettings <RemoteGdbSettings>();
            var environment = _project.GetEnvironmentVariables().AppendRange(Platform.EnvironmentVariables);

            console.Clear();

            var preInitCommand           = settings.PreInitCommand?.Trim().ExpandVariables(environment);
            var preInitCommandArguments  = settings.PreInitCommandArgs?.Trim().ExpandVariables(environment);
            var postInitCommand          = settings.PostInitCommand?.Trim().ExpandVariables(environment);
            var postInitCommandArguments = settings.PostInitCommandArgs?.Trim().ExpandVariables(environment);

            if (!string.IsNullOrEmpty(preInitCommand))
            {
                console.WriteLine("[Remote GDB] - Starting GDB Server...");

                var gdbServerStartInfo = new ProcessStartInfo
                {
                    Arguments        = preInitCommandArguments ?? "",
                    FileName         = preInitCommand,
                    WorkingDirectory = _project.CurrentDirectory,

                    // Hide console window
                    RedirectStandardOutput = true,
                    RedirectStandardError  = true,
                    UseShellExecute        = false,
                    CreateNoWindow         = true
                };

                Task.Run(() =>
                {
                    using (var process = Process.Start(gdbServerStartInfo))
                    {
                        _gdbServerProcess = process;

                        process.OutputDataReceived += (sender, e) =>
                        {
                            console.WriteLine("[GDB Server] - " + e.Data);
                        };

                        process.ErrorDataReceived += (sender, e) =>
                        {
                            if (!string.IsNullOrEmpty(e.Data))
                            {
                                console.WriteLine("[GDB Server] - " + e.Data);
                            }
                        };

                        process.BeginOutputReadLine();
                        process.BeginErrorReadLine();

                        process.WaitForExit();

                        Dispose();

                        console.WriteLine("[GDB Server] - GDB Server Closed.");

                        _gdbServerProcess = null;
                    }
                });

                TargetExited += (sender, e) =>
                {
                    _gdbServerProcess?.Kill();
                    _gdbServerProcess = null;
                };
            }

            base.OnRun(startInfo);

            Task.Factory.StartNew(async() =>
            {
                await Task.Delay(250);

                if (!string.IsNullOrEmpty(postInitCommand))
                {
                    var console = IoC.Get <IConsole>();

                    var exitCode = PlatformSupport.ExecuteShellCommand(postInitCommand, postInitCommandArguments, (s, e) =>
                    {
                        console.WriteLine(e.Data);
                    }, (s, ee) =>
                    {
                        if (ee.Data != null)
                        {
                            console.WriteLine(ee.Data);
                        }
                    }, false, _project.CurrentDirectory, false);
                }
            });
        }
Beispiel #25
0
        public ProjectViewModel(ISolutionParentViewModel parent, IProject model)
            : base(parent, model)
        {
            shell = IoC.Get <IShell>();

            Items = new ObservableCollection <ProjectItemViewModel>();

            Items.BindCollections(model.Items, p => { return(ProjectItemViewModel.Create(p)); }, (pivm, p) => pivm.Model == p);

            ConfigureCommand = ReactiveCommand.Create(() =>
            {
                if (configuration == null)
                {
                    configuration = new ProjectConfigurationDialogViewModel(model, () =>
                    {
                        configuration = null;
                    });

                    shell.AddDocument(configuration);
                }
                else
                {
                    shell.SelectedDocument = configuration;
                }
                //shell.ModalDialog.ShowDialog();
            });

            DebugCommand = ReactiveCommand.Create(() =>
            {
                //shell.Debug(model);
            });

            BuildCommand = ReactiveCommand.Create(() => shell.Build(model));

            CleanCommand = ReactiveCommand.Create(() => shell.Clean(model));

            ManageReferencesCommand = ReactiveCommand.Create(() => { });

            SetProjectCommand = ReactiveCommand.Create(() =>
            {
                model.Solution.StartupProject = model;
                model.Solution.Save();

                shell.InvalidateCodeAnalysis();

                var root = this.FindRoot();

                if (root != null)
                {
                    root.VisitChildren(solutionItem =>
                    {
                        solutionItem.RaisePropertyChanged(nameof(FontWeight));
                    });
                }
            });

            OpenInExplorerCommand = ReactiveCommand.Create(() => Platform.OpenFolderInExplorer(Model.CurrentDirectory));

            NewItemCommand = ReactiveCommand.Create(() =>
            {
                shell.ModalDialog = new NewItemDialogViewModel(model);
                shell.ModalDialog.ShowDialog();
            });

            RemoveCommand = ReactiveCommand.Create(() =>
            {
                shell.CloseDocumentsForProject(Model);
                Model.Solution.RemoveItem(Model);
                Model.Solution.Save();
            });

            DevConsoleCommand = ReactiveCommand.Create(() =>
            {
                PlatformSupport.LaunchShell(Model.CurrentDirectory, Model.ToolChain?.BinDirectory, Model.Debugger2?.BinDirectory);
            });
        }
Beispiel #26
0
        public SemanticVersion GetVersion(string workingDirectory = null)
        {
            var shellResult = PlatformSupport.ExecuteShellCommand(Path.Combine(workingDirectory, _dotnetPath), "--version");

            return(SemanticVersion.Parse(shellResult.Output));
        }
            public static bool IsApplicationStateSupported()
            {
#if UNITY_EDITOR
                // There are issues with releasing unmanaged memory while running in batch mode for OSX and iOS
                // TODO: Remove this check
                if (UnityEditorInternal.InternalEditorUtility.inBatchMode)
                {
                    return(false);
                }

                // Handles case in the Unity Editor where the buildtarget has changed
                if (m_support_currentBuildTarget != EditorUserBuildSettings.activeBuildTarget)
                {
                    m_support_currentBuildTarget = EditorUserBuildSettings.activeBuildTarget;
                    m_support_check = PlatformSupport.Unknown;
                }
#endif

                // Handles case in the Unity Editor where the platform has changed
                if (m_support_currentPlatform != Application.platform)
                {
                    m_support_currentPlatform = Application.platform;
                    m_support_check           = PlatformSupport.Unknown;
                }

                // Handles case where somehow the graphics device type has changed
                if (m_support_currentGraphicsDeviceType != SystemInfo.graphicsDeviceType)
                {
                    m_support_currentGraphicsDeviceType = SystemInfo.graphicsDeviceType;
                    m_support_check = PlatformSupport.Unknown;
                }

                if (m_support_check == PlatformSupport.Unknown)
                {
                    bool supported = true;

#if UNITY_EDITOR
                    if (!IsSupportedBuildTarget(EditorUserBuildSettings.activeBuildTarget))
                    {
                        Debug.LogError("The current build target is not supported by the 8i Unity Plugin [" + EditorUserBuildSettings.activeBuildTarget + "]");
                        supported = false;
                    }
#endif

                    if (!IsSupportedRuntimePlatform(Application.platform))
                    {
                        Debug.LogError("This platform is not supported by the 8i Unity Plugin [" + Application.platform + "]");
                        supported = false;
                    }

                    if (!IsSupportedRuntimePlatformGraphicsDeviceType(Application.platform, SystemInfo.graphicsDeviceType))
                    {
                        Debug.LogError("GraphicsDeviceType is not supported by the 8i Unity Plugin [" + SystemInfo.graphicsDeviceType + "]");
                        supported = false;
                    }

                    if (!IsSupportedGraphicsDeviceVersion(SystemInfo.graphicsDeviceVersion))
                    {
                        Debug.LogError("GraphicsDeviceVersion is not supported by the 8i Unity Plugin [" + SystemInfo.graphicsDeviceVersion + "]");
                        supported = false;
                    }

                    if (supported)
                    {
                        m_support_check = PlatformSupport.Supported;
                    }
                    else
                    {
                        m_support_check = PlatformSupport.NotSupported;
                    }
                }

                if (m_support_check == PlatformSupport.NotSupported)
                {
                    return(false);
                }

                return(true);
            }
Beispiel #28
0
 public DownloadMirror(PlatformSupport platformSupport, string urlFormat)
 {
     this.platformSupport = platformSupport;
     this.urlFormat       = urlFormat;
 }
Beispiel #29
0
        public Task <bool> Restore(IConsole console, IStatusBar statusBar = null, bool checkLock = false)
        {
            bool restore = !checkLock;

            if (checkLock)
            {
                lock (_restoreLock)
                {
                    restore = !IsRestored;

                    if (restore)
                    {
                        IsRestored = true;

                        _restoreTaskCompletionSource = new TaskCompletionSource <bool>();
                    }
                }
            }

            if (restore)
            {
                return(Task.Factory.StartNew(() =>
                {
                    statusBar.SetText($"Restoring Packages for solution: {Name}");

                    var exitCode = PlatformSupport.ExecuteShellCommand(DotNetCliService.Instance.DotNetPath, $"restore /m {Path.GetFileName(Location)}", (s, e) =>
                    {
                        if (statusBar != null)
                        {
                            if (!string.IsNullOrWhiteSpace(e.Data))
                            {
                                Dispatcher.UIThread.InvokeAsync(() =>
                                {
                                    statusBar.SetText(e.Data.Trim());
                                });
                            }
                        }

                        console?.WriteLine(e.Data);
                    }, (s, e) =>
                    {
                        if (e.Data != null)
                        {
                            if (console != null)
                            {
                                console.WriteLine();
                                console.WriteLine(e.Data);
                            }
                        }
                    },
                                                                       false, CurrentDirectory, false);

                    IsRestored = true;

                    var result = exitCode == 0;

                    _restoreTaskCompletionSource?.SetResult(result);

                    lock (_restoreLock)
                    {
                        _restoreTaskCompletionSource = null;
                    }

                    return result;
                }));
            }
            else
            {
                lock (_restoreLock)
                {
                    if (_restoreTaskCompletionSource != null)
                    {
                        return(_restoreTaskCompletionSource.Task);
                    }
                    else
                    {
                        return(Task.FromResult(true));
                    }
                }
            }
        }
Beispiel #30
0
        public override LinkResult Link(IConsole console, IStandardProject superProject, IStandardProject project, CompileResult assemblies, string outputPath)
        {
            var result = new LinkResult();

            string commandName = project.Type == ProjectType.StaticLibrary ? ARExecutable : LDExecutable;

            var objectArguments = string.Empty;

            foreach (var obj in assemblies.ObjectLocations)
            {
                objectArguments += obj + " ";
            }

            var libs = string.Empty;

            foreach (var lib in assemblies.LibraryLocations)
            {
                libs += lib + " ";
            }

            var outputDir = Path.GetDirectoryName(outputPath);

            if (!Directory.Exists(outputDir))
            {
                Directory.CreateDirectory(outputDir);
            }

            var outputName = Path.GetFileName(outputPath);

            if (project.Type == ProjectType.StaticLibrary)
            {
                outputName = Path.GetFileName(outputPath);
            }

            var executable = Path.Combine(outputDir, outputName);

            var linkedLibraries = string.Empty;

            foreach (var libraryPath in project.StaticLibraries)
            {
                var relativePath = Path.GetDirectoryName(libraryPath);

                var libName = Path.GetFileNameWithoutExtension(libraryPath).Substring(3);

                linkedLibraries += string.Format("-L\"{0}\" -l{1} ", relativePath, libName);
            }

            string libraryPaths = string.Empty;

            var linkerScripts = string.Empty;

            if (project.Type == ProjectType.Executable)
            {
                var settings = project.GetToolchainSettings <GccToolchainSettings>();

                foreach (var libraryPath in settings.LinkSettings.LinkedLibraries)
                {
                    libraryPaths += $"-Wl,--library-path={Path.Combine(project.CurrentDirectory, Path.GetDirectoryName(libraryPath)).ToPlatformPath()} ";

                    var libName = Path.GetFileName(libraryPath);

                    linkedLibraries += string.Format($"-Wl,--library=:{libName} ");
                }

                foreach (var script in settings.LinkSettings.LinkerScripts)
                {
                    linkerScripts += $"-Wl,-T\"{Path.Combine(project.CurrentDirectory, script)}\" ";
                }

                foreach (var lib in settings.LinkSettings.SystemLibraries)
                {
                    linkedLibraries += $"-l{lib} ";
                }
            }

            foreach (var lib in project.BuiltinLibraries)
            {
                linkedLibraries += $"-l{lib} ";
            }

            linkedLibraries += GetBaseLibraryArguments(superProject);

            string arguments = string.Empty;

            if (project.Type == ProjectType.StaticLibrary)
            {
                arguments = string.Format("rvs {0} {1}", executable, objectArguments);
            }
            else
            {
                var environment = superProject.GetEnvironmentVariables().AppendRange(Platform.EnvironmentVariables);
                arguments = string.Format("{0} {1} -o{2} {3} {4} -Wl,--start-group {5} {6} -Wl,--end-group", GetLinkerArguments(superProject, project).ExpandVariables(environment), linkerScripts, executable, objectArguments, libraryPaths, linkedLibraries, libs);
            }

            result.ExitCode = PlatformSupport.ExecuteShellCommand(commandName, arguments, (s, e) =>
            {
                if (e.Data != null)
                {
                    console.WriteLine(e.Data);
                }
            },
                                                                  (s, e) =>
            {
                if (e.Data != null && !e.Data.Contains("creating"))
                {
                    console.WriteLine(e.Data);
                }
            }, false, project.Solution.CurrentDirectory, false, RunWithSystemPaths);

            if (Shell.DebugMode)
            {
                console.WriteLine(Path.GetFileNameWithoutExtension(commandName) + " " + arguments);
            }

            if (result.ExitCode == 0)
            {
                result.Executable = executable;
            }

            return(result);
        }