root/release-kits/wirk2/src/wirk2.cpp @ 16746

Revision 16746, 4.8 KB (checked in by oranfry, 12 years ago)

leave these options to ant now

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 WIRK2_HOME = getenv( "WIRK2_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;" + WIRK2_HOME + "\\lib\\serializer.jar;" + WIRK2_HOME + "\\lib\\xalan.jar;" + WIRK2_HOME + "\\lib\\xercesImpl.jar;" + WIRK2_HOME + "\\lib\\xml-apis.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\ant-antlr.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\ant-apache-bcel.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\ant-apache-bsf.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\ant-apache-log4j.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\ant-apache-oro.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\ant-apache-regexp.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\ant-apache-resolver.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\ant-commons-logging.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\ant-commons-net.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\ant-icontract.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\ant-jai.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\ant.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\ant-javamail.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\ant-jdepend.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\ant-jmf.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\ant-jsch.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\ant-junit.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\ant-launcher.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\ant-netrexx.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\ant-nodeps.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\ant-starteam.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\ant-stylebook.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\ant-swing.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\ant-trax.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\ant-vaj.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\ant-weblogic.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\ant-xalan1.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\ant-xslp.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\xercesImpl.jar;" + WIRK2_HOME + "\\packages\\ant\\lib\\xml-apis.jar;" + WIRK2_HOME + "\\packages\\ant-installer\\lib\\ai-icons-amaranth.jar;" + WIRK2_HOME + "\\packages\\ant-installer\\lib\\ai-icons-bluecurve.jar;" + WIRK2_HOME + "\\packages\\ant-installer\\lib\\ai-icons-crystalsvg.jar;" + WIRK2_HOME + "\\packages\\ant-installer\\lib\\ai-icons-eclipse.jar;" + WIRK2_HOME + "\\packages\\ant-installer\\lib\\ai-icons-krystaline.jar;" + WIRK2_HOME + "\\packages\\ant-installer\\lib\\ant-installer-ext.jar;" + WIRK2_HOME + "\\packages\\ant-installer\\lib\\ant-installer.jar;" + WIRK2_HOME + "\\packages\\ant-installer\\lib\\jgoodies-edited-1_2_2.jar;" + WIRK2_HOME + "\\packages\\ant-installer\\lib\\xercesImpl.jar;" + WIRK2_HOME + "\\packages\\ant-installer\\lib\\xml-apis.jar;" + WIRK2_HOME + "\\packages\\ant-installer\\classes";
40    putenv( ("CLASSPATH=" + classpath).c_str() );
41
42    //check that it worked
43    //string changed_classpath = getenv("CLASSPATH");
44    //cout << "classpath: " << changed_classpath << endl;
45   
46    //create the command
47    command = WIRK2_HOME + "\\packages\\ant\\bin\\ant.bat -f " + WIRK2_HOME + "\\ant-scripts\\build.xml -Dwirk2.home=" + WIRK2_HOME;
48    //pass on the arguments
49    string a;
50    for ( int i=0; i < argc; i++ ) {
51        a = argv[i];
52           
53        if ( a.compare("-help") == 0 ) {
54            //show_help();
55            return 0;
56       
57        } else if ( a.compare("-cp") == 0) {
58            cout << classpath;
59            return 0;
60
61        } else {
62            command = command + " " + a;
63        }
64
65    }
66
67   
68    //use forward slashes for everything else
69    //replace_all( pwd, "\\", "/" );
70   
71    //set the basedir in the command
72    command = command + " -Dbasedir=";
73    command = command + pwd;
74
75
76   
77    //command = command + ".";
78
79    cout
80        << "O-----------------------------------------O" << endl
81        << "|                                         |" << endl
82        << "|   WiRK2                                 |" << endl
83        << "|   Windows Release Kit for Greenstone2   |" << endl
84        << "|                                         |" << endl
85        << "O-----------------------------------------O" << endl
86        ;
87   
88    cout << "pwd: " << pwd << endl;
89    cout << "command: " << command << endl;
90
91    system( command.c_str() );
92   
93    return 0;
94
95}
Note: See TracBrowser for help on using the browser.