implemented inherited Compiler Options View

git-svn-id: trunk@4061 -
This commit is contained in:
mattias 2003-04-15 17:58:28 +00:00
parent 088d4e7233
commit 94d356f9a1
9 changed files with 731 additions and 154 deletions

View File

@ -41,9 +41,10 @@ unit CompilerOptions;
interface interface
uses uses
Forms, Classes, SysUtils, ComCtrls, Buttons, StdCtrls, ExtCtrls, Forms, Classes, SysUtils, ComCtrls, Buttons, StdCtrls, ExtCtrls, Graphics,
Laz_XMLCfg, FileCtrl, Dialogs, Controls, PathEditorDlg, IDEProcs, LazConf, LResources, Laz_XMLCfg, FileCtrl, Dialogs, Controls,
IDEOptionDefs, LazarusIDEStrConsts; PathEditorDlg, IDEProcs, LazConf, IDEOptionDefs, LazarusIDEStrConsts,
TransferMacros;
type type
TInheritedCompilerOption = ( TInheritedCompilerOption = (
@ -60,19 +61,30 @@ type
{ TParsedCompilerOptions } { TParsedCompilerOptions }
TParsedCompilerOptString = ( TParsedCompilerOptString = (
pcosBaseDir, pcosBaseDir, // the base directory for the relative paths
pcosUnitPath, pcosUnitPath, // search path for pascal units
pcosIncludePath, pcosIncludePath, // search path for pascal include files
pcosObjectPath, pcosObjectPath, // search path for .o files
pcosLibraryPath, pcosLibraryPath, // search path for libraries
pcosLinkerOptions, pcosLinkerOptions,// additional linker options
pcosCustomOptions, pcosCustomOptions,// additional options
pcosOutputDir, pcosOutputDir, // the output directory
pcosCompilerPath pcosCompilerPath // the filename of the compiler
); );
TParsedCompilerOptStrings = set of TParsedCompilerOptString; TParsedCompilerOptStrings = set of TParsedCompilerOptString;
const
ParsedCompilerSearchPaths = [pcosUnitPath,pcosIncludePath,
pcosObjectPath,pcosLibraryPath];
ParsedCompilerFilenames = [pcosOutputDir,pcosCompilerPath];
ParsedCompilerFiles = ParsedCompilerSearchPaths+ParsedCompilerFilenames;
type
TLocalSubstitutionEvent = function(const s: string): string of object;
TParsedCompilerOptions = class TParsedCompilerOptions = class
private
FOnLocalSubstitute: TLocalSubstitutionEvent;
public public
UnparsedValues: array[TParsedCompilerOptString] of string; UnparsedValues: array[TParsedCompilerOptString] of string;
ParsedValues: array[TParsedCompilerOptString] of string; ParsedValues: array[TParsedCompilerOptString] of string;
@ -82,6 +94,10 @@ type
procedure SetUnparsedValue(Option: TParsedCompilerOptString; procedure SetUnparsedValue(Option: TParsedCompilerOptString;
const NewValue: string); const NewValue: string);
procedure Clear; procedure Clear;
procedure InvalidateAll;
procedure InvalidateFiles;
property OnLocalSubstitute: TLocalSubstitutionEvent read FOnLocalSubstitute
write FOnLocalSubstitute;
end; end;
TParseStringEvent = TParseStringEvent =
@ -93,16 +109,19 @@ type
TBaseCompilerOptions = class TBaseCompilerOptions = class
private private
fOwner: TObject; FBaseDirectory: string;
fInheritedOptions: array[TInheritedCompilerOption] of string;
fInheritedOptParseStamps: integer;
fInheritedOptGraphStamps: integer;
fLoaded: Boolean;
FModified: boolean; FModified: boolean;
FOnModified: TNotifyEvent; FOnModified: TNotifyEvent;
fOptionsString: String; fOptionsString: String;
fOwner: TObject;
FParsedOpts: TParsedCompilerOptions; FParsedOpts: TParsedCompilerOptions;
xmlconfig: TXMLConfig;
fXMLFile: String;
fTargetFilename: string; fTargetFilename: string;
fLoaded: Boolean; fXMLFile: String;
xmlconfig: TXMLConfig;
// Search Paths: // Search Paths:
fIncludeFiles: String; fIncludeFiles: String;
@ -111,6 +130,7 @@ type
fCompilerPath: String; fCompilerPath: String;
fUnitOutputDir: string; fUnitOutputDir: string;
fLCLWidgetType: string; fLCLWidgetType: string;
FObjectPath: string;
// Parsing: // Parsing:
// style // style
@ -181,17 +201,21 @@ type
fAdditionalConfigFile: Boolean; fAdditionalConfigFile: Boolean;
fConfigFilePath: String; fConfigFilePath: String;
fCustomOptions: string; fCustomOptions: string;
procedure SetCompilerPath(const AValue: String); protected
procedure SetCustomOptions(const AValue: string); procedure SetBaseDirectory(const AValue: string); virtual;
procedure SetIncludeFiles(const AValue: String); procedure SetCompilerPath(const AValue: String); virtual;
procedure SetLibraries(const AValue: String); procedure SetCustomOptions(const AValue: string); virtual;
procedure SetLinkerOptions(const AValue: String); procedure SetIncludeFiles(const AValue: String); virtual;
procedure SetOtherUnitFiles(const AValue: String); procedure SetLibraries(const AValue: String); virtual;
procedure SetUnitOutputDir(const AValue: string); procedure SetLinkerOptions(const AValue: String); virtual;
procedure SetOtherUnitFiles(const AValue: String); virtual;
procedure SetUnitOutputDir(const AValue: string); virtual;
procedure SetObjectPath(const AValue: string); virtual;
protected protected
procedure LoadTheCompilerOptions(const Path: string); virtual; procedure LoadTheCompilerOptions(const Path: string); virtual;
procedure SaveTheCompilerOptions(const Path: string); virtual; procedure SaveTheCompilerOptions(const Path: string); virtual;
procedure SetModified(const AValue: boolean); virtual; procedure SetModified(const AValue: boolean); virtual;
procedure ClearInheritedOptions;
public public
constructor Create(TheOwner: TObject); constructor Create(TheOwner: TObject);
destructor Destroy; override; destructor Destroy; override;
@ -214,13 +238,16 @@ type
function CreateTargetFilename(const MainSourceFileName: string): string; virtual; function CreateTargetFilename(const MainSourceFileName: string): string; virtual;
procedure GetInheritedCompilerOptions(var OptionsList: TList); virtual; procedure GetInheritedCompilerOptions(var OptionsList: TList); virtual;
function GetOwnerName: string; virtual; function GetOwnerName: string; virtual;
function GetBaseDirectory: string; virtual; function GetInheritedOption(Option: TInheritedCompilerOption): string; virtual;
function MergeLinkerOptions(const OldOptions, AddOptions: string): string;
function MergeCustomOptions(const OldOptions, AddOptions: string): string;
public public
{ Properties } { Properties }
property Owner: TObject read fOwner write fOwner; property Owner: TObject read fOwner write fOwner;
property Modified: boolean read FModified write SetModified; property Modified: boolean read FModified write SetModified;
property OnModified: TNotifyEvent read FOnModified write FOnModified; property OnModified: TNotifyEvent read FOnModified write FOnModified;
property ParsedOpts: TParsedCompilerOptions read FParsedOpts; property ParsedOpts: TParsedCompilerOptions read FParsedOpts;
property BaseDirectory: string read FBaseDirectory write SetBaseDirectory;
property XMLFile: String read fXMLFile write fXMLFile; property XMLFile: String read fXMLFile write fXMLFile;
property TargetFilename: String read fTargetFilename write fTargetFilename; property TargetFilename: String read fTargetFilename write fTargetFilename;
@ -234,6 +261,7 @@ type
property CompilerPath: String read fCompilerPath write SetCompilerPath; property CompilerPath: String read fCompilerPath write SetCompilerPath;
property UnitOutputDirectory: string read fUnitOutputDir write SetUnitOutputDir; property UnitOutputDirectory: string read fUnitOutputDir write SetUnitOutputDir;
property LCLWidgetType: string read fLCLWidgetType write fLCLWidgetType; property LCLWidgetType: string read fLCLWidgetType write fLCLWidgetType;
property ObjectPath: string read FObjectPath write SetObjectPath;
// parsing: // parsing:
property Style: Integer read fStyle write fStyle; property Style: Integer read fStyle write fStyle;
@ -317,6 +345,7 @@ type
TAdditionalCompilerOptions = class TAdditionalCompilerOptions = class
private private
FBaseDirectory: string;
FCustomOptions: string; FCustomOptions: string;
FIncludePath: string; FIncludePath: string;
FLibraryPath: string; FLibraryPath: string;
@ -325,12 +354,14 @@ type
fOwner: TObject; fOwner: TObject;
FParsedOpts: TParsedCompilerOptions; FParsedOpts: TParsedCompilerOptions;
FUnitPath: string; FUnitPath: string;
procedure SetCustomOptions(const AValue: string); protected
procedure SetIncludePath(const AValue: string); procedure SetBaseDirectory(const AValue: string); virtual;
procedure SetLibraryPath(const AValue: string); procedure SetCustomOptions(const AValue: string); virtual;
procedure SetLinkerOptions(const AValue: string); procedure SetIncludePath(const AValue: string); virtual;
procedure SetObjectPath(const AValue: string); procedure SetLibraryPath(const AValue: string); virtual;
procedure SetUnitPath(const AValue: string); procedure SetLinkerOptions(const AValue: string); virtual;
procedure SetObjectPath(const AValue: string); virtual;
procedure SetUnitPath(const AValue: string); virtual;
public public
constructor Create(TheOwner: TObject); constructor Create(TheOwner: TObject);
destructor Destroy; override; destructor Destroy; override;
@ -338,7 +369,6 @@ type
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string); procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string); procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);
function GetOwnerName: string; virtual; function GetOwnerName: string; virtual;
function GetBaseDirectory: string; virtual;
public public
property Owner: TObject read fOwner; property Owner: TObject read fOwner;
property UnitPath: string read FUnitPath write SetUnitPath; property UnitPath: string read FUnitPath write SetUnitPath;
@ -347,6 +377,7 @@ type
property LibraryPath: string read FLibraryPath write SetLibraryPath; property LibraryPath: string read FLibraryPath write SetLibraryPath;
property LinkerOptions: string read FLinkerOptions write SetLinkerOptions; property LinkerOptions: string read FLinkerOptions write SetLinkerOptions;
property CustomOptions: string read FCustomOptions write SetCustomOptions; property CustomOptions: string read FCustomOptions write SetCustomOptions;
property BaseDirectory: string read FBaseDirectory write SetBaseDirectory;
property ParsedOpts: TParsedCompilerOptions read FParsedOpts; property ParsedOpts: TParsedCompilerOptions read FParsedOpts;
end; end;
@ -363,6 +394,7 @@ type
TfrmCompilerOptions = class(TForm) TfrmCompilerOptions = class(TForm)
nbMain: TNotebook; nbMain: TNotebook;
ImageList: TImageList;
{ Search Paths Controls } { Search Paths Controls }
PathPage: TPage; PathPage: TPage;
@ -528,6 +560,8 @@ type
procedure SetupButtonBar; procedure SetupButtonBar;
private private
FReadOnly: boolean; FReadOnly: boolean;
ImageIndexPackage: integer;
ImageIndexRequired: integer;
function GetOtherSourcePath: string; function GetOtherSourcePath: string;
procedure SetOtherSourcePath(const AValue: string); procedure SetOtherSourcePath(const AValue: string);
procedure SetReadOnly(const AValue: boolean); procedure SetReadOnly(const AValue: boolean);
@ -549,10 +583,12 @@ type
var var
frmCompilerOptions: TfrmCompilerOptions; frmCompilerOptions: TfrmCompilerOptions;
ParseStamp: integer; CompilerParseStamp: integer;
CompilerGraphStamp: integer;
OnParseString: TParseStringEvent; OnParseString: TParseStringEvent;
procedure IncreaseParseStamp; procedure IncreaseCompilerParseStamp;
procedure IncreaseCompilerGraphStamp;
function ParseString(Options: TParsedCompilerOptions; function ParseString(Options: TParsedCompilerOptions;
const UnparsedValue: string): string; const UnparsedValue: string): string;
@ -560,16 +596,24 @@ implementation
const const
Config_Filename = 'compileroptions.xml'; Config_Filename = 'compileroptions.xml';
MaxParsedStamp = $7fffffff; MaxParseStamp = $7fffffff;
MinParsedStamp = -$7fffffff; MinParseStamp = -$7fffffff;
InvalidParsedStamp = MinParsedStamp-1; InvalidParseStamp = MinParseStamp-1;
procedure IncreaseParseStamp; procedure IncreaseCompilerParseStamp;
begin begin
if ParseStamp<MaxParsedStamp then if CompilerParseStamp<MaxParseStamp then
inc(ParseStamp) inc(CompilerParseStamp)
else else
ParseStamp:=MinParsedStamp; CompilerParseStamp:=MinParseStamp;
end;
procedure IncreaseCompilerGraphStamp;
begin
if CompilerGraphStamp<MaxParseStamp then
inc(CompilerGraphStamp)
else
CompilerGraphStamp:=MinParseStamp;
end; end;
function ParseString(Options: TParsedCompilerOptions; function ParseString(Options: TParsedCompilerOptions;
@ -665,6 +709,13 @@ begin
ParsedOpts.SetUnparsedValue(pcosCompilerPath,fCompilerPath); ParsedOpts.SetUnparsedValue(pcosCompilerPath,fCompilerPath);
end; end;
procedure TBaseCompilerOptions.SetBaseDirectory(const AValue: string);
begin
if FBaseDirectory=AValue then exit;
FBaseDirectory:=AValue;
ParsedOpts.SetUnparsedValue(pcosBaseDir,FBaseDirectory);
end;
procedure TBaseCompilerOptions.SetCustomOptions(const AValue: string); procedure TBaseCompilerOptions.SetCustomOptions(const AValue: string);
begin begin
if fCustomOptions=AValue then exit; if fCustomOptions=AValue then exit;
@ -700,6 +751,13 @@ begin
ParsedOpts.SetUnparsedValue(pcosOutputDir,fUnitOutputDir); ParsedOpts.SetUnparsedValue(pcosOutputDir,fUnitOutputDir);
end; end;
procedure TBaseCompilerOptions.SetObjectPath(const AValue: string);
begin
if FObjectPath=AValue then exit;
FObjectPath:=AValue;
ParsedOpts.SetUnparsedValue(pcosObjectPath,FObjectPath);
end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
TfrmCompilerOptions LoadTheCompilerOptions TfrmCompilerOptions LoadTheCompilerOptions
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
@ -724,6 +782,7 @@ begin
CompilerPath := XMLConfigFile.GetValue(p+'CompilerPath/Value', '$(CompPath)'); CompilerPath := XMLConfigFile.GetValue(p+'CompilerPath/Value', '$(CompPath)');
UnitOutputDirectory := XMLConfigFile.GetValue(p+'UnitOutputDirectory/Value', ''); UnitOutputDirectory := XMLConfigFile.GetValue(p+'UnitOutputDirectory/Value', '');
LCLWidgetType := XMLConfigFile.GetValue(p+'LCLWidgetType/Value', 'gtk'); LCLWidgetType := XMLConfigFile.GetValue(p+'LCLWidgetType/Value', 'gtk');
ObjectPath := XMLConfigFile.GetValue(p+'ObjectPath/Value', '');
{ Parsing } { Parsing }
p:='CompilerOptions/Parsing/'; p:='CompilerOptions/Parsing/';
@ -851,6 +910,7 @@ begin
XMLConfigFile.SetDeleteValue(p+'CompilerPath/Value', CompilerPath,''); XMLConfigFile.SetDeleteValue(p+'CompilerPath/Value', CompilerPath,'');
XMLConfigFile.SetDeleteValue(p+'UnitOutputDirectory/Value', UnitOutputDirectory,''); XMLConfigFile.SetDeleteValue(p+'UnitOutputDirectory/Value', UnitOutputDirectory,'');
XMLConfigFile.SetDeleteValue(p+'LCLWidgetType/Value', LCLWidgetType,''); XMLConfigFile.SetDeleteValue(p+'LCLWidgetType/Value', LCLWidgetType,'');
XMLConfigFile.SetDeleteValue(p+'ObjectPath/Value', ObjectPath,'');
{ Parsing } { Parsing }
p:='CompilerOptions/Parsing/'; p:='CompilerOptions/Parsing/';
@ -936,6 +996,16 @@ begin
OnModified(Self); OnModified(Self);
end; end;
procedure TBaseCompilerOptions.ClearInheritedOptions;
var
i: TInheritedCompilerOption;
begin
fInheritedOptParseStamps:=InvalidParseStamp;
fInheritedOptGraphStamps:=InvalidParseStamp;
for i:=Low(TInheritedCompilerOption) to High(TInheritedCompilerOption) do
fInheritedOptions[i]:='';
end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
TBaseCompilerOptions CreateTargetFilename TBaseCompilerOptions CreateTargetFilename
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
@ -971,11 +1041,88 @@ begin
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
function TBaseCompilerOptions.GetBaseDirectory: string; function TBaseCompilerOptions.GetInheritedOption(
Option: TInheritedCompilerOption): string;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TBaseCompilerOptions.GetBaseDirectory: string; function TBaseCompilerOptions.GetInheritedOption(
Option: TInheritedCompilerOption): string;
var
OptionsList: TList;
i: Integer;
AddOptions: TAdditionalCompilerOptions;
begin begin
Result:=''; if (fInheritedOptParseStamps<>CompilerParseStamp)
or (fInheritedOptGraphStamps<>CompilerGraphStamp)
then begin
// update inherited options
ClearInheritedOptions;
OptionsList:=nil;
GetInheritedCompilerOptions(OptionsList);
if OptionsList<>nil then begin
for i:=0 to OptionsList.Count-1 do begin
AddOptions:=TAdditionalCompilerOptions(OptionsList[i]);
if (not (AddOptions is TAdditionalCompilerOptions)) then continue;
// unit search path
fInheritedOptions[icoUnitPath]:=
MergeSearchPaths(fInheritedOptions[icoUnitPath],AddOptions.UnitPath);
// include search path
fInheritedOptions[icoIncludePath]:=
MergeSearchPaths(fInheritedOptions[icoIncludePath],
AddOptions.IncludePath);
// object search path
fInheritedOptions[icoObjectPath]:=
MergeSearchPaths(fInheritedOptions[icoObjectPath],
AddOptions.ObjectPath);
// library search path
fInheritedOptions[icoLibraryPath]:=
MergeSearchPaths(fInheritedOptions[icoLibraryPath],
AddOptions.LibraryPath);
// linker options
fInheritedOptions[icoLinkerOptions]:=
MergeLinkerOptions(fInheritedOptions[icoLinkerOptions],
AddOptions.LinkerOptions);
// custom options
fInheritedOptions[icoCustomOptions]:=
MergeCustomOptions(fInheritedOptions[icoCustomOptions],
AddOptions.CustomOptions);
end;
end;
fInheritedOptParseStamps:=CompilerParseStamp;
fInheritedOptGraphStamps:=CompilerGraphStamp;
end;
Result:=fInheritedOptions[Option];
end;
{------------------------------------------------------------------------------
function TBaseCompilerOptions.MergeLinkerOptions(const OldOptions,
AddOptions: string): string;
------------------------------------------------------------------------------}
function TBaseCompilerOptions.MergeLinkerOptions(const OldOptions,
AddOptions: string): string;
begin
Result:=OldOptions;
if AddOptions='' then exit;
if (OldOptions[length(OldOptions)]<>' ')
and (AddOptions[1]<>' ') then
Result:=Result+' '+AddOptions
else
Result:=Result+AddOptions;
end;
{------------------------------------------------------------------------------
function TBaseCompilerOptions.MergeCustomOptions(const OldOptions,
AddOptions: string): string;
------------------------------------------------------------------------------}
function TBaseCompilerOptions.MergeCustomOptions(const OldOptions,
AddOptions: string): string;
begin
Result:=OldOptions;
if AddOptions='' then exit;
if (OldOptions[length(OldOptions)]<>' ')
and (AddOptions[1]<>' ') then
Result:=Result+' '+AddOptions
else
Result:=Result+AddOptions;
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -986,6 +1133,10 @@ begin
Result:=MakeOptionsString('') Result:=MakeOptionsString('')
end; end;
{------------------------------------------------------------------------------
function TBaseCompilerOptions.MakeOptionsString(
const MainSourceFilename: string): String;
------------------------------------------------------------------------------}
function TBaseCompilerOptions.MakeOptionsString( function TBaseCompilerOptions.MakeOptionsString(
const MainSourceFilename: string): String; const MainSourceFilename: string): String;
var var
@ -1576,6 +1727,7 @@ begin
OtherUnitFiles := ''; OtherUnitFiles := '';
CompilerPath := '$(CompPath)'; CompilerPath := '$(CompPath)';
UnitOutputDirectory := ''; UnitOutputDirectory := '';
ObjectPath:='';
fLCLWidgetType := 'gtk'; fLCLWidgetType := 'gtk';
// parsing // parsing
@ -1643,6 +1795,9 @@ begin
fAdditionalConfigFile := false; fAdditionalConfigFile := false;
fConfigFilePath := './fpc.cfg'; fConfigFilePath := './fpc.cfg';
CustomOptions := ''; CustomOptions := '';
// inherited
ClearInheritedOptions;
end; end;
procedure TBaseCompilerOptions.Assign(CompOpts: TBaseCompilerOptions); procedure TBaseCompilerOptions.Assign(CompOpts: TBaseCompilerOptions);
@ -1657,6 +1812,7 @@ begin
CompilerPath := CompOpts.fCompilerPath; CompilerPath := CompOpts.fCompilerPath;
UnitOutputDirectory := CompOpts.fUnitOutputDir; UnitOutputDirectory := CompOpts.fUnitOutputDir;
fLCLWidgetType := CompOpts.fLCLWidgetType; fLCLWidgetType := CompOpts.fLCLWidgetType;
ObjectPath := CompOpts.FObjectPath;
// Parsing // Parsing
fStyle := CompOpts.fStyle; fStyle := CompOpts.fStyle;
@ -1736,6 +1892,7 @@ begin
and (fOtherUnitFiles = CompOpts.fOtherUnitFiles) and (fOtherUnitFiles = CompOpts.fOtherUnitFiles)
and (fCompilerPath = CompOpts.fCompilerPath) and (fCompilerPath = CompOpts.fCompilerPath)
and (fUnitOutputDir = CompOpts.fUnitOutputDir) and (fUnitOutputDir = CompOpts.fUnitOutputDir)
and (FObjectPath = CompOpts.FObjectPath)
and (fLCLWidgetType = CompOpts.fLCLWidgetType) and (fLCLWidgetType = CompOpts.fLCLWidgetType)
@ -1813,6 +1970,16 @@ end;
{ TfrmCompilerOptions Constructor } { TfrmCompilerOptions Constructor }
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
constructor TfrmCompilerOptions.Create(TheOwner: TComponent); constructor TfrmCompilerOptions.Create(TheOwner: TComponent);
procedure AddResImg(const ResName: string);
var Pixmap: TPixmap;
begin
Pixmap:=TPixmap.Create;
Pixmap.TransparentColor:=clWhite;
Pixmap.LoadFromLazarusResource(ResName);
ImageList.Add(Pixmap,nil)
end;
var Page: integer; var Page: integer;
begin begin
inherited Create(TheOwner); inherited Create(TheOwner);
@ -1821,6 +1988,17 @@ begin
Position:=poScreenCenter; Position:=poScreenCenter;
IDEDialogLayoutList.ApplyLayout(Self,550,450); IDEDialogLayoutList.ApplyLayout(Self,550,450);
ImageList:=TImageList.Create(Self);
with ImageList do begin
Width:=17;
Height:=17;
Name:='ImageList';
ImageIndexPackage:=Count;
AddResImg('pkg_package');
ImageIndexRequired:=Count;
AddResImg('pkg_required');
end;
nbMain := TNotebook.Create(Self); nbMain := TNotebook.Create(Self);
nbMain.Parent := Self; nbMain.Parent := Self;
@ -2218,19 +2396,50 @@ var
i: Integer; i: Integer;
AncestorOptions: TAdditionalCompilerOptions; AncestorOptions: TAdditionalCompilerOptions;
AncestorNode: TTreeNode; AncestorNode: TTreeNode;
procedure AddChildNode(const NewNodeName, Value: string);
var
VisibleValue: String;
ChildNode: TTreeNode;
begin
if Value='' then exit;
if length(Value)>100 then
VisibleValue:=copy(Value,1,100)+'[...]'
else
VisibleValue:=Value;
ChildNode:=InhTreeView.Items.AddChild(AncestorNode,
NewNodeName+' = "'+VisibleValue+'"');
ChildNode.ImageIndex:=ImageIndexRequired;
ChildNode.SelectedIndex:=ChildNode.ImageIndex;
end;
begin begin
CompilerOpts.GetInheritedCompilerOptions(OptionsList); CompilerOpts.GetInheritedCompilerOptions(OptionsList);
InhTreeView.BeginUpdate; InhTreeView.BeginUpdate;
InhTreeView.Items.Clear; InhTreeView.Items.Clear;
// add All node
// ToDo
if OptionsList<>nil then begin if OptionsList<>nil then begin
for i:=0 to OptionsList.Count-1 do begin for i:=0 to OptionsList.Count-1 do begin
AncestorOptions:=TAdditionalCompilerOptions(OptionsList[i]); AncestorOptions:=TAdditionalCompilerOptions(OptionsList[i]);
AncestorNode:=InhTreeView.Items.Add(nil,''); AncestorNode:=InhTreeView.Items.Add(nil,'');
AncestorNode.Text:=AncestorOptions.GetOwnerName; AncestorNode.Text:=AncestorOptions.GetOwnerName;
AncestorNode.ImageIndex:=ImageIndexPackage;
// ToDo AncestorNode.SelectedIndex:=AncestorNode.ImageIndex;
with AncestorOptions.ParsedOpts do begin
AddChildNode('unit path',GetParsedValue(pcosUnitPath));
AddChildNode('include path',GetParsedValue(pcosIncludePath));
AddChildNode('object path',GetParsedValue(pcosObjectPath));
AddChildNode('library path',GetParsedValue(pcosLibraryPath));
AddChildNode('linker options',GetParsedValue(pcosLinkerOptions));
AddChildNode('custom options',GetParsedValue(pcosCustomOptions));
end;
AncestorNode.Expanded:=true;
end; end;
end else begin
InhTreeView.Items.Add(nil,'No compiler options inherited.');
end; end;
InhTreeView.EndUpdate; InhTreeView.EndUpdate;
end; end;
@ -3209,6 +3418,7 @@ begin
Parent:=InheritedPage; Parent:=InheritedPage;
Options:=Options+[tvoReadOnly, tvoRightClickSelect, tvoShowRoot, Options:=Options+[tvoReadOnly, tvoRightClickSelect, tvoShowRoot,
tvoKeepCollapsedNodes]; tvoKeepCollapsedNodes];
Images:=ImageList;
Align:=alClient; Align:=alClient;
end; end;
end; end;
@ -3615,6 +3825,13 @@ begin
ParsedOpts.SetUnparsedValue(pcosCustomOptions,fCustomOptions); ParsedOpts.SetUnparsedValue(pcosCustomOptions,fCustomOptions);
end; end;
procedure TAdditionalCompilerOptions.SetBaseDirectory(const AValue: string);
begin
if FBaseDirectory=AValue then exit;
FBaseDirectory:=AValue;
ParsedOpts.SetUnparsedValue(pcosBaseDir,FBaseDirectory);
end;
procedure TAdditionalCompilerOptions.SetIncludePath(const AValue: string); procedure TAdditionalCompilerOptions.SetIncludePath(const AValue: string);
begin begin
if FIncludePath=AValue then exit; if FIncludePath=AValue then exit;
@ -3677,12 +3894,12 @@ procedure TAdditionalCompilerOptions.LoadFromXMLConfig(XMLConfig: TXMLConfig;
const Path: string); const Path: string);
begin begin
Clear; Clear;
fCustomOptions:=XMLConfig.GetValue(Path+'CustomOptions/Value',''); CustomOptions:=XMLConfig.GetValue(Path+'CustomOptions/Value','');
FIncludePath:=XMLConfig.GetValue(Path+'IncludePath/Value',''); IncludePath:=XMLConfig.GetValue(Path+'IncludePath/Value','');
FLibraryPath:=XMLConfig.GetValue(Path+'LibraryPath/Value',''); LibraryPath:=XMLConfig.GetValue(Path+'LibraryPath/Value','');
fLinkerOptions:=XMLConfig.GetValue(Path+'LinkerOptions/Value',''); LinkerOptions:=XMLConfig.GetValue(Path+'LinkerOptions/Value','');
FObjectPath:=XMLConfig.GetValue(Path+'ObjectPath/Value',''); ObjectPath:=XMLConfig.GetValue(Path+'ObjectPath/Value','');
FUnitPath:=XMLConfig.GetValue(Path+'UnitPath/Value',''); UnitPath:=XMLConfig.GetValue(Path+'UnitPath/Value','');
end; end;
procedure TAdditionalCompilerOptions.SaveToXMLConfig(XMLConfig: TXMLConfig; procedure TAdditionalCompilerOptions.SaveToXMLConfig(XMLConfig: TXMLConfig;
@ -3704,18 +3921,6 @@ begin
Result:='Has no owner'; Result:='Has no owner';
end; end;
function TAdditionalCompilerOptions.GetBaseDirectory: string;
begin
Result:='';
end;
{ TCompilerOptions }
procedure TCompilerOptions.Clear;
begin
inherited Clear;
end;
{ TParsedCompilerOptions } { TParsedCompilerOptions }
constructor TParsedCompilerOptions.Create; constructor TParsedCompilerOptions.Create;
@ -3725,33 +3930,92 @@ end;
function TParsedCompilerOptions.GetParsedValue(Option: TParsedCompilerOptString function TParsedCompilerOptions.GetParsedValue(Option: TParsedCompilerOptString
): string; ): string;
var
BaseDirectory: String;
s: String;
begin begin
if ParsedStamp[Option]<>ParseStamp then begin if ParsedStamp[Option]<>CompilerParseStamp then begin
ParsedValues[Option]:=ParseString(Self,UnparsedValues[Option]); s:=ParseString(Self,UnparsedValues[Option]);
// make filename absolute if Option=pcosBaseDir then
// ToDo // base directory (append path)
ParsedStamp[Option]:=ParseStamp; s:=AppendPathDelim(TrimFilename(s))
else if Option in ParsedCompilerFilenames then begin
// make filename absolute
s:=TrimFilename(s);
BaseDirectory:=GetParsedValue(pcosBaseDir);
if (BaseDirectory<>'') and (not FilenameIsAbsolute(s)) then
s:=BaseDirectory+s;
end
else if Option in ParsedCompilerSearchPaths then begin
// make search paths absolute
BaseDirectory:=GetParsedValue(pcosBaseDir);
s:=TrimSearchPath(s,BaseDirectory);
end;
ParsedValues[Option]:=s;
ParsedStamp[Option]:=CompilerParseStamp;
end; end;
Result:=ParsedValues[Option]; Result:=ParsedValues[Option];
end; end;
procedure TParsedCompilerOptions.SetUnparsedValue( procedure TParsedCompilerOptions.SetUnparsedValue(
Option: TParsedCompilerOptString; const NewValue: string); Option: TParsedCompilerOptString; const NewValue: string);
var
PreParsedValue: String;
begin begin
ParsedStamp[Option]:=InvalidParsedStamp; if Assigned(OnLocalSubstitute) then begin
UnparsedValues[Option]:=NewValue; PreParsedValue:=OnLocalSubstitute(NewValue);
end else begin
PreParsedValue:=NewValue;
end;
if PreParsedValue=UnparsedValues[Option] then exit;
IncreaseCompilerGraphStamp;
if Option=pcosBaseDir then
InvalidateFiles
else
ParsedStamp[Option]:=InvalidParseStamp;
UnparsedValues[Option]:=PreParsedValue;
end; end;
procedure TParsedCompilerOptions.Clear; procedure TParsedCompilerOptions.Clear;
var var
Option: TParsedCompilerOptString; Option: TParsedCompilerOptString;
begin begin
InvalidateAll;
for Option:=Low(TParsedCompilerOptString) to High(TParsedCompilerOptString) do for Option:=Low(TParsedCompilerOptString) to High(TParsedCompilerOptString) do
ParsedStamp[Option]:=InvalidParsedStamp; begin
ParsedValues[Option]:='';
UnparsedValues[Option]:='';
end;
end;
procedure TParsedCompilerOptions.InvalidateAll;
var
Option: TParsedCompilerOptString;
begin
for Option:=Low(TParsedCompilerOptString) to High(TParsedCompilerOptString) do
ParsedStamp[Option]:=InvalidParseStamp;
end;
procedure TParsedCompilerOptions.InvalidateFiles;
var
Option: TParsedCompilerOptString;
begin
for Option:=Low(TParsedCompilerOptString) to High(TParsedCompilerOptString) do
if (Option in ParsedCompilerFiles) then
ParsedStamp[Option]:=InvalidParseStamp;
end;
{ TCompilerOptions }
procedure TCompilerOptions.Clear;
begin
inherited Clear;
end; end;
initialization initialization
ParseStamp:=0; CompilerParseStamp:=1;
CompilerGraphStamp:=1;
end. end.

View File

@ -209,7 +209,6 @@ type
public public
constructor Create(TheProject: TProject); constructor Create(TheProject: TProject);
function GetOwnerName: string; override; function GetOwnerName: string; override;
function GetBaseDirectory: string; override;
public public
property OwnerProject: TProject read FOwnerProject; property OwnerProject: TProject read FOwnerProject;
end; end;
@ -254,6 +253,7 @@ type
fOnFileBackup: TOnFileBackup; fOnFileBackup: TOnFileBackup;
fOutputDirectory: String; fOutputDirectory: String;
fProjectInfoFile: String; // the lpi filename fProjectInfoFile: String; // the lpi filename
fProjectDirectory: string;
fProjectType: TProjectType; fProjectType: TProjectType;
fPublishOptions: TPublishProjectOptions; fPublishOptions: TPublishProjectOptions;
fRunParameterOptions: TRunParamsOptions; fRunParameterOptions: TRunParamsOptions;
@ -281,6 +281,7 @@ type
function JumpHistoryCheckPosition( function JumpHistoryCheckPosition(
APosition:TProjectJumpHistoryPosition): boolean; APosition:TProjectJumpHistoryPosition): boolean;
procedure SetSrcPath(const NewSrcPath: string); procedure SetSrcPath(const NewSrcPath: string);
procedure UpdateProjectDirectory;
protected protected
procedure AddToEditorWithIndexList(AnUnitInfo: TUnitInfo); procedure AddToEditorWithIndexList(AnUnitInfo: TUnitInfo);
procedure RemoveFromEditorWithIndexList(AnUnitInfo: TUnitInfo); procedure RemoveFromEditorWithIndexList(AnUnitInfo: TUnitInfo);
@ -349,7 +350,6 @@ type
function IsVirtual: boolean; function IsVirtual: boolean;
function RemoveProjectPathFromFilename(const AFilename: string): string; function RemoveProjectPathFromFilename(const AFilename: string): string;
function ProjectDirectory: string;
function FileIsInProjectDir(const AFilename: string): boolean; function FileIsInProjectDir(const AFilename: string): boolean;
procedure GetVirtualDefines(DefTree: TDefineTree; DirDef: TDirectoryDefines); procedure GetVirtualDefines(DefTree: TDefineTree; DirDef: TDirectoryDefines);
function SearchFile(const Filename,SearchPaths,InitialDir:string):string; function SearchFile(const Filename,SearchPaths,InitialDir:string):string;
@ -368,20 +368,21 @@ type
read fCompilerOptions write fCompilerOptions; read fCompilerOptions write fCompilerOptions;
property FirstAutoRevertLockedUnit: TUnitInfo read fFirstAutoRevertLockedUnit; property FirstAutoRevertLockedUnit: TUnitInfo read fFirstAutoRevertLockedUnit;
property FirstLoadedUnit: TUnitInfo read fFirstLoadedUnit; property FirstLoadedUnit: TUnitInfo read fFirstLoadedUnit;
property FirstUnitWithEditorIndex: TUnitInfo read fFirstUnitWithEditorIndex;
property FirstUnitWithForm: TUnitInfo read fFirstUnitWithForm;
property FirstPartOfProject: TUnitInfo read fFirstPartOfProject; property FirstPartOfProject: TUnitInfo read fFirstPartOfProject;
property FirstUnitWithEditorIndex: TUnitInfo read fFirstUnitWithEditorIndex;
property FirstUnitWithForm: TUnitInfo read fFirstUnitWithForm;
property Flags: TProjectFlags read FFlags write SetFlags; property Flags: TProjectFlags read FFlags write SetFlags;
property IconPath: String read fIconPath write fIconPath; property IconPath: String read fIconPath write fIconPath;
property JumpHistory: TProjectJumpHistory property JumpHistory: TProjectJumpHistory
read fJumpHistory write fJumpHistory; read fJumpHistory write fJumpHistory;
property MainFilename: String read GetMainFilename;
property MainUnitID: Integer read fMainUnitID write SetMainUnitID; property MainUnitID: Integer read fMainUnitID write SetMainUnitID;
property MainUnitInfo: TUnitInfo read GetMainUnitInfo; property MainUnitInfo: TUnitInfo read GetMainUnitInfo;
property Modified: boolean read fModified write fModified; property Modified: boolean read fModified write fModified;
property OnFileBackup: TOnFileBackup read fOnFileBackup write fOnFileBackup; property OnFileBackup: TOnFileBackup read fOnFileBackup write fOnFileBackup;
property OutputDirectory: String read fOutputDirectory write fOutputDirectory; property OutputDirectory: String read fOutputDirectory write fOutputDirectory;
property MainFilename: String read GetMainFilename; property ProjectDirectory: string read fProjectDirectory;
property ProjectInfoFile: string property ProjectInfoFile: string
read GetProjectInfoFile write SetProjectInfoFile; read GetProjectInfoFile write SetProjectInfoFile;
property ProjectType: TProjectType read fProjectType write fProjectType; property ProjectType: TProjectType read fProjectType write fProjectType;
@ -1066,6 +1067,7 @@ begin
fModified := false; fModified := false;
fOutputDirectory := '.'; fOutputDirectory := '.';
fProjectInfoFile := ''; fProjectInfoFile := '';
UpdateProjectDirectory;
fPublishOptions:=TPublishProjectOptions.Create; fPublishOptions:=TPublishProjectOptions.Create;
fRunParameterOptions:=TRunParamsOptions.Create; fRunParameterOptions:=TRunParamsOptions.Create;
fSrcPath := ''; fSrcPath := '';
@ -1482,6 +1484,7 @@ begin
fModified := false; fModified := false;
fOutputDirectory := '.'; fOutputDirectory := '.';
fProjectInfoFile := ''; fProjectInfoFile := '';
UpdateProjectDirectory;
fPublishOptions.Clear; fPublishOptions.Clear;
fSrcPath := ''; fSrcPath := '';
fTargetFileExt := DefaultTargetFileExt; fTargetFileExt := DefaultTargetFileExt;
@ -1912,13 +1915,18 @@ begin
end; end;
procedure TProject.SetProjectInfoFile(const NewFilename:string); procedure TProject.SetProjectInfoFile(const NewFilename:string);
var
NewProjectInfoFile: String;
begin begin
if NewFilename='' then exit; NewProjectInfoFile:=TrimFilename(NewFilename);
if NewProjectInfoFile='' then exit;
DoDirSeparators(NewProjectInfoFile);
if (AnsiCompareText(fTitle,ExtractFileNameOnly(fProjectInfoFile))=0) if (AnsiCompareText(fTitle,ExtractFileNameOnly(fProjectInfoFile))=0)
or (fProjectInfoFile='') or (fTitle='') then or (fProjectInfoFile='') or (fTitle='') then begin
fTitle:=ExtractFileNameOnly(NewFilename); fTitle:=ExtractFileNameOnly(NewProjectInfoFile);
fProjectInfoFile:=NewFilename; end;
fProjectInfoFile:=NewProjectInfoFile;
UpdateProjectDirectory;
Modified:=true; Modified:=true;
end; end;
@ -1968,11 +1976,6 @@ begin
length(Result)-length(ProjectPath)); length(Result)-length(ProjectPath));
end; end;
function TProject.ProjectDirectory: string;
begin
Result:=ExtractFilePath(ProjectInfoFile);
end;
function TProject.FileIsInProjectDir(const AFilename: string): boolean; function TProject.FileIsInProjectDir(const AFilename: string): boolean;
var ProjectDir, FilePath: string; var ProjectDir, FilePath: string;
begin begin
@ -2161,6 +2164,12 @@ begin
fSrcPath:=NewSrcPath; fSrcPath:=NewSrcPath;
end; end;
procedure TProject.UpdateProjectDirectory;
begin
fProjectDirectory:=ExtractFilePath(fProjectInfoFile);
CompilerOptions.BaseDirectory:=fProjectDirectory;
end;
procedure TProject.AddToEditorWithIndexList(AnUnitInfo: TUnitInfo); procedure TProject.AddToEditorWithIndexList(AnUnitInfo: TUnitInfo);
begin begin
// add to list if AnUnitInfo is not in list // add to list if AnUnitInfo is not in list
@ -2321,17 +2330,15 @@ begin
if Result='' then Result:=ExtractFilename(OwnerProject.ProjectInfoFile); if Result='' then Result:=ExtractFilename(OwnerProject.ProjectInfoFile);
end; end;
function TProjectCompilerOptions.GetBaseDirectory: string;
begin
Result:=OwnerProject.ProjectDirectory;
end;
end. end.
{ {
$Log$ $Log$
Revision 1.106 2003/04/15 17:58:28 mattias
implemented inherited Compiler Options View
Revision 1.105 2003/04/15 08:54:27 mattias Revision 1.105 2003/04/15 08:54:27 mattias
fixed TMemo.WordWrap fixed TMemo.WordWrap

View File

@ -73,9 +73,11 @@ type
TTransferMacroList = class TTransferMacroList = class
private private
fItems: TList; // list of TTransferMacro fItems: TList; // list of TTransferMacro
FMarkUnhandledMacros: boolean;
fOnSubstitution: TOnSubstitution; fOnSubstitution: TOnSubstitution;
function GetItems(Index: integer): TTransferMacro; function GetItems(Index: integer): TTransferMacro;
procedure SetItems(Index: integer; NewMacro: TTransferMacro); procedure SetItems(Index: integer; NewMacro: TTransferMacro);
procedure SetMarkUnhandledMacros(const AValue: boolean);
protected protected
function MF_Ext(const Filename:string; var Abort: boolean):string; virtual; function MF_Ext(const Filename:string; var Abort: boolean):string; virtual;
function MF_Path(const Filename:string; var Abort: boolean):string; virtual; function MF_Path(const Filename:string; var Abort: boolean):string; virtual;
@ -98,6 +100,7 @@ type
property OnSubstitution: TOnSubstitution property OnSubstitution: TOnSubstitution
read fOnSubstitution write fOnSubstitution; read fOnSubstitution write fOnSubstitution;
function FindByName(const MacroName: string): TTransferMacro; virtual; function FindByName(const MacroName: string): TTransferMacro; virtual;
property MarkUnhandledMacros: boolean read FMarkUnhandledMacros write SetMarkUnhandledMacros;
end; end;
@ -124,6 +127,7 @@ constructor TTransferMacroList.Create;
begin begin
inherited Create; inherited Create;
fItems:=TList.Create; fItems:=TList.Create;
FMarkUnhandledMacros:=true;
Add(TTransferMacro.Create('Ext','','Function: extract file extension',@MF_Ext,[])); Add(TTransferMacro.Create('Ext','','Function: extract file extension',@MF_Ext,[]));
Add(TTransferMacro.Create('Path','','Function: extract file path',@MF_Path,[])); Add(TTransferMacro.Create('Path','','Function: extract file path',@MF_Path,[]));
Add(TTransferMacro.Create('Name','','Function: extract file name+extension', Add(TTransferMacro.Create('Name','','Function: extract file name+extension',
@ -154,6 +158,12 @@ begin
fItems[Index]:=NewMacro; fItems[Index]:=NewMacro;
end; end;
procedure TTransferMacroList.SetMarkUnhandledMacros(const AValue: boolean);
begin
if FMarkUnhandledMacros=AValue then exit;
FMarkUnhandledMacros:=AValue;
end;
procedure TTransferMacroList.SetValue(const MacroName, NewValue: string); procedure TTransferMacroList.SetValue(const MacroName, NewValue: string);
var AMacro:TTransferMacro; var AMacro:TTransferMacro;
begin begin
@ -197,6 +207,7 @@ var MacroStart,MacroEnd: integer;
InFrontOfMacroLen: Integer; InFrontOfMacroLen: Integer;
NewStringLen: Integer; NewStringLen: Integer;
NewStringPos: Integer; NewStringPos: Integer;
sLen: Integer;
function SearchBracketClose(Position:integer): integer; function SearchBracketClose(Position:integer): integer;
var BracketClose:char; var BracketClose:char;
@ -216,25 +227,25 @@ var MacroStart,MacroEnd: integer;
begin begin
Result:=true; Result:=true;
sLen:=length(s);
MacroStart:=1; MacroStart:=1;
repeat repeat
while (MacroStart<=length(s)) do begin while (MacroStart<sLen) do begin
if (s[MacroStart]='$') and ((MacroStart=1) or (s[MacroStart-1]<>'\')) then if (s[MacroStart]='$') and ((MacroStart=1) or (s[MacroStart-1]<>'\')) then
break break
else else
inc(MacroStart); inc(MacroStart);
end; end;
if MacroStart>length(s) then break; if MacroStart>=sLen then break;
MacroEnd:=MacroStart+1; MacroEnd:=MacroStart+1;
while (MacroEnd<=length(s)) while (MacroEnd<=sLen) and (IsIdentChar[s[MacroEnd]]) do
and (IsIdentCHar[s[MacroEnd]]) do
inc(MacroEnd); inc(MacroEnd);
MacroName:=copy(s,MacroStart+1,MacroEnd-MacroStart-1);
if (MacroEnd<sLen) and (s[MacroEnd] in ['(','{']) then begin
if (MacroEnd<length(s)) and (s[MacroEnd] in ['(','{']) then begin MacroName:=copy(s,MacroStart+1,MacroEnd-MacroStart-1);
MacroEnd:=SearchBracketClose(MacroEnd)+1; MacroEnd:=SearchBracketClose(MacroEnd)+1;
if MacroEnd>length(s)+1 then break; if MacroEnd>sLen+1 then break;
OldMacroLen:=MacroEnd-MacroStart; OldMacroLen:=MacroEnd-MacroStart;
MacroStr:=copy(s,MacroStart,OldMacroLen); MacroStr:=copy(s,MacroStart,OldMacroLen);
// Macro found // Macro found
@ -263,13 +274,14 @@ begin
Result:=false; Result:=false;
exit; exit;
end; end;
Handled:=true;
end; end;
end else begin end else begin
// Macro variable // Macro variable
MacroStr:=copy(s,MacroStart+2,OldMacroLen-3); MacroStr:=copy(s,MacroStart+2,OldMacroLen-3);
AMacro:=FindByName(MacroStr); AMacro:=FindByName(MacroStr);
if Assigned(fOnSubstitution) then if Assigned(fOnSubstitution) then
fOnSubstitution(AMacro,MacroStr,Handled,ABort); fOnSubstitution(AMacro,MacroStr,Handled,Abort);
if Abort then begin if Abort then begin
Result:=false; Result:=false;
exit; exit;
@ -279,33 +291,41 @@ begin
MacroStr:=AMacro.Value; MacroStr:=AMacro.Value;
Handled:=true; Handled:=true;
end; end;
if not Handled then
MacroStr:='(unknown macro: '+MacroStr+')';
end; end;
NewMacroEnd:=MacroStart+length(MacroStr); // mark unhandled macros
NewMacroLen:=length(MacroStr); if not Handled and MarkUnhandledMacros then begin
InFrontOfMacroLen:=MacroStart-1; MacroStr:='(unknown macro: '+MacroStr+')';
BehindMacroLen:=length(s)-MacroEnd+1; Handled:=true;
NewString:=''; end;
NewStringLen:=InFrontOfMacroLen+NewMacroLen+BehindMacroLen; // replace macro with new value
if NewStringLen>0 then begin if Handled then begin
SetLength(NewString,NewStringLen); NewMacroLen:=length(MacroStr);
NewStringPos:=1; NewMacroEnd:=MacroStart+NewMacroLen;
if InFrontOfMacroLen>0 then begin InFrontOfMacroLen:=MacroStart-1;
Move(s[1],NewString[NewStringPos],InFrontOfMacroLen); BehindMacroLen:=sLen-MacroEnd+1;
inc(NewStringPos,InFrontOfMacroLen); NewString:='';
end; NewStringLen:=InFrontOfMacroLen+NewMacroLen+BehindMacroLen;
if NewMacroLen>0 then begin if NewStringLen>0 then begin
Move(MacroStr[1],NewString[NewStringPos],NewMacroLen); SetLength(NewString,NewStringLen);
inc(NewStringPos,NewMacroLen); NewStringPos:=1;
end; if InFrontOfMacroLen>0 then begin
if BehindMacroLen>0 then begin Move(s[1],NewString[NewStringPos],InFrontOfMacroLen);
Move(s[MacroEnd],NewString[NewStringPos],BehindMacroLen); inc(NewStringPos,InFrontOfMacroLen);
inc(NewStringPos,BehindMacroLen); end;
end; if NewMacroLen>0 then begin
Move(MacroStr[1],NewString[NewStringPos],NewMacroLen);
inc(NewStringPos,NewMacroLen);
end;
if BehindMacroLen>0 then begin
Move(s[MacroEnd],NewString[NewStringPos],BehindMacroLen);
inc(NewStringPos,BehindMacroLen);
end;
end;
s:=NewString;
sLen:=length(s);
// continue after the replacement
MacroEnd:=NewMacroEnd;
end; end;
s:=NewString;
MacroEnd:=NewMacroEnd;
end; end;
MacroStart:=MacroEnd; MacroStart:=MacroEnd;
until false; until false;

View File

@ -96,16 +96,56 @@ end;
function TrimFilename(const AFilename: string): string; function TrimFilename(const AFilename: string): string;
// trim double path delims, heading and trailing spaces // trim double path delims, heading and trailing spaces
// and special dirs . and .. // and special dirs . and ..
function FilenameIsTrimmed(const TheFilename: string): boolean;
var
l: Integer;
i: Integer;
begin
Result:=false;
if TheFilename='' then begin
Result:=true;
exit;
end;
l:=length(TheFilename);
// check heading spaces
if TheFilename[1]=' ' then exit;
// check trailing spaces
if TheFilename[l]=' ' then exit;
i:=1;
while i<=l do begin
case TheFilename[i] of
PathDelim:
// check for double path delimiter
if (i<l) and (TheFilename[i+1]=PathDelim) then exit;
'.':
if (i=1) or (TheFilename[i-1]=PathDelim) then begin
// check for . and .. directories
if (i=l) or (TheFilename[i+1]=PathDelim) then exit;
if (TheFilename[i+1]='.')
and ((i=l-1) or (TheFilename[i+2]=PathDelim)) then exit;
end;
end;
inc(i);
end;
Result:=true;
end;
var SrcPos, DestPos, l, DirStart: integer; var SrcPos, DestPos, l, DirStart: integer;
c: char; c: char;
begin begin
Result:=AFilename; Result:=AFilename;
if FilenameIsTrimmed(Result) then exit;
l:=length(AFilename); l:=length(AFilename);
SrcPos:=1; SrcPos:=1;
DestPos:=1; DestPos:=1;
// skip trailing spaces // skip trailing spaces
while (l>=1) and (AFilename[SrcPos]=' ') do dec(l); while (l>=1) and (AFilename[l]=' ') do dec(l);
// skip heading spaces // skip heading spaces
while (SrcPos<=l) and (AFilename[SrcPos]=' ') do inc(SrcPos); while (SrcPos<=l) and (AFilename[SrcPos]=' ') do inc(SrcPos);
@ -132,7 +172,8 @@ begin
// check for special dirs . and .. // check for special dirs . and ..
if (c='.') then begin if (c='.') then begin
if (SrcPos<l) then begin if (SrcPos<l) then begin
if (AFilename[SrcPos+1]=PathDelim) then begin if (AFilename[SrcPos+1]=PathDelim)
and ((DestPos=1) or (AFilename[SrcPos-1]=PathDelim)) then begin
// special dir ./ // special dir ./
// -> skip // -> skip
inc(SrcPos,2); inc(SrcPos,2);
@ -850,6 +891,9 @@ end;
{ {
$Log$ $Log$
Revision 1.23 2003/04/15 17:58:28 mattias
implemented inherited Compiler Options View
Revision 1.22 2003/03/30 20:37:15 mattias Revision 1.22 2003/03/30 20:37:15 mattias
ipro now shows simple HTML pages ipro now shows simple HTML pages

View File

@ -46,7 +46,7 @@ interface
uses uses
Classes, SysUtils, LCLProc, LResources, Graphics, Laz_XMLCfg, AVL_Tree, Classes, SysUtils, LCLProc, LResources, Graphics, Laz_XMLCfg, AVL_Tree,
CompilerOptions, Forms, FileCtrl, IDEProcs, ComponentReg; CompilerOptions, Forms, FileCtrl, IDEProcs, ComponentReg, TransferMacros;
type type
TLazPackage = class; TLazPackage = class;
@ -231,6 +231,10 @@ type
ListType: TPkgDependencyList); ListType: TPkgDependencyList);
procedure RemoveFromList(var FirstDependency: TPkgDependency; procedure RemoveFromList(var FirstDependency: TPkgDependency;
ListType: TPkgDependencyList); ListType: TPkgDependencyList);
procedure MoveUpInList(var FirstDependency: TPkgDependency;
ListType: TPkgDependencyList);
procedure MoveDownInList(var FirstDependency: TPkgDependency;
ListType: TPkgDependencyList);
public public
property PackageName: string read FPackageName write SetPackageName; property PackageName: string read FPackageName write SetPackageName;
property Flags: TPkgDependencyFlags read FFlags write SetFlags; property Flags: TPkgDependencyFlags read FFlags write SetFlags;
@ -251,26 +255,39 @@ type
protected protected
procedure SetLazPackage(const AValue: TLazPackage); procedure SetLazPackage(const AValue: TLazPackage);
procedure SetModified(const NewValue: boolean); override; procedure SetModified(const NewValue: boolean); override;
procedure SetCustomOptions(const AValue: string); override;
procedure SetIncludeFiles(const AValue: string); override;
procedure SetLibraries(const AValue: string); override;
procedure SetLinkerOptions(const AValue: string); override;
procedure SetObjectPath(const AValue: string); override;
procedure SetOtherUnitFiles(const AValue: string); override;
public public
constructor Create(ThePackage: TLazPackage); constructor Create(ThePackage: TLazPackage);
procedure Clear; override; procedure Clear; override;
procedure GetInheritedCompilerOptions(var OptionsList: TList); override; procedure GetInheritedCompilerOptions(var OptionsList: TList); override;
function GetOwnerName: string; override; function GetOwnerName: string; override;
procedure InvalidateOptions;
public public
property LazPackage: TLazPackage read FLazPackage write SetLazPackage; property LazPackage: TLazPackage read FLazPackage write SetLazPackage;
end; end;
{ TPkgAdditinoalCompilerOptions } { TPkgAdditionalCompilerOptions }
TPkgAdditionalCompilerOptions = class(TAdditionalCompilerOptions) TPkgAdditionalCompilerOptions = class(TAdditionalCompilerOptions)
private private
FLazPackage: TLazPackage; FLazPackage: TLazPackage;
procedure SetLazPackage(const AValue: TLazPackage); procedure SetLazPackage(const AValue: TLazPackage);
protected
procedure SetCustomOptions(const AValue: string); override;
procedure SetIncludePath(const AValue: string); override;
procedure SetLibraryPath(const AValue: string); override;
procedure SetLinkerOptions(const AValue: string); override;
procedure SetObjectPath(const AValue: string); override;
procedure SetUnitPath(const AValue: string); override;
public public
constructor Create(ThePackage: TLazPackage); constructor Create(ThePackage: TLazPackage);
function GetOwnerName: string; override; function GetOwnerName: string; override;
function GetBaseDirectory: string; override;
public public
property LazPackage: TLazPackage read FLazPackage write SetLazPackage; property LazPackage: TLazPackage read FLazPackage write SetLazPackage;
end; end;
@ -350,6 +367,7 @@ type
FFlags: TLazPackageFlags; FFlags: TLazPackageFlags;
FIconFile: string; FIconFile: string;
FInstalled: TPackageInstallType; FInstalled: TPackageInstallType;
FMacros: TTransferMacroList;
FModifiedLock: integer; FModifiedLock: integer;
FPackageEditor: TBasePackageEditor; FPackageEditor: TBasePackageEditor;
FPackageType: TLazPackageType; FPackageType: TLazPackageType;
@ -383,10 +401,13 @@ type
procedure SetPackageEditor(const AValue: TBasePackageEditor); procedure SetPackageEditor(const AValue: TBasePackageEditor);
procedure SetPackageType(const AValue: TLazPackageType); procedure SetPackageType(const AValue: TLazPackageType);
procedure SetReadOnly(const AValue: boolean); procedure SetReadOnly(const AValue: boolean);
procedure OnMacroListSubstitution(TheMacro: TTransferMacro; var s: string;
var Handled, Abort: boolean);
function SubstitutePkgMacro(const s: string): string;
procedure Clear;
public public
constructor Create; constructor Create;
destructor Destroy; override; destructor Destroy; override;
procedure Clear;
procedure LockModified; procedure LockModified;
procedure UnlockModified; procedure UnlockModified;
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string); procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);
@ -419,6 +440,8 @@ type
procedure DeleteRemoveRequiredPkg(Dependency: TPkgDependency); procedure DeleteRemoveRequiredPkg(Dependency: TPkgDependency);
procedure AddRequiredDependency(Dependency: TPkgDependency); procedure AddRequiredDependency(Dependency: TPkgDependency);
procedure RemoveRequiredDependency(Dependency: TPkgDependency); procedure RemoveRequiredDependency(Dependency: TPkgDependency);
procedure MoveRequiredDependencyUp(Dependency: TPkgDependency);
procedure MoveRequiredDependencyDown(Dependency: TPkgDependency);
function CreateDependencyForThisPkg: TPkgDependency; function CreateDependencyForThisPkg: TPkgDependency;
function AddComponent(PkgFile: TPkgFile; const Page: string; function AddComponent(PkgFile: TPkgFile; const Page: string;
TheComponentClass: TComponentClass): TPkgComponent; TheComponentClass: TComponentClass): TPkgComponent;
@ -461,6 +484,7 @@ type
property ReadOnly: boolean read FReadOnly write SetReadOnly; property ReadOnly: boolean read FReadOnly write SetReadOnly;
property RemovedFilesCount: integer read GetRemovedCount; property RemovedFilesCount: integer read GetRemovedCount;
property RemovedFiles[Index: integer]: TPkgFile read GetRemovedFiles; property RemovedFiles[Index: integer]: TPkgFile read GetRemovedFiles;
property Macros: TTransferMacroList read FMacros;
property UsageOptions: TPkgAdditionalCompilerOptions property UsageOptions: TPkgAdditionalCompilerOptions
read FUsageOptions; read FUsageOptions;
end; end;
@ -1108,6 +1132,42 @@ begin
PrevDependency[ListType]:=nil; PrevDependency[ListType]:=nil;
end; end;
procedure TPkgDependency.MoveUpInList(var FirstDependency: TPkgDependency;
ListType: TPkgDependencyList);
var
OldPrev: TPkgDependency;
begin
if (FirstDependency=Self) or (PrevDependency[ListType]=nil) then exit;
OldPrev:=PrevDependency[ListType];
if OldPrev.PrevDependency[ListType]<>nil then
OldPrev.PrevDependency[ListType].NextDependency[ListType]:=Self;
if NextDependency[ListType]<>nil then
NextDependency[ListType].PrevDependency[ListType]:=OldPrev;
OldPrev.NextDependency[ListType]:=NextDependency[ListType];
PrevDependency[ListType]:=OldPrev.PrevDependency[ListType];
NextDependency[ListType]:=OldPrev;
OldPrev.PrevDependency[ListType]:=Self;
if FirstDependency=OldPrev then FirstDependency:=Self;
end;
procedure TPkgDependency.MoveDownInList(var FirstDependency: TPkgDependency;
ListType: TPkgDependencyList);
var
OldNext: TPkgDependency;
begin
if (NextDependency[ListType]=nil) then exit;
OldNext:=NextDependency[ListType];
if OldNext.NextDependency[ListType]<>nil then
OldNext.NextDependency[ListType].PrevDependency[ListType]:=Self;
if PrevDependency[ListType]<>nil then
PrevDependency[ListType].NextDependency[ListType]:=OldNext;
OldNext.PrevDependency[ListType]:=PrevDependency[ListType];
NextDependency[ListType]:=OldNext.NextDependency[ListType];
PrevDependency[ListType]:=OldNext;
OldNext.NextDependency[ListType]:=Self;
if FirstDependency=Self then FirstDependency:=OldNext;
end;
{ TPkgVersion } { TPkgVersion }
procedure TPkgVersion.Clear; procedure TPkgVersion.Clear;
@ -1215,6 +1275,25 @@ end;
{ TLazPackage } { TLazPackage }
procedure TLazPackage.OnMacroListSubstitution(TheMacro: TTransferMacro;
var s: string; var Handled, Abort: boolean);
begin
if AnsiCompareText(s,'PkgOutDir')=0 then begin
Handled:=true;
s:=CompilerOptions.UnitOutputDirectory;
end
else if AnsiCompareText(s,'PkgDir')=0 then begin
Handled:=true;
s:=FDirectory;
end;
end;
function TLazPackage.SubstitutePkgMacro(const s: string): string;
begin
Result:=s;
FMacros.SubstituteStr(Result);
end;
function TLazPackage.GetAutoIncrementVersionOnBuild: boolean; function TLazPackage.GetAutoIncrementVersionOnBuild: boolean;
begin begin
Result:=lpfAutoIncrementVersionOnBuild in FFlags; Result:=lpfAutoIncrementVersionOnBuild in FFlags;
@ -1324,6 +1403,8 @@ begin
FDirectory:=FFilename FDirectory:=FFilename
else else
FDirectory:=ExtractFilePath(FFilename); FDirectory:=ExtractFilePath(FFilename);
FUsageOptions.BaseDirectory:=FDirectory;
FCompilerOptions.BaseDirectory:=FDirectory;
Modified:=true; Modified:=true;
end; end;
@ -1399,19 +1480,26 @@ begin
FComponents:=TList.Create; FComponents:=TList.Create;
FFiles:=TList.Create; FFiles:=TList.Create;
FRemovedFiles:=TList.Create; FRemovedFiles:=TList.Create;
FMacros:=TTransferMacroList.Create;
FMacros.MarkUnhandledMacros:=false;
FMacros.OnSubstitution:=@OnMacroListSubstitution;
FCompilerOptions:=TPkgCompilerOptions.Create(Self); FCompilerOptions:=TPkgCompilerOptions.Create(Self);
FCompilerOptions.ParsedOpts.OnLocalSubstitute:=@SubstitutePkgMacro;
FUsageOptions:=TPkgAdditionalCompilerOptions.Create(Self); FUsageOptions:=TPkgAdditionalCompilerOptions.Create(Self);
FUsageOptions.ParsedOpts.OnLocalSubstitute:=@SubstitutePkgMacro;
Clear; Clear;
end; end;
destructor TLazPackage.Destroy; destructor TLazPackage.Destroy;
begin begin
Include(FFlags,lpfDestroying);
Clear; Clear;
FreeAndNil(FRemovedFiles); FreeAndNil(FRemovedFiles);
FreeAndNil(FFiles); FreeAndNil(FFiles);
FreeAndNil(FComponents); FreeAndNil(FComponents);
FreeAndNil(FCompilerOptions); FreeAndNil(FCompilerOptions);
FreeAndNil(FUsageOptions); FreeAndNil(FUsageOptions);
FreeAndNil(FMacros);
inherited Destroy; inherited Destroy;
end; end;
@ -1437,7 +1525,6 @@ begin
for i:=FComponents.Count-1 downto 0 do Components[i].Free; for i:=FComponents.Count-1 downto 0 do Components[i].Free;
FComponents.Clear; FComponents.Clear;
FCompilerOptions.Clear; FCompilerOptions.Clear;
fCompilerOptions.UnitOutputDirectory:='lib'+PathDelim;
FDescription:=''; FDescription:='';
FDirectory:=''; FDirectory:='';
FVersion.Clear; FVersion.Clear;
@ -1446,13 +1533,20 @@ begin
FRemovedFiles.Clear; FRemovedFiles.Clear;
for i:=FFiles.Count-1 downto 0 do Files[i].Free; for i:=FFiles.Count-1 downto 0 do Files[i].Free;
FFiles.Clear; FFiles.Clear;
FFlags:=[lpfAutoIncrementVersionOnBuild,lpfAutoUpdate];
FIconFile:=''; FIconFile:='';
FInstalled:=pitNope; FInstalled:=pitNope;
FName:=''; FName:='';
FPackageType:=lptRunAndDesignTime; FPackageType:=lptRunAndDesignTime;
FRegistered:=false; FRegistered:=false;
FUsageOptions.Clear; FUsageOptions.Clear;
// set some nice start values
if not (lpfDestroying in FFlags) then begin
FFlags:=[lpfAutoIncrementVersionOnBuild,lpfAutoUpdate];
fCompilerOptions.UnitOutputDirectory:='lib'+PathDelim;
FUsageOptions.UnitPath:='$(PkgOutDir)';
end else begin
FFlags:=[lpfDestroying];
end;
end; end;
procedure TLazPackage.LockModified; procedure TLazPackage.LockModified;
@ -1856,6 +1950,16 @@ begin
Modified:=true; Modified:=true;
end; end;
procedure TLazPackage.MoveRequiredDependencyUp(Dependency: TPkgDependency);
begin
Dependency.MoveUpInList(FFirstRequiredDependency,pdlRequires);
end;
procedure TLazPackage.MoveRequiredDependencyDown(Dependency: TPkgDependency);
begin
Dependency.MoveDownInList(FFirstRequiredDependency,pdlRequires);
end;
function TLazPackage.CreateDependencyForThisPkg: TPkgDependency; function TLazPackage.CreateDependencyForThisPkg: TPkgDependency;
begin begin
Result:=TPkgDependency.Create; Result:=TPkgDependency.Create;
@ -2089,6 +2193,42 @@ begin
if Modified and (LazPackage<>nil) then LazPackage.Modified:=true; if Modified and (LazPackage<>nil) then LazPackage.Modified:=true;
end; end;
procedure TPkgCompilerOptions.SetCustomOptions(const AValue: string);
begin
if CustomOptions<>AValue then InvalidateOptions;
inherited SetCustomOptions(AValue);
end;
procedure TPkgCompilerOptions.SetIncludeFiles(const AValue: string);
begin
if IncludeFiles<>AValue then InvalidateOptions;
inherited SetIncludeFiles(AValue);
end;
procedure TPkgCompilerOptions.SetLibraries(const AValue: string);
begin
if Libraries<>AValue then InvalidateOptions;
inherited SetLibraries(AValue);
end;
procedure TPkgCompilerOptions.SetLinkerOptions(const AValue: string);
begin
if LinkerOptions<>AValue then InvalidateOptions;
inherited SetLinkerOptions(AValue);
end;
procedure TPkgCompilerOptions.SetObjectPath(const AValue: string);
begin
if ObjectPath<>AValue then InvalidateOptions;
inherited SetObjectPath(AValue);
end;
procedure TPkgCompilerOptions.SetOtherUnitFiles(const AValue: string);
begin
if OtherUnitFiles<>AValue then InvalidateOptions;
inherited SetOtherUnitFiles(AValue);
end;
constructor TPkgCompilerOptions.Create(ThePackage: TLazPackage); constructor TPkgCompilerOptions.Create(ThePackage: TLazPackage);
begin begin
inherited Create(ThePackage); inherited Create(ThePackage);
@ -2111,6 +2251,11 @@ begin
Result:=LazPackage.IDAsString; Result:=LazPackage.IDAsString;
end; end;
procedure TPkgCompilerOptions.InvalidateOptions;
begin
LazPackage.UsageOptions.ParsedOpts.InvalidateAll;
end;
{ TPkgAdditionalCompilerOptions } { TPkgAdditionalCompilerOptions }
procedure TPkgAdditionalCompilerOptions.SetLazPackage(const AValue: TLazPackage procedure TPkgAdditionalCompilerOptions.SetLazPackage(const AValue: TLazPackage
@ -2120,6 +2265,48 @@ begin
FLazPackage:=AValue; FLazPackage:=AValue;
end; end;
procedure TPkgAdditionalCompilerOptions.SetCustomOptions(const AValue: string);
begin
if AValue=CustomOptions then exit;
inherited SetCustomOptions(AValue);
LazPackage.Modified:=true;
end;
procedure TPkgAdditionalCompilerOptions.SetIncludePath(const AValue: string);
begin
if AValue=IncludePath then exit;
inherited SetIncludePath(AValue);
LazPackage.Modified:=true;
end;
procedure TPkgAdditionalCompilerOptions.SetLibraryPath(const AValue: string);
begin
if AValue=LibraryPath then exit;
inherited SetLibraryPath(AValue);
LazPackage.Modified:=true;
end;
procedure TPkgAdditionalCompilerOptions.SetLinkerOptions(const AValue: string);
begin
if AValue=LinkerOptions then exit;
inherited SetLinkerOptions(AValue);
LazPackage.Modified:=true;
end;
procedure TPkgAdditionalCompilerOptions.SetObjectPath(const AValue: string);
begin
if AValue=ObjectPath then exit;
inherited SetObjectPath(AValue);
LazPackage.Modified:=true;
end;
procedure TPkgAdditionalCompilerOptions.SetUnitPath(const AValue: string);
begin
if AValue=UnitPath then exit;
inherited SetUnitPath(AValue);
LazPackage.Modified:=true;
end;
constructor TPkgAdditionalCompilerOptions.Create(ThePackage: TLazPackage); constructor TPkgAdditionalCompilerOptions.Create(ThePackage: TLazPackage);
begin begin
inherited Create(ThePackage); inherited Create(ThePackage);
@ -2131,11 +2318,6 @@ begin
Result:=LazPackage.IDAsString; Result:=LazPackage.IDAsString;
end; end;
function TPkgAdditionalCompilerOptions.GetBaseDirectory: string;
begin
Result:=LazPackage.Directory;
end;
initialization initialization
PackageDependencies:=TAVLTree.Create(@ComparePkgDependencyNames); PackageDependencies:=TAVLTree.Create(@ComparePkgDependencyNames);

View File

@ -99,6 +99,8 @@ type
procedure InstallBitBtnClick(Sender: TObject); procedure InstallBitBtnClick(Sender: TObject);
procedure MaxVersionEditChange(Sender: TObject); procedure MaxVersionEditChange(Sender: TObject);
procedure MinVersionEditChange(Sender: TObject); procedure MinVersionEditChange(Sender: TObject);
procedure MoveDependencyUpClick(Sender: TObject);
procedure MoveDependencyDownClick(Sender: TObject);
procedure OpenFileMenuItemClick(Sender: TObject); procedure OpenFileMenuItemClick(Sender: TObject);
procedure OptionsBitBtnClick(Sender: TObject); procedure OptionsBitBtnClick(Sender: TObject);
procedure PackageEditorFormClose(Sender: TObject; var Action: TCloseAction); procedure PackageEditorFormClose(Sender: TObject; var Action: TCloseAction);
@ -282,6 +284,8 @@ procedure TPackageEditorForm.FilesPopupMenuPopup(Sender: TObject);
var var
CurNode: TTreeNode; CurNode: TTreeNode;
ItemCnt: Integer; ItemCnt: Integer;
CurDependency: TPkgDependency;
Removed: boolean;
procedure AddPopupMenuItem(const ACaption: string; AnEvent: TNotifyEvent; procedure AddPopupMenuItem(const ACaption: string; AnEvent: TNotifyEvent;
EnabledFlag: boolean); EnabledFlag: boolean);
@ -302,14 +306,19 @@ var
begin begin
CurNode:=FilesTreeView.Selected; CurNode:=FilesTreeView.Selected;
ItemCnt:=0; ItemCnt:=0;
CurDependency:=GetCurrentDependency(Removed);
if CurNode<>nil then begin if CurNode<>nil then begin
if CurNode.Parent<>nil then begin if CurNode.Parent<>nil then begin
if CurNode.Parent=FilesNode then begin if CurNode.Parent=FilesNode then begin
AddPopupMenuItem('Open file',@OpenFileMenuItemClick,true); AddPopupMenuItem('Open file',@OpenFileMenuItemClick,true);
AddPopupMenuItem('Remove file',@RemoveBitBtnClick,true); AddPopupMenuItem('Remove file',@RemoveBitBtnClick,true);
end else if (CurNode.Parent=RequiredPackagesNode) then begin end else if (CurDependency<>nil) and (not Removed) then begin
AddPopupMenuItem('Open package',@OpenFileMenuItemClick,true); AddPopupMenuItem('Open package',@OpenFileMenuItemClick,true);
AddPopupMenuItem('Remove dependency',@RemoveBitBtnClick,true); AddPopupMenuItem('Remove dependency',@RemoveBitBtnClick,true);
AddPopupMenuItem('Move dependency up',@MoveDependencyUpClick,
CurDependency.PrevRequiresDependency<>nil);
AddPopupMenuItem('Move dependency down',@MoveDependencyDownClick,
CurDependency.NextRequiresDependency<>nil);
end else if (CurNode.Parent=RemovedFilesNode) then begin end else if (CurNode.Parent=RemovedFilesNode) then begin
AddPopupMenuItem('Open file',@OpenFileMenuItemClick,true); AddPopupMenuItem('Open file',@OpenFileMenuItemClick,true);
AddPopupMenuItem('Add file',@ReAddMenuItemClick,true); AddPopupMenuItem('Add file',@ReAddMenuItemClick,true);
@ -363,6 +372,26 @@ begin
UpdateApplyDependencyButton; UpdateApplyDependencyButton;
end; end;
procedure TPackageEditorForm.MoveDependencyUpClick(Sender: TObject);
var
CurDependency: TPkgDependency;
Removed: boolean;
begin
CurDependency:=GetCurrentDependency(Removed);
if (CurDependency=nil) or Removed then exit;
PackageGraph.MoveRequiredDependencyUp(CurDependency);
end;
procedure TPackageEditorForm.MoveDependencyDownClick(Sender: TObject);
var
CurDependency: TPkgDependency;
Removed: boolean;
begin
CurDependency:=GetCurrentDependency(Removed);
if (CurDependency=nil) or Removed then exit;
PackageGraph.MoveRequiredDependencyDown(CurDependency);
end;
procedure TPackageEditorForm.OpenFileMenuItemClick(Sender: TObject); procedure TPackageEditorForm.OpenFileMenuItemClick(Sender: TObject);
var var
CurNode: TTreeNode; CurNode: TTreeNode;
@ -393,6 +422,9 @@ end;
procedure TPackageEditorForm.OptionsBitBtnClick(Sender: TObject); procedure TPackageEditorForm.OptionsBitBtnClick(Sender: TObject);
begin begin
ShowPackageOptionsDlg(LazPackage); ShowPackageOptionsDlg(LazPackage);
UpdateButtons;
UpdateTitle;
UpdateStatusBar;
end; end;
procedure TPackageEditorForm.PackageEditorFormClose(Sender: TObject; procedure TPackageEditorForm.PackageEditorFormClose(Sender: TObject;
@ -705,7 +737,7 @@ begin
with CompilerOptsDlg do begin with CompilerOptsDlg do begin
GetCompilerOptions; GetCompilerOptions;
Caption:='Compiler Options for Package '+LazPackage.IDAsString; Caption:='Compiler Options for Package '+LazPackage.IDAsString;
ReadOnly:=true; ReadOnly:=LazPackage.ReadOnly;
ShowModal; ShowModal;
Free; Free;
end; end;

View File

@ -158,6 +158,8 @@ type
procedure ChangeDependency(Dependency, NewDependency: TPkgDependency); procedure ChangeDependency(Dependency, NewDependency: TPkgDependency);
function OpenDependency(Dependency: TPkgDependency; function OpenDependency(Dependency: TPkgDependency;
var APackage: TLazPackage): TLoadPackageResult; var APackage: TLazPackage): TLoadPackageResult;
procedure MoveRequiredDependencyUp(ADependency: TPkgDependency);
procedure MoveRequiredDependencyDown(ADependency: TPkgDependency);
procedure IterateComponentClasses(APackage: TLazPackage; procedure IterateComponentClasses(APackage: TLazPackage;
Event: TIterateComponentClassesEvent; Event: TIterateComponentClassesEvent;
WithUsedPackages, WithRequiredPackages: boolean); WithUsedPackages, WithRequiredPackages: boolean);
@ -754,10 +756,12 @@ begin
Author:='FPC team'; Author:='FPC team';
AutoInstall:=pitStatic; AutoInstall:=pitStatic;
AutoUpdate:=false; AutoUpdate:=false;
Description:='The FCL - FreePascal Component Library provides the base classes for object pascal.'; Description:='The FCL - FreePascal Component Library '
+'provides the base classes for object pascal.';
PackageType:=lptDesignTime; PackageType:=lptDesignTime;
Installed:=pitStatic; Installed:=pitStatic;
CompilerOptions.UnitOutputDirectory:=''; CompilerOptions.UnitOutputDirectory:='';
UsageOptions.UnitPath:='';
// add files // add files
AddFile('inc/process.pp','Process',pftUnit,[pffHasRegisterProc],cpBase); AddFile('inc/process.pp','Process',pftUnit,[pffHasRegisterProc],cpBase);
@ -778,7 +782,8 @@ begin
Author:='Lazarus'; Author:='Lazarus';
AutoInstall:=pitStatic; AutoInstall:=pitStatic;
AutoUpdate:=false; AutoUpdate:=false;
Description:='The LCL - Lazarus Component Library contains all base components for form editing.'; Description:='The LCL - Lazarus Component Library '
+'contains all base components for form editing.';
PackageType:=lptDesignTime; PackageType:=lptDesignTime;
Installed:=pitStatic; Installed:=pitStatic;
CompilerOptions.UnitOutputDirectory:=''; CompilerOptions.UnitOutputDirectory:='';
@ -1133,6 +1138,30 @@ begin
Result:=Dependency.LoadPackageResult; Result:=Dependency.LoadPackageResult;
end; end;
procedure TLazPackageGraph.MoveRequiredDependencyUp(
ADependency: TPkgDependency);
begin
if (ADependency=nil) or (ADependency.Removed) or (ADependency.Owner=nil)
or (ADependency.PrevRequiresDependency=nil)
or (not (ADependency.Owner is TLazPackage))
then exit;
BeginUpdate(true);
TLazPackage(ADependency.Owner).MoveRequiredDependencyUp(ADependency);
EndUpdate;
end;
procedure TLazPackageGraph.MoveRequiredDependencyDown(
ADependency: TPkgDependency);
begin
if (ADependency=nil) or (ADependency.Removed) or (ADependency.Owner=nil)
or (ADependency.NextRequiresDependency=nil)
or (not (ADependency.Owner is TLazPackage))
then exit;
BeginUpdate(true);
TLazPackage(ADependency.Owner).MoveRequiredDependencyDown(ADependency);
EndUpdate;
end;
procedure TLazPackageGraph.IterateComponentClasses(APackage: TLazPackage; procedure TLazPackageGraph.IterateComponentClasses(APackage: TLazPackage;
Event: TIterateComponentClassesEvent; WithUsedPackages, Event: TIterateComponentClassesEvent; WithUsedPackages,
WithRequiredPackages: boolean); WithRequiredPackages: boolean);
@ -1228,6 +1257,9 @@ var
RequiredPackage.Flags:=RequiredPackage.Flags+[lpfVisited]; RequiredPackage.Flags:=RequiredPackage.Flags+[lpfVisited];
PkgStack[StackPtr]:=RequiredPackage; PkgStack[StackPtr]:=RequiredPackage;
inc(StackPtr); inc(StackPtr);
// add package to list
if List=nil then List:=TList.Create;
List.Add(RequiredPackage);
end; end;
end; end;
CurDependency:=CurDependency.NextRequiresDependency; CurDependency:=CurDependency.NextRequiresDependency;
@ -1247,9 +1279,6 @@ begin
// get required package from stack // get required package from stack
dec(StackPtr); dec(StackPtr);
Pkg:=PkgStack[StackPtr]; Pkg:=PkgStack[StackPtr];
// add package to list
if List=nil then List:=TList.Create;
List.Add(Pkg);
// put all required packages on stack // put all required packages on stack
PutPackagesFromDependencyListOnStack(Pkg.FirstRequiredDependency); PutPackagesFromDependencyListOnStack(Pkg.FirstRequiredDependency);
end; end;

View File

@ -49,7 +49,7 @@ uses
LazarusIDEStrConsts, KeyMapping, EnvironmentOpts, IDEProcs, ProjectDefs, LazarusIDEStrConsts, KeyMapping, EnvironmentOpts, IDEProcs, ProjectDefs,
InputHistory, IDEDefs, UComponentManMain, Project, ComponentReg, InputHistory, IDEDefs, UComponentManMain, Project, ComponentReg,
PackageEditor, AddToPackageDlg, PackageDefs, PackageLinks, PackageSystem, PackageEditor, AddToPackageDlg, PackageDefs, PackageLinks, PackageSystem,
OpenInstalledPkgDlg, PkgGraphExplorer, BrokenDependenciesDlg, OpenInstalledPkgDlg, PkgGraphExplorer, BrokenDependenciesDlg, CompilerOptions,
BasePkgManager, MainBar; BasePkgManager, MainBar;
type type
@ -284,6 +284,7 @@ end;
procedure TPkgManager.PkgManagerEndUpdate(Sender: TObject; GraphChanged: boolean); procedure TPkgManager.PkgManagerEndUpdate(Sender: TObject; GraphChanged: boolean);
begin begin
if GraphChanged then IncreaseCompilerGraphStamp;
if PackageGraphExplorer<>nil then begin if PackageGraphExplorer<>nil then begin
if GraphChanged then PackageGraphExplorer.UpdateAll; if GraphChanged then PackageGraphExplorer.UpdateAll;
PackageGraphExplorer.EndUpdate; PackageGraphExplorer.EndUpdate;

View File

@ -164,11 +164,7 @@ begin
AnEdit:=GetEditForPathButton(AButton); AnEdit:=GetEditForPathButton(AButton);
OldPath:=AnEdit.Text; OldPath:=AnEdit.Text;
if AButton=UnitPathButton then begin if AButton=UnitPathButton then begin
Templates:= Templates:='$(PkgOutDir)';
'$(LazarusDir)/lcl/units'
+';$(LazarusDir)/lcl/units/$(LCLWidgetType)'
+';$(LazarusDir)/components/units'
+';$(LazarusDir)/components/custom';
end; end;
if AButton=IncludePathButton then begin if AButton=IncludePathButton then begin
Templates:='include'; Templates:='include';
@ -386,6 +382,8 @@ begin
LinkerOptions:=LinkerOptionsMemo.Text; LinkerOptions:=LinkerOptionsMemo.Text;
CustomOptions:=CustomOptionsMemo.Text; CustomOptions:=CustomOptionsMemo.Text;
end; end;
ModalResult:=mrOk;
end; end;
procedure TPackageOptionsDialog.PackageOptionsDialogClose(Sender: TObject; procedure TPackageOptionsDialog.PackageOptionsDialogClose(Sender: TObject;