Commit 02f80536 authored by Laurent Belcour's avatar Laurent Belcour

Using the environment variable to load the plugin name.

parent 83c37875
......@@ -11,3 +11,15 @@ unix:!macx {
QMAKE_CXXFLAGS += -fopenmp
LIBS += -lgomp
}
macx {
exists(/opt/local/bin/gcc-mp-4.9) {
CONFIG += openmp
QMAKE_CXX = /opt/local/bin/gcc-mp-4.9
QMAKE_CXXFLAGS += -fopenmp
LIBS += -L/opt/local/lib/libgcc
QMAKE_LFLAGS += -fopenmp
} else {
warning("No OpenMP compliant compiler found")
}
}
......@@ -17,6 +17,7 @@ fi
path=${sources}/sources/build
export ALTA=$sources
export ALTA_LIB=$path
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$path
export PATH=$PATH:$path
export PYTHONPATH=$PYTHONPATH:$path
......@@ -13,7 +13,7 @@ sources = ['common.cpp',
'vertical_segment.cpp']
# Special linking flags, defined in the OS dependant configuration file
env.AppendUnique(env['CORE_LIB'])
env.AppendUnique(LIBS = env['CORE_LIB'])
## Known compilation issue. If the core is not compiled with -fvisibility-hidden
## on OSX, the shared libraries and the softwares cannot share vtables. This
......
......@@ -8,6 +8,7 @@
#include <dlfcn.h>
#endif
#include <stdio.h>
#include <list>
//! Add dynamic library extension (.so or .dll) to a dynamic object as well as
//! prepending 'lib' depending on the plateform.
......@@ -41,12 +42,48 @@ std::string library_name(const std::string name)
return filename;
}
void get_library_dirs(std::list<std::string>& dirs)
{
dirs.push_back("");
#ifndef _WIN32
std::string obj_str ;
const char *env_str = getenv("ALTA_LIB") ;
if(env_str == NULL) {
obj_str = "" ;
} else {
obj_str = std::string(env_str)+":" ;
}
while(true) {
int lb = obj_str.find_first_not_of(":",0) ;
int le = obj_str.find_first_of(":",lb) ;
if(lb < le) {
dirs.push_back(obj_str.substr(lb,le-lb)) ;
obj_str = obj_str.substr(le+1,obj_str.size()) ;
} else {
break ;
}
}
#endif
}
//! \brief Open a dynamic library file (.so or .dll) and extract the associated
//! provide function. The template argument is used to cast the library to a
//! specific type.
template<typename T> T open_library(const std::string& filename, const char* function)
{
std::string libname = library_name(filename);
std::list<std::string> basename;
get_library_dirs(basename);
std::list<std::string>::iterator iter;
for(iter = basename.begin(); iter != basename.end(); ++iter)
{
std::string libname = *iter;
libname.append(library_name(filename));
#ifdef _WIN32
HINSTANCE handle = LoadLibraryA(libname.c_str());
......@@ -57,7 +94,7 @@ template<typename T> T open_library(const std::string& filename, const char* fun
if(res == NULL)
{
std::cerr << "<<ERROR>> unable to load the symbol \"" << function << "\" from " << filename << std::endl;
return NULL;
continue;
}
#ifdef DEBUG_CORE
std::cout << "<<DEBUG>> will provide a " << function << " for library \"" << filename << "\"" << std::endl;
......@@ -68,7 +105,7 @@ template<typename T> T open_library(const std::string& filename, const char* fun
{
std::cerr << "<<ERROR>> unable to load the dynamic library file \"" << libname << "\"" << std::endl;
std::cerr << " cause: \"" << GetLastError() << "\"" << std::endl;
return NULL;
continue;
}
#else
void* handle = dlopen(libname.c_str(), RTLD_GLOBAL | RTLD_LAZY);
......@@ -81,7 +118,7 @@ template<typename T> T open_library(const std::string& filename, const char* fun
if(dlerror() != NULL)
{
std::cerr << "<<ERROR>> unable to load the symbol \"" << function << "\" from " << libname << std::endl;
return NULL;
continue;
}
#ifdef DEBUG_CORE
std::cout << "<<DEBUG>> will provide a " << function << " for library \"" << libname << "\"" << std::endl;
......@@ -92,9 +129,11 @@ template<typename T> T open_library(const std::string& filename, const char* fun
{
std::cerr << "<<ERROR>> unable to load the dynamic library file \"" << libname << "\"" << std::endl;
std::cerr << " cause: \"" << dlerror() << "\"" << std::endl;
return NULL;
continue;
}
#endif
}
return NULL;
}
//! \brief load a function from the ALTA input file.
......
env = Environment()
conf = Configure(env)
env.Append(CPPPATH=['../../external/build/include'])
env.Append(CPPPATH=['../', '/usr/include/python2.7'])
......@@ -10,19 +9,25 @@ env.Append(LIBPATH=['../build'])
env.Append(LIBPATH=['/usr/lib/x86_64-gnu-linux'])
env.Append(LIBPATH=['/opt/local/lib'])
conf = Configure(env)
boost_python_lib = ['boost_python-mt', 'python2.7']
build_lib = False
if conf.CheckLibWithHeader('boost_python-py27', 'boost/python.hpp', 'c++'):
if conf.CheckLibWithHeader(boost_python_lib, 'boost/python.hpp', 'c++'):
env.Append(LIBS=['python2.7', 'boost_python-py27', 'core'])
env.Append(LIBS=['python2.7', boost_python_lib, 'core'])
#env.Append(LIBS=['python2.7', 'boost_python-mt', 'core'])
env['SHLIBPREFIX']=''
build_lib = True
else:
print "<<ERROR>> Unable to build the Python interface, please install boost-python."
#end
env = conf.Finish()
if build_lib:
env.SharedLibrary('alta', ['alta.cpp'])
env.SharedLibrary('alta.so', ['alta.cpp'])
#end
......@@ -122,7 +122,7 @@ BOOST_PYTHON_MODULE(alta)
// Data interface
bp::class_<Data, ptr<Data>, boost::noncopyable>("data")
// .def("load", bp::pure_virtual(&data::load))
// .def("load", bp::pure_virtual(&data::load));
.def("size", bp::pure_virtual(&data::size));
bp::def("get_data", plugins_manager::get_data);
bp::def("load_data", load_data);
......
......@@ -124,21 +124,24 @@ int main(int argc, char** argv)
if(dynamic_pointer_cast<vertical_segment>(d_out) || args.is_defined("splat"))
{
params::input param = params::parse_input(args["param"]);
if(param == params::UNKNOWN_INPUT && d_in->input_parametrization() != params::UNKNOWN_INPUT)
if(dynamic_pointer_cast<vertical_segment>(d_out))
{
std::cout << "<<DEBUG>> using the input parametrization of the input file for the output file as well." << std::endl;
param = d_in->input_parametrization();
}
else if(param == params::UNKNOWN_INPUT)
{
std::cerr << "<<ERROR>> no parametrization defined for input and output files." << std::endl;
return -1;
}
params::input param = params::parse_input(args["param"]);
if(param == params::UNKNOWN_INPUT && d_in->input_parametrization() != params::UNKNOWN_INPUT)
{
std::cout << "<<DEBUG>> using the input parametrization of the input file for the output file as well." << std::endl;
param = d_in->input_parametrization();
}
else if(param == params::UNKNOWN_INPUT)
{
std::cerr << "<<ERROR>> no parametrization defined for input and output files." << std::endl;
return -1;
}
d_out->setParametrization(param);
d_out->setDimX(params::dimension(param));
d_out->setDimY(d_in->dimY());
d_out->setParametrization(param);
d_out->setDimX(params::dimension(param));
d_out->setDimY(d_in->dimY());
}
std::cout << "<<INFO>> output DIM = " << d_out->dimX() << ", " << d_out->dimY() << std::endl;
......@@ -150,7 +153,6 @@ int main(int argc, char** argv)
params::convert(&x[0], d_in->parametrization(), d_out->parametrization(), &temp[0]);
params::convert(&x[d_in->dimX()], d_in->output_parametrization(), d_in->dimY(), d_out->output_parametrization(), d_out->dimY(), &temp[d_out->dimX()]);
d_out->set(temp);
}
}
else
......
Markdown is supported
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