[1/2] testbot/build(*): Move the build VM's scripts to the bin/build directory.

Francois Gouget fgouget at codeweavers.com
Thu Oct 11 10:11:11 CDT 2012


This makes it easier to identify the scripts that are only meant to be run on the build VM, both when browsing the filesystem and when reading the WineTestBot code.

(*) Compatibility Note: This requires updating the WineTestBot checkout on the build VM.
---

One only needs to worry about this compatibility note if deploying this 
patch on a preexisting WineTestBot system. As it's unlikely to happen 
this is essentially moot.

 testbot/bin/BuildSingleTest.pl       |  379 ----------------------------------
 testbot/bin/Reconfig.pl              |  142 -------------
 testbot/bin/WineRunBuild.pl          |    4 +-
 testbot/bin/WineRunReconfig.pl       |   10 +-
 testbot/bin/build/BuildSingleTest.pl |  379 ++++++++++++++++++++++++++++++++++
 testbot/bin/build/Reconfig.pl        |  142 +++++++++++++
 6 files changed, 528 insertions(+), 528 deletions(-)
 delete mode 100755 testbot/bin/BuildSingleTest.pl
 delete mode 100755 testbot/bin/Reconfig.pl
 create mode 100755 testbot/bin/build/BuildSingleTest.pl
 create mode 100755 testbot/bin/build/Reconfig.pl

