01: /*
02: JSmooth: a VM wrapper toolkit for Windows
03: Copyright (C) 2003 Rodrigo Reyes <reyes@charabia.net>
04:
05: This program is free software; you can redistribute it and/or modify
06: it under the terms of the GNU General Public License as published by
07: the Free Software Foundation; either version 2 of the License, or
08: (at your option) any later version.
09:
10: This program is distributed in the hope that it will be useful,
11: but WITHOUT ANY WARRANTY; without even the implied warranty of
12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13: GNU General Public License for more details.
14:
15: You should have received a copy of the GNU General Public License
16: along with this program; if not, write to the Free Software
17: Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18:
19: */
20:
21: package net.charabia.jsmoothgen.application.cmdline;
22:
23: import net.charabia.jsmoothgen.application.*;
24: import net.charabia.jsmoothgen.skeleton.*;
25: import net.charabia.jsmoothgen.pe.*;
26:
27: import java.io.*;
28:
29: public class CommandLine {
30:
31: static void printUsage() {
32: System.out.println("Usage: jsmoothc [projectfile.jsmooth]");
33: System.out
34: .println(" where projectfile.jsmooth is a project file created by JSmoothGen");
35: }
36:
37: public static void main(String[] args) {
38: if (args.length != 1) {
39: printUsage();
40: System.exit(10);
41: }
42:
43: File prj = new File(args[0]);
44: if (prj.exists() == false) {
45: prj = new File(prj.toString() + ".jsmooth");
46: }
47:
48: if (prj.exists() == false) {
49: System.err.println("Error: project file <" + args[0]
50: + "> not found");
51: System.exit(10);
52: }
53:
54: // setup headless mode
55: System.setProperty("java.awt.headless", "true");
56: java.awt.Toolkit tk = java.awt.Toolkit.getDefaultToolkit();
57:
58: String jsmoothbase = System.getProperty("jsmooth.basedir");
59:
60: try {
61: JSmoothModelBean model = JSmoothModelPersistency.load(prj);
62: File basedir = prj.getParentFile();
63: File skelbase = new File("skeletons");
64: if (jsmoothbase != null) {
65: skelbase = new File(new File(jsmoothbase), "skeletons");
66: }
67:
68: SkeletonList skelList = new SkeletonList(skelbase);
69:
70: File out = new File(basedir, model.getExecutableName());
71:
72: SkeletonBean skel = skelList.getSkeleton(model
73: .getSkeletonName());
74: File skelroot = skelList.getDirectory(skel);
75:
76: ExeCompiler compiler = new ExeCompiler();
77: compiler.compile(skelroot, skel, basedir, model, out);
78:
79: System.exit(0);
80:
81: } catch (Exception exc) {
82: // exc.printStackTrace();
83: System.err.println("Incorrect project file!");
84: }
85:
86: System.exit(20);
87: }
88:
89: }
|