mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 08:59:13 +02:00
implemented Use Unit option for package units to allow units, that are not always compiled
git-svn-id: trunk@7192 -
This commit is contained in:
parent
b2ba0f4418
commit
536fc01a98
@ -2448,6 +2448,10 @@ resourcestring
|
|||||||
lisPckEditCallRegisterProcedureOfSelectedUnit = 'Call %sRegister%s '
|
lisPckEditCallRegisterProcedureOfSelectedUnit = 'Call %sRegister%s '
|
||||||
+'procedure of selected unit';
|
+'procedure of selected unit';
|
||||||
lisPckEditRegisteredPlugins = 'Registered plugins';
|
lisPckEditRegisteredPlugins = 'Registered plugins';
|
||||||
|
lisPkgMangAddUnitToUsesClauseOfPackageDisableThisOnlyForUnit = 'Add unit to '
|
||||||
|
+'uses clause of package. Disable this only for units, that should not be '
|
||||||
|
+'compiled in all cases.';
|
||||||
|
lisPkgMangUseUnit = 'Use unit';
|
||||||
lisPckEditMinimumVersion = 'Minimum Version:';
|
lisPckEditMinimumVersion = 'Minimum Version:';
|
||||||
lisPckEditMaximumVersion = 'Maximum Version:';
|
lisPckEditMaximumVersion = 'Maximum Version:';
|
||||||
lisPckEditApplyChanges = 'Apply changes';
|
lisPckEditApplyChanges = 'Apply changes';
|
||||||
|
@ -135,10 +135,13 @@ const
|
|||||||
type
|
type
|
||||||
TPkgFileFlag = (
|
TPkgFileFlag = (
|
||||||
pffHasRegisterProc, // file is unit and has a 'register' procedure
|
pffHasRegisterProc, // file is unit and has a 'register' procedure
|
||||||
|
pffAddToPkgUsesSection,// unit is added to uses section if package source
|
||||||
pffReportedAsRemoved // file has been reported as removed
|
pffReportedAsRemoved // file has been reported as removed
|
||||||
);
|
);
|
||||||
TPkgFileFlags = set of TPkgFileFlag;
|
TPkgFileFlags = set of TPkgFileFlag;
|
||||||
|
|
||||||
|
{ TPkgFile }
|
||||||
|
|
||||||
TPkgFile = class
|
TPkgFile = class
|
||||||
private
|
private
|
||||||
FAutoReferenceSourceDir: boolean;
|
FAutoReferenceSourceDir: boolean;
|
||||||
@ -153,8 +156,10 @@ type
|
|||||||
FSourceDirectoryReferenced: boolean;
|
FSourceDirectoryReferenced: boolean;
|
||||||
FSourceDirNeedReference: boolean;
|
FSourceDirNeedReference: boolean;
|
||||||
FUnitName: string;
|
FUnitName: string;
|
||||||
|
function GetAddToUsesPkgSection: boolean;
|
||||||
function GetComponents(Index: integer): TPkgComponent;
|
function GetComponents(Index: integer): TPkgComponent;
|
||||||
function GetHasRegisterProc: boolean;
|
function GetHasRegisterProc: boolean;
|
||||||
|
procedure SetAddToUsesPkgSection(const AValue: boolean);
|
||||||
procedure SetAutoReferenceSourceDir(const AValue: boolean);
|
procedure SetAutoReferenceSourceDir(const AValue: boolean);
|
||||||
procedure SetRemoved(const AValue: boolean);
|
procedure SetRemoved(const AValue: boolean);
|
||||||
procedure SetFilename(const AValue: string);
|
procedure SetFilename(const AValue: string);
|
||||||
@ -187,7 +192,9 @@ type
|
|||||||
property FileType: TPkgFileType read FFileType write SetFileType;
|
property FileType: TPkgFileType read FFileType write SetFileType;
|
||||||
property Flags: TPkgFileFlags read FFlags write SetFlags;
|
property Flags: TPkgFileFlags read FFlags write SetFlags;
|
||||||
property HasRegisterProc: boolean
|
property HasRegisterProc: boolean
|
||||||
read GetHasRegisterProc write SetHasRegisterProc;
|
read GetHasRegisterProc write SetHasRegisterProc;
|
||||||
|
property AddToUsesPkgSection: boolean
|
||||||
|
read GetAddToUsesPkgSection write SetAddToUsesPkgSection;
|
||||||
property LazPackage: TLazPackage read FPackage;
|
property LazPackage: TLazPackage read FPackage;
|
||||||
property UnitName: string read FUnitName write FUnitName;
|
property UnitName: string read FUnitName write FUnitName;
|
||||||
property ComponentPriority: TComponentPriority read FComponentPriority
|
property ComponentPriority: TComponentPriority read FComponentPriority
|
||||||
@ -766,7 +773,7 @@ const
|
|||||||
PkgFileTypeIdents: array[TPkgFileType] of string = (
|
PkgFileTypeIdents: array[TPkgFileType] of string = (
|
||||||
'Unit', 'Virtual Unit', 'LFM', 'LRS', 'Include', 'Text', 'Binary');
|
'Unit', 'Virtual Unit', 'LFM', 'LRS', 'Include', 'Text', 'Binary');
|
||||||
PkgFileFlag: array[TPkgFileFlag] of string = (
|
PkgFileFlag: array[TPkgFileFlag] of string = (
|
||||||
'pffHasRegisterProc', 'pffReportedAsRemoved');
|
'pffHasRegisterProc', 'pffAddToPkgUsesSection', 'pffReportedAsRemoved');
|
||||||
PkgDependencyFlagNames: array[TPkgDependencyFlag] of string = (
|
PkgDependencyFlagNames: array[TPkgDependencyFlag] of string = (
|
||||||
'pdfMinVersion', 'pdfMaxVersion');
|
'pdfMinVersion', 'pdfMaxVersion');
|
||||||
LazPackageTypeNames: array[TLazPackageType] of string = (
|
LazPackageTypeNames: array[TLazPackageType] of string = (
|
||||||
@ -1224,6 +1231,15 @@ begin
|
|||||||
Result:=pffHasRegisterProc in FFlags;
|
Result:=pffHasRegisterProc in FFlags;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TPkgFile.SetAddToUsesPkgSection(const AValue: boolean);
|
||||||
|
begin
|
||||||
|
if AddToUsesPkgSection=AValue then exit;
|
||||||
|
if AValue then
|
||||||
|
Include(FFlags,pffAddToPkgUsesSection)
|
||||||
|
else
|
||||||
|
Exclude(FFlags,pffAddToPkgUsesSection);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TPkgFile.SetAutoReferenceSourceDir(const AValue: boolean);
|
procedure TPkgFile.SetAutoReferenceSourceDir(const AValue: boolean);
|
||||||
begin
|
begin
|
||||||
if FAutoReferenceSourceDir=AValue then exit;
|
if FAutoReferenceSourceDir=AValue then exit;
|
||||||
@ -1245,6 +1261,11 @@ begin
|
|||||||
Result:=TPkgComponent(FComponents[Index]);
|
Result:=TPkgComponent(FComponents[Index]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TPkgFile.GetAddToUsesPkgSection: boolean;
|
||||||
|
begin
|
||||||
|
Result:=pffAddToPkgUsesSection in FFlags;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TPkgFile.SetFileType(const AValue: TPkgFileType);
|
procedure TPkgFile.SetFileType(const AValue: TPkgFileType);
|
||||||
begin
|
begin
|
||||||
if FFileType=AValue then exit;
|
if FFileType=AValue then exit;
|
||||||
@ -1352,6 +1373,8 @@ begin
|
|||||||
Filename:=AFilename;
|
Filename:=AFilename;
|
||||||
FileType:=PkgFileTypeIdentToType(XMLConfig.GetValue(Path+'Type/Value',''));
|
FileType:=PkgFileTypeIdentToType(XMLConfig.GetValue(Path+'Type/Value',''));
|
||||||
HasRegisterProc:=XMLConfig.GetValue(Path+'HasRegisterProc/Value',false);
|
HasRegisterProc:=XMLConfig.GetValue(Path+'HasRegisterProc/Value',false);
|
||||||
|
AddToUsesPkgSection:=XMLConfig.GetValue(Path+'AddToUsesPkgSection/Value',
|
||||||
|
FileType in PkgFileUnitTypes);
|
||||||
fUnitName:=XMLConfig.GetValue(Path+'UnitName/Value','');
|
fUnitName:=XMLConfig.GetValue(Path+'UnitName/Value','');
|
||||||
if FileType in PkgFileUnitTypes then begin
|
if FileType in PkgFileUnitTypes then begin
|
||||||
// make sure the unitname makes sense
|
// make sure the unitname makes sense
|
||||||
@ -1370,6 +1393,8 @@ begin
|
|||||||
XMLConfig.SetDeleteValue(Path+'Filename/Value',TmpFilename,'');
|
XMLConfig.SetDeleteValue(Path+'Filename/Value',TmpFilename,'');
|
||||||
XMLConfig.SetDeleteValue(Path+'HasRegisterProc/Value',HasRegisterProc,
|
XMLConfig.SetDeleteValue(Path+'HasRegisterProc/Value',HasRegisterProc,
|
||||||
false);
|
false);
|
||||||
|
XMLConfig.SetDeleteValue(Path+'AddToUsesPkgSection/Value',AddToUsesPkgSection,
|
||||||
|
FileType in PkgFileUnitTypes);
|
||||||
XMLConfig.SetDeleteValue(Path+'Type/Value',PkgFileTypeIdents[FileType],
|
XMLConfig.SetDeleteValue(Path+'Type/Value',PkgFileTypeIdents[FileType],
|
||||||
PkgFileTypeIdents[pftUnit]);
|
PkgFileTypeIdents[pftUnit]);
|
||||||
XMLConfig.SetDeleteValue(Path+'UnitName/Value',FUnitName,'');
|
XMLConfig.SetDeleteValue(Path+'UnitName/Value',FUnitName,'');
|
||||||
|
@ -108,6 +108,7 @@ type
|
|||||||
FilePropsGroupBox: TGroupBox;
|
FilePropsGroupBox: TGroupBox;
|
||||||
// file properties
|
// file properties
|
||||||
CallRegisterProcCheckBox: TCheckBox;
|
CallRegisterProcCheckBox: TCheckBox;
|
||||||
|
AddToUsesPkgSectionCheckBox: TCheckBox;
|
||||||
RegisteredPluginsGroupBox: TGroupBox;
|
RegisteredPluginsGroupBox: TGroupBox;
|
||||||
RegisteredListBox: TListBox;
|
RegisteredListBox: TListBox;
|
||||||
// dependency properties
|
// dependency properties
|
||||||
@ -122,6 +123,7 @@ type
|
|||||||
ImageList: TImageList;
|
ImageList: TImageList;
|
||||||
FilesPopupMenu: TPopupMenu;
|
FilesPopupMenu: TPopupMenu;
|
||||||
procedure AddBitBtnClick(Sender: TObject);
|
procedure AddBitBtnClick(Sender: TObject);
|
||||||
|
procedure AddToUsesPkgSectionCheckBoxClick(Sender: TObject);
|
||||||
procedure ApplyDependencyButtonClick(Sender: TObject);
|
procedure ApplyDependencyButtonClick(Sender: TObject);
|
||||||
procedure CallRegisterProcCheckBoxClick(Sender: TObject);
|
procedure CallRegisterProcCheckBoxClick(Sender: TObject);
|
||||||
procedure ChangeFileTypeMenuItemClick(Sender: TObject);
|
procedure ChangeFileTypeMenuItemClick(Sender: TObject);
|
||||||
@ -855,10 +857,16 @@ procedure TPackageEditorForm.FilePropsGroupBoxResize(Sender: TObject);
|
|||||||
var
|
var
|
||||||
y: Integer;
|
y: Integer;
|
||||||
x: Integer;
|
x: Integer;
|
||||||
|
w: Integer;
|
||||||
begin
|
begin
|
||||||
// components for files
|
// components for files
|
||||||
|
w:=(ClientWidth-15) div 2;
|
||||||
with CallRegisterProcCheckBox do
|
with CallRegisterProcCheckBox do
|
||||||
SetBounds(3,0,Parent.ClientWidth,Height);
|
SetBounds(3,0,w,Height);
|
||||||
|
x:=3+w+9;
|
||||||
|
|
||||||
|
with AddToUsesPkgSectionCheckBox do
|
||||||
|
SetBounds(x,0,w,Height);
|
||||||
|
|
||||||
y:=CallRegisterProcCheckBox.Top+CallRegisterProcCheckBox.Height+3;
|
y:=CallRegisterProcCheckBox.Top+CallRegisterProcCheckBox.Height+3;
|
||||||
with RegisteredPluginsGroupBox do
|
with RegisteredPluginsGroupBox do
|
||||||
@ -990,6 +998,20 @@ begin
|
|||||||
PackageGraph.EndUpdate;
|
PackageGraph.EndUpdate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TPackageEditorForm.AddToUsesPkgSectionCheckBoxClick(Sender: TObject);
|
||||||
|
var
|
||||||
|
CurFile: TPkgFile;
|
||||||
|
Removed: boolean;
|
||||||
|
begin
|
||||||
|
if LazPackage=nil then exit;
|
||||||
|
CurFile:=GetCurrentFile(Removed);
|
||||||
|
if (CurFile=nil) then exit;
|
||||||
|
if CurFile.AddToUsesPkgSection=AddToUsesPkgSectionCheckBox.Checked then exit;
|
||||||
|
CurFile.AddToUsesPkgSection:=AddToUsesPkgSectionCheckBox.Checked;
|
||||||
|
LazPackage.Modified:=not Removed;
|
||||||
|
UpdateAll;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TPackageEditorForm.ApplyDependencyButtonClick(Sender: TObject);
|
procedure TPackageEditorForm.ApplyDependencyButtonClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
CurDependency: TPkgDependency;
|
CurDependency: TPkgDependency;
|
||||||
@ -1045,6 +1067,7 @@ begin
|
|||||||
if LazPackage=nil then exit;
|
if LazPackage=nil then exit;
|
||||||
CurFile:=GetCurrentFile(Removed);
|
CurFile:=GetCurrentFile(Removed);
|
||||||
if (CurFile=nil) then exit;
|
if (CurFile=nil) then exit;
|
||||||
|
if CurFile.HasRegisterProc=CallRegisterProcCheckBox.Checked then exit;
|
||||||
CurFile.HasRegisterProc:=CallRegisterProcCheckBox.Checked;
|
CurFile.HasRegisterProc:=CallRegisterProcCheckBox.Checked;
|
||||||
LazPackage.Modified:=not Removed;
|
LazPackage.Modified:=not Removed;
|
||||||
UpdateAll;
|
UpdateAll;
|
||||||
@ -1316,6 +1339,17 @@ begin
|
|||||||
ShowHint:=true;
|
ShowHint:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
AddToUsesPkgSectionCheckBox:=TCheckBox.Create(Self);
|
||||||
|
with AddToUsesPkgSectionCheckBox do begin
|
||||||
|
Name:='AddToUsesPkgSectionCheckBox';
|
||||||
|
Parent:=FilePropsGroupBox;
|
||||||
|
Caption:=lisPkgMangUseUnit;
|
||||||
|
UseOnChange:=true;
|
||||||
|
OnClick:=@AddToUsesPkgSectionCheckBoxClick;
|
||||||
|
Hint:=lisPkgMangAddUnitToUsesClauseOfPackageDisableThisOnlyForUnit;
|
||||||
|
ShowHint:=true;
|
||||||
|
end;
|
||||||
|
|
||||||
RegisteredPluginsGroupBox:=TGroupBox.Create(Self);
|
RegisteredPluginsGroupBox:=TGroupBox.Create(Self);
|
||||||
with RegisteredPluginsGroupBox do begin
|
with RegisteredPluginsGroupBox do begin
|
||||||
Name:='RegisteredPluginsGroupBox';
|
Name:='RegisteredPluginsGroupBox';
|
||||||
@ -1593,6 +1627,7 @@ begin
|
|||||||
ApplyDependencyButton.Visible:=Dependency<>nil;
|
ApplyDependencyButton.Visible:=Dependency<>nil;
|
||||||
|
|
||||||
CallRegisterProcCheckBox.Visible:=CurFile<>nil;
|
CallRegisterProcCheckBox.Visible:=CurFile<>nil;
|
||||||
|
AddToUsesPkgSectionCheckBox.Visible:=CurFile<>nil;
|
||||||
RegisteredPluginsGroupBox.Visible:=CurFile<>nil;
|
RegisteredPluginsGroupBox.Visible:=CurFile<>nil;
|
||||||
|
|
||||||
if CurFile<>nil then begin
|
if CurFile<>nil then begin
|
||||||
@ -1602,6 +1637,9 @@ begin
|
|||||||
CallRegisterProcCheckBox.Enabled:=(not LazPackage.ReadOnly)
|
CallRegisterProcCheckBox.Enabled:=(not LazPackage.ReadOnly)
|
||||||
and (CurFile.FileType in [pftUnit,pftVirtualUnit]);
|
and (CurFile.FileType in [pftUnit,pftVirtualUnit]);
|
||||||
CallRegisterProcCheckBox.Checked:=pffHasRegisterProc in CurFile.Flags;
|
CallRegisterProcCheckBox.Checked:=pffHasRegisterProc in CurFile.Flags;
|
||||||
|
AddToUsesPkgSectionCheckBox.Checked:=pffAddToPkgUsesSection in CurFile.Flags;
|
||||||
|
AddToUsesPkgSectionCheckBox.Enabled:=(not LazPackage.ReadOnly)
|
||||||
|
and (CurFile.FileType in PkgFileUnitTypes);
|
||||||
// fetch all registered plugins
|
// fetch all registered plugins
|
||||||
CurListIndex:=0;
|
CurListIndex:=0;
|
||||||
RegCompCnt:=CurFile.ComponentCount;
|
RegCompCnt:=CurFile.ComponentCount;
|
||||||
|
@ -2554,6 +2554,7 @@ var
|
|||||||
OutputDir: String;
|
OutputDir: String;
|
||||||
OldSrc: String;
|
OldSrc: String;
|
||||||
CaseInsensitiveUnitName: String;
|
CaseInsensitiveUnitName: String;
|
||||||
|
NeedsRegisterProcCall: boolean;
|
||||||
begin
|
begin
|
||||||
{$IFDEF VerbosePkgCompile}
|
{$IFDEF VerbosePkgCompile}
|
||||||
writeln('TPkgManager.DoSavePackageMainSource A');
|
writeln('TPkgManager.DoSavePackageMainSource A');
|
||||||
@ -2603,11 +2604,14 @@ begin
|
|||||||
if SysUtils.CompareText(CurUnitName,CaseInsensitiveUnitName)<>0 then
|
if SysUtils.CompareText(CurUnitName,CaseInsensitiveUnitName)<>0 then
|
||||||
CurUnitName:=CaseInsensitiveUnitName;
|
CurUnitName:=CaseInsensitiveUnitName;
|
||||||
if (CurUnitName<>'') and IsValidIdent(CurUnitName) then begin
|
if (CurUnitName<>'') and IsValidIdent(CurUnitName) then begin
|
||||||
if UsedUnits<>'' then
|
NeedsRegisterProcCall:=CurFile.HasRegisterProc
|
||||||
UsedUnits:=UsedUnits+', ';
|
and (APackage.PackageType in [lptDesignTime,lptRunAndDesignTime]);
|
||||||
UsedUnits:=UsedUnits+CurUnitName;
|
if NeedsRegisterProcCall or CurFile.AddToUsesPkgSection then begin
|
||||||
if (APackage.PackageType in [lptDesignTime,lptRunAndDesignTime])
|
if UsedUnits<>'' then
|
||||||
and CurFile.HasRegisterProc then begin
|
UsedUnits:=UsedUnits+', ';
|
||||||
|
UsedUnits:=UsedUnits+CurUnitName;
|
||||||
|
end;
|
||||||
|
if NeedsRegisterProcCall then begin
|
||||||
RegistrationCode:=RegistrationCode+
|
RegistrationCode:=RegistrationCode+
|
||||||
' RegisterUnit('''+CurUnitName+''',@'+CurUnitName+'.Register);'+e;
|
' RegisterUnit('''+CurUnitName+''',@'+CurUnitName+'.Register);'+e;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user