Example #1
0
 private XElement GetModulePipDetails(ModulePip pip)
 {
     return(m_html.CreateBlock(
                "ModulePip Details",
                m_html.CreateRow("Identity", pip.Identity),
                m_html.CreateRow("Definition File", pip.Location.Path),
                m_html.CreateRow("Definition ", pip.Location)));
 }
Example #2
0
 private static ModuleSpecificDetails CreateModuleSpecificDetails(ModulePip pip, PathTable pathTable, StringTable stringTable)
 {
     return(new ModuleSpecificDetails
     {
         Identity = CreateString(pip.Identity, stringTable),
         DestinationFile = CreateString(pip.Location.Path, pathTable),
         Definition = CreateString(pip.Location),
     });
 }
        public void TestModulePipDump()
        {
            AbsolutePath specPath = CreateUniqueSourcePath();
            ModulePip    module   = ModulePip.CreateForTesting(Context.StringTable, specPath);

            PipGraphBuilder.AddModule(module);

            RunAndAssertDumpPip(module);
        }
Example #4
0
        /// <summary>
        /// Generates the ModulePipDetails for a given Pip
        /// </summary>
        public ModulePipDetails GenerateModulePipDetails(ModulePip pip)
        {
            ModulePipDetails modulePipDetails = new ModulePipDetails
            {
                Identity           = pip.Identity.ToString(StringTable),
                DefinitionFilePath = pip.Location.Path.ToString(PathTable),
                DefinitionPath     = pip.Location.ToString(PathTable)
            };

            return(modulePipDetails);
        }
Example #5
0
        public bool ShouldLoadModule(ModulePip module, CachedGraph cachedGraph)
        {
            foreach (IModuleFilter moduleFilter in m_moduleFilters)
            {
                if (!moduleFilter.ShouldLoadModule(module, cachedGraph))
                {
                    return(false);
                }
            }

            return(true);
        }
Example #6
0
        /// <summary>
        /// Creates an instance of <see cref="TestPipGraphFragment"/>.
        /// </summary>
        public TestPipGraphFragment(LoggingContext loggingContext, string sourceRoot, string objectRoot, string redirectedRoot, string moduleName, bool useTopSort = false)
        {
            Contract.Requires(loggingContext != null);
            Contract.Requires(!string.IsNullOrEmpty(sourceRoot));
            Contract.Requires(!string.IsNullOrEmpty(objectRoot));
            Contract.Requires(!string.IsNullOrEmpty(moduleName));

            Context          = BuildXLContext.CreateInstanceForTesting();
            m_loggingContext = loggingContext;
            m_sourceRoot     = AbsolutePath.Create(Context.PathTable, sourceRoot);
            m_objectRoot     = AbsolutePath.Create(Context.PathTable, objectRoot);
            m_expander       = new MountPathExpander(Context.PathTable);

            var configuration = new ConfigurationImpl()
            {
                Schedule =
                {
                    UseFixedApiServerMoniker     = true,
                    ComputePipStaticFingerprints = true,
                }
            };

            m_useTopSort = useTopSort;
            PipGraph     = m_useTopSort
                ? new PipGraphFragmentBuilderTopSort(Context, configuration, m_expander)
                : new PipGraphFragmentBuilder(Context, configuration, m_expander);

            ModuleName = moduleName;
            var specFileName = moduleName + ".dsc";

            m_specPath = m_sourceRoot.Combine(Context.PathTable, specFileName);
            m_moduleId = ModuleId.Create(StringId.Create(Context.StringTable, moduleName));
            var modulePip = ModulePip.CreateForTesting(
                Context.StringTable,
                m_specPath,
                m_moduleId);

            PipGraph.AddModule(modulePip);
            PipGraph.AddSpecFile(new SpecFilePip(new FileArtifact(m_specPath), new LocationData(m_specPath, 0, 0), modulePip.Module));

            m_defaultConstructionHelper = PipConstructionHelper.CreateForTesting(
                Context,
                objectRoot: m_objectRoot,
                redirectedRoot: AbsolutePath.Create(Context.PathTable, redirectedRoot),
                pipGraph: PipGraph,
                moduleName: moduleName,
                specRelativePath: Path.Combine(m_sourceRoot.GetName(Context.PathTable).ToString(Context.StringTable), specFileName),
                specPath: m_specPath,
                symbol: moduleName + "_defaultValue");
        }
Example #7
0
        private bool ModuleStartsWith(ModulePip module, CachedGraph cachedGraph)
        {
            bool   filterPrefixMatch = false;
            string moduleName        = module.Identity.ToString(cachedGraph.Context.StringTable);

            // Loop trough the filter strings. All these filters are module name prefixes.
            foreach (var filter in m_moduleFilters)
            {
                // Check if the module name matches the prefix
                if (moduleName.StartsWith(filter, StringComparison.OrdinalIgnoreCase))
                {
                    // We have a match
                    filterPrefixMatch = true;
                    break;
                }
            }

            // We should load the module when we have a match and the filter IS NOT an exclude filter, or
            // we do not have a match and the filter IS an exclude filter.
            return(filterPrefixMatch != m_moduleExcludeFilter);
        }
