mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-09 04:07:57 +02:00
IDE: warn when the project overrides a package output directory
git-svn-id: trunk@41585 -
This commit is contained in:
parent
985a7b4d07
commit
f2565fbe59
@ -24,6 +24,10 @@
|
||||
Options frame for build mode matrix options.
|
||||
|
||||
ToDo:
|
||||
- update matrix, when deleting build mode
|
||||
- move inherited to show options
|
||||
- move conditionals to Other
|
||||
- move IDE macros only for package usage
|
||||
- undo: combine changes while editing a cell
|
||||
}
|
||||
unit Compiler_ModeMatrix;
|
||||
|
@ -759,7 +759,7 @@
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="include"/>
|
||||
<OtherUnitFiles Value="frames;../converter;../debugger;../debugger/frames;../packager;../designer;../packager/frames;../ide"/>
|
||||
<OtherUnitFiles Value="frames;../converter;../debugger;../debugger/frames;../packager;../designer;../packager/frames;../ide;../packager"/>
|
||||
<UnitOutputDirectory Value="$(LazarusDir)/units/$(TargetCPU)-$(TargetOS)/$(LCLWidgetType)"/>
|
||||
</SearchPaths>
|
||||
<Other>
|
||||
|
@ -3072,6 +3072,9 @@ resourcestring
|
||||
// Build lazarus dialog
|
||||
lisConfirmLazarusRebuild = 'Do you want to rebuild Lazarus with profile: %s ?';
|
||||
lisConfirmation = 'Confirmation';
|
||||
lisPkgTheProjectOverridesTheOutputDirectoryOfTheFollowin = 'The project '
|
||||
+'overrides the output directory of the following packages.%sSee Project /'
|
||||
+' Project Options / Additions and Overrides%s%s%s';
|
||||
lisConfirmBuildAllProfiles = 'Lazarus will be rebuilt with the following profiles:%sContinue?';
|
||||
lisNoBuildProfilesSelected = 'No profiles are selected to be built.';
|
||||
lisCleanLazarusSource = 'Clean Lazarus Source';
|
||||
|
@ -6901,7 +6901,6 @@ begin
|
||||
// show messages
|
||||
IDEWindowCreators.ShowForm(MessagesView,EnvironmentOptions.MsgViewFocus);
|
||||
MessagesView.BeginBlock;
|
||||
|
||||
try
|
||||
Result:=DoSaveForBuild(AReason);
|
||||
if Result<>mrOk then begin
|
||||
|
@ -387,7 +387,7 @@ type
|
||||
end;
|
||||
|
||||
var
|
||||
MainIDEBar: TMainIDEBar;
|
||||
MainIDEBar: TMainIDEBar = nil;
|
||||
|
||||
implementation
|
||||
|
||||
|
@ -93,10 +93,11 @@ type
|
||||
Flags: TPkgUninstallFlags; ShowAbort: boolean): TModalResult of object;
|
||||
TPkgTranslate = procedure(APackage: TLazPackage) of object;
|
||||
TDependencyModifiedEvent = procedure(ADependency: TPkgDependency) of object;
|
||||
TEndUpdateEvent = procedure(Sender: TObject; GraphChanged: boolean) of object;
|
||||
TPkgGraphEndUpdateEvent = procedure(Sender: TObject; GraphChanged: boolean) of object;
|
||||
TFindFPCUnitEvent = procedure(const AUnitName, Directory: string;
|
||||
var Filename: string) of object;
|
||||
TPkgDeleteAmbiguousFiles = function(const Filename: string): TModalResult of object;
|
||||
TOnBeforeCompilePackages = function(aPkgList: TFPList): TModalResult of object;
|
||||
|
||||
{ TLazPackageGraph }
|
||||
|
||||
@ -115,12 +116,13 @@ type
|
||||
FLCLBasePackage: TLazPackage;
|
||||
FLCLPackage: TLazPackage;
|
||||
FOnAddPackage: TPkgAddedEvent;
|
||||
FOnBeforeCompilePackages: TOnBeforeCompilePackages;
|
||||
FOnBeginUpdate: TNotifyEvent;
|
||||
FOnChangePackageName: TPkgChangeNameEvent;
|
||||
FOnDeleteAmbiguousFiles: TPkgDeleteAmbiguousFiles;
|
||||
FOnDeletePackage: TPkgDeleteEvent;
|
||||
FOnDependencyModified: TDependencyModifiedEvent;
|
||||
FOnEndUpdate: TEndUpdateEvent;
|
||||
FOnEndUpdate: TPkgGraphEndUpdateEvent;
|
||||
FOnTranslatePackage: TPkgTranslate;
|
||||
FOnUninstallPackage: TPkgUninstall;
|
||||
FQuietRegistration: boolean;
|
||||
@ -375,13 +377,15 @@ type
|
||||
read FOnDependencyModified write FOnDependencyModified;
|
||||
property OnDeletePackage: TPkgDeleteEvent read FOnDeletePackage
|
||||
write FOnDeletePackage;
|
||||
property OnEndUpdate: TEndUpdateEvent read FOnEndUpdate write FOnEndUpdate;
|
||||
property OnEndUpdate: TPkgGraphEndUpdateEvent read FOnEndUpdate write FOnEndUpdate;
|
||||
property OnDeleteAmbiguousFiles: TPkgDeleteAmbiguousFiles
|
||||
read FOnDeleteAmbiguousFiles write FOnDeleteAmbiguousFiles;
|
||||
property OnTranslatePackage: TPkgTranslate read FOnTranslatePackage
|
||||
write FOnTranslatePackage;
|
||||
property OnUninstallPackage: TPkgUninstall read FOnUninstallPackage
|
||||
write FOnUninstallPackage;
|
||||
property OnBeforeCompilePackages: TOnBeforeCompilePackages read
|
||||
FOnBeforeCompilePackages write FOnBeforeCompilePackages;
|
||||
property Packages[Index: integer]: TLazPackage read GetPackages; default; // see Count for the number
|
||||
property RegistrationFile: TPkgFile read FRegistrationFile;
|
||||
property RegistrationPackage: TLazPackage read FRegistrationPackage
|
||||
@ -3235,10 +3239,11 @@ function TLazPackageGraph.CompileRequiredPackages(APackage: TLazPackage;
|
||||
FirstDependency: TPkgDependency; SkipDesignTimePackages: boolean;
|
||||
Policy: TPackageUpdatePolicy): TModalResult;
|
||||
var
|
||||
AutoPackages: TFPList;
|
||||
PkgList: TFPList;
|
||||
i: Integer;
|
||||
Flags: TPkgCompileFlags;
|
||||
ReqFlags: TPkgIntfRequiredFlags;
|
||||
CurPkg: TLazPackage;
|
||||
begin
|
||||
{$IFDEF VerbosePkgCompile}
|
||||
debugln('TLazPackageGraph.CompileRequiredPackages A MinPolicy=',dbgs(Policy),' SkipDesignTimePackages=',SkipDesignTimePackages);
|
||||
@ -3246,11 +3251,21 @@ begin
|
||||
ReqFlags:=[pirCompileOrder];
|
||||
if SkipDesignTimePackages then
|
||||
Include(ReqFlags,pirSkipDesignTimeOnly);
|
||||
GetAllRequiredPackages(APackage,FirstDependency,AutoPackages,ReqFlags,Policy);
|
||||
if AutoPackages<>nil then begin
|
||||
//DebugLn('TLazPackageGraph.CompileRequiredPackages B Count=',IntToStr(AutoPackages.Count));
|
||||
GetAllRequiredPackages(APackage,FirstDependency,PkgList,ReqFlags,Policy);
|
||||
if PkgList<>nil then begin
|
||||
//DebugLn('TLazPackageGraph.CompileRequiredPackages B Count=',IntToStr(PkgList.Count));
|
||||
try
|
||||
Flags:=[pcfDoNotCompileDependencies,pcfDoNotSaveEditorFiles];
|
||||
for i:=PkgList.Count-1 downto 0 do begin
|
||||
CurPkg:=TLazPackage(PkgList[i]);
|
||||
if SkipDesignTimePackages and (CurPkg.PackageType=lptDesignTime) then
|
||||
PkgList.Delete(i);
|
||||
end;
|
||||
if Assigned(OnBeforeCompilePackages) then
|
||||
begin
|
||||
Result:=OnBeforeCompilePackages(PkgList);
|
||||
if Result<>mrOk then exit;
|
||||
end;
|
||||
if Policy=pupAsNeeded then
|
||||
Include(Flags,pcfOnlyIfNeeded)
|
||||
else
|
||||
@ -3258,13 +3273,13 @@ begin
|
||||
if SkipDesignTimePackages then
|
||||
Include(Flags,pcfSkipDesignTimePackages);
|
||||
i:=0;
|
||||
while i<AutoPackages.Count do begin
|
||||
Result:=CompilePackage(TLazPackage(AutoPackages[i]),Flags,false);
|
||||
while i<PkgList.Count do begin
|
||||
Result:=CompilePackage(TLazPackage(PkgList[i]),Flags,false);
|
||||
if Result<>mrOk then exit;
|
||||
inc(i);
|
||||
end;
|
||||
finally
|
||||
AutoPackages.Free;
|
||||
PkgList.Free;
|
||||
end;
|
||||
end;
|
||||
{$IFDEF VerbosePkgCompile}
|
||||
|
@ -63,7 +63,7 @@ uses
|
||||
AddFileToAPackageDlg, LazarusPackageIntf, PublishProjectDlg, PkgLinksDlg,
|
||||
InstallPkgSetDlg, ConfirmPkgListDlg, NewPkgComponentDlg,
|
||||
// bosses
|
||||
BaseBuildManager, BasePkgManager, MainBar, MainIntf, MainBase;
|
||||
BaseBuildManager, BasePkgManager, MainBar, MainIntf, MainBase, ModeMatrixOpts;
|
||||
|
||||
type
|
||||
{ TPkgManager }
|
||||
@ -161,6 +161,7 @@ type
|
||||
procedure PackageFileLoaded(Sender: TObject);
|
||||
procedure OnCheckInstallPackageList(PkgIDList: TObjectList;
|
||||
RemoveConflicts: boolean; out Ok: boolean);
|
||||
function DoBeforeCompilePackages(aPkgList: TFPList): TModalResult;
|
||||
function LoadDependencyList(FirstDependency: TPkgDependency;
|
||||
Quiet: boolean): TModalResult;
|
||||
procedure CreateIDEWindow(Sender: TObject; aFormName: string;
|
||||
@ -242,7 +243,7 @@ type
|
||||
function IsOwnerDependingOnPkg(AnOwner: TObject; const PkgName: string;
|
||||
out DependencyOwner: TObject): boolean; override;
|
||||
procedure GetRequiredPackages(AnOwner: TObject; out PkgList: TFPList;
|
||||
Flags: TPkgIntfRequiredFlags = []) override;
|
||||
Flags: TPkgIntfRequiredFlags = []); override;
|
||||
function AddDependencyToOwners(OwnerList: TFPList; APackage: TIDEPackage;
|
||||
OnlyTestIfPossible: boolean = false): TModalResult; override;
|
||||
function AddDependencyToUnitOwners(const OwnedFilename,
|
||||
@ -497,6 +498,64 @@ begin
|
||||
Ok:=CheckInstallPackageList(PkgIDList);
|
||||
end;
|
||||
|
||||
function TPkgManager.DoBeforeCompilePackages(aPkgList: TFPList): TModalResult;
|
||||
// called before a bunch of packages are compiled
|
||||
|
||||
function GetIgnorePkgOutDirID(CurPkg: TLazPackage): string;
|
||||
begin
|
||||
Result:='PkgOutDir#'+CurPkg.Filename+':'+CurPkg.GetOutputDirectory;
|
||||
end;
|
||||
|
||||
var
|
||||
PkgWithProjOverriddenOutDirs: TFPList;
|
||||
i: Integer;
|
||||
CurPkg: TLazPackage;
|
||||
OutDir: String;
|
||||
IgnoreItem: TIgnoreIDEQuestionItem;
|
||||
s: String;
|
||||
begin
|
||||
Result:=mrOk;
|
||||
if MainIDEBar=nil then exit; // not interactive
|
||||
if InputHistories=nil then exit;
|
||||
|
||||
if not Assigned(OnGetOutputDirectoryOverride) then exit;
|
||||
PkgWithProjOverriddenOutDirs:=TFPList.Create;
|
||||
try
|
||||
for i:=0 to aPkgList.Count-1 do
|
||||
begin
|
||||
CurPkg:=TLazPackage(aPkgList[i]);
|
||||
OutDir:='';
|
||||
OnGetOutputDirectoryOverride(CurPkg,OutDir,[bmgtProject,bmgtSession]);
|
||||
if OutDir<>'' then begin
|
||||
IgnoreItem:=InputHistories.Ignores.Find(GetIgnorePkgOutDirID(CurPkg));
|
||||
if (IgnoreItem=nil) then
|
||||
PkgWithProjOverriddenOutDirs.Add(CurPkg);
|
||||
end;
|
||||
end;
|
||||
if PkgWithProjOverriddenOutDirs.Count>0 then
|
||||
begin
|
||||
s:='';
|
||||
for i:=0 to PkgWithProjOverriddenOutDirs.Count-1 do begin
|
||||
CurPkg:=TLazPackage(PkgWithProjOverriddenOutDirs[i]);
|
||||
OutDir:=CreateRelativePath(CurPkg.GetOutputDirectory,CurPkg.Directory);
|
||||
s+=CurPkg.Name+': '+OutDir+#13;
|
||||
end;
|
||||
if IDEMessageDialog(lisConfirmation,
|
||||
Format(lisPkgTheProjectOverridesTheOutputDirectoryOfTheFollowin, [#13,
|
||||
#13, #13, s]), mtWarning, [mbOk, mbCancel])<>mrOk
|
||||
then
|
||||
exit(mrCancel);
|
||||
// remember the answer
|
||||
for i:=0 to PkgWithProjOverriddenOutDirs.Count-1 do begin
|
||||
CurPkg:=TLazPackage(PkgWithProjOverriddenOutDirs[i]);
|
||||
InputHistories.Ignores.Add(GetIgnorePkgOutDirID(CurPkg),iiidForever);
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
PkgWithProjOverriddenOutDirs.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TPkgManager.LoadDependencyList(FirstDependency: TPkgDependency;
|
||||
Quiet: boolean): TModalResult;
|
||||
var
|
||||
@ -1533,6 +1592,7 @@ begin
|
||||
PackageGraph.OnDeleteAmbiguousFiles:=@BuildBoss.DeleteAmbiguousFiles;
|
||||
PackageGraph.OnUninstallPackage:=@DoUninstallPackage;
|
||||
PackageGraph.OnTranslatePackage:=@DoTranslatePackage;
|
||||
PackageGraph.OnBeforeCompilePackages:=@DoBeforeCompilePackages;
|
||||
|
||||
// package editors
|
||||
PackageEditors:=TPackageEditors.Create;
|
||||
@ -2595,7 +2655,7 @@ function TPkgManager.DoCompileProjectDependencies(AProject: TProject;
|
||||
var
|
||||
CompilePolicy: TPackageUpdatePolicy;
|
||||
begin
|
||||
// check graph for circles and broken dependencies
|
||||
// check graph for cycles and broken dependencies
|
||||
if not (pcfDoNotCompileDependencies in Flags) then begin
|
||||
Result:=CheckPackageGraphForCompilation(nil,
|
||||
AProject.FirstRequiredDependency,
|
||||
|
Loading…
Reference in New Issue
Block a user