implemented creating compiler option string for packages

git-svn-id: trunk@4063 -
This commit is contained in:
mattias 2003-04-16 13:48:10 +00:00
parent b1082798ec
commit 7691dfe1a7
6 changed files with 373 additions and 96 deletions

View File

@ -57,7 +57,11 @@ type
); );
TInheritedCompilerOptions = set of TInheritedCompilerOption; TInheritedCompilerOptions = set of TInheritedCompilerOption;
const
icoAllSearchPaths = [icoUnitPath,icoIncludePath,icoObjectPath,icoLibraryPath];
type
{ TParsedCompilerOptions } { TParsedCompilerOptions }
TParsedCompilerOptString = ( TParsedCompilerOptString = (
@ -84,6 +88,7 @@ type
TParsedCompilerOptions = class TParsedCompilerOptions = class
private private
FInvalidateGraphOnChange: boolean;
FOnLocalSubstitute: TLocalSubstitutionEvent; FOnLocalSubstitute: TLocalSubstitutionEvent;
public public
UnparsedValues: array[TParsedCompilerOptString] of string; UnparsedValues: array[TParsedCompilerOptString] of string;
@ -96,8 +101,11 @@ type
procedure Clear; procedure Clear;
procedure InvalidateAll; procedure InvalidateAll;
procedure InvalidateFiles; procedure InvalidateFiles;
public
property OnLocalSubstitute: TLocalSubstitutionEvent read FOnLocalSubstitute property OnLocalSubstitute: TLocalSubstitutionEvent read FOnLocalSubstitute
write FOnLocalSubstitute; write FOnLocalSubstitute;
property InvalidateGraphOnChange: boolean read FInvalidateGraphOnChange
write FInvalidateGraphOnChange;
end; end;
TParseStringEvent = TParseStringEvent =
@ -241,6 +249,7 @@ type
function GetInheritedOption(Option: TInheritedCompilerOption): string; virtual; function GetInheritedOption(Option: TInheritedCompilerOption): string; virtual;
function MergeLinkerOptions(const OldOptions, AddOptions: string): string; function MergeLinkerOptions(const OldOptions, AddOptions: string): string;
function MergeCustomOptions(const OldOptions, AddOptions: string): string; function MergeCustomOptions(const OldOptions, AddOptions: string): string;
function GetDefaultMainSourceFileName: string; virtual;
public public
{ Properties } { Properties }
property Owner: TObject read fOwner write fOwner; property Owner: TObject read fOwner write fOwner;
@ -248,9 +257,9 @@ type
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 BaseDirectory: string read FBaseDirectory write SetBaseDirectory;
property TargetFilename: String read fTargetFilename write fTargetFilename;
property XMLFile: String read fXMLFile write fXMLFile; property XMLFile: String read fXMLFile write fXMLFile;
property TargetFilename: String read fTargetFilename write fTargetFilename;
property XMLConfigFile: TXMLConfig read xmlconfig write xmlconfig; property XMLConfigFile: TXMLConfig read xmlconfig write xmlconfig;
property Loaded: Boolean read fLoaded write fLoaded; property Loaded: Boolean read fLoaded write fLoaded;
@ -530,6 +539,7 @@ type
InheritedPage: TPage; InheritedPage: TPage;
InhNoteLabel: TLabel; InhNoteLabel: TLabel;
InhTreeView: TTreeView; InhTreeView: TTreeView;
InhItemMemo: TMemo;
{ Buttons } { Buttons }
btnTest: TButton; btnTest: TButton;
@ -542,7 +552,8 @@ type
procedure ButtonCancelClicked(Sender: TObject); procedure ButtonCancelClicked(Sender: TObject);
procedure ButtonApplyClicked(Sender: TObject); procedure ButtonApplyClicked(Sender: TObject);
procedure ButtonTestClicked(Sender: TObject); procedure ButtonTestClicked(Sender: TObject);
procedure InhTreeViewSelectionChanged(Sender: TObject);
procedure InheritedPageResize(Sender: TObject);
procedure chkAdditionalConfigFileClick(Sender: TObject); procedure chkAdditionalConfigFileClick(Sender: TObject);
procedure PathEditBtnClick(Sender: TObject); procedure PathEditBtnClick(Sender: TObject);
procedure PathEditBtnExecuted(Sender: TObject); procedure PathEditBtnExecuted(Sender: TObject);
@ -562,10 +573,13 @@ type
FReadOnly: boolean; FReadOnly: boolean;
ImageIndexPackage: integer; ImageIndexPackage: integer;
ImageIndexRequired: integer; ImageIndexRequired: integer;
ImageIndexInherited: integer;
InheritedChildDatas: TList; // list of PInheritedNodeData
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);
procedure UpdateInheritedTab; procedure UpdateInheritedTab;
procedure ClearInheritedTree;
public public
CompilerOpts: TBaseCompilerOptions; CompilerOpts: TBaseCompilerOptions;
@ -599,6 +613,13 @@ const
MaxParseStamp = $7fffffff; MaxParseStamp = $7fffffff;
MinParseStamp = -$7fffffff; MinParseStamp = -$7fffffff;
InvalidParseStamp = MinParseStamp-1; InvalidParseStamp = MinParseStamp-1;
type
TInheritedNodeData = record
FullText: string;
Option: TInheritedCompilerOption;
end;
PInheritedNodeData = ^TInheritedNodeData;
procedure IncreaseCompilerParseStamp; procedure IncreaseCompilerParseStamp;
begin begin
@ -1062,29 +1083,31 @@ begin
for i:=0 to OptionsList.Count-1 do begin for i:=0 to OptionsList.Count-1 do begin
AddOptions:=TAdditionalCompilerOptions(OptionsList[i]); AddOptions:=TAdditionalCompilerOptions(OptionsList[i]);
if (not (AddOptions is TAdditionalCompilerOptions)) then continue; if (not (AddOptions is TAdditionalCompilerOptions)) then continue;
// unit search path // unit search path
fInheritedOptions[icoUnitPath]:= fInheritedOptions[icoUnitPath]:=
MergeSearchPaths(fInheritedOptions[icoUnitPath],AddOptions.UnitPath); MergeSearchPaths(fInheritedOptions[icoUnitPath],
AddOptions.ParsedOpts.GetParsedValue(pcosUnitPath));
// include search path // include search path
fInheritedOptions[icoIncludePath]:= fInheritedOptions[icoIncludePath]:=
MergeSearchPaths(fInheritedOptions[icoIncludePath], MergeSearchPaths(fInheritedOptions[icoIncludePath],
AddOptions.IncludePath); AddOptions.ParsedOpts.GetParsedValue(pcosIncludePath));
// object search path // object search path
fInheritedOptions[icoObjectPath]:= fInheritedOptions[icoObjectPath]:=
MergeSearchPaths(fInheritedOptions[icoObjectPath], MergeSearchPaths(fInheritedOptions[icoObjectPath],
AddOptions.ObjectPath); AddOptions.ParsedOpts.GetParsedValue(pcosObjectPath));
// library search path // library search path
fInheritedOptions[icoLibraryPath]:= fInheritedOptions[icoLibraryPath]:=
MergeSearchPaths(fInheritedOptions[icoLibraryPath], MergeSearchPaths(fInheritedOptions[icoLibraryPath],
AddOptions.LibraryPath); AddOptions.ParsedOpts.GetParsedValue(pcosLibraryPath));
// linker options // linker options
fInheritedOptions[icoLinkerOptions]:= fInheritedOptions[icoLinkerOptions]:=
MergeLinkerOptions(fInheritedOptions[icoLinkerOptions], MergeLinkerOptions(fInheritedOptions[icoLinkerOptions],
AddOptions.LinkerOptions); AddOptions.ParsedOpts.GetParsedValue(pcosLinkerOptions));
// custom options // custom options
fInheritedOptions[icoCustomOptions]:= fInheritedOptions[icoCustomOptions]:=
MergeCustomOptions(fInheritedOptions[icoCustomOptions], MergeCustomOptions(fInheritedOptions[icoCustomOptions],
AddOptions.CustomOptions); AddOptions.ParsedOpts.GetParsedValue(pcosCustomOptions));
end; end;
end; end;
fInheritedOptParseStamps:=CompilerParseStamp; fInheritedOptParseStamps:=CompilerParseStamp;
@ -1102,7 +1125,7 @@ function TBaseCompilerOptions.MergeLinkerOptions(const OldOptions,
begin begin
Result:=OldOptions; Result:=OldOptions;
if AddOptions='' then exit; if AddOptions='' then exit;
if (OldOptions[length(OldOptions)]<>' ') if (OldOptions<>'') and (OldOptions[length(OldOptions)]<>' ')
and (AddOptions[1]<>' ') then and (AddOptions[1]<>' ') then
Result:=Result+' '+AddOptions Result:=Result+' '+AddOptions
else else
@ -1118,19 +1141,24 @@ function TBaseCompilerOptions.MergeCustomOptions(const OldOptions,
begin begin
Result:=OldOptions; Result:=OldOptions;
if AddOptions='' then exit; if AddOptions='' then exit;
if (OldOptions[length(OldOptions)]<>' ') if (OldOptions<>'') and (OldOptions[length(OldOptions)]<>' ')
and (AddOptions[1]<>' ') then and (AddOptions[1]<>' ') then
Result:=Result+' '+AddOptions Result:=Result+' '+AddOptions
else else
Result:=Result+AddOptions; Result:=Result+AddOptions;
end; end;
function TBaseCompilerOptions.GetDefaultMainSourceFileName: string;
begin
Result:='';
end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
TBaseCompilerOptions MakeOptionsString TBaseCompilerOptions MakeOptionsString
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TBaseCompilerOptions.MakeOptionsString: String; function TBaseCompilerOptions.MakeOptionsString: String;
begin begin
Result:=MakeOptionsString('') Result:=MakeOptionsString(GetDefaultMainSourceFileName)
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -1141,7 +1169,27 @@ function TBaseCompilerOptions.MakeOptionsString(
const MainSourceFilename: string): String; const MainSourceFilename: string): String;
var var
switches, tempsw: String; switches, tempsw: String;
InhLinkerOpts: String;
InhIncludePath: String;
InhLibraryPath: String;
InhUnitPath: String;
InhCustomOptions: String;
NewTargetFilename: String;
CurIncludePath: String;
CurLibraryPath: String;
CurUnitPath: String;
CurOutputDir: String;
CurCustomOptions: String;
CurLinkerOptions: String;
InhObjectPath: String;
CurObjectPath: String;
CurMainSrcFile: String;
begin begin
if MainSourceFileName='' then
CurMainSrcFile:=GetDefaultMainSourceFileName
else
CurMainSrcFile:=MainSourceFileName;
switches := ''; switches := '';
{ Get all the options and create a string that can be passed to the compiler } { Get all the options and create a string that can be passed to the compiler }
@ -1437,7 +1485,7 @@ Processor specific options:
... } ... }
{ Only linux and win32 are in the dialog at this moment} { Only linux and win32 are in the dialog at this moment}
if TargetOS<>'' then if TargetOS<>'' then
switches := switches + ' -T' + TargetOS; switches := switches + ' -T' + TargetOS;
{ --------------- Linking Tab ------------------- } { --------------- Linking Tab ------------------- }
{ Debugging } { Debugging }
@ -1476,9 +1524,17 @@ Processor specific options:
3: switches := switches + ' -XX'; 3: switches := switches + ' -XX';
end; end;
// additional Linker options
if PassLinkerOptions then begin
CurLinkerOptions:=ParsedOpts.GetParsedValue(pcosLinkerOptions);
if (CurLinkerOptions<>'') then
switches := switches + ' ' + ParseOptions(' ','-k', CurLinkerOptions);
end;
if PassLinkerOptions and (LinkerOptions<>'') then // inherited Linker options
switches := switches + ' ' + ParseOptions(' ','-k', LinkerOptions); InhLinkerOpts:=GetInheritedOption(icoLinkerOptions);
if InhLinkerOpts<>'' then
switches := switches + ' ' + ParseOptions(' ','-k', InhLinkerOpts);
{ ---------------- Other Tab -------------------- } { ---------------- Other Tab -------------------- }
@ -1540,21 +1596,59 @@ Processor specific options:
if (AdditionalConfigFile) and (ConfigFilePath<>'') then if (AdditionalConfigFile) and (ConfigFilePath<>'') then
switches := switches + ' ' + PrepareCmdLineOption('@' + ConfigFilePath); switches := switches + ' ' + PrepareCmdLineOption('@' + ConfigFilePath);
{ ------------- Search Paths Tab ---------------- }
if (IncludeFiles <> '') then
switches := switches + ' ' + ParseSearchPaths('-Fi', IncludeFiles);
if (Libraries <> '') then { ------------- Search Paths ---------------- }
switches := switches + ' ' + ParseSearchPaths('-Fl', Libraries);
// include path
CurIncludePath:=ParsedOpts.GetParsedValue(pcosIncludePath);
if (CurIncludePath <> '') then
switches := switches + ' ' + ParseSearchPaths('-Fi', CurIncludePath);
// inherited include path
InhIncludePath:=GetInheritedOption(icoIncludePath);
if (InhIncludePath <> '') then
switches := switches + ' ' + ParseSearchPaths('-Fi', InhIncludePath);
// library path
CurLibraryPath:=ParsedOpts.GetParsedValue(pcosLibraryPath);
if (CurLibraryPath <> '') then
switches := switches + ' ' + ParseSearchPaths('-Fl', CurLibraryPath);
// inherited library path
InhLibraryPath:=GetInheritedOption(icoLibraryPath);
if (InhLibraryPath <> '') then
switches := switches + ' ' + ParseSearchPaths('-Fl', InhLibraryPath);
// object path
CurObjectPath:=ParsedOpts.GetParsedValue(pcosObjectPath);
if (CurObjectPath <> '') then
switches := switches + ' ' + ParseSearchPaths('-Fo', CurObjectPath);
// inherited object path
InhObjectPath:=GetInheritedOption(icoObjectPath);
if (InhObjectPath <> '') then
switches := switches + ' ' + ParseSearchPaths('-Fo', InhObjectPath);
// unit path
CurUnitPath:=ParsedOpts.GetParsedValue(pcosUnitPath);
if (CurUnitPath <> '') then
switches := switches + ' ' + ParseSearchPaths('-Fu', CurUnitPath);
// inherited unit path
InhUnitPath:=GetInheritedOption(icoUnitPath);
if (InhUnitPath <> '') then
switches := switches + ' ' + ParseSearchPaths('-Fu', InhUnitPath);
if (OtherUnitFiles <> '') then
switches := switches + ' ' + ParseSearchPaths('-Fu', OtherUnitFiles);
{ CompilerPath - Nothing needs to be done with this one } { CompilerPath - Nothing needs to be done with this one }
{ Unit output directory } { Unit output directory }
if UnitOutputDirectory<>'' then if UnitOutputDirectory<>'' then
switches := switches + ' '+PrepareCmdLineOption('-FU'+UnitOutputDirectory); CurOutputDir:=ParsedOpts.GetParsedValue(pcosOutputDir)
else
CurOutputDir:='';
if CurOutputDir<>'' then
switches := switches + ' '+PrepareCmdLineOption('-FU'+CurOutputDir);
{ TODO: Implement the following switches. They need to be added { TODO: Implement the following switches. They need to be added
to the dialog. } to the dialog. }
@ -1602,17 +1696,25 @@ Processor specific options:
-Xc = Link with C library (LINUX only) -Xc = Link with C library (LINUX only)
} }
if (TargetFilename<>'') or (MainSourceFilename<>'') if (TargetFilename<>'') or (CurMainSrcFile<>'') or (CurOutputDir<>'') then
or (UnitOutputDirectory<>'') then begin begin
tempsw:=CreateTargetFilename(MainSourceFilename); NewTargetFilename:=CreateTargetFilename(CurMainSrcFile);
if (tempsw <> ChangeFileExt(MainSourceFilename,'')) if (NewTargetFilename<>'')
or (UnitOutputDirectory<>'') then and ((CompareFileNames(NewTargetFilename,ChangeFileExt(CurMainSrcFile,''))<>0)
switches := switches + ' '+PrepareCmdLineOption('-o' + tempsw); or (CurOutputDir<>'')) then
switches := switches + ' '+PrepareCmdLineOption('-o' + NewTargetFilename);
end; end;
tempsw:=CustomOptionsAsString; // custom options
if tempsw<>'' then CurCustomOptions:=ParsedOpts.GetParsedValue(pcosCustomOptions);
Switches:=Switches+' '+tempsw; if CurCustomOptions<>'' then
Switches:=Switches+' '+CurCustomOptions;
// inherited custom options
InhCustomOptions:=GetInheritedOption(icoCustomOptions);
if InhCustomOptions<>'' then
Switches:=Switches+' '+InhCustomOptions;
fOptionsString := switches; fOptionsString := switches;
Result := fOptionsString; Result := fOptionsString;
@ -1998,6 +2100,8 @@ begin
AddResImg('pkg_package'); AddResImg('pkg_package');
ImageIndexRequired:=Count; ImageIndexRequired:=Count;
AddResImg('pkg_required'); AddResImg('pkg_required');
ImageIndexInherited:=Count;
AddResImg('pkg_inherited');
end; end;
nbMain := TNotebook.Create(Self); nbMain := TNotebook.Create(Self);
@ -2062,6 +2166,7 @@ end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
destructor TfrmCompilerOptions.Destroy; destructor TfrmCompilerOptions.Destroy;
begin begin
ClearInheritedTree;
inherited Destroy; inherited Destroy;
end; end;
@ -2095,8 +2200,6 @@ end;
procedure TfrmCompilerOptions.ButtonApplyClicked(Sender: TObject); procedure TfrmCompilerOptions.ButtonApplyClicked(Sender: TObject);
begin begin
// Apply any changes // Apply any changes
Assert(False, 'Trace:Apply compiler options changes');
PutCompilerOptions; PutCompilerOptions;
end; end;
@ -2130,9 +2233,44 @@ begin
[mbOk],0); [mbOk],0);
end; end;
{------------------------------------------------------------------------------} procedure TfrmCompilerOptions.InhTreeViewSelectionChanged(Sender: TObject);
{ TfrmCompilerOptions GetCompilerOptions } var
{------------------------------------------------------------------------------} ANode: TTreeNode;
ChildData: PInheritedNodeData;
sl: TStringList;
begin
ANode:=InhTreeView.Selected;
if (ANode=nil) or (ANode.Data=nil) then begin
InhItemMemo.Lines.Text:='Select a node';
end else begin
ChildData:=PInheritedNodeData(ANode.Data);
if ChildData^.Option in icoAllSearchPaths then begin
sl:=SplitString(ChildData^.FullText,';');
InhItemMemo.Lines.Assign(sl);
sl.Free;
end else
InhItemMemo.Lines.Text:=ChildData^.FullText;
end;
end;
{------------------------------------------------------------------------------
procedure TfrmCompilerOptions.InheritedPageResize(Sender: TObject);
------------------------------------------------------------------------------}
procedure TfrmCompilerOptions.InheritedPageResize(Sender: TObject);
var
y: Integer;
begin
InhNoteLabel.SetBounds(3,3,InheritedPage.ClientWidth-6,20);
InhTreeView.SetBounds(0,25,
InheritedPage.ClientWidth,InheritedPage.ClientHeight-100);
y:=InhTreeView.Top+InhTreeView.Height;
InhItemMemo.SetBounds(0,y,
InheritedPage.ClientWidth,InheritedPage.ClientHeight-y);
end;
{------------------------------------------------------------------------------
TfrmCompilerOptions GetCompilerOptions
------------------------------------------------------------------------------}
procedure TfrmCompilerOptions.GetCompilerOptions; procedure TfrmCompilerOptions.GetCompilerOptions;
var i: integer; var i: integer;
begin begin
@ -2397,18 +2535,26 @@ var
AncestorOptions: TAdditionalCompilerOptions; AncestorOptions: TAdditionalCompilerOptions;
AncestorNode: TTreeNode; AncestorNode: TTreeNode;
procedure AddChildNode(const NewNodeName, Value: string); procedure AddChildNode(const NewNodeName, Value: string;
Option: TInheritedCompilerOption);
var var
VisibleValue: String; VisibleValue: String;
ChildNode: TTreeNode; ChildNode: TTreeNode;
ChildData: PInheritedNodeData;
begin begin
if Value='' then exit; if Value='' then exit;
New(ChildData);
ChildData^.FullText:=Value;
ChildData^.Option:=Option;
if InheritedChildDatas=nil then InheritedChildDatas:=TList.Create;
InheritedChildDatas.Add(ChildData);
if length(Value)>100 then if length(Value)>100 then
VisibleValue:=copy(Value,1,100)+'[...]' VisibleValue:=copy(Value,1,100)+'[...]'
else else
VisibleValue:=Value; VisibleValue:=Value;
ChildNode:=InhTreeView.Items.AddChild(AncestorNode, ChildNode:=InhTreeView.Items.AddChildObject(AncestorNode,
NewNodeName+' = "'+VisibleValue+'"'); NewNodeName+' = "'+VisibleValue+'"',ChildData);
ChildNode.ImageIndex:=ImageIndexRequired; ChildNode.ImageIndex:=ImageIndexRequired;
ChildNode.SelectedIndex:=ChildNode.ImageIndex; ChildNode.SelectedIndex:=ChildNode.ImageIndex;
end; end;
@ -2416,12 +2562,32 @@ var
begin begin
CompilerOpts.GetInheritedCompilerOptions(OptionsList); CompilerOpts.GetInheritedCompilerOptions(OptionsList);
InhTreeView.BeginUpdate; InhTreeView.BeginUpdate;
InhTreeView.Items.Clear; ClearInheritedTree;
// add All node
// ToDo
if OptionsList<>nil then begin if OptionsList<>nil then begin
// add All node
AncestorNode:=InhTreeView.Items.Add(nil,'All inherited options');
AncestorNode.ImageIndex:=ImageIndexInherited;
AncestorNode.SelectedIndex:=AncestorNode.ImageIndex;
with CompilerOpts do begin
AddChildNode('unit path',
CreateRelativeSearchPath(GetInheritedOption(icoUnitPath),
BaseDirectory),icoUnitPath);
AddChildNode('include path',
CreateRelativeSearchPath(GetInheritedOption(icoIncludePath),
BaseDirectory),icoIncludePath);
AddChildNode('object path',
CreateRelativeSearchPath(GetInheritedOption(icoObjectPath),
BaseDirectory),icoObjectPath);
AddChildNode('library path',
CreateRelativeSearchPath(GetInheritedOption(icoLibraryPath),
BaseDirectory),icoLibraryPath);
AddChildNode('linker options',GetInheritedOption(icoLinkerOptions),
icoLinkerOptions);
AddChildNode('custom options',GetInheritedOption(icoCustomOptions),
icoCustomOptions);
end;
AncestorNode.Expanded:=true;
// add detail nodes
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,'');
@ -2429,12 +2595,22 @@ begin
AncestorNode.ImageIndex:=ImageIndexPackage; AncestorNode.ImageIndex:=ImageIndexPackage;
AncestorNode.SelectedIndex:=AncestorNode.ImageIndex; AncestorNode.SelectedIndex:=AncestorNode.ImageIndex;
with AncestorOptions.ParsedOpts do begin with AncestorOptions.ParsedOpts do begin
AddChildNode('unit path',GetParsedValue(pcosUnitPath)); AddChildNode('unit path',
AddChildNode('include path',GetParsedValue(pcosIncludePath)); CreateRelativeSearchPath(GetParsedValue(pcosUnitPath),
AddChildNode('object path',GetParsedValue(pcosObjectPath)); CompilerOpts.BaseDirectory),icoUnitPath);
AddChildNode('library path',GetParsedValue(pcosLibraryPath)); AddChildNode('include path',
AddChildNode('linker options',GetParsedValue(pcosLinkerOptions)); CreateRelativeSearchPath(GetParsedValue(pcosIncludePath),
AddChildNode('custom options',GetParsedValue(pcosCustomOptions)); CompilerOpts.BaseDirectory),icoIncludePath);
AddChildNode('object path',
CreateRelativeSearchPath(GetParsedValue(pcosObjectPath),
CompilerOpts.BaseDirectory),icoObjectPath);
AddChildNode('library path',
CreateRelativeSearchPath(GetParsedValue(pcosLibraryPath),
CompilerOpts.BaseDirectory),icoLibraryPath);
AddChildNode('linker options',GetParsedValue(pcosLinkerOptions),
icoLinkerOptions);
AddChildNode('custom options',GetParsedValue(pcosCustomOptions),
icoCustomOptions);
end; end;
AncestorNode.Expanded:=true; AncestorNode.Expanded:=true;
end; end;
@ -2444,6 +2620,24 @@ begin
InhTreeView.EndUpdate; InhTreeView.EndUpdate;
end; end;
procedure TfrmCompilerOptions.ClearInheritedTree;
var
i: Integer;
ChildData: PInheritedNodeData;
begin
InhTreeView.BeginUpdate;
// dispose all child data
if InheritedChildDatas<>nil then begin
for i:=0 to InheritedChildDatas.Count-1 do begin
ChildData:=PInheritedNodeData(InheritedChildDatas[i]);
Dispose(ChildData);
end;
InheritedChildDatas.Free;
end;
InhTreeView.Items.Clear;
InhTreeView.EndUpdate;
end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
TfrmCompilerOptions SetupParsingTab TfrmCompilerOptions SetupParsingTab
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
@ -3404,6 +3598,7 @@ end;
procedure TfrmCompilerOptions.SetupInheritedTab(Page: integer); procedure TfrmCompilerOptions.SetupInheritedTab(Page: integer);
begin begin
InheritedPage:=nbMain.Page[Page]; InheritedPage:=nbMain.Page[Page];
InheritedPage.OnResize:=@InheritedPageResize;
InhNoteLabel:=TLabel.Create(Self); InhNoteLabel:=TLabel.Create(Self);
with InhNoteLabel do begin with InhNoteLabel do begin
@ -3419,7 +3614,17 @@ begin
Options:=Options+[tvoReadOnly, tvoRightClickSelect, tvoShowRoot, Options:=Options+[tvoReadOnly, tvoRightClickSelect, tvoShowRoot,
tvoKeepCollapsedNodes]; tvoKeepCollapsedNodes];
Images:=ImageList; Images:=ImageList;
Align:=alClient; OnSelectionChanged:=@InhTreeViewSelectionChanged;
end;
InhItemMemo:=TMemo.Create(Self);
with InhItemMemo do begin
Name:='InhItemMemo';
Parent:=InheritedPage;
ReadOnly:=true;
WordWrap:=true;
ScrollBars:=ssAutoVertical;
Text:='Select a node';
end; end;
end; end;
@ -3935,7 +4140,14 @@ var
s: String; s: String;
begin begin
if ParsedStamp[Option]<>CompilerParseStamp then begin if ParsedStamp[Option]<>CompilerParseStamp then begin
s:=ParseString(Self,UnparsedValues[Option]); // parse locally
if Assigned(OnLocalSubstitute) then
s:=OnLocalSubstitute(UnparsedValues[Option])
else
s:=UnparsedValues[Option];
// parse globally
s:=ParseString(Self,s);
// improve
if Option=pcosBaseDir then if Option=pcosBaseDir then
// base directory (append path) // base directory (append path)
s:=AppendPathDelim(TrimFilename(s)) s:=AppendPathDelim(TrimFilename(s))
@ -3959,22 +4171,14 @@ end;
procedure TParsedCompilerOptions.SetUnparsedValue( procedure TParsedCompilerOptions.SetUnparsedValue(
Option: TParsedCompilerOptString; const NewValue: string); Option: TParsedCompilerOptString; const NewValue: string);
var
PreParsedValue: String;
begin begin
if Assigned(OnLocalSubstitute) then begin if NewValue=UnparsedValues[Option] then exit;
PreParsedValue:=OnLocalSubstitute(NewValue); if InvalidateGraphOnChange then IncreaseCompilerGraphStamp;
end else begin
PreParsedValue:=NewValue;
end;
if PreParsedValue=UnparsedValues[Option] then exit;
IncreaseCompilerGraphStamp;
if Option=pcosBaseDir then if Option=pcosBaseDir then
InvalidateFiles InvalidateFiles
else else
ParsedStamp[Option]:=InvalidParseStamp; ParsedStamp[Option]:=InvalidParseStamp;
UnparsedValues[Option]:=PreParsedValue; UnparsedValues[Option]:=NewValue;
end; end;
procedure TParsedCompilerOptions.Clear; procedure TParsedCompilerOptions.Clear;

