1{
2 /***************************************************************************
3                                 Lazarus.pp
4                             -------------------
5                   This is the lazarus editor program.
6
7                   Initial Revision  : Sun Mar 28 23:15:32 CST 1999
8
9
10 ***************************************************************************/
11
12 ***************************************************************************
13 *                                                                         *
14 *   This source is free software; you can redistribute it and/or modify   *
15 *   it under the terms of the GNU General Public License as published by  *
16 *   the Free Software Foundation; either version 2 of the License, or     *
17 *   (at your option) any later version.                                   *
18 *                                                                         *
19 *   This code is distributed in the hope that it will be useful, but      *
20 *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
21 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
22 *   General Public License for more details.                              *
23 *                                                                         *
24 *   A copy of the GNU General Public License is available on the World    *
25 *   Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also      *
26 *   obtain it by writing to the Free Software Foundation,                 *
27 *   Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1335, USA.   *
28 *                                                                         *
29 ***************************************************************************
30}
31
32program Lazarus;
33
34{$mode objfpc}{$H+}
35
36{$I ide.inc}
37
38{off $DEFINE IDE_MEM_CHECK}
39
40uses
41  {$IFDEF EnableRedirectStdErr}
42  redirect_stderr,
43  {$ENDIF}
44  {$IF defined(HASAMIGA) and not defined(DisableMultiThreading)}
45  athreads,
46  {$ENDIF}
47  {$IF defined(UNIX) and not defined(DisableMultiThreading)}
48  cthreads,
49  {$ENDIF}
50  {$IFDEF IDE_MEM_CHECK}
51  MemCheck,
52  {$ENDIF}
53  {$IF defined(Unix)}
54  clocale,
55  {$IFEND}
56  SysUtils,
57  Interfaces,
58  IDEInstances,//keep IDEInstances up so that it will be initialized soon
59  Forms, LCLProc,
60  IDEOptionsIntf,
61  LazConf, IDEGuiCmdLine,
62  Splash,
63  Main,
64  AboutFrm,
65  // use the custom IDE static packages AFTER 'main'
66  {$IFDEF AddStaticPkgs}
67  {$I staticpackages.inc}
68  {$ENDIF}
69  {$IFDEF BigIDE}
70    AllSynEditDsgn, DateTimeCtrlsDsgn,
71    RunTimeTypeInfoControls, Printer4Lazarus, Printers4LazIDE,
72    LeakView, MemDSLaz, SDFLaz, InstantFPCLaz, ExternHelp,
73    TurboPowerIPro, TurboPowerIProDsgn,
74    jcfidelazarus, chmhelppkg,
75    FPCUnitTestRunner, FPCUnitIDE, ProjTemplates, TAChartLazarusPkg,
76    TodoListLaz, DateTimeCtrls, SQLDBLaz, DBFLaz, pascalscript,
77    EditorMacroScript,
78    laz.virtualtreeview_package, OnlinePackageManager, Pas2jsDsgn,
79    LazDebuggerFpLldb, LazDebuggerFp,
80  {$ENDIF}
81  MainBase;
82
83{$I revision.inc}
84{$R lazarus.res}
85{$R ../images/laz_images.res}
86
87begin
88  Max_Frame_Dump:=32; // the default 8 is not enough
89
90  HasGUI:=true;
91  {$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('lazarus.pp: begin');{$ENDIF}
92
93  RequireDerivedFormResource := True;
94
95  // When quick rebuilding the IDE (e.g. when the set of install packages have
96  // changed), only the unit paths have changed and so FPC rebuilds only the
97  // lazarus.pp.
98  // Any flag that should work with quick build must be set here.
99  KeepInstalledPackages:={$IF defined(BigIDE) or defined(KeepInstalledPackages)}True{$ELSE}False{$ENDIF};
100
101  // end of build flags
102
103  LazarusRevisionStr:=RevisionStr;
104  {$IFDEF EnableWriteLazRev}
105  writeln('[20180608074905] lazarus.pp ide/revision.inc: ',LazarusRevisionStr);
106  {$ENDIF}
107  Application.Title:='Lazarus';
108  Application.Scaled:=True;
109  OnGetApplicationName:=@GetLazarusApplicationName;
110
111  {$IFDEF Windows}
112  // on windows when MainFormOnTaskBar = True the main form becomes
113  // the parent of all other forms and therefore it always shows under
114  // other forms. For Lazarus the main form is the component palette form
115  // and it is not a desired behavior to see it always under other windows.
116  // So until we have a good docking solution let's have a dummy taskbar windows on windows.
117  Application.{%H-}MainFormOnTaskBar := False;
118  {$ENDIF}
119
120  {$IF DEFINED(MSWINDOWS) AND DECLARED(GlobalSkipIfNoLeaks)}
121  // don't show empty heaptrc output dialog on windows
122  GlobalSkipIfNoLeaks := True;
123  {$ENDIF}
124
125  Application.Initialize;
126  LazIDEInstances.PerformCheck;
127  if not LazIDEInstances.StartIDE then
128    Exit;
129  LazIDEInstances.StartServer;
130  TMainIDE.ParseCmdLineOptions;
131  if not SetupMainIDEInstance then exit;
132  if Application.Terminated then exit;
133
134  // Show splashform
135  if ShowSplashScreen then begin
136    SplashForm := TSplashForm.Create(nil);
137    SplashForm.Show;
138    Application.ProcessMessages; // process splash paint message
139  end;
140
141  TMainIDE.Create(Application);
142  if not Application.Terminated then
143  begin
144    MainIDE.CreateOftenUsedForms;
145    try
146      MainIDE.StartIDE;
147    except
148      Application.HandleException(MainIDE);
149    end;
150    {$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('lazarus.pp: TMainIDE created');{$ENDIF}
151
152    try
153      Application.Run;
154    except
155      debugln('lazarus.pp - unhandled exception');
156      CleanUpPIDFile;
157      Halt;
158    end;
159  end;
160  CleanUpPIDFile;
161  FreeThenNil(SplashForm);
162
163  debugln('LAZARUS END - cleaning up ...');
164
165  // free the IDE, so everything is freed before the finalization sections
166  MainIDE.Free;
167end.
168
169