コード例 #1
0
 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
ファイル: HostService.cs プロジェクト: vicancy/docfx
 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
ファイル: SingleDocumentBuilder.cs プロジェクト: dotnet/docfx
 private static void UpdateHostServices(IncrementalBuildContext incrementalContext, IEnumerable<HostService> hostServices)
 {
     foreach (var hostService in hostServices)
     {
         if (hostService.CanIncrementalBuild)
         {
             hostService.ReloadUnloadedModels(incrementalContext, BuildPhase.PostBuild);
         }
     }
 }