1 | #include <windows.h>
|
---|
2 |
|
---|
3 | #include <fstream>
|
---|
4 | #include <iostream>
|
---|
5 | #include <string>
|
---|
6 |
|
---|
7 | using namespace std;
|
---|
8 |
|
---|
9 | void 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 |
|
---|
20 | int 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 | //set the classpath
|
---|
30 | classpath = 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 + "\\bin\\apache-ant-1.6.5\\lib\\ant-antlr.jar;" + WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-apache-bcel.jar;" + WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-apache-bsf.jar;" + WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-apache-log4j.jar;" + WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-apache-oro.jar;" + WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-apache-regexp.jar;" + WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-apache-resolver.jar;" + WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-commons-logging.jar;" + WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-commons-net.jar;" + WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-icontract.jar;" + WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-jai.jar;" + WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant.jar;" + WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-javamail.jar;" + WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-jdepend.jar;" + WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-jmf.jar;" + WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-jsch.jar;" + WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-junit.jar;" + WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-launcher.jar;" + WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-netrexx.jar;" + WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-nodeps.jar;" + WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-starteam.jar;" + WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-stylebook.jar;" + WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-swing.jar;" + WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-trax.jar;" + WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-vaj.jar;" + WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-weblogic.jar;" + WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-xalan1.jar;" + WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-xslp.jar;" + WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\lib\\xercesImpl.jar;" + WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\lib\\xml-apis.jar;" + WIRK3_HOME + "\\bin\\ant-installer\\lib\\ai-icons-amaranth.jar;" + WIRK3_HOME + "\\bin\\ant-installer\\lib\\ai-icons-bluecurve.jar;" + WIRK3_HOME + "\\bin\\ant-installer\\lib\\ai-icons-crystalsvg.jar;" + WIRK3_HOME + "\\bin\\ant-installer\\lib\\ai-icons-eclipse.jar;" + WIRK3_HOME + "\\bin\\ant-installer\\lib\\ai-icons-krystaline.jar;" + WIRK3_HOME + "\\bin\\ant-installer\\lib\\ant-installer-ext.jar;" + WIRK3_HOME + "\\bin\\ant-installer\\lib\\ant-installer.jar;" + WIRK3_HOME + "\\bin\\ant-installer\\lib\\jgoodies-edited-1_2_2.jar;" + WIRK3_HOME + "\\bin\\ant-installer\\lib\\xercesImpl.jar;" + WIRK3_HOME + "\\bin\\ant-installer\\lib\\xml-apis.jar;" + WIRK3_HOME + "\\bin\\ant-installer\\classes";
|
---|
31 | putenv( ("CLASSPATH=" + classpath).c_str() );
|
---|
32 |
|
---|
33 | //check that it worked
|
---|
34 | //string changed_classpath = getenv("CLASSPATH");
|
---|
35 | //cout << "classpath: " << changed_classpath << endl;
|
---|
36 |
|
---|
37 | //create the command
|
---|
38 | command = WIRK3_HOME + "\\bin\\apache-ant-1.6.5\\bin\\ant.bat -f " + WIRK3_HOME + "\\ant-scripts\\build.xml -Dwirk3.home=" + WIRK3_HOME;
|
---|
39 |
|
---|
40 | //pass on the arguments
|
---|
41 | string a;
|
---|
42 | for ( int i=0; i < argc; i++ ) {
|
---|
43 | a = argv[i];
|
---|
44 |
|
---|
45 | if ( a.compare("-help") == 0 ) {
|
---|
46 | //show_help();
|
---|
47 | return 0;
|
---|
48 |
|
---|
49 | } else if ( a.compare("-cp") == 0) {
|
---|
50 | cout << classpath;
|
---|
51 | return 0;
|
---|
52 |
|
---|
53 | } else if ( a.compare("-sim") == 0 ) {
|
---|
54 | command += " -Dexecute=false";
|
---|
55 |
|
---|
56 | } else if ( a.compare("-descend") == 0 ) {
|
---|
57 | command += " -Dresume.mode=descend";
|
---|
58 |
|
---|
59 | } else if ( a.compare("-from") == 0 ) {
|
---|
60 | command = command + " -Dresume.from=" + argv[++i];
|
---|
61 | //from=`echo $2 | sed 's/compile/1/g' | sed 's/create-distributions/2/g' | sed 's/create-installer/3/g' | sed 's/wrap/4/g'`
|
---|
62 | //toexec=$toexec$from
|
---|
63 | } else if ( a.compare("-to") == 0 ) {
|
---|
64 | command = command + " -Dresume.to=" + argv[++i];
|
---|
65 | //to=`echo $2 | sed 's/compile/1/g' | sed 's/create-distributions/2/g' | sed 's/create-installer/3/g' | sed 's/wrap/4/g'`
|
---|
66 | //toexec=$toexec$to
|
---|
67 | } else {
|
---|
68 | command = command + " " + a;
|
---|
69 | }
|
---|
70 |
|
---|
71 | }
|
---|
72 | //get the pwd
|
---|
73 | string pwd;
|
---|
74 | system( "CD > cd.dat" );
|
---|
75 | ifstream file( "cd.dat" ) ;
|
---|
76 | getline(file, pwd);
|
---|
77 | file.close();
|
---|
78 | system( "del cd.dat" );
|
---|
79 | replace_all( pwd, "\\", "/" );
|
---|
80 |
|
---|
81 | //set the basedir in the command
|
---|
82 | command = command + " -Dbasedir=";
|
---|
83 | command = command + pwd;
|
---|
84 | //command = command + ".";
|
---|
85 |
|
---|
86 | cout
|
---|
87 | << "O-----------------------------------------O" << endl
|
---|
88 | << "| |" << endl
|
---|
89 | << "| WiRK3 |" << endl
|
---|
90 | << "| Windows Release Kit for Greenstone3 |" << endl
|
---|
91 | << "| |" << endl
|
---|
92 | << "O-----------------------------------------O" << endl
|
---|
93 | ;
|
---|
94 |
|
---|
95 | cout << "pwd: " << pwd << endl;
|
---|
96 | cout << "command: " << command << endl;
|
---|
97 |
|
---|
98 | system( command.c_str() );
|
---|
99 |
|
---|
100 | return 0;
|
---|
101 |
|
---|
102 | } |
---|