Exemplo n.º 1
0
 private static void RegisterKnownWorkspaceResolvers(
     DScriptWorkspaceResolverFactory workspaceFactory,
     GlobalConstants constants,
     ModuleRegistry sharedModuleRegistry,
     IFrontEndStatistics statistics,
     MsBuildFrontEnd msBuildFrontEnd,
     NinjaFrontEnd ninjaFrontEnd,
     CMakeFrontEnd cmakeFrontend)
 {
     workspaceFactory.RegisterResolver(
         KnownResolverKind.SourceResolverKind,
         () => new WorkspaceSourceModuleResolver(constants, sharedModuleRegistry, statistics, logger: null));
     workspaceFactory.RegisterResolver(
         KnownResolverKind.DScriptResolverKind,
         () => new WorkspaceSourceModuleResolver(constants, sharedModuleRegistry, statistics, logger: null));
     workspaceFactory.RegisterResolver(
         KnownResolverKind.DefaultSourceResolverKind,
         () => new WorkspaceDefaultSourceModuleResolver(constants, sharedModuleRegistry, statistics, logger: null));
     workspaceFactory.RegisterResolver(
         KnownResolverKind.NugetResolverKind,
         () => new WorkspaceNugetModuleResolver(constants, sharedModuleRegistry, statistics));
     workspaceFactory.RegisterResolver(
         KnownResolverKind.DownloadResolverKind,
         () => new DownloadWorkspaceResolver(constants, sharedModuleRegistry));
     workspaceFactory.RegisterResolver(
         KnownResolverKind.MsBuildResolverKind,
         () => new MsBuildWorkspaceResolver(constants, sharedModuleRegistry, statistics, msBuildFrontEnd));
     workspaceFactory.RegisterResolver(
         KnownResolverKind.NinjaResolverKind,
         () => new NinjaWorkspaceResolver(constants, sharedModuleRegistry, statistics, ninjaFrontEnd));
     workspaceFactory.RegisterResolver(
         KnownResolverKind.CMakeResolverKind,
         () => new CMakeWorkspaceResolver(constants, sharedModuleRegistry, statistics, cmakeFrontend, ninjaFrontEnd));
 }
Exemplo n.º 2
0
 private static void RegisterKnownWorkspaceResolvers(
     StringTable stringTable,
     DScriptWorkspaceResolverFactory workspaceFactory,
     IFrontEndStatistics statistics)
 {
     workspaceFactory.RegisterResolver(
         KnownResolverKind.SourceResolverKind,
         () => new WorkspaceSourceModuleResolver(stringTable, statistics, logger: null));
     workspaceFactory.RegisterResolver(
         KnownResolverKind.DScriptResolverKind,
         () => new WorkspaceSourceModuleResolver(stringTable, statistics, logger: null));
     workspaceFactory.RegisterResolver(
         KnownResolverKind.DefaultSourceResolverKind,
         () => new WorkspaceDefaultSourceModuleResolver(stringTable, statistics, logger: null));
     workspaceFactory.RegisterResolver(
         KnownResolverKind.NugetResolverKind,
         () => new WorkspaceNugetModuleResolver(stringTable, statistics));
     workspaceFactory.RegisterResolver(
         KnownResolverKind.DownloadResolverKind,
         () => new DownloadWorkspaceResolver());
     workspaceFactory.RegisterResolver(
         KnownResolverKind.MsBuildResolverKind,
         () => new MsBuildWorkspaceResolver());
     workspaceFactory.RegisterResolver(
         KnownResolverKind.NinjaResolverKind,
         () => new NinjaWorkspaceResolver());
     workspaceFactory.RegisterResolver(
         KnownResolverKind.CMakeResolverKind,
         () => new CMakeWorkspaceResolver());
 }
