IDE: moved IFDEF BigIDE to lazarus.pp to let it work even on quick build, LazBuild: implemented compiling IDE standard packages

git-svn-id: trunk@15720 -
This commit is contained in:
mattias 2008-07-09 13:22:45 +00:00
parent a694ca9ced
commit 9d0afc204c
9 changed files with 155 additions and 41 deletions

View File

@ -436,8 +436,8 @@ begin
LinkerAddition := LCLWidgetLinkerAddition[Options.LCLPlatform];
if LinkerAddition <> '' then
begin
if ExtraOptions <> '' then ExtraOptions := ExtraOptions + ' ' + LinkerAddition
else ExtraOptions := LinkerAddition;
if ExtraOptions <> '' then ExtraOptions := ExtraOptions + ' ' + LinkerAddition
else ExtraOptions := LinkerAddition;
end;
if ExtraOptions<>'' then

View File

@ -661,7 +661,7 @@ type
var
EnvironmentOptions: TEnvironmentOptions;
EnvironmentOptions: TEnvironmentOptions = nil;
function DebuggerNameToType(const s: string): TDebuggerType;
function PascalExtToType(const Ext: string): TPascalExtType;

View File

@ -77,6 +77,11 @@ uses
begin
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('lazarus.pp: begin');{$ENDIF}
// When quick rebuilding the IDE, FPC rebuilds only the lazarus.pp, so any
// flag that should work with quick build must be set here.
KeepInstalledPackages:={$IFDEF BigIDE}True{$ELSE}False{$ENDIF};
LazarusRevisionStr:=RevisionStr;
Application.Title:='Lazarus';
Application.Initialize;

View File

