ide: show compiler options: append target src filename instead of inserting project main source file for consistency

This commit is contained in:
mattias 2024-07-18 10:22:10 +02:00
parent f6653b4638
commit 44b279bfd2
2 changed files with 31 additions and 12 deletions

View File

@ -154,6 +154,18 @@ type
); );
TCompilerCmdLineOptions = set of TCompilerCmdLineOption; TCompilerCmdLineOptions = set of TCompilerCmdLineOption;
const
CompilerCmdLineOptionNames: array[TCompilerCmdLineOption] of string = (
'NoLinkerOpts',
'AddVerboseAll',
'DoNotAppendOutFileOption',
'AbsolutePaths',
'NoMacroParams',
'AddCompilerPath'
);
type
{ TCompilationToolOptions } { TCompilationToolOptions }
TCompilationToolOptions = class(TLazCompilationToolOptions) TCompilationToolOptions = class(TLazCompilationToolOptions)
@ -221,7 +233,7 @@ type
function GetEnumerator: TCompilerMsgIDFlagsEnumerator; function GetEnumerator: TCompilerMsgIDFlagsEnumerator;
function GetMsgIdList(Delim: char; aValue: TCompilerFlagValue; FPCMsgFile: TFPCMsgFilePoolItem = nil): string; function GetMsgIdList(Delim: char; aValue: TCompilerFlagValue; FPCMsgFile: TFPCMsgFilePoolItem = nil): string;
function CreateDiff(Tool: TCompilerDiffTool; Other: TCompilerMsgIDFlags): boolean; function CreateDiff(Tool: TCompilerDiffTool; Other: TCompilerMsgIDFlags): boolean;
function Count: SizeInt; inline; function Count: SizeInt;
property ChangeStamp: int64 read FChangeStamp; property ChangeStamp: int64 read FChangeStamp;
end; end;
@ -428,6 +440,8 @@ procedure SaveXMLCompileReasons(const AConfig: TXMLConfig; const APath: String;
function EnumToStr(Flag: TCompilerFlagValue): string; overload; function EnumToStr(Flag: TCompilerFlagValue): string; overload;
function CompareCompMsgIdFlag(Data1, Data2: Pointer): integer; function CompareCompMsgIdFlag(Data1, Data2: Pointer): integer;
function dbgs(const Opts: TCompilerCmdLineOptions): string; overload;
var var
TestCompilerOptions: TNotifyEvent = nil; TestCompilerOptions: TNotifyEvent = nil;
@ -757,6 +771,19 @@ begin
Result:=0; Result:=0;
end; end;
function dbgs(const Opts: TCompilerCmdLineOptions): string;
var
o: TCompilerCmdLineOption;
begin
Result:='';
for o in Opts do
begin
if Result<>'' then Result+=',';
Result+=CompilerCmdLineOptionNames[o];
end;
Result:='['+Result+']';
end;
{ TCompilerMsgIDFlagsEnumerator } { TCompilerMsgIDFlagsEnumerator }
function TCompilerMsgIDFlagsEnumerator.GetCurrent: PCompilerMsgIdFlag; function TCompilerMsgIDFlagsEnumerator.GetCurrent: PCompilerMsgIdFlag;
@ -2663,7 +2690,7 @@ begin
CurMainSrcFile:=GetDefaultMainSourceFileName; CurMainSrcFile:=GetDefaultMainSourceFileName;
CurTargetFilename:=''; CurTargetFilename:='';
CurTargetDirectory:=''; CurTargetDirectory:='';
//DebugLn(['TBaseCompilerOptions.MakeOptionsString ',DbgSName(Self),' ',ccloDoNotAppendOutFileOption in Flags,' TargetFilename="',TargetFilename,'" CurMainSrcFile="',CurMainSrcFile,'" CurOutputDir="',CurOutputDir,'"']); DebugLn(['TBaseCompilerOptions.MakeOptionsString ',DbgSName(Self),' ',dbgs(Flags),' TargetFilename="',TargetFilename,'" CurMainSrcFile="',CurMainSrcFile,'" CurOutputDir="',CurOutputDir,'"']);
if (not (ccloDoNotAppendOutFileOption in Flags)) if (not (ccloDoNotAppendOutFileOption in Flags))
and (not (ccloNoMacroParams in Flags)) and (not (ccloNoMacroParams in Flags))
and ((TargetFilename<>'') or (CurMainSrcFile<>'') or (CurOutputDir<>'')) then and ((TargetFilename<>'') or (CurMainSrcFile<>'') or (CurOutputDir<>'')) then

View File

@ -295,28 +295,20 @@ end;
procedure TShowCompilerOptionsDlg.UpdateMemo; procedure TShowCompilerOptionsDlg.UpdateMemo;
var var
Flags: TCompilerCmdLineOptions; Flags: TCompilerCmdLineOptions;
CompPath: String;
CompOptions: TStringListUTF8Fast; CompOptions: TStringListUTF8Fast;
begin begin
if CompilerOpts=nil then exit; if CompilerOpts=nil then exit;
// set flags // set flags
Flags:=CompilerOpts.DefaultMakeOptionsFlags; Flags:=CompilerOpts.DefaultMakeOptionsFlags;
Include(Flags, ccloAddCompilerPath); Include(Flags,ccloAddCompilerPath);
if not RelativePathsCheckBox.Checked then if not RelativePathsCheckBox.Checked then
Include(Flags,ccloAbsolutePaths); Include(Flags,ccloAbsolutePaths);
// get command line parameters (include compiler path) // get command line parameters (include compiler path)
CompOptions := CompilerOpts.MakeCompilerParams(Flags); CompOptions := CompilerOpts.MakeCompilerParams(Flags);
try try
// add the main project unit after the compiler path CompOptions.Add(CompilerOpts.CreateTargetFilename);
if (Project1<>nil) and (Project1.MainUnitInfo<>nil) and (CompOptions.Count>0) then
begin
if RelativePathsCheckBox.Checked then
CompOptions.Insert(1, Project1.MainUnitInfo.ShortFilename)
else
CompOptions.Insert(1, Project1.MainUnitInfo.GetFullFilename);
end;
// show // show
FillMemo(CmdLineMemo,CompOptions); FillMemo(CmdLineMemo,CompOptions);