Exemplo n.º 3
0
        private bool CreateFactories(
            FrontEndContext frontEndContext,
            TestEngineAbstraction engineAbstraction,
            FrontEndStatistics frontEndStatistics,
            ICommandLineConfiguration configuration,
            out AmbientTesting ambientTesting,
            out DScriptWorkspaceResolverFactory workspaceFactory,
            out FrontEndFactory frontEndFactory)
        {
            var globalConstants = new GlobalConstants(frontEndContext.SymbolTable);

            ambientTesting = new AmbientTesting(engineAbstraction, GetAllDiagnostics, globalConstants.KnownTypes);
            ambientTesting.Initialize(globalConstants.Global);

            var ambientAssert = new AmbientAssert(globalConstants.KnownTypes);

            ambientAssert.Initialize(globalConstants.Global);

            var sharedModuleRegistry = new ModuleRegistry();

            workspaceFactory = new DScriptWorkspaceResolverFactory();
            workspaceFactory.RegisterResolver(
                KnownResolverKind.DScriptResolverKind,
                () => new WorkspaceSourceModuleResolver(globalConstants, sharedModuleRegistry, frontEndStatistics));
            workspaceFactory.RegisterResolver(
                KnownResolverKind.SourceResolverKind,
                () => new WorkspaceSourceModuleResolver(globalConstants, sharedModuleRegistry, frontEndStatistics));
            workspaceFactory.RegisterResolver(
                KnownResolverKind.DefaultSourceResolverKind,
                () => new WorkspaceDefaultSourceModuleResolver(globalConstants, sharedModuleRegistry, frontEndStatistics));

            // Create the controller
            frontEndFactory = new FrontEndFactory();
            frontEndFactory.SetConfigurationProcessor(new TestConfigProcessor(configuration));
            frontEndFactory.AddFrontEnd(
                new DScriptFrontEnd(
                    globalConstants,
                    sharedModuleRegistry,
                    frontEndStatistics,
                    logger: m_astLogger));

            if (!frontEndFactory.TrySeal(frontEndContext.LoggingContext))
            {
                HandleDiagnostics();
                return(false);
            }

            return(true);
        }
Exemplo n.º 4
0
        private BuildXLEngine CreateEngine(bool rememberAllChangedTrackedInputs)
        {
            IFrontEndController Create(PathTable pathTable, SymbolTable symbolTable)
            {
                var frontEndStatistics = new FrontEndStatistics();
                var moduleRegistry     = new ModuleRegistry(symbolTable);

                var workspaceFactory = new DScriptWorkspaceResolverFactory();

                workspaceFactory.RegisterResolver(KnownResolverKind.SourceResolverKind,
                                                  () => new WorkspaceSourceModuleResolver(pathTable.StringTable, frontEndStatistics, ParseAndEvaluateLogger));
                workspaceFactory.RegisterResolver(KnownResolverKind.DScriptResolverKind,
                                                  () => new WorkspaceSourceModuleResolver(pathTable.StringTable, frontEndStatistics, ParseAndEvaluateLogger));
                workspaceFactory.RegisterResolver(KnownResolverKind.DefaultSourceResolverKind,
                                                  () => new WorkspaceDefaultSourceModuleResolver(pathTable.StringTable, frontEndStatistics, ParseAndEvaluateLogger));

                var frontEndFactory = FrontEndFactory.CreateInstanceForTesting(
                    () => new ConfigurationProcessor(new FrontEndStatistics(), ParseAndEvaluateLogger),
                    new DScriptFrontEnd(frontEndStatistics, ParseAndEvaluateLogger));

                var evaluationScheduler = new EvaluationScheduler(degreeOfParallelism: 1);

                return(new FrontEndHostController(
                           frontEndFactory,
                           workspaceFactory,
                           evaluationScheduler,
                           moduleRegistry,
                           new FrontEndStatistics(),
                           logger: InitializationLogger,
                           collector: null,
                           collectMemoryAsSoonAsPossible: false));
            }

            BuildXLEngine.PopulateLoggingAndLayoutConfiguration(Configuration, Context.PathTable, bxlExeLocation: null, inTestMode: true);
            var successfulValdiation = BuildXLEngine.PopulateAndValidateConfiguration(Configuration, Configuration, Context.PathTable, LoggingContext);

            Assert.True(successfulValdiation);

            var engine = BuildXLEngine.Create(LoggingContext, Context, Configuration, new LambdaBasedFrontEndControllerFactory(Create), rememberAllChangedTrackedInputs: rememberAllChangedTrackedInputs);

            engine.TestHooks = TestHooks;

            return(engine);
        }
Exemplo n.º 5
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));
        }