private InternalBuildStep GetMainBuildStep() { InternalBuildStep step = (InternalBuildStep)CurrentConfig.Steps.FirstOrDefault(s => s is InternalBuildStep); if (step == null) { throw new ArgumentException("Missing main build step"); } return(step); }
public void ReadXML(XmlTextReader reader) { reader.MoveToNextElement(); if (reader.Name != "BuildSystem") { throw new ArgumentException("Invalid XML Format"); } string[] includeDirs = reader.GetAttribute("IncludeDirs").Split(';'); foreach (string include in includeDirs) { if (!string.IsNullOrEmpty(include)) { this.Project.IncludeDirs.Add(include); } } while (reader.MoveToNextElement()) { string configName = reader.Name; BuildConfig configToAdd = new BuildConfig(Project, configName); buildConfigs.Add(configToAdd); if (reader.IsEmptyElement) { continue; } reader.MoveToNextElement(); int count = Convert.ToInt32(reader.GetAttribute("Count")); string inputFile = reader.GetAttribute("InputFile"); switch (reader.Name) { case "ExternalBuildStep": string arguments = reader.GetAttribute("Arguments"); ExternalBuildStep exstep = new ExternalBuildStep(Project, count, inputFile, arguments); configToAdd.Steps.Add(exstep); break; case "InternalBuildStep": string outputFile = reader.GetAttribute("OutputFile"); StepType type = (StepType)Convert.ToInt16(reader.GetAttribute("StepType")); InternalBuildStep instep = new InternalBuildStep(Project, count, type, inputFile, outputFile); configToAdd.Steps.Add(instep); break; default: throw new ArgumentException("Invalid XML Format"); } } }
public void CreateXML(XmlTextWriter writer) { int counter = 0; writer.WriteStartElement("BuildSystem"); string includes = ""; foreach (string include in Project.IncludeDirs) { if (!string.IsNullOrEmpty(include)) { includes += include + ";"; } } writer.WriteAttributeString("IncludeDirs", includes); foreach (IBuildConfig config in buildConfigs) { writer.WriteStartElement(config.Name); foreach (IBuildStep step in config.Steps) { Type type = step.GetType(); writer.WriteStartElement(type.Name); writer.WriteAttributeString("Count", counter.ToString()); writer.WriteAttributeString("InputFile", step.InputFile); if (type == typeof(ExternalBuildStep)) { ExternalBuildStep eStep = (ExternalBuildStep)step; writer.WriteAttributeString("Arguments", eStep.Arguments); } else if (type == typeof(InternalBuildStep)) { InternalBuildStep iStep = (InternalBuildStep)step; writer.WriteAttributeString("OutputFile", iStep.OutputFile); writer.WriteAttributeString("StepType", Convert.ToInt16(iStep.StepType).ToString()); } writer.WriteEndElement(); } writer.WriteEndElement(); } writer.WriteEndElement(); }
public void ReadXML(XmlTextReader reader) { FilePath root = _project.ProjectDirectory; if (reader.Name != "BuildSystem") { throw new ArgumentException("Invalid XML Format"); } var attribute = reader.GetAttribute("IncludeDirs"); if (attribute != null) { string[] includeDirs = attribute.Split(';'); foreach (string include in includeDirs.Where(include => !string.IsNullOrEmpty(include))) { string path = Uri.UnescapeDataString(new Uri(Path.Combine(root, include)).AbsolutePath); _project.IncludeDirs.Add(new FilePath(path)); } } BuildConfig configToAdd = null; while (reader.MoveToNextElement()) { if (reader.Name.Contains("Step")) { if (configToAdd == null) { throw new ArgumentException("Invalid XML Format"); } int count = Convert.ToInt32(reader.GetAttribute("StepNum")); string inputFile = reader.GetAttribute("InputFile"); switch (reader.Name) { case "ExternalBuildStep": string arguments = reader.GetAttribute("Arguments"); if (inputFile != null) { ExternalBuildStep exstep = new ExternalBuildStep( count, root.Combine(inputFile), arguments); configToAdd.AddStep(exstep); } break; case "InternalBuildStep": string outputFile = reader.GetAttribute("OutputFile"); BuildStepType type = (BuildStepType)Convert.ToInt16(reader.GetAttribute("StepType")); if (inputFile != null && outputFile != null) { InternalBuildStep instep = new InternalBuildStep( count, type, root.Combine(inputFile), root.Combine(outputFile)); configToAdd.AddStep(instep); } break; default: throw new ArgumentException("Invalid XML Format"); } } else { string configName = reader.Name; configToAdd = new BuildConfig(configName); _buildConfigs.Add(configToAdd); } } }