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, parameters.ForceRebuild);
            var lbv = lb?.Versions?.SingleOrDefault(v => v.VersionName == parameters.VersionName);
            var cbv = new BuildVersionInfo()
            {
                BaseDir             = Path.GetFullPath(Environment.ExpandEnvironmentVariables(baseDir)),
                VersionName         = parameters.VersionName,
                ConfigHash          = ComputeConfigHash(parameters, markdownServiceContextHash),
                FileMetadataHash    = ComputeFileMetadataHash(parameters.FileMetadata),
                FileMetadata        = parameters.FileMetadata,
                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),
            };

            if (parameters.FileMetadata != null)
            {
                cbv.FileMetadataFile = IncrementalUtility.CreateRandomFileName(baseDir);
            }
            cb.Versions.Add(cbv);
            var context = new IncrementalBuildContext(baseDir, lastBaseDir, lastBuildStartTime, buildInfoIncrementalStatus, parameters, cbv, lbv)
            {
                IsTemplateUpdated = cb.TemplateHash != lb?.TemplateHash
            };

            if (context.IsTemplateUpdated)
            {
                Logger.LogVerbose($"Cannot build incrementally in link phase because template changed (new: {cb.TemplateHash} vs. old: {lb?.TemplateHash ?? "null"}). Will apply templates and post process all files", code: InfoCodes.IncrementalBuildReason.TemplateChanged);
            }
            context.InitDependency();
            context.InitFileAttributes();
            context.InitChanges();
            return(context);
        }
예제 #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()
            {
                BaseDir             = Path.GetFullPath(Environment.ExpandEnvironmentVariables(baseDir)),
                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)
            {
                IsTemplateUpdated = (cb.TemplateHash != lb?.TemplateHash)
            };

            context.InitDependency();
            context.InitFileAttributes();
            context.InitChanges();
            return(context);
        }
예제 #3
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 canBuildInfoIncremental = CanBuildInfoIncremental(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),
                Attributes       = ComputeFileAttributes(parameters, lbv?.Dependency),
                Dependency       = ConstructDependencyGraphFromLast(lbv?.Dependency),
            };

            cb.Versions.Add(cbv);
            var context = new IncrementalBuildContext(baseDir, lastBaseDir, lastBuildStartTime, canBuildInfoIncremental, parameters, cbv, lbv);

            context.InitChanges();
            return(context);
        }
예제 #4
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 canBuildInfoIncremental = CanBuildInfoIncremental(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),
         Attributes = ComputeFileAttributes(parameters, lbv?.Dependency),
         Dependency = ConstructDependencyGraphFromLast(lbv?.Dependency),
     };
     cb.Versions.Add(cbv);
     var context = new IncrementalBuildContext(baseDir, lastBaseDir, lastBuildStartTime, canBuildInfoIncremental, parameters, cbv, lbv);
     context.InitChanges();
     return context;
 }