@ -38,8 +38,8 @@ uses
// IDE
IDEProcs, InitialSetupDlgs, OutputFilter, Compiler, CompilerOptions,
TransferMacros, EnvironmentOpts, IDETranslations, LazarusIDEStrConsts,
Project, LazConf, PackageDefs, PackageLinks, PackageSystem,
BuildManager, BaseBuildManager;
MiscOptions, Project, LazConf, PackageDefs, PackageLinks, PackageSystem,
BuildLazDialog, BuildManager, BaseBuildManager;
type
@ -48,6 +48,8 @@ type
TLazBuildApplication = class(TCustomApplication)
private
FBuildAll: boolean;
FBuildIDE: boolean;
FBuildIDEOptions: string;
FBuildRecursive: boolean;
fCompilerOverride: String;
fCPUOverride: String;
@ -87,18 +89,24 @@ type
protected
function BuildFile(Filename: string): boolean;
// packages
function BuildPackage(const AFilename: string): boolean;
function LoadPackage(const AFilename: string): TLazPackage;
procedure CompilePackage(APackage: TLazPackage; Flags: TPkgCompileFlags);
procedure CheckPackageGraphForCompilation(APackage: TLazPackage;
FirstDependency: TPkgDependency);
// projects
function BuildProject(const AFilename: string): boolean;
function LoadProject(const AFilename: string): TProject;
procedure CloseProject(var AProject: TProject);
// IDE
function BuildLazarusIDE: boolean;
function Init: boolean;
procedure LoadEnvironmentOptions;
procedure LoadMiscellaneousOptions;
procedure SetupOutputFilter;
procedure SetupMacros;
procedure SetupPackageSystem;
@ -121,6 +129,8 @@ type
write FBuildRecursive;
property SkipDependencies: boolean read FSkipDependencies
write FSkipDependencies;
property BuildIDE: boolean read FBuildIDE write FBuildIDE;
property BuildIDEOptions: string read FBuildIDEOptions write FBuildIDEOptions;
property WidgetSetOverride: String read fWidgetsetOverride
write fWidgetsetOverride;
property OSOverride: String read fOSOverride write fOSOverride;
@ -353,6 +363,73 @@ begin
PkgLinks.SaveUserLinks;
end;
function TLazBuildApplication.BuildLazarusIDE: boolean;
var
Flags: TBuildLazarusFlags;
CurResult: TModalResult;
BuildLazOptions: TBuildLazarusOptions;
i: Integer;
CurItem: TBuildLazarusItem;
MakeMode: TMakeMode;
begin
Result:=false;
Init;
LoadMiscellaneousOptions;
BuildLazOptions:=MiscellaneousOptions.BuildLazOpts;
BuildLazOptions.TargetOS:=OSOverride;
BuildLazOptions.TargetCPU:=CPUOverride;
BuildLazOptions.TargetPlatform:=DirNameToLCLPlatform(WidgetSetOverride);
BuildLazOptions.ExtraOptions:=BuildIDEOptions;
MakeMode:=mmNone;
if BuildAll then begin
BuildLazOptions.CleanAll:=true;
MakeMode:=mmBuild;
end;
for i:=0 to BuildLazOptions.Count-1 do begin
CurItem:=BuildLazOptions.Items[i];
if (BuildLazOptions.IndexOf(CurItem)<BuildLazOptions.IndexOf(BuildLazOptions.ItemIDE))
then
// these items are needed for the IDE
CurItem.MakeMode:=MakeMode
else if CurItem=BuildLazOptions.ItemIDE then
// always build the IDE
CurItem.MakeMode:=mmBuild
else
// these are goodies (starter, examples)
CurItem.MakeMode:=mmNone;
end;
MainBuildBoss.SetBuildTargetIDE;
Flags:=[];
// first compile all lazarus components (LCL, SynEdit, CodeTools, ...)
// but not the IDE
CurResult:=BuildLazarus(MiscellaneousOptions.BuildLazOpts,
EnvironmentOptions.ExternalTools,GlobalMacroList,
'',EnvironmentOptions.CompilerFilename,
EnvironmentOptions.MakeFilename,
Flags+[blfWithoutCompilingIDE,blfWithoutLinkingIDE]);
if CurResult<>mrOk then begin
DebugLn('TLazBuildApplication.BuildLazarusIDE: Building standard components (LCL, SynEdit, CodeTools) failed.');
exit;
end;
DebugLn(['TLazBuildApplication.BuildLazarusIDE ToDo: compile installed packages']);
DebugLn(['TLazBuildApplication.BuildLazarusIDE ToDo: compile IDE']);
// compile auto install static packages
{CurResult:=PkgBoss.DoCompileAutoInstallPackages([]);
if CurResult<>mrOk then begin
DebugLn('TLazBuildApplication.BuildLazarusIDE: Compile AutoInstall Packages failed.');
exit;
end;}
Result:=true;
end;
procedure TLazBuildApplication.CompilePackage(APackage: TLazPackage;
Flags: TPkgCompileFlags);
begin
@ -572,6 +649,7 @@ begin
MainBuildBoss:=TBuildManager.Create;
MainBuildBoss.ScanningCompilerDisabled:=true;
LoadEnvironmentOptions;
LoadMiscellaneousOptions;
InteractiveSetup:=false;
SetupCompilerFilename(InteractiveSetup);
SetupLazarusDirectory(InteractiveSetup);
@ -590,6 +668,7 @@ end;
procedure TLazBuildApplication.LoadEnvironmentOptions;
begin
if EnvironmentOptions<>nil then exit;
EnvironmentOptions:=TEnvironmentOptions.Create;
with EnvironmentOptions do begin
SetLazarusDefaultFilename;
@ -608,6 +687,13 @@ begin
end;
end;
procedure TLazBuildApplication.LoadMiscellaneousOptions;
begin
if MiscellaneousOptions<>nil then exit;
MiscellaneousOptions:=TMiscellaneousOptions.Create;
MiscellaneousOptions.Load;
end;
procedure TLazBuildApplication.SetupOutputFilter;
begin
TheOutputFilter:=TOutputFilter.Create;
@ -808,6 +894,14 @@ begin
exit;
end;
end;
if BuildIDE then begin
if not BuildLazarusIDE then begin
writeln('Failed building Lazarus IDE');
ExitCode := ErrorBuildFailed;
exit;
end;
end;
end;
function TLazBuildApplication.ParseParameters: boolean;
@ -845,6 +939,7 @@ begin
LongOptions.Add('scp:');
LongOptions.Add('language:');
LongOptions.Add('build-all');
LongOptions.Add('build-ide:');
LongOptions.Add('recursive');
LongOptions.Add('skip-dependencies');
LongOptions.Add('widgetset:');
@ -860,9 +955,15 @@ begin
exit;
end;
// building IDE
if HasOption('build-ide') then begin
BuildIDE:=true;
BuildIDEOptions:=GetOptionValue('build-ide');
end;
// files
Files.Assign(NonOptions);
if Files.Count=0 then begin
if (Files.Count=0) and (not BuildIDE) then begin
writeln('Error: missing file');
WriteUsage;
exit;
@ -887,7 +988,7 @@ begin
BuildRecursive:=true;
if HasOption('d','skip-dependencies') then
SkipDependencies:=true;
// overides
// widgetset
if HasOption('ws') then
@ -930,8 +1031,9 @@ begin
writeln('--help or -? ', listhisHelpMessage);
writeln('');
writeln('-B or --build-all ','build all files of project/package');
writeln('-r or --recursive ','apply build flags (-B) to dependencies too.');
writeln('-r or --recursive ','apply build flags (-B) to dependencies too');
writeln('-d or --skip-dependencies ','do not compile dependencies');
writeln('--build-ide=<options> ','build IDE with packages');
writeln('-v or --version ','show version and exit');
writeln('');
writeln(PrimaryConfPathOptLong,'<path>');

