private void AddHFiles(string group, List<BuildFileWrapper> list, uVisionProject project) { foreach (BuildFileWrapper 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"); } } }
public MessagesParser(uVisionProject UVProject, string path) { uVisionProject = UVProject; uVisionProjectPath = path; //this.m_worker = new BackgroundWorker(); //this.m_worker.DoWork += new DoWorkEventHandler(m_worker_DoWork); //this.m_worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(m_worker_RunWorkerCompleted); }
void m_worker_DoWork(object sender, DoWorkEventArgs e) { WorkerRunArgument argument = (WorkerRunArgument)e.Argument; this.OnLog(new GeneratingLogMessage("", GeneratingLogMessage.WORK_TYPE.CONVERT_SOLUTION, GeneratingLogMessage.WORK_STATE.START)); uVisionMultiProjectWorkspace uVisionMPW = new uVisionMultiProjectWorkspace(); uVisionMPW.Name = argument.ConvertConfig.Name; GeneratingLogMessage.WORK_TYPE workType = GeneratingLogMessage.WORK_TYPE.UNKNOWN; try { foreach (ConvertableMFProject proj in argument.ConvertConfig.ProjectList) { this.OnLog(new GeneratingLogMessage(proj.Project.Name.Trim(), GeneratingLogMessage.WORK_TYPE.CONVERT_PROJECT, GeneratingLogMessage.WORK_STATE.START)); UVProject = new uVisionProject(); UVProject.Name = proj.Project.Name.Trim(); UVProject.ProjectPath = config.SolutionPath + @"\" + UVProject.Name; UVProject.DefaultOptions = argument.ConvertConfig.Processor; string path = argument.ConvertConfig.SolutionPath + "\\" + proj.Project.Name.Trim(); MessagesParser mParser = new MessagesParser(UVProject, path); MessagesCollector logger = new MessagesCollector(mParser); logger.Verbosity = LoggerVerbosity.Diagnostic; logger.MSBuildProjectStartedEvent += new MessagesCollector.MSBuildProjectStartedEventDelegate(logger_MSBuildProjectStartedEvent); mParser.LogEvent += new MessagesParser.LogEventDelegate(mParser_LogEvent); //Run project building workType = GeneratingLogMessage.WORK_TYPE.BUILD_PROJECT; this.OnLog(new GeneratingLogMessage(uVisionGenerator.Wizard.KeilWizardStrings.IDS_BUILDING, workType, GeneratingLogMessage.WORK_STATE.START)); if (!StartMSBuild(proj, logger)) { //Cant't build project throw new KeilProjectGeneratorException(uVisionGenerator.Wizard.KeilWizardStrings.IDS_BUILD_ERROR); } this.OnLog(new GeneratingLogMessage(uVisionGenerator.Wizard.KeilWizardStrings.IDS_BUILDING, workType, GeneratingLogMessage.WORK_STATE.DONE)); System.Threading.Thread.Sleep(sleeptime); workType = GeneratingLogMessage.WORK_TYPE.CONVERT_PROJECT; mParser.Convert(proj.Project.ProjectPath); uVisionMPW.Projects.Add(UVProject); this.OnLog(new GeneratingLogMessage(proj.Project.Name.Trim(), GeneratingLogMessage.WORK_TYPE.CONVERT_PROJECT, GeneratingLogMessage.WORK_STATE.DONE)); System.Threading.Thread.Sleep(sleeptime); } workType = GeneratingLogMessage.WORK_TYPE.WRITING_FILES; this.OnLog(new GeneratingLogMessage("", GeneratingLogMessage.WORK_TYPE.WRITING_FILES, GeneratingLogMessage.WORK_STATE.START)); try { if (Directory.Exists(config.SolutionPath)) Directory.Delete(config.SolutionPath, true); Directory.CreateDirectory(config.SolutionPath); } catch { } int index = 0; foreach (uVisionProject proj in uVisionMPW.Projects) { index++; this.OnLog(new GeneratingLogMessage("", GeneratingLogMessage.WORK_TYPE.WRITING_FILES, GeneratingLogMessage.WORK_STATE.WORKING, (int)((index * 100) / uVisionMPW.Projects.Count))); string projpath = proj.ProjectPath; ///ProjectFile List<string> resultstrings = proj.AllProjectStrings; if (Directory.Exists(projpath)) Directory.Delete(projpath, true); Directory.CreateDirectory(projpath); using (StreamWriter outfile = new StreamWriter(projpath + @"\" + proj.Name + ".Uv2")) { foreach (string s in resultstrings) { outfile.WriteLine(s); } } ///Scatter file foreach (Target t in proj.TargetList.Values) { if (!string.IsNullOrEmpty(t.Options.ADSLDSC)) { using (StreamWriter outfile = new StreamWriter(t.Options.ADSLDSC)) { foreach (string s in proj.Scatter.Values) { outfile.WriteLine(s); } } } } ///BatFiles try { if (Directory.Exists(projpath + "\\BatFiles\\Prebuild\\")) Directory.Delete(projpath + "\\BatFiles\\Prebuild\\", true); if (Directory.Exists(projpath + "\\BatFiles\\Postbuild\\")) Directory.Delete(projpath + "\\BatFiles\\Postbuild\\", true); Directory.CreateDirectory(projpath + "\\BatFiles\\Prebuild\\"); Directory.CreateDirectory(projpath + "\\BatFiles\\Postbuild\\"); } catch { } foreach (Target t in proj.TargetList.Values) { //PreBuild if (t.BeforeBuild.Count > 0) { using (StreamWriter outfile = new StreamWriter(projpath + "\\BatFiles\\Prebuild" + @"\" + t.Name + ".bat")) { foreach (string s in t.BeforeBuild) { outfile.WriteLine(s); } } } //PostBuild if (t.AfterBuild.Count > 0) { using (StreamWriter outfile = new StreamWriter(projpath + "\\BatFiles\\Postbuild" + @"\" + t.Name + ".bat")) { foreach (string s in t.AfterBuild) { outfile.WriteLine(s); } } } } } ///MultiProjectFile using (StreamWriter outfile = new StreamWriter(config.SolutionPath + @"\" + uVisionMPW.Name + ".mpw")) { outfile.WriteLine("[WORKSPACE]\r"); outfile.WriteLine(" MPW_NAME=\"" + uVisionMPW.Name + "\"\r"); string s = string.Empty; for (int i = 0; i < uVisionMPW.Projects.Count; i++) { uVisionProject proj = uVisionMPW.Projects[i]; if (i == 0) s = " Project=\".\\" + proj.Name + "\\" + proj.Name + ".Uv2\",A\r\r"; else s = " Project=\".\\" + proj.Name + "\\" + proj.Name + ".Uv2\"\r\r"; outfile.WriteLine(s); } } config.Result = uVisionMPW; this.OnLog(new GeneratingLogMessage("", GeneratingLogMessage.WORK_TYPE.WRITING_FILES, GeneratingLogMessage.WORK_STATE.DONE)); this.OnLog(new GeneratingLogMessage("", GeneratingLogMessage.WORK_TYPE.CONVERT_SOLUTION, GeneratingLogMessage.WORK_STATE.DONE)); } catch (Exception ex) { this.OnLog(new GeneratingLogMessage(ex.Message, workType, GeneratingLogMessage.WORK_STATE.ERROR)); } }