Example #8
0
 /// <nodoc/>
 public ModuleReference(ModulePip module, StringTable stringTable)
 {
     Id   = (int)module.PipId.Value;
     Name = module.Identity.ToString(stringTable);
 }
Example #9
0
 /// <inheritdoc />
 public bool AddModule(ModulePip module)
 {
     Contract.Requires(module != null, "Argument module cannot be null");
     return(m_builder.AddModule(module));
 }
Example #10
0
        public TestEnv(
            string name,
            string rootPath,
            bool enableLazyOutputMaterialization = false,
            int maxRelativeOutputDirectoryLength = 260,
            List <IMount> mounts = null,
            PathTable pathTable  = null)
        {
            Contract.Requires(name != null);
            Contract.Requires(!string.IsNullOrEmpty(rootPath));

            LoggingContext = new LoggingContext("TestLogger." + name);
            PathTable      = pathTable ?? new PathTable();

            PipDataBuilderPool = new ObjectPool <PipDataBuilder>(() => new PipDataBuilder(PathTable.StringTable), _ => { });

            // The tests that use TestEnv need to be modernized to take a filesystem
            var fileSystem = new PassThroughFileSystem(PathTable);

            Context = EngineContext.CreateNew(CancellationToken.None, PathTable, fileSystem);

            // Add some well-known paths with fixed casing to the Context.PathTable
            AbsolutePath.Create(Context.PathTable, rootPath.ToLowerInvariant());
            var root = AbsolutePath.Create(Context.PathTable, rootPath);

            var configuration = ConfigHelpers.CreateDefaultForXml(Context.PathTable, root);

            configuration.Layout.SourceDirectory = root.Combine(PathTable, PathAtom.Create(PathTable.StringTable, "src")); // These tests have non-standard src folder
            configuration.Engine.MaxRelativeOutputDirectoryLength   = maxRelativeOutputDirectoryLength;
            configuration.Schedule.EnableLazyOutputMaterialization  = enableLazyOutputMaterialization;
            configuration.Schedule.UnsafeDisableGraphPostValidation = false;
            configuration.Schedule.ComputePipStaticFingerprints     = true;
            configuration.Sandbox.FileAccessIgnoreCodeCoverage      = true;

            BuildXLEngine.PopulateFileSystemCapabilities(configuration, configuration, Context.PathTable, LoggingContext);
            BuildXLEngine.PopulateLoggingAndLayoutConfiguration(configuration, Context.PathTable, bxlExeLocation: null, inTestMode: true);
            BuildXLEngine.PopulateAndValidateConfiguration(configuration, configuration, Context.PathTable, LoggingContext);

            Configuration = configuration;

            var mountsTable = MountsTable.CreateAndRegister(LoggingContext, Context, Configuration, null);

            if (mounts != null)
            {
                foreach (var mount in mounts)
                {
                    mountsTable.AddResolvedMount(mount);
                }
            }

            AbsolutePath specFile = SourceRoot.CreateRelative(Context.PathTable, "TestSpecFile.dsc");

            var graph = TestSchedulerFactory.CreateEmptyPipGraph(Context, configuration, mountsTable.MountPathExpander);

            PipTable = graph.PipTable;
            PipGraph = graph;

            var locationData = new LocationData(specFile, 0, 0);
            var modulePip    = ModulePip.CreateForTesting(Context.StringTable, specFile);

            PipGraph.AddModule(modulePip);
            PipGraph.AddSpecFile(new SpecFilePip(FileArtifact.CreateSourceFile(specFile), locationData, modulePip.Module));

            PipConstructionHelper = PipConstructionHelper.CreateForTesting(
                Context,
                ObjectRoot,
                redirectedRoot: Configuration.Layout.RedirectedDirectory,
                pipGraph: PipGraph,
                moduleName: modulePip.Identity.ToString(Context.StringTable),
                symbol: name,
                specPath: specFile);

            Paths = new Paths(PathTable);

            mountsTable.CompleteInitialization();
        }
Example #11
0
 /// <inheritdoc />
 public bool AddModule([NotNull] ModulePip module)
 {
     AddPip(module);
     return(true);
 }
Example #12
0
 /// <inheritdoc />
 public bool AddModule([NotNull] ModulePip module)
 {
     return(AddPip(module));
 }
Example #13
0
 /// <nodoc/>
 public Module(ModulePip module, PathTable pathTable)
     : base(module, pathTable.StringTable)
 {
     Location = Location.FromToken(pathTable, module.Location);
 }
Example #14
0
 public bool ShouldLoadModule(ModulePip module, CachedGraph cachedGraph)
 {
     return(m_moduleFilterFunction.Invoke(module, cachedGraph));
 }
Example #15
0
        private bool ModuleNameFilterMatches(ModulePip module, CachedGraph cachedGraph)
        {
            string moduleName = module.Identity.ToString(cachedGraph.Context.StringTable);

            return(m_moduleNameFilter.IsMatch(moduleName));
        }
Example #16
0
 private static void SetModulePipDetails(ModulePip pip, PipDetails result, PathTable pathTable)
 {
 }