View File

@ -9696,7 +9696,7 @@ begin
EnvironmentOptions.MakeFilename,
Flags+[blfWithoutCompilingIDE,blfWithoutLinkingIDE]);
if Result<>mrOk then begin
DebugLn('TMainIDE.DoBuildLazarus: Build Lazarus without linking failed.');
DebugLn('TMainIDE.DoBuildLazarus: Building standard components (LCL, SynEdit, CodeTools) failed.');
exit;
end;
@ -14004,7 +14004,7 @@ begin
writeln('');
writeln('[TMainIDE.OnPropHookShowMethod] ************ "',AMethodName,'" ',ActiveUnitInfo.Filename);
{$ENDIF}
if CodeToolBoss.JumpToPublishedMethodBody(ActiveUnitInfo.Source,
ActiveUnitInfo.Component.ClassName,AMethodName,
NewSource,NewX,NewY,NewTopLine) then

View File

@ -168,6 +168,11 @@ type
var
MainIDE: TMainIDEBase = nil;
{ Normally the IDE builds itself with packages named in config files.
When the IDE should keep the packages installed in the current executable
set KeepInstalledPackages to true. }
var KeepInstalledPackages: boolean = false;
implementation

View File

@ -103,7 +103,7 @@ const
'AllOpenProjectsAndPackages'
);
var MiscellaneousOptions: TMiscellaneousOptions;
var MiscellaneousOptions: TMiscellaneousOptions = nil;
function SortDirectionNameToType(const s: string): TSortDirection;
function SortDomainNameToType(const s: string): TSortDomain;

View File

@ -108,6 +108,7 @@ type
FDefaultPackage: TLazPackage;
FErrorMsg: string;
FFCLPackage: TLazPackage;
FFirstAutoInstallDependency: TPkgDependency;
FIDEIntfPackage: TLazPackage;
FItems: TFPList; // unsorted list of TLazPackage
FLazarusBasePackages: TFPList;
@ -329,6 +330,9 @@ type
property IDEIntfPackage: TLazPackage read FIDEIntfPackage;
property LazarusBasePackages: TFPList read FLazarusBasePackages;
property DefaultPackage: TLazPackage read FDefaultPackage;// fall back package for buggy/obsoleted stuff
property FirstAutoInstallDependency: TPkgDependency
read FFirstAutoInstallDependency write FFirstAutoInstallDependency;
property OnAddPackage: TPkgAddedEvent read FOnAddPackage write FOnAddPackage;
property OnBeginUpdate: TNotifyEvent read FOnBeginUpdate write FOnBeginUpdate;
property OnChangePackageName: TPkgChangeNameEvent read FOnChangePackageName

