/// <summary> /// Creates a populated AssemblerConfig from the app settings for the specified ID. /// If the assembler hasn't been configured yet, the default configuration object /// will be returned. /// </summary> /// <param name="settings">Settings object to pull the values from.</param> /// <param name="id">Assembler ID.</param> /// <returns>The AssemblerConfig.</returns> public static AssemblerConfig GetConfig(AppSettings settings, AssemblerInfo.Id id) { string cereal = settings.GetString(GetSettingName(id), null); if (string.IsNullOrEmpty(cereal)) { IAssembler asm = AssemblerInfo.GetAssembler(id); return(asm.GetDefaultConfig()); } JavaScriptSerializer ser = new JavaScriptSerializer(); try { AssemblerConfig config = ser.Deserialize <AssemblerConfig>(cereal); if (config.ColumnWidths == null || config.ColumnWidths.Length != NUM_COLUMNS) { throw new Exception("Bad column widths"); } if (config.ExecutablePath == null) { throw new Exception("Missing exe path"); } return(config); } catch (Exception ex) { Debug.WriteLine("AssemblerConfig deserialization failed: " + ex.Message); return(null); } }
/// <summary> /// Queries the versions from all known assemblers, replacing any previously held data. /// </summary> public static void QueryVersions() { IEnumerator <AssemblerInfo> iter = AssemblerInfo.GetInfoEnumerator(); while (iter.MoveNext()) { AssemblerInfo.Id id = iter.Current.AssemblerId; if (id == AssemblerInfo.Id.Unknown) { continue; } AssemblerVersion vers = null; IAssembler asm = AssemblerInfo.GetAssembler(id); if (asm != null) { vers = asm.QueryVersion(); } Debug.WriteLine("Asm version query: " + id + "=" + vers); sVersions[id] = vers; } sQueried = true; }
public static AssemblerVersion GetVersion(AssemblerInfo.Id id) { IAssembler asm = AssemblerInfo.GetAssembler(id); if (asm == null) { Debug.WriteLine("Assembler " + id + " not configured"); return(null); } return(asm.QueryVersion()); }
private void runAssemblerButton_Click(object sender, EventArgs e) { IAssembler asm = AssemblerInfo.GetAssembler(mSelectedAssemblerId); if (asm == null) { Debug.WriteLine("Unable to get assembler for " + mSelectedAssemblerId); return; } asm.Configure(mGenerationResults, mWorkDirectory); AssemblerProgress dlg = new AssemblerProgress(asm); dlg.ShowDialog(); Debug.WriteLine("Dialog returned: " + dlg.DialogResult); if (dlg.DialogResult != DialogResult.OK) { // Cancelled, or failed to even run the assembler. return; } AssemblerResults results = dlg.Results; if (results == null) { Debug.WriteLine("Dialog returned OK, but no assembler results found"); Debug.Assert(false); return; } StringBuilder sb = new StringBuilder(results.Stdout.Length + results.Stderr.Length + 200); sb.Append(results.CommandLine); sb.Append("\r\n"); sb.AppendFormat("ExitCode={0} - ", results.ExitCode); if (results.ExitCode == 0) { FileInfo fi = new FileInfo(results.OutputPathName); if (!fi.Exists) { MessageBox.Show(this, Properties.Resources.ASM_OUTPUT_NOT_FOUND, Properties.Resources.ASM_MISMATCH_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); sb.Append(Properties.Resources.ASM_MATCH_FAILURE); } else if (!CommonUtil.FileUtil.CompareBinaryFile(mProject.FileData, results.OutputPathName, out int offset, out byte fileVal)) { if (fi.Length != mProject.FileData.Length && offset == fi.Length || offset == mProject.FileData.Length) { // The files matched up to the point where one ended. string msg = string.Format(Properties.Resources.ASM_MISMATCH_LENGTH_FMT, fi.Length, mProject.FileData.Length); MessageBox.Show(this, msg, Properties.Resources.ASM_MISMATCH_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); sb.Append(msg); } else { string msg = string.Format(Properties.Resources.ASM_MISMATCH_DATA_FMT, offset, fileVal, mProject.FileData[offset]); MessageBox.Show(this, msg, Properties.Resources.ASM_MISMATCH_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); sb.Append(msg); } } else { sb.Append(Properties.Resources.ASM_MATCH_SUCCESS); } }