Esempio n. 1
0
        /// <nodoc />
        public Args(string[] args, PathTable pathTable)
            : base(args)
        {
            Contract.Requires(pathTable != null);

            m_pathTable       = pathTable;
            CommandLineConfig = new CommandLineConfiguration();
            PipGraphFragmentGeneratorConfig = new PipGraphFragmentGeneratorConfiguration();

            NamedOption[] namedOptions = new[]
Esempio n. 2
0
        private static bool SerializeFragmentIfRequested(
            PipGraphFragmentGeneratorConfiguration pipGraphFragmentGeneratorConfig,
            FrontEndContext context,
            IPipScheduleTraversal pipGraph)
        {
            Contract.Requires(context != null);
            Contract.Requires(pipGraph != null);

            if (!pipGraphFragmentGeneratorConfig.OutputFile.IsValid)
            {
                return(true);
            }

            try
            {
                var serializer = new PipGraphFragmentSerializer(context, new PipGraphFragmentContext())
                {
                    AlternateSymbolSeparator = pipGraphFragmentGeneratorConfig.AlternateSymbolSeparator
                };

                serializer.Serialize(
                    pipGraphFragmentGeneratorConfig.OutputFile,
                    pipGraph,
                    pipGraphFragmentGeneratorConfig.Description,
                    pipGraphFragmentGeneratorConfig.TopSort);

                Logger.Log.GraphFragmentSerializationStats(context.LoggingContext, serializer.FragmentDescription, serializer.Stats.ToString());

                return(true);
            }
            catch (Exception e)
            {
                Logger.Log.GraphFragmentExceptionOnSerializingFragment(
                    context.LoggingContext,
                    pipGraphFragmentGeneratorConfig.OutputFile.ToString(context.PathTable),
                    e.ToString());

                return(false);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Generates pip graph fragment.
        /// </summary>
        public static bool TryGeneratePipGraphFragment(
            PathTable pathTable,
            ICommandLineConfiguration commandLineConfig,
            PipGraphFragmentGeneratorConfiguration pipGraphFragmentConfig)
        {
            var loggingContext = new LoggingContext(nameof(PipGraphFragmentGenerator));
            var fileSystem     = new PassThroughFileSystem(pathTable);
            var engineContext  = EngineContext.CreateNew(CancellationToken.None, pathTable, fileSystem);

            FrontEndContext context = engineContext.ToFrontEndContext(loggingContext);

            // Parse filter string.

            var evaluationFilter = EvaluationFilter.Empty;

            if (!string.IsNullOrWhiteSpace(commandLineConfig.Filter))
            {
                if (!TryGetEvaluationFilter(loggingContext, engineContext, commandLineConfig.Filter, out evaluationFilter))
                {
                    // Error should have been been reported already.
                    return(false);
                }
            }

            if (!TryBuildPipGraphFragment(
                    commandLineConfig,
                    pipGraphFragmentConfig,
                    context,
                    engineContext,
                    evaluationFilter))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 4
0
        private static bool TryBuildPipGraphFragment(
            ICommandLineConfiguration commandLineConfig,
            PipGraphFragmentGeneratorConfiguration pipGraphFragmentGeneratorConfig,
            FrontEndContext frontEndContext,
            EngineContext engineContext,
            EvaluationFilter evaluationFilter)
        {
            Contract.Requires(frontEndContext != null);
            Contract.Requires(engineContext != null);
            Contract.Requires(commandLineConfig.Startup.ConfigFile.IsValid);
            Contract.Requires(evaluationFilter != null);

            var pathTable      = engineContext.PathTable;
            var loggingContext = frontEndContext.LoggingContext;

            var mutableCommandlineConfig = CompleteCommandLineConfiguration(commandLineConfig);

            BuildXLEngine.ModifyConfigurationForCloudbuild(mutableCommandlineConfig, false, pathTable, loggingContext);
            BuildXLEngine.PopulateLoggingAndLayoutConfiguration(mutableCommandlineConfig, pathTable, bxlExeLocation: null);

            var statistics = new FrontEndStatistics();
            var frontEndControllerFactory = FrontEndControllerFactory.Create(
                mode: FrontEndMode.NormalMode,
                loggingContext: loggingContext,
                configuration: mutableCommandlineConfig,
                collector: null,
                statistics: statistics);

            var controller = frontEndControllerFactory.Create(engineContext.PathTable, engineContext.SymbolTable);

            controller.InitializeHost(frontEndContext, mutableCommandlineConfig);

            FrontEndHostController frontEndHostController = (FrontEndHostController)controller;

            var config = controller.ParseConfig(mutableCommandlineConfig);

            if (config == null)
            {
                return(false);
            }

            using (var cache = Task.FromResult <Possible <EngineCache> >(
                       new EngineCache(
                           new InMemoryArtifactContentCache(),
                           new EmptyTwoPhaseFingerprintStore())))
            {
                var mountsTable = MountsTable.CreateAndRegister(loggingContext, engineContext, config, mutableCommandlineConfig.Startup.Properties);
                FrontEndEngineAbstraction frontEndEngineAbstraction = new FrontEndEngineImplementation(
                    loggingContext,
                    frontEndContext.PathTable,
                    config,
                    mutableCommandlineConfig.Startup,
                    mountsTable,
                    InputTracker.CreateDisabledTracker(loggingContext),
                    null,
                    null,
                    () => FileContentTable.CreateStub(loggingContext),
                    5000,
                    false,
                    controller.RegisteredFrontEnds);

                var pipGraphBuilder = pipGraphFragmentGeneratorConfig.TopSort
                    ? new PipGraphFragmentBuilderTopSort(engineContext, config, mountsTable.MountPathExpander)
                    : new PipGraphFragmentBuilder(engineContext, config, mountsTable.MountPathExpander);

                if (!AddConfigurationMountsAndCompleteInitialization(config, loggingContext, mountsTable))
                {
                    return(false);
                }

                if (!mountsTable.PopulateModuleMounts(config.ModulePolicies.Values, out var moduleMountsTableMap))
                {
                    Contract.Assume(loggingContext.ErrorWasLogged, "An error should have been logged after MountTable.PopulateModuleMounts()");
                    return(false);
                }

                using (frontEndEngineAbstraction is IDisposable ? (IDisposable)frontEndEngineAbstraction : null)
                {
                    if (!controller.PopulateGraph(
                            cache: cache,
                            graph: pipGraphBuilder,
                            engineAbstraction: frontEndEngineAbstraction,
                            evaluationFilter: evaluationFilter,
                            configuration: config,
                            startupConfiguration: mutableCommandlineConfig.Startup))
                    {
                        // Error should have been reported already
                        return(false);
                    }

                    if (!SerializeFragmentIfRequested(pipGraphFragmentGeneratorConfig, frontEndContext, pipGraphBuilder))
                    {
                        // Error should have been reported already
                        return(false);
                    }
                }
            }

            return(true);
        }