⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 compilerdlg.cpp

📁 用于开发Atmel的AVR系列单片机的GCC集成开发环境
💻 CPP
📖 第 1 页 / 共 2 页
字号:
  Action->Caption = "Generating: " + ExtractFileName (output);
  con->RunChild (objcopy.c_str (), temp.c_str (), DirDlg->Bin_Dir.c_str ());
  temp = objcopy + temp + "\r\n";
  logfile->Write (temp.c_str (), temp.Length ());
  while (con->isChildRunning ())
  {
   Application->ProcessMessages ();
  }
 }
 // ------------------- Generate Extended Listing ----------------
 if (OptDlg->options.ExtLst)
 {
  temp = OptDlg->OutputName + ".lss";
  StdOutStream = new TFileStream (temp, fmCreate);
  con->OnStdOut = StdOutToFile;
  child_exitcode = 0;
  Action->Caption = "Generating: " + ExtractFileName (temp);
  temp = "-h -S \"" + OptDlg->OutputName + ".elf\"";
  objcopy = DirDlg->Bin_Dir + "avr-objdump.exe";
  if (!FileExists (objcopy))
  {
   Application->MessageBox ("Can't find avr-objdump.exe", "Error", MB_OK |MB_ICONERROR);
   return;
  }
  con->RunChild (objcopy.c_str (), temp.c_str (), DirDlg->Bin_Dir.c_str ());
  temp = objcopy + temp + " > \"" + OptDlg->OutputName + ".lss\"\r\n";
  logfile->Write (temp.c_str (), temp.Length ());
  while (con->isChildRunning ())
  {
   Application->ProcessMessages ();
  }
  con->OnStdOut = 0;
  delete StdOutStream;
 }
 // ---------------------- Generate Symbol Table ----------------
 if (OptDlg->options.SymTab)
 {
  temp = OptDlg->OutputName + ".sym";
  StdOutStream = new TFileStream (temp, fmCreate);
  con->OnStdOut = StdOutToFile;
  child_exitcode = 0;
  Action->Caption = "Generating: " + ExtractFileName (temp);
  temp = "-n \"" + OptDlg->OutputName + ".elf\"";
  objcopy = DirDlg->Bin_Dir + "avr-nm.exe";
  if (!FileExists (objcopy))
  {
   Application->MessageBox ("Can't find avr-nm.exe", "Error", MB_OK |MB_ICONERROR);
   return;
  }
  con->RunChild (objcopy.c_str (), temp.c_str (), DirDlg->Bin_Dir.c_str ());
  temp = objcopy + temp + " > \"" + OptDlg->OutputName + ".sym\"\r\n";
  logfile->Write (temp.c_str (), temp.Length ());
  while (con->isChildRunning ())
  {
   Application->ProcessMessages ();
  }
  con->OnStdOut = 0;
  delete StdOutStream;
 }
 return;
}
//---------------------------------------------------------------------------
void __fastcall TCompDlg::UpdateMemo (char *buffer, int len)
{
 MemoOut->SetSelTextBuf (buffer);
}
//---------------------------------------------------------------------------
void __fastcall TCompDlg::OnChildExit (int exitcode)
{
 child_exitcode = exitcode;
}
//---------------------------------------------------------------------------
void __fastcall TCompDlg::DoBuild (void)
{
 AnsiString temp, obj;
 TStringList *depList;
 int i, o;
 bool r;

 if (todo != DO_COMPILE) SetCurrentDir (ProjectPath);

 Application->ProcessMessages ();
 switch (todo)
 {
  case DO_MAKE: for (i = 0;i < CFList->Count;i++)
                {
                 temp = ExpandFileName (CFList->Strings[i]);
                 obj = ChangeExt (temp, ".o");
                 if (CompareFileDates (temp, obj) == 3 || !FileExists (obj))
                 {
                  doList->Add (temp);
                 }
                }
                for (o = 0;o < HFList->Count;o++)
                {
                 depList = (TStringList *)HFList->Objects[o];
                 if (depList != 0) for (i = 0;i < depList->Count;i++)
                 {
                  temp = ExpandFileName (HFList->Strings[o]);
                  obj = ChangeExt (ExpandFileName (depList->Strings[i]), ".o");
                  if (CompareFileDates (temp, obj) == 3 || !FileExists (obj))
                  {
                   temp = ExpandFileName (depList->Strings[i]);
                   if (doList->IndexOf (temp) == -1) doList->Add (temp);
                  }
                 }
                }
                break;
  case DO_MAKE_ALL: for (i = 0;i < CFList->Count;i++)
                    {
                     temp = ExpandFileName (CFList->Strings[i]);
                     doList->Add (temp);
                    }
                    break;
 }
 MemoOut->Clear ();

 con = new TConRedirect (this);
 con->OnStdErr = UpdateMemo;
 con->OnChildExit = OnChildExit;
 errors = warnings = 0;
 if (doList->Count != 0) r = Compile ();
 else r = true;
 if (r && todo != DO_COMPILE)
 {
  doList->Clear ();
  for (i = 0;i < CFList->Count;i++)
  {
   temp = ExpandFileName (CFList->Strings[i]);
   doList->Add (temp);
  }
  if (Linker ()) Convert ();
  else errors++;
 }
 CheckForErrWarn ();
 if (warnings || errors)
 {
  StatusLabel->Font->Color = clRed;
  StatusLabel->Caption = "Errors: " + AnsiString ((int)errors) +
                         " Warnings: " + AnsiString((int)warnings);
 }
 else StatusLabel->Caption = "Successfully done";
 delete con;

 OkButton->Visible = true;
}
//---------------------------------------------------------------------------
void __fastcall TCompDlg::CheckForErrWarn (void)
{
 int i;

 for (i = 0;i < MemoOut->Lines->Count;i++)
 {
  if (MemoOut->Lines->Strings[i].Pos ("error:")) errors++;
  if (MemoOut->Lines->Strings[i].Pos ("warning:")) warnings++;
 }
 if (child_exitcode != 0 && errors == 0 && warnings == 0) errors++;
}
//---------------------------------------------------------------------------

