root/release-kits/wirk3/src/wirk3.cpp @ 16631

Revision 16631, 5.0 KB (checked in by oranfry, 11 years ago)

changes afer splitting gsdl into common, build and runtime

Line 
1#include <windows.h>
2
3#include <fstream>
4#include <iostream>
5#include <string>
6
7using namespace std;
8
9void replace_all ( std::string & str, std::string const & pattern, std::string const & replacement ) {
10
11    std::string::size_type start = str.find( pattern, 0 );
12
13    while ( start != str.npos ) {
14        str.replace( start, pattern.size(), replacement );
15        start = str.find( pattern, start+replacement.size() );
16    }
17
18}
19
20int main(int argc, char** argv ) {
21
22    string classpath, command;
23   
24    //influential environment variables
25    string JAVA_HOME = getenv( "JAVA_HOME" );
26    string WIRK3_HOME = getenv( "WIRK3_HOME" );
27    //string PWD = getenv( "CD" );
28
29    //get the pwd
30    string pwd;
31    system( "CD > cd.dat" );
32    ifstream file( "cd.dat" ) ;
33    getline(file, pwd);
34    file.close();
35    system( "del cd.dat" );
36   
37   
38    //set the classpath
39    classpath = pwd + "\\installer\\classes;" + JAVA_HOME + "\\lib\\tools.jar;" + WIRK3_HOME + "\\lib\\serializer.jar;" + WIRK3_HOME + "\\lib\\xalan.jar;" + WIRK3_HOME + "\\lib\\xercesImpl.jar;" + WIRK3_HOME + "\\lib\\xml-apis.jar;" + WIRK3_HOME + "\\packages\\ant\\lib\\ant-antlr.jar;" + WIRK3_HOME + "\\packages\\ant\\lib\\ant-apache-bcel.jar;" + WIRK3_HOME + "\\packages\\ant\\lib\\ant-apache-bsf.jar;" + WIRK3_HOME + "\\packages\\ant\\lib\\ant-apache-log4j.jar;" + WIRK3_HOME + "\\packages\\ant\\lib\\ant-apache-oro.jar;" + WIRK3_HOME + "\\packages\\ant\\lib\\ant-apache-regexp.jar;" + WIRK3_HOME + "\\packages\\ant\\lib\\ant-apache-resolver.jar;" + WIRK3_HOME + "\\packages\\ant\\lib\\ant-commons-logging.jar;" + WIRK3_HOME + "\\packages\\ant\\lib\\ant-commons-net.jar;" + WIRK3_HOME + "\\packages\\ant\\lib\\ant-icontract.jar;" + WIRK3_HOME + "\\packages\\ant-1.6.5\\lib\\ant-jai.jar;" + WIRK3_HOME + "\\packages\\ant\\lib\\ant.jar;" + WIRK3_HOME + "\\packages\\ant\\lib\\ant-javamail.jar;" + WIRK3_HOME + "\\packages\\ant\\lib\\ant-jdepend.jar;" + WIRK3_HOME + "\\packages\\ant\\lib\\ant-jmf.jar;" + WIRK3_HOME + "\\packages\\ant\\lib\\ant-jsch.jar;" + WIRK3_HOME + "\\packages\\ant\\lib\\ant-junit.jar;" + WIRK3_HOME + "\\packages\\ant\\lib\\ant-launcher.jar;" + WIRK3_HOME + "\\packages\\ant\\lib\\ant-netrexx.jar;" + WIRK3_HOME + "\\packages\\ant\\lib\\ant-nodeps.jar;" + WIRK3_HOME + "\\packages\\ant\\lib\\ant-starteam.jar;" + WIRK3_HOME + "\\packages\\ant\\lib\\ant-stylebook.jar;" + WIRK3_HOME + "\\packages\\ant\\lib\\ant-swing.jar;" + WIRK3_HOME + "\\packages\\ant\\lib\\ant-trax.jar;" + WIRK3_HOME + "\\packages\\ant\\lib\\ant-vaj.jar;" + WIRK3_HOME + "\\packages\\ant\\lib\\ant-weblogic.jar;" + WIRK3_HOME + "\\packages\\ant\\lib\\ant-xalan1.jar;" + WIRK3_HOME + "\\packages\\ant\\lib\\ant-xslp.jar;" + WIRK3_HOME + "\\packages\\ant\\lib\\xercesImpl.jar;" + WIRK3_HOME + "\\packages\\ant\\lib\\xml-apis.jar;" + WIRK3_HOME + "\\packages\\ant-installer\\lib\\ai-icons-amaranth.jar;" + WIRK3_HOME + "\\packages\\ant-installer\\lib\\ai-icons-bluecurve.jar;" + WIRK3_HOME + "\\packages\\ant-installer\\lib\\ai-icons-crystalsvg.jar;" + WIRK3_HOME + "\\packages\\ant-installer\\lib\\ai-icons-eclipse.jar;" + WIRK3_HOME + "\\packages\\ant-installer\\lib\\ai-icons-krystaline.jar;" + WIRK3_HOME + "\\packages\\ant-installer\\lib\\ant-installer-ext.jar;" + WIRK3_HOME + "\\packages\\ant-installer\\lib\\ant-installer.jar;" + WIRK3_HOME + "\\packages\\ant-installer\\lib\\jgoodies-edited-1_2_2.jar;" + WIRK3_HOME + "\\packages\\ant-installer\\lib\\xercesImpl.jar;" + WIRK3_HOME + "\\packages\\ant-installer\\lib\\xml-apis.jar;" + WIRK3_HOME + "\\packages\\ant-installer\\classes";
40    putenv( ("CLASSPATH=" + classpath).c_str() );
41
42    //create the command
43    command = WIRK3_HOME + "\\packages\\ant\\bin\\ant.bat -f " + WIRK3_HOME + "\\ant-scripts\\build.xml -Dwirk3.home=" + WIRK3_HOME;
44    //pass on the arguments
45    string a;
46    for ( int i=0; i < argc; i++ ) {
47        a = argv[i];
48           
49        if ( a.compare("-help") == 0 ) {
50            //show_help();
51            return 0;
52       
53        } else if ( a.compare("-cp") == 0) {
54            cout << classpath;
55            return 0;
56
57        } else if ( a.compare("-sim") == 0 ) {
58            command += " -Dexecute=false";
59
60        } else if ( a.compare("-descend") == 0 ) {
61            command = command + " -Dresume.descend=" + argv[++i];
62        } else if ( a.compare("-from") == 0 ) {
63            command = command + " -Dresume.from=" + argv[++i];
64        } else if ( a.compare("-to") == 0 ) {
65            command = command + " -Dresume.to=" + argv[++i];
66        } else {
67            command = command + " " + a;
68        }
69
70    }
71
72   
73    //use forward slashes for everything else
74    //replace_all( pwd, "\\", "/" );
75   
76    //set the basedir in the command
77    command = command + " -Dbasedir=";
78    command = command + pwd;
79
80
81   
82    //command = command + ".";
83
84    cout
85        << "O-----------------------------------------O" << endl
86        << "|                                         |" << endl
87        << "|   WiRK3                                 |" << endl
88        << "|   Windows Release Kit for Greenstone3   |" << endl
89        << "|                                         |" << endl
90        << "O-----------------------------------------O" << endl
91        ;
92   
93    cout << "pwd: " << pwd << endl;
94    cout << "command: " << command << endl;
95
96    system( command.c_str() );
97   
98    return 0;
99
100}
Note: See TracBrowser for help on using the browser.