Ejemplo n.º 1
0
        private static IFrontEndController TryCreateFrontEndController(
            FrontEndFactory frontEndFactory,
            IDecorator <EvaluationResult> decorator,
            ICommandLineConfiguration configuration,
            SymbolTable symbolTable,
            LoggingContext loggingContext,
            PerformanceCollector collector,
            bool collectMemoryAsSoonAsPossible,
            IFrontEndStatistics statistics)
        {
            Contract.Requires(frontEndFactory != null && !frontEndFactory.IsSealed);

            // Statistic should be global for all front-ends, not per an instance.
            var frontEndStatistics = statistics ?? new FrontEndStatistics();

            var sharedModuleRegistry = new ModuleRegistry(symbolTable);

            // Note, that the following code is absolutely critical for detecting that front-end related objects
            // are freed successfully after evaluation.
            // ModuleRegistry was picked intentionally because it holds vast amount of front-end data.
            FrontEndControllerMemoryObserver.CaptureFrontEndReference(sharedModuleRegistry);

            frontEndFactory.SetConfigurationProcessor(
                new ConfigurationProcessor(
                    new FrontEndStatistics(), // Configuration processing is so lightweight that it won't affect overall perf statistics
                    logger: null));

            frontEndFactory.AddFrontEnd(new DScriptFrontEnd(
                                            frontEndStatistics,
                                            evaluationDecorator: decorator));

            frontEndFactory.AddFrontEnd(new NugetFrontEnd(
                                            frontEndStatistics,
                                            evaluationDecorator: decorator));

            frontEndFactory.AddFrontEnd(new DownloadFrontEnd());

#if PLATFORM_WIN
            frontEndFactory.AddFrontEnd(new MsBuildFrontEnd());
            frontEndFactory.AddFrontEnd(new NinjaFrontEnd());
            frontEndFactory.AddFrontEnd(new CMakeFrontEnd());
            frontEndFactory.AddFrontEnd(new RushFrontEnd());
            frontEndFactory.AddFrontEnd(new YarnFrontEnd());
            frontEndFactory.AddFrontEnd(new LageFrontEnd());
#endif

            if (!frontEndFactory.TrySeal(loggingContext))
            {
                return(null);
            }

            return(new FrontEndHostController(
                       frontEndFactory,
                       evaluationScheduler: EvaluationScheduler.Default,
                       moduleRegistry: sharedModuleRegistry,
                       frontEndStatistics: frontEndStatistics,
                       logger: BuildXL.FrontEnd.Core.Tracing.Logger.CreateLogger(),
                       collector: collector,
                       collectMemoryAsSoonAsPossible: collectMemoryAsSoonAsPossible));
        }
Ejemplo n.º 2
0
        private static IFrontEndController TryCreateFrontEndController(
            FrontEndFactory frontEndFactory,
            IDecorator <EvaluationResult> decorator,
            ICommandLineConfiguration configuration,
            SymbolTable symbolTable,
            LoggingContext loggingContext,
            PerformanceCollector collector,
            bool collectMemoryAsSoonAsPossible,
            IFrontEndStatistics statistics)
        {
            var workspaceResolverFactory = new DScriptWorkspaceResolverFactory();

            Contract.Requires(frontEndFactory != null && !frontEndFactory.IsSealed);

            // Statistic should be global for all front-ends, not per an instance.
            var frontEndStatistics = statistics ?? new FrontEndStatistics();

            var globalConstants      = new GlobalConstants(symbolTable);
            var sharedModuleRegistry = new ModuleRegistry();

            // Note, that the following code is absolutely critical for detecting that front-end related objects
            // are freed successfully after evaluation.
            // ModuleRegistry was picked intentionally because it holds vast amount of front-end data.
            FrontEndControllerMemoryObserver.CaptureFrontEndReference(sharedModuleRegistry);

            frontEndFactory.SetConfigurationProcessor(
                new ConfigurationProcessor(globalConstants, sharedModuleRegistry, logger: null));

            var msBuildFrontEnd = new MsBuildFrontEnd(
                globalConstants,
                sharedModuleRegistry,
                frontEndStatistics);

            var ninjaFrontEnd = new NinjaFrontEnd(
                globalConstants,
                sharedModuleRegistry,
                frontEndStatistics);

            var cmakeFrontEnd = new CMakeFrontEnd(
                globalConstants,
                sharedModuleRegistry,
                frontEndStatistics);

            // TODO: Workspace resolvers and frontends are registered in separate factories. Consider
            // adding a main coordinator/registry
            RegisterKnownWorkspaceResolvers(
                workspaceResolverFactory,
                globalConstants,
                sharedModuleRegistry,
                frontEndStatistics,
                msBuildFrontEnd,
                ninjaFrontEnd,
                cmakeFrontEnd);

            frontEndFactory.AddFrontEnd(new DScriptFrontEnd(
                                            globalConstants,
                                            sharedModuleRegistry,
                                            frontEndStatistics,
                                            evaluationDecorator: decorator));

            frontEndFactory.AddFrontEnd(new NugetFrontEnd(
                                            globalConstants,
                                            sharedModuleRegistry,
                                            frontEndStatistics,
                                            evaluationDecorator: decorator));

            frontEndFactory.AddFrontEnd(new DownloadFrontEnd(
                                            globalConstants,
                                            sharedModuleRegistry));

            frontEndFactory.AddFrontEnd(msBuildFrontEnd);
            frontEndFactory.AddFrontEnd(ninjaFrontEnd);
            frontEndFactory.AddFrontEnd(cmakeFrontEnd);

            if (!frontEndFactory.TrySeal(loggingContext))
            {
                return(null);
            }

            return(new FrontEndHostController(frontEndFactory, workspaceResolverFactory,
                                              frontEndStatistics: frontEndStatistics, collector: collector, collectMemoryAsSoonAsPossible: collectMemoryAsSoonAsPossible));
        }