public CMakeConversationExecuter(ExecutionContext executionContext, IProcessManager processManager, IBinariesLocator binariesLocator, IEnvironmentService environmentService, IOutputFormatterPool formatterPool) { this.executionContext = executionContext; this.processManager = processManager; this.binariesLocator = binariesLocator; this.environmentService = environmentService; this.formatterPool = formatterPool; }
public ProcessManager(IEnvironmentService environmentService, ExecutionContext executionContext, IOutputFormatterPool formatterPool, CancellationToken cancellationToken) { this.environmentService = environmentService; this.cancellationToken = cancellationToken; this.formatterPool = formatterPool; this.executionContext = executionContext; }
public CMakeSdkExplorer(IFileSystem fileSystem, IEnvironmentService environmentService, IProcessManager processManager, IBinariesLocator binariesLocator, ExecutionContext executionContext, IOutputFormatterPool formatterPool) { this.fileSystem = fileSystem; this.environmentService = environmentService; this.processManager = processManager; this.binariesLocator = binariesLocator; this.executionContext = executionContext; this.formatterPool = formatterPool; }
public CmakeExecuter(IProcessManager processManager, IUserInterface userInterface, IBinariesLocator binariesLocator, IFileSystem fileSystem, IEnvironmentService environmentService, ExecutionContext executionContext, IOutputFormatterPool formatterPool) { this.processManager = processManager; this.userInterface = userInterface; this.binariesLocator = binariesLocator; this.fileSystem = fileSystem; this.environmentService = environmentService; this.executionContext = executionContext; this.formatterPool = formatterPool; }
public static async Task <CMakeConversation> Start(IProcessManager processManager, IBinariesLocator binariesLocator, IOutputFormatterPool formatterPool, VirtualDirectory tempDirectory, bool isWindowsSystem, ExecutionContext executionContext, VirtualDirectory sourceDirectory, VirtualDirectory binaryDirectory) { IProcess process = null; NamedPipeClientStream pipeClient = null; try { string pipeName = isWindowsSystem ? $"{tempDirectory.FullName}\\.cmakeserver" : $"/tmp/cmake-server-{Guid.NewGuid().ToByteString()}"; string serverCommand = isWindowsSystem ? $"-E server --experimental --pipe=\"\\\\?\\pipe\\{pipeName}\"" : $"-E server --experimental --pipe={pipeName}"; process = processManager.StartProcess(binariesLocator.GetExecutableCommand("cmake"), serverCommand, executionContext); pipeClient = new NamedPipeClientStream(".", pipeName, PipeDirection.InOut, PipeOptions.Asynchronous, TokenImpersonationLevel.Impersonation); pipeClient.Connect(CMakeServerTimeout); if (!pipeClient.IsConnected) { throw new FormattableException("Could not connect to server"); } FormatterParameters parameters = new FormatterParameters(); parameters.Add("cmake-json", MessageFormat); IUserInterface jsonCmakeInterface = formatterPool.GetFormatter(parameters, executionContext); CMakeServerStream serverStream = new CMakeServerStream(pipeClient, executionContext); CMakeHelloMessage hello = null; do { foreach (string singleMessage in await serverStream.ReadMessage() .TimeoutAfter(CMakeServerTimeout) .ConfigureAwait(false)) { hello = CMakeMessage.Parse <CMakeMessage>(singleMessage, jsonCmakeInterface) as CMakeHelloMessage; } } while (hello == null); if (hello.SupportedProtocolVersions.All(v => v.Major != 1)) { throw new FormattableException("CMake server does not support the protocol version 1.X. " + $"Supported versions are {string.Join(", ", hello.SupportedProtocolVersions)}"); } CMakeConversation conversation = new CMakeConversation(process, pipeClient, serverStream, jsonCmakeInterface); await conversation.Handshake(sourceDirectory.FullName.Replace('\\', '/'), binaryDirectory.FullName.Replace('\\', '/')) .ConfigureAwait(false); await conversation.Configure().ConfigureAwait(false); return(conversation); } catch (Exception) { pipeClient?.Dispose(); process?.Dispose(); throw; } }