[PATCH] testbot/build: Simplify Build.pl by reusing the patch analyser.

Francois Gouget fgouget at codeweavers.com
Mon May 28 17:42:30 CDT 2018


Also better identify patches that require rebuilding the native tools.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
 testbot/bin/build/Build.pl            | 41 ++++-----------------------
 testbot/lib/WineTestBot/PatchUtils.pm | 31 ++++++++++++++++----
 2 files changed, 30 insertions(+), 42 deletions(-)

diff --git a/testbot/bin/build/Build.pl b/testbot/bin/build/Build.pl
index c72489c40..5e6b3700c 100755
--- a/testbot/bin/build/Build.pl
+++ b/testbot/bin/build/Build.pl
@@ -40,6 +40,7 @@ sub BEGIN
 }
 
 use WineTestBot::Config;
+use WineTestBot::PatchUtils;
 
 sub InfoMsg(@)
 {
@@ -74,39 +75,6 @@ sub ApplyPatch($)
 {
   my ($PatchFile) = @_;
 
-  my ($NeedMakeMakefiles, $NeedAutoconf, $HasConfigure, $NeedBuildNative);
-  if (open (FH, "<$PatchFile"))
-  {
-    my $Line;
-    while (defined($Line = <FH>) &&
-           (!$NeedMakeMakefiles || !$NeedAutoconf || !$HasConfigure ||
-            !$NeedBuildNative))
-    {
-      if ($Line =~ m=^diff.*(?:aclocal\.m4|configure\.ac)=)
-      {
-        $NeedAutoconf = 1;
-      }
-      elsif ($Line =~ m=^diff.*configure=)
-      {
-        $HasConfigure = 1;
-      }
-      elsif ($Line =~ m=^new file= || $Line =~ m=^deleted file= || $Line =~ m=^rename= ||
-             $Line =~ m=diff.*tools/make_makefiles=)
-      {
-        $NeedMakeMakefiles = 1;
-      }
-      elsif ($Line =~ m=^diff.*tools/makedep\.c=)
-      {
-        $NeedMakeMakefiles = $NeedBuildNative = 1;
-      }
-      elsif ($Line =~ m=^diff.*tools/(?:makedep\.c|make_xftmpl\.c|sfnt2fon|winebuild|winegcc|widl|wmc|wrc)=)
-      {
-        $NeedBuildNative = 1;
-      }
-    }
-    close FH;
-  }
-
   InfoMsg "Applying patch\n";
   system("( cd $DataDir/wine && set -x && " .
          "  git apply --verbose $PatchFile && " .
@@ -118,7 +86,8 @@ sub ApplyPatch($)
     return -1;
   }
 
-  if ($NeedMakeMakefiles)
+  my $Impacts = GetPatchImpact($PatchFile, "nounits");
+  if ($Impacts->{Makefiles})
   {
     InfoMsg "Running make_makefiles\n";
     system("( cd $DataDir/wine && set -x && " .
@@ -131,7 +100,7 @@ sub ApplyPatch($)
     }
   }
 
-  if ($NeedAutoconf && !$HasConfigure)
+  if ($Impacts->{Autoconf} && !$Impacts->{HasConfigure})
   {
     InfoMsg "Running autoconf\n";
     system("( cd $DataDir/wine && set -x && " .
@@ -144,7 +113,7 @@ sub ApplyPatch($)
     }
   }
 
-  return $NeedBuildNative;
+  return $Impacts->{Tools};
 }
 
 my $ncpus;
diff --git a/testbot/lib/WineTestBot/PatchUtils.pm b/testbot/lib/WineTestBot/PatchUtils.pm
index 62784874c..2000c9009 100644
--- a/testbot/lib/WineTestBot/PatchUtils.pm
+++ b/testbot/lib/WineTestBot/PatchUtils.pm
@@ -86,8 +86,8 @@ sub _AddTest($$$)
     };
   }
 
-  # Assume makefile modifications may break the build but not the tests.
-  return if ($File eq "Makefile.in");
+  # Assume makefile modifications may break the build but not the tests
+  return if ($File eq "Makefile.in" or $Impacts->{NoUnits});
 
   if (!$Tests->{$Module}->{Files})
   {
@@ -118,18 +118,37 @@ configure, whether it impacts the tests, etc.
 =back
 =cut
 
-sub GetPatchImpact($)
+sub GetPatchImpact($;$)
 {
-  my ($PatchFileName) = @_;
+  my ($PatchFileName, $NoUnits) = @_;
 
   my $fh;
   return undef if (!open($fh, "<", $PatchFileName));
 
-  my $Impacts = { Tests => {} };
+  my $Impacts = {
+    NoUnits => $NoUnits,
+    Tests => {},
+  };
   my ($Path, $Change);
   while (my $Line = <$fh>)
   {
-    if ($Line =~ m=^--- /dev/null$=)
+    if ($Line =~ m=^--- \w+/(?:aclocal\.m4|configure\.ac)$=)
+    {
+      $Impacts->{Autoconf} = 1;
+    }
+    elsif ($Line =~ m=^--- \w+/configure$=)
+    {
+      $Impacts->{HasConfigure} = 1;
+    }
+    elsif ($Line =~ m=^--- \w+/tools/make_makefiles$=)
+    {
+      $Impacts->{Makefiles} = $Impacts->{Tools} = 1;
+    }
+    elsif ($Line =~ m=^--- \w+/tools/(?:makedep\.c|make_xftmpl\.c|sfnt2fon|winebuild|winegcc|widl|wmc|wrc)$=)
+    {
+      $Impacts->{Tools} = 1;
+    }
+    elsif ($Line =~ m=^--- /dev/null$=)
     {
       $Change = "new";
     }
-- 
2.17.0



More information about the wine-devel mailing list