How code is generated

When you build an application from a Business Application diagram, the build rules define the various files that are input into the Code Generation Engine and the application code files that are output.


This figure is a flow diagram BA Diagrams flowing to XML files flowing to Code Generation Engine flowing to 4gl Application code. Tcl, XSL, and Python templates are also input into the Code Generation Engine.

Figure 1. Code Generation flow

BAM Consolidates and Generates

Data Consolidation
The input from the BA diagram and related entities is gathered into a single XML file, which consolidates all the inputs into one package. This file is used when processing and generating the application code. This file could also be used to provide input to create the application models.
Code Generation
The XML file and a code template are used to generate the application code. The default Tcl template produces Genero 4gl files, but another tool could be used to generate the code (XSL translator for example). Custom code is preserved; if any custom code was created earlier, it is automatically restored in the newly generated application code.

Example

The build rules define the series of commands used to build and generate the code. In general, the Build rule for code generation:

View default build rules selecting Projects >> Edit Build Rules. This example shows the build rules used to generate the code for a Program entity in the Business Application diagram.

Screenshot showing default build rule for a 4PRG program entity.

Figure 2. Default build rule for a generated program entity

Table 1. Default build rule example
Build rule command Description
$(generate) The $(generate) command creates an intermediary XML file from modeled entities.
$(blockpoint) -code BLOCK/POINT is extracted from previously generated and modified code.
tclsh The tclsh executable generates the final file by using both a Tcl template file and the intermediary XML file crated by the $(generate) command.
$(blockpoint) -storeGenerated Extracted BLOCK/POINT code is put back into the generated code.
$(fglcomp) The fglcomp tool compiles BDL program sources files into a p-code version.
$(move) Moves the given file or directory to the given destination in a platform independent way.

Reviewing the Build

To better understand what is happening during the build of the program, turn on verbose mode using Tools >> Preferences, Compiler and Runtime, Compilation Configuration. Compile a diagram file, program, or application and view the results in the output.