codetools: fixed rebuilding nodes when targetcpu changed

git-svn-id: branches/fixes_1_4@48288 -
This commit is contained in:
mattias 2015-03-12 09:45:08 +00:00
parent f15ba59e59
commit 4d846084c4
4 changed files with 63 additions and 37 deletions

View File

@ -568,7 +568,7 @@ type
function CreateFPCTemplate(const CompilerPath, CompilerOptions, function CreateFPCTemplate(const CompilerPath, CompilerOptions,
TestPascalFile: string; TestPascalFile: string;
out UnitSearchPath, TargetOS, out UnitSearchPath, TargetOS,
TargetProcessor: string; aTargetCPU: string;
Owner: TObject): TDefineTemplate; Owner: TObject): TDefineTemplate;
function GetFPCVerFromFPCTemplate(Template: TDefineTemplate; function GetFPCVerFromFPCTemplate(Template: TDefineTemplate;
out FPCVersion, FPCRelease, FPCPatch: integer): boolean; out FPCVersion, FPCRelease, FPCPatch: integer): boolean;
@ -1994,15 +1994,15 @@ begin
ctsDefaultFPCSource2OperatingSystem, ctsDefaultFPCSource2OperatingSystem,
ExternalMacroStart+'SrcOS2',SrcOS2,da_DefineRecurse); ExternalMacroStart+'SrcOS2',SrcOS2,da_DefineRecurse);
Result.AddChild(NewDefTempl); Result.AddChild(NewDefTempl);
// define #TargetProcessor // define #TargetCPU
TargetCPU:=Config.RealTargetCPU; TargetCPU:=Config.RealTargetCPU;
if TargetCPU='' then if TargetCPU='' then
TargetCPU:=Config.TargetCPU; TargetCPU:=Config.TargetCPU;
if TargetCPU='' then if TargetCPU='' then
TargetCPU:=GetCompiledTargetCPU; TargetCPU:=GetCompiledTargetCPU;
NewDefTempl:=TDefineTemplate.Create('Define TargetProcessor', NewDefTempl:=TDefineTemplate.Create('Define TargetCPU',
ctsDefaultFPCTargetProcessor, ctsDefaultFPCTargetProcessor,
ExternalMacroStart+'TargetProcessor',TargetCPU, TargetCPUMacroName,TargetCPU,
da_DefineRecurse); da_DefineRecurse);
Result.AddChild(NewDefTempl); Result.AddChild(NewDefTempl);
@ -2043,7 +2043,7 @@ end;
function CreateFPCSourceTemplate(FPCSrcDir: string; Owner: TObject function CreateFPCSourceTemplate(FPCSrcDir: string; Owner: TObject
): TDefineTemplate; ): TDefineTemplate;
var var
Dir, SrcOS, SrcOS2, TargetProcessor, Dir, SrcOS, SrcOS2, aTargetCPU,
IncPathMacro: string; IncPathMacro: string;
DS: char; // dir separator DS: char; // dir separator
@ -2072,8 +2072,8 @@ var
IncludePathMacroName,IncPathMacro+';inc', IncludePathMacroName,IncPathMacro+';inc',
da_Define)); da_Define));
RTLSrcOSDir.AddChild(TDefineTemplate.Create('Include Path', RTLSrcOSDir.AddChild(TDefineTemplate.Create('Include Path',
'include path to TargetProcessor directories', 'include path to TargetCPU directories',
IncludePathMacroName,IncPathMacro+';'+TargetProcessor, IncludePathMacroName,IncPathMacro+';'+aTargetCPU,
da_Define)); da_Define));
ParentDefTempl.AddChild(IfTargetOSIsNotSrcOS); ParentDefTempl.AddChild(IfTargetOSIsNotSrcOS);
@ -2086,8 +2086,8 @@ var
SrcOS2,da_Directory); SrcOS2,da_Directory);
IfTargetOSIsNotSrcOS2.AddChild(RTLSrcOS2Dir); IfTargetOSIsNotSrcOS2.AddChild(RTLSrcOS2Dir);
RTLSrcOS2Dir.AddChild(TDefineTemplate.Create('Include Path', RTLSrcOS2Dir.AddChild(TDefineTemplate.Create('Include Path',
'include path to TargetProcessor directories', 'include path to TargetCPU directories',
IncludePathMacroName,IncPathMacro+';'+TargetProcessor, IncludePathMacroName,IncPathMacro+';'+aTargetCPU,
da_DefineRecurse)); da_DefineRecurse));
ParentDefTempl.AddChild(IfTargetOSIsNotSrcOS2); ParentDefTempl.AddChild(IfTargetOSIsNotSrcOS2);
end; end;
@ -2126,8 +2126,8 @@ begin
Dir:=AppendPathDelim(FPCSrcDir); Dir:=AppendPathDelim(FPCSrcDir);
SrcOS:='$('+ExternalMacroStart+'SrcOS)'; SrcOS:='$('+ExternalMacroStart+'SrcOS)';
SrcOS2:='$('+ExternalMacroStart+'SrcOS2)'; SrcOS2:='$('+ExternalMacroStart+'SrcOS2)';
TargetProcessor:='$('+ExternalMacroStart+'TargetProcessor)'; aTargetCPU:=TargetCPUMacro;
IncPathMacro:='$('+ExternalMacroStart+'IncPath)'; IncPathMacro:=IncludePathMacro;
Result:=TDefineTemplate.Create(StdDefTemplFPCSrc, Result:=TDefineTemplate.Create(StdDefTemplFPCSrc,
Format(ctsFreePascalSourcesPlusDesc,['RTL, FCL, Packages, Compiler']), Format(ctsFreePascalSourcesPlusDesc,['RTL, FCL, Packages, Compiler']),
@ -2162,12 +2162,12 @@ begin
+';'+Dir+'rtl'+DS+SrcOS+DS +';'+Dir+'rtl'+DS+SrcOS+DS
+';'+Dir+'rtl'+DS+TargetOSMacro+DS +';'+Dir+'rtl'+DS+TargetOSMacro+DS
+';'+Dir+'rtl'+DS+SrcOS2+DS +';'+Dir+'rtl'+DS+SrcOS2+DS
+';'+Dir+'rtl'+DS+SrcOS2+DS+TargetProcessor +';'+Dir+'rtl'+DS+SrcOS2+DS+aTargetCPU
+';'+Dir+'rtl'+DS+TargetProcessor+DS +';'+Dir+'rtl'+DS+aTargetCPU+DS
+';'+Dir+'rtl'+DS+TargetOSMacro+DS+TargetProcessor+DS; +';'+Dir+'rtl'+DS+TargetOSMacro+DS+aTargetCPU+DS;
RTLDir.AddChild(TDefineTemplate.Create('Include Path', RTLDir.AddChild(TDefineTemplate.Create('Include Path',
Format(ctsIncludeDirectoriesPlusDirs, Format(ctsIncludeDirectoriesPlusDirs,
['objpas, inc,'+TargetProcessor+','+SrcOS]), ['objpas, inc,'+aTargetCPU+','+SrcOS]),
IncludePathMacroName,s,da_DefineRecurse)); IncludePathMacroName,s,da_DefineRecurse));
// if solaris or darwin or beos then define FPC_USE_LIBC // if solaris or darwin or beos then define FPC_USE_LIBC
@ -2212,16 +2212,16 @@ begin
TargetOSMacro,da_Directory); TargetOSMacro,da_Directory);
s:=IncPathMacro s:=IncPathMacro
+';'+Dir+'rtl'+DS+TargetOSMacro+DS+SrcOS+'inc' // e.g. rtl/win32/inc/ +';'+Dir+'rtl'+DS+TargetOSMacro+DS+SrcOS+'inc' // e.g. rtl/win32/inc/
+';'+Dir+'rtl'+DS+TargetOSMacro+DS+TargetProcessor+DS +';'+Dir+'rtl'+DS+TargetOSMacro+DS+aTargetCPU+DS
; ;
RTLOSDir.AddChild(TDefineTemplate.Create('Include Path', RTLOSDir.AddChild(TDefineTemplate.Create('Include Path',
Format(ctsIncludeDirectoriesPlusDirs,[TargetProcessor]), Format(ctsIncludeDirectoriesPlusDirs,[aTargetCPU]),
IncludePathMacroName, IncludePathMacroName,
s,da_DefineRecurse)); s,da_DefineRecurse));
s:=SrcPathMacro s:=SrcPathMacro
+';'+Dir+'rtl'+DS+'objpas'+DS; +';'+Dir+'rtl'+DS+'objpas'+DS;
RTLOSDir.AddChild(TDefineTemplate.Create('Src Path', RTLOSDir.AddChild(TDefineTemplate.Create('Src Path',
Format(ctsAddsDirToSourcePath,[TargetProcessor]), Format(ctsAddsDirToSourcePath,[aTargetCPU]),
ExternalMacroStart+'SrcPath',s,da_DefineRecurse)); ExternalMacroStart+'SrcPath',s,da_DefineRecurse));
RTLDir.AddChild(RTLOSDir); RTLDir.AddChild(RTLOSDir);
@ -2411,7 +2411,7 @@ begin
da_Directory); da_Directory);
CompilerDir.AddChild(TDefineTemplate.Create('SrcPath','SrcPath addition', CompilerDir.AddChild(TDefineTemplate.Create('SrcPath','SrcPath addition',
ExternalMacroStart+'SrcPath', ExternalMacroStart+'SrcPath',
SrcPathMacro+';'+Dir+TargetProcessor,da_Define)); SrcPathMacro+';'+Dir+aTargetCPU,da_Define));
CompilerDir.AddChild(TDefineTemplate.Create('IncPath','IncPath addition', CompilerDir.AddChild(TDefineTemplate.Create('IncPath','IncPath addition',
IncludePathMacroName, IncludePathMacroName,
IncPathMacro+';'+Dir+'compiler',da_DefineRecurse)); IncPathMacro+';'+Dir+'compiler',da_DefineRecurse));
@ -5090,7 +5090,7 @@ end;
function TDefinePool.CreateFPCTemplate( function TDefinePool.CreateFPCTemplate(
const CompilerPath, CompilerOptions, TestPascalFile: string; const CompilerPath, CompilerOptions, TestPascalFile: string;
out UnitSearchPath, TargetOS, TargetProcessor: string; out UnitSearchPath, TargetOS, aTargetCPU: string;
Owner: TObject): TDefineTemplate; Owner: TObject): TDefineTemplate;
// create symbol definitions for the freepascal compiler // create symbol definitions for the freepascal compiler
// To get reliable values the compiler itself is asked for // To get reliable values the compiler itself is asked for
@ -5228,7 +5228,7 @@ begin
UnitSearchPath:=''; UnitSearchPath:='';
TargetOS:=''; TargetOS:='';
SrcOS:=''; SrcOS:='';
TargetProcessor:=''; aTargetCPU:='';
if (CompilerPath='') or (not FileIsExecutable(CompilerPath)) then exit; if (CompilerPath='') or (not FileIsExecutable(CompilerPath)) then exit;
LastDefTempl:=nil; LastDefTempl:=nil;
// find all initial compiler macros and all unit paths // find all initial compiler macros and all unit paths
@ -5352,10 +5352,10 @@ begin
i:=1; i:=1;
while i<=OutLen do begin while i<=OutLen do begin
if Buf[i] in [#10,#13] then begin if Buf[i] in [#10,#13] then begin
TargetProcessor:=copy(Buf,1,i-1); aTargetCPU:=copy(Buf,1,i-1);
NewDefTempl:=TDefineTemplate.Create('Define TargetProcessor', NewDefTempl:=TDefineTemplate.Create('Define TargetCPU',
ctsDefaultFPCTargetProcessor, ctsDefaultFPCTargetProcessor,
ExternalMacroStart+'TargetProcessor',TargetProcessor, TargetCPUMacroName,aTargetCPU,
da_DefineRecurse); da_DefineRecurse);
AddTemplate(NewDefTempl); AddTemplate(NewDefTempl);
break; break;
@ -5466,7 +5466,7 @@ function TDefinePool.CreateFPCSrcTemplate(
UnitLinkListValid: boolean; var UnitLinkList: string; UnitLinkListValid: boolean; var UnitLinkList: string;
Owner: TObject): TDefineTemplate; Owner: TObject): TDefineTemplate;
var var
Dir, SrcOS, SrcOS2, TargetProcessor, UnitLinks: string; Dir, SrcOS, SrcOS2, TargetCPU, UnitLinks: string;
UnitTree: TAVLTree; // tree of TDefTemplUnitNameLink UnitTree: TAVLTree; // tree of TDefTemplUnitNameLink
IncPathMacro, DefaultSrcOS, DefaultSrcOS2: string; IncPathMacro, DefaultSrcOS, DefaultSrcOS2: string;
ProgressID: integer; ProgressID: integer;
@ -5584,7 +5584,7 @@ var
// replace processor type // replace processor type
for i:=Low(FPCProcessorNames) to High(FPCProcessorNames) do for i:=Low(FPCProcessorNames) to High(FPCProcessorNames) do
if ReplaceDir(FPCProcessorNames[i],DefaultProcessorName, if ReplaceDir(FPCProcessorNames[i],DefaultProcessorName,
TargetProcessor) TargetCPU)
then then
break; break;
end; end;
@ -5949,8 +5949,8 @@ var
IncludePathMacroName,IncPathMacro+';inc', IncludePathMacroName,IncPathMacro+';inc',
da_Define)); da_Define));
RTLSrcOSDir.AddChild(TDefineTemplate.Create('Include Path', RTLSrcOSDir.AddChild(TDefineTemplate.Create('Include Path',
'include path to TargetProcessor directories', 'include path to TargetCPU directories',
IncludePathMacroName,IncPathMacro+';'+TargetProcessor, IncludePathMacroName,IncPathMacro+';'+TargetCPU,
da_Define)); da_Define));
ParentDefTempl.AddChild(IfTargetOSIsNotSrcOS); ParentDefTempl.AddChild(IfTargetOSIsNotSrcOS);
@ -5963,8 +5963,8 @@ var
SrcOS2,da_Directory); SrcOS2,da_Directory);
IfTargetOSIsNotSrcOS2.AddChild(RTLSrcOS2Dir); IfTargetOSIsNotSrcOS2.AddChild(RTLSrcOS2Dir);
RTLSrcOS2Dir.AddChild(TDefineTemplate.Create('Include Path', RTLSrcOS2Dir.AddChild(TDefineTemplate.Create('Include Path',
'include path to TargetProcessor directories', 'include path to TargetCPU directories',
IncludePathMacroName,IncPathMacro+';'+TargetProcessor, IncludePathMacroName,IncPathMacro+';'+TargetCPU,
da_DefineRecurse)); da_DefineRecurse));
ParentDefTempl.AddChild(IfTargetOSIsNotSrcOS2); ParentDefTempl.AddChild(IfTargetOSIsNotSrcOS2);
end; end;
@ -5986,8 +5986,8 @@ begin
Dir:=AppendPathDelim(FPCSrcDir); Dir:=AppendPathDelim(FPCSrcDir);
SrcOS:='$('+ExternalMacroStart+'SrcOS)'; SrcOS:='$('+ExternalMacroStart+'SrcOS)';
SrcOS2:='$('+ExternalMacroStart+'SrcOS2)'; SrcOS2:='$('+ExternalMacroStart+'SrcOS2)';
TargetProcessor:='$('+ExternalMacroStart+'TargetProcessor)'; TargetCPU:=TargetCPUMacro;
IncPathMacro:='$('+ExternalMacroStart+'IncPath)'; IncPathMacro:=IncludePathMacro;
DefaultSrcOS:=GetDefaultSrcOSForTargetOS(DefaultTargetOS); DefaultSrcOS:=GetDefaultSrcOSForTargetOS(DefaultTargetOS);
DefaultSrcOS2:=GetDefaultSrcOS2ForTargetOS(DefaultTargetOS); DefaultSrcOS2:=GetDefaultSrcOS2ForTargetOS(DefaultTargetOS);

