Browse Source

* store fully resolved target filename for includes
* remove trailing / for -Fi include paths
* only indent info,debug messages

git-svn-id: trunk@9873 -

peter 17 years ago
parent
commit
a8d2a7932d
1 changed files with 37 additions and 45 deletions
  1. 37 45
      packages/fpmkunit/src/fpmkunit.pp

+ 37 - 45
packages/fpmkunit/src/fpmkunit.pp

@@ -77,7 +77,7 @@ Type
   TSourceType = (stDoc,stSrc,stExample,stTest);
   TSourceType = (stDoc,stSrc,stExample,stTest);
   TSourceTypes = set of TSourceType;
   TSourceTypes = set of TSourceType;
 
 
-  TVerboseLevel = (vlError,vlWarning,vlInfo,vldebug);
+  TVerboseLevel = (vlError,vlWarning,vlInfo,vldebug,vlCommand);
   TVerboseLevels = Set of TVerboseLevel;
   TVerboseLevels = Set of TVerboseLevel;
 
 
   TCommandAt = (caBeforeCompile,caAfterCompile,
   TCommandAt = (caBeforeCompile,caAfterCompile,
@@ -163,8 +163,8 @@ Const
   UnitTargets = [ttUnit,ttImplicitUnit,ttCleanOnlyUnit,ttExampleUnit];
   UnitTargets = [ttUnit,ttImplicitUnit,ttCleanOnlyUnit,ttExampleUnit];
   ProgramTargets = [ttProgram,ttExampleProgram];
   ProgramTargets = [ttProgram,ttExampleProgram];
 
 
-  DefaultMessages = [vlError,vlWarning];
-  AllMessages = [vlError,vlWarning,vlInfo];
+  DefaultMessages = [vlError,vlWarning,vlCommand];
+  AllMessages = [vlError,vlWarning,vlCommand,vlInfo];
 
 
 
 
 Type
 Type
@@ -279,14 +279,12 @@ Type
     FDependencyType : TDependencyType;
     FDependencyType : TDependencyType;
     // Package, Unit
     // Package, Unit
     FTarget : TObject;
     FTarget : TObject;
-    // Includes and implicit/external packages
-    FDirectory : String;
-    Procedure SetDirectory(const AValue:String);
+    // Filenames, Includes
+    FTargetFileName : String;
   Public
   Public
-    Function FullFileName: String;
     Property Target : TObject Read FTarget Write FTarget;
     Property Target : TObject Read FTarget Write FTarget;
     Property DependencyType : TDependencyType Read FDependencyType;
     Property DependencyType : TDependencyType Read FDependencyType;
-    Property Directory: String Read FDirectory write SetDirectory;
+    Property TargetFileName : String Read FTargetFileName Write FTargetFileName;
   end;
   end;
 
 
   TDependencies = Class(TConditionalStrings)
   TDependencies = Class(TConditionalStrings)
@@ -929,8 +927,8 @@ ResourceString
   SErrInvalidArgumentToSubstitute = 'Invalid number of arguments to Substitute';
   SErrInvalidArgumentToSubstitute = 'Invalid number of arguments to Substitute';
   SErrNoArchiveSupport  = 'This binary contains no archive support. Please recompile with archive support';
   SErrNoArchiveSupport  = 'This binary contains no archive support. Please recompile with archive support';
   SErrNoDictionaryItem  = 'No item called "%s" in the dictionary';
   SErrNoDictionaryItem  = 'No item called "%s" in the dictionary';
-  SErrNoDictionaryValue = 'The item "%s" in the dictionary is not a value.';
-  SErrNoDictionaryFunc  = 'The item "%s" in the dictionary is not a function.';
+  SErrNoDictionaryValue = 'The item "%s" in the dictionary is not a value';
+  SErrNoDictionaryFunc  = 'The item "%s" in the dictionary is not a function';
   SErrInvalidFPCInfo    = 'Compiler returns invalid information, check if fpc -iV works';
   SErrInvalidFPCInfo    = 'Compiler returns invalid information, check if fpc -iV works';
   SErrDependencyNotFound = 'Could not find unit directory for dependency package "%s"';
   SErrDependencyNotFound = 'Could not find unit directory for dependency package "%s"';
   SErrAlreadyInitialized = 'Installer can only be initialized once';
   SErrAlreadyInitialized = 'Installer can only be initialized once';
@@ -939,7 +937,8 @@ ResourceString
   SWarnFailedToSetTime    = 'Warning: Failed to set timestamp on file "%s"';
   SWarnFailedToSetTime    = 'Warning: Failed to set timestamp on file "%s"';
   SWarnFailedToGetTime    = 'Warning: Failed to get timestamp from file "%s"';
   SWarnFailedToGetTime    = 'Warning: Failed to get timestamp from file "%s"';
   SWarnFileDoesNotExist   = 'Warning: File "%s" does not exist';
   SWarnFileDoesNotExist   = 'Warning: File "%s" does not exist';
-  SWarnAttemptingToCompileNonNeutralTarget = 'Attempting to compile non-neutral target %s';
+  SWarnAttemptingToCompileNonNeutralTarget = 'Warning: Attempting to compile non-neutral target %s';
+  SWarnIncludeFileNotFound = 'Warning: Include File "%s" not found';
 
 
   SInfoEnterDir           = 'Entering directory "%s"';
   SInfoEnterDir           = 'Entering directory "%s"';
   SInfoCompilingPackage   = 'Compiling package %s';
   SInfoCompilingPackage   = 'Compiling package %s';
@@ -2888,7 +2887,7 @@ Var
 begin
 begin
   Log(vlInfo,SInfoExecutingCommand,[Cmd,Args]);
   Log(vlInfo,SInfoExecutingCommand,[Cmd,Args]);
   if ListMode then
   if ListMode then
-    Log(vlError,'%s %s',[Cmd,Args])
+    Log(vlCommand,'%s %s',[Cmd,Args])
   else
   else
     begin
     begin
       // We should check cmd for spaces, and move all after first space to args.
       // We should check cmd for spaces, and move all after first space to args.
@@ -3010,7 +3009,12 @@ end;
 procedure TBuildEngine.Log(Level: TVerboseLevel; const Msg: String);
 procedure TBuildEngine.Log(Level: TVerboseLevel; const Msg: String);
 begin
 begin
   If Assigned(FOnLog) then
   If Assigned(FOnLog) then
-    FOnLog(Level,FLogPrefix+Msg);
+    begin
+      if Level in [vlInfo,vlDebug] then
+        FOnLog(Level,FLogPrefix+Msg)
+      else
+        FOnLog(Level,Msg);
+    end;
 end;
 end;
 
 
 
 
@@ -3265,21 +3269,21 @@ begin
           D:=T.Dependencies[j];
           D:=T.Dependencies[j];
           if (D.DependencyType=depInclude) and DependencyOK(D)  then
           if (D.DependencyType=depInclude) and DependencyOK(D)  then
             begin
             begin
-              SD:=Dictionary.ReplaceStrings(D.Directory);
-              SF:=Dictionary.ReplaceStrings(D.Value);
-              if SD='' then
+              if D.TargetFileName='' then
                 begin
                 begin
+                  SF:=Dictionary.ReplaceStrings(D.Value);
+                  SD:='';
                   // first check the target specific path
                   // first check the target specific path
                   if not FindFileInPath(T.IncludePath,SF,SD,ACPU,AOS,APackage.Directory) then
                   if not FindFileInPath(T.IncludePath,SF,SD,ACPU,AOS,APackage.Directory) then
                     FindFileInPath(APackage.IncludePath,SF,SD,ACPU,AOS,APackage.Directory);
                     FindFileInPath(APackage.IncludePath,SF,SD,ACPU,AOS,APackage.Directory);
-                end
-              else
-                if APackage.Directory<>'' then
-                  SD:=IncludeTrailingPathDelimiter(APackage.Directory)+SD;
-               if SD<>'' then
-                 SD:=IncludeTrailingPathDelimiter(SD);
-               D.Directory:=SD;
-               Log(vlDebug,SDbgResolvedIncludeFile,[D.Value,D.FullFileName]);
+                   if SD<>'' then
+                     SD:=IncludeTrailingPathDelimiter(SD);
+                   D.TargetFileName:=SD+SF;
+                 end;
+               if FileExists(D.TargetFileName) then
+                 Log(vlDebug,SDbgResolvedIncludeFile,[D.Value,D.TargetFileName])
+               else
+                 Log(vlWarning,SWarnIncludeFileNotFound,[D.Value])
              end;
              end;
         end;
         end;
 
 
@@ -3315,6 +3319,7 @@ procedure TBuildEngine.AddDependencyIncludePaths(L:TStrings;ATarget: TTarget);
 Var
 Var
   I : Integer;
   I : Integer;
   D : TDependency;
   D : TDependency;
+  SD : String;
 begin
 begin
   For I:=0 to ATarget.Dependencies.Count-1 do
   For I:=0 to ATarget.Dependencies.Count-1 do
     begin
     begin
@@ -3322,7 +3327,9 @@ begin
       if (D.DependencyType=depInclude) and
       if (D.DependencyType=depInclude) and
          (Defaults.CPU in D.CPUs) and (Defaults.OS in D.OSes) then
          (Defaults.CPU in D.CPUs) and (Defaults.OS in D.OSes) then
         begin
         begin
-          L.Add(D.Directory);
+          SD:=ExcludeTrailingPathDelimiter(ExtractFilePath(D.TargetFileName));
+          if SD<>'' then
+            L.Add(SD);
         end;
         end;
     end;
     end;
 end;
 end;
@@ -3620,8 +3627,8 @@ begin
                   end;
                   end;
                 depInclude :
                 depInclude :
                   begin
                   begin
-                    if FileExists(D.FullFileName) then
-                      Result:=FileNewer(D.FullFileName,OFN)
+                    if FileExists(D.TargetFileName) then
+                      Result:=FileNewer(D.TargetFileName,OFN)
                   end;
                   end;
               end;
               end;
               if result then
               if result then
@@ -4311,7 +4318,7 @@ begin
       D:=Dependencies[i];
       D:=Dependencies[i];
       if (D.DependencyType=depInclude) and
       if (D.DependencyType=depInclude) and
          (ACPU in D.CPUs) and (AOS in D.OSes) then
          (ACPU in D.CPUs) and (AOS in D.OSes) then
-        List.Add(D.FullFileName);
+        List.Add(D.TargetFileName);
     end;
     end;
 end;
 end;
 
 
@@ -4447,22 +4454,6 @@ begin
 end;
 end;
 
 
 
 
-{****************************************************************************
-                                 TDependency
-****************************************************************************}
-
-Function TDependency.FullFileName: String;
-begin
-  Result:=FDirectory+Value;
-end;
-
-
-Procedure TDependency.SetDirectory(const AValue:String);
-begin
-  FDirectory:=IncludeTrailingPathDelimiter(AValue);
-end;
-
-
 {****************************************************************************
 {****************************************************************************
                                 TDependencies
                                 TDependencies
 ****************************************************************************}
 ****************************************************************************}
@@ -4565,7 +4556,8 @@ begin
   if ExtractFileExt(N)='' then
   if ExtractFileExt(N)='' then
     ChangeFileExt(N,IncExt);
     ChangeFileExt(N,IncExt);
   Result:=inherited Add(N,CPUs,OSes) as TDependency;
   Result:=inherited Add(N,CPUs,OSes) as TDependency;
-  Result.FDirectory:=D;
+  if D<>'' then
+    Result.TargetFileName:=D+N;
   Result.FDependencyType:=depInclude;
   Result.FDependencyType:=depInclude;
 end;
 end;