private ContentFingerprint CreateFingerprintForCompositeSharedOpaque( string composedSharedOpaqueRoot, string[] sharedOpaqueMembers, SealDirectoryContentFilter?contentFilter) { using (TestEnv env = TestEnv.CreateTestEnvWithPausedScheduler()) { var sharedOpaqueDirectoryArtifactMembers = new DirectoryArtifact[sharedOpaqueMembers.Length]; for (int i = 0; i < sharedOpaqueMembers.Length; i++) { sharedOpaqueDirectoryArtifactMembers[i] = CreateSharedOpaque(env, env.Paths.CreateAbsolutePath(sharedOpaqueMembers[i])); } var success = env.PipConstructionHelper.TryComposeSharedOpaqueDirectory( env.Paths.CreateAbsolutePath(composedSharedOpaqueRoot), sharedOpaqueDirectoryArtifactMembers, actionKind: SealDirectoryCompositionActionKind.WidenDirectoryCone, contentFilter: contentFilter, description: null, tags: new string[0], out var sharedOpaqueDirectory); XAssert.IsTrue(success); var graph = AssertSuccessGraphBuilding(env); var fingerprint = CreateFingerprintForSharedOpaque(sharedOpaqueDirectory, graph); return(fingerprint); } }
/// <nodoc/> public CompositeSharedOpaqueSealDirectory( AbsolutePath directoryRoot, IReadOnlyList <DirectoryArtifact> composedDirectories, PipProvenance provenance, ReadOnlyArray <StringId> tags, SealDirectoryContentFilter?contentFilter, SealDirectoryCompositionActionKind compositionAction) : base( directoryRoot, CollectionUtilities.EmptySortedReadOnlyArray <FileArtifact, OrdinalFileArtifactComparer>(OrdinalFileArtifactComparer.Instance), CollectionUtilities.EmptySortedReadOnlyArray <DirectoryArtifact, OrdinalDirectoryArtifactComparer>(OrdinalDirectoryArtifactComparer.Instance), SealDirectoryKind.SharedOpaque, provenance, tags, CollectionUtilities.EmptyArray <StringId>().ToReadOnlyArray()) { Contract.Requires(composedDirectories != null); Contract.Requires(compositionAction != SealDirectoryCompositionActionKind.None); Contract.Assert(compositionAction != SealDirectoryCompositionActionKind.NarrowDirectoryCone || (composedDirectories.Count == 1), "When action is NarrowDirectoryCone, exactly one directory must be provided."); ComposedDirectories = composedDirectories; CompositionActionKind = compositionAction; m_contentFilter = contentFilter; }
public SealDirectoryMutablePipState(PipType piptype, long semiStableHash, PageableStoreId storeId, SealDirectoryKind sealDirectoryKind, ReadOnlyArray <StringId> patterns, bool isComposite, bool scrub, SealDirectoryContentFilter?contentFilter) : base(piptype, semiStableHash, storeId) { SealDirectoryKind = sealDirectoryKind; Patterns = patterns; IsComposite = isComposite; Scrub = scrub; ContentFilter = contentFilter; }
internal static MutablePipState Deserialize(BuildXLReader reader, PipType pipType, long semiStableHash, PageableStoreId storeId) { var sealDirectoryKind = (SealDirectoryKind)reader.ReadByte(); var patterns = reader.ReadReadOnlyArray(reader1 => reader1.ReadStringId()); var isComposite = reader.ReadBoolean(); var scrub = reader.ReadBoolean(); SealDirectoryContentFilter?contentFilter = null; if (reader.ReadBoolean()) { contentFilter = new SealDirectoryContentFilter((SealDirectoryContentFilter.ContentFilterKind)reader.ReadByte(), reader.ReadString()); } return(new SealDirectoryMutablePipState(pipType, semiStableHash, storeId, sealDirectoryKind, patterns, isComposite, scrub, contentFilter)); }
private EvaluationResult GetSharedOpaqueSubDirectory(Context context, ModuleLiteral env, EvaluationStackFrame args) { var directory = Converter.ExpectSharedOpaqueDirectory(args[0]).Root; AbsolutePath subDirectoryPath = Args.AsPath(args, 1, false); var optionalFilterObj = Args.AsObjectLiteralOptional(args, 2); SealDirectoryContentFilter?contentFilter = GetContentFilterHelper(optionalFilterObj); if (!context.GetPipConstructionHelper().TryComposeSharedOpaqueDirectory(subDirectoryPath, new[] { directory }, SealDirectoryCompositionActionKind.NarrowDirectoryCone, contentFilter, description: null, tags: null, out var compositeSharedOpaque)) { // Error should have been logged return(EvaluationResult.Error); } var result = new StaticDirectory(root: compositeSharedOpaque, kind: SealDirectoryKind.SharedOpaque, s_emptySealContents.WithCompatibleComparer(OrdinalPathOnlyFileArtifactComparer.Instance)); return(new EvaluationResult(result)); }
/// <nodoc/> public bool TryComposeSharedOpaqueDirectory( AbsolutePath directoryRoot, IReadOnlyList <DirectoryArtifact> contents, SealDirectoryContentFilter?contentFilter, [CanBeNull] string description, [CanBeNull] string[] tags, out DirectoryArtifact sharedOpaqueDirectory) { Contract.Requires(directoryRoot.IsValid); Contract.Requires(contents != null); if (PipGraph == null) { sharedOpaqueDirectory = DirectoryArtifact.CreateWithZeroPartialSealId(directoryRoot); return(true); } PipData usage = PipDataBuilder.CreatePipData(Context.StringTable, string.Empty, PipDataFragmentEscaping.NoEscaping, description != null ? new PipDataAtom[] { description } : new PipDataAtom[] { "'", directoryRoot, "' [", contents.Count.ToString(CultureInfo.InvariantCulture), " shared opaque directories, filter: ", contentFilter.HasValue ? $"'{contentFilter.Value.Regex}' (kind: {Enum.GetName(typeof(SealDirectoryContentFilter.ContentFilterKind), contentFilter.Value.Kind)})" : "''", "]" }); sharedOpaqueDirectory = PipGraph.ReserveSharedOpaqueDirectory(directoryRoot); var pip = new CompositeSharedOpaqueSealDirectory( directoryRoot, contents, CreatePipProvenance(usage), ToStringIds(tags), contentFilter); // The seal directory is ready to be initialized, since the directory artifact has been reserved already pip.SetDirectoryArtifact(sharedOpaqueDirectory); sharedOpaqueDirectory = PipGraph.AddSealDirectory(pip, GetValuePipId()); if (!sharedOpaqueDirectory.IsValid) { return(false); } return(true); }
/// <nodoc/> public CompositeSharedOpaqueSealDirectory( AbsolutePath directoryRoot, IReadOnlyList <DirectoryArtifact> composedDirectories, PipProvenance provenance, ReadOnlyArray <StringId> tags, SealDirectoryContentFilter?contentFilter) : base( directoryRoot, CollectionUtilities.EmptySortedReadOnlyArray <FileArtifact, OrdinalFileArtifactComparer>(OrdinalFileArtifactComparer.Instance), CollectionUtilities.EmptySortedReadOnlyArray <DirectoryArtifact, OrdinalDirectoryArtifactComparer>(OrdinalDirectoryArtifactComparer.Instance), SealDirectoryKind.SharedOpaque, provenance, tags, CollectionUtilities.EmptyArray <StringId>().ToReadOnlyArray()) { Contract.Requires(composedDirectories != null); ComposedDirectories = composedDirectories; m_contentFilter = contentFilter; }
private static string CreateString(SealDirectoryContentFilter?value) { return(value.HasValue ? $"{value.Value.Regex} (kind: {Enum.Format(typeof(SealDirectoryContentFilter.ContentFilterKind), value.Value.Kind, "f")})" : null); }