Inheritance: RequiredBase
Ejemplo n.º 1
0
        private bool CheckItems(RequiredLibrary reqlib)
        {
            if (this.ParamCollection == null) return false;

            foreach (RequiredObject obj in reqlib.InputObjects.Values)
            {
                if (obj.ParamCollection == null) return false;
            }

            foreach (RequiredLibrary lib in reqlib.InputLibraries.Values)
            {
                if (!this.CheckItems(lib)) return false;
            }
            return true;
        }
Ejemplo n.º 2
0
        private SortedList <int, RequiredObject> GetLibraryObjects(RequiredLibrary lib)
        {
            SortedList <int, RequiredObject> result = new SortedList <int, RequiredObject>();

            foreach (RequiredObject o in lib.InputObjects.Values)
            {
                result.Add(result.Count + 1, o);
            }

            foreach (RequiredLibrary reqlib in lib.InputLibraries.Values)
            {
                SortedList <int, RequiredObject> tmplist = this.GetLibraryObjects(reqlib);

                foreach (RequiredObject o in tmplist.Values)
                {
                    result.Add(result.Count + 1, o);
                }
            }

            return(result);
        }
Ejemplo n.º 3
0
        private bool CheckItems(RequiredLibrary reqlib)
        {
            if (this.ParamCollection == null)
            {
                return(false);
            }

            foreach (RequiredObject obj in reqlib.InputObjects.Values)
            {
                if (obj.ParamCollection == null)
                {
                    return(false);
                }
            }

            foreach (RequiredLibrary lib in reqlib.InputLibraries.Values)
            {
                if (!this.CheckItems(lib))
                {
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 4
0
        private void CreateLibraryTartet(RequiredLibrary lib)
        {
            Target target = new Target(uVisionProject.DefaultOptions);

            //Setting default options
            //target.Set_AT91SAM7S16_DefaultOptions();
            //target.Options.SerializeXLM(@"AT91SAM7S16.xml");
            //target.LoadOptions(@"text.xml");


            target.Name = Path.GetFileNameWithoutExtension(lib.Name);
            target.Options.OutDir += uVisionTargetsPath + "\\" + target.Name + "\\";
            target.Options.OutName = Path.GetFileNameWithoutExtension(lib.Name);

            target.Options.GenApp = TWO_STATE_BOOL.DISABLED;
            target.Options.GenLib = TWO_STATE_BOOL.ENABLED;

            target.Options.ADSFLGA = "226,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0";

            target.Options.ADSCCFLG.ARM_Thumb_Interworking = THREE_STATE_BOOL.DISABLED;
            target.Options.ADSCCFLG.Optimisation = OPTIMIZATION.Level0;
            target.Options.ADSCCFLG.Optimize_for_time = THREE_STATE_BOOL.DISABLED;
            target.Options.ADSCCFLG.Split_Load_and_Store_Multiple = THREE_STATE_BOOL.DISABLED;
            target.Options.ADSCCFLG.One_EFL_Section_per_Function = THREE_STATE_BOOL.DISABLED;
            target.Options.ADSCCFLG.Strict_ANSI_C = THREE_STATE_BOOL.DISABLED;
            target.Options.ADSCCFLG.Enum_Container_always_int = THREE_STATE_BOOL.DISABLED;
            target.Options.ADSCCFLG.Plain_Char_is_Signed = THREE_STATE_BOOL.DISABLED;
            target.Options.ADSCCFLG.ReadOnly_Position_Independent = THREE_STATE_BOOL.DISABLED;
            target.Options.ADSCCFLG.ReadWrite_Position_Independent = THREE_STATE_BOOL.DISABLED;
            target.Options.ADSCCFLG.Thumb_Mode = THREE_STATE_BOOL.DISABLED;


            target.Options.ADSASFLG = "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0";
            target.Options.Debug = "1";
            target.Options.Browse = "1";


            //Exclude files from building
            foreach (PKStudio.Tools.uVisionGenerator.Classes.uvProjectClasses.File f in uVisionProject.FileList.Values)
            {
                PKStudio.Tools.uVisionGenerator.Classes.uvProjectClasses.FileOptions fileopt = new PKStudio.Tools.uVisionGenerator.Classes.uvProjectClasses.FileOptions(f);
                fileopt.IncBld = THREE_STATE_BOOL.DISABLED;
                target.FilesOpton.Add(fileopt);
            }

            foreach (RequiredObject obj in lib.InputObjects.Values)
            {
                this.AddCompileFile(obj, target);
            }

            foreach (RequiredLibrary reqlib in lib.InputLibraries.Values)
            {
                PKStudio.Tools.uVisionGenerator.Classes.uvProjectClasses.FileOptions fileOpt = target.FindFileOptions(reqlib.OutputFileuVision);
                if (fileOpt == null) throw new MessagesParserException(KeilWizardStrings.IDS_ERROR_INTERNAL + " " + reqlib.OutputFileMSBuild + ": " + KeilWizardStrings.IDS_ERROR_CANT_FIND_LIBRARY_FILE_OPTIONS);
                fileOpt.IncBld = THREE_STATE_BOOL.ENABLED;
                this.CreateLibraryTartet(reqlib);
            }

            target.Num = uVisionProject.TargetList.Count + 1;
            if (!uVisionProject.ContainsTarget(target))
                uVisionProject.TargetList.Add(target.Num, target);

            if (target.BeforeBuild.Count > 0)
            {
                target.Options.BrunUsr_0.Run = TWO_STATE_BOOL.ENABLED;
                target.Options.BrunUsr_0.Command = ".\\BatFiles\\Prebuild" + @"\" + target.Name + ".bat";
            }

            if (target.AfterBuild.Count > 0)
            {
                target.Options.RunUsr_0.Run = TWO_STATE_BOOL.ENABLED;
                target.Options.RunUsr_0.Command = ".\\BatFiles\\Postbuild" + @"\" + target.Name + ".bat";
            }
        }
Ejemplo n.º 5
0
        private void CheckSocketsLibs(SortedList<int, RequiredLibrary> Libraryes, IList<LogQueueItem> LogMessages)
        {
            //PKParser.Arg.PKArgParser ArgParser = new PKParser.Arg.PKArgParser();

            foreach (RequiredLibrary lib in Libraryes.Values)
            {
                #region sockets_hal.lib
                if (lib.Name.ToLower() == "sockets_hal.lib")
                {
                    if (lib.ParamCollection != null) return;

                    //foreach (LogQueueItem item in LogMessages)
                    //{
                    //    string util = ArgParser.GetUtil(item.Message);
                    //    if (util == null) continue;
                    //    if (String.Compare(ARMARPath, util, StringComparison.InvariantCultureIgnoreCase) == 0)
                    //if (item.Message.ToLower().Contains(ARMARPath))
                    //{
                    //ParamCollection par = ArgParser.Add(item.Message);
                    foreach (ParCollContainer container in ARMAR.Values)
                    {
                        ParamCollection par = container.ParamCollection;
                        if (par == null) continue;

                        bool Found = false;

                        foreach (ArgCollection arg in par.Values)
                        {
                            if (arg.Tag == "archive")
                            {
                                if (Path.GetFileName(arg.Name).ToLower() == "sockets_hal_stubs.lib") Found = true;
                            }
                        }

                        if (!Found) continue;

                        lib.ConsoleString = container.Message;
                        lib.ParamCollection = par;
                        lib.BuildList.AddRange(container.ProjectBuildContext);
                        lib.OutputFileuVision = uVisionProjectPath + "\\" + uVisionTargetsPath + "\\" + Path.GetFileNameWithoutExtension(lib.Name) + "\\" + Path.GetFileName(lib.Name);

                        string LIB_EXT = string.Empty;
                        string OBJ_EXT = string.Empty;

                        using (ProjectCollection LocalProjColl = new ProjectCollection())
                        {
                            Project MSBProj = LocalProjColl.LoadProject(container.ProjectBuildContext[container.ProjectBuildContext.Count - 1]);
                            LIB_EXT = MSBProj.GetPropertyValue("LIB_EXT");
                            OBJ_EXT = MSBProj.GetPropertyValue("OBJ_EXT");
                        }


                        foreach (string file in par.Files.Values)
                        {
                            RequiredLibrary libr = null;
                            RequiredObject obj = null;
                            if (Path.GetExtension(file).ToLower() == "." + LIB_EXT.ToLower())
                            {
                                libr = new RequiredLibrary(file, lib);
                                lib.InputLibraries.Add(lib.InputLibraries.Count + 1, libr);
                            }

                            if (Path.GetExtension(file).ToLower() == "." + OBJ_EXT.ToLower())
                            {
                                obj = new RequiredObject(file, lib);
                                lib.InputObjects.Add(lib.InputObjects.Count + 1, obj);
                            }
                            if (libr != null) lib.AllInputs.Add(lib.AllInputs.Count + 1, libr);
                            if (obj != null) lib.AllInputs.Add(lib.AllInputs.Count + 1, obj);
                        }


                        foreach (ArgCollection arg in par.Values)
                        {
                            switch (arg.Tag)
                            {
                                case "options":
                                    if (arg.Count > 0)
                                        foreach (string s in arg)
                                        {
                                            lib.OptionsString.Add(arg.Name + " " + s);
                                        }
                                    else
                                        lib.OptionsString.Add(arg.Name);
                                    break;
                                case "archive":
                                    lib.OutputFileMSBuild = arg.Name;
                                    break;
                            }
                        }
                        //}
                    }
                    if (lib.InputLibraries.Count > 0) this.AnalizeInputLibraries(lib.InputLibraries, LogMessages);
                }
                #endregion
                #region sockets_dhcp.lib
                if (lib.Name.ToLower() == "sockets_dhcp.lib")
                {
                    if (lib.ParamCollection != null) return;

                    //foreach (LogQueueItem item in LogMessages)
                    //{
                    //    string util = ArgParser.GetUtil(item.Message);
                    //    if (util == null) continue;
                    //    if (String.Compare(ARMARPath, util, StringComparison.InvariantCultureIgnoreCase) == 0)
                    //if (item.Message.ToLower().Contains(ARMARPath))
                    //{
                    //ParamCollection par = ArgParser.Add(item.Message);
                    foreach (ParCollContainer container in ARMAR.Values)
                    {
                        ParamCollection par = container.ParamCollection;
                        if (par == null) continue;

                        bool Found = false;

                        foreach (ArgCollection arg in par.Values)
                        {
                            if (arg.Tag == "archive")
                            {
                                if (Path.GetFileName(arg.Name).ToLower() == "sockets_dhcp_stubs.lib") Found = true;
                            }
                        }

                        if (!Found) continue;

                        lib.ConsoleString = container.Message;
                        lib.ParamCollection = par;
                        lib.BuildList.AddRange(container.ProjectBuildContext);
                        lib.OutputFileuVision = uVisionProjectPath + "\\" + uVisionTargetsPath + "\\" + Path.GetFileNameWithoutExtension(lib.Name) + "\\" + Path.GetFileName(lib.Name);

                        string LIB_EXT = string.Empty;
                        string OBJ_EXT = string.Empty;

                        using (ProjectCollection LocalProjColl = new ProjectCollection())
                        {
                            Project MSBProj = LocalProjColl.LoadProject(container.ProjectBuildContext[container.ProjectBuildContext.Count - 1]);
                            LIB_EXT = MSBProj.GetPropertyValue("LIB_EXT");
                            OBJ_EXT = MSBProj.GetPropertyValue("OBJ_EXT");
                        }


                        foreach (string file in par.Files.Values)
                        {
                            RequiredLibrary libr = null;
                            RequiredObject obj = null;
                            if (Path.GetExtension(file).ToLower() == "." + LIB_EXT.ToLower())
                            {
                                libr = new RequiredLibrary(file, lib);
                                lib.InputLibraries.Add(lib.InputLibraries.Count + 1, libr);
                            }

                            if (Path.GetExtension(file).ToLower() == "." + OBJ_EXT.ToLower())
                            {
                                obj = new RequiredObject(file, lib);
                                lib.InputObjects.Add(lib.InputObjects.Count + 1, obj);
                            }
                            if (libr != null) lib.AllInputs.Add(lib.AllInputs.Count + 1, libr);
                            if (obj != null) lib.AllInputs.Add(lib.AllInputs.Count + 1, obj);
                        }


                        foreach (ArgCollection arg in par.Values)
                        {
                            switch (arg.Tag)
                            {
                                case "options":
                                    if (arg.Count > 0)
                                        foreach (string s in arg)
                                        {
                                            lib.OptionsString.Add(arg.Name + " " + s);
                                        }
                                    else
                                        lib.OptionsString.Add(arg.Name);
                                    break;
                                case "archive":
                                    lib.OutputFileMSBuild = arg.Name;
                                    break;
                            }
                        }
                        //}
                    }
                    if (lib.InputLibraries.Count > 0) this.AnalizeInputLibraries(lib.InputLibraries, LogMessages);
                }
                #endregion
                #region sockets_hal_udp.lib
                if (lib.Name.ToLower() == "sockets_hal_udp.lib")
                {
                    if (lib.ParamCollection != null) return;

                    //foreach (LogQueueItem item in LogMessages)
                    //{
                    //    string util = ArgParser.GetUtil(item.Message);
                    //    if (util == null) continue;
                    //    if (String.Compare(ARMARPath, util, StringComparison.InvariantCultureIgnoreCase) == 0)
                    //if (item.Message.ToLower().Contains(ARMARPath))
                    //{
                    //ParamCollection par = ArgParser.Add(item.Message);
                    foreach (ParCollContainer container in ARMAR.Values)
                    {
                        ParamCollection par = container.ParamCollection;
                        if (par == null) continue;

                        bool Found = false;

                        foreach (ArgCollection arg in par.Values)
                        {
                            if (arg.Tag == "archive")
                            {
                                if (Path.GetFileName(arg.Name).ToLower() == "sockets_hal_udp_stubs.lib") Found = true;
                            }
                        }

                        if (!Found) continue;

                        lib.ConsoleString = container.Message;
                        lib.ParamCollection = par;
                        lib.BuildList.AddRange(container.ProjectBuildContext);
                        lib.OutputFileuVision = uVisionProjectPath + "\\" + uVisionTargetsPath + "\\" + Path.GetFileNameWithoutExtension(lib.Name) + "\\" + Path.GetFileName(lib.Name);

                        string LIB_EXT = string.Empty;
                        string OBJ_EXT = string.Empty;

                        using (ProjectCollection LocalProjColl = new ProjectCollection())
                        {
                            Project MSBProj = LocalProjColl.LoadProject(container.ProjectBuildContext[container.ProjectBuildContext.Count - 1]);
                            LIB_EXT = MSBProj.GetPropertyValue("LIB_EXT");
                            OBJ_EXT = MSBProj.GetPropertyValue("OBJ_EXT");
                        }


                        foreach (string file in par.Files.Values)
                        {
                            RequiredLibrary libr = null;
                            RequiredObject obj = null;
                            if (Path.GetExtension(file).ToLower() == "." + LIB_EXT.ToLower())
                            {
                                libr = new RequiredLibrary(file, lib);
                                lib.InputLibraries.Add(lib.InputLibraries.Count + 1, libr);
                            }

                            if (Path.GetExtension(file).ToLower() == "." + OBJ_EXT.ToLower())
                            {
                                obj = new RequiredObject(file, lib);
                                lib.InputObjects.Add(lib.InputObjects.Count + 1, obj);
                            }
                            if (libr != null) lib.AllInputs.Add(lib.AllInputs.Count + 1, libr);
                            if (obj != null) lib.AllInputs.Add(lib.AllInputs.Count + 1, obj);
                        }


                        foreach (ArgCollection arg in par.Values)
                        {
                            switch (arg.Tag)
                            {
                                case "options":
                                    if (arg.Count > 0)
                                        foreach (string s in arg)
                                        {
                                            lib.OptionsString.Add(arg.Name + " " + s);
                                        }
                                    else
                                        lib.OptionsString.Add(arg.Name);
                                    break;
                                case "archive":
                                    lib.OutputFileMSBuild = arg.Name;
                                    break;
                            }
                        }
                        //}
                    }
                    if (lib.InputLibraries.Count > 0) this.AnalizeInputLibraries(lib.InputLibraries, LogMessages);
                }
                #endregion
                #region sockets_ssl.lib
                if (lib.Name.ToLower() == "sockets_ssl.lib")
                {
                    if (lib.ParamCollection != null) return;

                    //foreach (LogQueueItem item in LogMessages)
                    //{
                    //    string util = ArgParser.GetUtil(item.Message);
                    //    if (util == null) continue;
                    //    if (String.Compare(ARMARPath, util, StringComparison.InvariantCultureIgnoreCase) == 0)
                    //if (item.Message.ToLower().Contains(ARMARPath))
                    //{
                    //ParamCollection par = ArgParser.Add(item.Message);
                    foreach (ParCollContainer container in ARMAR.Values)
                    {
                        ParamCollection par = container.ParamCollection;
                        if (par == null) continue;

                        bool Found = false;

                        foreach (ArgCollection arg in par.Values)
                        {
                            if (arg.Tag == "archive")
                            {
                                if (Path.GetFileName(arg.Name).ToLower() == "sockets_ssl_stubs.lib") Found = true;
                            }
                        }

                        if (!Found) continue;

                        lib.ConsoleString = container.Message;
                        lib.ParamCollection = par;
                        lib.BuildList.AddRange(container.ProjectBuildContext);
                        lib.OutputFileuVision = uVisionProjectPath + "\\" + uVisionTargetsPath + "\\" + Path.GetFileNameWithoutExtension(lib.Name) + "\\" + Path.GetFileName(lib.Name);

                        string LIB_EXT = string.Empty;
                        string OBJ_EXT = string.Empty;

                        using (ProjectCollection LocalProjColl = new ProjectCollection())
                        {
                            Project MSBProj = LocalProjColl.LoadProject(container.ProjectBuildContext[container.ProjectBuildContext.Count - 1]);
                            LIB_EXT = MSBProj.GetPropertyValue("LIB_EXT");
                            OBJ_EXT = MSBProj.GetPropertyValue("OBJ_EXT");
                        }


                        foreach (string file in par.Files.Values)
                        {
                            RequiredLibrary libr = null;
                            RequiredObject obj = null;
                            if (Path.GetExtension(file).ToLower() == "." + LIB_EXT.ToLower())
                            {
                                libr = new RequiredLibrary(file, lib);
                                lib.InputLibraries.Add(lib.InputLibraries.Count + 1, libr);
                            }

                            if (Path.GetExtension(file).ToLower() == "." + OBJ_EXT.ToLower())
                            {
                                obj = new RequiredObject(file, lib);
                                lib.InputObjects.Add(lib.InputObjects.Count + 1, obj);
                            }
                            if (libr != null) lib.AllInputs.Add(lib.AllInputs.Count + 1, libr);
                            if (obj != null) lib.AllInputs.Add(lib.AllInputs.Count + 1, obj);
                        }


                        foreach (ArgCollection arg in par.Values)
                        {
                            switch (arg.Tag)
                            {
                                case "options":
                                    if (arg.Count > 0)
                                        foreach (string s in arg)
                                        {
                                            lib.OptionsString.Add(arg.Name + " " + s);
                                        }
                                    else
                                        lib.OptionsString.Add(arg.Name);
                                    break;
                                case "archive":
                                    lib.OutputFileMSBuild = arg.Name;
                                    break;
                            }
                        }
                        //}
                    }
                    if (lib.InputLibraries.Count > 0) this.AnalizeInputLibraries(lib.InputLibraries, LogMessages);
                }
                #endregion
                #region sockets_sntp.lib
                if (lib.Name.ToLower() == "sockets_sntp.lib")
                {
                    if (lib.ParamCollection != null) return;

                    //foreach (LogQueueItem item in LogMessages)
                    //{
                    //    string util = ArgParser.GetUtil(item.Message);
                    //    if (util == null) continue;
                    //    if (String.Compare(ARMARPath, util, StringComparison.InvariantCultureIgnoreCase) == 0)
                    //if (item.Message.ToLower().Contains(ARMARPath))
                    //{
                    //ParamCollection par = ArgParser.Add(item.Message);
                    foreach (ParCollContainer container in ARMAR.Values)
                    {
                        ParamCollection par = container.ParamCollection;
                        if (par == null) continue;

                        bool Found = false;

                        foreach (ArgCollection arg in par.Values)
                        {
                            if (arg.Tag == "archive")
                            {
                                if (Path.GetFileName(arg.Name).ToLower() == "sockets_sntp_stubs.lib") Found = true;
                            }
                        }

                        if (!Found) continue;

                        lib.ConsoleString = container.Message;
                        lib.ParamCollection = par;
                        lib.BuildList.AddRange(container.ProjectBuildContext);
                        lib.OutputFileuVision = uVisionProjectPath + "\\" + uVisionTargetsPath + "\\" + Path.GetFileNameWithoutExtension(lib.Name) + "\\" + Path.GetFileName(lib.Name);

                        string LIB_EXT = string.Empty;
                        string OBJ_EXT = string.Empty;

                        using (ProjectCollection LocalProjColl = new ProjectCollection())
                        {
                            Project MSBProj = LocalProjColl.LoadProject(container.ProjectBuildContext[container.ProjectBuildContext.Count - 1]);
                            LIB_EXT = MSBProj.GetPropertyValue("LIB_EXT");
                            OBJ_EXT = MSBProj.GetPropertyValue("OBJ_EXT");
                        }


                        foreach (string file in par.Files.Values)
                        {
                            RequiredLibrary libr = null;
                            RequiredObject obj = null;
                            if (Path.GetExtension(file).ToLower() == "." + LIB_EXT.ToLower())
                            {
                                libr = new RequiredLibrary(file, lib);
                                lib.InputLibraries.Add(lib.InputLibraries.Count + 1, libr);
                            }

                            if (Path.GetExtension(file).ToLower() == "." + OBJ_EXT.ToLower())
                            {
                                obj = new RequiredObject(file, lib);
                                lib.InputObjects.Add(lib.InputObjects.Count + 1, obj);
                            }
                            if (libr != null) lib.AllInputs.Add(lib.AllInputs.Count + 1, libr);
                            if (obj != null) lib.AllInputs.Add(lib.AllInputs.Count + 1, obj);
                        }


                        foreach (ArgCollection arg in par.Values)
                        {
                            switch (arg.Tag)
                            {
                                case "options":
                                    if (arg.Count > 0)
                                        foreach (string s in arg)
                                        {
                                            lib.OptionsString.Add(arg.Name + " " + s);
                                        }
                                    else
                                        lib.OptionsString.Add(arg.Name);
                                    break;
                                case "archive":
                                    lib.OutputFileMSBuild = arg.Name;
                                    break;
                            }
                        }
                        //}
                    }
                    if (lib.InputLibraries.Count > 0) this.AnalizeInputLibraries(lib.InputLibraries, LogMessages);
                }
                #endregion
                #region sockets_hal_tcp.lib
                if (lib.Name.ToLower() == "sockets_hal_tcp.lib")
                {
                    if (lib.ParamCollection != null) return;

                    //foreach (LogQueueItem item in LogMessages)
                    //{
                    //    string util = ArgParser.GetUtil(item.Message);
                    //    if (util == null) continue;
                    //    if (String.Compare(ARMARPath, util, StringComparison.InvariantCultureIgnoreCase) == 0)
                    //if (item.Message.ToLower().Contains(ARMARPath))
                    //{
                    //ParamCollection par = ArgParser.Add(item.Message);
                    foreach (ParCollContainer container in ARMAR.Values)
                    {
                        ParamCollection par = container.ParamCollection;
                        if (par == null) continue;

                        bool Found = false;

                        foreach (ArgCollection arg in par.Values)
                        {
                            if (arg.Tag == "archive")
                            {
                                if (Path.GetFileName(arg.Name).ToLower() == "sockets_hal_tcp_stubs.lib") Found = true;
                            }
                        }

                        if (!Found) continue;

                        lib.ConsoleString = container.Message;
                        lib.ParamCollection = par;
                        lib.BuildList.AddRange(container.ProjectBuildContext);
                        lib.OutputFileuVision = uVisionProjectPath + "\\" + uVisionTargetsPath + "\\" + Path.GetFileNameWithoutExtension(lib.Name) + "\\" + Path.GetFileName(lib.Name);

                        string LIB_EXT = string.Empty;
                        string OBJ_EXT = string.Empty;

                        using (ProjectCollection LocalProjColl = new ProjectCollection())
                        {
                            Project MSBProj = LocalProjColl.LoadProject(container.ProjectBuildContext[container.ProjectBuildContext.Count - 1]);
                            LIB_EXT = MSBProj.GetPropertyValue("LIB_EXT");
                            OBJ_EXT = MSBProj.GetPropertyValue("OBJ_EXT");
                        }


                        foreach (string file in par.Files.Values)
                        {
                            RequiredLibrary libr = null;
                            RequiredObject obj = null;
                            if (Path.GetExtension(file).ToLower() == "." + LIB_EXT.ToLower())
                            {
                                libr = new RequiredLibrary(file, lib);
                                lib.InputLibraries.Add(lib.InputLibraries.Count + 1, libr);
                            }

                            if (Path.GetExtension(file).ToLower() == "." + OBJ_EXT.ToLower())
                            {
                                obj = new RequiredObject(file, lib);
                                lib.InputObjects.Add(lib.InputObjects.Count + 1, obj);
                            }
                            if (libr != null) lib.AllInputs.Add(lib.AllInputs.Count + 1, libr);
                            if (obj != null) lib.AllInputs.Add(lib.AllInputs.Count + 1, obj);
                        }


                        foreach (ArgCollection arg in par.Values)
                        {
                            switch (arg.Tag)
                            {
                                case "options":
                                    if (arg.Count > 0)
                                        foreach (string s in arg)
                                        {
                                            lib.OptionsString.Add(arg.Name + " " + s);
                                        }
                                    else
                                        lib.OptionsString.Add(arg.Name);
                                    break;
                                case "archive":
                                    lib.OutputFileMSBuild = arg.Name;
                                    break;
                            }
                        }
                        //}
                    }
                    if (lib.InputLibraries.Count > 0) this.AnalizeInputLibraries(lib.InputLibraries, LogMessages);
                }
                #endregion
            }
        }
Ejemplo n.º 6
0
        public void Convert(string ProjectPath)
        {
            using (ProjectCollection LocalProjColl = new ProjectCollection())
            {
                Project MSBProj = LocalProjColl.LoadProject(PK.Wrapper.ExpandEnvVars(ProjectPath, ""));

                ARMCCPath = MSBProj.GetPropertyValue("CC").ToLower();
                ARMASMPath = MSBProj.GetPropertyValue("AS").ToLower();
                ARMLINKPath = MSBProj.GetPropertyValue("LINK").ToLower();
                ARMARPath = MSBProj.GetPropertyValue("AR").ToLower();
                ARMFROMELFPath = MSBProj.GetPropertyValue("FromELF").ToLower();
            }

            PKParser.Arg.PKArgParser ArgParser = new PKParser.Arg.PKArgParser();

            int index = 0;

            Link Link = new Link("Link", null);

            Link.LogEvent += new MessagesParsesHelper.Link.LogEventDelegate(Link_LogEvent);

            OnLog(new GeneratingLogMessage("", GeneratingLogMessage.WORK_TYPE.CREATE_PROJECT_TREE, GeneratingLogMessage.WORK_STATE.START));

            foreach (LogQueueItem item in LogQueue.Values)
            {
                index++;
                OnLog(new GeneratingLogMessage(KeilWizardStrings.IDS_ANALYSE_LINKS, GeneratingLogMessage.WORK_TYPE.CREATE_PROJECT_TREE, GeneratingLogMessage.WORK_STATE.WORKING, (int)((index * 100) / LogQueue.Values.Count)));

                string s = ArgParser.GetUtil(item.Message);
                if (s == null) continue;
                if (String.Compare(ARMLINKPath, s, StringComparison.InvariantCultureIgnoreCase) == 0)
                {
                    //ArmLink
                    ARMLink.Add(ARMLink.Count + 1, new ParCollContainer(ArgParser.Add(item.Message), item.Message, item.ProjectBuildContext, item.CurrentDir));
                }
                else if (String.Compare(ARMCCPath, s, StringComparison.InvariantCultureIgnoreCase) == 0)
                {
                    //ArmCC 
                    ARMCCandARMASM.Add(ARMCCandARMASM.Count + 1, new ParCollContainer(ArgParser.Add(item.Message), item.Message, item.ProjectBuildContext, item.CurrentDir));
                }
                else if (String.Compare(ARMASMPath, s, StringComparison.InvariantCultureIgnoreCase) == 0)
                {
                    //ArmAsm
                    ARMCCandARMASM.Add(ARMCCandARMASM.Count + 1, new ParCollContainer(ArgParser.Add(item.Message), item.Message, item.ProjectBuildContext, item.CurrentDir));
                }
                else if (String.Compare(ARMARPath, s, StringComparison.InvariantCultureIgnoreCase) == 0)
                {
                    //ArmAr
                    ARMAR.Add(ARMAR.Count + 1, new ParCollContainer(ArgParser.Add(item.Message), item.Message, item.ProjectBuildContext, item.CurrentDir));
                }
                else if (String.Compare(ARMFROMELFPath, s, StringComparison.InvariantCultureIgnoreCase) == 0)
                {
                    //FROMElf
                    FROMELF.Add(FROMELF.Count + 1, new ParCollContainer(ArgParser.Add(item.Message), item.Message, item.ProjectBuildContext, item.CurrentDir));
                }
            }

            ArgParser.Clear();

            //Construct project tree

            ParCollContainer container = ARMLink.Values[ARMLink.Values.Count - 1];
            if (container.ParamCollection == null) throw new MessagesParserException(KeilWizardStrings.IDS_ERROR_CANT_PASRSE_LINK);
            Link.ParamCollection = container.ParamCollection;

            string LIB_EXT = string.Empty;
            string OBJ_EXT = string.Empty;

            using (ProjectCollection LocalProjColl = new ProjectCollection())
            {
                Project MSBProj = LocalProjColl.LoadProject(container.ProjectBuildContext[container.ProjectBuildContext.Count - 1]);

                LIB_EXT = MSBProj.GetPropertyValue("LIB_EXT");
                OBJ_EXT = MSBProj.GetPropertyValue("OBJ_EXT");
            }

            foreach (ArgCollection arg in container.ParamCollection.Values)
            {
                if (arg.Name == "--output")
                {
                    Link.Name = arg[0];
                }
            }

            foreach (string file in container.ParamCollection.Files.Values)
            {
                RequiredLibrary lib = null;
                RequiredObject obj = null;

                if (Path.GetExtension(file).ToLower() == "." + LIB_EXT.ToLower())
                {
                    lib = new RequiredLibrary(file, Link);
                    Link.InputLibraries.Add(Link.InputLibraries.Count + 1, lib);
                }

                if (Path.GetExtension(file).ToLower() == "." + OBJ_EXT.ToLower())
                {
                    obj = new RequiredObject(file, Link);
                    Link.InputObjects.Add(Link.InputObjects.Count + 1, obj);
                }
                if (lib != null) Link.AllInputs.Add(Link.AllInputs.Count + 1, lib);
                if (obj != null) Link.AllInputs.Add(Link.AllInputs.Count + 1, obj);
            }
            OnLog(new GeneratingLogMessage(KeilWizardStrings.IDS_ANALYSE_LINKS, GeneratingLogMessage.WORK_TYPE.CREATE_PROJECT_TREE, GeneratingLogMessage.WORK_STATE.WORKING, 100));
            System.Threading.Thread.Sleep(sleeptime);



            //using (StreamWriter outfile =
            //            new StreamWriter(Path.GetFileNameWithoutExtension(Link.Name) + ".input"))
            //{
            //    outfile.WriteLine(PK.Wrapper.Solution.ProjectPath);
            //    outfile.WriteLine(uVisionProjectPath);
            //    outfile.WriteLine(ProjectPath);                

            //    foreach (ArgCollection arg in Link.ParamCollection.Values)
            //    {
            //        if (arg.Name == "--scatter")
            //            outfile.WriteLine(arg[0]);
            //    }
            //    outfile.WriteLine(LogQueue.Values.Count);
            //    foreach (LogQueueItem item in LogQueue.Values)
            //    {
            //        outfile.WriteLine(item.Message);
            //        outfile.WriteLine(item.CurrentDir);
            //        outfile.WriteLine(item.ProjectBuildContext.Count);
            //        foreach (string s in item.ProjectBuildContext)
            //        {
            //            outfile.WriteLine(s);
            //        }
            //    }
            //}



            ArgParser.Clear();
            //Analysing libraries
            this.AnalizeInputLibraries(Link.InputLibraries, LogQueue.Values);

            //Checking Crypto.Lib
            this.CheckCryptoLib(Link.InputLibraries, LogQueue.Values);

            //Checking Sockets Libs
            this.CheckSocketsLibs(Link.InputLibraries, LogQueue.Values);            

            //Analysing Files
            SortedList<int, RequiredObject> ReqObjs = Link.GetAllRequiredObjects();
            this.AnalizeInputObjects(ReqObjs);//, LogQueue.Values);

            if (!Link.CheckItems())
            {
                throw new MessagesParserException(KeilWizardStrings.IDS_ERROR_FAIL_LINK_ANALYSE);
            }

            OnLog(new GeneratingLogMessage("", GeneratingLogMessage.WORK_TYPE.CREATE_PROJECT_TREE, GeneratingLogMessage.WORK_STATE.DONE));
            OnLog(new GeneratingLogMessage("", GeneratingLogMessage.WORK_TYPE.CREATE_FILE_LIST, GeneratingLogMessage.WORK_STATE.START));
            index = 0;
            //Collects required files
            List<RequiredLibrary> ReqLib = Link.GetAllSubRequiredLibraries();

            foreach (RequiredObject obj in ReqObjs.Values)
            {
                index++;
                OnLog(new GeneratingLogMessage(KeilWizardStrings.IDS_CREATING_FILE_LIST, GeneratingLogMessage.WORK_TYPE.CREATE_FILE_LIST, GeneratingLogMessage.WORK_STATE.WORKING, (int)((index * 100) / (ReqObjs.Values.Count + ReqLib.Count))));
                this.AddObjFile(obj);
            }
            foreach (RequiredLibrary lib in ReqLib)
            {
                index++;
                OnLog(new GeneratingLogMessage(KeilWizardStrings.IDS_CREATING_FILE_LIST, GeneratingLogMessage.WORK_TYPE.CREATE_FILE_LIST, GeneratingLogMessage.WORK_STATE.WORKING, (int)((index * 100) / (ReqObjs.Values.Count + ReqLib.Count))));
                uVisionProject.AddFile(lib.OutputFileuVision, Path.GetFileNameWithoutExtension(lib.Parent.Name));
            }

            //Sorting groups
            uVisionProject.SortGroups();

            foreach (RequiredLibrary lib in Link.InputLibraries.Values)
            {
                uVisionProject.AddFile(lib.OutputFileuVision, Path.GetFileNameWithoutExtension(Link.Name));
            }
            OnLog(new GeneratingLogMessage(KeilWizardStrings.IDS_CREATING_FILE_LIST, GeneratingLogMessage.WORK_TYPE.CREATE_FILE_LIST, GeneratingLogMessage.WORK_STATE.WORKING, 100));
            System.Threading.Thread.Sleep(sleeptime);
            OnLog(new GeneratingLogMessage("", GeneratingLogMessage.WORK_TYPE.CREATE_FILE_LIST, GeneratingLogMessage.WORK_STATE.DONE));
            OnLog(new GeneratingLogMessage("", GeneratingLogMessage.WORK_TYPE.CREATE_TARGETS, GeneratingLogMessage.WORK_STATE.START));
            //Create targets
            index = 0;
            foreach (RequiredLibrary lib in Link.InputLibraries.Values)
            {
                index++;
                OnLog(new GeneratingLogMessage(KeilWizardStrings.IDS_CREATING_TARGETS, GeneratingLogMessage.WORK_TYPE.CREATE_TARGETS, GeneratingLogMessage.WORK_STATE.WORKING, (int)((index * 100) / (Link.InputLibraries.Count))));

                this.CreateLibraryTartet(lib);
            }

            this.CreateLinkTarget(Link);//, LogQueue.Values);

            OnLog(new GeneratingLogMessage(KeilWizardStrings.IDS_CREATING_TARGETS, GeneratingLogMessage.WORK_TYPE.CREATE_TARGETS, GeneratingLogMessage.WORK_STATE.WORKING, 100));
            System.Threading.Thread.Sleep(sleeptime);
            OnLog(new GeneratingLogMessage("", GeneratingLogMessage.WORK_TYPE.CREATE_TARGETS, GeneratingLogMessage.WORK_STATE.DONE));

            //using (StreamWriter outfile = new StreamWriter(Path.GetFileNameWithoutExtension(Link.Name) + ".result"))
            //{
            //    List<string> strs = uVisionProject.GetAllProjectStrings();
            //    foreach (string s in strs)
            //    {
            //        outfile.WriteLine(s);
            //    }
            //}
        }
Ejemplo n.º 7
0
        private void AnalizeInputLibraries(SortedList<int, RequiredLibrary> Libraryes, IList<LogQueueItem> LogMessages)
        {
            //PKParser.Arg.PKArgParser ArgParser = new PKParser.Arg.PKArgParser();
            int index = 0;
            foreach (RequiredLibrary lib in Libraryes.Values)
            {
                index++;
                OnLog(new GeneratingLogMessage(KeilWizardStrings.IDS_ANALYSE_LYBRARIES_LINKS, GeneratingLogMessage.WORK_TYPE.CREATE_PROJECT_TREE, GeneratingLogMessage.WORK_STATE.WORKING, (int)((index * 100) / Libraryes.Values.Count)));

                foreach (ParCollContainer container in ARMAR.Values)
                {
                    ParamCollection par = container.ParamCollection;
                    if (par == null) continue;

                    bool Found = false;

                    foreach (ArgCollection arg in par.Values)
                    {
                        if (arg.Tag == "archive")
                        {
                            if (String.Compare(Path.GetFileName(arg.Name), lib.Name, StringComparison.InvariantCultureIgnoreCase) == 0) Found = true;
                        }
                    }

                    if (!Found) continue;

                    lib.ConsoleString = container.Message;
                    lib.ParamCollection = par;
                    lib.BuildList.AddRange(container.ProjectBuildContext);
                    lib.OutputFileuVision = uVisionProjectPath + "\\" + uVisionTargetsPath + "\\" + Path.GetFileNameWithoutExtension(lib.Name) + "\\" + Path.GetFileName(lib.Name);

                    string LIB_EXT = string.Empty;
                    string OBJ_EXT = string.Empty;

                    using (ProjectCollection LocalProjColl = new ProjectCollection())
                    {
                        Project MSBProj = LocalProjColl.LoadProject(container.ProjectBuildContext[container.ProjectBuildContext.Count - 1]);
                        LIB_EXT = MSBProj.GetPropertyValue("LIB_EXT");
                        OBJ_EXT = MSBProj.GetPropertyValue("OBJ_EXT");
                    }

                    foreach (string file in par.Files.Values)
                    {
                        RequiredLibrary libr = null;
                        RequiredObject obj = null;

                        if (Path.GetExtension(file).ToLower() == "." + LIB_EXT.ToLower())
                        {
                            libr = new RequiredLibrary(file, lib);
                            lib.InputLibraries.Add(lib.InputLibraries.Count + 1, libr);
                        }

                        if (Path.GetExtension(file).ToLower() == "." + OBJ_EXT.ToLower())
                        {
                            obj = new RequiredObject(file, lib);
                            lib.InputObjects.Add(lib.InputObjects.Count + 1, obj);
                        }
                        if (libr != null) lib.AllInputs.Add(lib.AllInputs.Count + 1, libr);
                        if (obj != null) lib.AllInputs.Add(lib.AllInputs.Count + 1, obj);
                    }

                    foreach (ArgCollection arg in par.Values)
                    {
                        switch (arg.Tag)
                        {
                            case "options":
                                if (arg.Count > 0)
                                    foreach (string s in arg)
                                    {
                                        lib.OptionsString.Add(arg.Name + " " + s);
                                    }
                                else
                                    lib.OptionsString.Add(arg.Name);
                                break;
                            case "archive":
                                lib.OutputFileMSBuild = arg.Name;
                                break;
                        }
                    }
                }
                if (lib.InputLibraries.Count > 0) this.AnalizeInputLibraries(lib.InputLibraries, LogMessages);
            }
            OnLog(new GeneratingLogMessage(KeilWizardStrings.IDS_ANALYSE_LYBRARIES_LINKS, GeneratingLogMessage.WORK_TYPE.CREATE_PROJECT_TREE, GeneratingLogMessage.WORK_STATE.WORKING, 100));
            System.Threading.Thread.Sleep(sleeptime);
        }
Ejemplo n.º 8
0
        private SortedList<int, RequiredObject> GetLibraryObjects(RequiredLibrary lib)
        {
            SortedList<int, RequiredObject> result = new SortedList<int, RequiredObject>();

            foreach (RequiredObject o in lib.InputObjects.Values)
            {
                result.Add(result.Count + 1, o);
            }

            foreach (RequiredLibrary reqlib in lib.InputLibraries.Values)
            {
                SortedList<int, RequiredObject> tmplist = this.GetLibraryObjects(reqlib);

                foreach (RequiredObject o in tmplist.Values)
                {
                    result.Add(result.Count + 1, o);
                }
            }

            return result;
        }