IDE: compile IDE with only base packages

git-svn-id: trunk@28612 -
This commit is contained in:
mattias 2010-12-03 16:32:25 +00:00
parent 512bbdeb86
commit 98d8c393c9
6 changed files with 112 additions and 71 deletions

View File

@ -1880,7 +1880,7 @@ begin
NewTargetOS:=GetDefaultTargetOS; NewTargetOS:=GetDefaultTargetOS;
if (NewTargetCPU='') or (NewTargetCPU='default') then if (NewTargetCPU='') or (NewTargetCPU='default') then
NewTargetCPU:=GetDefaultTargetCPU; NewTargetCPU:=GetDefaultTargetCPU;
//debugln(['TBuildManager.SetBuildTargetIDE OS=',NewTargetOS,' CPU=',NewTargetCPU,' WS=',NewLCLWidgetSet]); debugln(['TBuildManager.SetBuildTargetIDE OS=',NewTargetOS,' CPU=',NewTargetCPU,' WS=',NewLCLWidgetSet]);
SetBuildTarget(NewTargetOS,NewTargetCPU,NewLCLWidgetSet,bmsfsBackground); SetBuildTarget(NewTargetOS,NewTargetCPU,NewLCLWidgetSet,bmsfsBackground);
end; end;

View File

@ -11498,7 +11498,8 @@ begin
if (blfWithStaticPackages in Flags) if (blfWithStaticPackages in Flags)
or MiscellaneousOptions.BuildLazOpts.WithStaticPackages then begin or MiscellaneousOptions.BuildLazOpts.WithStaticPackages then begin
// create inherited compiler options // create inherited compiler options
PkgOptions:=PkgBoss.DoGetIDEInstallPackageOptions(InheritedOptionStrings); PkgOptions:=PackageGraph.GetIDEInstallPackageOptions(
PackageGraph.FirstAutoInstallDependency,InheritedOptionStrings);
// check ambiguous units // check ambiguous units
CodeToolBoss.GetFPCVersionForDirectory( CodeToolBoss.GetFPCVersionForDirectory(
@ -11521,6 +11522,7 @@ var
InheritedOptionStrings: TInheritedCompOptsStrings; InheritedOptionStrings: TInheritedCompOptsStrings;
CompiledUnitExt: String; CompiledUnitExt: String;
FPCVersion, FPCRelease, FPCPatch: integer; FPCVersion, FPCRelease, FPCPatch: integer;
OnlyBase: boolean;
begin begin
if ToolStatus<>itNone then begin if ToolStatus<>itNone then begin
MessageDlg(lisNotNow, MessageDlg(lisNotNow,
@ -11556,57 +11558,65 @@ begin
end; end;
// then compile the 'installed' packages // then compile the 'installed' packages
if ([blfWithStaticPackages,blfOnlyIDE]*Flags=[]) if (not (blfOnlyIDE in Flags))
and (MiscellaneousOptions.BuildLazProfiles.CurrentIdeMode=mmNone) then begin and (MiscellaneousOptions.BuildLazProfiles.CurrentIdeMode=mmNone) then begin
CompileProgress.Ready; CompileProgress.Ready;
Result:=mrIgnore; Result:=mrIgnore;
exit; exit;
end; end;
OnlyBase:=not (blfWithStaticPackages in Flags);
// prepare static auto install packages // prepare static auto install packages
PkgOptions:=''; PkgOptions:='';
if (blfWithStaticPackages in Flags) // compile auto install static packages
or MiscellaneousOptions.BuildLazOpts.WithStaticPackages then begin Result:=PkgBoss.DoCompileAutoInstallPackages([],OnlyBase);
// compile auto install static packages if Result<>mrOk then begin
Result:=PkgBoss.DoCompileAutoInstallPackages([]); DebugLn('TMainIDE.DoBuildLazarus: Compile AutoInstall Packages failed.');
if Result<>mrOk then begin exit;
DebugLn('TMainIDE.DoBuildLazarus: Compile AutoInstall Packages failed.'); end;
exit;
end;
// create uses section addition for lazarus.pp // create uses section addition for lazarus.pp
if not OnlyBase then begin
Result:=PkgBoss.DoSaveAutoInstallConfig; Result:=PkgBoss.DoSaveAutoInstallConfig;
if Result<>mrOk then begin if Result<>mrOk then begin
DebugLn('TMainIDE.DoBuildLazarus: Save AutoInstall Config failed.'); DebugLn('TMainIDE.DoBuildLazarus: Save AutoInstall Config failed.');
exit; exit;
end; end;
end;
// create inherited compiler options // create inherited compiler options
PkgOptions:=PkgBoss.DoGetIDEInstallPackageOptions(InheritedOptionStrings); if OnlyBase then
PkgOptions:=''
else
PkgOptions:=PackageGraph.GetIDEInstallPackageOptions(
PackageGraph.FirstAutoInstallDependency,InheritedOptionStrings);
// check ambiguous units // check ambiguous units
CodeToolBoss.GetFPCVersionForDirectory( CodeToolBoss.GetFPCVersionForDirectory(
EnvironmentOptions.LazarusDirectory, EnvironmentOptions.LazarusDirectory,
FPCVersion,FPCRelease,FPCPatch); FPCVersion,FPCRelease,FPCPatch);
if FPCPatch=0 then ; if FPCPatch=0 then ;
CompiledUnitExt:=GetDefaultCompiledUnitExt(FPCVersion,FPCRelease); CompiledUnitExt:=GetDefaultCompiledUnitExt(FPCVersion,FPCRelease);
Result:=MainBuildBoss.CheckUnitPathForAmbiguousPascalFiles( Result:=MainBuildBoss.CheckUnitPathForAmbiguousPascalFiles(
EnvironmentOptions.LazarusDirectory, EnvironmentOptions.LazarusDirectory+PathDelim+'ide',
InheritedOptionStrings[icoUnitPath], InheritedOptionStrings[icoUnitPath],
CompiledUnitExt,'IDE'); CompiledUnitExt,'IDE');
if Result<>mrOk then begin if Result<>mrOk then begin
DebugLn('TMainIDE.DoBuildLazarus: Check UnitPath for ambiguous pascal files failed.'); DebugLn('TMainIDE.DoBuildLazarus: Check UnitPath for ambiguous pascal files failed.');
exit; exit;
end;
end; end;
// save extra options // save extra options
IDEBuildFlags:=Flags+[blfOnlyIDE]; IDEBuildFlags:=Flags+[blfOnlyIDE];
Result:=SaveIDEMakeOptions(MiscellaneousOptions.BuildLazProfiles, if not OnlyBase then
GlobalMacroList,PkgOptions,IDEBuildFlags); begin
if Result<>mrOk then begin Result:=SaveIDEMakeOptions(MiscellaneousOptions.BuildLazProfiles,
DebugLn('TMainIDE.DoBuildLazarus: Save IDEMake options failed.'); GlobalMacroList,PkgOptions,IDEBuildFlags);
exit; if Result<>mrOk then begin
DebugLn('TMainIDE.DoBuildLazarus: Save IDEMake options failed.');
exit;
end;
end; end;
// make ide // make ide

View File

@ -139,13 +139,10 @@ type
procedure LoadInstalledPackages; virtual; abstract; procedure LoadInstalledPackages; virtual; abstract;
function DoShowOpenInstalledPckDlg: TModalResult; virtual; abstract; function DoShowOpenInstalledPckDlg: TModalResult; virtual; abstract;
function ShowConfigureCustomComponents: TModalResult; virtual; abstract; function ShowConfigureCustomComponents: TModalResult; virtual; abstract;
function DoCompileAutoInstallPackages(Flags: TPkgCompileFlags function DoCompileAutoInstallPackages(Flags: TPkgCompileFlags;
): TModalResult; virtual; abstract; OnlyBase: boolean): TModalResult; virtual; abstract;
function DoSaveAutoInstallConfig: TModalResult; virtual; abstract; function DoSaveAutoInstallConfig: TModalResult; virtual; abstract;
function DoGetIDEInstallPackageOptions(
var InheritedOptionStrings: TInheritedCompOptsStrings
): string; virtual; abstract;
// components // components
function GetUsableComponentUnits(CurRoot: TPersistent): TFPList; virtual; abstract; // list of TUnitInfo function GetUsableComponentUnits(CurRoot: TPersistent): TFPList; virtual; abstract; // list of TUnitInfo
procedure IterateComponentNames(CurRoot: TPersistent; TypeData: PTypeData; procedure IterateComponentNames(CurRoot: TPersistent; TypeData: PTypeData;

View File

@ -874,7 +874,7 @@ function GetPkgFileTypeLocalizedName(FileType: TPkgFileType): string;
function NameToAutoUpdatePolicy(const s: string): TPackageUpdatePolicy; function NameToAutoUpdatePolicy(const s: string): TPackageUpdatePolicy;
function FileNameToPkgFileType(const AFilename: string): TPkgFileType; function FileNameToPkgFileType(const AFilename: string): TPkgFileType;
procedure SortDependencyList(Dependencies: TFPList); procedure SortDependencyListAlphabetically(Dependencies: TFPList);
procedure LoadPkgDependencyList(XMLConfig: TXMLConfig; const ThePath: string; procedure LoadPkgDependencyList(XMLConfig: TXMLConfig; const ThePath: string;
var First: TPkgDependency; ListType: TPkgDependencyList; Owner: TObject; var First: TPkgDependency; ListType: TPkgDependencyList; Owner: TObject;
HoldPackages, SortList: boolean); HoldPackages, SortList: boolean);
@ -897,6 +897,8 @@ function GetDependencyWithIndex(First: TPkgDependency;
ListType: TPkgDependencyList; Index: integer): TPkgDependency; ListType: TPkgDependencyList; Index: integer): TPkgDependency;
function IndexOfDependencyInList(First: TPkgDependency; function IndexOfDependencyInList(First: TPkgDependency;
ListType: TPkgDependencyList; FindDependency: TPkgDependency): integer; ListType: TPkgDependencyList; FindDependency: TPkgDependency): integer;
function GetFirstDependency(ListItem: TPkgDependency;
ListType: TPkgDependencyList): TPkgDependency;
function FindLowestPkgDependencyWithName(const PkgName: string): TPkgDependency; function FindLowestPkgDependencyWithName(const PkgName: string): TPkgDependency;
function FindLowestPkgDependencyNodeWithName(const PkgName: string): TAVLTreeNode; function FindLowestPkgDependencyNodeWithName(const PkgName: string): TAVLTreeNode;
@ -999,7 +1001,7 @@ begin
PkgDependency.Free; PkgDependency.Free;
end; end;
if SortList then if SortList then
SortDependencyList(List); SortDependencyListAlphabetically(List);
Last:=First; Last:=First;
if Last<>nil then if Last<>nil then
while Last.NextDependency[ListType]<>nil do while Last.NextDependency[ListType]<>nil do
@ -1072,7 +1074,7 @@ begin
end; end;
end; end;
procedure SortDependencyList(Dependencies: TFPList); procedure SortDependencyListAlphabetically(Dependencies: TFPList);
var var
Count: Integer; Count: Integer;
i, j: Integer; i, j: Integer;
@ -1382,6 +1384,15 @@ begin
Result:=-1; Result:=-1;
end; end;
function GetFirstDependency(ListItem: TPkgDependency;
ListType: TPkgDependencyList): TPkgDependency;
begin
Result:=ListItem;
if Result=nil then exit;
while Result.PrevDependency[ListType]<>nil do
Result:=Result.PrevDependency[ListType];
end;
function FindLowestPkgDependencyWithName(const PkgName: string): TPkgDependency; function FindLowestPkgDependencyWithName(const PkgName: string): TPkgDependency;
var var
ANode: TAVLTreeNode; ANode: TAVLTreeNode;

View File

@ -299,7 +299,7 @@ type
procedure LoadStaticBasePackages; procedure LoadStaticBasePackages;
procedure LoadAutoInstallPackages(PkgList: TStringList); procedure LoadAutoInstallPackages(PkgList: TStringList);
procedure SortAutoInstallDependencies; procedure SortAutoInstallDependencies;
function GetIDEInstallPackageOptions( function GetIDEInstallPackageOptions(FirstDependency: TPkgDependency;
var InheritedOptionStrings: TInheritedCompOptsStrings): string; var InheritedOptionStrings: TInheritedCompOptsStrings): string;
function SaveAutoInstallConfig: TModalResult;// for the uses section function SaveAutoInstallConfig: TModalResult;// for the uses section
function IsStaticBasePackage(PackageName: string): boolean; function IsStaticBasePackage(PackageName: string): boolean;
@ -1947,6 +1947,7 @@ begin
end; end;
function TLazPackageGraph.GetIDEInstallPackageOptions( function TLazPackageGraph.GetIDEInstallPackageOptions(
FirstDependency: TPkgDependency;
var InheritedOptionStrings: TInheritedCompOptsStrings): string; var InheritedOptionStrings: TInheritedCompOptsStrings): string;
procedure AddOption(const s: string); procedure AddOption(const s: string);
@ -1968,7 +1969,7 @@ begin
// get all required packages // get all required packages
PkgList:=nil; PkgList:=nil;
OnGetAllRequiredPackages(PackageGraph.FirstAutoInstallDependency,PkgList); OnGetAllRequiredPackages(FirstDependency,PkgList);
if PkgList=nil then exit; if PkgList=nil then exit;
// get all usage options // get all usage options
AddOptionsList:=GetUsageOptionsList(PkgList); AddOptionsList:=GetUsageOptionsList(PkgList);

View File

@ -308,12 +308,9 @@ type
CheckList: boolean = true): TModalResult; CheckList: boolean = true): TModalResult;
procedure DoTranslatePackage(APackage: TLazPackage); procedure DoTranslatePackage(APackage: TLazPackage);
function DoOpenPackageSource(APackage: TLazPackage): TModalResult; function DoOpenPackageSource(APackage: TLazPackage): TModalResult;
function DoCompileAutoInstallPackages(Flags: TPkgCompileFlags function DoCompileAutoInstallPackages(Flags: TPkgCompileFlags;
): TModalResult; override; OnlyBase: boolean): TModalResult; override;
function DoSaveAutoInstallConfig: TModalResult; override; function DoSaveAutoInstallConfig: TModalResult; override;
function DoGetIDEInstallPackageOptions(
var InheritedOptionStrings: TInheritedCompOptsStrings
): string; override;
function DoPublishPackage(APackage: TLazPackage; Flags: TPkgSaveFlags; function DoPublishPackage(APackage: TLazPackage; Flags: TPkgSaveFlags;
ShowDialog: boolean): TModalResult; ShowDialog: boolean): TModalResult;
@ -3917,34 +3914,64 @@ begin
Result:=MainIDE.DoOpenEditorFile(Filename,-1,-1,[ofRegularFile]); Result:=MainIDE.DoOpenEditorFile(Filename,-1,-1,[ofRegularFile]);
end; end;
function TPkgManager.DoCompileAutoInstallPackages( function TPkgManager.DoCompileAutoInstallPackages(Flags: TPkgCompileFlags;
Flags: TPkgCompileFlags): TModalResult; OnlyBase: boolean): TModalResult;
var var
Dependency: TPkgDependency; Dependency: TPkgDependency;
OldDependency: TPkgDependency; OldDependency: TPkgDependency;
Dependencies: TPkgDependency;
AutoRemove: Boolean;
begin begin
PackageGraph.BeginUpdate(false); PackageGraph.BeginUpdate(false);
Dependencies:=PackageGraph.FirstAutoInstallDependency;
try try
Dependency:=PackageGraph.FirstAutoInstallDependency; if OnlyBase then
begin
// create the list of base packages
OldDependency:=PackageGraph.FirstAutoInstallDependency;
Dependencies:=nil;
while OldDependency<>nil do begin
if (OldDependency.RequiredPackage<>nil)
and PackageGraph.IsStaticBasePackage(OldDependency.RequiredPackage.Name) then
begin
Dependency:=TPkgDependency.Create;
Dependency.Assign(OldDependency);
Dependency.AddToEndOfList(Dependencies,pdlRequires);
end;
OldDependency:=OldDependency.NextRequiresDependency;
end;
Dependencies:=GetFirstDependency(Dependencies,pdlRequires);
PackageGraph.OpenRequiredDependencyList(Dependencies);
end;
// check every installed package if it was loaded correctly
Dependency:=Dependencies;
AutoRemove:=false;
while Dependency<>nil do begin while Dependency<>nil do begin
OldDependency:=Dependency; OldDependency:=Dependency;
Dependency:=Dependency.NextRequiresDependency; Dependency:=Dependency.NextRequiresDependency;
if OldDependency.LoadPackageResult<>lprSuccess then begin if OldDependency.LoadPackageResult<>lprSuccess then begin
Result:=IDEMessageDialog(lisProjAddPackageNotFound, if not AutoRemove then begin
Format(lisPkgMangThePackageIsMarkedForInstallationButCanNotBeFound, [ Result:=IDEMessageDialog(lisProjAddPackageNotFound,
'"', OldDependency.AsString, '"', #13]), Format(lisPkgMangThePackageIsMarkedForInstallationButCanNotBeFound, [
mtError,[mbYes,mbNo,mbAbort]); '"', OldDependency.AsString, '"', #13]),
if Result=mrNo then Result:=mrCancel; mtError,[mbYes,mbYesToAll,mbAbort]);
if Result<>mrYes then exit; case Result of
mrYes: ;
mrYesToAll: AutoRemove:=true;
else
SaveAutoInstallDependencies(true);
exit;
end;
end;
OldDependency.RemoveFromList(PackageGraph.FirstAutoInstallDependency,pdlRequires); OldDependency.RemoveFromList(PackageGraph.FirstAutoInstallDependency,pdlRequires);
OldDependency.Free; OldDependency.Free;
SaveAutoInstallDependencies(true);
end; end;
end; end;
SaveAutoInstallDependencies(true);
// check consistency // check consistency
Result:=CheckPackageGraphForCompilation(nil, Result:=CheckPackageGraphForCompilation(nil,Dependencies,
PackageGraph.FirstAutoInstallDependency,
EnvironmentOptions.LazarusDirectory,false); EnvironmentOptions.LazarusDirectory,false);
if Result<>mrOk then exit; if Result<>mrOk then exit;
//DebugLn(['TPkgManager.DoCompileAutoInstallPackages LCLUnitPath=',PackageGraph.LCLPackage.CompilerOptions.GetUnitPath(true)]); //DebugLn(['TPkgManager.DoCompileAutoInstallPackages LCLUnitPath=',PackageGraph.LCLPackage.CompilerOptions.GetUnitPath(true)]);
@ -3957,12 +3984,13 @@ begin
// compile all auto install dependencies // compile all auto install dependencies
MiscellaneousOptions.BuildLazProfiles.UpdateGlobals; MiscellaneousOptions.BuildLazProfiles.UpdateGlobals;
Result:=PackageGraph.CompileRequiredPackages(nil, Result:=PackageGraph.CompileRequiredPackages(nil,Dependencies,
PackageGraph.FirstAutoInstallDependency, MiscellaneousOptions.BuildLazProfiles.Globals,[pupAsNeeded]);
MiscellaneousOptions.BuildLazProfiles.Globals,[pupAsNeeded]);
if Result<>mrOk then exit; if Result<>mrOk then exit;
finally finally
if OnlyBase then
FreeDependencyList(Dependencies,pdlRequires);
PackageGraph.EndUpdate; PackageGraph.EndUpdate;
end; end;
Result:=mrOk; Result:=mrOk;
@ -3986,12 +4014,6 @@ begin
Result:=PackageGraph.SaveAutoInstallConfig; Result:=PackageGraph.SaveAutoInstallConfig;
end; end;
function TPkgManager.DoGetIDEInstallPackageOptions(
var InheritedOptionStrings: TInheritedCompOptsStrings): string;
begin
Result:=PackageGraph.GetIDEInstallPackageOptions(InheritedOptionStrings);
end;
function TPkgManager.DoPublishPackage(APackage: TLazPackage; function TPkgManager.DoPublishPackage(APackage: TLazPackage;
Flags: TPkgSaveFlags; ShowDialog: boolean): TModalResult; Flags: TPkgSaveFlags; ShowDialog: boolean): TModalResult;
begin begin