View File

@ -128,27 +128,27 @@ type
constructor Create(ACodeBuffer: TCodeBuffer); constructor Create(ACodeBuffer: TCodeBuffer);
destructor Destroy; override; destructor Destroy; override;
function ChangedOnDisk(CompareOnlyLoadSaveTime: boolean): boolean;
function IsAutoRevertLocked: boolean;
function IsMainUnit: boolean;
function IsVirtual: boolean;
function NeedsSaveToDisk: boolean;
function ReadOnly: boolean;
function ReadUnitSource(ReadUnitName:boolean): TModalResult; function ReadUnitSource(ReadUnitName:boolean): TModalResult;
procedure ReadUnitNameFromSource; function ShortFilename: string;
function WriteUnitSource: TModalResult; function WriteUnitSource: TModalResult;
function WriteUnitSourceToFile(const AFileName: string): TModalResult; function WriteUnitSourceToFile(const AFileName: string): TModalResult;
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);
procedure Clear; procedure Clear;
procedure CreateStartCode(NewUnitType: TNewUnitType; procedure CreateStartCode(NewUnitType: TNewUnitType;
const NewUnitName: string); const NewUnitName: string);
function IsVirtual: boolean;
function IsMainUnit: boolean;
procedure IncreaseAutoRevertLock;
procedure DecreaseAutoRevertLock; procedure DecreaseAutoRevertLock;
function IsAutoRevertLocked: boolean;
function ChangedOnDisk(CompareOnlyLoadSaveTime: boolean): boolean;
procedure IgnoreCurrentFileDateOnDisk; procedure IgnoreCurrentFileDateOnDisk;
function ShortFilename: string; procedure IncreaseAutoRevertLock;
function NeedsSaveToDisk: boolean; procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);
procedure ReadUnitNameFromSource;
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);
procedure UpdateUsageCount(Min, IfBelowThis, IncIfBelow: extended); procedure UpdateUsageCount(Min, IfBelowThis, IncIfBelow: extended);
procedure UpdateUsageCount(TheUsage: TUnitUsage; Factor: extended); procedure UpdateUsageCount(TheUsage: TUnitUsage; Factor: extended);
function ReadOnly: boolean;
{ Properties } { Properties }
public public
@ -209,6 +209,7 @@ type
public public
constructor Create(TheProject: TProject); constructor Create(TheProject: TProject);
function GetOwnerName: string; override; function GetOwnerName: string; override;
function GetDefaultMainSourceFileName: string; override;
public public
property OwnerProject: TProject read FOwnerProject; property OwnerProject: TProject read FOwnerProject;
end; end;
@ -334,6 +335,7 @@ type
procedure Clear; procedure Clear;
function SomethingModified: boolean; function SomethingModified: boolean;
procedure MainSourceFilenameChanged;
// Application.CreateForm statements // Application.CreateForm statements
function AddCreateFormToProjectFile(const AClassName, AName:string):boolean; function AddCreateFormToProjectFile(const AClassName, AName:string):boolean;
@ -870,6 +872,8 @@ begin
if IsAutoRevertLocked then if IsAutoRevertLocked then
fSource.LockAutoDiskRevert; fSource.LockAutoDiskRevert;
fFileName:=fSource.FileName; fFileName:=fSource.FileName;
if (fProject<>nil) and (fProject.MainUnitInfo=Self) then
fProject.MainSourceFilenameChanged;
end; end;
end; end;
@ -2089,6 +2093,11 @@ begin
Result:=Result or CompilerOptions.Modified; Result:=Result or CompilerOptions.Modified;
end; end;
procedure TProject.MainSourceFilenameChanged;
begin
end;
Function TProject.UnitWithForm(AForm : TComponent) : TUnitInfo; Function TProject.UnitWithForm(AForm : TComponent) : TUnitInfo;
begin begin
Result:=fFirstUnitWithForm; Result:=fFirstUnitWithForm;
@ -2330,12 +2339,26 @@ begin
if Result='' then Result:=ExtractFilename(OwnerProject.ProjectInfoFile); if Result='' then Result:=ExtractFilename(OwnerProject.ProjectInfoFile);
end; end;
function TProjectCompilerOptions.GetDefaultMainSourceFileName: string;
var
MainUnitInfo: TUnitInfo;
begin
MainUnitInfo:=FOwnerProject.MainUNitInfo;
if (MainUnitInfo<>nil) then
Result:=ExtractFileName(MainUnitInfo.Filename);
if Result='' then
Result:=inherited GetDefaultMainSourceFileName;
end;
end. end.
{ {
$Log$ $Log$
Revision 1.107 2003/04/16 13:48:10 mattias
implemented creating compiler option string for packages
Revision 1.106 2003/04/15 17:58:28 mattias Revision 1.106 2003/04/15 17:58:28 mattias
implemented inherited Compiler Options View implemented inherited Compiler Options View

View File

@ -216,9 +216,7 @@ var MacroStart,MacroEnd: integer;
else BracketClose:='}'; else BracketClose:='}';
inc(Position); inc(Position);
while (Position<=length(s)) and (s[Position]<>BracketClose) do begin while (Position<=length(s)) and (s[Position]<>BracketClose) do begin
if s[Position]='\' then if (s[Position] in ['(','{']) then
inc(Position)
else if (s[Position] in ['(','{']) then
Position:=SearchBracketClose(Position); Position:=SearchBracketClose(Position);
inc(Position); inc(Position);
end; end;
@ -231,10 +229,14 @@ begin
MacroStart:=1; MacroStart:=1;
repeat repeat
while (MacroStart<sLen) do begin while (MacroStart<sLen) do begin
if (s[MacroStart]='$') and ((MacroStart=1) or (s[MacroStart-1]<>'\')) then if (s[MacroStart]<>'$') then
break inc(MacroStart)
else else begin
inc(MacroStart); if (s[MacroStart+1]='$') then // skip $$
inc(MacroStart,2)
else
break;
end;
end; end;
if MacroStart>=sLen then break; if MacroStart>=sLen then break;
@ -330,13 +332,14 @@ begin
MacroStart:=MacroEnd; MacroStart:=MacroEnd;
until false; until false;
// convert \$ chars // convert $$ chars
MacroStart:=2; MacroStart:=2;
while (MacroStart<=length(s)) do begin while (MacroStart<sLen) do begin
if (s[MacroStart]='$') and (s[MacroStart-1]='\') then begin if (s[MacroStart]='$') and (s[MacroStart+1]='$') then begin
System.Delete(s,MacroStart-1,1); System.Delete(s,MacroStart,1);
end else dec(sLen);
inc(MacroStart); end;
inc(MacroStart);
end; end;
end; end;

View File

@ -2891,7 +2891,8 @@ begin
NewDefItemHeight:=StateImages.Height; NewDefItemHeight:=StateImages.Height;
if NewDefItemHeight<>FDefItemHeight then begin if NewDefItemHeight<>FDefItemHeight then begin
FDefItemHeight:=NewDefItemHeight; FDefItemHeight:=NewDefItemHeight;
Include(FStates,tvsTopsNeedsUpdate); FStates:=FStates+[tvsTopsNeedsUpdate,tvsTopItemNeedsUpdate,
tvsBottomItemNeedsUpdate];
Invalidate; Invalidate;
end; end;
end; end;

View File

@ -261,12 +261,15 @@ type
procedure SetLinkerOptions(const AValue: string); override; procedure SetLinkerOptions(const AValue: string); override;
procedure SetObjectPath(const AValue: string); override; procedure SetObjectPath(const AValue: string); override;
procedure SetOtherUnitFiles(const AValue: string); override; procedure SetOtherUnitFiles(const AValue: string); override;
procedure SetUnitOutputDir(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; procedure InvalidateOptions;
function GetDefaultMainSourceFileName: string; override;
function CreateTargetFilename(const MainSourceFileName: string): string; override;
public public
property LazPackage: TLazPackage read FLazPackage write SetLazPackage; property LazPackage: TLazPackage read FLazPackage write SetLazPackage;
end; end;
@ -454,6 +457,7 @@ type
procedure UpdateEditorRect; procedure UpdateEditorRect;
procedure GetAllRequiredPackages(var List: TList); procedure GetAllRequiredPackages(var List: TList);
procedure GetInheritedCompilerOptions(var OptionsList: TList); procedure GetInheritedCompilerOptions(var OptionsList: TList);
function GetCompileSourceFilenname: string;
public public
property Author: string read FAuthor write SetAuthor; property Author: string read FAuthor write SetAuthor;
property AutoCreated: boolean read FAutoCreated write SetAutoCreated; property AutoCreated: boolean read FAutoCreated write SetAutoCreated;
@ -1485,6 +1489,7 @@ begin
FMacros.OnSubstitution:=@OnMacroListSubstitution; FMacros.OnSubstitution:=@OnMacroListSubstitution;
FCompilerOptions:=TPkgCompilerOptions.Create(Self); FCompilerOptions:=TPkgCompilerOptions.Create(Self);
FCompilerOptions.ParsedOpts.OnLocalSubstitute:=@SubstitutePkgMacro; FCompilerOptions.ParsedOpts.OnLocalSubstitute:=@SubstitutePkgMacro;
FCompilerOptions.ParsedOpts.InvalidateGraphOnChange:=true;
FUsageOptions:=TPkgAdditionalCompilerOptions.Create(Self); FUsageOptions:=TPkgAdditionalCompilerOptions.Create(Self);
FUsageOptions.ParsedOpts.OnLocalSubstitute:=@SubstitutePkgMacro; FUsageOptions.ParsedOpts.OnLocalSubstitute:=@SubstitutePkgMacro;
Clear; Clear;
@ -2033,7 +2038,6 @@ begin
OptionsList:=TList.Create; OptionsList:=TList.Create;
Cnt:=PkgList.Count; Cnt:=PkgList.Count;
for i:=0 to Cnt-1 do begin for i:=0 to Cnt-1 do begin
writeln('TLazPackage.GetInheritedCompilerOptions A ');
OptionsList.Add(TLazPackage(PkgList[i]).UsageOptions); OptionsList.Add(TLazPackage(PkgList[i]).UsageOptions);
end; end;
end else begin end else begin
@ -2041,6 +2045,11 @@ writeln('TLazPackage.GetInheritedCompilerOptions A ');
end; end;
end; end;
function TLazPackage.GetCompileSourceFilenname: string;
begin
Result:=ChangeFileExt(ExtractFilename(Filename),'.pas');
end;
{ TPkgComponent } { TPkgComponent }
procedure TPkgComponent.SetPkgFile(const AValue: TPkgFile); procedure TPkgComponent.SetPkgFile(const AValue: TPkgFile);
@ -2195,40 +2204,53 @@ end;
procedure TPkgCompilerOptions.SetCustomOptions(const AValue: string); procedure TPkgCompilerOptions.SetCustomOptions(const AValue: string);
begin begin
if CustomOptions<>AValue then InvalidateOptions; if CustomOptions=AValue then exit;
InvalidateOptions;
inherited SetCustomOptions(AValue); inherited SetCustomOptions(AValue);
end; end;
procedure TPkgCompilerOptions.SetIncludeFiles(const AValue: string); procedure TPkgCompilerOptions.SetIncludeFiles(const AValue: string);
begin begin
if IncludeFiles<>AValue then InvalidateOptions; if IncludeFiles=AValue then exit;
InvalidateOptions;
inherited SetIncludeFiles(AValue); inherited SetIncludeFiles(AValue);
end; end;
procedure TPkgCompilerOptions.SetLibraries(const AValue: string); procedure TPkgCompilerOptions.SetLibraries(const AValue: string);
begin begin
if Libraries<>AValue then InvalidateOptions; if Libraries=AValue then exit;
InvalidateOptions;
inherited SetLibraries(AValue); inherited SetLibraries(AValue);
end; end;
procedure TPkgCompilerOptions.SetLinkerOptions(const AValue: string); procedure TPkgCompilerOptions.SetLinkerOptions(const AValue: string);
begin begin
if LinkerOptions<>AValue then InvalidateOptions; if LinkerOptions=AValue then exit;
InvalidateOptions;
inherited SetLinkerOptions(AValue); inherited SetLinkerOptions(AValue);
end; end;
procedure TPkgCompilerOptions.SetObjectPath(const AValue: string); procedure TPkgCompilerOptions.SetObjectPath(const AValue: string);
begin begin
if ObjectPath<>AValue then InvalidateOptions; if ObjectPath=AValue then exit;
InvalidateOptions;
inherited SetObjectPath(AValue); inherited SetObjectPath(AValue);
end; end;
procedure TPkgCompilerOptions.SetOtherUnitFiles(const AValue: string); procedure TPkgCompilerOptions.SetOtherUnitFiles(const AValue: string);
begin begin
if OtherUnitFiles<>AValue then InvalidateOptions; if OtherUnitFiles=AValue then exit;
InvalidateOptions;
inherited SetOtherUnitFiles(AValue); inherited SetOtherUnitFiles(AValue);
end; end;
procedure TPkgCompilerOptions.SetUnitOutputDir(const AValue: string);
begin
if UnitOutputDirectory=AValue then exit;
InvalidateOptions;
inherited SetUnitOutputDir(AValue);
end;
constructor TPkgCompilerOptions.Create(ThePackage: TLazPackage); constructor TPkgCompilerOptions.Create(ThePackage: TLazPackage);
begin begin
inherited Create(ThePackage); inherited Create(ThePackage);
@ -2256,6 +2278,19 @@ begin
LazPackage.UsageOptions.ParsedOpts.InvalidateAll; LazPackage.UsageOptions.ParsedOpts.InvalidateAll;
end; end;
function TPkgCompilerOptions.GetDefaultMainSourceFileName: string;
begin
Result:=LazPackage.GetCompileSourceFilenname;
if Result='' then
Result:=inherited GetDefaultMainSourceFileName;
end;
function TPkgCompilerOptions.CreateTargetFilename(
const MainSourceFileName: string): string;
begin
Result:='';
end;
{ TPkgAdditionalCompilerOptions } { TPkgAdditionalCompilerOptions }
procedure TPkgAdditionalCompilerOptions.SetLazPackage(const AValue: TLazPackage procedure TPkgAdditionalCompilerOptions.SetLazPackage(const AValue: TLazPackage

View File

@ -686,6 +686,8 @@ begin
Result:=MessageDlg('Invalid file extension', Result:=MessageDlg('Invalid file extension',
'The file "'+AFilename+'" is not a lazarus package.', 'The file "'+AFilename+'" is not a lazarus package.',
mtError,[mbCancel,mbAbort],0); mtError,[mbCancel,mbAbort],0);
RemoveFromRecentList(AFilename,EnvironmentOptions.RecentPackageFiles);
SetRecentPackagesMenu;
exit; exit;
end; end;
@ -697,9 +699,18 @@ begin
'The package file name "'+AlternativePkgName+'" in'#13 'The package file name "'+AlternativePkgName+'" in'#13
+'"'+AFilename+'" is not a valid lazarus package name.', +'"'+AFilename+'" is not a valid lazarus package name.',
mtError,[mbCancel,mbAbort],0); mtError,[mbCancel,mbAbort],0);
RemoveFromRecentList(AFilename,EnvironmentOptions.RecentPackageFiles);
SetRecentPackagesMenu;
exit; exit;
end; end;
// add to recent packages
if pofAddToRecent in Flags then begin
AddToRecentList(AFilename,EnvironmentOptions.RecentPackageFiles,
EnvironmentOptions.MaxRecentPackageFiles);
SetRecentPackagesMenu;
end;
// check if package is already loaded // check if package is already loaded
APackage:=PackageGraph.FindPackageWithFilename(AFilename,true); APackage:=PackageGraph.FindPackageWithFilename(AFilename,true);
if APackage=nil then begin if APackage=nil then begin