Commit 9b39cba9 by Basile Starynkevitch Committed by Rafael Espindola

gengtype.c (plugin_output): New.

2009-09-29  Basile Starynkevitch  <basile@starynkevitch.net>
            Rafael Avila de Espindola  <espindola@google.com>

	* gengtype.c (plugin_output): New.
	(get_output_file_with_visibility): Return plugin_output for plugins.
	(main): Parse and use the -P option.
	* gty.texi: Update the command line format.


Co-Authored-By: Rafael Avila de Espindola <espindola@google.com>

From-SVN: r152286
parent 4a0ce41d
2009-09-29 Basile Starynkevitch <basile@starynkevitch.net>
Rafael Avila de Espindola <espindola@google.com>
* gengtype.c (plugin_output): New.
(get_output_file_with_visibility): Return plugin_output for plugins.
(main): Parse and use the -P option.
* gty.texi: Update the command line format.
2009-09-29 Jakub Jelinek <jakub@redhat.com> 2009-09-29 Jakub Jelinek <jakub@redhat.com>
PR debug/41438 PR debug/41438
...@@ -451,11 +451,10 @@ somewhere. It will be called @file{gtype-@var{lang}.h}, where ...@@ -451,11 +451,10 @@ somewhere. It will be called @file{gtype-@var{lang}.h}, where
@var{lang} is the name of the subdirectory the language is contained in. @var{lang} is the name of the subdirectory the language is contained in.
Plugins can add additional root tables. Run the @code{gengtype} Plugins can add additional root tables. Run the @code{gengtype}
utility in plugin mode as @code{gengtype -p @var{source-dir} utility in plugin mode as @code{gengtype -P pluginout.h @var{source-dir}
@var{file-list} @var{plugin*.c}} with your plugin files @var{file-list} @var{plugin*.c}} with your plugin files
@var{plugin*.c} using @code{GTY} to generate the corresponding @var{plugin*.c} using @code{GTY} to generate the @var{pluginout.h} file.
@var{gt-plugin*.h} files. The GCC build tree is needed to be present in The GCC build tree is needed to be present in that mode.
that mode.
@node Invoking the garbage collector @node Invoking the garbage collector
......
...@@ -145,6 +145,8 @@ static outf_p output_files; ...@@ -145,6 +145,8 @@ static outf_p output_files;
directory. */ directory. */
static char** plugin_files; static char** plugin_files;
static size_t nb_plugin_files; static size_t nb_plugin_files;
/* the generated plugin output name & file */
static outf_p plugin_output;
/* The output header file that is included into pretty much every /* The output header file that is included into pretty much every
source file. */ source file. */
...@@ -1714,14 +1716,13 @@ get_output_file_with_visibility (const char *input_file) ...@@ -1714,14 +1716,13 @@ get_output_file_with_visibility (const char *input_file)
/* In plugin mode, return NULL unless the input_file is one of the /* In plugin mode, return NULL unless the input_file is one of the
plugin_files. */ plugin_files. */
if (plugin_files && nb_plugin_files > 0) if (plugin_files)
{ {
int ix= -1;
size_t i; size_t i;
for (i = 0; i < nb_plugin_files && ix < 0; i++) for (i = 0; i < nb_plugin_files; i++)
if (strcmp (input_file, plugin_files[i]) == 0) if (strcmp (input_file, plugin_files[i]) == 0)
ix = i; return plugin_output;
if (ix < 0)
return NULL; return NULL;
} }
...@@ -3667,20 +3668,24 @@ main (int argc, char **argv) ...@@ -3667,20 +3668,24 @@ main (int argc, char **argv)
size_t i; size_t i;
static struct fileloc pos = { this_file, 0 }; static struct fileloc pos = { this_file, 0 };
char* inputlist = 0; char* inputlist = 0;
outf_p output_header;
char* plugin_output_filename = NULL;
/* fatal uses this */ /* fatal uses this */
progname = "gengtype"; progname = "gengtype";
if (argc >= 5 && !strcmp (argv[1], "-p")) if (argc >= 6 && !strcmp (argv[1], "-P"))
{ {
srcdir = argv[2]; plugin_output_filename = argv[2];
inputlist = argv[3]; plugin_output = create_file ("GCC", plugin_output_filename);
nb_plugin_files = argc-4; srcdir = argv[3];
inputlist = argv[4];
nb_plugin_files = argc - 5;
plugin_files = XCNEWVEC (char *, nb_plugin_files); plugin_files = XCNEWVEC (char *, nb_plugin_files);
for (i = 0; i < nb_plugin_files; i++) for (i = 0; i < nb_plugin_files; i++)
{ {
/* Place an all zero lang_bitmap before the plugin file /* Place an all zero lang_bitmap before the plugin file
name. */ name. */
char *name = argv[i + 4]; char *name = argv[i + 5];
int len = strlen(name) + 1 + sizeof (lang_bitmap); int len = strlen(name) + 1 + sizeof (lang_bitmap);
plugin_files[i] = XCNEWVEC (char, len) + sizeof (lang_bitmap); plugin_files[i] = XCNEWVEC (char, len) + sizeof (lang_bitmap);
strcpy (plugin_files[i], name); strcpy (plugin_files[i], name);
...@@ -3692,7 +3697,8 @@ main (int argc, char **argv) ...@@ -3692,7 +3697,8 @@ main (int argc, char **argv)
inputlist = argv[2]; inputlist = argv[2];
} }
else else
fatal ("usage: gengtype [-p] srcdir input-list [file1 file2 ... fileN]"); fatal ("usage: gengtype [-P pluginout.h] srcdir input-list "
"[file1 file2 ... fileN]");
srcdir_len = strlen (srcdir); srcdir_len = strlen (srcdir);
...@@ -3728,7 +3734,8 @@ main (int argc, char **argv) ...@@ -3728,7 +3734,8 @@ main (int argc, char **argv)
open_base_files (); open_base_files ();
write_enum_defn (structures, param_structs); write_enum_defn (structures, param_structs);
write_types (header_file, structures, param_structs, &ggc_wtd); output_header = plugin_output ? plugin_output : header_file;
write_types (output_header, structures, param_structs, &ggc_wtd);
if (plugin_files == NULL) if (plugin_files == NULL)
{ {
write_types (header_file, structures, param_structs, &pch_wtd); write_types (header_file, structures, param_structs, &pch_wtd);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment