7.6. Building With Multiple Languages

By default, the WRS builder will compile any C, C++, and Assembly language source files found in the source directories of a Workbench project. All directories are considered source directories, including those added after project creation, whenever the project builder is invoked.

By default, the Ada builder will only compile Ada files. It will not process any of those other languages’ source files. However, the Ada builder can be made to compile those files by changing the content of the GNAT project file (the “gpr file”). Specifically, you must specify those languages in the Languages attribute and, in addition, specify the containing source directories in the Source_Dirs attribute of the project file.

Having both builders process these source files is obviously not desirable. Therefore, when using the Ada builder to compile those other languages’ files, you should prevent the WRS builder from doing so. This processing can be prevented by controlling which directories are recognized as source directories by the WRS builder.

Users can control which directories are so recognized by editing the “Build Targets” content. By default, all directories are considered source directories because the Build Targets content specifies the root directory with the “recursive” flag enabled. Specific directories can instead be named as source directories by removing this default content and specifying the intended individual directories explicitly. Directory trees can be specified by enabling the “recursive” flag for those directory tree roots. See the Wind River documentation for editing the Build Targets.

Note that the Builder Targets content does not specify Ada source directories. These directories are to be specified in the GNAT project file, as usual.

7.6.2. Using GNATPRO C Compiler

The C code can be compiled using GNATPRO C Compiler instead of Wind River GNU/Diab Compilers.

It is currently limited to vxworks-6.x platforms Please read GNAT User?s Guide Supplement for Cross Platforms to check if your installed GNATPRO toolchain supports it.

To activate, the “–config=c,,,,GCC_Pro” switch should replace existing config switch for C language.

See below a makefile example.

# To compile C code with GNATPRO C Compiler instead of Wind River GNU/Diab C Comp?lers
# uncomment the following line.
#USE_GNATPRO_C_COMPILER=True
ifeq (True,$(USE_GNAT_C_COMPILER))
CONFIG_C=–config=c,,,,GCC_Pro
else
CONFIG_C=–config=c,,$(RUNTIME),

endif

# Configure Ada and C tools for gprbuild. We want to generate this file # before each build in case the user makes a different build spec active. # The RUNTIME value could not change in that case, but the PLATFORM value # could change. $(CONFIG_FILE) : FORCE

@echo “building $(PROJECT_OBJ_DIR)/$(GPRBUILD_OBJECT_NAME)” $(TRACE_FLAG)if [ ! -d $(PROJECT_OBJ_DIR) ]; then mkdir -p $(PROJECT_OBJ_DIR); fi $(TRACE_FLAG)gprconfig $(QUIET) –target=$(PLATFORM)

–config=ada,,$(RUNTIME), $(CONFIG_C) –config=c++,,$(RUNTIME), –config=asm,,, –batch -o $(CONFIG_FILE)

gnat.makefile generated by GNATbench-17.0 or later contains a commented USE_GNATPRO_C_COMPILER variable definition. Uncomment it to active GNATPRO C Compiler use.