View File

@ -1992,9 +1992,13 @@ begin
end; end;
procedure TExpressionEvaluator.WriteDebugReport; procedure TExpressionEvaluator.WriteDebugReport;
var
i: Integer;
begin begin
DebugLn('[TExpressionEvaluator.WriteDebugReport] '); DebugLn('[TExpressionEvaluator.WriteDebugReport] ');
ConsistencyCheck; ConsistencyCheck;
for i:=0 to Count-1 do
debugln(' ',Items(i));
end; end;
function TExpressionEvaluator.CalcMemSize(WithNamesAndValues: boolean; function TExpressionEvaluator.CalcMemSize(WithNamesAndValues: boolean;

View File

@ -2236,7 +2236,7 @@ begin
// check initvalues // check initvalues
//if ExtractFileNameOnly(MainFilename)='androidr14' then //if ExtractFileNameOnly(MainFilename)='androidr14' then
// debugln(['TLinkScanner.UpdateNeeded FGlobalInitValuesChangeStep=',FGlobalInitValuesChangeStep,' CurInitValuesChangeStep=',CurInitValuesChangeStep]); //debugln(['TLinkScanner.UpdateNeeded FGlobalInitValuesChangeStep=',FGlobalInitValuesChangeStep,' CurInitValuesChangeStep=',CurInitValuesChangeStep]);
if FGlobalInitValuesChangeStep<>CurInitValuesChangeStep then begin if FGlobalInitValuesChangeStep<>CurInitValuesChangeStep then begin
FGlobalInitValuesChangeStep:=CurInitValuesChangeStep; FGlobalInitValuesChangeStep:=CurInitValuesChangeStep;
if Assigned(FOnGetInitValues) then begin if Assigned(FOnGetInitValues) then begin

View File

@ -42,7 +42,7 @@ uses
{$IFDEF MEM_CHECK} {$IFDEF MEM_CHECK}
MemCheck, MemCheck,
{$ENDIF} {$ENDIF}
Classes, SysUtils, FileProcs, CodeToolsStrConsts, CodeTree, CodeAtom, Classes, SysUtils, FileProcs, CodeToolsStrConsts, CodeTree, CodeAtom, ExprEval,
CustomCodeTool, MultiKeyWordListTool, KeywordFuncLists, BasicCodeTools, CustomCodeTool, MultiKeyWordListTool, KeywordFuncLists, BasicCodeTools,
CodeToolsStructs, LinkScanner, CodeCache, AVL_Tree; CodeToolsStructs, LinkScanner, CodeCache, AVL_Tree;
@ -140,6 +140,9 @@ type
// parsing // parsing
FLastCompilerMode: TCompilerMode; FLastCompilerMode: TCompilerMode;
FLastCompilerModeSwitches: TCompilerModeSwitches; FLastCompilerModeSwitches: TCompilerModeSwitches;
FLastDefineStatic: Boolean;
FLastDefineEmbedded: Boolean;
FLastDefineTargetCPU: String;
procedure FetchScannerSource(Range: TLinkScannerRange); override; procedure FetchScannerSource(Range: TLinkScannerRange); override;
// sections // sections
function KeyWordFuncSection: boolean; function KeyWordFuncSection: boolean;
@ -513,6 +516,7 @@ end;
function TPascalParserTool.EndOfSourceExpected: boolean; function TPascalParserTool.EndOfSourceExpected: boolean;
begin begin
Result:=false; Result:=false;
//debugln(['TPascalParserTool.EndOfSourceExpected ',MainFilename,' Atom=',GetAtom,' ',CleanPosToStr(CurPos.StartPos,true)]);
SaveRaiseEndOfSourceExpected; SaveRaiseEndOfSourceExpected;
end; end;
@ -598,6 +602,7 @@ begin
CurNode:=Tree.Root; CurNode:=Tree.Root;
if CurNode<>nil then if CurNode<>nil then
while CurNode.NextBrother<>nil do CurNode:=CurNode.NextBrother; while CurNode.NextBrother<>nil do CurNode:=CurNode.NextBrother;
//if (ExtractFileNameOnly(MainFilename)='androidr14') and (CurNode<>nil) then
//debugln(['TPascalParserTool.BuildTree CurNode=',CurNode.DescAsString]); //debugln(['TPascalParserTool.BuildTree CurNode=',CurNode.DescAsString]);
if (CurNode=nil) if (CurNode=nil)
or ((CurNode.Desc in AllSourceTypes) and (CurNode.FirstChild=nil)) then begin or ((CurNode.Desc in AllSourceTypes) and (CurNode.FirstChild=nil)) then begin
@ -782,6 +787,7 @@ begin
ReadNextAtom; ReadNextAtom;
{$IFDEF VerboseUpdateNeeded} {$IFDEF VerboseUpdateNeeded}
//if ExtractFileNameOnly(MainFilename)='androidr14' then
debugln(['TPascalParserTool.BuildTree ScannedRange=',dbgs(ScannedRange),' CurNode=',CurNode.DescAsString,' first atom=',GetAtom,' Range=',dbgs(Range)]); debugln(['TPascalParserTool.BuildTree ScannedRange=',dbgs(ScannedRange),' CurNode=',CurNode.DescAsString,' first atom=',GetAtom,' Range=',dbgs(Range)]);
{$ENDIF} {$ENDIF}
@ -5144,6 +5150,9 @@ var
DiffPos: PtrInt; DiffPos: PtrInt;
Node: TCodeTreeNode; Node: TCodeTreeNode;
DeleteNode: TCodeTreeNode; DeleteNode: TCodeTreeNode;
aHasStatic: Boolean;
aHasEmbedded: Boolean;
aTargetCPU: String;
begin begin
// update scanned code // update scanned code
if FLastScannerChangeStep=Scanner.ChangeStep then begin if FLastScannerChangeStep=Scanner.ChangeStep then begin
@ -5155,10 +5164,23 @@ begin
// code has changed // code has changed
//debugln(['TPascalParserTool.FetchScannerSource link scanner has changed ',MainFilename]); //debugln(['TPascalParserTool.FetchScannerSource link scanner has changed ',MainFilename]);
FLastScannerChangeStep:=Scanner.ChangeStep; FLastScannerChangeStep:=Scanner.ChangeStep;
aHasStatic:=Scanner.Values.IsDefined('STATIC');
aHasEmbedded:=Scanner.Values.IsDefined('EMBEDDED');
aTargetCPU:=Scanner.Values[ExternalMacroStart+'TargetCPU'];
AllChanged:=(FLastCompilerMode<>Scanner.CompilerMode) AllChanged:=(FLastCompilerMode<>Scanner.CompilerMode)
or (FLastCompilerModeSwitches<>Scanner.CompilerModeSwitches); or (FLastCompilerModeSwitches<>Scanner.CompilerModeSwitches)
or (FLastDefineStatic<>aHasStatic)
or (FLastDefineEmbedded<>aHasEmbedded)
or (FLastDefineTargetCPU<>aTargetCPU);
//if ExtractFileNameOnly(MainFilename)='androidr14' then begin
//Scanner.Values.WriteDebugReport;
//debugln(['TPascalParserTool.FetchScannerSource ',aTargetCPU,' old=',FLastDefineTargetCPU]);
//end;
FLastCompilerMode:=Scanner.CompilerMode; FLastCompilerMode:=Scanner.CompilerMode;
FLastCompilerModeSwitches:=Scanner.CompilerModeSwitches; FLastCompilerModeSwitches:=Scanner.CompilerModeSwitches;
FLastDefineStatic:=aHasStatic;
FLastDefineEmbedded:=aHasEmbedded;
FLastDefineTargetCPU:=aTargetCPU;
NewSrc:=Scanner.CleanedSrc; NewSrc:=Scanner.CleanedSrc;
NewSrcLen:=length(NewSrc); NewSrcLen:=length(NewSrc);
if AllChanged then begin if AllChanged then begin