diff --git a/testbot/bin/BuildSingleTest.pl b/testbot/bin/BuildSingleTest.pl
deleted file mode 100755
index 07787d4..0000000
--- a/testbot/bin/BuildSingleTest.pl
+++ /dev/null
@@ -1,379 +0,0 @@
-#!/usr/bin/perl -Tw
-#
-# Performs the 'build' task in the build machine. Specifically this applies a
-# conformance test patch, rebuilds the impacted test and retrieves the
-# resulting 32 and 64 bit binaries.
-#
-# Copyright 2009 Ge van Geldorp
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
-
-use strict;
-
-my $Dir;
-sub BEGIN
-{
-  $main::BuildEnv = 1;
-  $0 =~ m=^(.*)/[^/]*$=;
-  $Dir = $1;
-}
-use lib "$Dir/../lib";
-
-use WineTestBot::Config;
-
-sub InfoMsg
-{
-  my $oldumask = umask(002);
-  if (open LOGFILE, ">>$LogDir/BuildSingleTest.log")
-  {
-    print LOGFILE @_;
-    close LOGFILE;
-  }
-  umask($oldumask);
-}
-
-sub LogMsg
-{
-  my $oldumask = umask(002);
-  if (open LOGFILE, ">>$LogDir/BuildSingleTest.log")
-  {
-    print LOGFILE "BuildSingleTest: ", @_;
-    close LOGFILE;
-  }
-  umask($oldumask);
-}
-
-sub FatalError
-{
-  LogMsg @_;
-
-  exit 1;
-}
-
-sub ApplyPatch
-{
-  my ($PatchFile, $PatchType, $BaseName) = @_;
-
-  my $NeedMakefile = 0;
-  my $NeedMakeInclude = !1;
-  my $NeedBuildDeps = !1;
-  my $NeedImplib = !1;
-  my $NeedAutoconf = !1;
-  my $NeedConfigure = !1;
-  if (open (FH, "<$PatchFile"))
-  {
-    my $Line;
-    while (defined($Line = <FH>) &&
-           ($NeedMakefile == 0 || ! $NeedMakeInclude || ! $NeedBuildDeps ||
-            ! $NeedImplib || ! $NeedAutoconf || ! $NeedConfigure))
-    {
-      if ($Line =~ m=^diff.*tests/Makefile\.in=)
-      {
-        $NeedMakefile = 1;
-      }
-      elsif ($Line =~ m=^diff.*include/.*\.idl=)
-      {
-        $NeedMakeInclude = 1;
-      }
-      elsif ($Line =~ m=^diff.*\.spec=)
-      {
-        $NeedBuildDeps = 1;
-      }
-      elsif ($PatchType eq "dlls" && $Line =~ m=^diff.*$BaseName/Makefile\.in=)
-      {
-        $NeedImplib = 1;
-      }
-      elsif ($Line =~ m=^diff.*configure\.ac=)
-      {
-        $NeedAutoconf = 1;
-      }
-      elsif ($Line =~ m=^diff.*configure=)
-      {
-        $NeedConfigure = 1;
-      }
-    }
-    close FH;
-  }
-
-  InfoMsg "Applying patch\n";
-  system("git apply --verbose --directory=$DataDir/wine-git $PatchFile " .
-         ">> $LogDir/BuildSingleTest.log 2>&1");
-  if ($? != 0)
-  {
-    LogMsg "Patch failed to apply\n";
-    return (-1, $NeedMakeInclude, $NeedBuildDeps, $NeedImplib, $NeedConfigure);
-  }
-
-  if ($NeedAutoconf && ! $NeedConfigure)
-  {
-    InfoMsg "Running autoconf\n";
-    system("( cd $DataDir/wine-git && set -x && " .
-           "  autoconf --output configure configure.ac " .
-           ") >>$LogDir/BuildSingleTest.log 2>&1");
-    if ($? != 0)
-    {
-       LogMsg "Autoconf failed\n";
-       return (-1, $NeedMakeInclude, $NeedBuildDeps, $NeedImplib,
-               $NeedConfigure);
-    }
-    $NeedConfigure = 1;
-  }
-
-  if ($NeedImplib)
-  {
-    if (open (FH, "<$DataDir/wine-git/$PatchType/$BaseName/Makefile.in"))
-    {
-      $NeedImplib = !1;
-      my $Line;
-      while (defined($Line = <FH>) && ! $NeedImplib)
-      {
-        $NeedImplib = ($Line =~ m/^\s*IMPORTLIB\s*=.*$BaseName/)
-      }
-      close FH;
-    }
-  }
-
-  return ($NeedMakefile, $NeedMakeInclude, $NeedBuildDeps, $NeedImplib,
-          $NeedConfigure);
-}
-
-my $ncpus;
-sub CountCPUs()
-{
-    if (open(my $fh, "<", "/proc/cpuinfo"))
-    {
-        # Linux
-        map { $ncpus++ if (/^processor/); } <$fh>;
-        close($fh);
-    }
-    $ncpus ||= 1;
-}
-
-sub BuildTestExecutable
-{
-  my ($BaseName, $PatchType, $Bits, $NeedConfigure, $NeedMakefile,
-      $NeedMakeInclude, $NeedBuildDeps, $NeedImplib) = @_;
-
-  if ($NeedConfigure)
-  {
-    InfoMsg "Reconfigure $Bits-bit crossbuild\n";
-    my $Host = ($Bits == 64 ? "x86_64-w64-mingw32" : "i686-pc-mingw32");
-    system("( cd $DataDir/build-mingw$Bits && set -x && " .
-           "  ../wine-git/configure --host=$Host --with-wine-tools=../build-native --without-x --without-freetype " .
-           ") >>$LogDir/BuildSingleTest.log 2>&1");
-    if ($? != 0)
-    {
-      LogMsg "Reconfigure of $Bits-bit crossbuild failed\n";
-      return !1;
-    }
-  }
-
-  if ($NeedMakeInclude || $NeedConfigure)
-  {
-    InfoMsg "Recreating include/Makefile\n";
-    system("( cd $DataDir/build-mingw$Bits && set -x && " .
-           "  ./config.status --file include/Makefile:Make.vars.in:include/Makefile.in " .
-           ") >>$LogDir/BuildSingleTest.log 2>&1");
-    if ($? != 0)
-    {
-      LogMsg "Recreation of include/Makefile failed\n";
-      return !1;
-    }
-
-    system("( cd $DataDir/build-mingw$Bits && set -x && " .
-           "  make -j$ncpus include " .
-           ") >> $LogDir/BuildSingleTest.log 2>&1");
-    if ($? != 0)
-    {
-      LogMsg "Make in include dir failed\n";
-      return !1;
-    }
-  }
-
-  if ($NeedImplib || $NeedConfigure)
-  {
-    InfoMsg "Rebuilding $BaseName import lib\n";
-    system("( cd $DataDir/build-mingw$Bits && set -x && " .
-           "  ./config.status --file $PatchType/$BaseName/Makefile:Make.vars.in:$PatchType/$BaseName/Makefile.in " .
-           ") >>$LogDir/BuildSingleTest.log 2>&1");
-    if ($? != 0)
-    {
-      LogMsg "Unable to regenerate $PatchType/$BaseName/Makefile\n";
-    }
-    else
-    {
-      system("( cd $DataDir/build-mingw$Bits && set -x && " .
-             "  make -j$ncpus -C $PatchType/$BaseName lib$BaseName.a " .
-             ") >>$LogDir/BuildSingleTest.log 2>&1");
-      if ($? != 0)
-      {
-        InfoMsg "Make of import library failed\n";
-      }
-    }
-  }
-
-  if ($NeedMakefile || $NeedConfigure)
-  {
-    InfoMsg "Recreating tests/Makefile\n";
-    system("( cd $DataDir/build-mingw$Bits && set -x && " .
-           "  ./config.status --file $PatchType/$BaseName/tests/Makefile:Make.vars.in:$PatchType/$BaseName/tests/Makefile.in " .
-           ") >>$LogDir/BuildSingleTest.log 2>&1");
-    if ($? != 0)
-    {
-      LogMsg "Recreation of tests/Makefile failed\n";
-      return !1;
-    }
-  }
-
-  if ($NeedBuildDeps)
-  {
-    InfoMsg "Making build dependencies\n";
-    system("( cd $DataDir/build-mingw$Bits && set -x && " .
-           "  make -j$ncpus __builddeps__ " .
-           ") >>$LogDir/BuildSingleTest.log 2>&1");
-    if ($? != 0)
-    {
-      LogMsg "Making build dependencies failed\n";
-      return !1;
-    }
-  }
-
-  my $TestsDir = "$PatchType/$BaseName/tests";
-  my $TestExecutable = "$TestsDir/$BaseName";
-  if ($PatchType eq "programs")
-  {
-    $TestExecutable .= ".exe";
-  }
-  $TestExecutable .= "_test.exe";
-  unlink("$DataDir/build-mingw${Bits}/$TestExecutable");
- 
-  InfoMsg "Making test executable\n";
-  system("( cd $DataDir/build-mingw$Bits && set -x && " .
-         "  make -j$ncpus -C $TestsDir " .
-         ") >>$LogDir/BuildSingleTest.log 2>&1");
-  if ($? != 0)
-  {
-    LogMsg "Make failed\n";
-    return !1;
-  }
-  if (! -f "$DataDir/build-mingw${Bits}/$TestExecutable")
-  {
-    LogMsg "Make didn't produce a $TestExecutable file\n";
-    return !1;
-  }
-
-  return 1;
-}
-
-$ENV{PATH} = "/usr/lib/ccache:/usr/bin:/bin";
-delete $ENV{ENV};
-
-# Start with clean logfile
-unlink("$LogDir/BuildSingleTest.log");
-
-my ($PatchFile, $PatchType, $BaseName, $BitIndicators) = @ARGV;
-if (! $PatchFile || ! $PatchType || ! $BaseName || !$BitIndicators)
-{
-  FatalError "Usage: BuildSingleTest.pl <patchfile> <patchtype> <basename> <bits>\n";
-}
-
-# Untaint parameters
-if ($PatchFile =~ m/^([\w_.\-]+)$/)
-{
-  $PatchFile = "$DataDir/staging/$1";
-  if (! -r $PatchFile)
-  {
-    FatalError "Patch file $PatchFile not readable\n";
-  }
-}
-else
-{
-  FatalError "Invalid patch file $PatchFile\n";
-}
-
-if ($PatchType =~ m/^patch(dlls|programs)$/)
-{
-  $PatchType = $1;
-}
-else
-{
-  FatalError "Invalid patch type $PatchType\n";
-}
-
-if ($BaseName =~ m/^([\w_.\-]+)$/)
-{
-  $BaseName = $1;
-}
-else
-{
-  FatalError "Invalid DLL base name $BaseName\n";
-}
-
-my $Run32 = !1;
-my $Run64 = !1;
-if ($BitIndicators =~ m/^([\d,]+)$/)
-{
-  my @Bits = split /,/, $1;
-  foreach my $BitsValue (@Bits)
-  {
-    if ($BitsValue == 32)
-    {
-      $Run32 = 1;
-    }
-    elsif ($BitsValue == 64)
-    {
-      $Run64 = 1;
-    }
-    else
-    {
-      FatalError "Invalid number of bits $BitsValue\n";
-    }
-  }
-  if (! $Run32 && ! $Run64)
-  {
-    FatalError "Specify at least one of 32 or 64 bits\n";
-  }
-}
-else
-{
-  FatalError "Invalid number of bits $BitIndicators\n";
-}
-
-my ($NeedMakefile, $NeedMakeInclude, $NeedBuildDeps, $NeedImplib,
-    $NeedConfigure) = ApplyPatch($PatchFile, $PatchType, $BaseName);
-if ($NeedMakefile < 0)
-{
-  exit(1);
-}
-
-CountCPUs();
-
-if ($Run32 && ! BuildTestExecutable($BaseName, $PatchType, 32,
-                                    $NeedConfigure, 0 < $NeedMakefile,
-                                    $NeedMakeInclude, $NeedBuildDeps,
-                                    $NeedImplib))
-{
-  exit(1);
-}
-if ($Run64 && ! BuildTestExecutable($BaseName, $PatchType, 64,
-                                    $NeedConfigure, 0 < $NeedMakefile,
-                                    $NeedMakeInclude, $NeedBuildDeps,
-                                    $NeedImplib))
-{
-  exit(1);
-}
-
-LogMsg "ok\n";
-exit;
diff --git a/testbot/bin/Reconfig.pl b/testbot/bin/Reconfig.pl
deleted file mode 100755
index f049e8a..0000000
--- a/testbot/bin/Reconfig.pl
+++ /dev/null
@@ -1,142 +0,0 @@
-#!/usr/bin/perl -Tw
-#
-# Performs the 'reconfig' task in the build machine. Specifically this updates
-# the build machine's Wine repository, re-runs configure, and rebuilds the
-# 32 and 64 bit winetest binaries.
-#
-# Copyright 2009 Ge van Geldorp
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
-
-use strict;
-
-my $Dir;
-sub BEGIN
-{
-  $main::BuildEnv = 1;
-  $0 =~ m=^(.*)/[^/]*$=;
-  $Dir = $1;
-}
-use lib "$Dir/../lib";
-
-use WineTestBot::Config;
-
-sub LogMsg
-{
-  my $oldumask = umask(002);
-  if (open LOGFILE, ">>$LogDir/Reconfig.log")
-  {
-    print LOGFILE "Reconfig: ", @_;
-    close LOGFILE;
-  }
-  umask($oldumask);
-}
-
-sub FatalError
-{
-  LogMsg @_;
-
-  exit 1;
-}
-
-sub GitPull
-{
-  system("cd $DataDir/wine-git && git pull >> $LogDir/Reconfig.log 2>&1");
-  if ($? != 0)
-  {
-    LogMsg "Git pull failed\n";
-    return !1;
-  }
-
-  return 1;
-}
-
-my $ncpus;
-sub CountCPUs()
-{
-    if (open(my $fh, "<", "/proc/cpuinfo"))
-    {
-        # Linux
-        map { $ncpus++ if (/^processor/); } <$fh>;
-        close($fh);
-    }
-    $ncpus ||= 1;
-}
-
-sub BuildNative
-{
-  mkdir "$DataDir/build-native" if (! -d "$DataDir/build-native");
-  system("( cd $DataDir/build-native && set -x && " .
-         "  rm -rf * && " .
-         "  time ../wine-git/configure --enable-win64 --without-x --without-freetype && " .
-         "  time make -j$ncpus depend && " .
-         "  time make -j$ncpus __tooldeps__ " .
-         ") >>$LogDir/Reconfig.log 2>&1");
-
-  if ($? != 0)
-  {
-    LogMsg "Build native failed\n";
-    return !1;
-  }
-
-  return 1;
-}
-
-sub BuildCross
-{
-  my $Bits = $_[0];
-
-  my $Host = ($Bits == 64 ? "x86_64-w64-mingw32" : "i686-w64-mingw32");
-  mkdir "$DataDir/build-mingw$Bits" if (! -d "$DataDir/build-mingw$Bits");
-  system("( cd $DataDir/build-mingw$Bits && set -x && " .
-         "  rm -rf * && " .
-         "  time ../wine-git/configure --host=$Host --with-wine-tools=../build-native --without-x --without-freetype && " .
-         "  time make -j$ncpus depend  && " .
-         "  time make -j$ncpus programs/winetest " .
-         ") >>$LogDir/Reconfig.log 2>&1");
-  if ($? != 0)
-  {
-    LogMsg "Build cross ($Bits bits) failed\n";
-    return !1;
-  }
-
-  return 1;
-}
-
-$ENV{PATH} = "/usr/lib/ccache:/usr/bin:/bin";
-delete $ENV{ENV};
-
-# Start with clean logfile
-unlink("$LogDir/Reconfig.log");
-
-if (! GitPull())
-{
-  exit(1);
-}
-
-CountCPUs();
-
-if (! BuildNative())
-{
-  exit(1);
-}
-
-if (! BuildCross(32) || ! BuildCross(64))
-{
-  exit(1);
-}
-
-LogMsg "ok\n";
-exit;
diff --git a/testbot/bin/WineRunBuild.pl b/testbot/bin/WineRunBuild.pl
index 2699351..56161da 100755
--- a/testbot/bin/WineRunBuild.pl
+++ b/testbot/bin/WineRunBuild.pl
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -Tw
 #
 # Communicates with the build machine to have it perform the 'build' task.
-# See the bin/BuildSingleTest.pl script.
+# See the bin/build/Build.pl script.
 #
 # Copyright 2009 Ge van Geldorp
 #
@@ -241,7 +241,7 @@ if (defined($ErrMessage))
              $FullErrFileName, $Job, $Step, $Task;
 }
 my $Script = "#!/bin/sh\n";
-$Script .= "$BinDir/BuildSingleTest.pl $FileName " . $Step->FileType .
+$Script .= "$BinDir/build/BuildSingleTest.pl $FileName " . $Step->FileType .
            " $BaseName 32";
 if ($Run64)
 {
diff --git a/testbot/bin/WineRunReconfig.pl b/testbot/bin/WineRunReconfig.pl
index 4aacd81..ae102e9 100755
--- a/testbot/bin/WineRunReconfig.pl
+++ b/testbot/bin/WineRunReconfig.pl
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -Tw
 #
 # Communicates with the build machine to have it perform the 'reconfig' task.
-# See the bin/Reconfig.pl script.
+# See the bin/build/Reconfig.pl script.
 #
 # Copyright 2009 Ge van Geldorp
 #
@@ -194,7 +194,7 @@ if (defined($ErrMessage))
   FatalError "Can't set VM status to running: $ErrMessage\n",
              $FullErrFileName, $Job, $Step, $Task;
 }
