1 /* cacaoh/cacaoh.c - main for header generation (cacaoh)
3 Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4 R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5 C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6 Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
27 Authors: Reinhard Grafl
33 $Id: cacaoh.c 1735 2004-12-07 14:33:27Z twisti $
44 #include "cacaoh/headers.h"
46 #include "mm/memory.h"
48 #if defined(USE_THREADS)
49 # if defined(NATIVE_THREADS)
50 # include "threads/native/threads.h"
52 # include "threads/green/threads.h"
56 #include "toolbox/logging.h"
57 #include "vm/global.h"
58 #include "vm/loader.h"
59 #include "vm/options.h"
60 #include "vm/tables.h"
63 /* define cacaoh options ******************************************************/
68 #define OPT_DIRECTORY 5
71 { "help", false, OPT_HELP },
72 { "version", false, OPT_VERSION },
73 { "verbose", false, OPT_VERBOSE },
74 { "d", true, OPT_DIRECTORY },
79 /* usage ***********************************************************************
81 Obviously prints usage information of cacaoh.
83 *******************************************************************************/
87 printf("Usage: cacaoh [options] <classes>\n"
90 " -help Print this message\n"
91 " -version Print version information\n"
92 " -verbose Enable verbose output\n"
93 " -d <dir> Output directory\n");
95 /* exit with error code */
101 static void version()
103 printf("cacaoh "VERSION"\n");
108 /* main ************************************************************************
112 *******************************************************************************/
114 int main(int argc, char **argv)
121 /********** internal (only used by main) *****************************/
123 char classpath[500] = "";
124 u4 heapmaxsize = 2 * 1024 * 1024;
125 u4 heapstartsize = 100 * 1024;
128 /************ Collect some info from the environment *****************/
133 cp = getenv("CLASSPATH");
135 strcpy(classpath + strlen(classpath), ":");
136 strcpy(classpath + strlen(classpath), cp);
139 /* initialize options with default values */
142 opt_directory = NULL;
144 while ((i = get_opt(argc, argv, opts)) != OPT_DONE) {
162 opt_directory = MNEW(char, strlen(opt_arg));
163 strcpy(opt_directory, opt_arg);
171 /**************************** Program start **************************/
175 log_text("Java - header-generator started");
178 /* initialize the garbage collector */
179 gc_init(heapmaxsize, heapstartsize);
183 suck_init(classpath);
185 #if defined(USE_THREADS)
186 #if defined(NATIVE_THREADS)
195 /*********************** Load JAVA classes **************************/
197 nativemethod_chain = chain_new();
198 nativeclass_chain = chain_new();
200 for (a = opt_ind; a < argc; a++) {
203 /* convert classname */
204 for (i = strlen(cp) - 1; i >= 0; i--) {
212 c = class_new(utf_new_char(cp));
214 /* exceptions are catched with new_exception call */
218 headerfile_generate(c, opt_directory);
221 /************************ Release all resources **********************/
224 tables_close(literalstring_free);
227 log_text("Java - header-generator stopped");
237 * These are local overrides for various environment variables in Emacs.
238 * Please do not remove this and leave it at the end of the file, where
239 * Emacs will automagically detect them.
240 * ---------------------------------------------------------------------
243 * indent-tabs-mode: t