public static BuildResult BuildProject(string workingDirectory, PrjFile projectFile, IModule topModule) { // Create prj file on disk string toplevelComponentName = string.Format("{0}.{1}", topModule.Parent.Name, topModule.Name); string projectFilePath = PathHelper.Combine(workingDirectory, "projectfile.prj"); File.WriteAllText(projectFilePath, projectFile.ToString(ExecutionType.SynthesisOnly)); string projectXstFilePath = PathHelper.Combine(workingDirectory, "projectfile.xst"); string projectSyrFilePath = PathHelper.Combine(workingDirectory, "projectfile.syr"); string projectXstPath = PathHelper.Combine(workingDirectory, "xst"); string projectTmpPath = PathHelper.Combine(projectXstPath, ".tmp"); File.WriteAllText(projectXstFilePath, GenerateScript(workingDirectory, projectFilePath, topModule.Name)); Directory.CreateDirectory(projectXstPath); Directory.CreateDirectory(projectTmpPath); Logger.Instance.WriteDebug("Top Level component name: {0}", toplevelComponentName); Logger.Instance.WriteDebug("Xst path: {0}", projectXstFilePath); List <string> arguments = new List <string>(); arguments.Add(string.Format("-ifn \"{0}\"", projectXstFilePath)); arguments.Add(string.Format("-ofn \"{0}\"", projectSyrFilePath)); XilinxProcess process = new XilinxProcess("xst", arguments); DefaultMessageParser parser = new DefaultMessageParser(); StringProcessListener stringParser = new StringProcessListener(); parser.MessageOccured += ((obj) => obj.WriteToLogger()); process.Listeners.Add(parser); process.Listeners.Add(stringParser); process.WorkingDirectory = workingDirectory; process.Start(); process.WaitForExit(); BuildResult buildResult = new BuildResult(); buildResult.BuildLog = stringParser.Output + "\n\n\n" + stringParser.ErrorOutput; buildResult.WorkingDirectory = workingDirectory; File.Delete(projectFilePath); File.Delete(projectXstFilePath); Directory.Delete(PathHelper.Combine(workingDirectory, "xst"), true); return(buildResult); }
public static BuildResult BuildProject(string workingDirectory, PrjFile projectFile, IModule topModule) { // Create prj file on disk string toplevelComponentName = string.Format("{0}.{1}", topModule.Parent.Name, topModule.Name); string projectFilePath = PathHelper.Combine(workingDirectory, "projectfile.prj"); File.WriteAllText(projectFilePath, projectFile.ToString(ExecutionType.SynthesisOnly)); string projectXstFilePath = PathHelper.Combine(workingDirectory, "projectfile.xst"); string projectSyrFilePath = PathHelper.Combine(workingDirectory, "projectfile.syr"); string projectXstPath = PathHelper.Combine(workingDirectory, "xst"); string projectTmpPath = PathHelper.Combine(projectXstPath, ".tmp"); File.WriteAllText(projectXstFilePath, GenerateScript(workingDirectory, projectFilePath, topModule.Name)); Directory.CreateDirectory(projectXstPath); Directory.CreateDirectory(projectTmpPath); Logger.Instance.WriteDebug("Top Level component name: {0}", toplevelComponentName); Logger.Instance.WriteDebug("Xst path: {0}", projectXstFilePath); List<string> arguments = new List<string>(); arguments.Add(string.Format("-ifn \"{0}\"", projectXstFilePath)); arguments.Add(string.Format("-ofn \"{0}\"", projectSyrFilePath)); XilinxProcess process = new XilinxProcess("xst", arguments); DefaultMessageParser parser = new DefaultMessageParser(); StringProcessListener stringParser = new StringProcessListener(); parser.MessageOccured += ((obj) => obj.WriteToLogger()); process.Listeners.Add(parser); process.Listeners.Add(stringParser); process.WorkingDirectory = workingDirectory; process.Start(); process.WaitForExit(); BuildResult buildResult = new BuildResult(); buildResult.BuildLog = stringParser.Output + "\n\n\n" + stringParser.ErrorOutput; buildResult.WorkingDirectory = workingDirectory; File.Delete(projectFilePath); File.Delete(projectXstFilePath); Directory.Delete(PathHelper.Combine(workingDirectory, "xst"), true); return buildResult; }
private bool TranslateNCDFile(string ncdFile, string xdlFile) { // Setup Arguments List<string> arguments = new List<string>(); // Default configuration arguments.Add("-ncd2xdl"); // NCD to XDL // The source NCD arguments.Add(string.Format("\"{0}\"", ncdFile)); // The output XDL arguments.Add(string.Format("\"{0}\"", xdlFile)); // Prepare Process XilinxProcess process = new XilinxProcess("xdl", arguments); DefaultMessageParser parser = new DefaultMessageParser(); StringProcessListener stdout = new StringProcessListener(); parser.MessageOccured += ((obj) => obj.WriteToLogger()); process.Listeners.Add(parser); process.Listeners.Add(stdout); process.WorkingDirectory = OutputLocation.TemporaryDirectory; process.Start(); process.WaitForExit(); Logger.Instance.WriteDebug(stdout.Output); // Check if the process completed correctly if (process.CurrentProcess.ExitCode != 0 || !File.Exists(xdlFile)) { return false; } return true; }
public bool Build() { string projectName = Path.GetFileNameWithoutExtension(Bitstream); string projectMemFilePath = PathHelper.Combine(OutputLocation.TemporaryDirectory, string.Format("{0}.mem", projectName)); string projectBitFilePath = PathHelper.Combine(OutputLocation.TemporaryDirectory, string.Format("{0}_mem.bit", projectName)); // Check bitstream file exists if (string.IsNullOrEmpty(Bitstream) || !File.Exists(Bitstream)) { throw new FileNotFoundException("Bitstream File does not exist."); } // Check bmm file exists if (string.IsNullOrEmpty(BMMDescription) || !File.Exists(BMMDescription)) { throw new FileNotFoundException("BMM File does not exist."); } // Check binary file exists if (string.IsNullOrEmpty(BinaryFile) || !File.Exists(BinaryFile)) { throw new FileNotFoundException("Binary File does not exist."); } // Generate the mem file from binary data string data = MemFormatHelper.ConvertBinaryToMem(File.ReadAllBytes(BinaryFile)); File.WriteAllText(projectMemFilePath, data); // Setup Arguments List<string> arguments = new List<string>(); // The BMM arguments.Add(string.Format("-bm \"{0}\"", BMMDescription)); // The memory contents arguments.Add(string.Format("-bd \"{0}\"", projectMemFilePath)); // The source bitstream arguments.Add(string.Format("-bt \"{0}\"", Bitstream)); // The output bitstream arguments.Add(string.Format("-o b \"{0}\"", projectBitFilePath)); // Prepare Process XilinxProcess process = new XilinxProcess("data2mem", arguments); DefaultMessageParser parser = new DefaultMessageParser(); StringProcessListener stdout = new StringProcessListener(); parser.MessageOccured += ((obj) => obj.WriteToLogger()); process.Listeners.Add(parser); process.Listeners.Add(stdout); process.WorkingDirectory = OutputLocation.TemporaryDirectory; process.Start(); process.WaitForExit(); Logger.Instance.WriteDebug(stdout.Output); // Copy results to output OutputLocation.CopyOutputFile(projectBitFilePath); // Check if the process completed correctly if (process.CurrentProcess.ExitCode != 0 || !File.Exists(projectBitFilePath)) { return false; } return true; }
protected static ProcessHelper.ProcessExecutionResult ExecuteProcessObject(StandardProcess process) { using (StringProcessListener listener = new StringProcessListener()) { ProcessHelper.ProcessExecutionResult result = new ProcessHelper.ProcessExecutionResult(); process.Listeners.Add(listener); process.RedirectOutput = true; process.Start(); process.WaitForExit(); result.StandardError = listener.ErrorOutput; result.StandardOutput = listener.Output; return result; } }