[cig-commits] commit: Forgot to update StgSCons and the

Mercurial hg at geodynamics.org
Mon Nov 24 11:22:55 PST 2008


changeset:   54:3404438a3a54
user:        LukeHodkinson
date:        Thu Mar 27 23:10:18 2008 +0000
files:       StgSCons config/SConfig/packages/PETScExt.py
description:
Forgot to update StgSCons and the
PETScExt package.


diff -r 35a6b29fa76a -r 3404438a3a54 StgSCons
--- a/StgSCons	Thu Mar 27 23:06:19 2008 +0000
+++ b/StgSCons	Thu Mar 27 23:10:18 2008 +0000
@@ -14,6 +14,16 @@ def glob(env, ptrn):
         os.chdir(old)
     else:
         res = pyglob.glob(ptrn)
+    return res
+
+def path_exists(env, path):
+    if not os.path.isabs(path):
+        old = os.getcwd()
+        os.chdir(Dir('.').srcnode().abspath)
+        res = os.path.exists(path)
+        os.chdir(old)
+    else:
+        res = os.path.exists(path)
     return res
 
 # Normalise an SCons path to the project root.
@@ -44,6 +54,7 @@ def copy_file(env, dst, src):
 
 # Add to the SCons main class.
 SConsEnvironment.glob = glob
+SConsEnvironment.path_exists = path_exists
 SConsEnvironment.norm_path = norm_path
 SConsEnvironment.copy_file = copy_file
 
