compiler options: added option to show options : relatvie/absolute, .compiled files now create relative paths

git-svn-id: trunk@9349 -
This commit is contained in:
mattias 2006-05-24 16:52:12 +00:00
parent 62232c909b
commit eadacf707a
7 changed files with 150 additions and 84 deletions

View File

@ -3312,9 +3312,9 @@ var
InstallerDir: TDefineTemplate;
IFTempl: TDefineTemplate;
begin
{ $IFDEF VerboseFPCSrcScan}
{$IFDEF VerboseFPCSrcScan}
DebugLn('CreateFPCSrcTemplate ',FPCSrcDir,': length(UnitSearchPath)=',DbgS(length(UnitSearchPath)),' Valid=',DbgS(UnitLinkListValid),' PPUExt=',PPUExt);
{ $ENDIF}
{$ENDIF}
Result:=nil;
if (FPCSrcDir='') or (not DirPathExists(FPCSrcDir)) then exit;
DS:=PathDelim;

View File

@ -198,7 +198,8 @@ type
TCompilerCmdLineOption = (
ccloNoLinkerOpts, // exclude linker options
ccloAddVerboseAll, // add -va
ccloDoNotAppendOutFileOption // do not add -o option
ccloDoNotAppendOutFileOption, // do not add -o option
cclAbsolutePaths
);
TCompilerCmdLineOptions = set of TCompilerCmdLineOption;
@ -314,6 +315,8 @@ type
Parsed: TCompilerOptionsParseType = coptParsed): string;
function GetUnitOutPath(RelativeToBaseDir: boolean;
Parsed: TCompilerOptionsParseType = coptParsed): string;
function GetObjectPath(RelativeToBaseDir: boolean;
Parsed: TCompilerOptionsParseType = coptParsed): string;
function GetPath(Option: TParsedCompilerOptString;
InheritedOption: TInheritedCompilerOption;
RelativeToBaseDir: boolean;
@ -1446,6 +1449,12 @@ begin
CreateAbsoluteSearchPath(Result,BaseDirectory);
end;
function TBaseCompilerOptions.GetObjectPath(RelativeToBaseDir: boolean;
Parsed: TCompilerOptionsParseType): string;
begin
Result:=GetPath(pcosObjectPath,icoObjectPath,RelativeToBaseDir,Parsed);
end;
function TBaseCompilerOptions.GetPath(Option: TParsedCompilerOptString;
InheritedOption: TInheritedCompilerOption; RelativeToBaseDir: boolean;
Parsed: TCompilerOptionsParseType): string;
@ -1476,11 +1485,13 @@ begin
debugln('TBaseCompilerOptions.GetParsedPath GetParsedValue ',dbgsName(Self),' RelativeToBaseDir=',dbgs(RelativeToBaseDir),' CurrentPath="',CurrentPath,'"');
{$ENDIF}
if (not RelativeToBaseDir) then
CreateAbsoluteSearchPath(CurrentPath,BaseDirectory);
if RelativeToBaseDir then
CurrentPath:=CreateRelativeSearchPath(CurrentPath,BaseDirectory)
else
CurrentPath:=CreateAbsoluteSearchPath(CurrentPath,BaseDirectory);
{$IFDEF VerbosePkgUnitPath}
if Option=pcosUnitPath then
debugln('TBaseCompilerOptions.GetParsedPath CreateAbsoluteSearchPath ',dbgsName(Self),' CurrentPath="',CurrentPath,'"');
debugln('TBaseCompilerOptions.GetParsedPath Absolute/Relative=',dbgs(RelativeToBaseDir),' SearchPath ',dbgsName(Self),' CurrentPath="',CurrentPath,'" BaseDirectory="',BaseDirectory,'"');
{$ENDIF}
// inherited path
@ -1641,7 +1652,6 @@ var
CurUnitPath: String;
CurOutputDir: String;
CurLinkerOptions: String;
InhObjectPath: String;
CurObjectPath: String;
CurMainSrcFile: String;
CurCustomOptions: String;
@ -2075,42 +2085,38 @@ Processor specific options:
{ ------------- Search Paths ---------------- }
// include path
CurIncludePath:=GetIncludePath(true);
CurIncludePath:=GetIncludePath(not (cclAbsolutePaths in Flags));
if (CurIncludePath <> '') then
switches := switches + ' ' + ConvertSearchPathToCmdLine('-Fi', CurIncludePath);
// library path
if (not (ccloNoLinkerOpts in Flags)) then begin
CurLibraryPath:=GetLibraryPath(true);
CurLibraryPath:=GetLibraryPath(not (cclAbsolutePaths in Flags));
if (CurLibraryPath <> '') then
switches := switches + ' ' + ConvertSearchPathToCmdLine('-Fl', CurLibraryPath);
end;
// object path
CurObjectPath:=ParsedOpts.GetParsedValue(pcosObjectPath);
CurObjectPath:=GetObjectPath(not (cclAbsolutePaths in Flags));
if (CurObjectPath <> '') then
switches := switches + ' ' + ConvertSearchPathToCmdLine('-Fo', CurObjectPath);
// inherited object path
InhObjectPath:=GetInheritedOption(icoObjectPath,true,coptParsed);
if (InhObjectPath <> '') then
switches := switches + ' ' + ConvertSearchPathToCmdLine('-Fo', InhObjectPath);
// unit path
CurUnitPath:=GetUnitPath(true);
CurUnitPath:=GetUnitPath(not (cclAbsolutePaths in Flags));
//debugln('TBaseCompilerOptions.MakeOptionsString A ',dbgsName(Self),' CurUnitPath="',CurUnitPath,'"');
// always add the current directory to the unit path, so that the compiler
// checks for changed files in the directory
CurUnitPath:=CurUnitPath+';.';
CurUnitPath:=MergeSearchPaths(CurUnitPath,'.');
switches := switches + ' ' + ConvertSearchPathToCmdLine('-Fu', CurUnitPath);
{ CompilerPath - Nothing needs to be done with this one }
{ Unit output directory }
if UnitOutputDirectory<>'' then
CurOutputDir:=CreateRelativePath(ParsedOpts.GetParsedValue(pcosOutputDir),
BaseDirectory)
else
if UnitOutputDirectory<>'' then begin
CurOutputDir:=ParsedOpts.GetParsedValue(pcosOutputDir);
if not (cclAbsolutePaths in Flags) then
CurOutputDir:=CreateRelativePath(CurOutputDir,BaseDirectory);
end else
CurOutputDir:='';
if CurOutputDir<>'' then
switches := switches + ' '+PrepareCmdLineOption('-FU'+CurOutputDir);
@ -2169,7 +2175,11 @@ Processor specific options:
if (NewTargetFilename<>'')
and ((CompareFileNames(NewTargetFilename,ChangeFileExt(CurMainSrcFile,''))<>0)
or (CurOutputDir<>'')) then
begin
if not (cclAbsolutePaths in Flags) then
NewTargetFilename:=CreateRelativePath(NewTargetFilename,BaseDirectory);
switches := switches + ' '+PrepareCmdLineOption('-o' + NewTargetFilename);
end;
end;
// custom options

View File

@ -468,15 +468,10 @@ end;
this function and its button when the function is working correctly.
------------------------------------------------------------------------------}
procedure TfrmCompilerOptions.ButtonShowOptionsClicked(Sender: TObject);
var
CurOptions: String;
begin
// Test MakeOptionsString function
PutCompilerOptions(true);
CurOptions := CompilerOpts.MakeOptionsString(nil,
CompilerOpts.DefaultMakeOptionsFlags);
//DebugLn('CompilerOpts.MakeOptionsString: ' + CurOptions);
ShowCompilerOptionsDialog(CurOptions);
ShowCompilerOptionsDialog(CompilerOpts);
end;
procedure TfrmCompilerOptions.ExecuteAfterGroupBoxResize(Sender: TObject);

View File

@ -3028,6 +3028,7 @@ resourcestring
lisDebugOptionsFrmResumeUnhandled = 'Resume Unhandled';
lisHFMHelpForFreePascalCompilerMessage = 'Help for FreePascal Compiler '
+'message';
lisRelativePaths = 'Relative paths';
implementation
end.

View File

@ -1,44 +1,57 @@
object ShowCompilerOptionsDlg: TShowCompilerOptionsDlg
CAPTION = 'Compiler Options'
CLIENTHEIGHT = 203
CLIENTWIDTH = 393
HORZSCROLLBAR.PAGE = 394
VERTSCROLLBAR.PAGE = 204
LEFT = 358
HEIGHT = 203
TOP = 337
WIDTH = 393
object OkButton: TBUTTON
ANCHORS = [akbottom]
CAPTION = 'Ok'
TABSTOP = True
TABORDER = 0
ONCLICK = OkButtonCLICK
LEFT = 159
HEIGHT = 25
TOP = 168
WIDTH = 75
ActiveControl = OkButton
Caption = 'Compiler Options'
ClientHeight = 194
ClientWidth = 390
OnCreate = FormCreate
PixelsPerInch = 112
HorzScrollBar.Page = 389
VertScrollBar.Page = 193
Left = 358
Height = 194
Top = 337
Width = 390
object OkButton: TButton
Anchors = [akBottom]
BorderSpacing.InnerBorder = 4
Caption = 'Ok'
OnClick = OkButtonCLICK
TabOrder = 0
Left = 157
Height = 25
Top = 159
Width = 75
end
object CmdLineGroupbox: TGROUPBOX
ALIGN = altop
ANCHORS = [aktop, akleft, akbottom]
CAPTION = 'Command line parameters'
CLIENTHEIGHT = 144
CLIENTWIDTH = 389
PARENTCTL3D = False
TABORDER = 1
HEIGHT = 161
WIDTH = 393
object CmdLineMemo: TMEMO
ALIGN = alclient
LINES.Strings = (
object CmdLineGroupbox: TGroupBox
Align = alTop
Anchors = [akTop, akLeft, akBottom]
Caption = 'Command line parameters'
ClientHeight = 135
ClientWidth = 386
ParentCtl3D = False
TabOrder = 1
Height = 152
Width = 390
object CmdLineMemo: TMemo
Align = alClient
Lines.Strings = (
'CmdLineMemo'
)
TABSTOP = True
TABSTOP = True
TABORDER = 0
HEIGHT = 144
WIDTH = 389
TabOrder = 0
Height = 135
Width = 386
end
end
object RelativePathsCheckBox: TCheckBox
Anchors = [akLeft, akBottom]
Caption = 'RelativePathsCheckBox'
Checked = True
OnChange = RelativePathsCheckBoxChange
State = cbChecked
TabOrder = 2
Left = 11
Height = 20
Top = 164
Width = 160
end
end

View File

@ -1,14 +1,21 @@
{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TShowCompilerOptionsDlg','FORMDATA',[
'TPF0'#23'TShowCompilerOptionsDlg'#22'ShowCompilerOptionsDlg'#7'CAPTION'#6#16
+'Compiler Options'#12'CLIENTHEIGHT'#3#203#0#11'CLIENTWIDTH'#3#137#1#18'HORZS'
+'CROLLBAR.PAGE'#3#138#1#18'VERTSCROLLBAR.PAGE'#3#204#0#4'LEFT'#3'f'#1#6'HEIG'
+'HT'#3#203#0#3'TOP'#3'Q'#1#5'WIDTH'#3#137#1#0#7'TBUTTON'#8'OkButton'#7'ANCHO'
+'RS'#11#8'akbottom'#0#7'CAPTION'#6#2'Ok'#7'TABSTOP'#9#8'TABORDER'#2#0#7'ONCL'
+'ICK'#7#13'OkButtonCLICK'#4'LEFT'#3#159#0#6'HEIGHT'#2#25#3'TOP'#3#168#0#5'WI'
+'DTH'#2'K'#0#0#9'TGROUPBOX'#15'CmdLineGroupbox'#5'ALIGN'#7#5'altop'#7'ANCHOR'
+'S'#11#5'aktop'#6'akleft'#8'akbottom'#0#7'CAPTION'#6#23'Command line paramet'
+'ers'#12'CLIENTHEIGHT'#3#144#0#11'CLIENTWIDTH'#3#133#1#11'PARENTCTL3D'#8#8'T'
+'ABORDER'#2#1#6'HEIGHT'#3#161#0#5'WIDTH'#3#137#1#0#5'TMEMO'#11'CmdLineMemo'#5
+'ALIGN'#7#8'alclient'#13'LINES.Strings'#1#6#11'CmdLineMemo'#0#7'TABSTOP'#9#7
+'TABSTOP'#9#8'TABORDER'#2#0#6'HEIGHT'#3#144#0#5'WIDTH'#3#133#1#0#0#0#0
'TPF0'#23'TShowCompilerOptionsDlg'#22'ShowCompilerOptionsDlg'#13'ActiveContro'
+'l'#7#8'OkButton'#7'Caption'#6#16'Compiler Options'#12'ClientHeight'#3#194#0
+#11'ClientWidth'#3#134#1#8'OnCreate'#7#10'FormCreate'#13'PixelsPerInch'#2'p'
+#18'HorzScrollBar.Page'#3#133#1#18'VertScrollBar.Page'#3#193#0#4'Left'#3'f'#1
+#6'Height'#3#194#0#3'Top'#3'Q'#1#5'Width'#3#134#1#0#7'TButton'#8'OkButton'#7
+'Anchors'#11#8'akBottom'#0#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#2
+'Ok'#7'OnClick'#7#13'OkButtonCLICK'#8'TabOrder'#2#0#4'Left'#3#157#0#6'Height'
+#2#25#3'Top'#3#159#0#5'Width'#2'K'#0#0#9'TGroupBox'#15'CmdLineGroupbox'#5'Al'
+'ign'#7#5'alTop'#7'Anchors'#11#5'akTop'#6'akLeft'#8'akBottom'#0#7'Caption'#6
+#23'Command line parameters'#12'ClientHeight'#3#135#0#11'ClientWidth'#3#130#1
+#11'ParentCtl3D'#8#8'TabOrder'#2#1#6'Height'#3#152#0#5'Width'#3#134#1#0#5'TM'
+'emo'#11'CmdLineMemo'#5'Align'#7#8'alClient'#13'Lines.Strings'#1#6#11'CmdLin'
+'eMemo'#0#8'TabOrder'#2#0#6'Height'#3#135#0#5'Width'#3#130#1#0#0#0#9'TCheckB'
+'ox'#21'RelativePathsCheckBox'#7'Anchors'#11#6'akLeft'#8'akBottom'#0#7'Capti'
+'on'#6#21'RelativePathsCheckBox'#7'Checked'#9#8'OnChange'#7#27'RelativePaths'
+'CheckBoxChange'#5'State'#7#9'cbChecked'#8'TabOrder'#2#2#4'Left'#2#11#6'Heig'
+'ht'#2#20#3'Top'#3#164#0#5'Width'#3#160#0#0#0#0
]);

