From 27d9411dfcda1833855d6240e3693a7df12c12fe Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Fri, 25 Dec 2020 23:42:42 -0600 Subject: [PATCH 1/8] Remove CPP_LOCATION and TAO_IDL_DEFAULT_CPP_FLAGS Remove support for these environment variables because they have been marked as deprecated for at least 20 years at this point. --- ACE/ACE-INSTALL.html | 10 +++---- TAO/NEWS | 6 +++++ TAO/TAO_IDL/fe/fe_init.cpp | 53 +++----------------------------------- TAO/docs/compiler.html | 6 ----- 4 files changed, 14 insertions(+), 61 deletions(-) diff --git a/ACE/ACE-INSTALL.html b/ACE/ACE-INSTALL.html index 13bcad42f9575..bb04390b990e0 100644 --- a/ACE/ACE-INSTALL.html +++ b/ACE/ACE-INSTALL.html @@ -1361,7 +1361,7 @@

Building Shared Libraries for VxWorks.

# include "ace/config-vxworks5.x.h" #endif

-

  • Set your ACE_ROOT, CPP_LOCATION, +

  • Set your ACE_ROOT, TAO_IDL_PREPROCESSOR, WIND_BASE, and WIND_HOST_TYPE environment variables.

  • Build for NT, then build for VxWorks.

    @@ -1411,7 +1411,7 @@

    Building Shared Libraries for VxWorks.

    SHELL=/bin/sh.exe TERM=pcbios TAO_ROOT=/ace/ACE_wrappers.vxworks/TAO - CPP_LOCATION=/Program Files/DevStudio/VC/bin/CL.EXE + TAO_IDL_PREPROCESSOR=/Program Files/DevStudio/VC/bin/CL.EXE GCC_EXEC_PREFIX=/tornado/host/x86-win32/lib/gcc-lib/ WIND_HOST_TYPE=x86-win32 ACE_ROOT=/ace/ACE_wrappers.vxworks @@ -1467,13 +1467,13 @@

    TAO on NT Tornado host, VxWorks target.

    ACE_wrappers/apps/gperf/src.

  • Build $TAO_ROOT/tao -
          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
           
  • Build orbsvcs. -
          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
           
    @@ -1528,7 +1528,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 f8bc2bdb513f6..de08bbf5021e1 100644 --- a/TAO/NEWS +++ b/TAO/NEWS @@ -4,6 +4,12 @@ USER VISIBLE CHANGES BETWEEN TAO-2.5.12 and TAO-3.0.0 . C++11 is now a mandatory compiler feature which is required for TAO +. TAO_IDL: + + . 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. + USER VISIBLE CHANGES BETWEEN TAO-2.5.11 and TAO-2.5.12 ====================================================== diff --git a/TAO/TAO_IDL/fe/fe_init.cpp b/TAO/TAO_IDL/fe/fe_init.cpp index 24c8284bf4d10..afd950dd63d06 100644 --- a/TAO/TAO_IDL/fe/fe_init.cpp +++ b/TAO/TAO_IDL/fe/fe_init.cpp @@ -491,30 +491,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; @@ -523,35 +506,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/docs/compiler.html b/TAO/docs/compiler.html index c12076ec35c52..89753e4f1a881 100644 --- a/TAO/docs/compiler.html +++ b/TAO/docs/compiler.html @@ -157,12 +157,6 @@

    Generated Files

    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.

    -

    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 directories. This is to allow TAO_IDL to automatically find From 7c6b0870f3a1a3dac507faad60d894a3dc363501 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Sat, 26 Dec 2020 01:02:38 -0600 Subject: [PATCH 2/8] TAO_IDL: Make IDL 4 the Default --- TAO/NEWS | 3 +++ TAO/TAO_IDL/include/idl_version.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/TAO/NEWS b/TAO/NEWS index de08bbf5021e1..7575b8ab9b7c1 100644 --- a/TAO/NEWS +++ b/TAO/NEWS @@ -6,6 +6,9 @@ USER VISIBLE CHANGES BETWEEN TAO-2.5.12 and TAO-3.0.0 . TAO_IDL: + . IDL 4 is now the default IDL version. Note that IDL 4 support is still + incomplete. + . 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. diff --git a/TAO/TAO_IDL/include/idl_version.h b/TAO/TAO_IDL/include/idl_version.h index 03255a8896207..1659fc745ee6f 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 From b79e784341ef801d7e9b946405dec93de5c98ceb Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Mon, 28 Dec 2020 14:44:15 -0600 Subject: [PATCH 3/8] TAO/docs/compiler.html Cleanup Use conventional HTML, non breaking dashs, remove some outdated information. --- TAO/docs/compiler.html | 814 +++++++++++++++++++++-------------------- 1 file changed, 427 insertions(+), 387 deletions(-) diff --git a/TAO/docs/compiler.html b/TAO/docs/compiler.html index 89753e4f1a881..c394213f93b3d 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:)

      -
    • 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,71 +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 script generate_export_file.pl, located in + $ACE_ROOT/bin.
    -TAO's IDL compiler creates separate *.inl and *S_T.* +TAO's IDL compiler creates separate *.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.

    -


    -

    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 +
    +

    Environment Variables

    + + + + + + + + + + + + + - - - + the preprocessor is invoked. - -
    VariableUsage
    TAO_IDL_PREPROCESSORUsed to override the program name of the preprocessor that TAO_IDL + uses.
    TAO_IDL_PREPROCESSOR_ARGSUsed 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 Components.idl is located.
    +
    TAO_ROOTUsed to determine where orb.idl is located.
    ACE_ROOTUsed to determine where gperf is located.
    CIAO_ROOTUsed 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:

    -
      -
    1. If the macro TAO_IDL_PREPROCESSOR is defined, then it will use that. -
    2. Else if the macro ACE_CC_PREPROCESSOR is defined, then it will use that. -
    3. Otherwise, it will use "cc" -
    +
      +
    1. If the macro TAO_IDL_PREPROCESSOR is defined, then it will use that.
    2. +
    3. Else if the macro ACE_CC_PREPROCESSOR is defined, then it will use that.
    4. +
    5. Otherwise, it will use cc
    6. +
    -

    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, HPUX, 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.

    +by setting the environment variables TAO_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 @@ -163,8 +192,8 @@

    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

    +
    +

    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 @@ -181,120 +210,126 @@

    Operation Demuxing Strategies

    the following:
      -
    • Enable ACE_HAS_GPERF when building ACE and TAO. - This macro has been defined for the platforms where gperf +
    • Enable ACE_HAS_GPERF when building ACE and TAO. + This macro has been defined for the platforms where gperf 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 install ace_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 install ace_gperf in a + directory other than $ACE_ROOT/bin.
    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.

    -


    -

    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.

    - +
    - - + + + - - + + - + - + - + - - + + - + - + - - + - + - + - + - - + - + - + - + - + - + - + - + - - + - + - + - + - - + - + - + - + - - + - + - + - + + (see option ‑SS below). - + - + + (see option ‑SS below). - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - . + - - + + - - + + - + - - + + @@ -586,57 +621,57 @@

    TAO's IDL Compiler Options

    - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -671,8 +706,8 @@

    TAO's IDL Compiler Options

    - - + + @@ -680,29 +715,29 @@

    TAO's IDL Compiler Options

    - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -802,8 +837,8 @@

    TAO's IDL Compiler Options

    - - + + @@ -813,8 +848,8 @@

    TAO's IDL Compiler Options

    were not as stringent. - - + + @@ -822,111 +857,111 @@

    TAO's IDL Compiler Options

    - - + + + ‑aw or ‑as - - + + + ‑ae or ‑as - - + + + ‑aw or ‑ae - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - + - + - + - + - + - + - + - - + + - - + + - - + + + with the gen_ostream feature turned on. - - + + - - + + + + - - + + - - + + - - - + + - - + + - - + + + + - - + + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - - + + - - + + - - + + - - + + - - + + @@ -1197,8 +1236,8 @@

    TAO's IDL Compiler Options

    associated typecode. - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -1326,31 +1365,32 @@

    TAO's IDL Compiler Options

    valuetype factory class will be abstract and must be overridden by the user, and registered in hand-written code. - - + + - +
    Option Description Remark
    -h
    --help
    -u
    ‑h
    + ‑‑help
    + ‑u
    The compiler prints out the arguments it supports and exits  
    -V
    --version
    ‑V
    + ‑‑version
    The compiler printouts its version and exits  
    --idl-version VERSION‑‑idl‑version VERSION Set the IDL version to use  
    --default-idl-version‑‑default‑idl‑version Prints the default IDL version for the compiler and exits  
    --list-idl-versions‑‑list‑idl‑versions Lists IDL versions the compiler supports and exits  
    -Wb,option_list
    ‑Wb,option_list Pass options to the TAO IDL compiler backend.  
    skel_export_macro=macro_nameskel_export_macro=macro_nameThe compiler will emit macro_name right after each class - or extern keyword in the generated skeleton header (*S.h) - files. If CIAO servant code is being generated (see -Gsv option below), - and svnt_export_macro (see below) isn't set, this macro will also + The compiler will emit macro_name right after each class + or extern keyword in the generated skeleton header (*S.h) + files. If CIAO servant code is being generated (see ‑Gsv option below), + and svnt_export_macro (see below) isn't set, this macro will also appear in the generated CIAO servant (*_svnt.h) files, since skeleton and CIAO servant files are often compiled together. This macro is needed for Windows and newer versions of gcc, which require @@ -302,45 +337,45 @@

    TAO's IDL Compiler Options

    is just a space. 
    skel_export_include=include_pathskel_export_include=include_path The compiler will generate code to include include_path at the top of the generated server header, this is usually a good place to define the server side export macro.
    stub_export_macro=macro_namestub_export_macro=macro_nameThe compiler will emit macro_name right after each class - or extern keyword in the generated stub code, this is + The compiler will emit macro_name right after each class + or extern keyword in the generated stub code, this is needed for Windows and newer versions of gcc, which require special directives to export symbols from DLLs, otherwise the definition is just a space. 
    stub_export_include=include_pathstub_export_include=include_path The compiler will generate code to include include_path at the top of the client header, this is usually a good place to define the export macro.
    anyop_export_macro=macro_nameanyop_export_macro=macro_name The compiler will emit macro_name before each Any operator - or extern typecode declaration in the generated stub code, + or extern typecode declaration in the generated stub code, this is needed for Windows and newer versions of gcc, which require special directives to export symbols from DLLs, otherwise the definition is just a space on Unix platforms. This option works only in conjunction with @@ -348,10 +383,10 @@

    TAO's IDL Compiler Options

    separate set of files. 
    anyop_export_include=include_pathanyop_export_include=include_path The compiler will generate code to include include_path at the top of the anyop file header, this is usually a good place to define the export @@ -359,118 +394,118 @@

    TAO's IDL Compiler Options

    operators and typecodes into a separate set of files.
    svnt_export_macro=macro_namesvnt_export_macro=macro_nameThe compiler will emit macro_name right after each class - or extern keyword in the generated CIAO servant code, if such - code is being generated (see -Gsv option below). Since skeleton + The compiler will emit macro_name right after each class + or extern keyword in the generated CIAO servant code, if such + code is being generated (see ‑Gsv option below). Since skeleton and servant files are often compiled together, the value of - skel_export_macro will appear here, if it is set and - svnt_export_macro is not. These macros + skel_export_macro will appear here, if it is set and + svnt_export_macro is not. These macros are needed for Windows and newer versions of gcc, which require special directives to export symbols from DLLs - otherwise the definition is just a space. 
    svnt_export_macro=include_pathsvnt_export_macro=include_path The compiler will generate code to include include_path at the top of the CIAO servant file header, if this file is being generated - (see -Gsv option below). This is usually a good place to define the export + (see ‑Gsv option below). This is usually a good place to define the export macro.
    exec_export_macro=macro_nameexec_export_macro=macro_nameThe compiler will emit macro_name right after each class - or extern keyword in the generated CIAO executor implementation header + The compiler will emit macro_name right after each class + or extern keyword in the generated CIAO executor implementation header (*_exec.h) files, if such - code is being generated (see -Gex option below). These macros + code is being generated (see ‑Gex option below). These macros are needed for Windows and newer versions of gcc, which require special directives to export symbols from DLLs - otherwise the definition is just a space. 
    exec_export_include=include_pathexec_export_include=include_path The compiler will generate code to include include_path at the top of the CIAO executor implementation header (*_exec.h) file, if this file is being generated - (see -Gex option below). This is usually a good place to define the export + (see ‑Gex option below). This is usually a good place to define the export macro.
    conn_export_macro=macro_nameconn_export_macro=macro_nameThe compiler will emit macro_name right after each class - or extern keyword in the generated CIAO connector implementation header + The compiler will emit macro_name right after each class + or extern keyword in the generated CIAO connector implementation header (*_conn.h) files, if such - code is being generated (see -Gcn option below). These macros + code is being generated (see ‑Gcn option below). These macros are needed for Windows and newer versions of gcc, which require special directives to export symbols from DLLs - otherwise the definition is just a space. 
    conn_export_include=include_pathconn_export_include=include_path The compiler will generate code to include include_path at the top of the CIAO connector implementation header (*_conn.h) file, if this file is being generated - (see -Gcn option below). This is usually a good place to define the export + (see ‑Gcn option below). This is usually a good place to define the export macro.
    export_macro=macro_nameexport_macro=macro_name This option has the same effect as issuing
    - -Wb,skel_export_macro=macro_name
    - -Wb,stub_export_macro=macro_name
    - -Wb,anyop_export_macro=macro_name.
    - -Wb,svnt_export_macro=macro_name
    - -Wb,exec_export_macro=macro_name
    - -Wb,conn_export_macro=macro_name
    + ‑Wb,skel_export_macro=macro_name
    + ‑Wb,stub_export_macro=macro_name
    + ‑Wb,anyop_export_macro=macro_name.
    + ‑Wb,svnt_export_macro=macro_name
    + ‑Wb,exec_export_macro=macro_name
    + ‑Wb,conn_export_macro=macro_name
    This option is useful when building a single DLL or when some code generation is suppressed or not triggered - (see option -SS below).
    export_include=include_pathexport_include=include_path This option has the same effect as specifying
    - -Wb,stub_export_include=include_path
    - -Wb,skel_export_include=include_path
    - -Wb,anyop_export_include=include_path.
    - -Wb,svnt_export_include=include_path
    - -Wb,exec_export_include=include_path
    - -Wb,conn_export_include=include_path
    + ‑Wb,stub_export_include=include_path
    + ‑Wb,skel_export_include=include_path
    + ‑Wb,anyop_export_include=include_path.
    + ‑Wb,svnt_export_include=include_path
    + ‑Wb,exec_export_include=include_path
    + ‑Wb,conn_export_include=include_path
    This option goes with the previous option to build a DLL containing all code generation, or when some code generation is suppressed - (see option -SS below).
    pch_include=include_pathpch_include=include_path The compiler will generate code to include include_path at the top of all TAO IDL compiler generated files. This can be used with a @@ -478,19 +513,19 @@

    TAO's IDL Compiler Options

    C++Builder or MSVC++.
    obv_opt_accessorobv_opt_accessor The IDL compiler will generate code to optimize access to base class data for valuetypes.
    pre_include=include_pathpre_include=include_path The compiler will generate code to include include_path at the top of the each header file, before any other include statements. For @@ -499,10 +534,10 @@

    TAO's IDL Compiler Options

    IDL-generated files in the TAO libraries and CORBA services.
    post_include=include_pathpost_include=include_path The compiler will generate code to include include_path at the bottom of the each header file. For example, ace/post.h, which pops @@ -511,74 +546,74 @@

    TAO's IDL Compiler Options

    and CORBA services.
    include_guard=defineinclude_guard=define The compiler will generate code the define in the C.h file to prevent users from including the generated C.h file. Useful for regenerating the pidl files in the archive.
    safe_include=filesafe_include=file File that the user should include instead of this generated C.h file. Useful for regenerating the pidl files in the archive.
    unique_include=fileunique_include=file File that the user should include instead of the normal includes in the C.h file. Useful for regenerating the *_include pidl files in the archive.
    stripped_filename=filestripped_filename=file File that should be generated as stripped_filename instead of taking the stripped filename of the input file.
    ciao_container_type=fileciao_container_type=fileType of container we are going to use, Session by default.Type of container we are going to use, Session by default.
    -E
    ‑E Invoke only the preprocessor  
    -Wp,option_list
    ‑Wp,option_list Pass options to the preprocessor.  
    --syntax-only‑‑syntax‑only Parse input files, but exit without generating any files.  
    --dump
    -d
    ‑‑dump
    -d
    Causes output of a dump of the AST and exits before any files would be created.
    --dump-builtins‑‑dump‑builtins Implies --dump, but also dumps IDL defined by the compiler.  
    --just-dump-builtins‑‑just‑dump‑builtins Dumps IDL defined by the compiler but ignores any files passed and exits.  
    -Dmacro_definition
    ‑Dmacro_definition It is passed to the preprocessor  
    -Umacro_name
    ‑Umacro_name It is passed to the preprocessor  
    -Iinclude_path
    ‑Iinclude_path It is passed to the preprocessor  
    -Aassertion
    ‑Aassertion It is passed to the preprocessor  
    -Yp,path
    ‑Yp,path Specifies the path for the C preprocessor  
    -H perfect_hash
    ‑H perfect_hash To specify the IDL compiler to generate skeleton code that uses perfect hashed operation demuxing strategy, which is the default strategy. Perfect @@ -646,24 +681,24 @@

    TAO's IDL Compiler Options

     
    -H dynamic_hash
    ‑H dynamic_hash To specify the IDL compiler to generate skeleton code that uses dynamic hashed operation demuxing strategy.   
    -H binary_search
    -H linear_search
    -in
    ‑in To generate #include statements with <>'s for the standard include files (e.g. tao/corba.h) indicating them as non-changing files
    -ic
    ‑ic To generate #include statements with ""s for changing standard include files (e.g. tao/corba.h).  
    -g path
    ‑g path To specify the path for the perfect hashing program (GPERF). Default is $ACE_ROOT/bin/ace_gperf.   
    -iC path
    ‑iC path Generate #included stubs in *A.h prefixed with this path. Default is local filename only (no prefix). 
    -o path
    ‑o path To specify the output directory to IDL compiler as to where all the IDL-compiler-generated files are to be put. By default, all the files are @@ -712,86 +747,86 @@

    TAO's IDL Compiler Options

    itself already exists, no action is taken. 
    -oS path
    ‑oS path Same as -o option but applies only to generated *S.* files  Default is value of -o option or current directory 
    -oA path
    ‑oA path Same as -o option but applies only to generated *A.* files  Default is value of -o option or current directory 
    -oE path
    ‑oE path Same as -o option but applies only to generated *_exec.* files  Default is value of -o option or current directory 
    -oN path
    ‑oN path Do not overwrite *_exec.* files  When -Gex option is used, executor implementation files shouldn't be overwritten if they are already in the output directory. 
    -hc
    ‑hc Client's header file name ending. Default is "C.h".  
    -hs
    ‑hs Server's header file name ending. Default is "S.h".  
    -hT
    ‑hT Server's template header file name ending. Default is "S_T.h".  
    -cs
    ‑cs Client stub's file name ending. Default is "C.cpp".  
    -ci
    ‑ci Client inline file name ending. Default is "C.inl".  
    -ss
    ‑ss Server skeleton file name ending. Default is "S.cpp".  
    -sT
    ‑sT Server template skeleton file name ending. Default is "S_T.cpp".  
    -t
    ‑t Temporary directory to be used by the IDL compiler.
    -Cw
    ‑Cw Output a warning if two identifiers in the same scope differ in spelling only by case (default is output of error message).
    -Ce
    ‑Ce Output an error if two identifiers in the same scope differ in spelling only by case (default).  
    -ae
    ‑ae Output an error if an anonymous type is seen. Anonymous types are deprecated by the OMG spec (default is no output). This behavior can be selected globally by defining IDL_ANON_ERROR in config.h. It may then be overridden locally by - -aw or -as
    -aw
    ‑aw Output a warning if an anonymous type is seen. Anonymous types are deprecated by the OMG spec (default is no output). This behavior can be selected globally by defining IDL_ANON_WARNING in config.h. It may then be overridden locally by - -ae or -as
    -as
    ‑as Silence any diagnostic output for anonymous types (default). This behavior can be selected globally by defining IDL_ANON_SILENT in config.h. It may then be overridden locally by - -aw or -ae
    -GC
    ‑GC Generate AMI stubs ("sendc_" methods, reply handler stubs, etc)  
    -GH
    ‑GH Generate AMH stubs, skeletons, exception holders, etc.  
    -GM
    ‑GM Generate AMI4CCM code *A.idl file (containing callback interface, "sendc_" methods and CCM connector) plus addition to CCM servant and executor
    -Gp
    ‑Gp Generated collocated stubs that use Thru_POA collocation strategy (default)  
    -Gd
    ‑Gd Generated collocated stubs that use Direct collocation strategy  
    -Gce
    ‑Gce Generated code for CORBA/e. This reduces the size of the generated code  
    -Gmc
    ‑Gmc Generated code for Minimum CORBA. This reduces the size of the generated code  
    -Gcl
    ‑Gcl Generated code for LwCCM. This reduces the size of the generated code  
    -Gsp
    ‑Gsp Generate client smart proxies  
    -Gt
    ‑Gt Generate optimized TypeCodes  
    -GX
    ‑GX Generate empty A.h file Used by TAO developers for generating an empty A.h file when the @@ -934,8 +969,8 @@

    TAO's IDL Compiler Options

    -Guc
    ‑Guc Generate uninlined constant if defined in a module Inlined (assigned a value in the C++ header file) by default, but this causes a @@ -944,16 +979,16 @@

    TAO's IDL Compiler Options

    or a valuetype never are - neither case is affected by this option.
    -Gsd
    ‑Gsd Generate static description operations Generate static description operations to retrieve the repository id or interface name as string. Can be useful for template programming
    -Gse
    ‑Gse Generate explicit export of sequence's template base class Occasionally needed as a workaround for a bug in Visual Studio @@ -962,71 +997,71 @@

    TAO's IDL Compiler Options

    -GI‑GI Generate boiler-plate files that contain empty servant implementations  
    -GIh arg‑GIh arg Servant implementation header file name ending  
    -GIs arg‑GIs arg Servant implementation skeleton file name ending  
    -GIb arg‑GIb arg Prefix to the implementation class names  
    -GIe arg‑GIe arg Suffix to the implementation class names  
    -GIc‑GIc Generate copy constructors in the servant implementation template files  
    -GIa‑GIa Generate assignment operators in the servant implementation template files  
    -GId‑GId Generate IDL compiler source file/line# debug info in implementation files  
    -GT
    ‑GT Enable generation of the TIE classes, and the *S_T.* files that contain them.  
    -GA
    ‑GA Generate type codes and Any operators in *A.h and *A.cpp Decouples client and server decisions to compile and link @@ -1035,21 +1070,21 @@

    TAO's IDL Compiler Options

    an empty *A.h file is generated.
    -Gos
    ‑Gos Generate std::ostream insertion operators for IDL declarations ORB IDL declarations (including the basic type sequences) don't have these operators generated by default, to avoid the increased footprint. To turn on this generation for ORB IDL files, set - gen_ostream=1 in your default.features MPC file. + gen_ostream=1 in your default.features MPC file. If this option is used on application IDL that references any of the predefined basic sequence IDL types, TAO must be compiled - with the gen_ostream feature turned on.
    -Gata
    ‑Gata Generate the AnyTypeCode_Adapter version of the Any insert policy When generating arg traits instantiations, this option forces @@ -1062,14 +1097,16 @@

    TAO's IDL Compiler Options

    application IDL processing or not.
    -Gsv
    ‑Gsv Generate CIAO servant code for component and home IDL declarations
    -Gex
    ‑Gex Generate CIAO executor implementation code for component and home IDL declarations @@ -1077,119 +1114,121 @@

    TAO's IDL Compiler Options

    to be filled in by the developer.
    -Gexr
    ‑Gexr Generate CIAO executor implementation code for component and home IDL declarations, including an implementation of the ACE_ReactorWhen applying -Gexr, the TAO IDL compiler will generate an extra method which + When applying ‑Gexr, the TAO IDL compiler will generate an extra method which retrieves the ACE_Reactor from the ORB. One should use this option when an ACE_reactor. In code, use 'this->reactor ()' to get the ACE_Reactor. A CORBA::INTERNAL exception is thrown when the ACE_Reactor cannot be retrieved.
    The goal of this method is to prevent memory leaks.
    -Gcn
    ‑Gcn Generate CIAO connector implementation code for connector IDL declarations Generate a complete implementation for each connector. Specialized at present for DDS connectors.
    -Gts
    ‑Gts Generate DDS type support IDL in a separate IDL file Not used with OpenDDS, since OpenDDS's IDL processor does this already.
    -Glem
    ‑Glem Generate CIAO executor IDL for component and home IDL declarations
    -Gsw
    ‑Gsw Generate CIAO servant code to support component swapping Modify the generated servant code and container file includes to support on-the-fly swapping of components.
    -Gxhst
    ‑Gxhst Generate the stub export header fileThis is the file specified in -Wb,stub_export_include=include_pathThis is the file specified in ‑Wb,stub_export_include=include_path
    -Gxhsk
    ‑Gxhsk Generate the skeleton export header fileThis is the file specified in -Wb,skel_export_include=include_pathThis is the file specified in ‑Wb,skel_export_include=include_path
    -Gxhsv
    ‑Gxhsv Generate the CIAO servant export header fileThis is the file specified in -Wb,svnt_export_include=include_pathThis is the file specified in ‑Wb,svnt_export_include=include_path
    -Gxhex
    ‑Gxhex Generate the executor export header fileThis is the file specified in -Wb,exec_export_include=include_pathThis is the file specified in ‑Wb,exec_export_include=include_path
    -Gxhcn
    ‑Gxhcn Generate the connector export header fileThis is the file specified in -Wb,conn_export_include=include_pathThis is the file specified in ‑Wb,conn_export_include=include_path
    -Sa
    ‑Sa Suppress generation of the Any operators  
    -Sal
    ‑Sal Suppress generation of the Any operators for local interfaces only  
    -Sat
    ‑Sat Suppress generation of arg traits instantiations  
    -Sp
    ‑Sp Suppress generation of collocated stubs that use Thru_POA collocation strategy  
    -Sd
    ‑Sd Suppress generation of collocated stubs that use Direct collocation strategy (default)  
    -St
    ‑St Suppress generation of typecodes
    -Sm
    ‑Sm Suppress C++ code generation from CCM 'implied' IDL. This code generation is achieved by default using a 'preprocessing' visitor @@ -1209,88 +1248,88 @@

    TAO's IDL Compiler Options

    so this command line option will suppress it.
    -SS
    ‑SS Suppress generation of the skeleton implementation and inline file. This option doesn't check whether something is generated in the files. It just suppresses them without looking at any possible contents;
    -Sci
    ‑Sci Suppress generation of the client inline file. This option doesn't check whether something is generated in the file. It just suppresses it without looking at any possible contents;
    -Scc
    ‑Scc Suppress generation of the client stub file. This option doesn't check whether something is generated in the file. It just suppresses it without looking at any possible contents;
    -Sch
    ‑Sch Suppress generation of the client header file. This option doesn't check whether something is generated in the file. It just suppresses it without looking at any possible contents;
    -Ssi
    ‑Ssi Suppress generation of the servant inline file. This option doesn't check whether something is generated in the file. It just suppresses it without looking at any possible contents;
    -SS
    ‑SS Suppress generation of the servant skeleton file. This option doesn't check whether something is generated in the file. It just suppresses it without looking at any possible contents;
    -Ssh
    ‑Ssh Suppress generation of the servant header file. This option doesn't check whether something is generated in the file. It just suppresses it without looking at any possible contents;
    -Ssvntc
    ‑Ssvntc Suppress generation of the servant implementation file (_svnt.cpp). This option doesn't check whether something is generated in the files. It just suppresses them without looking at any possible contents;
    -Ssvntt
    ‑Ssvntt Suppress generation of the servant templated files (_svnt_T.{h,cpp}). This option doesn't check whether something is generated in the files. It just suppresses them without looking at any possible contents;
    -Sorb
    ‑Sorb Suppress generation of the ORB.h include. This option is useful when regenerating pidl files in the core TAO libs to prevent cyclic includes;
    -Se
    ‑Se Disable custom header file name endings for files that are found in TAO specific include directories @@ -1301,8 +1340,8 @@

    TAO's IDL Compiler Options

    use TAO specific files with their original endings;
    -Sg
    ‑Sg Disable generation of unique preprocessor guards for generated header files. The guards will still be generated, but without @@ -1314,8 +1353,8 @@

    TAO's IDL Compiler Options

    the desired function of the preprocessor in such a system.
    -Sfr
    ‑Sfr Disable CIAO servant code generation to register valuetype factories for events.
    -TS value
    ‑TS value Set tab size for generated files Default is 2 spaces
    --unknown-annotations ARG‑‑unknown‑annotations ARG Controls the reaction when encountering undefined annotations. The valid - arguments to this option are "warn-once" (Default), "warn-all", "error", - and "ignore". + arguments to this option are warn-once (Default), + warn-all, error, and ignore. - The difference between "warn-once" and "warn-all" is that with - "warn-once" using annotations the same local name will not be warned - about more than once, while "warn-all" will warn with every usage. + The difference between warn-once and warn-all + is that with warn-once using annotations the same local name + will not be warned about more than once, while warn-all will + warn with every usage.

    -


    +


    Back to the TAO
    documentation. From 413509358f005e9cc0c513b93d58702a71cd69b4 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Mon, 28 Dec 2020 16:21:29 -0600 Subject: [PATCH 4/8] Added __TAO_IDL_IDL_VERSION Macro --- TAO/NEWS | 5 ++- TAO/TAO_IDL/driver/drv_preproc.cpp | 5 +++ TAO/TAO_IDL/include/idl_version.h | 5 +++ TAO/TAO_IDL/util/idl_version.cpp | 26 +++++++++++++--- TAO/docs/compiler.html | 50 ++++++++++++++++++++++++++++-- 5 files changed, 82 insertions(+), 9 deletions(-) diff --git a/TAO/NEWS b/TAO/NEWS index 7575b8ab9b7c1..ccf08318a5be7 100644 --- a/TAO/NEWS +++ b/TAO/NEWS @@ -4,11 +4,14 @@ USER VISIBLE CHANGES BETWEEN TAO-2.5.12 and TAO-3.0.0 . C++11 is now a mandatory compiler feature which is required for TAO -. TAO_IDL: +. 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. diff --git a/TAO/TAO_IDL/driver/drv_preproc.cpp b/TAO/TAO_IDL/driver/drv_preproc.cpp index 3e02a5c4ac1c6..1f8b7188696c6 100644 --- a/TAO/TAO_IDL/driver/drv_preproc.cpp +++ b/TAO/TAO_IDL/driver/drv_preproc.cpp @@ -582,6 +582,11 @@ DRV_add_include_path (ACE_CString& include_path, void DRV_cpp_post_init () { + char idl_version_arg[128]; + ACE_OS::sprintf (idl_version_arg, "-D__TAO_IDL_IDL_VERSION=%s", + idl_global->idl_version_.to_macro ()); + DRV_cpp_putarg (idl_version_arg); + // Add include path for TAO_ROOT/orbsvcs. char* TAO_ROOT = ACE_OS::getenv ("TAO_ROOT"); diff --git a/TAO/TAO_IDL/include/idl_version.h b/TAO/TAO_IDL/include/idl_version.h index 1659fc745ee6f..261b9f46634fc 100644 --- a/TAO/TAO_IDL/include/idl_version.h +++ b/TAO/TAO_IDL/include/idl_version.h @@ -94,6 +94,11 @@ class TAO_IDL_FE_Export IdlVersion */ void from_string (const char * version); + /** + * Get the value for __TAO_IDL_IDL_VERSION preprocessor macro. + */ + const char * to_macro () const; + /** * Compare a IdlVersion to a SpecificIdlVersion or another IdlVersion */ diff --git a/TAO/TAO_IDL/util/idl_version.cpp b/TAO/TAO_IDL/util/idl_version.cpp index 2ab8a542b24ba..a5499d663e657 100644 --- a/TAO/TAO_IDL/util/idl_version.cpp +++ b/TAO/TAO_IDL/util/idl_version.cpp @@ -7,11 +7,22 @@ #include "ace/OS_NS_string.h" #include "idl_version.h" -static const char * idlVersionNames[IDL_VERSION_COUNT] = { - "Invalid", - "3", - "4" -}; +namespace { + const char * idlVersionNames[IDL_VERSION_COUNT] = { + "Invalid", + "3", + "4" + }; + + /** + * Values for __TAO_IDL_IDL_VERSION. Should work like __TAO_IDL does. + */ + const char * idl_version_macros[IDL_VERSION_COUNT] = { + "0x0", + "0x030000", + "0x040000" + }; +} IdlVersion::IdlVersion () : version_(DEFAULT_DEFAULT_IDL_VERSION) { @@ -58,6 +69,11 @@ void IdlVersion::from_string (const char * version) version_ = IDL_VERSION_INVALID; } +const char * IdlVersion::to_macro () const +{ + return idl_version_macros[version_]; +} + IdlVersion::operator SpecificIdlVersion () const { return version_; diff --git a/TAO/docs/compiler.html b/TAO/docs/compiler.html index c394213f93b3d..2e6cbb0d8f3df 100644 --- a/TAO/docs/compiler.html +++ b/TAO/docs/compiler.html @@ -192,6 +192,45 @@

    Environment Variables

    <orb.idl> when it is included in an IDL file. TAO_IDL will display a warning message when neither is defined.

    +
    +

    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:

    + + + + + + + + + + + + + + + + +
    NameDescription
    __TAO_IDL +

    The version of ACE that tao_idl was built with. The format + is three bytes for each version field in hex format. For example, in TAO + version 3.2.1, which corresponds to ACE version 7.3.1, + __TAO_IDL would be 0x070201.

    + +

    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_VERSIONVersion 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 byte fields in a hex format. For example IDL version 3 is + 0x030000. +
    +

    Operation Demuxing Strategies

    @@ -293,17 +332,22 @@

    TAO's IDL Compiler Options

      - + ‑‑idl‑version VERSION - Set the IDL version to use + Set the IDL version to use. This will be available in IDL as the + __TAO_IDL_IDL_VERSION macro. +   ‑‑default‑idl‑version - Prints the default IDL version for the compiler and exits + Prints the default IDL version for the compiler and exits. This will be + available in IDL as the + __TAO_IDL_IDL_VERSION macro. +   From 5a2f4cdd93c8eeb4f2dab243d8456d3b775224bf Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Mon, 28 Dec 2020 16:33:14 -0600 Subject: [PATCH 5/8] TAO_IDL/driver/drv_args.cpp: --help Make it easier to read and edit by replacing tabs with spaces. --- TAO/TAO_IDL/driver/drv_args.cpp | 68 +++++++++++++++------------------ 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/TAO/TAO_IDL/driver/drv_args.cpp b/TAO/TAO_IDL/driver/drv_args.cpp index 94b811bb67af7..d2937311ce611 100644 --- a/TAO/TAO_IDL/driver/drv_args.cpp +++ b/TAO/TAO_IDL/driver/drv_args.cpp @@ -124,46 +124,38 @@ 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") )); be_util::usage (); From 17dce7375e7ee0b56a9ebdae9612dacb62583c2f Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Mon, 28 Dec 2020 22:12:30 -0600 Subject: [PATCH 6/8] Change How tao_idl Passes Files to Preprocessor Fixes an issue that came up in https://github.com/objectcomputing/OpenDDS/pull/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. --- TAO/NEWS | 5 + TAO/TAO_IDL/driver/drv_args.cpp | 63 ++++- TAO/TAO_IDL/driver/drv_preproc.cpp | 262 ++++++++++++------ TAO/TAO_IDL/include/drv_extern.h | 12 +- TAO/TAO_IDL/include/idl_global.h | 11 + TAO/TAO_IDL/tao_idl.cpp | 10 +- TAO/TAO_IDL/util/utl_global.cpp | 1 + TAO/docs/compiler.html | 47 +++- TAO/tests/IDL_Relative_Include/.gitignore | 5 + .../IDL_Relative_Include.mpc | 6 + TAO/tests/IDL_Relative_Include/README.md | 10 + TAO/tests/IDL_Relative_Include/a/a.idl | 0 TAO/tests/IDL_Relative_Include/a/b/b.idl | 1 + 13 files changed, 332 insertions(+), 101 deletions(-) create mode 100644 TAO/tests/IDL_Relative_Include/.gitignore create mode 100644 TAO/tests/IDL_Relative_Include/IDL_Relative_Include.mpc create mode 100644 TAO/tests/IDL_Relative_Include/README.md create mode 100644 TAO/tests/IDL_Relative_Include/a/a.idl create mode 100644 TAO/tests/IDL_Relative_Include/a/b/b.idl diff --git a/TAO/NEWS b/TAO/NEWS index ccf08318a5be7..85984dbb09848 100644 --- a/TAO/NEWS +++ b/TAO/NEWS @@ -16,6 +16,11 @@ USER VISIBLE CHANGES BETWEEN TAO-2.5.12 and TAO-3.0.0 `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 d2937311ce611..4eb433245461d 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 @@ -156,6 +156,10 @@ DRV_usage () 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 (); @@ -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; @@ -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") @@ -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; @@ -680,7 +684,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] )); } @@ -688,13 +692,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 1f8b7188696c6..2715ca35982e8 100644 --- a/TAO/TAO_IDL/driver/drv_preproc.cpp +++ b/TAO/TAO_IDL/driver/drv_preproc.cpp @@ -87,6 +87,8 @@ trademarks or registered trademarks of Sun Microsystems, Inc. #include "ace/OS_NS_unistd.h" #include "ace/OS_NS_fcntl.h" +#include + // Storage for preprocessor args. unsigned long const DRV_MAX_ARGCOUNT = 1024; unsigned long DRV_argcount = 0; @@ -126,7 +128,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) { @@ -138,6 +140,7 @@ DRV_cpp_putarg (const char *str) throw Bailout (); } + ACE_TCHAR const *insert; if (str && ACE_OS::strchr (str, ' ')) { ACE_TCHAR *buf = nullptr; @@ -147,14 +150,20 @@ DRV_cpp_putarg (const char *str) buf[0] = ACE_TEXT ('"'); ACE_OS::strcpy (buf + 1, ACE_TEXT_CHAR_TO_TCHAR (str)); ACE_OS::strcat (buf, ACE_TEXT ("\"")); - DRV_arglist[DRV_argcount++] = buf; + insert = buf; } } else { - DRV_arglist[DRV_argcount++] = - ACE::strnew (ACE_TEXT_CHAR_TO_TCHAR (str)); + insert = ACE::strnew (ACE_TEXT_CHAR_TO_TCHAR (str)); } + const size_t new_arg_count = DRV_argcount + 1; + if (front) + for (size_t i = 1; i < new_arg_count; ++i) + std::swap(insert, DRV_arglist[i]); + else + DRV_arglist[DRV_argcount] = insert; + DRV_argcount = new_arg_count; } // Expand the output argument with the given filename. @@ -273,9 +282,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 (); @@ -290,7 +297,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'. @@ -300,15 +307,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 { @@ -577,6 +577,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 @@ -587,6 +612,72 @@ DRV_cpp_post_init () idl_global->idl_version_.to_macro ()); DRV_cpp_putarg (idl_version_arg); + // 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"); @@ -908,6 +999,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 @@ -915,7 +1026,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); @@ -947,12 +1058,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); } @@ -1012,21 +1118,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); @@ -1089,22 +1181,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\": %p\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\": %p\n", + idl_global->prog_name (), tmp_ifile)); - throw Bailout (); + throw Bailout (); + } } ACE_HANDLE const tf_fd = ACE_OS::mkstemp (tmp_file); @@ -1116,7 +1209,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 (); } @@ -1126,19 +1219,17 @@ 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) { ACE_ERROR ((LM_ERROR, @@ -1146,15 +1237,23 @@ DRV_pre_proc (const char *myfile) 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; @@ -1172,22 +1271,20 @@ DRV_pre_proc (const char *myfile) ACE_ERROR ((LM_ERROR, ACE_TEXT ("Unable to construct full file pathname\n"))); - (void) ACE_OS::unlink (tmp_ifile); + if (copy) (void) ACE_OS::unlink (tmp_ifile); (void) ACE_OS::unlink (tmp_file); throw Bailout (); } ACE_NEW (utl_string, UTL_String (main_fullpath, true)); - - idl_global->set_main_filename (utl_string); } #else ACE_NEW (utl_string, UTL_String (myfile, true)); +#endif idl_global->set_main_filename (utl_string); -#endif ACE_Auto_String_Free safety (ACE_OS::strdup (myfile)); @@ -1198,8 +1295,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); @@ -1208,7 +1304,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 @@ -1229,7 +1325,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 (); } @@ -1247,12 +1343,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 " @@ -1297,7 +1393,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 (); } @@ -1326,7 +1422,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 (); } @@ -1341,7 +1437,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 (); } } @@ -1362,25 +1458,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 (); } } @@ -1396,7 +1494,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 @@ -1420,7 +1518,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 (); } @@ -1441,7 +1539,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 (); } @@ -1468,7 +1566,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/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 485486a60ddba..2c825e9d58ca0 100644 --- a/TAO/TAO_IDL/include/idl_global.h +++ b/TAO/TAO_IDL/include/idl_global.h @@ -311,6 +311,14 @@ class TAO_IDL_FE_Export IDL_GlobalData UNKNOWN_ANNOTATIONS_IGNORE }; + enum PreprocessorInput { + PreprocessorInputGuess, + PreprocessorInputDirectWithE, + PreprocessorInputDirectWithoutE, + PreprocessorInputDirectGcc, + PreprocessorInputCopy + }; + IDL_GlobalData (); ~IDL_GlobalData (); @@ -892,6 +900,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/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 1c9a20bd53b13..796c89fc38dfd 100644 --- a/TAO/TAO_IDL/util/utl_global.cpp +++ b/TAO/TAO_IDL/util/utl_global.cpp @@ -122,6 +122,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 2e6cbb0d8f3df..1651eb8f60f69 100644 --- a/TAO/docs/compiler.html +++ b/TAO/docs/compiler.html @@ -210,9 +210,9 @@

    IDL Preprocessor Macros

    __TAO_IDL

    The version of ACE that tao_idl was built with. The format - is three bytes for each version field in hex format. For example, in TAO - version 3.2.1, which corresponds to ACE version 7.3.1, - __TAO_IDL would be 0x070201.

    + 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 be 0x070201.

    It's also possible to include tao/Version.h and use the same macros from that header file as you can use in C++.

    @@ -225,8 +225,8 @@

    IDL Preprocessor Macros

    --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 byte fields in a hex format. For example IDL version 3 is - 0x030000. + which is three one-byte fields in a hex format. For example IDL version 3 + is 0x030000. @@ -1432,6 +1432,43 @@

    TAO's IDL Compiler Options

    + + ‑‑preprocessor‑input KIND + + +

    Set the C preprocessor file input method. KIND must be + guess (default), direct‑with‑e, + direct‑without‑e, direct‑gcc, + or copy.

    + +

    direct-without-e passes the IDL file path to the + preprocessor directly. Most, if not all, standalone C preprocessors like + GNU and Clang cpp or mcpp can use this.

    + +

    direct-with-e is the same as + direct-without-e except ‑E is also + passed. CL, the Visual Studio C++ compiler can use this.

    + +

    direct‑gcc is same as + direct‑with‑e, but it's for g++ and + clang++ which also require ‑x c++ to be + passed.

    + +

    copy makes a copy of the IDL file to a temporary location + and passes that to the preprocessor.

    + +

    guess picks one of the previous based on the name of the + preprocessor.

    + + + + Although copy should work with all compilers, it only + approximates relative includes using ‑I., which fails under + certain conditions. Therefore the direct kinds are preferred by + guess. + + +


    diff --git a/TAO/tests/IDL_Relative_Include/.gitignore b/TAO/tests/IDL_Relative_Include/.gitignore new file mode 100644 index 0000000000000..68e911a00a9d6 --- /dev/null +++ b/TAO/tests/IDL_Relative_Include/.gitignore @@ -0,0 +1,5 @@ +/bC.cpp +/bC.inl +/bC.h +/bS.cpp +/bS.h diff --git a/TAO/tests/IDL_Relative_Include/IDL_Relative_Include.mpc b/TAO/tests/IDL_Relative_Include/IDL_Relative_Include.mpc new file mode 100644 index 0000000000000..5eadc7ab2e94d --- /dev/null +++ b/TAO/tests/IDL_Relative_Include/IDL_Relative_Include.mpc @@ -0,0 +1,6 @@ +project(*): taoidldefaults { + custom_only = 1 + IDL_Files { + a/b/b.idl + } +} diff --git a/TAO/tests/IDL_Relative_Include/README.md b/TAO/tests/IDL_Relative_Include/README.md new file mode 100644 index 0000000000000..5f95a37fc4a77 --- /dev/null +++ b/TAO/tests/IDL_Relative_Include/README.md @@ -0,0 +1,10 @@ +# IDL Relative Include Test + +Like with C/C++, `#include ""` should be able to be used with `tao_idl` to +include a path relative to the including file. If the `tao_idl` falls back to +`‑‑preprocessor‑input copy`, then this test will fail. If it does then this +shouldn't affect normal usage of TAO, but `tao_idl` should be updated for the +failing case so that it can pass the IDL file directly to the preprocessor. + +See `‑‑preprocessor‑input` in `TAO/docs/compiler.html` and `DRV_cpp_post_init` +in `TAO/TAO_IDL/driver/drv_preproc.cpp` for more information. diff --git a/TAO/tests/IDL_Relative_Include/a/a.idl b/TAO/tests/IDL_Relative_Include/a/a.idl new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/TAO/tests/IDL_Relative_Include/a/b/b.idl b/TAO/tests/IDL_Relative_Include/a/b/b.idl new file mode 100644 index 0000000000000..432a35e1b702c --- /dev/null +++ b/TAO/tests/IDL_Relative_Include/a/b/b.idl @@ -0,0 +1 @@ +#include "../a.idl" From 75dea65c11d93184f495e7499386f07301a08888 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Mon, 28 Dec 2020 22:42:28 -0600 Subject: [PATCH 7/8] Make fuzz.pl Happy --- TAO/tests/IDL_Relative_Include/a/a.idl | 1 + 1 file changed, 1 insertion(+) diff --git a/TAO/tests/IDL_Relative_Include/a/a.idl b/TAO/tests/IDL_Relative_Include/a/a.idl index e69de29bb2d1d..f845fd17624f4 100644 --- a/TAO/tests/IDL_Relative_Include/a/a.idl +++ b/TAO/tests/IDL_Relative_Include/a/a.idl @@ -0,0 +1 @@ +// Empty File From 9ffdaa2f65f252c699188b362b0db44c14835c7c Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Mon, 28 Dec 2020 23:02:49 -0600 Subject: [PATCH 8/8] Add Possible Missing Include --- TAO/TAO_IDL/driver/drv_preproc.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/TAO/TAO_IDL/driver/drv_preproc.cpp b/TAO/TAO_IDL/driver/drv_preproc.cpp index 2715ca35982e8..b4f33fa210fd1 100644 --- a/TAO/TAO_IDL/driver/drv_preproc.cpp +++ b/TAO/TAO_IDL/driver/drv_preproc.cpp @@ -86,6 +86,7 @@ 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