* ./unicorn:

- Change: Read verbosity, info and trace level from configuration.
    - New: Catches correctly boost exceptions.
    - New: Can specify an additionnal XML configuration file on the command
        line.
    - Change: Makes use of the CRL::System environment variable loading.
        XML environment loading is also obsoleted by the new Utility features.
    - Change: In UnicornGui, _banner is now a static member. Useful to print
        the banner whenever running in pure text mode so no UnicornGui is
        created.
This commit is contained in:
Jean-Paul Chaput 2010-06-22 13:59:40 +00:00
parent 5705929dc8
commit 3144735c93
3 changed files with 88 additions and 101 deletions

View File

@ -97,12 +97,6 @@ int main ( int argc, char *argv[] )
float expandStep; float expandStep;
unsigned long eventsLimit; unsigned long eventsLimit;
unsigned int traceLevel; unsigned int traceLevel;
bool verbose1;
bool verbose2;
bool info;
bool showConf;
bool coreDump;
bool logMode;
bool textMode; bool textMode;
double margin; double margin;
bool quadriPlace; bool quadriPlace;
@ -116,24 +110,26 @@ int main ( int argc, char *argv[] )
boptions::options_description options ("Command line arguments & options"); boptions::options_description options ("Command line arguments & options");
options.add_options() options.add_options()
( "help,h" , "Print this help." ) ( "help,h" , "Print this help." )
( "trace-level,l" , boptions::value<unsigned int>(&traceLevel)->default_value(1000) ( "trace-level,l" , boptions::value<unsigned int>(&traceLevel)
, "Set the level of trace, trace messages with a level superior to " , "Set the level of trace, trace messages with a level superior to "
"<arg> will be printed on <stderr>." ) "<arg> will be printed on <stderr>." )
( "verbose,v" , boptions::bool_switch(&verbose1)->default_value(false) ( "verbose,v" , boptions::bool_switch()
, "First level of verbosity.") , "First level of verbosity.")
( "very-verbose,V" , boptions::bool_switch(&verbose2)->default_value(false) ( "very-verbose,V" , boptions::bool_switch()
, "Second level of verbosity.") , "Second level of verbosity.")
( "info,i" , boptions::bool_switch(&info)->default_value(false) ( "info,i" , boptions::bool_switch()
, "Lots of informational messages.") , "Lots of informational messages.")
( "show-conf" , boptions::bool_switch(&showConf)->default_value(false) ( "show-conf" , boptions::bool_switch()
, "Print Kite configuration settings.") , "Print Kite configuration settings.")
( "core-dump,D" , boptions::bool_switch(&coreDump)->default_value(false) ( "conf" , boptions::value<string>()
, "An XML configuration file." )
( "core-dump,D" , boptions::bool_switch()
, "Enable core dumping.") , "Enable core dumping.")
( "log-mode,L" , boptions::bool_switch(&logMode)->default_value(false) ( "log-mode,L" , boptions::bool_switch()
, "Disable ANSI escape sequences displaying.") , "Disable ANSI escape sequences displaying.")
( "text,t" , boptions::bool_switch(&textMode)->default_value(false) ( "text,t" , boptions::bool_switch(&textMode)->default_value(false)
, "Run in pure text mode.") , "Run in pure text mode.")
( "margin,m" , boptions::value<double>(&margin)->default_value(40.0) ( "margin,m" , boptions::value<double>(&margin)
, "Percentage of free area to add to the minimal placement area.") , "Percentage of free area to add to the minimal placement area.")
( "quadri-place,p" , boptions::bool_switch(&quadriPlace)->default_value(false) ( "quadri-place,p" , boptions::bool_switch(&quadriPlace)->default_value(false)
, "Place using quadripartitions then placement legalisation.") , "Place using quadripartitions then placement legalisation.")
@ -170,45 +166,31 @@ int main ( int argc, char *argv[] )
exit ( 0 ); exit ( 0 );
} }
System::getSystem()->setCatchCore ( not coreDump ); if ( arguments.count("conf") ) {
bfs::path userConfFile = arguments["conf"].as<string>();
if ( verbose1 ) mstream::enable ( mstream::VerboseLevel1 ); if ( bfs::exists(userConfFile) ) {
if ( verbose2 ) mstream::enable ( mstream::VerboseLevel2 ); Cfg::Configuration* conf = Cfg::Configuration::get ();
if ( info ) mstream::enable ( mstream::Info ); conf->readFromFile ( userConfFile.string() );
if ( logMode ) tty::disable (); } else {
cerr << Warning("User defined configuration file:\n <%s> not found."
ltracelevel ( traceLevel ); ,userConfFile.string().c_str()) << endl;
}
dbo_ptr<DataBase> db ( DataBase::create() );
dbo_ptr<AllianceFramework> af ( AllianceFramework::create() );
Cell* cell = NULL;
cmess1 << " o Reading Configuration." << endl;
bfs::path::default_name_check ( bfs::portable_posix_name );
Cfg::Configuration* conf = Cfg::Configuration::get ();
const string strSysConfDir = SYS_CONF_DIR;
bfs::path systemConfPath;
bfs::path sysConfDir ( strSysConfDir );
if ( sysConfDir.has_root_path() )
systemConfPath = sysConfDir / "coriolis2" / "tools.configuration.xml";
else
systemConfPath = af->getEnvironment()->getCORIOLIS_TOP()
/ sysConfDir / "coriolis2" / "tools.configuration.xml";
if ( bfs::exists(systemConfPath) ) {
cmess1 << " - <" << systemConfPath.string() << ">." << endl;
conf->readFromFile ( systemConfPath.string() );
} else {
cmess1 << "[WARNING] System configuration file:\n <" << systemConfPath.string() << "> not found." << endl;
} }
bfs::path dotConfPath ( "./.coriolis2.configuration.xml" ); if (arguments["core-dump" ].as<bool>()) Cfg::getParamBool("misc.catchCore" )->setBool ( false );
if ( bfs::exists(dotConfPath) ) { if (arguments["verbose" ].as<bool>()) Cfg::getParamBool("misc.verboseLevel1")->setBool ( true );
cmess1 << " - <" << dotConfPath.string() << ">." << endl; if (arguments["very-verbose"].as<bool>()) Cfg::getParamBool("misc.verboseLevel2")->setBool ( true );
conf->readFromFile ( dotConfPath.string() ); if (arguments["info" ].as<bool>()) Cfg::getParamBool("misc.info" )->setBool ( true );
} if (arguments["log-mode" ].as<bool>()) Cfg::getParamBool("misc.logMode" )->setBool ( true );
if (arguments["show-conf" ].as<bool>()) Cfg::getParamBool("misc.showConf" )->setBool ( true );
if (arguments.count("trace-level" )) Cfg::getParamInt("misc.traceLevel")->setInt ( traceLevel );
bool showConf = Cfg::getParamBool("misc.showConf")->asBool();
dbo_ptr<DataBase> db ( DataBase::create() );
dbo_ptr<AllianceFramework> af ( AllianceFramework::create() );
Cell* cell = NULL;
if ( arguments.count("cell") ) { if ( arguments.count("cell") ) {
cell = af->getCell (arguments["cell"].as<string>().c_str(), Catalog::State::Views ); cell = af->getCell (arguments["cell"].as<string>().c_str(), Catalog::State::Views );
@ -226,9 +208,8 @@ int main ( int argc, char *argv[] )
detailedRoute = false; detailedRoute = false;
} }
if ( arguments.count("margin") ) { if ( arguments.count("margin") )
Cfg::getParamPercentage("nimbus.spaceMargin")->setPercentage ( margin ); Cfg::getParamPercentage("nimbus.spaceMargin")->setPercentage ( margin );
}
if ( arguments.count("partition-size-stop") ) if ( arguments.count("partition-size-stop") )
Cfg::getParamInt("metis.numberOfInstancesStopCriterion")->setInt ( partitionSizeStop ); Cfg::getParamInt("metis.numberOfInstancesStopCriterion")->setInt ( partitionSizeStop );
@ -242,6 +223,31 @@ int main ( int argc, char *argv[] )
if ( arguments.count("expand-step") ) if ( arguments.count("expand-step") )
Cfg::getParamPercentage("kite.expandStep")->setPercentage ( expandStep ); Cfg::getParamPercentage("kite.expandStep")->setPercentage ( expandStep );
UnicornGui::getBanner().setName ( "cgt" );
UnicornGui::getBanner().setPurpose ( "Coriolis Graphical Tool" );
cmess1 << UnicornGui::getBanner() << endl;
cmess1 << " Tool Credits" << endl;
cmess1 << " Hurricane .................... Remy Escassut & Christian Masson" << endl;
cmess1 << " Nimbus - Infrastructure .......................... Hugo Clement" << endl;
cmess1 << " Mauka - Placer ........................... Christophe Alexandre" << endl;
cmess1 << " Knik - Global Router ............................ Damien Dupuis" << endl;
cmess1 << " Kite - Detailed Router ....................... Jean-Paul Chaput" << endl;
cmess1 << endl;
cout << " hMETIS software credits" << endl;
cout << " Author ........................................ Georges Karypis" << endl;
cout << " Prof. Ident. .......................... University of Minnesota" << endl;
cout << " URL .......................... http://glaros.dtc.umn.edu/gkhome" << endl;
cout << endl;
cout << " The Knik router makes use of FLUTE software" << endl;
cout << " Author ........................................ Chris C. N. CHU" << endl;
cout << " Prof. Ident. ............................ Iowa State University" << endl;
cout << " URL ........................ http://home.eng.iastate.edu/~cnchu" << endl;
cout << endl;
cmess2 << af->getPrint() << endl;
if ( cell ) { if ( cell ) {
// addaccu. // addaccu.
//DebugSession::addToTrace ( cell, "sel" ); //DebugSession::addToTrace ( cell, "sel" );
@ -337,31 +343,7 @@ int main ( int argc, char *argv[] )
Graphics::enable (); Graphics::enable ();
dbo_ptr<UnicornGui> unicorn ( UnicornGui::create() ); dbo_ptr<UnicornGui> unicorn ( UnicornGui::create() );
unicorn->setApplicationName ( QObject::tr("cgt") ); unicorn->setApplicationName ( QObject::tr("cgt") );
unicorn->getBanner().setName ( "cgt" );
unicorn->getBanner().setPurpose ( "Coriolis Graphical Tool" );
cmess1 << unicorn->getBanner() << endl;
cmess1 << " Tool Credits" << endl;
cmess1 << " Hurricane .................... Remy Escassut & Christian Masson" << endl;
cmess1 << " Nimbus - Infrastructure .......................... Hugo Clement" << endl;
cmess1 << " Mauka - Placer ........................... Christophe Alexandre" << endl;
cmess1 << " Knik - Global Router ............................ Damien Dupuis" << endl;
cmess1 << " Kite - Detailed Router ....................... Jean-Paul Chaput" << endl;
cmess1 << endl;
cout << " hMETIS software credits" << endl;
cout << " Author ........................................ Georges Karypis" << endl;
cout << " Prof. Ident. .......................... University of Minnesota" << endl;
cout << " URL .......................... http://glaros.dtc.umn.edu/gkhome" << endl;
cout << endl;
cout << " The Knik router makes use of FLUTE software" << endl;
cout << " Author ........................................ Chris C. N. CHU" << endl;
cout << " Prof. Ident. ............................ Iowa State University" << endl;
cout << " URL ........................ http://home.eng.iastate.edu/~cnchu" << endl;
cout << endl;
cmess2 << af->getPrint() << endl;
unicorn->registerTool ( Mauka::GraphicMaukaEngine::grab() ); unicorn->registerTool ( Mauka::GraphicMaukaEngine::grab() );
//unicorn->registerTool ( Knik::GraphicKnikEngine::grab() ); //unicorn->registerTool ( Knik::GraphicKnikEngine::grab() );
@ -455,12 +437,16 @@ int main ( int argc, char *argv[] )
} }
} }
} }
catch ( Error& e ) {
cerr << e.what() << endl;
exit ( 1 );
}
catch ( boptions::error& e ) { catch ( boptions::error& e ) {
cerr << "[ERROR] " << e.what() << endl; cerr << "[ERROR] " << e.what() << endl;
exit ( 1 ); exit ( 1 );
} }
catch ( Error& e ) { catch ( exception& e ) {
cerr << e.what() << endl; cerr << "[ERROR] " << e.what() << endl;
exit ( 1 ); exit ( 1 );
} }
catch ( ... ) { catch ( ... ) {

View File

@ -50,16 +50,18 @@ namespace Unicorn {
// Class : "UnicornGui". // Class : "UnicornGui".
Banner UnicornGui::_banner ( "Unicorn"
, "1.0b"
, "Coriolis Main GUI"
, "2008"
, "Jean-Paul Chaput"
, ""
);
UnicornGui::UnicornGui ( QWidget* parent ) UnicornGui::UnicornGui ( QWidget* parent )
: CellViewer(parent) : CellViewer(parent)
, _banner ( "Unicorn" , _tools ()
, "1.0b"
, "Coriolis Main GUI"
, "2008"
, "Jean-Paul Chaput"
, ""
)
, _tools()
{ } { }

View File

@ -52,23 +52,22 @@ namespace Unicorn {
class UnicornGui : public CellViewer { class UnicornGui : public CellViewer {
Q_OBJECT; Q_OBJECT;
public: public:
static UnicornGui* create ( QWidget* parent=NULL ); static UnicornGui* create ( QWidget* parent=NULL );
void destroy (); void destroy ();
inline Banner& getBanner (); static inline Banner& getBanner ();
virtual Cell* getCellFromDb ( const char* name ); virtual Cell* getCellFromDb ( const char* name );
void registerTool ( GraphicTool* ); void registerTool ( GraphicTool* );
public slots: public slots:
void openCell (); void openCell ();
void saveCell (); void saveCell ();
protected: protected:
UnicornGui ( QWidget* parent ); UnicornGui ( QWidget* parent );
virtual ~UnicornGui (); virtual ~UnicornGui ();
virtual void _postCreate (); virtual void _postCreate ();
virtual void _preDestroy (); virtual void _preDestroy ();
protected: protected:
Banner _banner; static Banner _banner;
set<GraphicTool*> _tools; set<GraphicTool*> _tools;
}; };