1998-12-03 09:33:59 +03:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
1998-11-28 19:52:24 +03:00
|
|
|
/*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
|
1998-12-02 22:53:27 +03:00
|
|
|
/*
|
|
|
|
* Main xpidl program entry point.
|
|
|
|
*/
|
|
|
|
|
1998-11-24 00:02:31 +03:00
|
|
|
#include "xpidl.h"
|
|
|
|
|
|
|
|
gboolean enable_debug = FALSE;
|
|
|
|
gboolean enable_warnings = FALSE;
|
|
|
|
gboolean verbose_mode = FALSE;
|
|
|
|
gboolean generate_docs = FALSE;
|
1998-12-18 20:12:07 +03:00
|
|
|
gboolean generate_typelib = FALSE;
|
1998-11-24 00:02:31 +03:00
|
|
|
gboolean generate_headers = FALSE;
|
|
|
|
gboolean generate_nothing = FALSE;
|
|
|
|
|
|
|
|
static char xpidl_usage_str[] =
|
1998-12-18 20:12:07 +03:00
|
|
|
"Usage: %s [-t] [-d] [-h] [-w] [-v] [-I path] [-n] [-o basename] filename.idl\n"
|
|
|
|
" -t generate typelib data (filename.xpt) (NYI)\n"
|
1998-12-09 16:08:29 +03:00
|
|
|
" -d generate HTML documentation (filename.html) (NYI)\n"
|
1998-12-06 21:41:44 +03:00
|
|
|
" -h generate C++ headers (filename.h)\n"
|
1998-11-24 00:02:31 +03:00
|
|
|
" -w turn on warnings (recommended)\n"
|
1998-12-06 21:41:44 +03:00
|
|
|
" -v verbose mode (NYI)\n"
|
|
|
|
" -I add entry to start of include path for ``#include \"nsIThing.idl\"''\n"
|
1998-12-14 21:47:39 +03:00
|
|
|
" -n do not generate output files, just test IDL (NYI)\n"
|
|
|
|
" -o use basename (e.g. ``/tmp/nsIThing'') for output\n";
|
1998-11-24 00:02:31 +03:00
|
|
|
|
|
|
|
static void
|
|
|
|
xpidl_usage(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
/* XXX Mac! */
|
|
|
|
fprintf(stderr, xpidl_usage_str, argv[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int i, idlfiles;
|
1998-12-06 21:41:44 +03:00
|
|
|
IncludePathEntry *inc, *inc_head = NULL;
|
1998-12-14 21:47:39 +03:00
|
|
|
char *basename = NULL;
|
1998-12-06 21:41:44 +03:00
|
|
|
|
|
|
|
inc_head = malloc(sizeof *inc);
|
|
|
|
if (!inc_head)
|
|
|
|
return 1;
|
|
|
|
inc_head->directory = ".";
|
|
|
|
inc_head->next = NULL;
|
1998-11-24 00:02:31 +03:00
|
|
|
|
|
|
|
for (i = 1; i < argc; i++) {
|
1998-12-06 21:41:44 +03:00
|
|
|
if (argv[i][0] != '-')
|
|
|
|
break;
|
|
|
|
switch (argv[i][1]) {
|
|
|
|
case 'd':
|
|
|
|
generate_docs = TRUE;
|
|
|
|
break;
|
1998-12-18 20:12:07 +03:00
|
|
|
case 't':
|
|
|
|
generate_typelib = TRUE;
|
1998-12-06 21:41:44 +03:00
|
|
|
break;
|
|
|
|
case 'h':
|
1998-12-18 20:12:07 +03:00
|
|
|
generate_headers = TRUE;
|
|
|
|
break;
|
1998-12-06 21:41:44 +03:00
|
|
|
case 'w':
|
|
|
|
enable_warnings = TRUE;
|
|
|
|
break;
|
|
|
|
case 'v':
|
|
|
|
verbose_mode = TRUE;
|
|
|
|
break;
|
|
|
|
case 'n':
|
|
|
|
generate_nothing = TRUE;
|
|
|
|
break;
|
|
|
|
case 'I':
|
|
|
|
if (i == argc) {
|
|
|
|
fputs("ERROR: missing path after -I\n", stderr);
|
1998-12-03 09:33:59 +03:00
|
|
|
xpidl_usage(argc, argv);
|
|
|
|
return 1;
|
|
|
|
}
|
1998-12-06 21:41:44 +03:00
|
|
|
inc = malloc(sizeof *inc);
|
|
|
|
if (!inc)
|
|
|
|
return 1;
|
|
|
|
inc->directory = argv[i + 1];
|
1998-12-14 21:47:39 +03:00
|
|
|
#ifdef DEBUG_shaver_includes
|
1998-12-06 21:41:44 +03:00
|
|
|
fprintf(stderr, "adding %s to include path\n", inc->directory);
|
|
|
|
#endif
|
|
|
|
inc->next = inc_head;
|
|
|
|
inc_head = inc;
|
|
|
|
i++;
|
|
|
|
break;
|
1998-12-14 21:47:39 +03:00
|
|
|
case 'o':
|
|
|
|
if (i == argc) {
|
|
|
|
fprintf(stderr, "ERROR: missing basename after -o\n", stderr);
|
|
|
|
xpidl_usage(argc, argv);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
basename = argv[i + 1];
|
|
|
|
i++;
|
1998-12-06 21:41:44 +03:00
|
|
|
default:
|
|
|
|
xpidl_usage(argc, argv);
|
|
|
|
return 1;
|
1998-12-03 09:33:59 +03:00
|
|
|
}
|
1998-11-24 00:02:31 +03:00
|
|
|
}
|
|
|
|
|
1998-12-18 20:12:07 +03:00
|
|
|
if (!(generate_docs || generate_typelib || generate_headers)) {
|
|
|
|
fprintf(stderr, "ERROR: must specify one of -t, -d, -h\n");
|
1998-12-03 09:33:59 +03:00
|
|
|
xpidl_usage(argc, argv);
|
|
|
|
return 1;
|
1998-12-02 22:53:27 +03:00
|
|
|
}
|
|
|
|
|
1998-12-06 21:41:44 +03:00
|
|
|
for (idlfiles = 0; i < argc; i++) {
|
1998-12-03 09:33:59 +03:00
|
|
|
if (argv[i][0] && argv[i][0] != '-')
|
1998-12-14 21:47:39 +03:00
|
|
|
idlfiles += xpidl_process_idl(argv[i], inc_head, basename);
|
1998-11-24 00:02:31 +03:00
|
|
|
}
|
|
|
|
|
1998-12-14 21:47:39 +03:00
|
|
|
if (!idlfiles)
|
1998-12-03 09:33:59 +03:00
|
|
|
return 1;
|
1998-11-24 00:02:31 +03:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|