Example #1
0
        private IEnumerable <TargetRelativePath> GetDependencyResults(IBuildContext context, IBuilder node)
        {
            var referenceBuilder = node as IReferenceBuilder;

            if (referenceBuilder != null)
            {
                foreach (var depSource in context.GetResults(referenceBuilder))
                {
                    foreach (var project in slnBuilder.Projects)
                    {
                        if (project.References.Contains(referenceBuilder.Reference))
                        {
                            // We expect the msbuild compilation to copy these dependencies to the module target directory
                            yield return(new TargetRelativePath(project.RelativeTargetPath, Path.GetFileName(depSource.RelativePath)));
                        }
                    }
                }
            }
            else
            {
                foreach (var result in context.GetDependencies(node).SelectMany(child => GetDependencyResults(context, child)))
                {
                    yield return(result);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Runs this builder
        /// </summary>
        /// <param name="context"> </param>
        /// <returns>Returns a set of generated files, in suite relative paths</returns>
        public override ISet <TargetRelativePath> Run(IBuildContext context)
        {
            var          vcxprojPath   = project.Name + ".vcxproj";
            const string csversionPath = "version.cpp";

            var csversion = project.GetVersionSupport() ? project.RootDirectory.CreateTextFile(csversionPath) : null;

            using (var fsproj = project.RootDirectory.GetChildDirectory("cpp").CreateTextFile(vcxprojPath))
            {
                var references = new HashSet <TargetRelativePath>();
                foreach (var refBuilder in context.GetDependencies(this).OfType <IReferenceBuilder>().Where(r => r.Reference.Type == ReferenceType.Build))
                {
                    var builderResults = context.GetResults(refBuilder);
                    references.UnionWith(builderResults);
                }

                generator.Generate(project, references, fsproj, csversion, csversionPath);
            }

            if (csversion != null)
            {
                csversion.Close();
                csversion.Dispose();
            }

            return(new HashSet <TargetRelativePath>(
                       new[]
            {
                new TargetRelativePath(String.Empty,
                                       suite.SuiteRoot.GetRelativePathFrom(targetDir,
                                                                           Path.Combine(suite.SuiteRoot.GetRelativePath(project.RootDirectory), "cpp", vcxprojPath))),
            }));
        }
Example #3
0
        /// <summary>
        /// Prepares a builder to be ran in a given build context.
        ///
        /// <para>This is the place where a builder can add additional dependencies.</para>
        /// </summary>
        /// <param name="context">The current build context</param>
        public void AddToContext(IBuildContext context)
        {
            var moduleName  = reference.Uri.Host;
            var projectName = reference.Uri.AbsolutePath.TrimStart('/');

            if (suite.HasModule(moduleName))
            {
                var module = suite.GetModule(moduleName);
                referencedProject = module.GetProjectOrTestProject(projectName);

                if (!context.Contains(this))
                {
                    if (referencedProject != null)
                    {
                        subtasks = new HashSet <IBuilder>();
                        context.AddBuilder(this, SubtaskGenerator(context));
                    }
                    else
                    {
                        throw new InvalidReferenceException(string.Format("Module {0} has no project called {1}",
                                                                          moduleName, projectName));
                    }
                }
                else
                {
                    subtasks = new HashSet <IBuilder>(context.GetDependencies(this));
                }
            }
            else
            {
                throw new InvalidReferenceException(string.Format("Suite has no module called {0}", moduleName));
            }
        }
Example #4
0
        public IEnumerable <IBuilder> GetDependencies(IBuilder builder)
        {
            var resolved  = ResolveBuilder(builder);
            var converted = ConvertBuilder(resolved);

            return(baseContext.GetDependencies(converted ?? resolved));
        }
Example #5
0
        /// <summary>
        /// Runs this builder
        /// </summary>
        /// <param name="context"> </param>
        /// <returns>Returns a set of generated files, in suite relative paths</returns>
        public override ISet <TargetRelativePath> Run(IBuildContext context)
        {
            var          fsprojPath    = project.Name + ".fsproj";
            const string fsversionPath = "version.fs";

            using (var fsproj = project.RootDirectory.GetChildDirectory("fs").CreateTextFile(fsprojPath))
                using (var fsversion = project.RootDirectory.CreateTextFile(fsversionPath))
                {
                    var references = new HashSet <TargetRelativePath>();
                    foreach (var refBuilder in context.GetDependencies(this).OfType <IReferenceBuilder>().Where(r => r.Reference.Type == ReferenceType.Build))
                    {
                        var builderResults = context.GetResults(refBuilder);
                        references.UnionWith(builderResults);
                    }

                    generator.Generate(project, references, fsproj, fsversion, fsversionPath);
                }

            return(new HashSet <TargetRelativePath>(
                       new[]
            {
                new TargetRelativePath(String.Empty,
                                       suite.SuiteRoot.GetRelativePathFrom(targetDir,
                                                                           Path.Combine(suite.SuiteRoot.GetRelativePath(project.RootDirectory), "fs", fsprojPath))),
                new TargetRelativePath(String.Empty,
                                       suite.SuiteRoot.GetRelativePathFrom(targetDir,
                                                                           Path.Combine(suite.SuiteRoot.GetRelativePath(project.RootDirectory), fsversionPath)))
            }));
        }
Example #6
0
        /// <summary>
        /// Prepares a builder to be ran in a given build context.
        ///
        /// <para>This is the place where a builder can add additional dependencies.</para>
        /// </summary>
        /// <param name="context">The current build context</param>
        public void AddToContext(IBuildContext context)
        {
            builders.Clear();

            if (alias != null && !context.Contains(this))
            {
                foreach (var childRef in alias.References)
                {
                    if (childRef.Type == reference.Type)
                    {
                        var builder = referenceBuilderFactory.CreateReferenceBuilder(childRef, project);
                        builder.AddToContext(context);

                        builders.Add(builder);
                    }
                }

                context.AddBuilder(this, builders);
            }
            else
            {
                foreach (var dep in context.GetDependencies(this))
                {
                    builders.Add(dep);
                }
            }
        }
Example #7
0
        /// <summary>
        /// Prepares a builder to be ran in a given build context.
        ///
        /// <para>This is the place where a builder can add additional dependencies.</para>
        /// </summary>
        /// <param name="context">The current build context</param>
        public void AddToContext(IBuildContext context)
        {
            if (!context.Contains(this))
            {
                referenceBuilders = new HashSet <IBuilder>(project.References.Select(CreateReferenceBuilder));

                foreach (var refBuilder in referenceBuilders)
                {
                    refBuilder.AddToContext(context);
                }

                context.AddBuilder(this, referenceBuilders);
            }
            else
            {
                referenceBuilders = new HashSet <IBuilder>(context.GetDependencies(this));
            }
        }
Example #8
0
        /// <summary>
        /// Prepares a builder to be ran in a given build context.
        ///
        /// <para>This is the place where a builder can add additional dependencies.</para>
        /// </summary>
        /// <param name="context">The current build context</param>
        public void AddToContext(IBuildContext context)
        {
            if (!context.Contains(this))
            {
                log.DebugFormat("Creating reference builders for {0}", project.Name);

                referenceBuilders = new HashSet <IBuilder>(
                    project.References.Where(r => r.Type == ReferenceType.Build).Select(CreateReferenceBuilder));

                foreach (var refBuilder in referenceBuilders)
                {
                    refBuilder.AddToContext(context);
                }

                context.AddBuilder(this, referenceBuilders);

                log.DebugFormat("{0} added to build context", project.Name);
            }
            else
            {
                referenceBuilders = new HashSet <IBuilder>(context.GetDependencies(this));
            }
        }
Example #9
0
        /// <summary>
        /// Prepares a builder to be ran in a given build context.
        ///
        /// <para>This is the place where a builder can add additional dependencies.</para>
        /// </summary>
        /// <param name="context">The current build context</param>
        public void AddToContext(IBuildContext context)
        {
            if (!context.Contains(this))
            {
                var solutionBuildContext = new SolutionBuildContext(inSolutionReferenceBuilderFactory, context, this);

                projectBuilders = new HashSet <ISlnProjectBuilder>(
                    from project in projects
                    select CreateProjectBuilder(solutionBuildContext, project)
                    into builder
                    where builder != null
                    select builder
                    );

                solutionBuildContext.AddBuilder(this, projectBuilders);
            }
            else
            {
                projectBuilders = new HashSet <ISlnProjectBuilder>(context.GetDependencies(this).Cast <ISlnProjectBuilder>());
            }

            projectDependencies = MultipleDependenciesHelper.CreateMultipleDependencies(new HashSet <IBuilder>(projectBuilders));
        }
Example #10
0
        /// <summary>
        /// Runs this builder
        /// </summary>
        /// <param name="context"> </param>
        /// <returns>Returns a set of generated files, in suite relative paths</returns>
        public override ISet <TargetRelativePath> Run(IBuildContext context)
        {
            var          csprojPath    = project.Name + ".csproj";
            const string csversionPath = "version.cs";

            using (var csproj = project.RootDirectory.GetChildDirectory("cs").CreateTextFile(csprojPath))
                using (var csversion = project.RootDirectory.CreateTextFile(csversionPath))
                {
                    var references = new HashSet <TargetRelativePath>();
                    foreach (var refBuilder in context.GetDependencies(this).OfType <IReferenceBuilder>().Where(r => r.Reference.Type == ReferenceType.Build))
                    {
                        try
                        {
                            var builderResults = context.GetResults(refBuilder);
                            references.UnionWith(builderResults);
                        }
                        catch (InvalidOperationException ex)
                        {
                            log.ErrorFormat("Failed to get results of reference {0}: {1}", refBuilder, ex.Message);
                            throw;
                        }
                    }

                    generator.Generate(project, references, csproj, csversion, csversionPath);
                }

            return(new HashSet <TargetRelativePath>(
                       new[]
            {
                new TargetRelativePath(String.Empty,
                                       suite.SuiteRoot.GetRelativePathFrom(targetDir,
                                                                           Path.Combine(suite.SuiteRoot.GetRelativePath(project.RootDirectory), "cs", csprojPath))),
                new TargetRelativePath(String.Empty,
                                       suite.SuiteRoot.GetRelativePathFrom(targetDir,
                                                                           Path.Combine(suite.SuiteRoot.GetRelativePath(project.RootDirectory), csversionPath)))
            }));
        }
Example #11
0
        /// <summary>
        /// Prepares a builder to be ran in a given build context.
        ///
        /// <para>This is the place where a builder can add additional dependencies.</para>
        /// </summary>
        /// <param name="context">The current build context</param>
        public void AddToContext(IBuildContext context)
        {
            string projectName = reference.Uri.Host;

            referencedProject = module.GetProjectOrTestProject(projectName);

            if (!context.Contains(this))
            {
                if (referencedProject != null)
                {
                    subtasks = new HashSet <IBuilder>();
                    context.AddBuilder(this, SubtaskGenerator(context));
                }
                else
                {
                    throw new InvalidReferenceException(string.Format("Module {0} has no project called {1}",
                                                                      module.Name, projectName));
                }
            }
            else
            {
                subtasks = new HashSet <IBuilder>(context.GetDependencies(this));
            }
        }