public HostServiceCreatorWithIncremental(DocumentBuildContext context) : base(context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } IncrementalContext = context.IncrementalBuildContext; }
public static IncrementalBuildContext Create(DocumentBuildParameters parameters, BuildInfo cb, BuildInfo lb, string intermediateFolder, string markdownServiceContextHash) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } if (cb == null) { throw new ArgumentNullException(nameof(cb)); } if (intermediateFolder == null) { throw new ArgumentNullException(nameof(intermediateFolder)); } var baseDir = Path.Combine(intermediateFolder, cb.DirectoryName); var lastBaseDir = lb != null?Path.Combine(intermediateFolder, lb.DirectoryName) : null; var lastBuildStartTime = lb?.BuildStartTime; var buildInfoIncrementalStatus = GetBuildInfoIncrementalStatus(cb, lb); var lbv = lb?.Versions?.SingleOrDefault(v => v.VersionName == parameters.VersionName); var cbv = new BuildVersionInfo { VersionName = parameters.VersionName, ConfigHash = ComputeConfigHash(parameters, markdownServiceContextHash), AttributesFile = IncrementalUtility.CreateRandomFileName(baseDir), DependencyFile = IncrementalUtility.CreateRandomFileName(baseDir), ManifestFile = IncrementalUtility.CreateRandomFileName(baseDir), OutputFile = IncrementalUtility.CreateRandomFileName(baseDir), XRefSpecMapFile = IncrementalUtility.CreateRandomFileName(baseDir), FileMapFile = IncrementalUtility.CreateRandomFileName(baseDir), BuildMessageFile = IncrementalUtility.CreateRandomFileName(baseDir), TocRestructionsFile = IncrementalUtility.CreateRandomFileName(baseDir), }; cb.Versions.Add(cbv); var context = new IncrementalBuildContext(baseDir, lastBaseDir, lastBuildStartTime, buildInfoIncrementalStatus, parameters, cbv, lbv); context.InitDependency(); context.InitFileAttributes(); context.InitChanges(); return(context); }
public static IncrementalBuildContext Create(DocumentBuildParameters parameters, BuildInfo cb, BuildInfo lb, string intermediateFolder) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } if (cb == null) { throw new ArgumentNullException(nameof(cb)); } if (intermediateFolder == null) { throw new ArgumentNullException(nameof(intermediateFolder)); } var baseDir = Path.Combine(intermediateFolder, cb.DirectoryName); var lastBaseDir = lb != null?Path.Combine(intermediateFolder, lb.DirectoryName) : null; var lastBuildStartTime = lb?.BuildStartTime; var canBuildInfoIncremental = CanBuildInfoIncremental(cb, lb); var lbv = lb?.Versions?.SingleOrDefault(v => v.VersionName == parameters.VersionName); var cbv = new BuildVersionInfo { VersionName = parameters.VersionName, ConfigHash = ComputeConfigHash(parameters), AttributesFile = IncrementalUtility.CreateRandomFileName(baseDir), DependencyFile = IncrementalUtility.CreateRandomFileName(baseDir), ManifestFile = IncrementalUtility.CreateRandomFileName(baseDir), XRefSpecMapFile = IncrementalUtility.CreateRandomFileName(baseDir), BuildMessageFile = IncrementalUtility.CreateRandomFileName(baseDir), Attributes = ComputeFileAttributes(parameters, lbv?.Dependency), Dependency = new DependencyGraph(), }; cb.Versions.Add(cbv); var context = new IncrementalBuildContext(baseDir, lastBaseDir, lastBuildStartTime, canBuildInfoIncremental, parameters, cbv, lbv); return(context); }
public static IncrementalBuildContext Create(DocumentBuildParameters parameters, BuildInfo cb, BuildInfo lb, string intermediateFolder) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } if (cb == null) { throw new ArgumentNullException(nameof(cb)); } if (intermediateFolder == null) { throw new ArgumentNullException(nameof(intermediateFolder)); } var baseDir = Path.Combine(intermediateFolder, cb.DirectoryName); var lastBaseDir = lb != null ? Path.Combine(intermediateFolder, lb.DirectoryName) : null; var lastBuildStartTime = lb?.BuildStartTime; var canBuildInfoIncremental = CanBuildInfoIncremental(cb, lb); var lbv = lb?.Versions?.SingleOrDefault(v => v.VersionName == parameters.VersionName); var cbv = new BuildVersionInfo { VersionName = parameters.VersionName, ConfigHash = ComputeConfigHash(parameters), AttributesFile = IncrementalUtility.CreateRandomFileName(baseDir), DependencyFile = IncrementalUtility.CreateRandomFileName(baseDir), ManifestFile = IncrementalUtility.CreateRandomFileName(baseDir), XRefSpecMapFile = IncrementalUtility.CreateRandomFileName(baseDir), BuildMessageFile = IncrementalUtility.CreateRandomFileName(baseDir), Attributes = ComputeFileAttributes(parameters, lbv?.Dependency), Dependency = new DependencyGraph(), }; cb.Versions.Add(cbv); var context = new IncrementalBuildContext(baseDir, lastBaseDir, lastBuildStartTime, canBuildInfoIncremental, parameters, cbv, lbv); return context; }
public FileModel LoadIntermediateModel(IncrementalBuildContext incrementalContext, string fileName) { if (!CanIncrementalBuild) { return null; } var processor = (ISupportIncrementalDocumentProcessor)Processor; var cmm = incrementalContext.GetCurrentIntermediateModelManifest(this); string cfn; if (!cmm.Models.TryGetValue(fileName, out cfn)) { throw new BuildCacheException($"Last build hasn't loaded model {fileName}"); } using (var stream = File.OpenRead(Path.Combine(incrementalContext.BaseDir, cfn))) { return processor.LoadIntermediateModel(stream); } }
public void SaveIntermediateModel(IncrementalBuildContext incrementalContext) { if (!ShouldTraceIncrementalInfo) { return; } var processor = (ISupportIncrementalDocumentProcessor)Processor; var mi = incrementalContext.GetModelLoadInfo(this); var lmm = incrementalContext.GetLastIntermediateModelManifest(this); var cmm = incrementalContext.GetCurrentIntermediateModelManifest(this); foreach (var pair in mi) { IncrementalUtility.RetryIO(() => { string fileName = IncrementalUtility.GetRandomEntry(incrementalContext.BaseDir); if (pair.Value == null) { if (lmm == null) { throw new BuildCacheException($"Full build hasn't loaded model {pair.Key}"); } string lfn; if (!lmm.Models.TryGetValue(pair.Key, out lfn)) { throw new BuildCacheException($"Last build hasn't loaded model {pair.Key}"); } File.Move(Path.Combine(incrementalContext.LastBaseDir, lfn), Path.Combine(incrementalContext.BaseDir, fileName)); } else { var key = TypeForwardedToRelativePath.NormalizedWorkingFolder + pair.Key; var model = Models.Find(m => m.Key == key); using (var stream = File.Create(Path.Combine(incrementalContext.BaseDir, fileName))) { processor.SaveIntermediateModel(model, stream); } } cmm.Models.Add(pair.Key, fileName); }); } }
private void ReloadUnloadedModelsPerCondition(IncrementalBuildContext incrementalContext, BuildPhase phase, Func<string, bool> condition) { if (!CanIncrementalBuild) { return; } var mi = incrementalContext.GetModelLoadInfo(this); var toLoadList = (from f in mi.Keys where condition(f) select LoadIntermediateModel(incrementalContext, f) into m where m != null select m).ToList(); if (toLoadList.Count > 0) { Reload(Models.Concat(toLoadList)); incrementalContext.ReportModelLoadInfo(this, toLoadList.Select(t => t.FileAndType.File), phase); } }
public void ReloadUnloadedModels(IncrementalBuildContext incrementalContext, BuildPhase loadedAt) { var mi = incrementalContext.GetModelLoadInfo(this); ReloadUnloadedModelsPerCondition(incrementalContext, loadedAt, f => mi[f] == null); }
public void ReloadModelsPerIncrementalChanges(IncrementalBuildContext incrementalContext, IEnumerable<string> changes, BuildPhase loadedAt) { if (changes == null) { return; } ReloadUnloadedModelsPerCondition( incrementalContext, loadedAt, f => { var key = ((TypeForwardedToRelativePath)f).GetPathFromWorkingFolder().ToString(); return changes.Contains(key); }); }
public List<string> GetUnloadedModelFiles(IncrementalBuildContext incrementalContext) { if (!CanIncrementalBuild) { return new List<string>(); } return (from pair in incrementalContext.GetModelLoadInfo(this) where pair.Value == null select pair.Key).ToList(); }
private static void UpdateHostServices(IncrementalBuildContext incrementalContext, IEnumerable<HostService> hostServices) { foreach (var hostService in hostServices) { if (hostService.CanIncrementalBuild) { hostService.ReloadUnloadedModels(incrementalContext, BuildPhase.PostBuild); } } }