@@ -101,12 +112,15 @@ def copy_includes(env, files, dst, inc_n
 def copy_includes(env, files, dst, inc_nodes, force=False):
     files = to_list(files)
     dst = os.path.join(env['buildPath'], dst)
+    nodes = []
     for i in files:
         node = env.Install(dst, i)
+        nodes.append(node)
         inc_nodes.append(node)
         if force:
             dst_path = os.path.join(dst, os.path.basename(i))
             env.copy_file(dst_path, i)
+    return nodes
 
 #
 # Builder helpers.
@@ -116,12 +130,12 @@ def get_target_name(env, src, suffix='.c
     return os.path.join(env['buildPath'], env.project_name, src[:-len(suffix)])
 
 def build_defines(env, files, dst):
-    copy_includes(env, files, os.path.join('include', dst), 
+    copy_includes(env, files, os.path.join('include', dst),
                   env.def_nodes, True)
 
 def build_headers(env, files, dst, force_copy=False):
-    copy_includes(env, files, os.path.join('include', dst),
-                  env.hdr_nodes, force_copy)
+    return copy_includes(env, files, os.path.join('include', dst),
+                         env.hdr_nodes, force_copy)
 
 def build_xmls(env, files, dst, force_copy=False):
     copy_includes(env, files, os.path.join('lib', dst),
@@ -155,14 +169,15 @@ def build_library(env, objs, name, libs=
 def build_library(env, objs, name, libs=[], force_name=False):
     objs = to_list(objs)
     dst = os.path.join(env['buildPath'], 'lib', name)
-    if force_name:
-        cur_node = env.library_builder(
-            dst, objs,
-            SHLIBPREFIX='',
-            LIBPREFIXES=[env['LIBPREFIXES']] + [''],
-	    LIBS=libs + env.get('LIBS', []))
-    else:
-        cur_node = env.library_builder(dst, objs, LIBS=libs + env.get('LIBS', []))
+    for b in env.library_builders:
+        if force_name:
+            cur_node = b(
+                dst, objs,
+                SHLIBPREFIX='',
+                LIBPREFIXES=[env['LIBPREFIXES']] + [''],
+                LIBS=libs + env.get('LIBS', []))
+        else:
+            cur_node = b(dst, objs, LIBS=libs + env.get('LIBS', []))
     env.lib_nodes.insert(0, cur_node)
 
 def build_tests(env, files, name, sup_objs=[], libs=None):
@@ -183,12 +198,14 @@ def build_tests(env, files, name, sup_ob
                                LIBS=l + env.get('LIBS', []))
         nodes.append(cur_node)
 
-def build_directory(env, dir, extra_objs=[],
-                    test_libs=None, build_lib=True):
-    if not test_libs:
-        test_libs = env.lib_nodes
-    test_libs = to_list(test_libs)
-    extra_objs = to_list(extra_objs)
+def build_suites(env, sources):
+    sources = to_list(sources)
+    for src in sources:
+        tgt = get_target_name(env, src)
+        obj_node = env.SharedObject(tgt, src)
+        env.suite_nodes += obj_node
+
+def build_directory(env, dir, build_lib=False):
     srcDir = os.path.join(dir, 'src')
     tstDir = os.path.join(dir, 'tests')
     hdrDir = os.path.join(env.project_name, dir)
@@ -200,15 +217,18 @@ def build_directory(env, dir, extra_objs
     env.build_objects(env.glob(os.path.join(srcDir, '*.c')), dir)
     if build_lib:
         objs = env.get_hnodes(env.SharedObject, dir)
-        env.build_library(objs + extra_objs, mod)
-    if os.path.exists(tstDir):
+        env.build_library(objs, mod)
+    if env.path_exists(tstDir):
         tst_files = env.glob(os.path.join(tstDir, 'test*.c'))
+        suites = env.glob(os.path.join(tstDir, '*Suite.c'))
         sup_gen = env.glob(os.path.join(tstDir, '*.c'))
-        sup_files = [f for f in sup_gen if f not in tst_files]
+        sup_files = [f for f in sup_gen if f not in tst_files + suites]
         sup = env.build_objects(sup_files, dir, False)
         env.build_tests(tst_files, mod,
                         sup_objs=sup,
-                        libs=test_libs + [mod])
+                        libs=[env.project_name])
+        if suites:
+            env.build_suites(suites)
 
 def build_plugin(env, dir, hpath, prefix=True):
     name = hpath.split(os.path.sep)
@@ -222,12 +242,53 @@ def build_plugin(env, dir, hpath, prefix
                          hpath, False)
     env.build_library(objs, name, [env.project_name], True)
 
+def build_suite_runner(env):
+    hdrs = ""
+    suites = ""
+    for node in env.suite_nodes:
+        name = node.path[node.path.rfind(os.path.sep) + 1:node.path.rfind('.')]
+        suites += "pcu_runner_addSuite( %s );\n" % name
+        name = node.path[len(env['buildPath']):node.path.rfind('.')]
+        hdrs += "#include \"%s.h\"" % name
+    src = """#include <stdlib.h>
+#include <mpi.h>
+#include "StGermain/pcu/pcu.h"
+%s
+
+int main( int argc, char* argv[] ) {
+   pcu_listener_t* lsnr;
+
+   MPI_Init( &argc, &argv );
+   StGermain_Init( &argc, &argv );
+   pcu_runner_init( argc, argv );
+
+   %s
+   lsnr = pcu_textoutput_create();
+   pcu_runner_run( lsnr );
+   pcu_runner_finalise();
+   pcu_textoutput_destroy( lsnr );
+   StGermain_Finalise();
+   MPI_Finalize();
+   return EXIT_SUCCESS;
+}
+""" % (hdrs, suites)
+    src_filename = os.path.join(env["buildPath"], env.project_name, 
+                                "test" + env.project_name + ".c")
+    f = open(File(src_filename).path, "w")
+    f.write(src)
+    f.close()
+    bin_filename = os.path.join(env["buildPath"], "bin", "test" + env.project_name)
+    env.Program(bin_filename, [File(src_filename)] + env.suite_nodes,
+                CPPPATH=["#."] + env.get("CPPPATH", []),
+                LIBS=[env.project_name] + env.get("LIBS", []))
+
 def clear_all(env):
     env.hclear()
     env.def_nodes = []
     env.hdr_nodes = []
     env.lib_nodes = []
     env.test_nodes = []
+    env.suite_nodes = []
 
 SConsEnvironment.build_defines = build_defines
 SConsEnvironment.build_headers = build_headers
@@ -236,8 +297,10 @@ SConsEnvironment.build_metadata = build_
 SConsEnvironment.build_metadata = build_metadata
 SConsEnvironment.build_library = build_library
 SConsEnvironment.build_tests = build_tests
+SConsEnvironment.build_suites = build_suites
 SConsEnvironment.build_directory = build_directory
 SConsEnvironment.build_plugin = build_plugin
+SConsEnvironment.build_suite_runner = build_suite_runner
 SConsEnvironment.clear_all = clear_all
 
 #
diff -r 35a6b29fa76a -r 3404438a3a54 config/SConfig/packages/PETScExt.py
--- a/config/SConfig/packages/PETScExt.py	Thu Mar 27 23:06:19 2008 +0000
+++ b/config/SConfig/packages/PETScExt.py	Thu Mar 27 23:10:18 2008 +0000
@@ -2,9 +2,9 @@ import SConfig
 import SConfig
 
 class PETScExt(SConfig.Package):
-    def __init__(self, env, options):
+    def __init__(self, scons_env, scons_opts, required=False):
         SConfig.Package.__init__(self, env, options)
-        self.pkg_petsc = self.dependency(SConfig.packages.PETSc)
+        self.petsc = self.dependency(SConfig.packages.PETSc)
         self.base_patterns = ['petscext*', 'PETSCEXT*', 'PETScExt*']
         self.header_sub_dir = 'petsc'
         self.headers = [['petscext.h',
@@ -14,28 +14,27 @@ class PETScExt(SConfig.Package):
                            'petscext_mat', 'petscext_vec',
                            'petscext_utils']]
         self.require_shared = True
-        self.use_rpath = True
-        self.have_define = 'HAVE_PETSCEXT'
 
-    def validate_location(self, location):
-        # Just use whatever architecture PETSc uses.
-        arch = self.pkg_petsc.arch
-        self.arch = arch
+    def generate_locations(self):
+        for loc in SConfig.Package.generate_locations(self):
+            # Just use whatever architecture PETSc uses.
+            arch = self.pkg_petsc.arch
+            self.arch = arch
 
-        # Add the bmake/arch include directory.
-        hdr_dir = os.path.join('bmake', arch)
-        if not os.path.exists(os.path.join(location[0], hdr_dir)):
-            return [0, '', 'No bmake/<arch> directory.']
-        if hdr_dir not in location[1]:
-            location[1] += [hdr_dir]
+            # Add the bmake/arch include directory.
+            hdr_dir = os.path.join('bmake', arch)
+            if not os.path.exists(os.path.join(location[0], hdr_dir)):
+                continue
+            if hdr_dir not in location[1]:
+                location[1] += [hdr_dir]
 
-        # Add the lib/arch library directory.
-        if 'lib' in location[2]:
-            location[2].remove('lib')
-        lib_dir = os.path.join('lib', arch)
-        if not os.path.exists(os.path.join(location[0], lib_dir)):
-            return [0, '', 'No lib/<arch> directory.']
-        if lib_dir not in location[2]:
-            location[2] += [lib_dir]
+            # Add the lib/arch library directory.
+            if 'lib' in location[2]:
+                location[2].remove('lib')
+            lib_dir = os.path.join('lib', arch)
+            if not os.path.exists(os.path.join(location[0], lib_dir)):
+                continue
+            if lib_dir not in location[2]:
+                location[2] += [lib_dir]
 
-        return [1, '', '']
+            yield loc



More information about the CIG-COMMITS mailing list