FindFileOptions() public method

public FindFileOptions ( string path ) : FileOptions
path string
return FileOptions
        private void AddCompileFile(RequiredObject obj, Target target)
        {
            string DefaultWorkingDir = Directory.GetCurrentDirectory();
            Directory.SetCurrentDirectory(obj.CurrentDir);
            foreach (string path in obj.ParamCollection.Files.Values)
            {
                PKStudio.Tools.uVisionGenerator.Classes.uvProjectClasses.FileOptions fileOpt = target.FindFileOptions(Path.GetFullPath(ExpandPath(path)));
                if (fileOpt == null) throw new MessagesParserException(KeilWizardStrings.IDS_ERROR_INTERNAL + " " + path + ": " + KeilWizardStrings.IDS_ERROR_CANT_FIND_COMPILE_FILE_OPTIONS);


                fileOpt.IncBld = THREE_STATE_BOOL.ENABLED;

                foreach (ArgCollection arg in obj.ParamCollection.Values)
                {
                    if (arg.Tag != "options") continue;
                    switch (arg.Name)
                    {
                        case "-I":
                            foreach (string include in arg)
                            {
                                fileOpt.Include.Add(include);
                            }
                            break;
                        case "-D":

                            foreach (string def in arg)
                            {
                                if (!def.Contains("="))
                                    fileOpt.Define.Add(def);
                                else
                                    fileOpt.Misc.Add("-D" + def);
                            }

                            break;
                        case "--PD":
                            foreach (string def in arg)
                            {
                                if (fileOpt.File.Type == PKStudio.Tools.uVisionGenerator.Classes.uvProjectClasses.File.FILE_TYPE.ASM_FILE)
                                    fileOpt.Misc.Add("--PD " + def);
                            }
                            break;
                        case "--split_sections":
                            fileOpt.ADSCCFLG.One_EFL_Section_per_Function = THREE_STATE_BOOL.ENABLED;
                            break;
                        //case "--fpu":
                        //    fileOpt.Misc.Add("--fpu " + arg[0]);
                        //    break;
                        case "--littleend":
                            fileOpt.Misc.Add("--littleend");
                            break;
                        case "-c":
                            break;
                        case "--cpp":
                            fileOpt.Misc.Add("--cpp");
                            break;
                        case "-O":
                            OPTIMIZATION tmp = OPTIMIZATION.Default;
                            switch (arg[0])
                            {
                                case "0":
                                    tmp = OPTIMIZATION.Level0;
                                    break;
                                case "1":
                                    tmp = OPTIMIZATION.Level1;
                                    break;
                                case "2":
                                    tmp = OPTIMIZATION.Level2;
                                    break;
                                case "3":
                                    tmp = OPTIMIZATION.Level3;
                                    break;
                                default:
                                    break;
                            }
                            fileOpt.ADSCCFLG.Optimisation = tmp;
                            break;
                        case "--diag_suppress":
                            foreach (string item in arg)
                            {
                                //if (!target.Options.ADSCMISC.Contains("--diag_suppress " + item))
                                //{
                                fileOpt.Misc.Add("--diag_suppress " + item);
                                //}
                            }

                            break;
                        //Ignored. uVision IDE sets it by default
                        case "--device":
                            break;
                        //Special process for this param
                        case "-o":
                            //obj.OutputFileuVision = uVisionProjectPath + target.Options.OutDir.Replace(".", "") + Path.GetFileNameWithoutExtension(arg[0]) + ".o ";
                            break;
                        case "--LIST":
                        case "--list":
                            //s = "IF NOT EXIST " + Path.GetDirectoryName(arg[0]) + " md " + Path.GetDirectoryName(arg[0]);
                            //if (!target.BeforeBuild.Contains(s))
                            //    target.BeforeBuild.Add(s);
                            break;
                        default:
                            string str = arg.Name;
                            foreach (string item in arg)
                            {
                                str += " " + item;
                            }
                            fileOpt.Misc.Add(str);
                            break;
                    }
                }
            }
            Directory.SetCurrentDirectory(DefaultWorkingDir);
        }
        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";
            }
        }
        private void CreateLinkTarget(Link link)//, IList<LogQueueItem> messages)
        {
            Target target = new Target(uVisionProject.DefaultOptions);
            //Setting default options
            //target.SeTLPC2478DefaultOptions();

            target.Name = Path.GetFileNameWithoutExtension(link.Name);

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

            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.ADSLDFG = "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0";

            target.Options.ADSLDTA = "";
            target.Options.ADSLDDA = "";
            target.Options.Debug = "1";
            target.Options.Browse = "1";


            //Exclude files from building
            foreach (PKStudio.Tools.uVisionGenerator.Classes.uvProjectClasses.File f in uVisionProject.FileList.Values)
            {
                //if ((f.Type == uVision.Project.File.FILE_TYPE.C_FILE) || (f.Type == uVision.Project.File.FILE_TYPE.CPP_FILE) || (f.Type == uVision.Project.File.FILE_TYPE.ASM_FILE))
                //{
                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);
                //}
            }

            target.Options.OutDir = Path.GetDirectoryName(link.OutputFileMSBuild) + "\\";
            target.Options.OutName = Path.GetFileNameWithoutExtension(link.OutputFileMSBuild);
            link.OutputFileuVision = link.OutputFileMSBuild;

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


            foreach (RequiredLibrary lib in link.InputLibraries.Values)
            {
                PKStudio.Tools.uVisionGenerator.Classes.uvProjectClasses.FileOptions fileOpt = target.FindFileOptions(lib.OutputFileuVision);
                fileOpt.IncBld = THREE_STATE_BOOL.ENABLED;
            }

            //string LinkString = ARMLINKPath;

            foreach (ArgCollection arg in link.ParamCollection.Values)
            {
                if (arg.Tag == "options")
                {
                    switch (arg.Name)
                    {
                        //no need process this because all paths will be contained in file list
                        case "--userlibpath":
                            break;
                        case "--scatter":
                            //target.Options.ADSLDSC = arg[0];
                            target.Options.ADSLDSC = uVisionProject.ProjectPath + @"\" + Path.GetFileName(arg[0]);
                            string line;

                            using (StreamReader infile = new StreamReader(arg[0]))
                            {
                                while ((line = infile.ReadLine()) != null)
                                {
                                    uVisionProject.Scatter.Add(uVisionProject.Scatter.Count + 1, line);
                                }

                            }
                            //uVisionProject
                            break;
                        case "--device":
                            break;
                        case "--output":
                            break;
                        default:
                            if (arg.Count > 0)
                            {
                                foreach (string s in arg)
                                {
                                    //LinkString += " " + arg.Name + " " + s;
                                    target.Options.ADSLDMC.Add(arg.Name + " " + s);
                                }
                            }
                            //else LinkString += " " + arg.Name;
                            else target.Options.ADSLDMC.Add(arg.Name);
                            break;
                    }
                }
            }

            //foreach (BuildBase bb in link.AllInputs.Values)
            //{
            //    LinkString += " " + bb.OutputFileuVision;
            //}

            //target.AfterBuild.Add(LinkString);

            //PKArgParser ArgParser = new PKArgParser();

            //Adds fromelf
            foreach (ParCollContainer container in FROMELF.Values)
            {
                if (container.Message.ToLower().Contains(link.OutputFileMSBuild.ToLower()))
                {
                    target.AfterBuild.Add(container.Message);
                }
            }

            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";
            }

        }