public void ParseSolution() { //read the config xml var psolutionXml = new XmlDocument(); psolutionXml.Load(Options.SolutionXml); var fileName = Path.GetFileName(Options.SolutionXml); Console.WriteLine("Loaded the solution file : {0}", fileName); try { var solName = psolutionXml.GetElementsByTagName("PSolution")[0].Attributes.GetNamedItem("name").Value .ToLower(); var pprojects = psolutionXml.GetElementsByTagName("PProject"); foreach (XmlNode project in pprojects) { var projectInfo = new PProjectInfo { Name = project.Attributes.GetNamedItem("name").Value.ToLower(), outputDir = Path.GetFullPath(project.Attributes.GetNamedItem("outputdir").Value) }; var psources = project["Source"].ChildNodes; foreach (XmlNode pfile in psources) { projectInfo.psources.Add(pfile.InnerText); } var depends = project.SelectNodes("Depends"); foreach (XmlNode dproject in depends) { projectInfo.depends.Add(dproject.InnerText.ToLower()); } var plinkfiles = project["Link"]; if (plinkfiles != null) { foreach (XmlNode pfile in plinkfiles.ChildNodes) { projectInfo.testscripts.Add(pfile.InnerText); } } CurrentSolution.projects.Add(projectInfo); } CurrentSolution.name = solName; CurrentSolution.solutionDir = Path.GetDirectoryName(Path.GetFullPath(Options.SolutionXml)); } catch (Exception ex) { Console.WriteLine("Failed to parse the XML"); Console.WriteLine(ex.ToString()); } }
private void CompileProject(PProjectInfo project) { var compileArgs = new CommandLineOptions { inputFileNames = new List <string>(project.psources.Select(Path.GetFullPath).ToList()) }; //populate all dependencies var depFiles = (from depFile in project.depends let outDir = Path.GetFullPath(CurrentSolution.projects.First(x => x.Name == depFile).outputDir) select Path.Combine(outDir, depFile + ".4ml")).ToList(); compileArgs.dependencies = new List <string>(depFiles); compileArgs.shortFileNames = true; compileArgs.outputDir = project.outputDir; compileArgs.unitName = project.Name + ".4ml"; compileArgs.liveness = LivenessOption.None; compileArgs.compilerOutput = Options.Output; compileArgs.profile = true; var compileResult = false; var svc = new CompilerServiceClient(); if (Options.Relink && !Options.Rebuild) { compileResult = true; } else { // use separate process that contains pre-compiled P compiler. Console.WriteLine("=============================================================="); Console.WriteLine("=== Compiling project {0} ===", project.Name); compileResult = svc.Compile(new StandardOutput(), compileArgs); } if (!compileResult) { Environment.Exit(-1); } if (project.testscripts.Count > 0) { Console.WriteLine("=== Linking project {0} ===", project.Name); //start linking the project compileArgs.inputFileNames = new List <string>(project.testscripts.Select(Path.GetFullPath).ToList()); //populate all summary files compileArgs.dependencies.Add(Path.Combine(project.outputDir, project.Name + ".4ml")); svc.Link(new StandardOutput(), compileArgs); } Console.WriteLine("=============================================================="); }
public bool CheckIfCompileProject(PProjectInfo project) { var returnVal = false; var summaryFile = Path.Combine(project.outputDir, project.Name + ".4ml"); var allPSources = new List <string>(project.psources.Select(Path.GetFullPath).ToList()); var summaryFileWriteTime = File.GetLastWriteTime(summaryFile); foreach (var pfile in allPSources) { if (DateTime.Compare(summaryFileWriteTime, File.GetLastWriteTime(pfile)) <= 0) { returnVal = true; } } return(returnVal); }