Exemplo n.º 1
0
        private void CheckCryptoLib(SortedList<int, RequiredLibrary> Libraryes, IList<LogQueueItem> LogMessages)
        {
            PKParser.Arg.PKArgParser ArgParser = new PKParser.Arg.PKArgParser();

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

                    foreach (LogQueueItem item in LogMessages)
                    {
                        if (item.Message.ToLower().Contains(ARMARPath))
                        {
                            ParamCollection par = ArgParser.Add(item.Message);
                            if (par == null) continue;

                            bool Found = false;

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

                            if (!Found) continue;

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

                            ProjectCollection LocalProjColl = new ProjectCollection();
                            Project MSBProj = LocalProjColl.LoadProject(item.ProjectBuildContext[item.ProjectBuildContext.Count - 1]);
                            string LIB_EXT = MSBProj.GetPropertyValue("LIB_EXT");
                            string 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);
                }
            }
        }
Exemplo n.º 2
0
        private void CreateLibraryTartet(RequiredLibrary lib)
        {
            Target target = new Target();
            //Установка опций по умолчанию
            target.SeTLPC2478DefaultOptions();

            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 = uVision.Project.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";


            //Исключаем все файлы из построения
            foreach (PKStudio.uVision.Project.File f in uVisionProject.FileList.Values)
            {
                PKStudio.uVision.Project.FileOptions fileopt = new uVision.Project.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.uVision.Project.FileOptions fileOpt = target.FindFileOptions(reqlib.OutputFileuVision);
                if (fileOpt == null) throw new Exception("Can't find lib file options");
                fileOpt.IncBld = THREE_STATE_BOOL.ENABLED;
                this.CreateLibraryTartet(reqlib);
            }

            target.Num = uVisionProject.TargetList.Count + 1;
            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";
            }
        }
Exemplo n.º 3
0
        void m_worker_DoWork(object sender, DoWorkEventArgs e)
        {

            //if (Directory.Exists(uVisionProjectPath)) Directory.Delete(uVisionProjectPath, true);

            OnLogText("start analize");

            //ObjectList.Clear();

            Directory.CreateDirectory(uVisionProjectPath);

            WorkerParams pars = (WorkerParams)e.Argument;

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

            //string DefaultWorkingDir = Directory.GetCurrentDirectory();

            //List<UsedItem> LibList = new List<UsedItem>();
            //List<UsedItem> SourceList = new List<UsedItem>();

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

            //Собираем дерево проекта

            foreach (LogQueueItem item in pars.messages.Values)
            {
                if (item.Message.ToLower().Contains(ARMLINKPath))
                {
                    Link.ConsoleString = item.Message;
                    ParamCollection par = ArgParser.Add(item.Message);
                    if (par == null) throw new Exception(KeilWizardStrings);
                    Link.ParamCollection = par;

                    ProjectCollection LocalProjColl = new ProjectCollection();
                    Project MSBProj = LocalProjColl.LoadProject(item.ProjectBuildContext[item.ProjectBuildContext.Count - 1]);
                    string LIB_EXT = MSBProj.GetPropertyValue("LIB_EXT");
                    string OBJ_EXT = MSBProj.GetPropertyValue("OBJ_EXT");

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

                    foreach (string file in par.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);
                    }
                }
            }
            ArgParser.Clear();
            //Идем по требуемым библиотекам
            this.AnalizeInputLibraries(Link.InputLibraries, pars.messages.Values);

            //Проверка Crypto.Lib
            this.CheckCryptoLib(Link.InputLibraries, pars.messages.Values);

            //Идем по всем требуемым файлам
            SortedList<int, RequiredObject> ReqObjs = Link.GetAllRequiredObjects();
            this.AnalizeInputObjects(ReqObjs, pars.messages.Values);

            if (!Link.CheckItems())
            {
                throw new Exception("Not all Link Items founded");
            }


            //Собираем необходимые для проекта файлы
            List<RequiredLibrary> ReqLib = Link.GetAllSubRequiredLibraries();

            foreach (RequiredObject obj in ReqObjs.Values)
            {
                this.AddObjFile(obj);
            }
            foreach (RequiredLibrary lib in ReqLib)
            {
                uVisionProject.AddFile(lib.OutputFileuVision, Path.GetFileNameWithoutExtension(lib.Parent.Name));
            }

            //Сортируем группы
            uVisionProject.SortGroups();

            foreach (RequiredLibrary lib in Link.InputLibraries.Values)
            {
                uVisionProject.AddFile(lib.OutputFileuVision,Path.GetFileNameWithoutExtension(Link.Name));
            }

            //Создаем таргеты
            foreach (RequiredLibrary lib in Link.InputLibraries.Values)
            {
                if (lib.Name.ToLower().Contains("crypto"))
                {
                }
                this.CreateLibraryTartet(lib);
            }

            //foreach (RequiredObject obj in Link.InputObjects.Values)
            //{
            //    this.CreateObjectTartet(obj);
            //}

            this.CreateLinkTarget(Link, pars.messages.Values);

            //this.CreateBrowseTarget(Link);

            OnLogText("Writing files");
            ///ProjectFile
            List<string> resultstrings = uVisionProject.GetAllProjectStrings();

            using (StreamWriter outfile =
                    new StreamWriter(uVisionProjectPath + @"\generated.Uv2"))
            {
                foreach (string s in resultstrings)
                {
                    outfile.WriteLine(s);
                }

            }

            ///MultiProjectFile
            using (StreamWriter outfile =
                    new StreamWriter(uVisionProjectPath + @"\project.mpw"))
            {
                outfile.WriteLine("[WORKSPACE]\r");
                outfile.WriteLine(" MPW_NAME=\"WorkSpace\"\r");
                outfile.WriteLine(" Project=\".\\generated.Uv2\",A,X,B\r\r");
            }

            ///BatFiles
            //try
            //{
                if (Directory.Exists(uVisionProjectPath + "\\BatFiles\\Prebuild\\"))
                    Directory.Delete(uVisionProjectPath + "\\BatFiles\\Prebuild\\", true);

                if (Directory.Exists(uVisionProjectPath + "\\BatFiles\\Postbuild\\"))
                    Directory.Delete(uVisionProjectPath + "\\BatFiles\\Postbuild\\", true);

                Directory.CreateDirectory(uVisionProjectPath + "\\BatFiles\\Prebuild\\");

                Directory.CreateDirectory(uVisionProjectPath + "\\BatFiles\\Postbuild\\");
            //}
           // catch
            //{
            //}



            foreach (Target t in uVisionProject.TargetList.Values)
            {
                //PreBuild
                if (t.BeforeBuild.Count > 0)
                {
                    using (StreamWriter outfile =
                        new StreamWriter(uVisionProjectPath + "\\BatFiles\\Prebuild" + @"\" + t.Name + ".bat"))
                    {
                        foreach (string s in t.BeforeBuild)
                        {
                            outfile.WriteLine(s);
                        }

                    }
                }

                if (t.AfterBuild.Count > 0)
                {
                    using (StreamWriter outfile =
                        new StreamWriter(uVisionProjectPath + "\\BatFiles\\Postbuild" + @"\" + t.Name + ".bat"))
                    {
                        foreach (string s in t.AfterBuild)
                        {
                            outfile.WriteLine(s);
                        }

                    }
                }
            }

            OnLogText("Done");

            e.Result = resultstrings;
        }