[cig-commits] commit: Shuffling some things around to make it all

Mercurial hg at geodynamics.org
Mon Nov 24 11:30:49 PST 2008


changeset:   75:310dacff26a8
user:        LukeHodkinson
date:        Wed Mar 05 01:18:50 2008 +0000
files:       config/SConfig/Package.py config/SConfig/packages/BlasLapack.py config/SConfig/packages/MPI.py config/SConfig/packages/PETSc.py
description:
Shuffling some things around to make it all
a bit clearer. Also, fixed a minor bug with
search paths.


diff -r b00f7e3fa3bc -r 310dacff26a8 config/SConfig/Package.py
--- a/config/SConfig/Package.py	Wed Mar 05 01:15:24 2008 +0000
+++ b/config/SConfig/Package.py	Wed Mar 05 01:18:50 2008 +0000
@@ -70,17 +70,6 @@ class Package(object):
         self.env = env
         self.opts = options
 
-    def __str__(self):
-        str =  'Package name:  %s\n' % self.name
-        str += 'Found:         %s\n' % self.result[0]
-        str += 'Base path:     %s\n' % self.base_dir
-        str += 'Header paths:  %s\n' % self.hdr_dirs
-        str += 'Library paths: %s\n' % self.lib_dirs
-        str += 'Libraries:     %s\n' % self.libs
-        str += 'Have shared:   %s\n' % self.have_shared
-        str += 'Frameworks:    %s\n' % self.fworks
-        return str
-
     def setup_search_defaults(self):
         # Set common defaults of Darwin and Linux.
         if self.system in ['Darwin', 'Linux']:
@@ -91,8 +80,11 @@ class Package(object):
             if self.bits == 64:
                 if self.header_sub_dir:
                     self.sub_dirs = [[[os.path.join('include', self.header_sub_dir)],
-                                      ['lib64']]] + self.sub_dirs
-                self.sub_dirs = [[['include'], ['lib64']]] + self.sub_dirs
+                                      ['lib64']],
+                                     [[os.path.join('include', self.header_sub_dir)],
+                                      [os.path.join('lib', '64')]]] + self.sub_dirs
+                self.sub_dirs = [[['include'], ['lib64']],
+                                 [['include'], [os.path.join('lib', '64')]]] + self.sub_dirs
 
         # Set Darwin specific defaults.
         if self.system == 'Darwin':
@@ -122,12 +114,155 @@ class Package(object):
              '%s framework' % self.name,
              None, None))
 
