mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-20 12:19:31 +02:00
Package: use new lists in LPK files + add compatibility mode option
git-svn-id: trunk@62307 -
This commit is contained in:
parent
2be8de0d13
commit
e2fea199d7
@ -381,11 +381,12 @@ end;
|
||||
procedure TAarrePkgListItem.LoadLPK(LPKFilename: string);
|
||||
var
|
||||
xml: TXMLConfig;
|
||||
Path: String;
|
||||
Path, SubPath: String;
|
||||
FileVersion: Integer;
|
||||
i: Integer;
|
||||
NewCount: Integer;
|
||||
PkgDependency: TAPkgDependency;
|
||||
LegacyList: Boolean;
|
||||
begin
|
||||
xml:=TXMLConfig.Create(LPKFilename);
|
||||
try
|
||||
@ -403,11 +404,13 @@ begin
|
||||
License:=FixUTF8(xml.GetValue(Path+'License/Value',''));
|
||||
Version.Load(xml,Path+'Version/');
|
||||
|
||||
NewCount:=xml.GetValue(Path+'RequiredPkgs/Count',0);
|
||||
LegacyList:=xml.IsLegacyList(Path+'RequiredPkgs/');
|
||||
NewCount:=xml.GetListItemCount(Path+'RequiredPkgs/', 'Item', LegacyList);
|
||||
Dependencies.Clear;
|
||||
for i:=0 to NewCount-1 do begin
|
||||
PkgDependency:=TAPkgDependency.Create;
|
||||
PkgDependency.Load(xml,Path+'RequiredPkgs/Item'+IntToStr(i+1)+'/');
|
||||
SubPath:=Path+'RequiredPkgs/'+xml.GetListItemXPath('Item', i, LegacyList, True)+'/';
|
||||
PkgDependency.Load(xml,SubPath);
|
||||
Dependencies.Add(PkgDependency);
|
||||
end;
|
||||
|
||||
|
@ -845,6 +845,7 @@ var
|
||||
DefaultFilename, Paths, BaseDir: String;
|
||||
Cnt, i, p: Integer;
|
||||
Pkg: TIDEPackage;
|
||||
LegacyList: Boolean;
|
||||
begin
|
||||
if LPKFiles.Contains(LPKFilename) then exit;
|
||||
//debugln(['TIDEProjectGroupManager.AddLPKSrcPaths ',LPKFilename]);
|
||||
@ -876,9 +877,10 @@ begin
|
||||
BaseDir:=ExtractFilePath(LPKFilename);
|
||||
// list of files
|
||||
Path:='Files/';
|
||||
Cnt:=xml.GetValue(Path+'Count',0);
|
||||
for i:=1 to Cnt do begin
|
||||
SubPath:=Path+'Item'+IntToStr(i)+'/';
|
||||
LegacyList:=xml.IsLegacyList(Path);
|
||||
Cnt:=xml.GetListItemCount(Path, 'Item', LegacyList);
|
||||
for i:=0 to Cnt-1 do begin
|
||||
SubPath:=Path+xml.GetListItemXPath('Item', i, LegacyList, True)+'/';
|
||||
CurFilename:=xml.GetValue(SubPath+'Filename/Value','');
|
||||
if CurFilename='' then continue;
|
||||
AddSrcPathOfFile(SrcPaths,CurFilename);
|
||||
@ -886,9 +888,10 @@ begin
|
||||
|
||||
// load list of RequiredPackages from lpk
|
||||
Path:='Package/RequiredPkgs/';
|
||||
Cnt:=xml.GetValue(Path+'Count',0);
|
||||
for i:=1 to Cnt do begin
|
||||
SubPath:=Path+'Item'+IntToStr(i)+'/';
|
||||
LegacyList:=xml.IsLegacyList(Path);
|
||||
Cnt:=xml.GetListItemCount(Path, 'Item', LegacyList);
|
||||
for i:=0 to Cnt-1 do begin
|
||||
SubPath:=Path+xml.GetListItemXPath('Item', i, LegacyList, True)+'/';
|
||||
PkgName:=xml.GetValue(SubPath+'PackageName/Value','');
|
||||
if not IsValidPkgName(PkgName) then continue;
|
||||
PreferredFilename:=xml.GetValue(SubPath+'DefaultFilename/Prefer','');
|
||||
|
@ -1357,6 +1357,8 @@ resourcestring
|
||||
lisFilesInASCIIOrUTF8Encoding = 'Files in ASCII or UTF-8 encoding';
|
||||
lisFilesNotInASCIINorUTF8Encoding = 'Files not in ASCII nor UTF-8 encoding';
|
||||
podAddPackageUnitToUsesSection = 'Add package unit to uses section';
|
||||
lisLPKCompatibilityModeCheckBox = 'Maximize compatibility of package file (LPK)';
|
||||
lisLPKCompatibilityModeCheckBoxHint = 'Check this if you want to open your package in legacy (2.0 and older) Lazarus versions.';
|
||||
lisCodeBrowser = 'Code Browser';
|
||||
|
||||
// IDE General options
|
||||
|
@ -1,9 +1,9 @@
|
||||
object PackageUsageOptionsFrame: TPackageUsageOptionsFrame
|
||||
Left = 0
|
||||
Height = 415
|
||||
Height = 528
|
||||
Top = 0
|
||||
Width = 535
|
||||
ClientHeight = 415
|
||||
ClientHeight = 528
|
||||
ClientWidth = 535
|
||||
TabOrder = 0
|
||||
DesignLeft = 762
|
||||
@ -244,4 +244,34 @@ object PackageUsageOptionsFrame: TPackageUsageOptionsFrame
|
||||
TabOrder = 0
|
||||
end
|
||||
end
|
||||
object PackageGroupBox: TGroupBox
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = ProjectGroupBox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 0
|
||||
Height = 51
|
||||
Top = 382
|
||||
Width = 535
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Top = 6
|
||||
Caption = 'PackageGroupBox'
|
||||
ClientHeight = 31
|
||||
ClientWidth = 531
|
||||
TabOrder = 3
|
||||
object CompatibilityModeCheckBox: TCheckBox
|
||||
Left = 6
|
||||
Height = 19
|
||||
Top = 6
|
||||
Width = 519
|
||||
Align = alTop
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'CompatibilityModeCheckBox'
|
||||
ParentShowHint = False
|
||||
ShowHint = True
|
||||
TabOrder = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -22,6 +22,7 @@ type
|
||||
TPackageUsageOptionsFrame = class(TAbstractIDEOptionsEditor)
|
||||
AddOptionsGroupBox: TGroupBox;
|
||||
AddPackageUnitToProjectCheckBox: TCheckBox;
|
||||
CompatibilityModeCheckBox: TCheckBox;
|
||||
AddPathsGroupBox: TGroupBox;
|
||||
CustomOptionsLabel: TLabel;
|
||||
CustomOptionsMemo: TMemo;
|
||||
@ -34,6 +35,7 @@ type
|
||||
ObjectPathEdit: TEdit;
|
||||
ObjectPathLabel: TLabel;
|
||||
ProjectGroupBox: TGroupBox;
|
||||
PackageGroupBox: TGroupBox;
|
||||
UnitPathEdit: TEdit;
|
||||
UnitPathLabel: TLabel;
|
||||
private
|
||||
@ -187,6 +189,9 @@ begin
|
||||
|
||||
ProjectGroupBox.Caption := dlgProject;
|
||||
AddPackageUnitToProjectCheckBox.Caption := podAddPackageUnitToUsesSection;
|
||||
PackageGroupBox.Caption := lisPackage;
|
||||
CompatibilityModeCheckBox.Caption := lisLPKCompatibilityModeCheckBox;
|
||||
CompatibilityModeCheckBox.Hint := lisLPKCompatibilityModeCheckBoxHint;
|
||||
end;
|
||||
|
||||
procedure TPackageUsageOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions);
|
||||
@ -202,6 +207,7 @@ begin
|
||||
CustomOptionsMemo.Text := CustomOptions;
|
||||
end;
|
||||
AddPackageUnitToProjectCheckBox.Checked := FLazPackage.AddToProjectUsesSection;
|
||||
CompatibilityModeCheckBox.Checked := FLazPackage.UseLegacyLists;
|
||||
end;
|
||||
|
||||
procedure TPackageUsageOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions);
|
||||
@ -219,6 +225,7 @@ begin
|
||||
CustomOptions := CustomOptionsMemo.Text;
|
||||
end;
|
||||
LazPackage.AddToProjectUsesSection := AddPackageUnitToProjectCheckBox.Checked;
|
||||
FLazPackage.UseLegacyLists := CompatibilityModeCheckBox.Checked;
|
||||
end;
|
||||
|
||||
class function TPackageUsageOptionsFrame.SupportedOptionsClass: TAbstractIDEOptionsClass;
|
||||
|
@ -444,7 +444,8 @@ type
|
||||
lpfLoading, // set during loading
|
||||
lpfSkipSaving, // Used by PkgBoss to skip saving
|
||||
lpfCycle, // Used by the PackageGraph to mark cycles
|
||||
lpfNeedGroupCompile // set during group compile, dependent packages need compile too
|
||||
lpfNeedGroupCompile,// set during group compile, dependent packages need compile too
|
||||
lpfCompatibilityMode// use legacy file format to maximize compatibility with old Lazarus versions
|
||||
);
|
||||
TLazPackageFlags = set of TLazPackageFlag;
|
||||
|
||||
@ -555,6 +556,7 @@ type
|
||||
function GetFiles(Index: integer): TPkgFile;
|
||||
function GetIDEOptions: TPackageIDEOptions;
|
||||
function GetSourceDirectories: TFileReferenceList;
|
||||
function GetUseLegacyLists: Boolean;
|
||||
procedure SetAddToProjectUsesSection(const AValue: boolean);
|
||||
procedure SetAuthor(const AValue: string);
|
||||
procedure SetAutoIncrementVersionOnBuild(const AValue: boolean);
|
||||
@ -577,6 +579,7 @@ type
|
||||
procedure SetPackageEditor(const AValue: TBasePackageEditor);
|
||||
procedure SetPackageType(const AValue: TLazPackageType);
|
||||
procedure SetStorePathDelim(const AValue: TPathDelimSwitch);
|
||||
procedure SetUseLegacyLists(const AUseLegacyLists: Boolean);
|
||||
procedure SetUserReadOnly(const AValue: boolean);
|
||||
procedure OnMacroListSubstitution({%H-}TheMacro: TTransferMacro;
|
||||
const MacroName: string; var s: string;
|
||||
@ -771,6 +774,7 @@ type
|
||||
property TopologicalLevel: integer read FTopologicalLevel write FTopologicalLevel;
|
||||
property Translated: string read FTranslated write FTranslated;
|
||||
property UsageOptions: TPkgAdditionalCompilerOptions read FUsageOptions;
|
||||
property UseLegacyLists: Boolean read GetUseLegacyLists write SetUseLegacyLists;
|
||||
property UserReadOnly: boolean read FUserReadOnly write SetUserReadOnly;
|
||||
property UserIgnoreChangeStamp: integer read FUserIgnoreChangeStamp
|
||||
write FUserIgnoreChangeStamp;
|
||||
@ -793,7 +797,7 @@ type
|
||||
end;
|
||||
|
||||
const
|
||||
LazPkgXMLFileVersion = 4;
|
||||
LazPkgXMLFileVersion = 5;
|
||||
|
||||
AutoUpdateNames: array[TPackageUpdatePolicy] of string = (
|
||||
'Manually', 'OnRebuildingAll', 'AsNeeded');
|
||||
@ -2608,6 +2612,16 @@ begin
|
||||
FStorePathDelim:=AValue;
|
||||
end;
|
||||
|
||||
procedure TLazPackage.SetUseLegacyLists(const AUseLegacyLists: Boolean);
|
||||
begin
|
||||
if AUseLegacyLists=UseLegacyLists then exit;
|
||||
if AUseLegacyLists then
|
||||
Include(FFlags, lpfCompatibilityMode)
|
||||
else
|
||||
Exclude(FFlags, lpfCompatibilityMode);
|
||||
Modified:=true;
|
||||
end;
|
||||
|
||||
constructor TLazPackage.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
@ -2820,12 +2834,15 @@ var
|
||||
i: Integer;
|
||||
NewCount: Integer;
|
||||
PkgFile: TPkgFile;
|
||||
LegacyList: Boolean;
|
||||
SubPath: string;
|
||||
begin
|
||||
NewCount:=XMLConfig.GetValue(ThePath+'Count',0);
|
||||
LegacyList := (FileVersion<=4) or XMLConfig.IsLegacyList(ThePath);
|
||||
NewCount:=XMLConfig.GetListItemCount(ThePath, 'Item', LegacyList);
|
||||
for i:=0 to NewCount-1 do begin
|
||||
PkgFile:=TPkgFile.Create(Self);
|
||||
PkgFile.LoadFromXMLConfig(XMLConfig,ThePath+'Item'+IntToStr(i+1)+'/',
|
||||
FileVersion,PathDelimChanged);
|
||||
SubPath := ThePath+XMLConfig.GetListItemXPath('Item', i, LegacyList, True)+'/';
|
||||
PkgFile.LoadFromXMLConfig(XMLConfig,SubPath,FileVersion,PathDelimChanged);
|
||||
if PkgFile.MakeSense then
|
||||
List.Add(PkgFile)
|
||||
else
|
||||
@ -2839,6 +2856,11 @@ var
|
||||
Include(FFlags,lpfAutoIncrementVersionOnBuild)
|
||||
else
|
||||
Exclude(FFlags,lpfAutoIncrementVersionOnBuild);
|
||||
if FileVersion<=4 then begin
|
||||
// set CompatibilityMode flag for legacy projects (this flag was added in FileVersion=5 that changed
|
||||
// item format so that LPK cannot be opened in legacy Lazarus unless lpfCompatibilityMode is set)
|
||||
UseLegacyLists := True;
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
@ -2849,6 +2871,7 @@ begin
|
||||
Clear;
|
||||
Filename:=OldFilename;
|
||||
LockModified;
|
||||
LoadFlags(Path);
|
||||
StorePathDelim:=CheckPathDelim(XMLConfig.GetValue(Path+'PathDelim/Value','/'),PathDelimChanged);
|
||||
Name:=XMLConfig.GetValue(Path+'Name/Value','');
|
||||
FPackageType:=LazPackageTypeIdentToType(XMLConfig.GetValue(Path+'Type/Value',
|
||||
@ -2889,7 +2912,6 @@ begin
|
||||
|
||||
LoadFiles(Path+'Files/',FFiles);
|
||||
UpdateSourceDirectories;
|
||||
LoadFlags(Path);
|
||||
LoadPkgDependencyList(XMLConfig,Path+'RequiredPkgs/',
|
||||
FFirstRequiredDependency,pdlRequires,Self,false,false);
|
||||
FUsageOptions.LoadFromXMLConfig(XMLConfig,Path+'UsageOptions/',
|
||||
@ -2924,11 +2946,13 @@ var
|
||||
var
|
||||
i: Integer;
|
||||
PkgFile: TPkgFile;
|
||||
SubPath: string;
|
||||
begin
|
||||
XMLConfig.SetDeleteValue(ThePath+'Count',List.Count,0);
|
||||
XMLConfig.SetListItemCount(ThePath, List.Count, UseLegacyLists);
|
||||
for i:=0 to List.Count-1 do begin
|
||||
PkgFile:=TPkgFile(List[i]);
|
||||
PkgFile.SaveToXMLConfig(XMLConfig,ThePath+'Item'+IntToStr(i+1)+'/',UsePathDelim);
|
||||
SubPath := ThePath+XMLConfig.GetListItemXPath('Item', i, UseLegacyLists, True)+'/';
|
||||
PkgFile.SaveToXMLConfig(XMLConfig,SubPath,UsePathDelim);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -2968,7 +2992,7 @@ begin
|
||||
XMLConfig.SetDeleteValue(Path+'i18n/EnableI18NForLFM/Value', EnableI18NForLFM, false);
|
||||
|
||||
SavePkgDependencyList(XMLConfig,Path+'RequiredPkgs/',
|
||||
FFirstRequiredDependency,pdlRequires,UsePathDelim,True);
|
||||
FFirstRequiredDependency,pdlRequires,UsePathDelim,UseLegacyLists);
|
||||
FUsageOptions.SaveToXMLConfig(XMLConfig,Path+'UsageOptions/',UsePathDelim);
|
||||
fPublishOptions.SaveToXMLConfig(XMLConfig,Path+'PublishOptions/',UsePathDelim);
|
||||
SaveStringList(XMLConfig,FProvides,Path+'Provides/');
|
||||
@ -3882,6 +3906,11 @@ begin
|
||||
Result:=CompilerOptions.GetUnitPath(RelativeToBaseDir);
|
||||
end;
|
||||
|
||||
function TLazPackage.GetUseLegacyLists: Boolean;
|
||||
begin
|
||||
Result:=lpfCompatibilityMode in Flags;
|
||||
end;
|
||||
|
||||
function TLazPackage.GetIncludePath(RelativeToBaseDir: boolean): string;
|
||||
begin
|
||||
Result:=CompilerOptions.GetIncludePath(RelativeToBaseDir);
|
||||
|
Loading…
Reference in New Issue
Block a user