public LogSubject(Guid id) { var buildEvents = new Subject <IBinaryMessage>(); var loggedEvents = new AccumulatingProgress <IBinaryMessage>(buildEvents.ToProgress()); var errorList = new ErrorListAdapter(id, loggedEvents); var textWriter = new TextWriterAdapter(id, loggedEvents); Log = new Log(errorList, textWriter); Messages = buildEvents; }
/// <exception cref="BuildFailed"></exception> /// <exception cref="FailedToCreateOutputDir"></exception> public System.Threading.Tasks.Task <BuildResult> BuildUno(Guid id, BuildProject args, PreviewTarget previewTarget, bool driectToDevice, CancellationToken cancellationToken, bool quitAfterApkLaunch) { args.Id = id; var loggedEvents = new AccumulatingProgress <IBinaryMessage>(_buildEvents); var errorList = new ErrorListAdapter(id, loggedEvents); var textWriter = new TextWriterAdapter(id, loggedEvents); var tcs = new TaskCompletionSource <BuildResult>(); var project = _simulatorBuilder.CreateSimulatorProject(args, previewTarget, driectToDevice, quitAfterApkLaunch); var thread = new Thread( () => { var logger = new Log(errorList, textWriter); if (project.IsVerboseBuild) { logger.Level = Uno.Logging.LogLevel.Verbose; } if (project.BuildLibraries) { new LibraryBuilder(new Disk(logger), BuildTargets.Package) { Express = true } } .Build(); var buildTarget = GetBuildTarget(previewTarget); //BuildTarget target; //Enum.TryParse(buildTarget.Identifier, true, out target); _buildEvents.Report( new Started { Command = args }); var faulty = false; try { var buildResult = new ProjectBuilder( logger, buildTarget, project.Options) .Build(project.Project); if (buildResult.ErrorCount != 0) { _errorHelpers.OnBuildFailed(buildResult); tcs.SetException(new UserCodeContainsErrors()); } else { tcs.SetResult(buildResult); } } catch (Exception e) { if (e is ThreadAbortException) { return; } tcs.TrySetException(new InternalBuildError(e)); faulty = true; } finally { _buildEvents.Report( new Ended { Command = args, Success = !faulty, BuildDirectory = AbsoluteDirectoryPath.Parse(project.Project.OutputDirectory) }); } })