diff --git a/ACE/ACE-INSTALL.html b/ACE/ACE-INSTALL.html index 7bed37506625e..c9e28b4d67756 100644 --- a/ACE/ACE-INSTALL.html +++ b/ACE/ACE-INSTALL.html @@ -1320,7 +1320,7 @@
-
ACE_ROOT
, CPP_LOCATION
,
+ ACE_ROOT
, TAO_IDL_PREPROCESSOR
,
WIND_BASE
, and WIND_HOST_TYPE
environment
variables.
@@ -1370,7 +1370,7 @@
ACE_wrappers/apps/gperf/src
.
CPP_LOCATION=/Program Files/DevStudio/VC/bin/CL.exe +TAO_IDL_PREPROCESSOR=/Program Files/DevStudio/VC/bin/CL.exe cd $TAO_ROOT/tao /gnuwin32/b18/H-i386-cygwin32/bin/make
CPP_LOCATION=/Program Files/DevStudio/VC/bin/CL.exe +TAO_IDL_PREPROCESSOR=/Program Files/DevStudio/VC/bin/CL.exe cd $TAO_ROOT/orbsvcs/orbsvcs /gnuwin32/b18/H-i386-cygwin32/bin/make@@ -1487,7 +1487,7 @@Jaffar Shaikh's SHELL=/bin/sh.exe TERM=pcbios TAO_ROOT=/Corba/ACE_wrapper/Tao -CPP_LOCATION=/Program Files/Microsoft Visual Studio/VC98/Bin/CL.exe +TAO_IDL_PREPROCESSOR=/Program Files/Microsoft Visual Studio/VC98/Bin/CL.exe GCC_EXEC_PREFIX=/tornado/host/x86-win32/lib/gcc-lib/ WIND_HOST_TYPE=x86-win32 PERL_PATH=/perl/bin/perl.exe diff --git a/TAO/NEWS b/TAO/NEWS index 32b437bc561ac..1daeb928e838b 100644 --- a/TAO/NEWS +++ b/TAO/NEWS @@ -124,6 +124,23 @@ USER VISIBLE CHANGES BETWEEN TAO-2.5.12 and TAO-3.0.0 . Add portspan support to DIOP +. TAO IDL: + + . IDL 4 is now the default IDL version. Note that IDL 4 support is still + incomplete. + + . Version of IDL specification being used is available as the + `__TAO_IDL_IDL_VERSION` preprocessor macro. + + . Support for the long deprecated `CPP_LOCATION` and + `TAO_IDL_DEFAULT_CPP_FLAGS` environment variables has been removed; replace + with `TAO_IDL_PREPROCESSOR` and `TAO_IDL_PREPROCESSOR` respectively. + + . To make behavior of `#include ".."` consistent with C and C++, how `tao_idl` + calls the C preprocessor by default in most cases has changed from making a + copy of the IDL file to using the IDL file directly. For details, see the + `--preprocessor-input` argument in `docs/compiler.html`. + USER VISIBLE CHANGES BETWEEN TAO-2.5.11 and TAO-2.5.12 ====================================================== diff --git a/TAO/TAO_IDL/driver/drv_args.cpp b/TAO/TAO_IDL/driver/drv_args.cpp index 03c82030f93de..be47b04fae0b8 100644 --- a/TAO/TAO_IDL/driver/drv_args.cpp +++ b/TAO/TAO_IDL/driver/drv_args.cpp @@ -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 @@ -124,46 +124,42 @@ DRV_usage () ACE_TEXT ("%C: usage: %C [[flag|file] ...] [-- file ...]\n"), idl_global->prog_name (), idl_global->prog_name ())); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Legal flags:\n") - ACE_TEXT (" -h | --help | -u\tPrint this list and exit successfully\n") - ACE_TEXT (" -A...\t\t\tlocal implementation-specific escape\n") - ACE_TEXT (" -Cw\t\t\tWarning if identifier spellings differ ") - ACE_TEXT ("only in case (default is error)\n") - ACE_TEXT (" -Ce\t\t\tError if identifier spellings differ ") - ACE_TEXT ("only in case (default)\n") - ACE_TEXT (" -ae\t\t\tError if anonymous type is seen ") - ACE_TEXT ("(default)\n") - ACE_TEXT (" -aw\t\t\tWarning if anonymous type is seen ") - ACE_TEXT ("(default is error)\n") - ACE_TEXT (" -as\t\t\tSilences the anonymous type diagnostic ") - ACE_TEXT ("(default is error)\n") - ACE_TEXT (" -d | --dump\t\tPrints a dump of the AST and exits\n") - ACE_TEXT (" -Dname[=value]\t\tdefines name for preprocessor\n") - ACE_TEXT (" -E\t\t\truns preprocessor only, prints on stdout\n") - ACE_TEXT (" -Idir\t\t\tincludes dir in search path for preprocessor\n") - ACE_TEXT (" -t\t\t\tTemporary directory to be used") - ACE_TEXT (" by the IDL compiler.\n") - ACE_TEXT (" -Uname\t\t\tundefines name for preprocessor\n") - ACE_TEXT (" -v\t\t\ttraces compilation stages\n") - ACE_TEXT (" -V | --version\t\tprints version info then exits\n") - ACE_TEXT (" -w\t\t\tsuppresses IDL compiler warning messages\n") - ACE_TEXT (" -Wp,
\tpasses args to preprocessor\n") - ACE_TEXT (" -Yp,path\t\tdefines location of preprocessor\n") - ACE_TEXT (" --idl-version VERSION\tSet the version of IDL to use\n") - ACE_TEXT (" --default-idl-version\tPrint the default IDL version and exit\n") - ACE_TEXT (" --list-idl-versions\tPrint IDL versions supported and exit\n") - ACE_TEXT (" --syntax-only\t\tJust check the syntax, do not create files\n") - ACE_TEXT (" --bison-trace\t\tEnable Bison Tracing (sets yydebug to 1)\n") - ACE_TEXT (" --dump-builtins\tDump the compiler and user defined IDL.\n") - ACE_TEXT (" --just-dump-builtins\tJust dump the compiler defined IDL and exit.\n") - ACE_TEXT (" --unknown-annotations ARG\t") - ACE_TEXT ("Set reaction to unknown annotations. ARG must be one of the following:\n") - ACE_TEXT ("\t\t\t\twarn-once\tThe default, warn once per unique local name\n") - ACE_TEXT ("\t\t\t\twarn-all\tWarn for all unknown annotations\n") - ACE_TEXT ("\t\t\t\terror\t\tCauses the process to exit with a failed return status\n") - ACE_TEXT ("\t\t\t\tignore\t\tDon't report unknown annotations\n") + ACE_TEXT (" -h | --help | -u Print this list and exit successfully\n") + ACE_TEXT (" -A... Local implementation-specific escape\n") + ACE_TEXT (" -Cw Warning if identifier spellings differ\n") + ACE_TEXT (" only in case (default is error)\n") + ACE_TEXT (" -Ce Error if identifier spellings differ only in case\n") + ACE_TEXT (" (default)\n") + ACE_TEXT (" -ae Error if anonymous type is seen (default)\n") + ACE_TEXT (" -aw Warning if anonymous type is seen (default is error)\n") + ACE_TEXT (" -as Silences the anonymous type error (default is error)\n") + ACE_TEXT (" -d | --dump Prints a dump of the AST and exits\n") + ACE_TEXT (" -Dname[=value] Defines name for preprocessor\n") + ACE_TEXT (" -E Runs preprocessor only, prints on stdout\n") + ACE_TEXT (" -Idir Includes dir in search path for preprocessor\n") + ACE_TEXT (" -t Temporary directory to be used by the IDL compiler.\n") + ACE_TEXT (" -Uname Undefines name for preprocessor\n") + ACE_TEXT (" -v Traces compilation stages\n") + ACE_TEXT (" -V | --version Prints version info then exits\n") + ACE_TEXT (" -w Suppresses IDL compiler warning messages\n") + ACE_TEXT (" -Wp, Passes args to preprocessor\n") + ACE_TEXT (" -Yp,path Defines location of preprocessor\n") + ACE_TEXT (" --idl-version VERSION Set the version of IDL to use\n") + ACE_TEXT (" --default-idl-version Print the default IDL version and exit\n") + ACE_TEXT (" --list-idl-versions Print IDL versions supported and exit\n") + ACE_TEXT (" --syntax-only Just check the syntax, do not create files\n") + ACE_TEXT (" --bison-trace Enable Bison Tracing (sets yydebug to 1)\n") + ACE_TEXT (" --dump-builtins Dump the compiler and user defined IDL.\n") + ACE_TEXT (" --just-dump-builtins Just dump the compiler defined IDL and exit.\n") + 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` (default), `direct-with-e`, \n") + ACE_TEXT (" `direct-without-e`, `direct-gcc`, or `copy`.\n") + ACE_TEXT (" See docs/compiler.html for more info.\n") )); be_util::usage (); @@ -480,7 +476,7 @@ DRV_parse_args (long ac, char **av) } else { - process_long_option(ac, av, i); + process_long_option (ac, av, i); } break; @@ -551,7 +547,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") @@ -565,7 +561,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; @@ -675,7 +671,7 @@ 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] )); } @@ -683,13 +679,58 @@ process_long_option(long ac, char **av, long &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); diff --git a/TAO/TAO_IDL/driver/drv_preproc.cpp b/TAO/TAO_IDL/driver/drv_preproc.cpp index a26c09cce3a49..349f39fe2be21 100644 --- a/TAO/TAO_IDL/driver/drv_preproc.cpp +++ b/TAO/TAO_IDL/driver/drv_preproc.cpp @@ -87,8 +87,11 @@ trademarks or registered trademarks of Sun Microsystems, Inc. #include "ace/OS_NS_stdio.h" #include "ace/OS_NS_unistd.h" #include "ace/OS_NS_fcntl.h" +#include "ace/OS_NS_ctype.h" #include "ace/OS_NS_sys_stat.h" +#include + // Storage for preprocessor args. unsigned long const DRV_MAX_ARGCOUNT = 1024; unsigned long DRV_argcount = 0; @@ -128,7 +131,7 @@ DRV_cpp_new_location (char const * new_loc) // Push an argument into the DRV_arglist. void -DRV_cpp_putarg (const char *str) +DRV_cpp_putarg (char const *str, bool front) { if (DRV_argcount >= DRV_MAX_ARGCOUNT) { @@ -196,7 +199,14 @@ DRV_cpp_putarg (const char *str) } } - DRV_arglist[DRV_argcount++] = ACE::strnew (ACE_TEXT_CHAR_TO_TCHAR (replace ? replace : str)); + ACE_TCHAR const *tmp = ACE::strnew (ACE_TEXT_CHAR_TO_TCHAR (replace ? replace : str)); + const size_t new_arg_count = DRV_argcount + 1; + if (front) + for (size_t i = 1; i < new_arg_count; ++i) + std::swap(tmp, DRV_arglist[i]); + else + DRV_arglist[DRV_argcount] = tmp; + DRV_argcount = new_arg_count; if (replace) { @@ -321,9 +331,7 @@ DRV_cpp_init () ACE_MAJOR_VERSION, ACE_MINOR_VERSION, ACE_MICRO_VERSION); - DRV_cpp_putarg (version_option); - DRV_cpp_putarg ("-I."); const char *platform_cpp_args = FE_get_cpp_args_from_env (); @@ -338,7 +346,7 @@ DRV_cpp_init () #elif defined (ACE_CC_PREPROCESSOR_ARGS) platform_cpp_args = ACE_CC_PREPROCESSOR_ARGS; #else - platform_cpp_args = "-E"; + platform_cpp_args = ""; #endif /* TAO_IDL_PREPROCESSOR_ARGS */ // So we can find OMG IDL files, such as `orb.idl'. @@ -348,15 +356,8 @@ DRV_cpp_init () if (TAO_ROOT != nullptr) { - DRV_add_include_path (include_path1, - TAO_ROOT, - nullptr, - true); - - DRV_add_include_path (include_path2, - TAO_ROOT, - "/tao", - true); + DRV_add_include_path (include_path1, TAO_ROOT, nullptr, true); + DRV_add_include_path (include_path2, TAO_ROOT, "/tao", true); } else { @@ -620,6 +621,31 @@ DRV_add_include_path (ACE_CString& include_path, return include_path; } +namespace { + const char *our_basename(const char *path) + { + const char *temp; + while ((temp = ACE_OS::strchr (path, ACE_DIRECTORY_SEPARATOR_CHAR_A))) + { + path = temp + 1; + } + return path; + } + + char *tolower(const char *input) + { + if (!input) return nullptr; + const size_t size = ACE_OS::strlen (input); + char *output = nullptr; + ACE_NEW_RETURN (output, char [size], nullptr); + for (size_t i = 0; i < size; ++i) output[i] = ACE_OS::ace_tolower(input[i]); + return output; + } + + /// Copy IDL input file for preprocessor? + bool copy = true; +} + // Adds additional include paths, but after parse_args() has // added user-defined include paths. void @@ -638,6 +664,72 @@ DRV_cpp_post_init () #endif ); + // Decide how files will be passed to the preprocessor + if (idl_global->preprocessor_input_ == IDL_GlobalData::PreprocessorInputGuess) + { + const char * const cpp_name = tolower (our_basename (FE_get_cpp_loc_from_env ())); + const char * method = "copy"; + if (idl_global->compile_flags () & IDL_CF_INFORMATIVE) + { + ACE_DEBUG ((LM_DEBUG, "%C: guessing preprocessor input method using name: %C\n", + idl_global->prog_name (), cpp_name)); + } + if (ACE_OS::strstr (cpp_name, "g++")) // g++ or clang++ + { + idl_global->preprocessor_input_ = IDL_GlobalData::PreprocessorInputDirectGcc; + method = "direct-gcc"; + } + else if (ACE_OS::strstr (cpp_name, "cl.exe")) + { + idl_global->preprocessor_input_ = IDL_GlobalData::PreprocessorInputDirectWithE; + method = "direct-with-e (msvc)"; + } + else if (ACE_OS::strstr (cpp_name, "cpp")) // GNU and Clang cpp or mcpp + { + idl_global->preprocessor_input_ = IDL_GlobalData::PreprocessorInputDirectWithoutE; + method = "direct-without-e (cpp)"; + } + else + { + // If we don't know it seems like it's safer to fallback to the copy + // method. Warn about it anyway, because it shouldn't happen. + idl_global->preprocessor_input_ = IDL_GlobalData::PreprocessorInputCopy; + if (!(idl_global->compile_flags () & IDL_CF_NOWARNINGS)) + ACE_ERROR ((LM_WARNING, + "Warning - %C: Unknown preprocessor \"%C\", falling back to copy method.\n", + idl_global->prog_name (), cpp_name)); + } + if (idl_global->compile_flags () & IDL_CF_INFORMATIVE) + { + ACE_DEBUG ((LM_DEBUG, "%C: using preprocessor input method: %C\n", + idl_global->prog_name (), method)); + } + delete [] cpp_name; + } + switch (idl_global->preprocessor_input_) { + case IDL_GlobalData::PreprocessorInputDirectGcc: + // GCC and Clang will treat IDL files as a linker script if passed in by + // themselves, which is useless to us, so we need to force them to see the + // IDL files as C++ files. + DRV_cpp_putarg ("-x"); + DRV_cpp_putarg ("c++"); + // fallthrough + case IDL_GlobalData::PreprocessorInputDirectWithE: + DRV_cpp_putarg ("-E"); + // fallthrough + case IDL_GlobalData::PreprocessorInputDirectWithoutE: + copy = false; + break; + case IDL_GlobalData::PreprocessorInputCopy: + DRV_cpp_putarg ("-I.", true); // TODO: Change to directory of IDL file? + DRV_cpp_putarg ("-E"); + copy = true; + break; + case IDL_GlobalData::PreprocessorInputGuess: + // Unreachable + break; + } + // Add include path for TAO_ROOT/orbsvcs. char* TAO_ROOT = ACE_OS::getenv ("TAO_ROOT"); @@ -959,6 +1051,26 @@ namespace *buf = '>'; } } + + void process_input_file (FILE *in, FILE *out = nullptr) + { + while (DRV_get_line (in)) + { + if (out) + { + DRV_convert_includes (drv_line); + + // Print the line to the temporary file. + ACE_OS::fprintf (out, "%s\n", drv_line); + } + + // We really need to know whether this line is a "#include + // ...". If so, we would like to separate the "file name" and + // keep that in the idl_global. We need them to produce + // "#include's in the stubs and skeletons. + DRV_check_for_include (drv_line); + } + } } // End of local/internal namespace void @@ -966,7 +1078,7 @@ DRV_get_orb_idl_includes () { static char const orb_idl[] = "tao/orb.idl"; - // Search for orb.idl in supplied include file search paths. + // Search for orb.idl in supplied include file search paths. char const * directory = nullptr; FILE * fp = FE_Utils::open_included_file (orb_idl, directory); @@ -998,12 +1110,7 @@ DRV_get_orb_idl_includes () DRV_add_include_path (include_path_arg, directory, "/tao", true); } - while (DRV_get_line (fp)) - { - // Find the included .pidl files in orb.idl and add them to the - // included IDL file list. - DRV_check_for_include (drv_line); - } + process_input_file (fp); ACE_OS::fclose (fp); } @@ -1063,21 +1170,7 @@ DRV_copy_input (FILE *fin, buf); #endif /* ! ACE_WIN32 */ - while (DRV_get_line (fin)) - { - DRV_convert_includes (drv_line); - - // Print the line to the temporary file. - ACE_OS::fprintf (f, - "%s\n", - drv_line); - - // We really need to know whether this line is a "#include - // ...". If so, we would like to separate the "file name" and - // keep that in the idl_global. We need them to produce - // "#include's in the stubs and skeletons. - DRV_check_for_include (drv_line); - } + process_input_file (fin, f); // Close the temporary file. ACE_OS::fclose (f); @@ -1161,22 +1254,23 @@ DRV_pre_proc (const char *myfile) } ACE_OS::strcpy (tmp_file, tmpdir); - ACE_OS::strcpy (tmp_ifile, tmpdir); + if (copy) ACE_OS::strcpy (tmp_ifile, tmpdir); // Append temporary filename template to temporary directory. ACE_OS::strcat (tmp_file, tao_idlf_template); - ACE_OS::strcat (tmp_ifile, tao_idli_template); + if (copy) ACE_OS::strcat (tmp_ifile, tao_idli_template); - ACE_HANDLE const ti_fd = ACE_OS::mkstemp (tmp_ifile); - - if (ti_fd == ACE_INVALID_HANDLE) + ACE_HANDLE ti_fd = ACE_INVALID_HANDLE; + if (copy) { - ACE_ERROR ((LM_ERROR, - "%C: Unable to create temporary file \"%C\": %m\n", - idl_global->prog_name (), - tmp_ifile)); + ti_fd = ACE_OS::mkstemp (tmp_ifile); + if (ti_fd == ACE_INVALID_HANDLE) + { + ACE_ERROR ((LM_ERROR, "%C: Unable to create temporary file \"%C\": %m\n", + idl_global->prog_name (), tmp_ifile)); - throw Bailout (); + throw Bailout (); + } } ACE_HANDLE const tf_fd = ACE_OS::mkstemp (tmp_file); @@ -1188,7 +1282,7 @@ DRV_pre_proc (const char *myfile) idl_global->prog_name (), tmp_file)); - (void) ACE_OS::unlink (tmp_ifile); + if (copy) (void) ACE_OS::unlink (tmp_ifile); throw Bailout (); } @@ -1198,17 +1292,16 @@ DRV_pre_proc (const char *myfile) // Append C++ source file extension. Temporary files will be renamed // to these filenames. ACE_OS::strcpy (tmp_cpp_file, tmp_file); - ACE_OS::strcpy (tmp_cpp_ifile, tmp_ifile); + if (copy) ACE_OS::strcpy (tmp_cpp_ifile, tmp_ifile); ACE_OS::strcat (tmp_cpp_file, temp_file_extension); - ACE_OS::strcat (tmp_cpp_ifile, temp_file_extension); + if (copy) ACE_OS::strcat (tmp_cpp_ifile, temp_file_extension); char * const t_file = tmp_cpp_file; char * const t_ifile = tmp_cpp_ifile; + const char * const input_file = copy ? t_ifile : myfile; ACE_OS::close (tf_fd); - // Rename temporary files so that they have extensions accepted - // by the preprocessor. FILE * const file = ACE_OS::fopen (myfile, "r"); if (file == nullptr) { @@ -1216,22 +1309,27 @@ DRV_pre_proc (const char *myfile) "%C: ERROR: Unable to open file (fopen) \"%C\": %m\n", idl_global->prog_name (), myfile)); - (void) ACE_OS::unlink (tmp_ifile); + + if (copy) (void) ACE_OS::unlink (tmp_ifile); (void) ACE_OS::unlink (tmp_file); throw Bailout (); } - DRV_copy_input (file, - ACE_OS::fdopen (ti_fd, ACE_TEXT("w")), - tmp_ifile, - myfile); + if (copy) + { + // Rename temporary files so that they have extensions accepted + // by the preprocessor. + DRV_copy_input (file, ACE_OS::fdopen (ti_fd, ACE_TEXT ("w")), + tmp_ifile, myfile); + } + else + { + process_input_file (file); + } ACE_OS::fclose (file); UTL_String *utl_string = nullptr; - - ACE_NEW (utl_string, - UTL_String (myfile, true)); - + ACE_NEW (utl_string, UTL_String (myfile, true)); idl_global->set_main_filename (utl_string); ACE_Auto_String_Free safety (ACE_OS::strdup (myfile)); @@ -1243,8 +1341,7 @@ DRV_pre_proc (const char *myfile) idl_global->set_stripped_filename (stripped_tmp); UTL_String *real_tmp = nullptr; - ACE_NEW (real_tmp, - UTL_String (t_ifile, true)); + ACE_NEW (real_tmp, UTL_String (input_file, true)); idl_global->set_real_filename (real_tmp); @@ -1253,7 +1350,7 @@ DRV_pre_proc (const char *myfile) ACE_Process process; DRV_cpp_expand_output_arg (t_file); - DRV_cpp_putarg (t_ifile); + DRV_cpp_putarg (input_file); DRV_cpp_putarg (nullptr); // Null terminate the DRV_arglist. // For complex builds, the default @@ -1274,7 +1371,7 @@ DRV_pre_proc (const char *myfile) idl_global->prog_name (), DRV_arglist[0])); - (void) ACE_OS::unlink (tmp_ifile); + if (copy) (void) ACE_OS::unlink (tmp_ifile); (void) ACE_OS::unlink (tmp_file); throw Bailout (); } @@ -1292,12 +1389,12 @@ DRV_pre_proc (const char *myfile) t_file)); - (void) ACE_OS::unlink (tmp_ifile); + if (copy) (void) ACE_OS::unlink (tmp_ifile); (void) ACE_OS::unlink (tmp_file); throw Bailout (); } - if (ACE_OS::rename (tmp_ifile, t_ifile) != 0) + if (copy && ACE_OS::rename (tmp_ifile, t_ifile) != 0) { ACE_ERROR ((LM_ERROR, "%C: Unable to rename temporary " @@ -1334,7 +1431,7 @@ DRV_pre_proc (const char *myfile) t_file)); (void) ACE_OS::unlink (t_file); - (void) ACE_OS::unlink (t_ifile); + if (copy) (void) ACE_OS::unlink (t_ifile); throw Bailout (); } @@ -1363,7 +1460,7 @@ DRV_pre_proc (const char *myfile) (void) ACE_OS::unlink (t_file); - (void) ACE_OS::unlink (t_ifile); + if (copy) (void) ACE_OS::unlink (t_ifile); throw Bailout (); } @@ -1378,7 +1475,7 @@ DRV_pre_proc (const char *myfile) t_file)); (void) ACE_OS::unlink (t_file); - (void) ACE_OS::unlink (t_ifile); + if (copy) (void) ACE_OS::unlink (t_ifile); throw Bailout (); } } @@ -1399,25 +1496,27 @@ DRV_pre_proc (const char *myfile) idl_global->prog_name ())); (void) ACE_OS::unlink (t_file); - (void) ACE_OS::unlink (t_ifile); + if (copy) (void) ACE_OS::unlink (t_ifile); throw Bailout (); } if (WIFEXITED ((status))) { // Child terminated normally? - if (WEXITSTATUS ((status)) != 0) + const ACE_exitcode narrowed_status = WEXITSTATUS ((status)); + if (narrowed_status != 0) { - errno = WEXITSTATUS ((status)); + errno = narrowed_status; ACE_ERROR ((LM_ERROR, "%C: preprocessor \"%s\" " - "returned with an error\n", + "failed by returning exit code %d\n", idl_global->prog_name (), - DRV_arglist[0])); + cpp_options.command_line_buf (), + narrowed_status)); (void) ACE_OS::unlink (t_file); - (void) ACE_OS::unlink (t_ifile); + if (copy) (void) ACE_OS::unlink (t_ifile); throw Bailout (); } } @@ -1433,7 +1532,7 @@ DRV_pre_proc (const char *myfile) DRV_arglist[0])); (void) ACE_OS::unlink (t_file); - (void) ACE_OS::unlink (t_ifile); + if (copy) (void) ACE_OS::unlink (t_ifile); throw Bailout (); } // TODO: Manage problems in the @@ -1452,7 +1551,7 @@ DRV_pre_proc (const char *myfile) t_file)); (void) ACE_OS::unlink (t_file); - (void) ACE_OS::unlink (t_ifile); + if (copy) (void) ACE_OS::unlink (t_ifile); throw Bailout (); } @@ -1473,7 +1572,7 @@ DRV_pre_proc (const char *myfile) t_file)); (void) ACE_OS::unlink (t_file); - (void) ACE_OS::unlink (t_ifile); + if (copy) (void) ACE_OS::unlink (t_ifile); throw Bailout (); } @@ -1500,7 +1599,7 @@ DRV_pre_proc (const char *myfile) ACE_OS::fclose (preproc); } - if (ACE_OS::unlink (t_ifile) == -1) + if (copy && ACE_OS::unlink (t_ifile) == -1) { ACE_ERROR ((LM_ERROR, "%C: Could not remove cpp " diff --git a/TAO/TAO_IDL/fe/fe_init.cpp b/TAO/TAO_IDL/fe/fe_init.cpp index dd8e162edbd7f..8ec101bd152ff 100644 --- a/TAO/TAO_IDL/fe/fe_init.cpp +++ b/TAO/TAO_IDL/fe/fe_init.cpp @@ -496,30 +496,13 @@ FE_get_cpp_loc_from_env () // Set cpp_loc to the built in location, unless it has been overriden by // environment variables. - if (preprocessor != 0) + if (preprocessor) { cpp_loc = preprocessor; } else { - // Check for the deprecated CPP_LOCATION environment variable - ACE_Env_Value cpp_path (ACE_TEXT ("CPP_LOCATION"), - (char *) nullptr); - - if (cpp_path != 0) - { - ACE_ERROR ((LM_WARNING, - "WARNING: The environment variable " - "CPP_LOCATION has been deprecated.\n" - " Please use TAO_IDL_PREPROCESSOR " - "instead.\n")); - - cpp_loc = cpp_path; - } - else - { - cpp_loc = idl_global->cpp_location (); - } + cpp_loc = idl_global->cpp_location (); } return cpp_loc; @@ -528,35 +511,5 @@ FE_get_cpp_loc_from_env () const char * FE_get_cpp_args_from_env () { - const char *cpp_args = nullptr; - - // Added some customizable preprocessor options - ACE_Env_Value args1 (ACE_TEXT ("TAO_IDL_PREPROCESSOR_ARGS"), - (char *) nullptr); - - if (args1 != 0) - { - cpp_args = args1; - } - else - { - // Check for the deprecated TAO_IDL_DEFAULT_CPP_FLAGS environment - // variable. - ACE_Env_Value args2 (ACE_TEXT ("TAO_IDL_DEFAULT_CPP_FLAGS"), - (char *) nullptr); - - if (args2 != 0) - { - ACE_ERROR ((LM_WARNING, - "Warning: The environment variable " - "TAO_IDL_DEFAULT_CPP_FLAGS has been " - "deprecated.\n" - " Please use " - "TAO_IDL_PREPROCESSOR_ARGS instead.\n")); - - cpp_args = args2; - } - } - - return cpp_args; + return ACE_Env_Value (ACE_TEXT ("TAO_IDL_PREPROCESSOR_ARGS"), nullptr); } diff --git a/TAO/TAO_IDL/include/drv_extern.h b/TAO/TAO_IDL/include/drv_extern.h index 03a543b161f3d..8d5b70e35367e 100644 --- a/TAO/TAO_IDL/include/drv_extern.h +++ b/TAO/TAO_IDL/include/drv_extern.h @@ -68,18 +68,18 @@ trademarks or registered trademarks of Sun Microsystems, Inc. // External functions for the IDL compiler driver program. extern void DRV_parse_args (long, char **); extern void DRV_usage (); -extern void DRV_pre_proc (char const * myfile); +extern void DRV_pre_proc (char const *myfile); extern void DRV_store_env_include_paths (); extern void DRV_cpp_init (); -extern ACE_CString& DRV_add_include_path (ACE_CString&, - const char* p, const char* suffix, +extern ACE_CString& DRV_add_include_path (ACE_CString &, + const char *p, const char *suffix, bool is_system); extern void DRV_cpp_post_init (); -extern void DRV_cpp_putarg (char const * str); -extern void DRV_cpp_new_location (char const * new_loc); +extern void DRV_cpp_putarg (char const *str, bool front = false); +extern void DRV_cpp_new_location (char const *new_loc); extern void DRV_get_orb_idl_includes (); // Not used by all backends. -extern void DRV_push_file (char const * s); +extern void DRV_push_file (char const *s); #endif // _DRV_EXTERN_DRV_EXTERN_HH diff --git a/TAO/TAO_IDL/include/idl_global.h b/TAO/TAO_IDL/include/idl_global.h index aa3182566dac5..a01377dda63b6 100644 --- a/TAO/TAO_IDL/include/idl_global.h +++ b/TAO/TAO_IDL/include/idl_global.h @@ -318,6 +318,14 @@ class TAO_IDL_FE_Export IDL_GlobalData UNKNOWN_ANNOTATIONS_IGNORE }; + enum PreprocessorInput { + PreprocessorInputGuess, + PreprocessorInputDirectWithE, + PreprocessorInputDirectWithoutE, + PreprocessorInputDirectGcc, + PreprocessorInputCopy + }; + IDL_GlobalData (); ~IDL_GlobalData (); @@ -897,6 +905,9 @@ class TAO_IDL_FE_Export IDL_GlobalData */ ACE_Unbounded_Set unknown_annotations_seen_; + /// How to pass input files to the C preprocessor + PreprocessorInput preprocessor_input_; + private: // Data UTL_ScopeStack pd_scopes; // Store scopes stack diff --git a/TAO/TAO_IDL/include/idl_version.h b/TAO/TAO_IDL/include/idl_version.h index 3d47ec5cfe2de..3cd8221123878 100644 --- a/TAO/TAO_IDL/include/idl_version.h +++ b/TAO/TAO_IDL/include/idl_version.h @@ -50,7 +50,7 @@ enum SpecificIdlVersion * This is so that BE can control the version without overriding idl_version_ * directly and making --default-idl-version incorrect. */ -const SpecificIdlVersion DEFAULT_DEFAULT_IDL_VERSION = IDL_VERSION_3; +const SpecificIdlVersion DEFAULT_DEFAULT_IDL_VERSION = IDL_VERSION_4; /** * Class Operations involving SpecificIdlVersion Values diff --git a/TAO/TAO_IDL/tao_idl.cpp b/TAO/TAO_IDL/tao_idl.cpp index 7cbbca9ed784f..06f133ed5741c 100644 --- a/TAO/TAO_IDL/tao_idl.cpp +++ b/TAO/TAO_IDL/tao_idl.cpp @@ -230,6 +230,14 @@ DRV_drive (const char *s) // and checked below. (void) FE_yyparse (); + if (!idl_global->filename ()) + { + ACE_ERROR ((LM_ERROR, ACE_TEXT ("Error - %C: %C: No filename info found. ") + ACE_TEXT ("Preprocessor output was probably empty\n"), + idl_global->prog_name (), s)); + throw Bailout (); + } + // This option creates a single IDL file that includes all // input files. The backend outputs their names individually. if (!idl_global->multi_file_input () && @@ -454,7 +462,7 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[]) } } - int const retval = idl_global->err_count (); + int const retval = idl_global->err_count () == 0 ? EXIT_SUCCESS : EXIT_FAILURE; DRV_cleanup (); return retval; diff --git a/TAO/TAO_IDL/util/utl_global.cpp b/TAO/TAO_IDL/util/utl_global.cpp index 87c7640f211c7..ab2dc0ec0411f 100644 --- a/TAO/TAO_IDL/util/utl_global.cpp +++ b/TAO/TAO_IDL/util/utl_global.cpp @@ -105,6 +105,7 @@ IDL_GlobalData::IDL_GlobalData () ignore_files_ (false), ignore_lookup_errors_ (false), unknown_annotations_ (UNKNOWN_ANNOTATIONS_WARN_ONCE), + preprocessor_input_ (PreprocessorInputGuess), pd_root (nullptr), pd_gen (nullptr), pd_primary_key_base (nullptr), diff --git a/TAO/docs/compiler.html b/TAO/docs/compiler.html index eaa53ba1a27d1..683955d9a2616 100644 --- a/TAO/docs/compiler.html +++ b/TAO/docs/compiler.html @@ -5,16 +5,40 @@ TAO IDL compiler User's Guide - + - +
--TAO IDL Compiler User's Guide
+TAO IDL Compiler User's Guide
-Scope
This document describes the options and features of +Scope
+This document describes the options and features of TAO IDL compiler. It is not a reference manual or tutorial on OMG IDL. For more information on OMG IDL see the @@ -27,8 +51,8 @@Scope
This document describes the options and features of available in the OCI TAO Developer's Guide.-
-
Optional CIAO Functionality
+
+Optional CIAO Functionality
For users of the Component Integrated ACE ORB ( CIAO), it is @@ -40,50 +64,50 @@Optional CIAO Functionality
by additional functionality in the TAO IDL compiler. All the additional files generated and command line options used are described below. --
Generated Files
+
+Generated Files
-The IDL compiler generates up to 16 files from each .idl file. The +The IDL compiler generates up to 16 files from each.idl
file. The file names are obtained by taking the IDL basename and appending the following suffixes (see the list of TAO's IDL compiler options on how to get different suffixes for these files:)
-
-TAO's IDL compiler creates separate *.inl and *S_T.* +TAO's IDL compiler creates separate- Client stubs, i.e., *C.h, - *C.inl, and *C.cpp. Pure client applications +
- Client stubs, i.e.,
*C.h
, +*C.inl
, and*C.cpp
. Pure client applications only need to#include
and link with these files. -- Server skeletons, i.e., *S.h, and - *S.cpp. Servers need to
#include
and link - with these files. Generation of these files may be suppressed with the -SS option. -- Server skeleton templates, i.e., *S_T.h, S_T.inl, - and *S_T.cpp. Some C++ compilers do not like template +
- Server skeletons, i.e.,
*S.h
, and +*S.cpp
. Servers need to#include
and link + with these files. Generation of these files may be suppressed with the‑SS
option. +- Server skeleton templates, i.e.,
*S_T.h
,S_T.inl
, + and*S_T.cpp
. Some C++ compilers do not like template and non-template code in the same files, so TAO's IDL compiler generates these files separately. These files define tie classes, used to enable servant inheritance trees, and are not generated by default. -- Anyop files, i.e., *A.h, - and *A.cpp. Optionally generated files containing +
- Anyop files, i.e.,
*A.h
, + and*A.cpp
. Optionally generated files containing typecode and Any insertion/extraction operator definitions. This option enables the contents of these files to remain unlinked if not used. -- CIAO servant files, i.e., *_svnt.h, - and *_svnt.cpp. Optionally generated files, containing component +
- CIAO servant files, i.e.,
*_svnt.h
, + and*_svnt.cpp
. Optionally generated files, containing component and home servant implementations, as well as factory functions to create components and homes. -- Executor IDL file, i.e., *E.idl. +
- Executor IDL file, i.e.,
*E.idl
. IDL file containing local interfaces used for component and home executors, optionally generated. -- Executor implementation files, i.e., *_exec.h, - and *_exec.cpp. Optionally generated files containing executor implementation classes +
- Executor implementation files, i.e.,
*_exec.h
, + and*_exec.cpp
. Optionally generated files containing executor implementation classes with empty function bodies for facet, supported and inherited operations, as well as factory functions to create component and home executors. -- Connector implementation files, i.e., *_conn.h, - and *_conn.cpp. Optionally generated files containing connector implementation classes +
- Connector implementation files, i.e.,
*_conn.h
, + and*_conn.cpp
. Optionally generated files containing connector implementation classes with complete function bodies. The function implementations are specialized for DDS at present, but will be configurable to other connection mechanisms in the future. -- Export header files, i.e., *_export.h. +
- Export header files, i.e.,
*_export.h
. Optionally generated files defining export/import macros as well as corresponding macros related to singletons and tracing, all in terms of existing ACE macros. Note that, while these files must have the @@ -91,77 +115,76 @@Generated Files
from the IDL filename, as is the stem of the other file groups above. There can be as many as 4 of these files per build, for stub, skeleton, servant, and executor export macros, and they may also be generated by - the Perl script generate_export_file.pl, located in - $ACE_ROOT/bin. + the Perl scriptgenerate_export_file.pl
, located in +$ACE_ROOT/bin
.*.inl
and*S_T.*
files to improve the performance of the generated code. For example, -the *.inl files enable you to compile with inlining enabled or +the*.inl
files enable you to compile with inlining enabled or not, which is useful for trading-off compile-time and run-time -performance. Fortunately, you need to#include
only the -client stubs declared in the *C.h file and the skeletons in -the *S.h file in your code. Inline files are not generated +performance. Fortunately, you need to#include
only the +client stubs declared in the*C.h
file and the skeletons in +the*S.h
file in your code. Inline files are not generated for CIAO servant or executor implementation code.-
-
Variable - Usage - - TAO_IDL_PREPROCESSOR - Used to override the program name of the preprocessor that TAO_IDL - uses. - - +TAO_IDL_PREPROCESSOR_ARGS - Used to override the flags passed to the preprocessor that TAO_IDL +
+Environment Variables
+ ++
++ +Variable +Usage ++ ++ TAO_IDL_PREPROCESSOR
Used to override the program name of the preprocessor that TAO_IDL + uses. ++ + TAO_IDL_PREPROCESSOR_ARGS
Used to override the flags passed to the preprocessor that TAO_IDL uses. This can be used to alter the default options for the preprocessor and specify things like include directories and how - the preprocessor is invoked. Two flags that will always be passed to - the preprocessor are -DIDL
and-I.
. -- TAO_ROOT - Used to determine where orb.idl
is located. -- ACE_ROOT - Used to determine where orb.idl
is located. -- -CIAO_ROOT - Used to determine where + the preprocessor is invoked. -Components.idl
is located.+ ++ TAO_ROOT
Used to determine where +orb.idl
is located.+ ++ ACE_ROOT
Used to determine where +gperf
is located.+ ++ CIAO_ROOT
Used to determine where +Components.idl
is located.Because TAO_IDL doesn't have any code to implement a preprocessor, it has to use an external one. For convenience, it uses a built-in name for an external preprocessor to call. During compilation, this is how that default is set:
--
+- If the macro TAO_IDL_PREPROCESSOR is defined, then it will use that. -
- Else if the macro ACE_CC_PREPROCESSOR is defined, then it will use that. -
- Otherwise, it will use "cc" -
+
-- If the macro
+TAO_IDL_PREPROCESSOR
is defined, then it will use that.- Else if the macro
+ACE_CC_PREPROCESSOR
is defined, then it will use that.- Otherwise, it will use
+cc
And the same behavior occurs for the TAO_IDL_PREPROCESSOR_ARGS and -ACE_CC_PREPROCESSOR_ARGS macros.
+And the same behavior occurs for the
TAO_IDL_PREPROCESSOR_ARGS
and +ACE_CC_PREPROCESSOR_ARGS
macros.Case 1 is used by the Makefile on most machines to specify the preprocessor. Case 2 is used on Windows and platforms that need special arguments passed to the preprocessor (MVS, etc.). And case 3 isn't used at all, but is included as a default case.
-Since the default preprocessor may not always work when TAO_IDL is moved to +
Since the default preprocessor may not always work when TAO_IDL is moved to another machine or used in cross-compilation, it can be overridden at runtime -by setting the environment variables TAO_IDL_PREPROCESSOR and -TAO_IDL_PREPROCESSOR_ARGS.
- -In previous versions, the environment variables CPP_LOCATION and -TAO_IDL_DEFAULT_CPP_FLAGS were used for this purpose. Both will still work, -but TAO_IDL will display a deprecation warning if it detects one of these. -It is possible that support for these old variables will be removed in a -future version of TAO.
+by setting the environment variablesTAO_IDL_PREPROCESSOR
and +TAO_IDL_PREPROCESSOR_ARGS
.If ACE_ROOT or TAO_ROOT are defined, then TAO_IDL will use them to include the $(ACE_ROOT)/TAO/tao or $(TAO_ROOT)/tao @@ -169,8 +192,47 @@
Generated Files
<orb.idl> when it is included in an IDL file. TAO_IDL will display a warning message when neither is defined. --
Operation Demuxing Strategies
+
+IDL Preprocessor Macros
+ +The preprocessor macros available in IDL include all the ones built-in to +the preprocessor when it's being used for C/C++. In addition to the ones +built-in to the preprocessor, the following are also defined by +
+ +tao_idl
:+
+ ++ + +Name +Description ++ + ++ __TAO_IDL
+ +The version of ACE that
+ +tao_idl
was built with. The format + is one byte for each version field in hex format. For example, in a + theoretical TAO version 3.2.1, which would correspond to ACE version + 7.3.1,__TAO_IDL
would be0x070201
.It's also possible to include
+tao/Version.h
and use the + same macros from that header file as you can use in C++.+ ++ __TAO_IDL_IDL_VERSION
Version of the IDL specification the compiler that can be changed using + +--idl-version
. Note that this + doesn't mean that the compiler will support all those features of the + IDL spec version. The format is the same as__TAO_IDL
, + which is three one-byte fields in a hex format. For example IDL version 3 + is0x030000
. +
+Operation Demuxing Strategies
The server skeleton can use different demuxing strategies to match the incoming operation with the correct operation at the servant. TAO's @@ -187,120 +249,131 @@Operation Demuxing Strategies
the following:-
Note that if you can't use perfect hashing for some reason the next best operation demuxing strategy is binary search, which can be configured using TAO's IDL compiler options.- Enable
ACE_HAS_GPERF
when building ACE and TAO. - This macro has been defined for the platforms wheregperf
+- Enable
-ACE_HAS_GPERF
when building ACE and TAO. + This macro has been defined for the platforms wheregperf
has been tested, which includes most platforms - that ACE runs on.+ that ACE runs on.
- Build the
gperf
in $ACE_ROOT/apps/gperf. This build +- Build the
-gperf
in $ACE_ROOT/apps/gperf. This build also leaves a copy/link of the ace_gperf program at the $ACE_ROOT/bin - directory.+ directory.
- Set the environment variable $ACE_ROOT appropriately or add - $ACE_ROOT/bin to your search path.
+
- Set the environment variable
-$ACE_ROOT
appropriately or add +$ACE_ROOT/bin
to your search path.- Use the
-g
option for the TAO IDL compiler or set - your search path accordingly to installace_gperf
in a - directory other than $ACE_ROOT/bin. +- Use the
‑g
option for the TAO IDL compiler or set + your search path accordingly to installace_gperf
in a + directory other than$ACE_ROOT/bin
.-
-
AMI support
+
+AMI support
The TAO_IDL compiler generates AMI stubs and skeletons as described in the CORBA 3.0.3 specification. --
Collocation Strategies
+
+Collocation Strategies
+TAO_IDL can generate collocated stubs using two different collocation strategies. It also allows you to suppress/enable the generation of the stubs of a particular strategy. To gain great flexibility at run-time, you can generate stubs for both collocation strategies -(using both '
-Gp
' and '-Gd
' flags at the same time) and defer the +(using both '‑Gp
' and '‑Gd
' flags at the same time) and defer the determination of collocation strategy until run-time. On the other hand, if you want to minimize the footprint of your program, you might want to pre-determine the collocation strategy you want and only generate the right collocated stubs (or not generating any at all using -both '-Sp
' and '-Sd
' flags at the same time if +both '‑Sp
' and '‑Sd
' flags at the same time if it's a pure client.) See our collocation paper for a detail discussion on the collocation support in -TAO.+TAO.
--
TAO's IDL Compiler Options
+
+TAO's IDL Compiler Options
-TAO's IDL compiler invokes your C (or C++) ++TAO's IDL compiler invokes your C (or C++) preprocessor to resolve included IDL files. It receives the common -options for preprocessors (such as -D or -I). It -also receives other options that are specific to it.
+options for preprocessors (such as
-‑D
or‑I
). It +also receives other options that are specific to it.