View File

@ -158,7 +158,6 @@ type
function LoadDependencyList(FirstDependency: TPkgDependency): TModalResult;
procedure OnOpenPackageForCurrentSrcEditFile(Sender: TObject);
private
FirstAutoInstallDependency: TPkgDependency;
// helper functions
function DoShowSavePackageAsDialog(APackage: TLazPackage): TModalResult;
function DoWriteMakefile(APackage: TLazPackage): TModalResult;
@ -451,7 +450,7 @@ begin
NewFirstAutoInstallDependency:=nil;
PkgList:=nil;
try
if ShowEditInstallPkgsDialog(FirstAutoInstallDependency,
if ShowEditInstallPkgsDialog(PackageGraph.FirstAutoInstallDependency,
@OnCheckInstallPackageList,PkgIDList,RebuildIDE)<>mrOk
then exit;
@ -467,7 +466,7 @@ begin
// tell the user, which packages will stay, which will be removed and
// which will be newly installed
Report:=CreateChangeReport(FirstAutoInstallDependency,
Report:=CreateChangeReport(PackageGraph.FirstAutoInstallDependency,
NewFirstAutoInstallDependency);
if IDEMessageDialog(lisConfirmNewPackageSetForTheIDE,
Format(lisThisWillHappenContinue, [#13#13, Report, #13]), mtConfirmation,
@ -492,7 +491,7 @@ begin
// mark packages for uninstall
//debugln('TPkgManager.MainIDEitmPkgEditInstallPkgsClick mark packages for uninstall');
CurDependency:=FirstAutoInstallDependency;
CurDependency:=PackageGraph.FirstAutoInstallDependency;
while CurDependency<>nil do begin
if (CurDependency.RequiredPackage<>nil)
and (not CurDependency.RequiredPackage.AutoCreated) then
@ -502,8 +501,8 @@ begin
// replace install list
//debugln('TPkgManager.MainIDEitmPkgEditInstallPkgsClick replace install list');
FreeDependencyList(FirstAutoInstallDependency,pdlRequires);
FirstAutoInstallDependency:=NewFirstAutoInstallDependency;
FreeDependencyList(PackageGraph.FirstAutoInstallDependency,pdlRequires);
PackageGraph.FirstAutoInstallDependency:=NewFirstAutoInstallDependency;
NewFirstAutoInstallDependency:=nil;
finally
PackageGraph.EndUpdate;
@ -1604,7 +1603,7 @@ begin
end;
sl:=TStringList.Create;
Dependency:=FirstAutoInstallDependency;
Dependency:=PackageGraph.FirstAutoInstallDependency;
while Dependency<>nil do begin
if (Dependency.LoadPackageResult=lprSuccess)
and (not Dependency.RequiredPackage.AutoCreated)
@ -1635,7 +1634,7 @@ begin
BasePackage:=TLazPackage(PackageGraph.LazarusBasePackages[i]);
Dependency:=BasePackage.CreateDependencyWithOwner(Self);
PackageGraph.OpenDependency(Dependency);
Dependency.AddToList(FirstAutoInstallDependency,pdlRequires)
Dependency.AddToList(PackageGraph.FirstAutoInstallDependency,pdlRequires)
end;
SortAutoInstallDependencies;
@ -1673,8 +1672,7 @@ begin
end;
// load package
APackage:=LoadInstalledPackage(StaticPackage^.Name,
{$IFDEF BigIDE}True{$ELSE}False{$ENDIF},
APackage:=LoadInstalledPackage(StaticPackage^.Name,KeepInstalledPackages,
Quiet);
// register
@ -1697,7 +1695,7 @@ begin
PackageGraph.OpenInstalledDependency(NewDependency,pitStatic,Quiet);
Result:=NewDependency.RequiredPackage;
if AddToAutoInstall and (Result<>nil) then begin
NewDependency.AddToList(FirstAutoInstallDependency,pdlRequires);
NewDependency.AddToList(PackageGraph.FirstAutoInstallDependency,pdlRequires);
PackageList:=MiscellaneousOptions.BuildLazOpts.StaticAutoInstallPackages;
if PackageList.IndexOf(NewDependency.PackageName)<0 then
PackageList.Add(NewDependency.PackageName);
@ -1719,14 +1717,14 @@ begin
for i:=0 to PkgList.Count-1 do begin
PackageName:=PkgList[i];
if (PackageName='') or (not IsValidIdent(PackageName)) then continue;
Dependency:=FindDependencyByNameInList(FirstAutoInstallDependency,
Dependency:=FindDependencyByNameInList(PackageGraph.FirstAutoInstallDependency,
pdlRequires,PackageName);
//DebugLn('TPkgManager.LoadAutoInstallPackages ',dbgs(Dependency),' ',PackageName);
if Dependency<>nil then continue;
Dependency:=TPkgDependency.Create;
Dependency.Owner:=Self;
Dependency.PackageName:=PackageName;
Dependency.AddToList(FirstAutoInstallDependency,pdlRequires);
Dependency.AddToList(PackageGraph.FirstAutoInstallDependency,pdlRequires);
if PackageGraph.OpenDependency(Dependency)<>lprSuccess then begin
IDEMessageDialog(lisPkgMangUnableToLoadPackage,
Format(lisPkgMangUnableToOpenThePackage, ['"', PackageName, '"', #13]),
@ -1742,7 +1740,7 @@ end;
procedure TPkgManager.SortAutoInstallDependencies;
begin
// sort install dependencies, so that lower packages come first
PackageGraph.SortDependencyListTopologically(FirstAutoInstallDependency,
PackageGraph.SortDependencyListTopologically(PackageGraph.FirstAutoInstallDependency,
false);
end;
@ -1844,10 +1842,10 @@ begin
if IDEComponentPalette<>nil then
TComponentPalette(IDEComponentPalette).Notebook:=nil;
FreeThenNil(LazPackageDescriptors);
while FirstAutoInstallDependency<>nil do begin
Dependency:=FirstAutoInstallDependency;
while PackageGraph.FirstAutoInstallDependency<>nil do begin
Dependency:=PackageGraph.FirstAutoInstallDependency;
Dependency.RequiredPackage:=nil;
Dependency.RemoveFromList(FirstAutoInstallDependency,pdlRequires);
Dependency.RemoveFromList(PackageGraph.FirstAutoInstallDependency,pdlRequires);
Dependency.Free;
end;
FreeThenNil(PackageGraphExplorer);
@ -1954,10 +1952,10 @@ var
Dependency: TPkgDependency;
begin
// break and free auto installed packages
while FirstAutoInstallDependency<>nil do begin
Dependency:=FirstAutoInstallDependency;
while PackageGraph.FirstAutoInstallDependency<>nil do begin
Dependency:=PackageGraph.FirstAutoInstallDependency;
Dependency.RequiredPackage:=nil;
Dependency.RemoveFromList(FirstAutoInstallDependency,pdlRequires);
Dependency.RemoveFromList(PackageGraph.FirstAutoInstallDependency,pdlRequires);
Dependency.Free;
end;
end;
@ -2000,7 +1998,7 @@ var
i: Integer;
begin
PkgList:=nil;
OnGetAllRequiredPackages(FirstAutoInstallDependency,PkgList);
OnGetAllRequiredPackages(PackageGraph.FirstAutoInstallDependency,PkgList);
if PkgList=nil then exit;
for i:=0 to PkgList.Count-1 do
if TObject(PkgList[i]) is TLazPackage then
@ -3628,7 +3626,7 @@ begin
if RequiredPackage.AutoInstall=pitNope then begin
RequiredPackage.AutoInstall:=pitStatic;
Dependency:=RequiredPackage.CreateDependencyWithOwner(Self);
Dependency.AddToList(FirstAutoInstallDependency,pdlRequires);
Dependency.AddToList(PackageGraph.FirstAutoInstallDependency,pdlRequires);
PackageGraph.OpenDependency(Dependency);
NeedSaving:=true;
end;
@ -3706,10 +3704,10 @@ begin
// remove package from auto installed packages
if APackage.AutoInstall<>pitNope then begin
APackage.AutoInstall:=pitNope;
Dependency:=FindCompatibleDependencyInList(FirstAutoInstallDependency,
Dependency:=FindCompatibleDependencyInList(PackageGraph.FirstAutoInstallDependency,
pdlRequires,APackage);
if Dependency<>nil then begin
Dependency.RemoveFromList(FirstAutoInstallDependency,pdlRequires);
Dependency.RemoveFromList(PackageGraph.FirstAutoInstallDependency,pdlRequires);
Dependency.Free;
SortAutoInstallDependencies;
end;
@ -3785,7 +3783,7 @@ var
begin
PackageGraph.BeginUpdate(false);
try
Dependency:=FirstAutoInstallDependency;
Dependency:=PackageGraph.FirstAutoInstallDependency;
while Dependency<>nil do begin
OldDependency:=Dependency;
Dependency:=Dependency.NextRequiresDependency;
@ -3796,14 +3794,14 @@ begin
mtError,[mbYes,mbNo,mbAbort]);
if Result=mrNo then Result:=mrCancel;
if Result<>mrYes then exit;
OldDependency.RemoveFromList(FirstAutoInstallDependency,pdlRequires);
OldDependency.RemoveFromList(PackageGraph.FirstAutoInstallDependency,pdlRequires);
OldDependency.Free;
SaveAutoInstallDependencies(true);
end;
end;
// check consistency
Result:=CheckPackageGraphForCompilation(nil,FirstAutoInstallDependency,
Result:=CheckPackageGraphForCompilation(nil,PackageGraph.FirstAutoInstallDependency,
EnvironmentOptions.LazarusDirectory);
if Result<>mrOk then exit;
//DebugLn(['TPkgManager.DoCompileAutoInstallPackages LCLUnitPath=',PackageGraph.LCLPackage.CompilerOptions.GetUnitPath(true)]);
@ -3815,7 +3813,7 @@ begin
end;
// compile all auto install dependencies
Result:=PackageGraph.CompileRequiredPackages(nil,FirstAutoInstallDependency,
Result:=PackageGraph.CompileRequiredPackages(nil,PackageGraph.FirstAutoInstallDependency,
MiscellaneousOptions.BuildLazOpts.Globals,[pupAsNeeded]);
if Result<>mrOk then exit;
@ -3837,7 +3835,7 @@ begin
// create auto install package list for the Lazarus uses section
StaticPackagesInc:='';
Dependency:=FirstAutoInstallDependency;
Dependency:=PackageGraph.FirstAutoInstallDependency;
while Dependency<>nil do begin
if (Dependency.RequiredPackage<>nil)
and (not Dependency.RequiredPackage.AutoCreated) then
@ -3884,7 +3882,7 @@ begin
// get all required packages
PkgList:=nil;
OnGetAllRequiredPackages(FirstAutoInstallDependency,PkgList);
OnGetAllRequiredPackages(PackageGraph.FirstAutoInstallDependency,PkgList);
if PkgList=nil then exit;
// get all usage options
AddOptionsList:=GetUsageOptionsList(PkgList);