void __fastcall TCompDlg::FormActivate(TObject *Sender)
{
 StatusLabel->Caption = "";
 StatusLabel->Font->Color = clBlack;
 OkButton->Visible = false;
 DoBuild ();
}
//---------------------------------------------------------------------------
void __fastcall TCompDlg::StdOutToList (char *buffer, int len)
{
 SizeOutput += buffer;
}
//---------------------------------------------------------------------------
void __fastcall TCompDlg::StdOutToFile (char *buffer, int len)
{
 StdOutStream->Write (buffer, len);
}
//---------------------------------------------------------------------------
void __fastcall TCompDlg::FormShow(TObject *Sender)
{
 SizeGrid->Cells[0][0] = "Section";
 SizeGrid->Cells[1][0] = "Size (dec)";
 SizeGrid->Cells[2][0] = "Address (hex)";
}
//---------------------------------------------------------------------------
void __fastcall TCompDlg::SizeToGrid (void)
{
 int i, row, s, a;
 AnsiString sec, size, addr;
 bool found = false;
 char ch;

 for (i = 0, row = 1;i < SizeOutput.Length ();i++)
 {
  ch = SizeOutput[i + 1];
  if (ch == '.' && !found)
  {
   found = true;
   s = 0;
   sec = "";
   size = "";
   addr = "";
  }
  if (found)
  {
   switch (s)
   {
    case 0: if (ch != ' ') sec += ch;
            else s++;
            if (ch == '\r' || ch == '\n') found = false;
            break;
    case 1: if (ch != ' ')
            {
             size += ch;
             s++;
            }
            if (ch == '\r' || ch == '\n') found = false;
            break;
    case 2: if (ch != ' ') size += ch;
            else s++;
            if (ch == '\r' || ch == '\n') found = false;
            break;
    case 3: if (ch != ' ')
            {
             addr += ch;
             s++;
            }
            if (ch == '\r' || ch == '\n') found = false;
            break;
    case 4: if (ch != ' ' && ch != '\r' && ch != '\n') addr += ch;
            else
            {
             a = addr.ToInt ();
             if (sec == ".data" || sec == ".bss" || sec == ".noinit") a -= 0x800000;
             else if (sec == ".eeprom") a -= 0x810000;
             addr = IntToHex (a, 1);
             found = false;
             SizeGrid->Cells[0][row] = sec;
             SizeGrid->Cells[1][row] = size;
             SizeGrid->Cells[2][row] = addr;
             row++;
            }
            break;
   }
  }
 }
 SizeGrid->RowCount = row;
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -