[cig-commits] r7540 - in cs/buildbot/trunk: bin buildbot buildbot/scripts

leif at geodynamics.org leif at geodynamics.org
Wed Jun 27 17:53:31 PDT 2007


Author: leif
Date: 2007-06-27 17:53:31 -0700 (Wed, 27 Jun 2007)
New Revision: 7540

Added:
   cs/buildbot/trunk/bin/mkpetscdlls
   cs/buildbot/trunk/buildbot/scripts/windows.py
Modified:
   cs/buildbot/trunk/buildbot/bs.py
   cs/buildbot/trunk/buildbot/scripts/packager.py
Log:
Incorporated my 'mkpetscdlls' script into BuildBot.

PETSc doesn't support building DLLs on Windows.  The 'configure.py'
option '--enable-shared' is ignored.  Satish says that whatever
user-contributed code is there doesn't work.

The 'mkpetscdlls' script is a quick-and-dirty script I wrote which
simply extracts the .o files from PETSc's archive libraries, and links
them into DLLs.  (One can get away with this because all code on
Windows is PIC, and Cygwin's GCC automatically exports all non-static
symbols.)


Added: cs/buildbot/trunk/bin/mkpetscdlls
===================================================================
--- cs/buildbot/trunk/bin/mkpetscdlls	2007-06-27 23:19:26 UTC (rev 7539)
+++ cs/buildbot/trunk/bin/mkpetscdlls	2007-06-28 00:53:31 UTC (rev 7540)
@@ -0,0 +1,4 @@
+#!/usr/bin/python
+
+from buildbot.scripts import windows
+windows.mkpetscdlls()


Property changes on: cs/buildbot/trunk/bin/mkpetscdlls
___________________________________________________________________
Name: svn:executable
   + *

Modified: cs/buildbot/trunk/buildbot/bs.py
===================================================================
--- cs/buildbot/trunk/buildbot/bs.py	2007-06-27 23:19:26 UTC (rev 7539)
+++ cs/buildbot/trunk/buildbot/bs.py	2007-06-28 00:53:31 UTC (rev 7540)
@@ -227,6 +227,34 @@
               env=env,
               timeout=3600, # Building Sieve takes a long time...
               ),
+            ]
+
+        if env['PETSC_ARCH'].startswith("cygwin-"):
+            # PETSc ignores "--enable-shared" on Windows.  Satish
+            # says: "Because it currently doesn't work. There is some
+            # code contributed here [cygwin_shared target] - I'll have
+            # to check it out again.. Also there is this issue that
+            # windows .dll files require stub libraries to function,
+            # and the LD_LIBRARY_PATH equvalent is PATH. Our current
+            # model doesn't accomodate these 2 deviations - so it
+            # might need extra steps on the users part to get this
+            # working.."
+
+            # So, we roll our own PETSc DLLs.  See mkpetscdlls() in
+            # buildbot.scrips.windows.
+
+            steps.extend([
+                s(step.ShellCommand,
+                  description=["building DLLs"] + desc,
+                  descriptionDone=desc + ["DLL build"],
+                  command=["mkpetscdlls"],
+                  workdir=workdir,
+                  env=env,
+                  haltOnFailure=True,
+                  ),
+                ])
+        
+        steps.extend([
             s(step.ShellCommand,
               description=["being paranoid"] + desc,
               descriptionDone=desc + ["paranoia"],
@@ -283,7 +311,7 @@
               env=env,
               haltOnFailure=True,
               ),
-            ]
+            ])
         
         return steps
 

Modified: cs/buildbot/trunk/buildbot/scripts/packager.py
===================================================================
--- cs/buildbot/trunk/buildbot/scripts/packager.py	2007-06-27 23:19:26 UTC (rev 7539)
+++ cs/buildbot/trunk/buildbot/scripts/packager.py	2007-06-28 00:53:31 UTC (rev 7540)
@@ -57,14 +57,14 @@
             stripList.extend(libs)
             self.libraries.extend(libs)
         if petsc:
-            if opSys == "win":
-                l = libglob % "petsc"
-            else:
-                petsc_arch = os.environ['PETSC_ARCH']
-                petsc_libglob = "opt/" + petsc + "/" + petsc_arch + "/" + libglob
-                l = petsc_libglob % ""
+            petsc_arch = os.environ['PETSC_ARCH']
+            petsc_libglob = "opt/" + petsc + "/" + petsc_arch + "/" + libglob
+            l = petsc_libglob % ""
             libs = glob(l)
             stripList.extend(libs)
+            if opSys == "win":
+                # Install DLLs under 'bin'.
+                libs = [(dll, "bin") for dll in libs]
             self.libraries.extend(libs)
 
         self.misc = []

Added: cs/buildbot/trunk/buildbot/scripts/windows.py
===================================================================
--- cs/buildbot/trunk/buildbot/scripts/windows.py	2007-06-27 23:19:26 UTC (rev 7539)
+++ cs/buildbot/trunk/buildbot/scripts/windows.py	2007-06-28 00:53:31 UTC (rev 7540)
@@ -0,0 +1,79 @@
+#!/usr/bin/env python
+
+
+import os, sys
+from popen2 import Popen4
+
+
+def spawn(*argv):
+    status = os.spawnvp(os.P_WAIT, argv[0], argv)
+    if status != 0:
+        statusMsg = "%s: %s: exit %d" % (sys.argv[0], argv[0], status)
+        sys.exit(statusMsg)
+    return
+
+
+def ospawn(*argv):
+    print ' '.join(argv)
+    child = Popen4(argv)
+
+    child.tochild.close()
+
+    output = child.fromchild.readlines()
+    status = child.wait()
+
+    exitStatus = None
+    if (os.WIFSIGNALED(status)):
+        statusStr = "signal %d" % os.WTERMSIG(status)
+    elif (os.WIFEXITED(status)):
+        exitStatus = os.WEXITSTATUS(status)
+        statusStr = "exit %d" % exitStatus
+    else:
+        statusStr = "status %d" % status
+    if exitStatus != 0:
+        sys.exit("%s: %s: %s" % (sys.argv[0], argv[0], statusStr))
+
+    return output
+
+
+def mkpetscdlls():
+    cxx = os.environ['CXX']
+    petsc_dir = os.getcwd()
+    petsc_arch = os.environ['PETSC_ARCH']
+    petsc_lib = petsc_dir + "/" + petsc_arch + "/lib"
+    petsc_bin = petsc_dir + "/" + petsc_arch + "/bin"
+
+    os.chdir(petsc_lib)
+
+    # from PETSC_LIBS:
+    #     -lpetscts -lpetscsnes -lpetscksp -lpetscdm -lpetscmat -lpetscvec -lpetsc
+    #     -lchaco -llapack -lblas -ldl
+    #     -lmpich -lfrtbegin -lg2c
+    #     -lcygwin -luser32 -ladvapi32 -lshell32 -lmpichcxx -lstdc++ -lgdi32 -luser32 -ladvapi32 -lkernel32 -ldl
+
+    # libs, in order
+    libs = ["petscts", "petscsnes", "petscksp", "petscdm", "petscmat", "petscvec", "petsc", "chaco"]
+    deps = ["-llapack", "-lblas", "-lgdi32", "-lg2c"]
+
+    while libs:
+        l = libs.pop()
+        archive = "lib" + l + ".a"
+        dll = petsc_bin + "/" + l + ".dll"
+        implib = "lib" + l + ".dll.a"
+        
+        output = ospawn("ar", "xv", archive)
+        objs = [line.split()[2] for line in output]
+
+        # NYI: assumes GCC
+        link = [cxx, "-shared", "-o", dll, "-Wl,--out-implib," + implib, "-L."] + objs + deps
+        spawn(*link)
+
+        spawn("rm", *objs)
+
+        deps.insert(0, "-l" + l)
+        
+    return
+
+
+if __name__ == "__main__":
+    mkpetscdlls()


Property changes on: cs/buildbot/trunk/buildbot/scripts/windows.py
___________________________________________________________________
Name: svn:executable
   + *



More information about the cig-commits mailing list