private void AddHFiles(string group, List<MFBuildFile> list, uVisionProject project) { foreach (MFBuildFile mfbf in list) { string path = this.ExpandPath(mfbf.FullPath); if (System.IO.File.Exists(path)) { if (string.Compare(System.IO.Path.GetExtension(path), ".h", StringComparison.InvariantCultureIgnoreCase) == 0) project.AddFile(path, group); } else { //throw new Exception("File missing"); } } }
//private void TargetPropertiesGeneralization(Target target) //{ // List<PKStudio.uVision.Project.FileOptions> filesList = new List<uVision.Project.FileOptions>(); // int CFilesCount = 0; // int AsmFilesCount = 0; // List<string> IncludeList = new List<string>(); // List<string> DefineCList = new List<string>(); // List<string> DefineAsmList = new List<string>(); // List<string> MiscAsmList = new List<string>(); // List<string> MiscCList = new List<string>(); // //int splitSectionsCount = 0; // //int littleendCount = 0; // //int cppCount = 0; // //int OptimizeCount = 0; // //string DefaultOptLevel = ""; // //int DiagSupressCount = 0; // //List<string> DefaultDiagSupress = new List<string>(); // foreach (PKStudio.uVision.Project.FileOptions fo in target.FilesOpton) // { // if (fo.IncBld == THREE_STATE_BOOL.ENABLED) // { // filesList.Add(fo); // if (fo.File.Type == uVision.Project.File.FILE_TYPE.ASM_FILE) // { // AsmFilesCount++; // foreach (string s in fo.Define) // { // if (!DefineAsmList.Contains(s)) DefineAsmList.Add(s); // } // foreach (string s in fo.Misc) // { // if (!MiscAsmList.Contains(s)) MiscAsmList.Add(s); // } // } // if ((fo.File.Type == uVision.Project.File.FILE_TYPE.C_FILE) || (fo.File.Type == uVision.Project.File.FILE_TYPE.CPP_FILE)) // { // CFilesCount++; // foreach (string s in fo.Define) // { // if (!DefineCList.Contains(s)) DefineCList.Add(s); // } // foreach (string s in fo.Misc) // { // if (!MiscCList.Contains(s)) MiscCList.Add(s); // } // } // foreach (string s in fo.Include) // { // if (!IncludeList.Contains(s)) IncludeList.Add(s); // } // } // } // //includes // #region Includes // foreach (string path in IncludeList) // { // int ARMCIncludeOccurrences = 0; // int ARMAIncludeOccurrences = 0; // foreach (PKStudio.uVision.Project.FileOptions fo in target.FilesOpton) // { // foreach (string s in fo.Include) // { // if (s == path) // { // if ((fo.File.Type == uVision.Project.File.FILE_TYPE.C_FILE) || (fo.File.Type == uVision.Project.File.FILE_TYPE.CPP_FILE)) // ARMCIncludeOccurrences++; // if (fo.File.Type == uVision.Project.File.FILE_TYPE.ASM_FILE) // ARMAIncludeOccurrences++; // } // } // } // if ((ARMCIncludeOccurrences == CFilesCount) && (CFilesCount > 0)) // { // target.Options.ADSCINCD.Add(path); // foreach (PKStudio.uVision.Project.FileOptions fo in filesList) // { // fo.Include.Remove(path); // } // } // if ((ARMAIncludeOccurrences == AsmFilesCount) && (AsmFilesCount > 0)) // { // target.Options.ADSAINCD.Add(path); // foreach (PKStudio.uVision.Project.FileOptions fo in filesList) // { // fo.Include.Remove(path); // } // } // } // #endregion // #region Defines C // foreach (string def in DefineCList) // { // int ARMCOccurrences = 0; // foreach (PKStudio.uVision.Project.FileOptions fo in target.FilesOpton) // { // if ((fo.File.Type == uVision.Project.File.FILE_TYPE.C_FILE) || (fo.File.Type == uVision.Project.File.FILE_TYPE.CPP_FILE)) // { // foreach (string s in fo.Define) // { // if (s == def) // { // ARMCOccurrences++; // } // } // } // } // if ((ARMCOccurrences == CFilesCount) && (CFilesCount > 0)) // { // target.Options.ADSCDEFN.Add(def); // foreach (PKStudio.uVision.Project.FileOptions fo in filesList) // { // if ((fo.File.Type == uVision.Project.File.FILE_TYPE.C_FILE) || (fo.File.Type == uVision.Project.File.FILE_TYPE.CPP_FILE)) // { // fo.Define.Remove(def); // } // } // } // } // #endregion // #region Misc C // foreach (string misc in MiscCList) // { // int ARMCOccurrences = 0; // foreach (PKStudio.uVision.Project.FileOptions fo in target.FilesOpton) // { // if ((fo.File.Type == uVision.Project.File.FILE_TYPE.C_FILE) || (fo.File.Type == uVision.Project.File.FILE_TYPE.CPP_FILE)) // { // foreach (string s in fo.Misc) // { // if (s == misc) // { // ARMCOccurrences++; // } // } // } // } // if ((ARMCOccurrences == CFilesCount) && (CFilesCount > 0)) // { // target.Options.ADSCMISC.Add(misc); // foreach (PKStudio.uVision.Project.FileOptions fo in filesList) // { // if ((fo.File.Type == uVision.Project.File.FILE_TYPE.C_FILE) || (fo.File.Type == uVision.Project.File.FILE_TYPE.CPP_FILE)) // { // fo.Misc.Remove(misc); // } // } // } // } // #endregion // #region Defines Asm // foreach (string def in DefineAsmList) // { // int Occurrences = 0; // foreach (PKStudio.uVision.Project.FileOptions fo in target.FilesOpton) // { // if (fo.File.Type == uVision.Project.File.FILE_TYPE.ASM_FILE) // { // foreach (string s in fo.Define) // { // if (s == def) // { // Occurrences++; // } // } // } // } // if ((Occurrences == AsmFilesCount) && (AsmFilesCount > 0)) // { // target.Options.ADSADEFN.Add(def); // foreach (PKStudio.uVision.Project.FileOptions fo in filesList) // { // if (fo.File.Type == uVision.Project.File.FILE_TYPE.ASM_FILE) // { // fo.Define.Remove(def); // } // } // } // } // #endregion // #region Misc Asm // foreach (string misc in MiscAsmList) // { // int Occurrences = 0; // foreach (PKStudio.uVision.Project.FileOptions fo in target.FilesOpton) // { // if (fo.File.Type == uVision.Project.File.FILE_TYPE.ASM_FILE) // { // foreach (string s in fo.Misc) // { // if (s == misc) // { // Occurrences++; // } // } // } // } // if ((Occurrences == AsmFilesCount) && (AsmFilesCount > 0)) // { // target.Options.ADSAMISC.Add(misc); // foreach (PKStudio.uVision.Project.FileOptions fo in filesList) // { // if (fo.File.Type == uVision.Project.File.FILE_TYPE.ASM_FILE) // { // fo.Misc.Remove(misc); // } // } // } // } // #endregion //} //private void AnalizeLinkTarget(SortedList<int, LogQueueItem> consolecalls, Target target) //{ // //Установка опций по умолчанию // target.SeTLPC2478DefaultOptions(); // 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.OCR_RVCT = "1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,8,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,1,0,0,0,0,224,127,0,64,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 = ""; // //Исключаем все файлы из построения // foreach (PKStudio.uVision.Project.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.uVision.Project.FileOptions fileopt = new uVision.Project.FileOptions(f); // fileopt.IncBld = THREE_STATE_BOOL.DISABLED; // target.FilesOpton.Add(fileopt); // } // } // PKParser.Arg.PKArgParser parser = new PKArgParser(); // bool compileStarted = false; // bool compileFinished = false; // //string ObjDir = string.Empty; // foreach (LogQueueItem item in consolecalls.Values) // { // if (item.CurrentDir != null) Directory.SetCurrentDirectory(item.CurrentDir); // ParamCollection par = parser.Add(item.Message); // if (par == null) // { // if (!compileStarted) // { // //Команды до компиляции // //target.BeforeBuild.Add(item.Message); // } // else if (compileFinished) // { // //Команды после компиляции // //target.AfterBuild.Add(item.Message); // } // } // else // { // switch (par.Name) // { // case "armcc.exe": // case "armasm.exe": // compileStarted = true; // break; // case "armar.exe": // break; // case "armlink.exe": // compileStarted = true; // compileFinished = true; // //Смотрим на наличие Crypto.lib // foreach (ArgCollection arg in par.Values) // { // //if (arg.Tag == "input-file-list") // //{ // // if (arg.Name.ToLower().Contains("crypto.lib")) // // { // // foreach (ArgCollection arg2 in par.Values) // // { // // if (arg2.Name == "--userlibpath") // // { // // foreach (string str in arg2) // // { // // string s = "IF EXIST " + str + "\\crypto_stub.lib " + "copy /Y " + str + "\\crypto_stub.lib " + str + "\\crypto.lib"; // // if (!target.BeforeBuild.Contains(s)) // // target.BeforeBuild.Add(s); // // } // // } // // } // // } // //} // //if ((arg.Name == "--symdefs") || (arg.Name == "--list") || (arg.Name == "--scatter") || (arg.Name == "--output")) // //{ // // string s = string.Empty; // // s = "IF NOT EXIST " + Path.GetDirectoryName(arg[0]) + " md " + Path.GetDirectoryName(arg[0]); // // if (!target.BeforeBuild.Contains(s)) // // target.BeforeBuild.Add(s); // //} // if (arg.Name == "--output") // { // target.Options.OutDir = Path.GetDirectoryName(arg[0]) + "\\"; // target.Options.OutName = Path.GetFileNameWithoutExtension(arg[0]); // } // switch (arg.Name) // { // //case "--output": // // target.Options.OutDir = Path.GetDirectoryName(arg[0]) + "\\"; // // target.Options.OutName = Path.GetFileNameWithoutExtension(arg[0]); // // break; // //case "--scatter": // // target.Options.ADSLDSC = arg[0]; // // break; // case "--userlibpath": // //foreach (string s in arg) // //{ // // string str = arg.Name; // // str += " " + s; // // target.Options.ADSLDMC.Insert(0, str); // //} // break; // default: // string strs = arg.Name; // foreach (string s in arg) // { // strs += " " + s; // } // if (arg.Tag == "input-file-list") // { // if (Path.GetDirectoryName(strs) != string.Empty) // { // foreach (ObjectListItem OLI in ObjectList) // { // if (strs == OLI.MSBuildPath) // target.Options.ADSLDMC.Add(OLI.KeilPath); // } // } // else // target.Options.ADSLDMC.Add(Path.GetFileName(strs)); // } // else // target.Options.ADSLDMC.Insert(0, strs); // break; // } // } // //target.AfterBuild.Add(item.Message); // break; // default: // break; // } // } // } // foreach (Target t in uVisionProject.TargetList.Values) // { // target.Options.ADSLDMC.Insert(0, "--userlibpath " + uVisionProjectPath + t.Options.OutDir.Replace(".", "")); // } // target.Name = "Link"; // 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"; // } //} public void NewProject(string ProjectPath) { LogQueue.Clear(); uVisionProject = new uVisionProject(); ProjectCollection LocalProjColl = new ProjectCollection(); Project MSBProj = LocalProjColl.LoadProject(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(); }