diff --git a/crlcore/CMakeLists.txt b/crlcore/CMakeLists.txt index e69f41e6..21365ec6 100644 --- a/crlcore/CMakeLists.txt +++ b/crlcore/CMakeLists.txt @@ -41,6 +41,9 @@ SET(QT_USE_QTXML "true") LIST(INSERT CMAKE_MODULE_PATH 0 "${CRLCORE_SOURCE_DIR}/cmake_modules/") +FIND_PACKAGE(LibXml2 REQUIRED) +FIND_PACKAGE(PythonLibs REQUIRED) +FIND_PACKAGE(PythonSitePackages REQUIRED) FIND_PACKAGE(Qt4 REQUIRED) # find and setup Qt4 for this project FIND_PACKAGE(BISON REQUIRED) FIND_PACKAGE(FLEX REQUIRED) @@ -51,7 +54,7 @@ FIND_PACKAGE(HURRICANE REQUIRED) INCLUDE(UseLATEX) SET_LIB_LINK_MODE() -FIND_PACKAGE(Boost 1.33.1 COMPONENTS program_options REQUIRED) +FIND_PACKAGE(Boost 1.33.1 COMPONENTS program_options filesystem REQUIRED) STRING(REGEX MATCH "^/usr" IS_USR "$ENV{CORIOLIS_TOP}") STRING(REGEX MATCH "^/opt" IS_OPT "$ENV{CORIOLIS_TOP}") diff --git a/crlcore/src/ccore/AllianceFramework.cpp b/crlcore/src/ccore/AllianceFramework.cpp index d9bc48a4..ac53b209 100644 --- a/crlcore/src/ccore/AllianceFramework.cpp +++ b/crlcore/src/ccore/AllianceFramework.cpp @@ -63,6 +63,9 @@ namespace CRL { , _parentLibrary(NULL) , _routingGauges() { + // Triggers System singleton loading. + System::get (); + DataBase* db = DataBase::getDB (); if ( !db ) db = DataBase::create (); diff --git a/crlcore/src/ccore/CMakeLists.txt b/crlcore/src/ccore/CMakeLists.txt index 01517a1a..102a8821 100644 --- a/crlcore/src/ccore/CMakeLists.txt +++ b/crlcore/src/ccore/CMakeLists.txt @@ -27,10 +27,12 @@ ${HURRICANE_INCLUDE_DIR} ${CIF_INCLUDE_DIR} ${CONFIGURATION_INCLUDE_DIR} + ${PYTHON_INCLUDE_PATH} ) add_definitions ( -DCORIOLIS_TOP="${CORIOLIS_TOP}" -DSYS_CONF_DIR="${SYS_CONF_DIR}" + -DPYTHON_SITE_PACKAGES="${PYTHON_SITE_PACKAGES}" ) set ( includes crlcore/Utilities.h @@ -239,14 +241,4 @@ ${lefdef_cpps} ${openaccess_cpps} ) - target_link_libraries ( crlcore ${HURRICANE_LIBRARIES} - ${HURRICANE_GRAPHICAL_LIBRARIES} - ${QT_LIBRARIES} - ${IO_LIBRARIES} - ${LEFDEF_LIBRARIES} - ${OA_LIBRARIES} - ${AGDS_LIBRARY} - ${CIF_LIBRARY} - ${CONFIGURATION_LIBRARY} - ) install ( TARGETS crlcore DESTINATION lib${LIB_SUFFIX} ) diff --git a/crlcore/src/ccore/Utilities.cpp b/crlcore/src/ccore/Utilities.cpp index 26f8ee19..0bb4bcbf 100644 --- a/crlcore/src/ccore/Utilities.cpp +++ b/crlcore/src/ccore/Utilities.cpp @@ -32,8 +32,9 @@ #include namespace boptions = boost::program_options; -#include "hurricane/Warning.h" #include "vlsisapd/configuration/Configuration.h" +#include "hurricane/Warning.h" +#include "hurricane/isobar/Script.h" #include "crlcore/Utilities.h" @@ -199,12 +200,14 @@ namespace CRL { // Class : "CRL::System". - System* System::_singleton = System::get(); + System* System::_singleton = NULL; //System::get(); System::System () : _catchCore(true) { + cerr << "Creating System singleton." << endl; + // Immediate setup to avoid some tiresome looping... _singleton = this; @@ -223,17 +226,17 @@ namespace CRL { // Environment variables reading. boptions::options_description options ("Environment Variables"); options.add_options() - ( "coriolis_top", boptions::value() + ( "coriolis_top", boptions::value()->default_value(CORIOLIS_TOP) , "The root directory of the Coriolis installation tree." ); boptions::variables_map arguments; boptions::store ( boptions::parse_environment(options,environmentMapper), arguments ); boptions::notify ( arguments ); - bfs::path::default_name_check ( bfs::portable_posix_name ); + if ( bfs::path::default_name_check_writable() ) + bfs::path::default_name_check ( bfs::portable_posix_name ); - const string strSysConfDir = SYS_CONF_DIR; - bfs::path sysConfDir ( strSysConfDir ); + bfs::path sysConfDir ( SYS_CONF_DIR ); if ( not sysConfDir.has_root_path() ) { if ( arguments.count("coriolis_top") ) { sysConfDir = arguments["coriolis_top"].as() / sysConfDir; @@ -280,6 +283,11 @@ namespace CRL { conf->readFromFile ( dotConfFile.string() ); } + bfs::path pythonSitePackages = PYTHON_SITE_PACKAGES; + pythonSitePackages = arguments["coriolis_top"].as() / pythonSitePackages; + + Isobar::Script::addPath ( pythonSitePackages.string() ); + // Delayed printing, as we known only now whether VerboseLevel1 is requested. if ( cmess1.enabled() ) { cmess1 << " o Reading Configuration. " << endl; diff --git a/crlcore/src/cyclop/CMakeLists.txt b/crlcore/src/cyclop/CMakeLists.txt index d7715531..21a7c9c7 100644 --- a/crlcore/src/cyclop/CMakeLists.txt +++ b/crlcore/src/cyclop/CMakeLists.txt @@ -20,11 +20,20 @@ add_executable ( cyclop ${cpps} ${MOCcpps} ) target_link_libraries ( cyclop crlcore + ${HURRICANE_PYTHON_LIBRARIES} ${HURRICANE_GRAPHICAL_LIBRARIES} ${HURRICANE_LIBRARIES} + ${CONFIGURATION_LIBRARY} + ${AGDS_LIBRARY} + ${CIF_LIBRARY} ${IO_LIBRARIES} ${OA_LIBRARIES} + ${LEFDEF_LIBRARIES} ${QT_LIBRARIES} - ${Boost_LIBRARIES} ) + ${Boost_LIBRARIES} + ${LIBXML2_LIBRARIES} + ${PYTHON_LIBRARIES} + -lutil + ) install ( TARGETS cyclop DESTINATION bin ) diff --git a/crlcore/src/cyclop/CyclopMain.cpp b/crlcore/src/cyclop/CyclopMain.cpp index 5511e48e..bb261de6 100644 --- a/crlcore/src/cyclop/CyclopMain.cpp +++ b/crlcore/src/cyclop/CyclopMain.cpp @@ -28,7 +28,10 @@ using namespace std; #include -namespace poptions = boost::program_options; +namespace boptions = boost::program_options; + +#include +namespace bfs = boost::filesystem; #include #if (QT_VERSION >= QT_VERSION_CHECK(4,5,0)) and not defined (__APPLE__) @@ -93,35 +96,41 @@ namespace { int main ( int argc, char *argv[] ) { + int returnCode = 0; try { + bfs::path::default_name_check ( bfs::portable_posix_name ); + unsigned int traceLevel; bool verbose1; bool verbose2; bool coreDump; bool textMode; - poptions::options_description options ("Command line arguments & options"); + boptions::options_description options ("Command line arguments & options"); options.add_options() ( "help,h" , "Print this help." ) - ( "verbose,v" , poptions::bool_switch(&verbose1)->default_value(false) + ( "verbose,v" , boptions::bool_switch(&verbose1)->default_value(false) , "First level of verbosity.") - ( "very-verbose,V", poptions::bool_switch(&verbose2)->default_value(false) + ( "very-verbose,V", boptions::bool_switch(&verbose2)->default_value(false) , "Second level of verbosity.") - ( "core-dump,D" , poptions::bool_switch(&coreDump)->default_value(false) + ( "core-dump,D" , boptions::bool_switch(&coreDump)->default_value(false) , "Enable core dumping.") - ( "text,t" , poptions::bool_switch(&textMode)->default_value(false) + ( "text,t" , boptions::bool_switch(&textMode)->default_value(false) , "Run in pure text mode.") - ( "trace-level,l" , poptions::value(&traceLevel)->default_value(1000) + ( "trace-level,l" , boptions::value(&traceLevel)->default_value(1000) , "Set the level of trace, trace messages with a level superior to " " will be printed on ." ) - ( "cell,c" , poptions::value() + ( "cell,c" , boptions::value() , "The name of the cell to load, whithout extension." ); - poptions::variables_map arguments; - poptions::store ( poptions::parse_command_line(argc,argv,options), arguments ); - poptions::notify ( arguments ); + boptions::variables_map arguments; + boptions::store ( boptions::parse_command_line(argc,argv,options), arguments ); + boptions::notify ( arguments ); + + bfs::path userConfFile = "ma/configuration"; + cerr << "Mark:" << userConfFile.string() << endl; if ( arguments.count("help") ) { cout << options << endl; @@ -223,12 +232,16 @@ int main ( int argc, char *argv[] ) returnCode = qa->exec(); } } - catch ( poptions::error& e ) { + catch ( Error& e ) { + cerr << e.what() << endl; + exit ( 1 ); + } + catch ( boptions::error& e ) { cerr << "[ERROR] " << e.what() << endl; exit ( 1 ); } - catch ( Error& e ) { - cerr << e.what() << endl; + catch ( exception& e ) { + cerr << "[ERROR] " << e.what() << endl; exit ( 1 ); } catch ( ... ) { diff --git a/crlcore/src/x2y/CMakeLists.txt b/crlcore/src/x2y/CMakeLists.txt index f799a096..be9b0695 100644 --- a/crlcore/src/x2y/CMakeLists.txt +++ b/crlcore/src/x2y/CMakeLists.txt @@ -11,9 +11,18 @@ add_executable ( cx2y ${cpps} ) target_link_libraries ( cx2y crlcore + ${HURRICANE_PYTHON_LIBRARIES} ${HURRICANE_GRAPHICAL_LIBRARIES} ${HURRICANE_LIBRARIES} + ${CONFIGURATION_LIBRARY} + ${AGDS_LIBRARY} + ${CIF_LIBRARY} ${OA_LIBRARIES} ${QT_LIBRARIES} - ${Boost_LIBRARIES} ) + ${LEFDEF_LIBRARIES} + ${Boost_LIBRARIES} + ${LIBXML2_LIBRARIES} + ${PYTHON_LIBRARIES} + -lutil + ) install ( TARGETS cx2y DESTINATION bin )