Exemplo n.º 1
0
 public TrackedConfiguration FindConfiguration(ITarget target)
 {
     return(Configurations[target.GetTargetString()]);
 }
Exemplo n.º 2
0
        internal void Link(Builder builder)
        {
            if (_dependenciesResolved)
            {
                return;
            }

            foreach (Solution.Configuration solutionConfiguration in Configurations)
            {
                // Build SolutionFilesMapping
                string configurationFile = Path.Combine(solutionConfiguration.SolutionPath, solutionConfiguration.SolutionFileName);

                var fileConfigurationList = SolutionFilesMapping.GetValueOrAdd(configurationFile, new List <Solution.Configuration>());
                fileConfigurationList.Add(solutionConfiguration);

                // solutionConfiguration.IncludedProjectInfos will be appended
                // while iterating, but with projects that we already have resolved,
                // so no need to parse them again
                int origCount = solutionConfiguration.IncludedProjectInfos.Count;
                for (int i = 0; i < origCount; ++i)
                {
                    Configuration.IncludedProjectInfo configurationProject = solutionConfiguration.IncludedProjectInfos[i];

                    Project project = builder.GetProject(configurationProject.Type);
                    Project.Configuration projectConfiguration = project.GetConfiguration(configurationProject.Target);

                    if (projectConfiguration == null)
                    {
                        throw new Error(
                                  "Solution {0} for target '{1}' contains project {2} with invalid target '{3}'",
                                  GetType().FullName, solutionConfiguration.Target, project.GetType().FullName, configurationProject.Target
                                  );
                    }

                    configurationProject.Project       = project;
                    configurationProject.Configuration = projectConfiguration;

                    bool build = !projectConfiguration.IsExcludedFromBuild && !configurationProject.InactiveProject;
                    if (configurationProject.ToBuild != Configuration.IncludedProjectInfo.Build.YesThroughDependency)
                    {
                        if (build)
                        {
                            configurationProject.ToBuild = Configuration.IncludedProjectInfo.Build.Yes;
                        }
                        else if (configurationProject.ToBuild != Configuration.IncludedProjectInfo.Build.Yes)
                        {
                            configurationProject.ToBuild = Configuration.IncludedProjectInfo.Build.No;
                        }
                    }

                    var dependenciesConfiguration = configurationProject.Configuration.GetRecursiveDependencies();
                    foreach (Project.Configuration dependencyConfiguration in dependenciesConfiguration)
                    {
                        Type dependencyProjectType = dependencyConfiguration.Project.GetType();

                        if (dependencyProjectType.IsDefined(typeof(Export), false))
                        {
                            continue;
                        }

                        ITarget dependencyProjectTarget = dependencyConfiguration.Target;

                        Configuration.IncludedProjectInfo configurationProjectDependency = solutionConfiguration.GetProject(dependencyProjectType);

                        if (configurationProjectDependency == null)
                        {
                            var dependencyProject = builder.GetProject(dependencyProjectType);
                            configurationProjectDependency = new Configuration.IncludedProjectInfo
                            {
                                Type            = dependencyProjectType,
                                Project         = dependencyProject,
                                Configuration   = dependencyProject.GetConfiguration(dependencyProjectTarget),
                                Target          = dependencyProjectTarget,
                                InactiveProject = configurationProject.InactiveProject // inherit from the parent: no reason to mark dependencies for build if parent is inactive
                            };
                            solutionConfiguration.IncludedProjectInfos.Add(configurationProjectDependency);
                        }
                        else
                        {
                            if (!configurationProjectDependency.Target.IsEqualTo(dependencyProjectTarget))
                            {
                                throw new Error("In solution configuration (solution: {3}, config: {4}) the parent project {5} generates multiple dependency targets for the same child project {0}: {1} and {2}. Look for all AddPublicDependency() and AddPrivateDependency() calls for the child project and follow the dependency chain.",
                                                configurationProjectDependency.Project.GetType().ToString(),
                                                configurationProjectDependency.Target,
                                                dependencyProjectTarget,
                                                solutionConfiguration.SolutionFileName,
                                                solutionConfiguration.Target,
                                                project.Name);
                            }
                        }

                        bool depBuild = !dependencyConfiguration.IsExcludedFromBuild && !configurationProjectDependency.InactiveProject;
                        if (configurationProjectDependency.ToBuild != Configuration.IncludedProjectInfo.Build.YesThroughDependency)
                        {
                            if (depBuild)
                            {
                                configurationProjectDependency.ToBuild = Configuration.IncludedProjectInfo.Build.YesThroughDependency;
                            }
                            else if (configurationProjectDependency.ToBuild != Configuration.IncludedProjectInfo.Build.Yes)
                            {
                                configurationProjectDependency.ToBuild = Configuration.IncludedProjectInfo.Build.No;
                            }
                        }
                    }
                }
            }
            _dependenciesResolved = true;
        }