View File

@ -36,33 +36,43 @@ interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Buttons,
StdCtrls;
StdCtrls, LazarusIDEStrConsts, CompilerOptions;
type
{ TShowCompilerOptionsDlg }
TShowCompilerOptionsDlg = class(TForm)
RelativePathsCheckBox: TCheckBox;
OkButton: TBUTTON;
CmdLineGroupbox: TGROUPBOX;
CmdLineMemo: TMEMO;
procedure FormCreate(Sender: TObject);
procedure OkButtonCLICK(Sender: TObject);
procedure RelativePathsCheckBoxChange(Sender: TObject);
private
FCompilerOpts: TBaseCompilerOptions;
procedure SetCompilerOpts(const AValue: TBaseCompilerOptions);
procedure UpdateMemo;
public
property CompilerOpts: TBaseCompilerOptions read FCompilerOpts write SetCompilerOpts;
end;
function ShowCompilerOptionsDialog(const CmdLine: string): TModalResult;
function ShowCompilerOptionsDialog(
CompilerOpts: TBaseCompilerOptions): TModalResult;
implementation
function ShowCompilerOptionsDialog(const CmdLine: string): TModalResult;
function ShowCompilerOptionsDialog(
CompilerOpts: TBaseCompilerOptions): TModalResult;
var
ShowCompilerOptionsDlg: TShowCompilerOptionsDlg;
begin
Result:=mrOk;
ShowCompilerOptionsDlg:=TShowCompilerOptionsDlg.Create(nil);
with ShowCompilerOptionsDlg do begin
CmdLineMemo.Lines.Text:=CmdLine;
ShowModal;
Free;
end;
ShowCompilerOptionsDlg.CompilerOpts:=CompilerOpts;
ShowCompilerOptionsDlg.ShowModal;
ShowCompilerOptionsDlg.Free;
end;
{ TShowCompilerOptionsDlg }
@ -72,6 +82,36 @@ begin
ModalResult:=mrOk;
end;
procedure TShowCompilerOptionsDlg.RelativePathsCheckBoxChange(Sender: TObject);
begin
UpdateMemo;
end;
procedure TShowCompilerOptionsDlg.FormCreate(Sender: TObject);
begin
RelativePathsCheckBox.Caption:=lisRelativePaths;
end;
procedure TShowCompilerOptionsDlg.SetCompilerOpts(
const AValue: TBaseCompilerOptions);
begin
if FCompilerOpts=AValue then exit;
FCompilerOpts:=AValue;
UpdateMemo;
end;
procedure TShowCompilerOptionsDlg.UpdateMemo;
var
Flags: TCompilerCmdLineOptions;
CurOptions: String;
begin
Flags:=CompilerOpts.DefaultMakeOptionsFlags;
if not RelativePathsCheckBox.Checked then
Include(Flags,cclAbsolutePaths);
CurOptions := CompilerOpts.MakeOptionsString(nil,Flags);
CmdLineMemo.Lines.Text:=CurOptions;
end;
initialization
{$I showcompileropts.lrs}