public HostServiceCreatorWithIncremental(DocumentBuildContext context) : base(context)
 {
     if (context == null)
     {
         throw new ArgumentNullException(nameof(context));
     }
     IncrementalContext = context.IncrementalBuildContext;
 }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
 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;
 }
예제 #5
0
파일: HostService.cs 프로젝트: dotnet/docfx
 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);
     }
 }
예제 #6
0
파일: HostService.cs 프로젝트: dotnet/docfx
        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);
                });
            }
        }
예제 #7
0
파일: HostService.cs 프로젝트: dotnet/docfx
 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);
     }
 }
예제 #8
0
파일: HostService.cs 프로젝트: dotnet/docfx
 public void ReloadUnloadedModels(IncrementalBuildContext incrementalContext, BuildPhase loadedAt)
 {
     var mi = incrementalContext.GetModelLoadInfo(this);
     ReloadUnloadedModelsPerCondition(incrementalContext, loadedAt, f => mi[f] == null);
 }
예제 #9
0
파일: HostService.cs 프로젝트: dotnet/docfx
 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);
         });
 }
예제 #10
0
 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();
 }
예제 #11
0
 private static void UpdateHostServices(IncrementalBuildContext incrementalContext, IEnumerable<HostService> hostServices)
 {
     foreach (var hostService in hostServices)
     {
         if (hostService.CanIncrementalBuild)
         {
             hostService.ReloadUnloadedModels(incrementalContext, BuildPhase.PostBuild);
         }
     }
 }