-my $Script = "#!/bin/sh\n$BinDir/Reconfig.pl\n";
+my $Script = "#!/bin/sh\n$BinDir/build/Reconfig.pl\n";
 $ErrMessage = $VM->RunScriptInGuestTimeout("", $Script, $Task->Timeout);
 if (defined($ErrMessage))
 {
@@ -212,10 +212,10 @@ if (defined($ErrMessage))
   FatalError "Can't copy log from VM: $ErrMessage\n", $FullErrFileName,
              $Job, $Step, $Task;
 }
-my $ReconfigSucceeded = ProcessRawlog($FullRawlogFileName, $FullLogFileName,
-                                      $FullErrFileName);
+my $Success = ProcessRawlog($FullRawlogFileName, $FullLogFileName,
+                              $FullErrFileName);
 
-if ($ReconfigSucceeded)
+if ($Success)
 {
   $ErrMessage = $VM->RemoveSnapshot($VM->IdleSnapshot);
   if (defined($ErrMessage))
diff --git a/testbot/bin/build/BuildSingleTest.pl b/testbot/bin/build/BuildSingleTest.pl
new file mode 100755
index 0000000..8d06614
--- /dev/null
+++ b/testbot/bin/build/BuildSingleTest.pl
@@ -0,0 +1,379 @@
+#!/usr/bin/perl -Tw
+#
+# Performs the 'build' task in the build machine. Specifically this applies a
+# conformance test patch, rebuilds the impacted test and retrieves the
+# resulting 32 and 64 bit binaries.
+#
+# Copyright 2009 Ge van Geldorp
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+
+use strict;
+
+my $Dir;
+sub BEGIN
+{
+  $main::BuildEnv = 1;
+  $0 =~ m=^(.*)/[^/]*$=;
+  $Dir = $1;
+}
+use lib "$Dir/../../lib";
+
+use WineTestBot::Config;
+
+sub InfoMsg
+{
+  my $oldumask = umask(002);
+  if (open LOGFILE, ">>$LogDir/BuildSingleTest.log")
+  {
+    print LOGFILE @_;
+    close LOGFILE;
+  }
+  umask($oldumask);
+}
+
+sub LogMsg
+{
+  my $oldumask = umask(002);
+  if (open LOGFILE, ">>$LogDir/BuildSingleTest.log")
+  {
+    print LOGFILE "BuildSingleTest: ", @_;
+    close LOGFILE;
+  }
+  umask($oldumask);
+}
+
+sub FatalError
+{
+  LogMsg @_;
+
+  exit 1;
+}
+
+sub ApplyPatch
+{
+  my ($PatchFile, $PatchType, $BaseName) = @_;
+
+  my $NeedMakefile = 0;
+  my $NeedMakeInclude = !1;
+  my $NeedBuildDeps = !1;
+  my $NeedImplib = !1;
+  my $NeedAutoconf = !1;
+  my $NeedConfigure = !1;
+  if (open (FH, "<$PatchFile"))
+  {
+    my $Line;
+    while (defined($Line = <FH>) &&
+           ($NeedMakefile == 0 || ! $NeedMakeInclude || ! $NeedBuildDeps ||
+            ! $NeedImplib || ! $NeedAutoconf || ! $NeedConfigure))
+    {
+      if ($Line =~ m=^diff.*tests/Makefile\.in=)
+      {
+        $NeedMakefile = 1;
+      }
+      elsif ($Line =~ m=^diff.*include/.*\.idl=)
+      {
+        $NeedMakeInclude = 1;
+      }
+      elsif ($Line =~ m=^diff.*\.spec=)
+      {
+        $NeedBuildDeps = 1;
+      }
+      elsif ($PatchType eq "dlls" && $Line =~ m=^diff.*$BaseName/Makefile\.in=)
+      {
+        $NeedImplib = 1;
+      }
+      elsif ($Line =~ m=^diff.*configure\.ac=)
+      {
+        $NeedAutoconf = 1;
+      }
+      elsif ($Line =~ m=^diff.*configure=)
+      {
+        $NeedConfigure = 1;
+      }
+    }
+    close FH;
+  }
+
+  InfoMsg "Applying patch\n";
+  system("git apply --verbose --directory=$DataDir/wine-git $PatchFile " .
+         ">> $LogDir/BuildSingleTest.log 2>&1");
+  if ($? != 0)
+  {
+    LogMsg "Patch failed to apply\n";
+    return (-1, $NeedMakeInclude, $NeedBuildDeps, $NeedImplib, $NeedConfigure);
+  }
+
+  if ($NeedAutoconf && ! $NeedConfigure)
+  {
+    InfoMsg "Running autoconf\n";
+    system("( cd $DataDir/wine-git && set -x && " .
+           "  autoconf --output configure configure.ac " .
+           ") >>$LogDir/BuildSingleTest.log 2>&1");
+    if ($? != 0)
+    {
+       LogMsg "Autoconf failed\n";
+       return (-1, $NeedMakeInclude, $NeedBuildDeps, $NeedImplib,
+               $NeedConfigure);
+    }
+    $NeedConfigure = 1;
+  }
+
+  if ($NeedImplib)
+  {
+    if (open (FH, "<$DataDir/wine-git/$PatchType/$BaseName/Makefile.in"))
+    {
+      $NeedImplib = !1;
+      my $Line;
+      while (defined($Line = <FH>) && ! $NeedImplib)
+      {
+        $NeedImplib = ($Line =~ m/^\s*IMPORTLIB\s*=.*$BaseName/)
+      }
+      close FH;
+    }
+  }
+
+  return ($NeedMakefile, $NeedMakeInclude, $NeedBuildDeps, $NeedImplib,
+          $NeedConfigure);
+}
+
+my $ncpus;
+sub CountCPUs()
+{
+    if (open(my $fh, "<", "/proc/cpuinfo"))
+    {
+        # Linux
+        map { $ncpus++ if (/^processor/); } <$fh>;
+        close($fh);
+    }
+    $ncpus ||= 1;
+}
+
+sub BuildTestExecutable
+{
+  my ($BaseName, $PatchType, $Bits, $NeedConfigure, $NeedMakefile,
+      $NeedMakeInclude, $NeedBuildDeps, $NeedImplib) = @_;
+
+  if ($NeedConfigure)
+  {
+    InfoMsg "Reconfigure $Bits-bit crossbuild\n";
+    my $Host = ($Bits == 64 ? "x86_64-w64-mingw32" : "i686-pc-mingw32");
+    system("( cd $DataDir/build-mingw$Bits && set -x && " .
+           "  ../wine-git/configure --host=$Host --with-wine-tools=../build-native --without-x --without-freetype " .
+           ") >>$LogDir/BuildSingleTest.log 2>&1");
+    if ($? != 0)
+    {
+      LogMsg "Reconfigure of $Bits-bit crossbuild failed\n";
+      return !1;
+    }
+  }
+
+  if ($NeedMakeInclude || $NeedConfigure)
+  {
+    InfoMsg "Recreating include/Makefile\n";
+    system("( cd $DataDir/build-mingw$Bits && set -x && " .
+           "  ./config.status --file include/Makefile:Make.vars.in:include/Makefile.in " .
+           ") >>$LogDir/BuildSingleTest.log 2>&1");
+    if ($? != 0)
+    {
+      LogMsg "Recreation of include/Makefile failed\n";
+      return !1;
+    }
+
+    system("( cd $DataDir/build-mingw$Bits && set -x && " .
+           "  make -j$ncpus include " .
+           ") >> $LogDir/BuildSingleTest.log 2>&1");
+    if ($? != 0)
+    {
+      LogMsg "Make in include dir failed\n";
+      return !1;
+    }
+  }
+
+  if ($NeedImplib || $NeedConfigure)
+  {
+    InfoMsg "Rebuilding $BaseName import lib\n";
+    system("( cd $DataDir/build-mingw$Bits && set -x && " .
+           "  ./config.status --file $PatchType/$BaseName/Makefile:Make.vars.in:$PatchType/$BaseName/Makefile.in " .
+           ") >>$LogDir/BuildSingleTest.log 2>&1");
+    if ($? != 0)
+    {
+      LogMsg "Unable to regenerate $PatchType/$BaseName/Makefile\n";
+    }
+    else
+    {
+      system("( cd $DataDir/build-mingw$Bits && set -x && " .
+             "  make -j$ncpus -C $PatchType/$BaseName lib$BaseName.a " .
+             ") >>$LogDir/BuildSingleTest.log 2>&1");
+      if ($? != 0)
+      {
+        InfoMsg "Make of import library failed\n";
+      }
+    }
+  }
+
+  if ($NeedMakefile || $NeedConfigure)
+  {
+    InfoMsg "Recreating tests/Makefile\n";
+    system("( cd $DataDir/build-mingw$Bits && set -x && " .
+           "  ./config.status --file $PatchType/$BaseName/tests/Makefile:Make.vars.in:$PatchType/$BaseName/tests/Makefile.in " .
+           ") >>$LogDir/BuildSingleTest.log 2>&1");
+    if ($? != 0)
+    {
+      LogMsg "Recreation of tests/Makefile failed\n";
+      return !1;
+    }
+  }
+
+  if ($NeedBuildDeps)
+  {
+    InfoMsg "Making build dependencies\n";
+    system("( cd $DataDir/build-mingw$Bits && set -x && " .
+           "  make -j$ncpus __builddeps__ " .
+           ") >>$LogDir/BuildSingleTest.log 2>&1");
+    if ($? != 0)
+    {
+      LogMsg "Making build dependencies failed\n";
+      return !1;
+    }
+  }
+
+  my $TestsDir = "$PatchType/$BaseName/tests";
+  my $TestExecutable = "$TestsDir/$BaseName";
+  if ($PatchType eq "programs")
+  {
+    $TestExecutable .= ".exe";
+  }
+  $TestExecutable .= "_test.exe";
+  unlink("$DataDir/build-mingw${Bits}/$TestExecutable");
+
+  InfoMsg "Making test executable\n";
+  system("( cd $DataDir/build-mingw$Bits && set -x && " .
+         "  make -j$ncpus -C $TestsDir " .
+         ") >>$LogDir/BuildSingleTest.log 2>&1");
+  if ($? != 0)
+  {
+    LogMsg "Make failed\n";
+    return !1;
+  }
+  if (! -f "$DataDir/build-mingw${Bits}/$TestExecutable")
+  {
+    LogMsg "Make didn't produce a $TestExecutable file\n";
+    return !1;
+  }
+
+  return 1;
+}
+
+$ENV{PATH} = "/usr/lib/ccache:/usr/bin:/bin";
+delete $ENV{ENV};
+
+# Start with clean logfile
+unlink("$LogDir/BuildSingleTest.log");
+
+my ($PatchFile, $PatchType, $BaseName, $BitIndicators) = @ARGV;
+if (! $PatchFile || ! $PatchType || ! $BaseName || !$BitIndicators)
+{
+  FatalError "Usage: BuildSingleTest.pl <patchfile> <patchtype> <basename> <bits>\n";
+}
+
+# Untaint parameters
+if ($PatchFile =~ m/^([\w_.\-]+)$/)
+{
+  $PatchFile = "$DataDir/staging/$1";
+  if (! -r $PatchFile)
+  {
+    FatalError "Patch file $PatchFile not readable\n";
+  }
+}
+else
+{
+  FatalError "Invalid patch file $PatchFile\n";
+}
+
+if ($PatchType =~ m/^patch(dlls|programs)$/)
+{
+  $PatchType = $1;
+}
+else
+{
+  FatalError "Invalid patch type $PatchType\n";
+}
+
+if ($BaseName =~ m/^([\w_.\-]+)$/)
+{
+  $BaseName = $1;
+}
+else
+{
+  FatalError "Invalid DLL base name $BaseName\n";
+}
+
+my $Run32 = !1;
+my $Run64 = !1;
+if ($BitIndicators =~ m/^([\d,]+)$/)
+{
+  my @Bits = split /,/, $1;
+  foreach my $BitsValue (@Bits)
+  {
+    if ($BitsValue == 32)
+    {
+      $Run32 = 1;
+    }
+    elsif ($BitsValue == 64)
+    {
+      $Run64 = 1;
+    }
+    else
+    {
+      FatalError "Invalid number of bits $BitsValue\n";
+    }
+  }
+  if (! $Run32 && ! $Run64)
+  {
+    FatalError "Specify at least one of 32 or 64 bits\n";
+  }
+}
+else
+{
+  FatalError "Invalid number of bits $BitIndicators\n";
+}
+
+my ($NeedMakefile, $NeedMakeInclude, $NeedBuildDeps, $NeedImplib,
+    $NeedConfigure) = ApplyPatch($PatchFile, $PatchType, $BaseName);
+if ($NeedMakefile < 0)
+{
+  exit(1);
+}
+
+CountCPUs();
+
+if ($Run32 && ! BuildTestExecutable($BaseName, $PatchType, 32,
+                                    $NeedConfigure, 0 < $NeedMakefile,
+                                    $NeedMakeInclude, $NeedBuildDeps,
+                                    $NeedImplib))
+{
+  exit(1);
+}
+if ($Run64 && ! BuildTestExecutable($BaseName, $PatchType, 64,
+                                    $NeedConfigure, 0 < $NeedMakefile,
+                                    $NeedMakeInclude, $NeedBuildDeps,
+                                    $NeedImplib))
+{
+  exit(1);
+}
+
+LogMsg "ok\n";
+exit;
diff --git a/testbot/bin/build/Reconfig.pl b/testbot/bin/build/Reconfig.pl
new file mode 100755
index 0000000..c3f8eb4
--- /dev/null
+++ b/testbot/bin/build/Reconfig.pl
@@ -0,0 +1,142 @@
+#!/usr/bin/perl -Tw
+#
+# Performs the 'reconfig' task in the build machine. Specifically this updates
+# the build machine's Wine repository, re-runs configure, and rebuilds the
+# 32 and 64 bit winetest binaries.
+#
+# Copyright 2009 Ge van Geldorp
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+
+use strict;
+
+my $Dir;
+sub BEGIN
+{
+  $main::BuildEnv = 1;
+  $0 =~ m=^(.*)/[^/]*$=;
+  $Dir = $1;
+}
+use lib "$Dir/../../lib";
+
+use WineTestBot::Config;
+
+sub LogMsg
+{
+  my $oldumask = umask(002);
+  if (open LOGFILE, ">>$LogDir/Reconfig.log")
+  {
+    print LOGFILE "Reconfig: ", @_;
+    close LOGFILE;
+  }
+  umask($oldumask);
+}
+
+sub FatalError
+{
+  LogMsg @_;
+
+  exit 1;
+}
+
+sub GitPull
+{
+  system("cd $DataDir/wine-git && git pull >> $LogDir/Reconfig.log 2>&1");
+  if ($? != 0)
+  {
+    LogMsg "Git pull failed\n";
+    return !1;
+  }
+
+  return 1;
+}
+
+my $ncpus;
+sub CountCPUs()
+{
+    if (open(my $fh, "<", "/proc/cpuinfo"))
+    {
+        # Linux
+        map { $ncpus++ if (/^processor/); } <$fh>;
+        close($fh);
+    }
+    $ncpus ||= 1;
+}
+
+sub BuildNative
+{
+  mkdir "$DataDir/build-native" if (! -d "$DataDir/build-native");
+  system("( cd $DataDir/build-native && set -x && " .
+         "  rm -rf * && " .
+         "  time ../wine-git/configure --enable-win64 --without-x --without-freetype && " .
+         "  time make -j$ncpus depend && " .
+         "  time make -j$ncpus __tooldeps__ " .
+         ") >>$LogDir/Reconfig.log 2>&1");
+
+  if ($? != 0)
+  {
+    LogMsg "Build native failed\n";
+    return !1;
+  }
+
+  return 1;
+}
+
+sub BuildCross
+{
+  my $Bits = $_[0];
+
+  my $Host = ($Bits == 64 ? "x86_64-w64-mingw32" : "i686-w64-mingw32");
+  mkdir "$DataDir/build-mingw$Bits" if (! -d "$DataDir/build-mingw$Bits");
+  system("( cd $DataDir/build-mingw$Bits && set -x && " .
+         "  rm -rf * && " .
+         "  time ../wine-git/configure --host=$Host --with-wine-tools=../build-native --without-x --without-freetype && " .
+         "  time make -j$ncpus depend  && " .
+         "  time make -j$ncpus programs/winetest " .
+         ") >>$LogDir/Reconfig.log 2>&1");
+  if ($? != 0)
+  {
+    LogMsg "Build cross ($Bits bits) failed\n";
+    return !1;
+  }
+
+  return 1;
+}
+
+$ENV{PATH} = "/usr/lib/ccache:/usr/bin:/bin";
+delete $ENV{ENV};
+
+# Start with clean logfile
+unlink("$LogDir/Reconfig.log");
+
+if (! GitPull())
+{
+  exit(1);
+}
+
+CountCPUs();
+
+if (! BuildNative())
+{
+  exit(1);
+}
+
+if (! BuildCross(32) || ! BuildCross(64))
+{
+  exit(1);
+}
+
+LogMsg "ok\n";
+exit;
-- 
1.7.10.4




More information about the wine-patches mailing list