-    def run_source(self, source):
-        """At this point we know all our construction environment has been set up,
-        so we should be able to build and run the application."""
-        result = self.run_scons_cmd(self.ctx.TryRun, source, '.c')
-        msg = self.get_run_error_message(result[1])
-        return [result[0][0], result[0][1], msg]
+    def get_headers_error_message(self, console):
+        return ''
+
+    def get_run_error_message(self, console):
+        return ''
+
+    def configure(self, configure_context):
+        """Perform the configuration of this package. Override this method to perform
+        custom configuration checks."""
+        # If we've already configured this package, just return.
+        if self.configured:
+            return
+
+        # Setup our configure context and environment.
+        self.ctx = configure_context
+        self.configured = True
+
+        # Process dependencies first.
+        self.process_dependencies()
+
+        # Perfrom actual configuration.
+        for check in self.checks:
+            result = check()
+            if not result[0]:
+                break
+
+        # Required?
+        if self.required and not result[0]:
+            self.env.Exit()
+
+        # If we succeeded, store the resulting environment.
+        if result[0]:
+            if self.have_define:
+                self.cpp_defines += [self.have_define]
+            self.build_state()
+            self.push_state(self.state)
+
+        return result
+
+    def setup_dependencies(self):
+        # If the package doesn't yet exist, create it.
+        for pkg_module in self.dependencies:
+            if pkg_module not in self.env.packages:
+                self.env.Package(pkg_module, self.opts)
+
+    def process_dependencies(self):
+        """Ensure all dependencies have been configured before this package."""
+        for pkg_module in self.dependencies:
+            # Configure the dependency now.
+            pkg = self.env.packages[pkg_module]
+            pkg.sconf = self.sconf
+            pkg.configure(self.ctx)
+
+    def find_package(self):
+        # Search for package locations.
+        self.ctx.Message('Checking for package %s ... ' % self.name)
+        self.ctx.Display('\n   Searching locations:\n')
+        for loc in self.generate_locations():
+            result = self.check_location(loc)
+            self.ctx.Display('      %s\n' % str(loc))
+
+            # If we succeeded, back out here.
+            if result[0]:
+                break
+
+            # Display an error message.
+            if result[2]:
+                self.ctx.Display('         %s\n' % result[2])
+
+        # Display results.
+        self.ctx.Display('   ')
+        self.ctx.Result(result[0])
+
+        return result
+
+    def check_location(self, location):
+        """Check if the currently selected location is a valid installation of the
+        required package. At this stage we know that the paths given in the location
+        actually exist."""
+        # Validate the headers, first.
+        result = self.validate_location(location)
+        if not result[0]:
+            return result
+
+        # Construct our path state.
+        path_state = self.build_header_state(location)
+        old = self.push_state(path_state)
+
+        # Check for the headers.
+        result = self.check_headers(location)
+        if not result[0]:
+            self.pop_state(old)
+            return result
+
+        # Scan each set of libraries in turn.
+        libs = []
+        for libs in self.libraries:
+            result = self.check_libs(location, libs)
+            if result[0]:
+                break
+
+        # Store last known configuration.
+        self.store_result(result, location, libs)
+
+        # Roll-back on state.
+        self.pop_state(old)
+        return result
+
+    def check_headers(self, location):
+        """Determine if the required headers are available with the current construction
+        environment settings."""
+        src = self.get_header_source()
+        result = self.run_scons_cmd(self.ctx.TryCompile, src, '.c')
+        msg = self.get_headers_error_message(result[1])
+        if not msg:
+            msg = 'Failed to locate headers.'
+        return [result[0], '', msg]
+
+    def check_libs(self, location, libs):
+        """Check if the currently selected location is a valid installation of the
+        required package. At this stage we know that the paths given in the location
+        actually exist and we need to confirm that the libraries in 'libs' exist."""
+        # Validate the libraries.
+        result = self.validate_libraries(location, libs)
+        if not result[0]:
+            return result
+
+        # Construct the library state.
+        lib_state = self.build_lib_state(location, libs)
+        old = self.push_state(lib_state)
+
+        # Check that we can link against the libraries by trying to link against
+        # a particular set of symbols.
+        result = self.check_symbols()
+        if not result[0]:
+            if not result[2]:
+                result[2] = 'Failed to link against library(s).'
+            self.pop_state(old)
+            return result
+
+        # Check if we have shared libraries.
+        if self.require_shared:
+            result = self.check_shared(location, libs)
+            if not result[0] and not result[2]:
+                result[2] = 'No shared library(s) available.'
+
+        # Roll-back on our state.
+        self.pop_state(old)
+        return result
 
     def check_symbols(self):
         """We have our paths and libraries setup, now we need to see if we can find
@@ -145,155 +280,12 @@ class Package(object):
         # TODO
         return [1, '', '']
 
-    def check_libs(self, location, libs):
-        """Check if the currently selected location is a valid installation of the
-        required package. At this stage we know that the paths given in the location
-        actually exist and we need to confirm that the libraries in 'libs' exist."""
-        # Validate the libraries.
-        result = self.validate_libraries(location, libs)
-        if not result[0]:
-            return result
-
-        # Construct the library state.
-        lib_state = self.build_lib_state(location, libs)
-        old = self.push_state(lib_state)
-
-        # Check that we can link against the libraries by trying to link against
-        # a particular set of symbols.
-        result = self.check_symbols()
-        if not result[0]:
-            if not result[2]:
-                result[2] = 'Failed to link against library(s).'
-            self.pop_state(old)
-            return result
-
-        # Check if we have shared libraries.
-        if self.require_shared:
-            result = self.check_shared(location, libs)
-            if not result[0] and not result[2]:
-                result[2] = 'No shared library(s) available.'
-
-        # Roll-back on our state.
-        self.pop_state(old)
-        return result
-
-    def check_headers(self, location):
-        """Determine if the required headers are available with the current construction
-        environment settings."""
-        src = self.get_header_source()
-        result = self.run_scons_cmd(self.ctx.TryCompile, src, '.c')
-        msg = self.get_headers_error_message(result[1])
-        if not msg:
-            msg = 'Failed to locate headers.'
-        return [result[0], '', msg]
-
-    def check_location(self, location):
-        """Check if the currently selected location is a valid installation of the
-        required package. At this stage we know that the paths given in the location
-        actually exist."""
-        # Validate the headers, first.
-        result = self.validate_location(location)
-        if not result[0]:
-            return result
-
-        # Construct our path state.
-        path_state = self.build_header_state(location)
-        old = self.push_state(path_state)
-
-        # Check for the headers.
-        result = self.check_headers(location)
-        if not result[0]:
-            self.pop_state(old)
-            return result
-
-        # Scan each set of libraries in turn.
-        libs = []
-        for libs in self.libraries:
-            result = self.check_libs(location, libs)
-            if result[0]:
-                break
-
-        # Store last known configuration.
-        self.store_result(result, location, libs)
-
-        # Roll-back on state.
-        self.pop_state(old)
-        return result
-
-    def get_headers_error_message(self, console):
-        return ''
-
-    def get_run_error_message(self, console):
-        return ''
-
-    def configure(self, configure_context):
-        """Perform the configuration of this package. Override this method to perform
-        custom configuration checks."""
-        # If we've already configured this package, just return.
-        if self.configured:
-            return
-
-        # Setup our configure context and environment.
-        self.ctx = configure_context
-        self.configured = True
-
-        # Process dependencies first.
-        self.process_dependencies()
-
-        # Perfrom actual configuration.
-        for check in self.checks:
-            result = check()
-            if not result[0]:
-                break
-
-        # Required?
-        if self.required and not result[0]:
-            self.env.Exit()
-
-        # If we succeeded, store the resulting environment.
-        if result[0]:
-            if self.have_define:
-                self.cpp_defines += [self.have_define]
-            self.build_state()
-            self.push_state(self.state)
-
-        return result
-
-    def find_package(self):
-        # Search for package locations.
-        self.ctx.Message('Checking for package %s ... ' % self.name)
-        self.ctx.Display('\n   Searching locations:\n')
-        for loc in self.generate_locations():
-            result = self.check_location(loc)
-            self.ctx.Display('      %s\n' % str(loc))
-
-            # If we succeeded, back out here.
-            if result[0]:
-                break
-
-            # Display an error message.
-            if result[2]:
-                self.ctx.Display('         %s\n' % result[2])
-
-        # Display results.
-        self.ctx.Display('   ')
-        self.ctx.Result(result[0])
-
-        return result
-
-    def setup_dependencies(self):
-        # If the package doesn't yet exist, create it.
-        for pkg_module in self.dependencies:
-            if pkg_module not in self.env.packages:
-                self.env.Package(pkg_module, self.opts)
-
-    def process_dependencies(self):
-        """Ensure all dependencies have been configured before this package."""
-        for pkg_module in self.dependencies:
-            # Configure the dependency now.
-            pkg = self.env.packages[pkg_module]
-            pkg.sconf = self.sconf
-            pkg.configure(self.ctx)
+    def run_source(self, source):
+        """At this point we know all our construction environment has been set up,
+        so we should be able to build and run the application."""
+        result = self.run_scons_cmd(self.ctx.TryRun, source, '.c')
+        msg = self.get_run_error_message(result[1])
+        return [result[0][0], result[0][1], msg]
 
     def validate_location(self, location):
         """Confirm that the location is okay, possibly modifying it in place if
