Пример #1
0
        public bool IsReference(LibraryWrapper library)
        {
            string libpath  = Path.GetDirectoryName(PK.Wrapper.ExpandPath(library.ProjectPath));
            string projpath = Path.GetDirectoryName(PK.Wrapper.ExpandPath(this.ProjectPath));

            return(!libpath.StartsWith(projpath, StringComparison.OrdinalIgnoreCase));
        }
Пример #2
0
        public ReferenceInfo(Dictionary <ComponentWrapper, ReferenceData> references, ProjectWrapper Project, SolutionWrapper Solution, OnAddComponentHandler OnAddComponent)
        {
            this.ReadOnlyComponents = new List <ComponentWrapper>();
            this.Project            = Project;
            this.Solution           = Solution;
            this.OnAddComponent     = OnAddComponent;
            this.AddedComponents    = new Collection <ComponentWrapper>();
            this.RemovedComponents  = new Collection <ComponentWrapper>();

            if (references != null)
            {
                this.References = references;
            }
            else
            {
                this.References = new Dictionary <ComponentWrapper, ReferenceData>();

                foreach (BaseWrapper wrapper in GetComponents())
                {
                    ComponentWrapper component = ComponentWrapper.GetComponentWrapper(wrapper);
                    References.Add(component, new ReferenceData(wrapper));
                }
                foreach (ComponentWrapper component in this.References.Keys)
                {
                    BaseWrapper wrapper = this[component].Wrapper;
                    switch (component.ComponentType)
                    {
                    case ComponentTypeWrapper.Library:
                        LibraryWrapper library = wrapper as LibraryWrapper;
                        Debug.Assert(library != null);
                        library.Dependencies = GetComponents(library.Dependencies);
                        if ((library.LibraryCategory != null) && (library.HasLibraryCategory))
                        {
                            library.LibraryCategory = GetComponent(library.LibraryCategory);
                        }
                        break;

                    case ComponentTypeWrapper.Feature:
                        FeatureWrapper feature = wrapper as FeatureWrapper;
                        Debug.Assert(feature != null);
                        feature.FeatureDependencies   = GetComponents(feature.FeatureDependencies);
                        feature.ComponentDependencies = GetComponents(feature.ComponentDependencies);
                        break;

                    case ComponentTypeWrapper.LibraryCategory:
                        LibraryCategoryWrapper libcat = wrapper as LibraryCategoryWrapper;
                        Debug.Assert(libcat != null);
                        libcat.FeatureAssociations = GetComponents(libcat.FeatureAssociations);
                        break;

                    default:
                        Debug.Assert(false);
                        break;
                    }
                }
                this.Solution.TransportType.FeatureAssociations = GetComponents(this.Solution.TransportType.FeatureAssociations);
            }
        }
Пример #3
0
        protected override void OnCalcReferences()
        {
            Collection <ComponentWrapper> templateList = new Collection <ComponentWrapper>();

            foreach (ComponentWrapper component in this.References.Keys)
            {
                LibraryWrapper template = this[component].Wrapper as LibraryWrapper;
                if ((template != null) && (template.IsTemplate))
                {
                    templateList.Add(component);
                }
            }
            foreach (ComponentWrapper component in templateList)
            {
                this.References.Remove(component);
            }
            this.Templates.Clear();
        }
Пример #4
0
 private void UnResolveLibraryCategory(ReferenceData refData, bool IsStub)
 {
     foreach (ComponentWrapper realization in refData.Realization)
     {
         if (realization.Checked)
         {
             LibraryWrapper realizationlib = this[realization].Wrapper as LibraryWrapper;
             Debug.Assert(realizationlib != null);
             if (realizationlib != null)
             {
                 if (realizationlib.IsStub == IsStub)
                 {
                     realization.Checked = false;
                     RecursiveCheckComponent(realization);
                 }
             }
             break;
         }
     }
 }
