Ignore:
Timestamp:
2009-05-14T12:03:27+12:00 (15 years ago)
Author:
oranfry
Message:

fixed generalised wirk source

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release-kits/shared/windows/wirk.cpp

    r19452 r19467  
    44#include <iostream>
    55#include <string>
     6#include <sstream>
     7
     8#ifndef XXX
     9#define XXX 2
     10#endif
    611
    712using namespace std;
     
    2025void show_help() {
    2126
    22     cout << "WirkXXX - Windows Release Kit for GreenstoneXXX" << endl;
     27    cout << "Wirk" << XXX << " - Windows Release Kit for Greenstone" << XXX << endl;
    2328    cout << "Helps you to create releases from the Repository" << endl << endl;
    2429
    25     cout << "usage: wirkXXX [args]" << endl;
     30    cout << "usage: wirk" << XXX << " [args]" << endl;
    2631    cout << "   -sim" << endl;
    2732    cout << "       simulation only, don't actually do anything" << endl << endl;
     
    3944    cout << "       execute only the target with the given address, including subtargets" << endl << endl;
    4045
    41     cout << "   -cp" << endl;
    42     cout << "       show the classpath being used by wirkXXX" << endl << endl;
    43 
    4446}
    4547
    4648
    4749int main(int argc, char** argv ) {
    48 
    49     string classpath, command;
    5050   
    5151    //some checks
    5252    bool ok = true;
    5353    if ( getenv( "JAVA_HOME" ) == NULL ) {
    54         cerr << "Please set JAVA_HOME before running wirkXXX" << endl;
     54        cerr << "Please set JAVA_HOME before running wirk" << XXX << endl;
    5555        ok = false;
    5656    }
    57     if ( getenv( "WIRKXXX_HOME" ) == NULL ) {
    58         cerr << "Please set WIRKXXX_HOME before running wirkXXX" << endl;
     57
     58    stringstream out;
     59    out << "WIRK" << XXX << "_HOME";
     60    string wirk_home_var;
     61    wirk_home_var = out.str();
     62
     63    if ( getenv( wirk_home_var.c_str() ) == NULL ) {
     64        cerr << "Please set " << wirk_home_var << " before running wirk" << XXX << endl;
    5965        ok = false;
    6066    }
     
    6571    //load environment variables
    6672    string JAVA_HOME = getenv( "JAVA_HOME" );
    67     string WIRKXXX_HOME = getenv( "WIRKXXX_HOME" );
    68     putenv( ("ANT_HOME=" + WIRKXXX_HOME + "\\core\\ant").c_str() );
     73    string WIRK_HOME = getenv( wirk_home_var.c_str() );
     74    putenv( ("ANT_HOME=" + WIRK_HOME + "\\core\\ant").c_str() );
    6975   
    7076    //get the pwd
     
    7783       
    7884    //create the command
    79     command = WIRKXXX_HOME + "\\core\\ant\\bin\\ant.bat -f \"" + WIRKXXX_HOME + "\\ant-scripts\\build.xml\" -addressing \"-Dwirk3.home=" + WIRKXXX_HOME + "\"";
     85    stringstream command;
     86    command << WIRK_HOME << "\\core\\ant\\bin\\ant.bat -f \"" << WIRK_HOME << "\\ant-scripts\\build.xml\" -addressing \"-Dwirk" << XXX << ".home=" << WIRK_HOME << "\"";
    8087
    8188    //pass on the arguments
    8289    string a;
    8390    bool simMode = false;
    84     for ( int i=0; i < argc; i++ ) {
     91    for ( int i=1; i < argc; i++ ) {
    8592        a = argv[i];
    8693       
     
    8895            show_help();
    8996            return 0;
    90         } else if ( a.compare("-cp") == 0 || a.compare("--cp") == 0 ) {
    91             cout << classpath;
    92             return 0;
    9397        } else if ( a.compare("-sim") == 0) {
    94             command = command + " " + a;
     98            command << " " << a;
    9599            simMode = true;
    96100        } else {
    97             command = command + " " + a;
     101            command << " " << a;
    98102        }
    99103
     
    101105
    102106    //set the basedir in the command
    103     command = command + " \"-Dbasedir=" + pwd + "\"";
     107    command << " \"-Dbasedir=" << pwd << "\"";
    104108
    105109    cout
    106110        << "O-----------------------------------------O" << endl
    107111        << "|                                         |" << endl
    108         << "|   WiRKXXX                                 |" << endl
    109         << "|   Windows Release Kit for GreenstoneXXX   |" << endl
     112        << "|   WiRK" << XXX << "                                 |" << endl
     113        << "|   Windows Release Kit for Greenstone" << XXX << "   |" << endl
    110114        << "|                                         |" << endl
    111115        << "O-----------------------------------------O" << endl
    112116        ;
    113117   
     118    string final_command = command.str();
    114119    cout << "pwd: " << pwd << endl;
    115     cout << "command: " << command << endl;
     120    cout << "command: " << final_command << endl;
    116121
    117     system( command.c_str() );
     122    system( final_command.c_str() );
    118123   
    119124    return 0;
Note: See TracChangeset for help on using the changeset viewer.