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  LazControlDsgn,
66  // use the custom IDE static packages AFTER 'main'
67  {$IFDEF AddStaticPkgs}
68  {$I staticpackages.inc}
69  {$ENDIF}
70  {$IFDEF BigIDE}
71    AllSynEditDsgn, DateTimeCtrlsDsgn,
72    RunTimeTypeInfoControls, Printer4Lazarus, Printers4LazIDE,
73    LeakView, MemDSLaz, SDFLaz, InstantFPCLaz, ExternHelp,
74    TurboPowerIPro, TurboPowerIProDsgn,
75    jcfidelazarus, chmhelppkg,
76    FPCUnitTestRunner, FPCUnitIDE, ProjTemplates, TAChartLazarusPkg,
77    TodoListLaz, DateTimeCtrls, SQLDBLaz, DBFLaz, pascalscript,
78    EditorMacroScript, RegisterVirtualTreeView, OnlinePackageManager,
79    LazDebuggerFpLldb,
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.Scaled := True;
108  OnGetApplicationName:=@GetLazarusApplicationName;
109
110  {$IFDEF Windows}
111  // on windows when MainFormOnTaskBar = True the main form becomes
112  // the parent of all other forms and therefore it always shows under
113  // other forms. For Lazarus the main form is the component palette form
114  // and it is not a desired behavior to see it always under other windows.
115  // So until we have a good docking solution let's have a dummy taskbar windows on windows.
116  Application.{%H-}MainFormOnTaskBar := False;
117  {$ENDIF}
118
119  {$IF DEFINED(MSWINDOWS) AND DECLARED(GlobalSkipIfNoLeaks)}
120  // don't show empty heaptrc output dialog on windows
121  GlobalSkipIfNoLeaks := True;
122  {$ENDIF}
123
124  Application.Initialize;
125  LazIDEInstances.PerformCheck;
126  if not LazIDEInstances.StartIDE then
127    Exit;
128  LazIDEInstances.StartServer;
129  TMainIDE.ParseCmdLineOptions;
130  if not SetupMainIDEInstance then exit;
131  if Application.Terminated then exit;
132
133  // Show splashform
134  if ShowSplashScreen then begin
135    SplashForm := TSplashForm.Create(nil);
136    SplashForm.Show;
137    Application.ProcessMessages; // process splash paint message
138  end;
139
140  TMainIDE.Create(Application);
141  if not Application.Terminated then
142  begin
143    MainIDE.CreateOftenUsedForms;
144    try
145      MainIDE.StartIDE;
146    except
147      Application.HandleException(MainIDE);
148    end;
149    {$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('lazarus.pp: TMainIDE created');{$ENDIF}
150
151    try
152      Application.Run;
153    except
154      debugln('lazarus.pp - unhandled exception');
155      CleanUpPIDFile;
156      Halt;
157    end;
158  end;
159  CleanUpPIDFile;
160  FreeThenNil(SplashForm);
161
162  debugln('LAZARUS END - cleaning up ...');
163
164  // free the IDE, so everything is freed before the finalization sections
165  MainIDE.Free;
166end.
167
168