Browse Source

* Do not search for files in directories that do not exist when doing distclean

Michaël Van Canneyt 1 year ago
parent
commit
f7d6201946
1 changed files with 52 additions and 32 deletions
  1. 52 32
      packages/fpmkunit/src/fpmkunit.pp

+ 52 - 32
packages/fpmkunit/src/fpmkunit.pp

@@ -4472,7 +4472,11 @@ Var
   I : Integer;
 begin
   OB:=IncludeTrailingPathDelimiter(GetBinOutputDir(aTarget));
+  if Not DirectoryExists(OB) then
+    OB:='';
   OU:=IncludeTrailingPathDelimiter(GetUnitsOutputDir(aTarget));
+  if not DirectoryExists(OU) then
+    OU:='';
   List.Add(GetUnitConfigOutputFilename(aTarget));
   List.Add(ManifestFile);
   AddConditionalStrings(Self, List,CleanFiles,aTarget);
@@ -10299,50 +10303,66 @@ begin
   aOS:=aTarget.OS;
   If not(aCPU in CPUs) or not(AOS in OSes) then
     exit;
-  List.Add(APrefixU + ObjectFileName);
-  List.Add(APrefixU + LTOFileName);
-  If (TargetType in [ttUnit,ttImplicitUnit,ttExampleUnit, ttCleanOnlyUnit]) then
+  if aPrefixU<>'' then
     begin
-      List.Add(APrefixU + UnitFileName);
-      if (AOS in AllSmartLinkLibraryOSes) and FileExists(APrefixU + GetUnitLibFileName(AOS)) then
-        List.Add(APrefixU + GetUnitLibFileName(AOS));
-      if (AOS in AllImportLibraryOSes) and FileExists(APrefixU + GetImportLibFilename(AOS)) then
-        List.Add(APrefixU + GetImportLibFilename(AOS));
-    end
-  else If (TargetType in [ttProgram,ttExampleProgram]) then
+    List.Add(APrefixU + ObjectFileName);
+    List.Add(APrefixU + LTOFileName);
+    end;
+  Case TargetType of
+  ttUnit,ttImplicitUnit,ttExampleUnit, ttCleanOnlyUnit:
+      if aPrefixU<>'' then
+        begin
+        List.Add(APrefixU + UnitFileName);
+        if (AOS in AllSmartLinkLibraryOSes) and FileExists(APrefixU + GetUnitLibFileName(AOS)) then
+          List.Add(APrefixU + GetUnitLibFileName(AOS));
+        if (AOS in AllImportLibraryOSes) and FileExists(APrefixU + GetImportLibFilename(AOS)) then
+          List.Add(APrefixU + GetImportLibFilename(AOS));
+        end;
+  ttProgram,ttExampleProgram:
     begin
+    if (aPrefixB<>'') then
+      begin
       List.Add(APrefixB + GetProgramFileName(AOS));
-      if FileExists(APrefixB + GetProgramDebugFileName(AOS)) then
-        List.Add(APrefixB + GetProgramDebugFileName(AOS));
+        if FileExists(APrefixB + GetProgramDebugFileName(AOS)) then
+          List.Add(APrefixB + GetProgramDebugFileName(AOS));
+      end;
+    if (aPrefixU<>'') then
+      begin
       if (AOS in AllImportLibraryOSes) and FileExists(APrefixU + GetImportLibFilename(AOS)) then
         List.Add(APrefixU + GetImportLibFilename(AOS));
-    end
-  else If (TargetType in [ttSharedLibrary]) then
+      end;
+    end;
+  ttSharedLibrary:
+    if (APrefixB<>'') then
     begin
       List.Add(APrefixB + GetLibraryFileName(AOS));
       if FileExists(APrefixB + GetLibraryDebugFileName(AOS)) then
         List.Add(APrefixB + GetLibraryDebugFileName(AOS));
     end;
-  If ResourceStrings then
+  end; { case }
+  if (APrefixU<>'') then
     begin
-      // choose between 2 possible resource files
-      if FileExists(APrefixU + RSJFileName) then
-        List.Add(APrefixU + RSJFileName)
-      else
-        List.Add(APrefixU + RSTFileName);
-    end
-  else
-    begin
-      if FileExists(APrefixU + RSJFileName) then
-        begin
-          Installer.Log(VlDebug,Format(SDbgUnregisteredResource,[APrefixU + RSJFileName]));
-          List.Add(APrefixU + RSJFileName);
-        end
-      else if FileExists(APrefixU + RSTFileName) then
-        begin
-          Installer.Log(VlDebug,Format(SDbgUnregisteredResource,[APrefixU + RSTFileName]));
+    If ResourceStrings  then
+      begin
+        // choose between 2 possible resource files
+        if FileExists(APrefixU + RSJFileName) then
+          List.Add(APrefixU + RSJFileName)
+        else
           List.Add(APrefixU + RSTFileName);
-        end;
+      end
+    else
+      begin
+        if FileExists(APrefixU + RSJFileName) then
+          begin
+            Installer.Log(VlDebug,Format(SDbgUnregisteredResource,[APrefixU + RSJFileName]));
+            List.Add(APrefixU + RSJFileName);
+          end
+        else if FileExists(APrefixU + RSTFileName) then
+          begin
+            Installer.Log(VlDebug,Format(SDbgUnregisteredResource,[APrefixU + RSTFileName]));
+            List.Add(APrefixU + RSTFileName);
+          end;
+       end;
      end;
   // Maybe add later ?  AddConditionalStrings(List,CleanFiles);
 end;