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

View File

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