Exemple #1
0
        /// <nodoc/>
        public DirectoryMembershipFingerprinterRuleSet(
            IEnumerable <DirectoryMembershipFingerprinterRule> rules,
            DirectoryMembershipFingerprinterRuleSet parent = null)
        {
            m_rules  = new Dictionary <AbsolutePath, DirectoryMembershipFingerprinterRule>();
            m_parent = parent;

            if (rules != null)
            {
                foreach (var rule in rules)
                {
                    DirectoryMembershipFingerprinterRule existingException;
                    if (m_rules.TryGetValue(rule.Root, out existingException))
                    {
                        Contract.Assert(
                            false,
                            "Encountered duplicate DirectoryMembershipFingerprinterRule. Duplicates are supposed to be detected when the user provided configuration is validated.");
                    }
                    else
                    {
                        m_rules.Add(rule.Root, rule);
                    }
                }
            }
            else
            {
                m_rules = new Dictionary <AbsolutePath, DirectoryMembershipFingerprinterRule>();
            }
        }
Exemple #2
0
 /// <nodoc/>
 private DirectoryMembershipFingerprinterRuleSet(
     IModuleConfiguration moduleConfiguration,
     StringTable stringTable,
     DirectoryMembershipFingerprinterRuleSet parent = null)
     : this(CreateFromConfig(moduleConfiguration, stringTable), parent)
 {
 }
Exemple #3
0
 /// <nodoc/>
 private DirectoryMembershipFingerprinterRuleSet(
     IEnumerable <DirectoryMembershipFingerprinterRule> rules,
     Dictionary <ModuleId, DirectoryMembershipFingerprinterRuleSet> moduleRuleSets,
     List <string> searchPathEnumerationTools,
     DirectoryMembershipFingerprinterRuleSet parent = null)
     : this(rules, parent)
 {
     m_moduleRuleSets = moduleRuleSets;
     m_searchPathEnumerationToolFragments = searchPathEnumerationTools;
 }
Exemple #4
0
        private static DirectoryMembershipFingerprinterRuleSet Deserialize(BuildXLReader reader, DirectoryMembershipFingerprinterRuleSet parent)
        {
            int ruleCount = reader.ReadInt32Compact();
            List <DirectoryMembershipFingerprinterRule> rules = new List <DirectoryMembershipFingerprinterRule>(ruleCount);

            for (int i = 0; i < ruleCount; i++)
            {
                rules.Add(DirectoryMembershipFingerprinterRule.Deserialize(reader));
            }

            List <string> searchPathEnumerationTools = null;

            if (reader.ReadBoolean())
            {
                var count = reader.ReadInt32Compact();
                searchPathEnumerationTools = new List <string>();
                for (int i = 0; i < count; i++)
                {
                    var tool = reader.ReadString();
                    searchPathEnumerationTools.Add(tool);
                }
            }

            DirectoryMembershipFingerprinterRuleSet result;
            Dictionary <ModuleId, DirectoryMembershipFingerprinterRuleSet> moduleRuleSets = null;

            if (reader.ReadBoolean())
            {
                moduleRuleSets = new Dictionary <ModuleId, DirectoryMembershipFingerprinterRuleSet>();
                result         = new DirectoryMembershipFingerprinterRuleSet(rules, moduleRuleSets, searchPathEnumerationTools, parent);
                var count = reader.ReadInt32Compact();
                for (int i = 0; i < count; i++)
                {
                    var moduleId      = reader.ReadModuleId();
                    var moduleRuleSet = Deserialize(reader, result);
                    result.m_moduleRuleSets.Add(moduleId, moduleRuleSet);
                }
            }
            else
            {
                result = new DirectoryMembershipFingerprinterRuleSet(rules, moduleRuleSets, searchPathEnumerationTools, parent);
            }

            return(result);
        }
Exemple #5
0
        /// <summary>
        /// Class constructor
        /// </summary>
        public PipExecutionState(
            IConfiguration configuration,
            LoggingContext loggingContext,
            PipTwoPhaseCache cache,
            FileAccessWhitelist fileAccessWhitelist,
            IDirectoryMembershipFingerprinter directoryMembershipFingerprinter,
            SemanticPathExpander pathExpander,
            IExecutionLogTarget executionLog,
            DirectoryMembershipFingerprinterRuleSet directoryMembershipFinterprinterRuleSet,
            FileContentManager fileContentManager,
            IUnsafeSandboxConfiguration unsafeConfiguration,
            PreserveOutputsInfo preserveOutputsSalt,
            FileSystemView fileSystemView,
            bool lazyDeletionOfSharedOpaqueOutputsEnabled,
            ServiceManager serviceManager = null)
        {
            Contract.Requires(fileContentManager != null);
            Contract.Requires(directoryMembershipFingerprinter != null);
            Contract.Requires(pathExpander != null);

            Cache = cache;
            m_fileAccessWhitelist            = fileAccessWhitelist;
            DirectoryMembershipFingerprinter = directoryMembershipFingerprinter;
            ResourceManager           = new ProcessResourceManager(loggingContext);
            m_pathExpander            = new FileContentManagerSemanticPathExpander(fileContentManager, pathExpander);
            ExecutionLog              = executionLog;
            m_rootModuleConfiguration = configuration;
            m_directoryMembershipFingerprinterRuleSet = directoryMembershipFinterprinterRuleSet;
            PathExistenceCache    = new ConcurrentBigMap <AbsolutePath, PathExistence>();
            FileContentManager    = fileContentManager;
            ServiceManager        = serviceManager ?? ServiceManager.Default;
            PipEnvironment        = new PipEnvironment(loggingContext);
            FileSystemView        = fileSystemView;
            m_unsafeConfiguration = unsafeConfiguration;
            m_preserveOutputsSalt = preserveOutputsSalt;
            LazyDeletionOfSharedOpaqueOutputsEnabled = lazyDeletionOfSharedOpaqueOutputsEnabled;

            if (fileSystemView != null)
            {
                fileContentManager.SetLocalDiskFileSystemExistenceView(fileSystemView);
            }
        }
Exemple #6
0
        /// <nodoc/>
        public void Serialize(BuildXLWriter writer)
        {
            writer.WriteCompact(m_rules.Count);
            foreach (var rule in m_rules)
            {
                rule.Value.Serialize(writer);
            }

            if (m_searchPathEnumerationToolFragments != null)
            {
                writer.Write(true);
                writer.WriteCompact(m_searchPathEnumerationToolFragments.Count);
                foreach (var tool in m_searchPathEnumerationToolFragments)
                {
                    writer.Write(tool);
                }
            }
            else
            {
                writer.Write(false);
            }

            if (m_moduleRuleSets != null)
            {
                writer.Write(true);
                writer.WriteCompact(m_moduleRuleSets.Count);
                foreach (var moduleRuleSetEntry in m_moduleRuleSets)
                {
                    ModuleId moduleId = moduleRuleSetEntry.Key;
                    DirectoryMembershipFingerprinterRuleSet moduleRuleSet = moduleRuleSetEntry.Value;
                    writer.Write(moduleId);
                    moduleRuleSet.Serialize(writer);
                }
            }
            else
            {
                writer.Write(false);
            }
        }
Exemple #7
0
 /// <summary>
 /// For testing
 /// </summary>
 internal void AddModuleRuleSet(ModuleId moduleId, DirectoryMembershipFingerprinterRuleSet ruleSet)
 {
     m_moduleRuleSets.Add(moduleId, ruleSet);
 }