Commit 4dd13a94 authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#107 Compilation with CustomLibrary() works well in the case of the static...

#107 Compilation with CustomLibrary() works well in the case of the static library. Shared libraries however are faulty at the moment, clearly because somehow environment is not correctly taken into account (it uses for instance g++ instead of my own CXX which is mpic++).
parent c48ad677
import copy
Import(['env', 'all_libs', 'CreateObjectList'])
Import(['env', 'all_libs', 'CustomLibrary'])
core_src = Split('''
......@@ -19,9 +19,6 @@ InputParameter/Variable.cpp
TransientParameters.cpp
''')
name = 'happy_heart_core'
# At the moment, only shared library supported by both Linux and Mac OS X (but XCode's build is with static).
core_lib = env.StaticLibrary(name, core_src, LIBS=all_libs, LIBPATH=env['LIBPATH'])
core_lib = CustomLibrary(env, 'happy_heart_core', core_src)
Return('core_lib')
import copy
import os
Import(['env', 'all_libs', 'CreateObjectList'])
Import(['env', 'all_libs', 'CustomLibrary'])
finite_elt_src = Split('''
......@@ -93,19 +93,6 @@ Unknown/Unknown.cpp
Unknown/UnknownComponent.cpp
Unknown/UnknownManager.cpp''')
name = 'happy_heart_finite_elt'
# First create the list of objects.
object_list = CreateObjectList(finite_elt_src)
# Call the Prelink builder to create a single object file that covers the whole library.
single_obj_file = "prelink_{0}.o".format(name)
env.Prelink(single_obj_file, object_list)
# Create the static library from the result of the Prelink builder.
finite_elt_lib = env.StaticLibrary(name, single_obj_file,
LIBS=all_libs,
LIBPATH=env['LIBPATH'])
finite_elt_lib = CustomLibrary(env, 'happy_heart_finite_elt', finite_elt_src)
Return('finite_elt_lib')
......@@ -2,7 +2,7 @@ import os
import copy
import subprocess
Import(['env', 'all_libs', 'CustomStaticLibrary'])
Import(['env', 'all_libs', 'CustomLibrary'])
geometry_src = Split('''
Coords.cpp
......@@ -82,22 +82,7 @@ Private/MeshLevelInterfaceList.cpp
RefGeomElt.cpp
''')
name = 'happy_heart_geometry'
# # First create the list of objects.
# object_list = CreateObjectList(geometry_src)
#
# # Call the Prelink builder to create a single object file that covers the whole library.
# single_obj_file = "prelink_{0}.o".format(name)
# env.Prelink(single_obj_file, object_list)
#
# # Create the static library from the result of the Prelink builder.
# geometry_lib = env.StaticLibrary(name, single_obj_file,
# LIBS=all_libs,
# LIBPATH=env['LIBPATH'])
geometry_lib = CustomStaticLibrary(env, name, geometry_src)
geometry_lib = CustomLibrary(env, 'happy_heart_geometry', geometry_src)
Return('geometry_lib')
import copy
Import(['env', 'all_libs'])
Import(['env', 'all_libs', 'CustomLibrary'])
elasticity_src = Split('''
......@@ -9,9 +9,7 @@ elasticity_src = Split('''
''')
name = 'happy_heart_elasticity'
elasticity_lib = env.StaticLibrary(name, elasticity_src, LIBS=all_libs, LIBPATH=env['LIBPATH'])
elasticity_lib = CustomLibrary(env, 'happy_heart_elasticity', elasticity_src)
main_elasticity_src = Split('''
......@@ -19,7 +17,8 @@ main_elasticity_src = Split('''
''')
elasticity = env.Program('elasticity', main_elasticity_src,
elasticity = env.Program('elasticity-{0}'.format(env["LIBRARY_TYPE"]),
main_elasticity_src,
LIBS=[all_libs, elasticity_lib],
LIBPATH=env['LIBPATH'])
......
import copy
Import(['env', 'all_libs'])
Import(['env', 'all_libs', 'CustomLibrary'])
heat_src = Split('''
......@@ -9,9 +9,7 @@ heat_src = Split('''
''')
name = 'happy_heart_heat'
heat_lib = env.StaticLibrary(name, heat_src, LIBS=all_libs, LIBPATH=env['LIBPATH'])
heat_lib = CustomLibrary(env, 'happy_heart_heat', heat_src)
main_heat_src = Split('''
......@@ -19,7 +17,8 @@ main_heat_src = Split('''
''')
heat = env.Program('heat', main_heat_src,
heat = env.Program('heat-{0}'.format(env["LIBRARY_TYPE"]),
main_heat_src,
LIBS=[all_libs, heat_lib],
LIBPATH=env['LIBPATH'])
......
import copy
Import(['env', 'all_libs'])
Import(['env', 'all_libs', 'CustomLibrary'])
......@@ -12,9 +12,7 @@ TimeSchemes/Midpoint/VectorsAndMatrices.cpp
''')
name = 'happy_heart_hyperelasticity'
hyperelasticity_lib = env.StaticLibrary(name, hyperelasticity_src, LIBS=all_libs, LIBPATH=env['LIBPATH'])
hyperelasticity_lib = CustomLibrary(env, 'happy_heart_hyperelasticity', hyperelasticity_src)
main_hyperelasticity_src = Split('''
......
import copy
Import(['env', 'all_libs'])
Import(['env', 'all_libs', 'CustomLibrary'])
pseudo_stokes_src = Split('''
......@@ -9,17 +9,16 @@ pseudo_stokes_src = Split('''
''')
name = 'happy_heart_pseudo_stokes'
pseudo_stokes_lib = env.StaticLibrary(name, pseudo_stokes_src, LIBS=all_libs, LIBPATH=env['LIBPATH'])
pseudo_stokes_lib = CustomLibrary(env, 'happy_heart_pseudo_stokes', pseudo_stokes_src)
main_pseudo_stokes_src = Split('''
main.cpp
''')
pseudo_stokes = env.Program('pseudo_stokes', main_pseudo_stokes_src,
pseudo_stokes = env.Program('pseudo_stokes-{0}'.format(env["LIBRARY_TYPE"]),
main_pseudo_stokes_src,
LIBS=[all_libs, pseudo_stokes_lib],
LIBPATH=env['LIBPATH'])
......
import os
Import(['env', 'all_libs'])
Import(['env', 'all_libs', 'CustomLibrary'])
all_instances_executable_list = []
all_instances_library_list = []
problems = ("Hyperelasticity", )#"Elasticity", "PseudoStokes", "Heat")
problems = ("Hyperelasticity", "Elasticity", "PseudoStokes", "Heat")
for problem in problems:
(executable_list, library_list) = SConscript(os.path.join(problem, 'SConscript'), ['env', 'all_libs'], duplicate=0)
(executable_list, library_list) = SConscript(os.path.join(problem, 'SConscript'), ['env', 'all_libs', 'CustomLibrary'], duplicate=0)
for executable in executable_list:
all_instances_executable_list.append(executable)
......
import copy
Import(['env', 'all_libs'])
Import(['env', 'all_libs', 'CustomLibrary'])
post_processing_src = Split('''
......@@ -16,18 +16,16 @@ Private/TimeIterationFile.cpp
Private/UnknownInformationFile.cpp
''')
name = 'happy_heart_post_processing'
post_processing_lib = CustomLibrary(env, 'happy_heart_post_processing', post_processing_src)
post_processing_lib = env.StaticLibrary(name, post_processing_src, LIBS=all_libs, LIBPATH=env['LIBPATH'])
main_compute_ensight_output_src = Split('''
main_ensight_output.cpp
''')
compute_ensight_output = env.Program('compute_ensight_output', main_compute_ensight_output_src,
compute_ensight_output = env.Program('compute_ensight_output-{0}'.format(env["LIBRARY_TYPE"]),
main_compute_ensight_output_src,
LIBS=[all_libs, post_processing_lib],
LIBPATH=env['LIBPATH'])
......
......@@ -261,7 +261,15 @@ def CreateObjectList(source_list):
ret = []
for source_file in source_list:
obj_file = env.Object(source_file)
try:
obj_file = env.Object(source_file)
except:
# ThirdParty add some flags to disable warnings; to objects are given instead of sources.
# In this case the call above raise an exception; I assume here it is because \a source_file
# is already an object.
obj_file = source_file
ret.append(obj_file)
return ret
......@@ -294,6 +302,14 @@ def Prelink(target, source, env):
def CustomStaticLibrary(env, name, source_file_list):
"""Create a static library where all the objects have been prelinked in a single one.
The reason for this is that HappyHeart use a FactoryPattern which loads data in the factory before the
program even starts. With a standard StaticLibrary, these informations aren't kept and the program fails in runtime.
The library does the same operation as 'Perform Single-Object Prelink = yes' option in XCode settings.
"""
# First create the list of objects.
object_list = CreateObjectList(source_file_list)
......@@ -305,6 +321,15 @@ def CustomStaticLibrary(env, name, source_file_list):
return env.StaticLibrary(name, single_obj_file,
LIBS=all_libs,
LIBPATH=env['LIBPATH'])
def CustomLibrary(env, name, source_file_list):
if env["LIBRARY_TYPE"] == "static":
return CustomStaticLibrary(env, name, source_file_list)
else:
return SharedLibrary(name, source_file_list, LIBS=all_libs, LIBPATH=env['LIBPATH'])
# Add to the environment the Prelink builder.
......@@ -419,7 +444,7 @@ for library in libraries:
scons_library_object = SConscript(os.path.join(library, 'SConscript'),
exports=(['env', 'all_libs', 'CreateObjectList', 'CustomStaticLibrary']),
exports=(['env', 'all_libs', 'CustomLibrary']),
variant_dir=variant_dir,
duplicate=0)
......@@ -427,7 +452,6 @@ for library in libraries:
libname = PrepareTargetName(scons_library_object)
# Install here the library in the final target folder.
#if library != 'Geometry':
env.Command(os.path.join(target_variant_directory, libname), scons_library_object, InstallStaticLibrary)
# Update the list of known libraries so far.
......@@ -439,7 +463,7 @@ for library in libraries:
# Now create the executables for all the problems.
(executable_list, exec_library_list) = SConscript('ModelInstances/SConscript',
exports=(['env', 'all_libs']),
exports=(['env', 'all_libs', 'CustomLibrary']),
variant_dir=os.path.join(intermediate_variant_directory, 'ModelInstances'),
duplicate=0)
......@@ -448,14 +472,14 @@ list_test_exec = SConscript('Test/SConscript',
variant_dir=os.path.join(intermediate_variant_directory, 'Tests'),
duplicate=0)
# DEV TMP executable_list.extend(list_test_exec)
executable_list.extend(list_test_exec)
(post_processing_exec, post_processing_lib) = SConscript('PostProcessing/SConscript',
exports=(['env', 'all_libs']),
exports=(['env', 'all_libs', 'CustomLibrary']),
variant_dir=os.path.join(intermediate_variant_directory, 'PostProcessing'),
duplicate=0)
#DEV TMP executable_list.extend(post_processing_exec)
executable_list.extend(post_processing_exec)
exec_library_list.extend(post_processing_lib)
......
......@@ -16,15 +16,18 @@ main_src = Split('''
''')
test = env.Program('test', main_src,
LIBS=all_libs,
LIBPATH=env['LIBPATH'])
test = env.Program('test-{0}'.format(env["LIBRARY_TYPE"]),
main_src,
LIBS=all_libs,
LIBPATH=env['LIBPATH'])
main_ondomatic_numbering_src = Split('''
OndomaticNumbering/main_test_ondomatic_numbering.cpp
''')
test_ondomatic_numbering = env.Program('test_ondomatic_numbering', main_ondomatic_numbering_src,
test_ondomatic_numbering = env.Program('test_ondomatic_numbering-{0}'.format(env["LIBRARY_TYPE"]),
main_ondomatic_numbering_src,
LIBS=all_libs,
LIBPATH=env['LIBPATH'])
......@@ -33,7 +36,8 @@ main_coloring_src = Split('''
Geometry/main_test_coloring.cpp
''')
test_coloring = env.Program('test_coloring', main_coloring_src,
test_coloring = env.Program('test_coloring-{0}'.format(env["LIBRARY_TYPE"]),
main_coloring_src,
LIBS=all_libs,
LIBPATH=env['LIBPATH'])
......@@ -43,7 +47,8 @@ main_jacobian_src = Split('''
Geometry/main_test_jacobian.cpp
''')
test_jacobian = env.Program('test_jacobian', main_jacobian_src,
test_jacobian = env.Program('test_jacobian-{0}'.format(env["LIBRARY_TYPE"]),
main_jacobian_src,
LIBS=all_libs,
LIBPATH=env['LIBPATH'])
......
import os
import copy
Import('env')
Import('env', 'CustomLibrary')
utilities_src_and_obj = Split('''
......@@ -34,19 +34,8 @@ name = 'happy_heart_utilities'
all_libs = copy.copy(env['LIBS'])
# env.Prelink(['prelink.o'], utilities_src)
# env.StaticLibrary(name, ['prelink.o'], LIBS=local_libs, LIBPATH=env['LIBPATH'])
platform = env['PLATFORM']
# At the moment, only shared library supported by both Linux and Mac OS X (but XCode's build is with static).
utilities_lib = env.StaticLibrary(name, utilities_src_and_obj, LIBS=all_libs, LIBPATH=env['LIBPATH'])
utilities_lib = CustomLibrary(env, 'happy_heart_utilities', utilities_src_and_obj)
Return('utilities_lib')
#env['LIBS'].append('happy_heart_utilities')
# print "In Utilities, the value is:"
# print env['LIBPATH']
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment