Nokia Networks Home

Nokia nmake Product Builder

Quick Links

Related Products

Building C++ code from IDL

nmake release lu3.5 introduced partial support for building IDL code. The base rules include a default scan rule for the IDL language in order to scan for include files. However, there is no rule provided to actually build the IDL code. A build rule is not included because the rule is project dependent and may very depending on the needs of the project and the IDL compiler being used.

In general, building IDL code includes the following steps:

  1. Scan the IDL code for implicit prerequisites (include files)
  2. Set the IDL flags
  3. Compile the IDL files to generate C++ source code
  4. Compile the C++ code

1. Scanning IDL code

nmake release lu3.5 includes a default IDL scan rule called .SCAN.idl. If the IDL files end with the suffix .idl, then the files will be scanned when necessary. If the files end with another suffix then they must be associated with the scan rule. Use the following line if you have IDL files with a suffix other than .idl (not including header files).

    .ATTRIBUTE.%.suffix : .SCAN.idl

Use .SOURCE.idl to define what directories to search for .idl files, including include files.

    .SOURCE.idl : $(VROOT)/src/idl $(VROOT)/include/idl

You may need to consider using the new quoteinclude feature of release lu3.5, which allows the integration of tools that do not support -I- for referencing include files in the viewpath. By setting quoteinclude=[1|2|3], nmake will emit a warning or error when a #include "..." directive is detected inside the viewpath, allowing the project to enforce the exclusive use of #include <...> directives which do not require -I- for viewpath support. Versions of Iona's IDL compiler prior to Orbix 2000 do not support -I- and there is no reliable way to preprocess IDL code using the nmake supplied preprocessor. For such cases, quoteinclude is the only reasonable way to reliably use the the compiler in a viewpathing environment. Otherwise the wrong header files can easily be picked up in the viewpath. See also the Orbix 2000 FAQ to learn how to take advantage of its -I- support.

To use the quoteinclude feature set quoteinclude to the desired error level as shown below.

    quoteinclude = 2

2. Setting the IDL flags

Because nmake is scanning the code for include files it can also generate -I flags for the IDL compiler. Set IDLFLAGS as shown below. Use = or += to set the project default flags and &= with the .INCLUDE. function for the generated -I flags. Adjust the default flags as necessary for your project.

    IDLFLAGS = -A -B
    IDLFLAGS &= $$(.INCLUDE. idl -I -I-)

3. Compiling IDL code

The user must define an IDL rule appropriate for their project. The following metarule template can be used; adjust it as necessary. With this metarule, fileC.C, fileS.C and file.hh are generated from file.idl.

    (IDL) (IDLFLAGS) : .PARAMETER

    %C.C %S.C %.hh : %.idl (IDL) (IDLFLAGS) .TERMINAL
    		$(IDL) $(IDLFLAGS) $(>)

Note, the targets on the LHS (%C.C, %S.C, and %.hh) must accurately reflect all the files being generated by the IDL compiler. If a file is generated but has no corresponding metarule target then nmake will not be able to trigger the rule's action when that file is needed, and nmake may also have trouble locating the file when it is generated as a consequence of another target.

4. Compiling C++ code

Rules for compiling C++ are already included in all versions of nmake.

Finally, there should be some assertion that causes your rules to be triggered. For example:

    app :: app.C fileC.C
    appsvr :: appsvr.C fileS.C

In this example, when app is made the IDL rule will be triggered to generate fileC.C from file.idl. This action also generates fileS.C, so the resulting fileS.C will be used and not regenerated, for making appsvr. The default C/C++ rules will take care of compiling the generated .C files to make app and appsvr.

Example

Here is a simple example showing the above elements in action.

Contents of global.mk:

    CC = CC
    IDL = idl

    IDLFLAGS = -A -B
    IDLFLAGS &= $$(.INCLUDE. idl -I -I-)

    .SOURCE.idl : $(VROOT)/idl $(VROOT)/include/idl

    (IDL) (IDLFLAGS) : .PARAMETER

    %C.C %S.C %.hh : %.idl (IDL) (IDLFLAGS) .TERMINAL
	    $(IDL) $(IDLFLAGS) $(>)

Contents of Makefile

    :ALL:
    app :: app.C fileC.C
    appsvr :: appsvr.C fileS.C

Output

    $ nmake -g global.mk
    + CC -O -I- -c app.C
    + idl -A -B -I../include/idl -I- -I../idl file.idl
    + CC -O -I. -I- -c fileC.C
    + CC -O -I. -I- -I. -o app app.o fileC.o
    + CC -O -I- -c appsvr.C
    + CC -O -I. -I- -c fileS.C
    + CC -O -I. -I- -I. -o appsvr appsvr.o fileS.o
Last Update: Friday,12-Aug-2016 10:45:57 EDT