@@ -505,5 +497,13 @@ class Package(object):
         old_log.write(log)
         return (res, log)
 
-    def dump(self, env, file):
-        pass
+    def __str__(self):
+        str =  'Package name:  %s\n' % self.name
+        str += 'Found:         %s\n' % self.result[0]
+        str += 'Base path:     %s\n' % self.base_dir
+        str += 'Header paths:  %s\n' % self.hdr_dirs
+        str += 'Library paths: %s\n' % self.lib_dirs
+        str += 'Libraries:     %s\n' % self.libs
+        str += 'Have shared:   %s\n' % self.have_shared
+        str += 'Frameworks:    %s\n' % self.fworks
+        return str
diff -r b00f7e3fa3bc -r 310dacff26a8 config/SConfig/packages/BlasLapack.py
--- a/config/SConfig/packages/BlasLapack.py	Wed Mar 05 01:15:24 2008 +0000
+++ b/config/SConfig/packages/BlasLapack.py	Wed Mar 05 01:18:50 2008 +0000
@@ -6,7 +6,10 @@ class BlasLapack(SConfig.Package):
         SConfig.Package.__init__(self, env, options)
         self.setup_search_defaults()
         self.setup_options()
-        self.libraries = [['blas', 'lapack']]
+        self.libraries = [['blas', 'lapack'],
+                          ['cblas', 'clapack'],
+                          ['mkl']]
+        self.frameworks = ['Accelerate']
         self.symbols = [(['dgeev'], 'FORTRAN_NORMAL'),
                         (['dgeev_'], 'FORTRAN_SINGLE_TRAILINGBAR'),
                         (['dgeev__'], 'FORTRAN_DOUBLE_TRAILINGBAR'),
diff -r b00f7e3fa3bc -r 310dacff26a8 config/SConfig/packages/MPI.py
--- a/config/SConfig/packages/MPI.py	Wed Mar 05 01:15:24 2008 +0000
+++ b/config/SConfig/packages/MPI.py	Wed Mar 05 01:18:50 2008 +0000
@@ -4,10 +4,10 @@ class MPI(SConfig.Package):
 class MPI(SConfig.Package):
     def __init__(self, env, options):
         SConfig.Package.__init__(self, env, options)
+        self.header_sub_dir = 'mpi'
         self.setup_search_defaults()
         self.setup_options()
         self.base_patterns = ['mpich*', 'MPICH*']
-        self.header_sub_dir = 'mpi'
         self.headers = ['mpi.h']
         self.libraries = [['mpich'],
                           ['mpich', 'pmpich'],
diff -r b00f7e3fa3bc -r 310dacff26a8 config/SConfig/packages/PETSc.py
--- a/config/SConfig/packages/PETSc.py	Wed Mar 05 01:15:24 2008 +0000
+++ b/config/SConfig/packages/PETSc.py	Wed Mar 05 01:18:50 2008 +0000
@@ -4,11 +4,11 @@ class PETSc(SConfig.Package):
 class PETSc(SConfig.Package):
     def __init__(self, env, options):
         SConfig.Package.__init__(self, env, options)
+        self.header_sub_dir = 'petsc'
         self.setup_search_defaults()
         self.setup_options()
         self.dependencies = [SConfig.packages.MPI]
         self.base_patterns = ['petsc*', 'PETSC*', 'PETSc*']
-        self.header_sub_dir = 'petsc'
         self.headers = ['petsc.h',
                         'petscvec.h', 'petscmat.h',
                         'petscksp.h', 'petscsnes.h']



More information about the CIG-COMMITS mailing list