Skip to content

Commit

Permalink
Change How tao_idl Passes Files to Preprocessor
Browse files Browse the repository at this point in the history
This is a backport of the same commit in
DOCGroup#1357, but with copy
preprocessor input method being the default.

Fixes an issue that came up in
OpenDDS/OpenDDS#2161.

To make behavior of `#include ".."` consistent with C and C++, change
how `tao_idl` calls the C preprocessor by default in most cases from
making a copy of the IDL file to using the IDL file directly.
  • Loading branch information
iguessthislldo committed Dec 30, 2020
1 parent 0fdb3b7 commit b4c82d2
Show file tree
Hide file tree
Showing 13 changed files with 342 additions and 109 deletions.
5 changes: 5 additions & 0 deletions TAO/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ USER VISIBLE CHANGES BETWEEN TAO-2.5.12 and TAO-2.5.13
. Version of IDL specification being used is available as the
`__TAO_IDL_IDL_VERSION` preprocessor macro.

. Added `--preprocessor-input` option to `tao_idl` to make behavior of
`#include ".."` consistent with C and C++. This is not enabled by default
like it is in TAO 3, though. For details, see the `--preprocessor-input`
argument in `docs/compiler.html`.

USER VISIBLE CHANGES BETWEEN TAO-2.5.11 and TAO-2.5.12
======================================================

Expand Down
63 changes: 56 additions & 7 deletions TAO/TAO_IDL/driver/drv_args.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ trademarks or registered trademarks of Sun Microsystems, Inc.
extern long DRV_nfiles;
extern char *DRV_files[];

void process_long_option(long ac, char **av, long &i);
void process_long_option (long ac, char **av, long &i);

// Push a file into the list of files to be processed
void
Expand Down Expand Up @@ -156,6 +156,10 @@ DRV_usage (void)
ACE_TEXT (" --unknown-annotations ARG Set reaction to unknown annotations.\n")
ACE_TEXT (" ARG must be `warn-once` (default), `warn-all`,\n")
ACE_TEXT (" `error`, or `ignore`.\n")
ACE_TEXT (" --preprocessor-input KIND Set C preprocessor file input method. KIND must \n")
ACE_TEXT (" be `guess`, `direct-with-e`, `direct-without-e`,\n")
ACE_TEXT (" `direct-gcc`, or `copy` (default).\n")
ACE_TEXT (" See docs/compiler.html for more info.\n")
));

be_util::usage ();
Expand Down Expand Up @@ -485,7 +489,7 @@ DRV_parse_args (long ac, char **av)
}
else
{
process_long_option(ac, av, i);
process_long_option (ac, av, i);
}
break;

Expand Down Expand Up @@ -556,7 +560,7 @@ DRV_parse_args (long ac, char **av)
}

void
print_idl_versions()
print_idl_versions ()
{
ACE_DEBUG ((LM_INFO,
ACE_TEXT ("These are the valid IDL versions this compiler will accept:\n")
Expand All @@ -570,7 +574,7 @@ print_idl_versions()
}

void
process_long_option(long ac, char **av, long &i)
process_long_option (long ac, char **av, long &i)
{
const char *long_option = av[i] + 2;
bool no_more_args = i + 1 >= ac;
Expand Down Expand Up @@ -680,21 +684,66 @@ process_long_option(long ac, char **av, long &i)
{
invalid_argument = true;
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("\"%C\" is not a valid argument.\n"),
ACE_TEXT ("\"%C\" is not a valid argument to --unknown-annotations.\n"),
av[i]
));
}
}
if (invalid_argument)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("Use either \"warn-once\", \"warn-all\", ")
ACE_TEXT ("\"error\" or \"ignore\".\n"),
ACE_TEXT ("Use \"warn-once\", \"warn-all\", \"error\" or \"ignore\".\n"),
av[i]
));
idl_global->parse_args_exit (1);
}
}
else if (!ACE_OS::strcmp (long_option, "preprocessor-input"))
{
bool invalid_argument = no_more_args;
if (no_more_args)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("--preprocessor-input is missing its required argument.")));
}
else
{
i++;
if (!ACE_OS::strcmp (av[i], "guess"))
{
idl_global->preprocessor_input_ = IDL_GlobalData::PreprocessorInputGuess;
}
else if (!ACE_OS::strcmp (av[i], "direct-with-e"))
{
idl_global->preprocessor_input_ = IDL_GlobalData::PreprocessorInputDirectWithE;
}
else if (!ACE_OS::strcmp (av[i], "direct-without-e"))
{
idl_global->preprocessor_input_ = IDL_GlobalData::PreprocessorInputDirectWithoutE;
}
else if (!ACE_OS::strcmp (av[i], "direct-gcc"))
{
idl_global->preprocessor_input_ = IDL_GlobalData::PreprocessorInputDirectGcc;
}
else if (!ACE_OS::strcmp (av[i], "copy"))
{
idl_global->preprocessor_input_ = IDL_GlobalData::PreprocessorInputCopy;
}
else
{
invalid_argument = true;
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("\"%C\" is not a valid argument to --preprocessor-input.\n"), av[i]));
}
}
if (invalid_argument)
{
ACE_ERROR ((LM_ERROR, ACE_TEXT ("Use \"guess\", \"direct-with-e\", ")
ACE_TEXT ("\"direct-without-e\", \"direct-gcc\", or \"copy\".\n"),
av[i]));
idl_global->parse_args_exit (1);
}
}
else
{
be_global->parse_args (i, av);
Expand Down
Loading

0 comments on commit b4c82d2

Please sign in to comment.