Bug 100843 - Add an explicit output filename option (-e) to xpidl
Patch by aegis@aegisknight.org, r=dbradley, sr=scc git-svn-id: svn://10.0.0.236/trunk@106861 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
28d45091af
commit
c3fe6e0f41
@ -64,14 +64,17 @@ gboolean enable_debug = FALSE;
|
||||
gboolean enable_warnings = FALSE;
|
||||
gboolean verbose_mode = FALSE;
|
||||
gboolean emit_typelib_annotations = FALSE;
|
||||
gboolean explicit_output_filename = FALSE;
|
||||
|
||||
static char xpidl_usage_str[] =
|
||||
"Usage: %s [-m mode] [-w] [-v] [-I path] [-o basename] filename.idl\n"
|
||||
"Usage: %s [-m mode] [-w] [-v]\n"
|
||||
" [-I path] [-o basename | -e filename.ext] filename.idl\n"
|
||||
" -a emit annotations to typelib\n"
|
||||
" -w turn on warnings (recommended)\n"
|
||||
" -v verbose mode (NYI)\n"
|
||||
" -I add entry to start of include path for ``#include \"nsIThing.idl\"''\n"
|
||||
" -o use basename (e.g. ``/tmp/nsIThing'') for output\n"
|
||||
" -e use explicit output filename\n"
|
||||
" -m specify output mode:\n";
|
||||
|
||||
static void
|
||||
@ -154,8 +157,17 @@ int main(int argc, char *argv[])
|
||||
xpidl_usage(argc, argv);
|
||||
return 1;
|
||||
}
|
||||
file_basename = argv[i + 1];
|
||||
i++;
|
||||
file_basename = argv[++i];
|
||||
explicit_output_filename = FALSE;
|
||||
break;
|
||||
case 'e':
|
||||
if (i == argc) {
|
||||
fprintf(stderr, "ERROR: missing basename after -e\n");
|
||||
xpidl_usage(argc, argv);
|
||||
return 1;
|
||||
}
|
||||
file_basename = argv[++i];
|
||||
explicit_output_filename = TRUE;
|
||||
break;
|
||||
case 'm':
|
||||
if (i == argc) {
|
||||
|
||||
@ -82,6 +82,7 @@ extern gboolean enable_debug;
|
||||
extern gboolean enable_warnings;
|
||||
extern gboolean verbose_mode;
|
||||
extern gboolean emit_typelib_annotations;
|
||||
extern gboolean explicit_output_filename;
|
||||
|
||||
typedef struct TreeState TreeState;
|
||||
|
||||
|
||||
@ -711,22 +711,30 @@ xpidl_process_idl(char *filename, IncludePathEntry *include_path,
|
||||
|
||||
if (strcmp(outname, "-")) {
|
||||
const char *fopen_mode;
|
||||
const char *out_basename;
|
||||
#if defined(XP_UNIX)
|
||||
const char os_separator = '/';
|
||||
#elif defined(XP_WIN)
|
||||
const char os_separator = '\\';
|
||||
#endif
|
||||
|
||||
#if defined(XP_UNIX) || defined(XP_WIN)
|
||||
tmp = strrchr(outname, os_separator);
|
||||
if (!file_basename && tmp) {
|
||||
real_outname = g_strdup_printf("%s.%s", tmp + 1, mode->suffix);
|
||||
/* explicit_output_filename can't be true without a filename */
|
||||
if (explicit_output_filename) {
|
||||
real_outname = g_strdup(outname);
|
||||
} else {
|
||||
real_outname = g_strdup_printf("%s.%s", outname, mode->suffix);
|
||||
}
|
||||
|
||||
#if defined(XP_UNIX) || defined(XP_WIN)
|
||||
tmp = strrchr(outname, os_separator);
|
||||
if (!file_basename && tmp) {
|
||||
out_basename = tmp + 1;
|
||||
} else {
|
||||
out_basename = outname;
|
||||
}
|
||||
#else
|
||||
real_outname = g_strdup_printf("%s.%s", outname, mode->suffix);
|
||||
out_basename = outname;
|
||||
#endif
|
||||
real_outname = g_strdup_printf("%s.%s", out_basename, mode->suffix);
|
||||
}
|
||||
|
||||
/* Use binary write for typelib mode */
|
||||
fopen_mode = (strcmp(mode->mode, "typelib")) ? "w" : "wb";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user