[cig-commits] r5221 - long/3D/Gale/trunk
walter at geodynamics.org
walter at geodynamics.org
Thu Nov 9 16:43:31 PST 2006
Author: walter
Date: 2006-11-09 16:43:31 -0800 (Thu, 09 Nov 2006)
New Revision: 5221
Added:
long/3D/Gale/trunk/SConstruct
Modified:
long/3D/Gale/trunk/
Log:
r1044 at earth: boo | 2006-11-08 13:18:03 -0800
Add in SConstruct file (oops)
Property changes on: long/3D/Gale/trunk
___________________________________________________________________
Name: svk:merge
- 3a629746-de10-0410-b17b-fd6ecaaa963e:/cig:1043
+ 3a629746-de10-0410-b17b-fd6ecaaa963e:/cig:1044
Added: long/3D/Gale/trunk/SConstruct
===================================================================
--- long/3D/Gale/trunk/SConstruct 2006-11-10 00:43:28 UTC (rev 5220)
+++ long/3D/Gale/trunk/SConstruct 2006-11-10 00:43:31 UTC (rev 5221)
@@ -0,0 +1,278 @@
+# Builds everything for Gale
+
+# Note that SConstruct is created by running configure.py over
+# SConstruct.in
+
+# Copyright (C) 2006 California Institute of Technology
+
+# This program 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 program 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
+# General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA
+
+import os
+import sys
+
+env=Environment()
+
+env.Append(CCFLAGS=['-g'])
+
+env.Append(CPPPATH=['#/build/include'])
+env.Append(CPPPATH=['#/build/include/StGermain'])
+env.Append(CPPFLAGS=['-DVERSION=\\"CIG\\"'])
+# Export all of the variables
+Export('env')
+
+SConscript('configure_vars')
+
+Import('env','with_shared','mpirun','extra_libs','libs')
+
+
+if not with_shared:
+ with_shared=False
+ env.Append(CPPFLAGS=['-DNOSHARED'])
+
+# Set up stuff for a static build
+
+env.Append(FRAMEWORKS=["vecLib"])
+
+if os.getenv("STATIC_BUILD"):
+ if with_shared:
+ print "Can not make a static build if you configured using --with-shared"
+ sys.exit(1)
+ env.Append(LINKFLAGS=Split("-static -shared-libgcc"))
+ env.Append(LIBS=Split('z g2c'))
+
+# Add the local "lib" directory to the linker path
+
+env.Append(LIBPATH=['#/build/lib'])
+
+# Store the signatures in a single file, because otherwise the install
+# target will install the .sconsign file
+SConsignFile()
+
+## ## We have to use these signatures to prevent spurious rebuilds
+## TargetSignatures('content')
+## SourceSignatures('MD5')
+
+header_groups={}
+bin_objects=[]
+shared_lib_objects=[]
+static_lib_objects=[]
+tests=[]
+
+Export('header_groups')
+Export('bin_objects')
+Export('shared_lib_objects')
+Export('static_lib_objects')
+Export('tests')
+
+# Create a new Builder to handle creating the -meta files.
+
+def create_meta(target, source, env):
+ output_file = file(str(target[0]),'wb')
+ output_file.write("#define XML_METADATA \"")
+ xml_file = file(str(source[0]))
+ xml_lines = xml_file.readlines()
+ for l in xml_lines:
+ output_file.write(l.replace('\"','\\\"')[:-1])
+ output_file.write("\"\n#define COMPONENT_NAME ")
+ for l in xml_lines:
+ start=l.find('<param name="Name">')
+ if start!=-1:
+ end=l.find('<',start+19)
+ if end==-1:
+ raise RunTimeError('Malformed XML file. The file '
+ + str(source[0])
+ + ' does not close off <param name="Name"> on the same line.')
+ output_file.write(l[start+19:end])
+ output_file.write("\n")
+ break
+ template_file=file("meta-template.c")
+ output_file.write(template_file.read())
+
+def gen_meta_suffix(env, sources):
+ return "-meta.c"
+
+env['BUILDERS']['Meta']=Builder(action=create_meta,src_suffix="meta",
+ suffix=gen_meta_suffix,single_source=True)
+
+# Create a new builder to run all of the tests
+
+class TestError(Exception):
+ pass
+
+def execute_test_and_compare(test_args,expected):
+ r,w,e=os.popen3(test_args)
+ e.readlines()
+ output_file=w.readlines()
+ r.close()
+ e.close()
+ w.close()
+
+ f=file(expected)
+ expected_file=f.readlines()
+ f.close()
+
+ if expected_file!=output_file:
+ print "expected and result",test_args, expected
+ raise TestError
+
+def run_test(target,source,env):
+ test_args=[mpirun]
+
+ if not env.has_key('MPI_PROCS'):
+ env['MPI_PROCS']="1"
+ test_args+=["-np",env['MPI_PROCS']]
+
+ if not env.has_key('EXPECTED'):
+ env['EXPECTED']="./"
+
+ testname=str(source[0])
+ expected=env['EXPECTED']+testname+".0of"+env['MPI_PROCS']+".expected"
+
+ test_args.append(testname)
+ if env.has_key('TESTARGS'):
+ for s in Split(env['TESTARGS']):
+ test_args.append(s)
+
+ execute_test_and_compare(test_args,expected)
+ return None
+
+def gen_test_suffix(env, sources):
+ if env.has_key('MPI_PROCS'):
+ return "test"+env['MPI_PROCS']
+ return ".test"
+
+env['BUILDERS']['Test']=Builder(action=run_test,
+ suffix=gen_test_suffix,single_source=True)
+
+def run_general_test(target,source,env):
+ test_args=[mpirun]
+
+ if not env.has_key('MPI_PROCS'):
+ env['MPI_PROCS']="1"
+ test_args+=["-np",env['MPI_PROCS']]
+
+ if not env.has_key('EXPECTED'):
+ env['EXPECTED']="./"
+
+ testname=str(source[0])
+ expected=str(source[1])
+
+ test_args.append(testname)
+
+ if env.has_key('TESTARGS'):
+ for s in Split(env['TESTARGS']):
+ test_args.append(s)
+
+ execute_test_and_compare(test_args,expected)
+ return None
+
+env['BUILDERS']['GeneralTest']=Builder(action=run_general_test,
+ suffix=gen_test_suffix)
+
+
+def add_tests(env,tests,test_files,libraries,procs):
+ for f in test_files:
+ tests+=[env.GeneralTest([env.Program(f[:-2],[f,libraries]),
+ f[:-1]+"0of"+procs+".expected"])]
+
+Export('env','add_tests')
+BuildDir('build','src',duplicate=0)
+
+# We have to do the dependency checking in two stages, because the
+# tests need the libraries in order to build (because otherwise you
+# get duplicate symbols), but the library dependencies are not figured
+# out until all of the files are scanned.
+
+make_test_deps=False
+Export('make_test_deps')
+SConscript('build/SConscript')
+make_test_deps=True
+Export('make_test_deps')
+SConscript('build/StGermain/Base/Foundation/SConscript')
+SConscript('build/StGermain/Base/Container/SConscript')
+
+# We have to do a fake install of the headers, because otherwise the
+# libraries won't build. We have to do a fake install of the
+# libraries, because otherwise the binaries won't build.
+
+header_install=[]
+fake_header_install=[]
+for partial_dir, headers in header_groups.iteritems():
+ for h in headers:
+
+ # The petsc compatibility header is found in a different kind
+ # of place.
+
+ if(partial_dir=='StGermain/compatibility'):
+ source="StGermain/compatibility/libpetsc/"
+
+ # This is a hack because the top foo.h header files do
+ # not obey the usual naming construction. They are in the
+ # libfoo directory.
+
+ elif(partial_dir=='StGermain'):
+ source="StGermain/libStGermain/src/"
+ elif(partial_dir=='StgFEM'):
+ source="StgFEM/libStG_FEM/src/"
+ elif(partial_dir=='PICellerator'):
+ source="PICellerator/libPICellerator/src/"
+ elif(partial_dir=='Underworld'):
+ source="Underworld/libUnderworld/src/"
+ elif(partial_dir=='Gale'):
+ source="Gale/libGale/src/"
+ else:
+ source=partial_dir + '/src/'
+
+ target=partial_dir
+
+ # Flatten the hierarchy of where plugins header files are
+ # found.
+ plugin_start=target.find('/plugins/')
+ if(plugin_start!=-1):
+ target=target[:plugin_start] + target[target.rfind('/'):]
+ # The directory for plugins does not have a "src/"
+ # component.
+ source=partial_dir + '/';
+
+
+ header_install+=[env.InstallAs(env["include_dir"] + '/'
+ + target + '/' + h,
+ 'src/' + source + h)]
+ fake_header_install+=[env.InstallAs('build/include/' + target
+ + '/' + h,
+ 'src/' + source + h)]
+
+
+Depends(shared_lib_objects,fake_header_install)
+Depends(static_lib_objects,fake_header_install)
+
+if with_shared:
+ fake_lib_install=env.Install('build/lib',shared_lib_objects)
+ Depends(bin_objects,fake_lib_install)
+ lib_install=env.Install(env['lib_dir'],shared_lib_objects)
+else:
+ lib_install=env.Install(env['lib_dir'],static_lib_objects)
+
+bin_install=env.Install(env['bin_dir'],bin_objects)
+
+env.Alias('install',bin_install)
+env.Alias('install',lib_install)
+env.Alias('install',header_install)
+env.Alias('test',tests)
+
+
+Default(None)
+Default(bin_objects)
More information about the cig-commits
mailing list