1 /* GRMIC.java -- GIOP support for RMIC.
2 Copyright (C) 2006 Free Software Foundation
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 package gnu.classpath.tools.giop;
24 import gnu.classpath.tools.HelpPrinter;
25 import gnu.classpath.tools.giop.grmic.GiopRmicCompiler;
28 import java.io.FileOutputStream;
29 import java.io.IOException;
30 import java.io.OutputStream;
33 * The main class of the GIOP compiler to generate stubs and ties for
36 * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
41 * The version of the compiler.
43 public static String VERSION = "0.0 alpha pre";
46 * The GRMIC compiler methods
48 * @param args the compiler parameters.
50 public static void main(String[] args)
52 boolean noWrite = false;
53 boolean verbose = false;
55 String HelpPath = "giop/GRMIC.txt";
57 HelpPrinter.checkHelpKey(args, HelpPath);
59 File output = new File(".");
63 HelpPrinter.printHelpAndExit(HelpPath);
67 GiopRmicCompiler compiler = new GiopRmicCompiler();
71 Options: for (int i = 0; i < args.length; i++)
75 compiler.setPoaMode(true);
76 else if (c.equals("-impl"))
77 compiler.setPoaMode(false);
78 else if (c.equals("-v"))
83 else if (c.equals("-nowrite"))
85 else if (c.equals("-nowarn"))
86 compiler.setWarnings(false);
87 else if (c.equals("-verbose"))
90 compiler.setVerbose(true);
92 else if (c.equals("-force"))
94 compiler.setForce(true);
96 else if (c.equals("-d"))
101 output = new File(args[f]);
105 HelpPrinter.printHelpAndExit(HelpPath);
107 else if (c.equals("-classpath"))
112 compiler.setClassPath(args[f]);
116 HelpPrinter.printHelpAndExit(HelpPath);
118 else if (c.charAt(0) != '-')
119 // No more options - start of class list.
127 HelpPrinter.printHelpAndExit(HelpPath);
130 System.out.println("Compiling to " + output.getAbsolutePath());
133 Compile: for (int i = cl; i < args.length; i++)
135 if (args[i].charAt(0) != '-')
138 Class c = compiler.loadClass(args[i]);
141 String packag = compiler.getPackageName().replace('.', '/');
142 File fw = new File(output, packag);
145 String stub = compiler.generateStub();
146 String subName = "_" + compiler.getStubName() + "_Stub.java";
152 String tie = compiler.generateTie();
153 String tieName = "_" + compiler.name(c) + "_Tie.java";
161 OutputStream out = new FileOutputStream(new File(fw,
163 out.write(stub.getBytes());
166 out = new FileOutputStream(new File(fw, tieName));
167 out.write(tie.getBytes());
170 catch (IOException ioex)
172 System.err.println("Output path not accessible");
173 ioex.printStackTrace();
182 * Print the version information.
184 public static void printVersion()
187 ("grmic v "+VERSION+" - GIOP stub and tie generator for javax.rmi.* ");