lazarus编写程序特别是需要交叉编译时,不能直观显示当前project交叉编译的目标CPU及OS,跟踪源码后发现很简单就能显示相关信息,可以参考以下代码(红字部分)修改。
打开lazarus\ide\main.pp,找到procedure TMainIDE.UpdateCaption;
打开lazarus\ide\main.pp,找到procedure TMainIDE.UpdateCaption;
procedure TMainIDE.UpdateCaption; function AddToCaption(const CurrentCaption, CaptAddition: string): String; begin if EnvironmentGuiOpts.Desktop.IDETitleStartsWithProject then Result := CaptAddition + ' - ' + CurrentCaption else Result := CurrentCaption + ' - ' + CaptAddition; end; var rev, NewCaption, NewTitle, ProjectName, DirName,TargetOSCPU: String; begin if MainIDEBar = nil then Exit; if ToolStatus = itExiting then Exit; rev := GetLazarusRevision; if IsNumber(rev) then NewCaption := Format(lisLazarusEditorV + ' r%s', [GetLazarusVersionString, rev]) else NewCaption := Format(lisLazarusEditorV, [GetLazarusVersionString]); NewTitle := NewCaption; if MainBarSubTitle <> '' then NewCaption := AddToCaption(NewCaption, MainBarSubTitle) else begin if Project1 <> nil then begin ProjectName := Project1.GetTitleOrName; if ProjectName <> '' then begin if EnvironmentGuiOpts.Desktop.IDETitleShowsProjectDir then begin DirName := ExtractFileDir(Project1.ProjectInfoFile); TargetOSCPU:=' '+Project1.ActiveBuildMode.CompilerOptions.TargetOS+'-'+Project1.ActiveBuildMode.CompilerOptions.TargetCPU; if trim(TargetOSCPU)='-' then TargetOSCPU:=' '+lowercase({$i %FPCTARGETOS%})+'-'+lowercase({$i %FPCTARGETCPU%}); if DirName <> '' then ProjectName := ProjectName + ' ('+DirName+TargetOSCPU+')'; end; end else ProjectName := lisnewProject; NewTitle := AddToCaption(NewCaption, ProjectName); if EnvironmentGuiOpts.Desktop.IDETitleShowsBuildMode and (Project1.BuildModes.Count > 1) then ProjectName:= ProjectName + ' - ' +Project1.ActiveBuildMode.GetCaption; NewCaption := AddToCaption(NewCaption, ProjectName); end; end; case ToolStatus of itBuilder: NewCaption := Format(liscompiling, [NewCaption]); itDebugger: begin if DebugBoss.Commands - [dcRun, dcStop, dcEnvironment] <> [] then NewCaption := Format(lisDebugging, [NewCaption]) else NewCaption := Format(lisRunning, [NewCaption]); end; else end; MainIDEBar.Caption := NewCaption; Application.Title := NewTitle; end;
修改后重新编译lazarus就可以在标题栏显示目标OS/CPU: