#include #include #include #include using namespace std; void replace_all ( std::string & str, std::string const & pattern, std::string const & replacement ) { std::string::size_type start = str.find( pattern, 0 ); while ( start != str.npos ) { str.replace( start, pattern.size(), replacement ); start = str.find( pattern, start+replacement.size() ); } } void show_help() { cout << "WirkXXX - Windows Release Kit for GreenstoneXXX" << endl; cout << "Helps you to create releases from the Repository" << endl << endl; cout << "usage: wirkXXX [args]" << endl; cout << " -sim" << endl; cout << " simulation only, don't actually do anything" << endl << endl; cout << " -help" << endl; cout << " show this help screen" << endl << endl; cout << " -from " << endl; cout << " start execution from the target with the given target address" << endl << endl; cout << " -to " << endl; cout << " stop execution just before the target with the given target address" << endl << endl; cout << " -descend " << endl; cout << " execute only the target with the given address, including subtargets" << endl << endl; cout << " -cp" << endl; cout << " show the classpath being used by wirkXXX" << endl << endl; } int main(int argc, char** argv ) { string classpath, command; //some checks bool ok = true; if ( getenv( "JAVA_HOME" ) == NULL ) { cerr << "Please set JAVA_HOME before running wirkXXX" << endl; ok = false; } if ( getenv( "WIRKXXX_HOME" ) == NULL ) { cerr << "Please set WIRKXXX_HOME before running wirkXXX" << endl; ok = false; } if ( !ok ) { return -1; } //load environment variables string JAVA_HOME = getenv( "JAVA_HOME" ); string WIRKXXX_HOME = getenv( "WIRKXXX_HOME" ); putenv( ("ANT_HOME=" + WIRKXXX_HOME + "\\core\\ant").c_str() ); //get the pwd string pwd; system( "CD > cd.dat" ); ifstream file( "cd.dat" ) ; getline(file, pwd); file.close(); system( "del cd.dat" ); //create the command command = WIRKXXX_HOME + "\\core\\ant\\bin\\ant.bat -f \"" + WIRKXXX_HOME + "\\ant-scripts\\build.xml\" -addressing \"-Dwirk3.home=" + WIRKXXX_HOME + "\""; //pass on the arguments string a; bool simMode = false; for ( int i=0; i < argc; i++ ) { a = argv[i]; if ( a.compare("-help") == 0 || a.compare("--help") == 0 ) { show_help(); return 0; } else if ( a.compare("-cp") == 0 || a.compare("--cp") == 0 ) { cout << classpath; return 0; } else if ( a.compare("-sim") == 0) { command = command + " " + a; simMode = true; } else { command = command + " " + a; } } //set the basedir in the command command = command + " \"-Dbasedir=" + pwd + "\""; cout << "O-----------------------------------------O" << endl << "| |" << endl << "| WiRKXXX |" << endl << "| Windows Release Kit for GreenstoneXXX |" << endl << "| |" << endl << "O-----------------------------------------O" << endl ; cout << "pwd: " << pwd << endl; cout << "command: " << command << endl; system( command.c_str() ); return 0; }