Пример #5
0
        protected override void CheckComponents()
        {
            if (this.FeaturesInfo != null)
            {
                foreach (ComponentWrapper feature in this.FeaturesInfo.CheckedComponents)
                {
                    feature.Checked = true;
                }
            }

            foreach (LibraryWrapper template in this.Templates)
            {
                ComponentWrapper component = ComponentWrapper.GetComponentWrapper(template);
                this.References.Add(component, new ReferenceData(template));
                MutualReference(template.LibraryCategory, component, ReferenceType.Realization);
            }

            foreach (ComponentWrapper component in this.References.Keys)
            {
                ReferenceData refData = this[component];
                bool          add     = component.Checked;
                switch (component.ComponentType)
                {
                case ComponentTypeWrapper.LibraryCategory:
                    LibraryCategoryWrapper libcat = refData.Wrapper as LibraryCategoryWrapper;
                    Debug.Assert(libcat != null);
                    if ((libcat.Required == true) || (this.IsTransport(libcat)))
                    {
                        add = true;
                    }
                    break;

                case ComponentTypeWrapper.Library:
                    LibraryWrapper library = refData.Wrapper as LibraryWrapper;
                    if (library.IsTemplate)
                    {
                        component.Name = "Generate Template";
                    }
                    Debug.Assert(library != null);
                    if (library.Required == true)
                    {
                        component.Checked = true;
                        add = true;
                    }
                    break;

                case ComponentTypeWrapper.Feature:
                    FeatureWrapper feature = refData.Wrapper as FeatureWrapper;
                    Debug.Assert(feature != null);
                    if (feature.Required == true)
                    {
                        component.Checked = true;
                        add = true;
                    }
                    break;

                default:
                    Debug.Assert(false);
                    break;
                }
                if (add)
                {
                    RecursiveAddComponent(component);
                }
            }


            foreach (ComponentWrapper component in this.References.Keys)
            {
                if (DefaultComponents(component, this))
                {
                    this.ReadOnlyComponents.Add(component);
                }
                break;
            }
        }
Пример #6
0
        ComponentWrapper GetAutoselectLibrary(ComponentWrapper component)
        {
            Debug.Assert(component.ComponentType == ComponentTypeWrapper.LibraryCategory);
            ReferenceData          refData = this[component];
            LibraryCategoryWrapper libcat  = refData.Wrapper as LibraryCategoryWrapper;

            Debug.Assert(libcat != null);
            ComponentWrapper defaultLib     = null;
            ComponentWrapper stubLib        = null;
            ComponentWrapper templateLib    = null;
            ComponentWrapper bootloaderLib  = null;
            ComponentWrapper projectLib     = null;
            LibraryWrapper   defaultWrapper = null;
            bool             alterLib       = false;

            foreach (ComponentWrapper library in refData.Realization)
            {
                LibraryWrapper wrapper = this[library].Wrapper as LibraryWrapper;
                Debug.Assert(wrapper != null);
                if (wrapper != null)
                {
                    if (this.Project.Libraries.Contains(library))
                    {
                        if (wrapper.IsStub == false)
                        {
                            projectLib = library;
                        }
                        else
                        {
                            stubLib = library;
                        }
                    }
                    if (wrapper.IsStub)
                    {
                        if (stubLib == null)
                        {
                            stubLib = library;
                        }
                    }
                    else if (wrapper.IsBootloaderLibrary())
                    {
                        bootloaderLib = library;
                    }
                    else if (wrapper.IsTemplate)
                    {
                        templateLib = library;
                    }
                    else if (defaultLib == null)
                    {
                        defaultLib     = library;
                        defaultWrapper = wrapper;
                    }
                    else
                    {
                        alterLib = true;
                    }
                }
            }

            if (libcat != null)
            {
                if (libcat.FeatureAssociations.Count != 0)
                {
                    bool selected = false;
                    foreach (ComponentWrapper feature in libcat.FeatureAssociations)
                    {
                        if (feature.Checked == true)
                        {
                            selected = true;
                            break;
                        }
                    }
                    if (selected)
                    {
                        if (this.Project.IsBootloaderProject() == false)
                        {
                            if ((alterLib == false) && (defaultLib != null))
                            {
                                return(defaultLib);
                            }
                            if (projectLib != null)
                            {
                                return(projectLib);
                            }
                        }
                        else if (bootloaderLib == null)
                        {
                            if (this.IsTransport(libcat))
                            {
                                if (alterLib == false)
                                {
                                    return(defaultLib);
                                }
                                if (stubLib != null)
                                {
                                    return(stubLib);
                                }
                                if (((alterLib == true) || (defaultLib == null)) || (((templateLib != null) && (string.IsNullOrEmpty(defaultWrapper.CustomFilter))) && ((defaultWrapper.ProcessorSpecific != null) && (string.IsNullOrEmpty(defaultWrapper.ProcessorSpecific.Guid)))))
                                {
                                    return(null);
                                }
                                return(defaultLib);
                            }
                        }
                        else
                        {
                            return(bootloaderLib);
                        }
                    }
                    else
                    {
                        if (this.IsTransport(libcat))
                        {
                            return(null);
                        }
                        return(stubLib);
                    }
                }
                else
                {
                    if (!this.Project.IsBootloaderProject())
                    {
                        if ((alterLib == false) && (defaultLib != null))
                        {
                            if ((stubLib == null) && (templateLib == null))
                            {
                                return(defaultLib);
                            }
                            if (!string.IsNullOrEmpty(defaultWrapper.CustomFilter) || ((defaultWrapper.ProcessorSpecific != null) && (!string.IsNullOrEmpty(defaultWrapper.ProcessorSpecific.Guid))))
                            {
                                return(defaultLib);
                            }
                        }
                        if (projectLib != null)
                        {
                            return(projectLib);
                        }
                        if ((stubLib != null) && (this.Project.Libraries.Contains(stubLib)))
                        {
                            return(stubLib);
                        }
                    }
                    else if (bootloaderLib == null)
                    {
                        if (stubLib != null)
                        {
                            return(stubLib);
                        }
                        if (alterLib == false)
                        {
                            return(defaultLib);
                        }
                    }
                    else
                    {
                        return(bootloaderLib);
                    }
                }
            }
            return(null);
        }
Пример #7
0
        private bool ValidateLibrary(LibraryWrapper library)
        {
            if (((library.ProcessorSpecific != null) && !string.IsNullOrEmpty(library.ProcessorSpecific.Guid)) && (string.Compare(library.ProcessorSpecific.Guid, this.Solution.Processor.Guid, true) != 0))
            {
                return(false);
            }
            if (!string.IsNullOrEmpty(library.CustomFilter))
            {
                bool found = false;
                //CustomFilter содержит список процессоров через разделитель ';'
                //Идем вдоль процессоров библиотеки
                foreach (string libfilter in library.CustomFilter.Split(new char[] { ';' }))
                {
                    //Идем вдоль процессоров процессора
                    foreach (string procfilter in this.Processor.CustomFilter.Split(new char[] { ';' }))
                    {
                        //Если найдено соответствие, то найдено
                        if (string.Compare(procfilter, libfilter, true) == 0)
                        {
                            found = true;
                            break;
                        }
                    }
                    //Если соответствия не найдено
                    if (found == false)
                    {
                        //Ищем в процессорах решения
                        foreach (string solutionfilter in this.Solution.CustomFilter.Split(new char[] { ';' }))
                        {
                            if (string.Compare(solutionfilter, libfilter, true) == 0)
                            {
                                found = true;
                                break;
                            }
                        }
                    }
                    //Если не найдено
                    if (found == false)
                    {
                        //Находим проект CLR
                        Collection <ComponentWrapper> features = null;
                        if (this.Project.IsClrProject)
                        {
                            features = this.FeaturesInfo.CheckedComponents;
                        }
                        else
                        {
                            foreach (ProjectWrapper project in this.Solution.Projects)
                            {
                                if (project.IsClrProject)
                                {
                                    features = GetComponents(project.Features);
                                    break;
                                }
                            }
                        }
                        if (features != null)
                        {
                            //Идем вдоль фич проекта CLR
                            foreach (ComponentWrapper component in features)
                            {
                                //Находим соответствующую фичу
                                FeatureWrapper feature = this[component].Wrapper as FeatureWrapper;
                                //И проверяем ее фильтр, если совпало, устанавливаем флаг
                                if ((feature != null) && (string.Compare(feature.Filter, libfilter, true) == 0))
                                {
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }
                    //Если не найдено, в конечном итоге сравниваем с именем решения
                    if (!found)
                    {
                        found = 0 == string.Compare(library.CustomFilter, this.Solution.Name, true);
                    }
                    //Если найдено хоть одно соответствие выходим
                    if (found)
                    {
                        break;
                    }
                }
                if (!found)
                {
                    return(false);
                }
            }
            //Если проект не Загрузчик а библиотека - загрузчик, то валидация не проходит
            if (!this.Project.IsBootloaderProject() && library.IsBootloaderLibrary())
            {
                return(false);
            }
            //Есби библиотека - CLR а проект - нет, то валидация не проходит
            if ((library.Level == LibraryLevelWrapper.CLR) && !this.Project.IsClrProject)
            {
                return(false);
            }
            string libProjectPath = library.ProjectPath.ToLower();

            //Если библиотека лежит в примерах, то валидация не проходит
            if (libProjectPath.Contains(@"\devicecode\drivers\sample\"))
            {
                return(false);
            }
            //Если библиотека находится в другом проекте, то валидация не проходит
            if (libProjectPath.Contains(@"\solutions\") && !libProjectPath.Contains(@"\solutions\" + this.Solution.Name.ToLower() + @"\"))
            {
                return(false);
            }

            return(true);
        }
Пример #8
0
        protected override void OnComponentRefs(ComponentWrapper component)
        {
            ReferenceData refData = this.References[component];

            switch (component.ComponentType)
            {
            case ComponentTypeWrapper.Feature:
                FeatureWrapper feature = refData.Wrapper as FeatureWrapper;
                Debug.Assert(feature != null);
                if (feature != null)
                {
                    foreach (ComponentWrapper dependency in feature.ComponentDependencies)
                    {
                        MutualReference(component, dependency);
                    }
                }
                break;

            case ComponentTypeWrapper.Library:
                LibraryWrapper library = refData.Wrapper as LibraryWrapper;
                Debug.Assert(library != null);
                if (library != null)
                {
                    if ((library.LibraryCategory != null) && (library.HasLibraryCategory == true))
                    {
                        if (this.ValidateLibrary(library))
                        {
                            MutualReference(library.LibraryCategory, component, ReferenceType.Realization);
                        }
                    }
                    foreach (ComponentWrapper dependency in library.Dependencies)
                    {
                        MutualReference(component, dependency);
                    }
                }
                break;

            case ComponentTypeWrapper.LibraryCategory:
                LibraryCategoryWrapper libcat = refData.Wrapper as LibraryCategoryWrapper;
                Debug.Assert(libcat != null);
                if (libcat != null)
                {
                    //foreach (ComponentWrapper assotiation in libcat.FeatureAssociations)
                    //{
                    //    MutualReference(assotiation, component,ReferenceType.Assotiation);
                    //}

                    if ((libcat.Level != LibraryLevelWrapper.CLR) && (libcat.Templates.Count != 0))
                    {
                        LibraryWrapper template = PK.Wrapper.CreateLibrary(
                            libcat.Name + "_" + this.Solution.Name,
                            libcat.Level,
                            @"Generates template code in your solution's DeviceCode directory for the given Library Category.The project will be generated in Solutions\" + this.Solution.Name + @"\DeviceCode\" + libcat.Name,
                            PK.Wrapper.SpoClientPath + @"Solutions\" + this.Solution.Name + @"\DeviceCode\" + libcat.Name + @"\dotnetmf.proj",
                            true,
                            component);
                        this.Templates.Add(template);
                    }
                }
                break;
            }
        }
Пример #9
0
 public static ComponentWrapper GetComponentWrapper(LibraryWrapper lib)
 {
     return(GetComponentWrapper(lib, ComponentTypeWrapper.Library));
 }