IDE: macros: fixed nested macros, bug #20941

git-svn-id: trunk@34348 -
This commit is contained in:
mattias 2011-12-21 12:38:16 +00:00
parent 5590db43a7
commit 0272ffb1cc
5 changed files with 33 additions and 31 deletions

View File

@ -3771,29 +3771,35 @@ begin
s:=OptionText;
// parse locally (macros depending on owner, like pkgdir and build macros)
//DebugLn(['TParsedCompilerOptions.DoParseOption local "',s,'" ...']);
if Assigned(OnLocalSubstitute) then
s:=OnLocalSubstitute(s,PlatformIndependent);
// parse globally (general macros)
//DebugLn(['TParsedCompilerOptions.DoParseOption global "',s,'" ...']);
s:=ParseString(Self,s,PlatformIndependent);
begin
//DebugLn(['TParsedCompilerOptions.DoParseOption local "',s,'" ...']);
s:=OnLocalSubstitute(s,PlatformIndependent)
end else
begin
//DebugLn(['TParsedCompilerOptions.DoParseOption global "',s,'" ...']);
s:=ParseString(Self,s,PlatformIndependent);
end;
//DebugLn(['TParsedCompilerOptions.DoParseOption complete "',s,'" ...']);
// improve
if Option=pcosBaseDir then
// base directory
s:=AppendPathDelim(TrimFilename(s))
else if Option in ParsedCompilerFilenames then begin
else if Option in ParsedCompilerFilenames then
begin
// make filename absolute
MakeFilenameAbsolute(s);
end
else if Option in ParsedCompilerDirectories then begin
else if Option in ParsedCompilerDirectories then
begin
// make directory absolute
s:=TrimFilename(s);
if Option<>pcosBaseDir then
MakeFilenameAbsolute(s);
s:=AppendPathDelim(s);
end
else if Option in ParsedCompilerSearchPaths then begin
else if Option in ParsedCompilerSearchPaths then
begin
// make search paths absolute
BaseDirectory:=GetBaseDir;
s:=TrimSearchPath(s,BaseDirectory);

View File

@ -13550,6 +13550,9 @@ var MacroLName:string;
begin
if TheMacro=nil then begin
DebugLn('WARNING: Macro not defined: "'+MacroName+'".');
{$IFDEF VerboseMacroNotDefined}
DumpStack;
{$ENDIF}
s:='';
//MessageDlg('Unknown Macro','Macro not defined: "'+s+'".',mtError,[mbAbort],0);
Handled:=true;

View File

@ -2548,7 +2548,6 @@ begin
FBookmarks := TProjectBookmarkList.Create;
FMacroEngine:=TTransferMacroList.Create;
FMacroEngine.MarkUnhandledMacros:=false;
FMacroEngine.OnSubstitution:=@OnMacroEngineSubstitution;
FBuildModes:=TProjectBuildModes.Create(nil);
FBuildModes.LazProject:=Self;
@ -5510,17 +5509,9 @@ begin
end;
// check local macros
{if CompareText(MacroName,'PkgOutDir')=0 then begin
Handled:=true;
if Data=CompilerOptionMacroNormal then
s:=CompilerOptions.ParsedOpts.GetParsedValue(pcosOutputDir)
else
s:=CompilerOptions.ParsedOpts.GetParsedPIValue(pcosOutputDir);
end
else if CompareText(MacroName,'PkgDir')=0 then begin
Handled:=true;
s:=FDirectory;
end;}
// check global macros
GlobalMacroList.ExecuteMacro(MacroName,s,Data,Handled,Abort,Depth);
end;
function TProject.SearchFile(const ShortFilename: string;
@ -5779,8 +5770,8 @@ begin
CompOpts:=TProjectCompilerOptions(Owner);
//debugln(['TProjectCompilationToolOptions.SubstituteMacros ',DbgSName(Owner),' ',CompOpts.LazProject<>nil]);
s:=CompOpts.SubstituteProjectMacros(s,false);
end;
inherited SubstituteMacros(s);
end else
inherited SubstituteMacros(s);
end;
procedure TProjectCompilationToolOptions.Clear;

View File

@ -1598,13 +1598,11 @@ begin
if fFullFilenameStamp<>CompilerParseStamp then begin
fFullFilename:=Filename;
fFullFilenameStamp:=CompilerParseStamp;
if LazPackage<>nil then begin
// substitute locally
LazPackage.SubstitutePkgMacros(fFullFilename,false);
end;
// substitute globally
IDEMacros.SubstituteMacros(fFullFilename);
fFullFilename:=CleanAndExpandFilename(fFullFilename);
if LazPackage<>nil then
LazPackage.SubstitutePkgMacros(fFullFilename,false)
else
IDEMacros.SubstituteMacros(fFullFilename);
fFullFilename:=TrimAndExpandFilename(fFullFilename);
end;
Result:=fFullFilename;
end;
@ -2135,15 +2133,21 @@ begin
s:=CompilerOptions.ParsedOpts.GetParsedValue(pcosOutputDir)
else
s:=CompilerOptions.ParsedOpts.GetParsedPIValue(pcosOutputDir);
exit;
end
else if CompareText(MacroName,'PkgDir')=0 then begin
Handled:=true;
s:=FDirectory;
exit;
end
else if CompareText(MacroName,'PkgName')=0 then begin
Handled:=true;
s:=Name;
exit;
end;
// check global macros
GlobalMacroList.ExecuteMacro(MacroName,s,Data,Handled,Abort,Depth);
end;
procedure TLazPackage.SetUserReadOnly(const AValue: boolean);
@ -2511,7 +2515,6 @@ begin
FFiles:=TFPList.Create;
FRemovedFiles:=TFPList.Create;
FMacros:=TTransferMacroList.Create;
FMacros.MarkUnhandledMacros:=false;
FMacros.OnSubstitution:=@OnMacroListSubstitution;
FCompilerOptions:=TPkgCompilerOptions.Create(Self);
FLazCompilerOptions:=FCompilerOptions;

View File

@ -4337,7 +4337,6 @@ begin
// (this way the fallback creates the same amount of target directories)
Dir:=APackage.CompilerOptions.ParsedOpts.UnparsedValues[pcosOutputDir];
Dir:=APackage.SubstitutePkgMacros(Dir,false);
GlobalMacroList.SubstituteStr(Dir);
if FilenameIsAbsolute(Dir) then begin
// it is not relative => create a default one
Dir:='$(TargetOS)-$(TargetCPU)';