Ignore:
Timestamp:
Mar 4, 2022, 10:57:08 PM (3 years ago)
Author:
chronos
Message:
  • Added: Compile multiple action for compilation of code with mutliple compilers at once.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.pas

    r128 r133  
    1515
    1616  TFormMain = class(TForm)
     17    AProgramCompileMultiple: TAction;
    1718    AViewLog: TAction;
    1819    AProgramShowExecutionPoint: TAction;
     
    5253    MenuItem19: TMenuItem;
    5354    MenuItem2: TMenuItem;
     55    MenuItem20: TMenuItem;
    5456    MenuItem22: TMenuItem;
    5557    MenuItem24: TMenuItem;
     
    117119    procedure AOptionsExecute(Sender: TObject);
    118120    procedure AProgramCompileExecute(Sender: TObject);
     121    procedure AProgramCompileMultipleExecute(Sender: TObject);
    119122    procedure AProgramPauseExecute(Sender: TObject);
    120123    procedure AProgramRunToCursorExecute(Sender: TObject);
     
    171174  UCore, UFormCPU, UFormOptions, UFormMessages, UFormTargets, UFormOutput, UFormInput,
    172175  UFormMemory, UFormSourceCode, UFormTargetCode, UTargetInterpretter, UFormLog,
    173   UBFTarget, UCommon;
     176  UBFTarget, UCommon, UFormCompileMultiple;
    174177
    175178resourcestring
     
    206209    FormSourceCode.UpdateTheme;
    207210  end;
     211  Core.Messages.OnChange := FormMain.MessagesChanged;
    208212end;
    209213
     
    227231    AProgramShowExecutionPoint.Execute;
    228232  if Core.CurrentTarget.State = rsStopped then
    229     Core.CurrentTarget.Messages.AddMessage(SProgramStopped);
     233    Core.Messages.AddMessage(SProgramStopped);
    230234end;
    231235
     
    405409  if not Core.CurrentTarget.Compiled then AProgramCompile.Execute;
    406410  Core.CurrentTarget.Run;
    407   Core.CurrentTarget.Messages.AddMessage(SProgramStarted);
     411  Core.Messages.AddMessage(SProgramStarted);
    408412end;
    409413
     
    432436procedure TFormMain.AViewCompilersExecute(Sender: TObject);
    433437begin
    434   if not Assigned(FormTargets) then FormTargets := TFormTargets.Create(Self);
    435   FormTargets.Show;
     438  with TFormTargets.Create(nil) do
     439  try
     440    ShowModal;
     441  finally
     442    Free;
     443  end;
    436444end;
    437445
     
    493501  with Core.CurrentTarget do
    494502  try
     503    Core.Messages.Clear;
    495504    AProgramStop.Execute;
    496505    SourceCode := FormSourceCode.SynEditSource.Text;
     
    499508    if Core.CurrentTarget is TBFTarget then
    500509      TBFTarget(Core.CurrentTarget).Optimizations := Core.Optimizations;
    501     Core.CurrentTarget.Messages.AddMessage(SCompileStart);
     510    DebugEnabled := Core.DebugEnabled;
     511    Core.Messages.AddMessage(SCompileStart);
    502512    Application.ProcessMessages;
    503513    Compile;
    504     Core.CurrentTarget.Messages.AppendMessage(SDone);
     514    Core.Messages.AppendMessage(SDone);
    505515    FormTargetCode.SynEditTarget.Text := TargetCode;
    506516    FormTargetCode.SetHighlighter(Core.CurrentTarget.SourceExtension);
     
    509519    on E: Exception do
    510520      MessageDlg(SError, E.Message, mtError, [mbOk], 0);
     521  end;
     522end;
     523
     524procedure TFormMain.AProgramCompileMultipleExecute(Sender: TObject);
     525var
     526  I: Integer;
     527begin
     528  AProgramStop.Execute;
     529  with TFormCompileMultiple.Create(nil) do
     530  try
     531    Targets := Core.Targets;
     532    if ShowModal = mrOk then begin
     533      Core.Messages.Clear;
     534      for I := 0 to Targets.Count - 1 do
     535      with Targets[I] do
     536      if Selected then
     537      try
     538        AProgramStop.Execute;
     539        SourceCode := FormSourceCode.SynEditSource.Text;
     540        ProjectFileName := Core.Project.FileName;
     541        ProgramName := ExtractFileNameOnly(Core.Project.FileName);
     542        if Targets[I] is TBFTarget then
     543          TBFTarget(Targets[I]).Optimizations := Core.Optimizations;
     544        DebugEnabled := Core.DebugEnabled;
     545        Core.Messages.AddMessage(Name + ' ' + SCompileStart);
     546        Application.ProcessMessages;
     547        Compile;
     548        Core.Messages.AppendMessage(SDone);
     549        FormTargetCode.SynEditTarget.Text := TargetCode;
     550        FormTargetCode.SetHighlighter(Core.CurrentTarget.SourceExtension);
     551        UpdateInterface;
     552      except
     553        on E: Exception do
     554          MessageDlg(SError, E.Message, mtError, [mbOk], 0);
     555      end;
     556    end;
     557  finally
     558    Free;
    511559  end;
    512560end;
Note: See TracChangeset for help on using the changeset viewer.